厂商调整

This commit is contained in:
dong 2023-11-13 11:23:27 +08:00
parent 003557a2fa
commit cd4701b55d
4 changed files with 59 additions and 13 deletions

View File

@ -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 },
];

View File

@ -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;
});
</script>

View File

@ -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, '获取厂家列表失败!');
});
}
</script>

View File

@ -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, '获取厂家列表失败!');
});
}
</script>