forked from beimingwu/beimingwu
feat(frontend): allow search learnware by id
This commit is contained in:
parent
46d5e6afbd
commit
d6a2e5ac3b
|
@ -1,6 +1,8 @@
|
|||
export default {
|
||||
Search: "Search",
|
||||
ChooseSemanticRequirement: "Choose semantic requirement",
|
||||
SearchById: "Search by id",
|
||||
LearnwareId: "Learnware Id",
|
||||
SearchByName: "Search by name",
|
||||
LearnwareName: "Learnware Name",
|
||||
UploadStatisticalRequirement: "Upload statistical requirement",
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
export default {
|
||||
Search: "查搜",
|
||||
ChooseSemanticRequirement: "选择语义需求",
|
||||
SearchById: "按ID查找",
|
||||
LearnwareId: "学件ID",
|
||||
SearchByName: "按名称查找",
|
||||
LearnwareName: "学件名称",
|
||||
UploadStatisticalRequirement: "上传统计需求",
|
||||
|
|
|
@ -22,6 +22,7 @@ export interface Props {
|
|||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
filters: () => ({
|
||||
id: "",
|
||||
name: "",
|
||||
dataType: "",
|
||||
taskType: "",
|
||||
|
|
|
@ -24,6 +24,7 @@ export interface Props {
|
|||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
filters: () => ({
|
||||
id: "",
|
||||
name: "",
|
||||
dataType: "",
|
||||
taskType: "",
|
||||
|
|
|
@ -33,6 +33,7 @@ const { t } = useI18n();
|
|||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
filters: () => ({
|
||||
id: "",
|
||||
name: "",
|
||||
dataType: "",
|
||||
taskType: "",
|
||||
|
|
|
@ -26,6 +26,7 @@ const emit = defineEmits(["click:edit", "click:delete", "pageChange"]);
|
|||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
filters: () => ({
|
||||
id: "",
|
||||
name: "",
|
||||
dataType: "",
|
||||
taskType: "",
|
||||
|
|
|
@ -7,21 +7,24 @@ import TaskTypeBtns from "../Specification/SpecTag/TaskType.vue";
|
|||
import LibraryTypeBtns from "../Specification/SpecTag/LibraryType.vue";
|
||||
import FileUpload from "../Specification/FileUpload.vue";
|
||||
import ScenarioListBtns from "../Specification/SpecTag/ScenarioList.vue";
|
||||
import type { DataType, TaskType, LibraryType } from "@beiming-system/types/learnware";
|
||||
import type { DataType, TaskType, LibraryType, Filter } from "@beiming-system/types/learnware";
|
||||
|
||||
export interface Props {
|
||||
modelValue: Filter;
|
||||
isAdmin?: boolean;
|
||||
}
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const emits = defineEmits(["update:value"]);
|
||||
const emits = defineEmits(["update:modelValue"]);
|
||||
|
||||
defineProps({
|
||||
value: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
withDefaults(defineProps<Props>(), {
|
||||
isAdmin: false,
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const id = ref(route.query.id || "");
|
||||
const search = ref(route.query.search || "");
|
||||
const dataType = ref<DataType | "">((route.query.dataType?.toString() as DataType) || "");
|
||||
const taskType = ref<TaskType | "">((route.query.taskType?.toString() as TaskType) || "");
|
||||
|
@ -39,6 +42,7 @@ const scenarioList = ref(tryScenarioList);
|
|||
const files = ref([]);
|
||||
|
||||
const requirement = computed(() => ({
|
||||
id: id.value,
|
||||
name: search.value,
|
||||
dataType: dataType.value,
|
||||
taskType: taskType.value,
|
||||
|
@ -50,7 +54,7 @@ const requirement = computed(() => ({
|
|||
watch(
|
||||
() => requirement.value,
|
||||
() => {
|
||||
emits("update:value", requirement.value);
|
||||
emits("update:modelValue", requirement.value);
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
@ -64,6 +68,19 @@ watch(
|
|||
{{ t("Search.ChooseSemanticRequirement") }}
|
||||
</div>
|
||||
|
||||
<div v-if="isAdmin">
|
||||
<div class="mt-7 mb-3 text-h6 !text-base">
|
||||
{{ t("Search.SearchById") }}
|
||||
</div>
|
||||
<v-text-field
|
||||
v-model="id"
|
||||
:label="t('Search.LearnwareId')"
|
||||
hide-details
|
||||
append-inner-icon="mdi-close"
|
||||
@click:append-inner="id = ''"
|
||||
></v-text-field>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mt-7 mb-3 text-h6 !text-base">
|
||||
{{ t("Search.SearchByName") }}
|
||||
|
|
|
@ -36,6 +36,7 @@ function getSemanticSpecification(): Promise<{
|
|||
}
|
||||
|
||||
function searchLearnware({
|
||||
id,
|
||||
name,
|
||||
dataType,
|
||||
taskType,
|
||||
|
@ -47,6 +48,7 @@ function searchLearnware({
|
|||
page,
|
||||
limit,
|
||||
}: {
|
||||
id: string;
|
||||
name: Name;
|
||||
dataType: DataType | "";
|
||||
taskType: TaskType | "";
|
||||
|
@ -78,6 +80,9 @@ function searchLearnware({
|
|||
semanticSpec.Description.Values = "";
|
||||
|
||||
const fd = new FormData();
|
||||
if (id) {
|
||||
fd.append("learnware_id", id);
|
||||
}
|
||||
fd.append("semantic_specification", JSON.stringify(semanticSpec));
|
||||
fd.append("statistical_specification", (files.length > 0 && files[0]) || "");
|
||||
fd.append("heterogeneous_mode", String(heterogeneousMode));
|
||||
|
|
|
@ -28,6 +28,7 @@ const router = useRouter();
|
|||
const { t } = useI18n();
|
||||
|
||||
const filters = ref<Filter>({
|
||||
id: "",
|
||||
name: "",
|
||||
dataType: "",
|
||||
taskType: "",
|
||||
|
@ -87,6 +88,7 @@ function fetchByFilterAndPage(
|
|||
loading.value = true;
|
||||
|
||||
searchLearnware({
|
||||
id: filters.id,
|
||||
name: filters.name,
|
||||
dataType: filters.dataType,
|
||||
taskType: filters.taskType,
|
||||
|
@ -307,9 +309,10 @@ onMounted(() => init());
|
|||
|
||||
<div class="w-full lg:max-w-[460px]">
|
||||
<user-requirement
|
||||
v-model:value="filters"
|
||||
v-model="filters"
|
||||
class="bottom-0 w-full lg:fixed lg:max-w-[460px]"
|
||||
style="top: var(--v-layout-top)"
|
||||
:is-admin="isAdmin"
|
||||
>
|
||||
<template #prepend>
|
||||
<v-btn
|
||||
|
|
|
@ -101,6 +101,7 @@ export interface LearnwareCardInfo extends LearnwareInfo {
|
|||
}
|
||||
|
||||
export interface Filter {
|
||||
id: string;
|
||||
name: Name;
|
||||
dataType: DataType | "";
|
||||
taskType: TaskType | "";
|
||||
|
|
Loading…
Reference in New Issue