diff --git a/src/components/hTable/hTable.ts b/src/components/hTable/hTable.ts index b7598f6..3de9845 100644 --- a/src/components/hTable/hTable.ts +++ b/src/components/hTable/hTable.ts @@ -1,3 +1,5 @@ +import { array } from "vue-types"; + export interface Dialog { /** 对话框是否可见 */ visible: boolean; @@ -380,25 +382,33 @@ export function intTableData(tValue: TableConfig): TableConfig { element.search = { ...new TableColumnSearch(), ...element.search }; element.setting = { ...new FieldSetting(), ...element.setting }; - if ( - element.custom == undefined && - (element.type === "switch" || - element.type === "dropdown" || - element.type === "string" || - element.type === undefined) - ) { - if (element.type === "string" || element.type === undefined) - element.custom = row => row[key]; - else { + //已有的情况下以 传入为主 + if (element.custom != undefined) continue; + switch (element.type) { + case "switch": + case "dropdown": { element.custom = row => { - let sc = element.setting.datasource.find( - s => s[element.setting.mapValue] + "" == row[key] + "" - ); - return !sc ? row[key] : sc[element.setting.maplabel]; + const value = Array.isArray(row[key]) ? row[key] : [row[key]]; + const res = value.map(item => { + const sc = element.setting.datasource.find( + s => s[element.setting.mapValue] + "" == item + "" + ); + return !sc ? item : sc[element.setting.maplabel]; + }); + return res.join(","); }; + break; + } + + case "string": + case undefined: { + element.custom = row => row[key]; + break; + } + default: { + element.custom = row => row[key]; + break; } - } else if (element.custom == undefined) { - element.custom = row => row[key]; } } diff --git a/src/views/school/index.vue b/src/views/school/index.vue index d2d838c..8ece4c7 100644 --- a/src/views/school/index.vue +++ b/src/views/school/index.vue @@ -8,11 +8,11 @@ import { } from "@/components/hTable/hTable"; import { onMounted, ref } from "vue"; import { fa } from "element-plus/es/locales.mjs"; +import { getenum } from "@/api/enum"; defineOptions({ name: "School", }); -onMounted(() => {}); function searchCallback(data) { //let c = data.Conditions.find((s) => s.FieldName == "Pname"); } @@ -22,6 +22,7 @@ const tableData: TableConfig = intTableData({ selectColumn: false, // 列表选择 border: false, // 是否显示表格边框 searchCallback: searchCallback, + editCallback: function (from) {}, search: { // 查询条件 show: true, @@ -74,6 +75,17 @@ const tableData: TableConfig = intTableData({ width: "300px", custom: (row) => `${row.pname}-${row.cname}-${row.rname}`, }, + projectType: { + label: "学校项目", + width: "200px", + type: "dropdown", + search: new TableColumnSearch(true), + edit: { + multiple: true, + + edit: true, + }, + }, enable: { label: "启用", type: "switch", @@ -91,10 +103,18 @@ const tableData: TableConfig = intTableData({ }, selectRows: [], }); +const showTable = ref(false); +onMounted(async () => { + let res = await getenum("SchoolProjectEnum"); + tableData.column.projectType.setting.datasource = res.data; + + //初始化数据完成后显示页面 + showTable.value = true; +});