From cd4701b55db6f6cdb1bd70c0a133333d2c2df920 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Mon, 13 Nov 2023 11:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=82=E5=95=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CategoryType.ts | 6 ------ src/pages/CategoryManage.vue | 18 +++++++++++++++--- src/pages/DraftManage.vue | 24 ++++++++++++++++++++++-- src/pages/PublishManage.vue | 24 ++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/components/CategoryType.ts b/src/components/CategoryType.ts index 567431f..59827be 100644 --- a/src/components/CategoryType.ts +++ b/src/components/CategoryType.ts @@ -3,9 +3,3 @@ export enum CategoryType { TH = 'TH', ZDWX = 'ZDWX', } - -export const categoryTypeOptions = [ - { label: '交控(11)', value: CategoryType.JK }, - { label: '通号(12)', value: CategoryType.TH }, - { label: '浙大网新', value: CategoryType.ZDWX }, -]; diff --git a/src/pages/CategoryManage.vue b/src/pages/CategoryManage.vue index b59712a..fcd1b26 100644 --- a/src/pages/CategoryManage.vue +++ b/src/pages/CategoryManage.vue @@ -116,7 +116,7 @@ import { getCategoryInfo, } from '../api/CategoryInfoApi'; import { ApiError } from 'src/boot/axios'; -import { categoryTypeOptions } from 'src/components/CategoryType'; +import { CategoryType } from 'src/components/CategoryType'; const $q = useQuasar(); @@ -219,7 +219,7 @@ function onCreate() { const params: createParams = { name: editInfo.categoryName, code: editInfo.code, - config: editInfo.config, + config: JSON.stringify(editInfo.config), }; if (editInfo.id) { await saveCategoryData(+editInfo.id, params); @@ -286,7 +286,7 @@ function editData(row: CategoryItem) { editInfo.id = res.id + ''; editInfo.categoryName = res.name; editInfo.code = res.code; - editInfo.config = res.config || ''; + editInfo.config = res.config ? JSON.parse(res.config) : ''; createFormShow.value = true; }) .catch((err) => { @@ -297,4 +297,16 @@ function editData(row: CategoryItem) { }); }); } + +const categoryTypeOptions = computed(() => { + const list: { label: string; value: string }[] = []; + for (let item in CategoryType) { + const obj = { + label: item, + value: CategoryType[item as CategoryType], + }; + list.push(obj); + } + return list; +}); diff --git a/src/pages/DraftManage.vue b/src/pages/DraftManage.vue index edcb992..38b53d4 100644 --- a/src/pages/DraftManage.vue +++ b/src/pages/DraftManage.vue @@ -151,7 +151,7 @@ import { publishDraft } from '../api/PublishApi'; import { ApiError } from 'src/boot/axios'; import { PictureType } from 'src/protos/picture'; import { useRouter } from 'vue-router'; -import { categoryTypeOptions } from 'src/components/CategoryType'; +import { getCategoryList } from 'src/api/CategoryInfoApi'; const $q = useQuasar(); @@ -169,6 +169,7 @@ const tableHeight = computed(() => { const router = useRouter(); onMounted(() => { + getCategoryOptions(); tableRef.value.requestServerInteraction(); }); @@ -365,7 +366,7 @@ const pictureType = ref(PictureType.StationLayout); function categoryName(val?: string) { let n = ''; if (val) { - const find = categoryTypeOptions.find((item) => { + const find = categoryTypeOptions.value.find((item) => { return item.value == val; }); n = find ? find.label : val; @@ -392,4 +393,23 @@ function goToPath(row: DraftItem) { } router.push({ path: path }); } + +const categoryTypeOptions = ref<{ label: string; value: string }[]>([]); +function getCategoryOptions() { + getCategoryList() + .then((res) => { + const arr: { label: string; value: string }[] = []; + res.forEach((item) => { + const obj = { + label: item.name, + value: item.code, + }; + arr.push(obj); + }); + categoryTypeOptions.value = arr; + }) + .catch((err) => { + console.log(err, '获取厂家列表失败!'); + }); +} diff --git a/src/pages/PublishManage.vue b/src/pages/PublishManage.vue index 49552b6..6122be1 100644 --- a/src/pages/PublishManage.vue +++ b/src/pages/PublishManage.vue @@ -99,7 +99,7 @@ import { createSimulation } from 'src/api/Simulation'; import { ApiError } from 'src/boot/axios'; import { useLineStore } from 'src/stores/line-store'; import { MapInfo } from 'src/api/ProjectLinkApi'; -import { categoryTypeOptions } from 'src/components/CategoryType'; +import { getCategoryList } from 'src/api/CategoryInfoApi'; const router = useRouter(); const route = useRoute(); const $q = useQuasar(); @@ -117,6 +117,7 @@ const tableHeight = computed(() => { }); onMounted(() => { + getCategoryOptions(); tableRef.value.requestServerInteraction(); selected.value = props.selects; }); @@ -156,7 +157,7 @@ const columnDefs: QTableColumn[] = [ function categoryName(val?: string) { let n = ''; if (val) { - const find = categoryTypeOptions.find((item) => { + const find = categoryTypeOptions.value.find((item) => { return item.value == val; }); n = find ? find.label : val; @@ -309,4 +310,23 @@ watch( } } ); + +const categoryTypeOptions = ref<{ label: string; value: string }[]>([]); +function getCategoryOptions() { + getCategoryList() + .then((res) => { + const arr: { label: string; value: string }[] = []; + res.forEach((item) => { + const obj = { + label: item.name, + value: item.code, + }; + arr.push(obj); + }); + categoryTypeOptions.value = arr; + }) + .catch((err) => { + console.log(err, '获取厂家列表失败!'); + }); +}