From 0fba8917f28981e6a55d3802f7f0d1d191f1c42a Mon Sep 17 00:00:00 2001 From: fks-yangshouda Date: Mon, 22 Jul 2024 10:56:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E5=89=8D=E5=8F=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hx-ai-intelligent/src/api/dict.ts | 6 + hx-ai-intelligent/src/icon/zidian.svg | 1 + hx-ai-intelligent/src/router/dict.ts | 15 ++ hx-ai-intelligent/src/view/dict/config.ts | 51 +++++ hx-ai-intelligent/src/view/dict/index.vue | 302 ++++++++++++++++++++++++++++++ 5 files changed, 375 insertions(+) create mode 100644 hx-ai-intelligent/src/api/dict.ts create mode 100644 hx-ai-intelligent/src/icon/zidian.svg create mode 100644 hx-ai-intelligent/src/router/dict.ts create mode 100644 hx-ai-intelligent/src/view/dict/config.ts create mode 100644 hx-ai-intelligent/src/view/dict/index.vue diff --git a/hx-ai-intelligent/src/api/dict.ts b/hx-ai-intelligent/src/api/dict.ts new file mode 100644 index 0000000..3e5f685 --- /dev/null +++ b/hx-ai-intelligent/src/api/dict.ts @@ -0,0 +1,6 @@ +export enum dict { + dictionaryUnitManagement = '/carbon-smart/client/dict/dictionaryUnitManagement', + updateDictionary = '/carbon-smart/client/dict/updateDictionary', + createDictionary = '/carbon-smart/client/dict/createDictionary', + delDictionary = '/carbon-smart/client/dict/delDictionary', +} diff --git a/hx-ai-intelligent/src/icon/zidian.svg b/hx-ai-intelligent/src/icon/zidian.svg new file mode 100644 index 0000000..8bdc9c9 --- /dev/null +++ b/hx-ai-intelligent/src/icon/zidian.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/hx-ai-intelligent/src/router/dict.ts b/hx-ai-intelligent/src/router/dict.ts new file mode 100644 index 0000000..c34035b --- /dev/null +++ b/hx-ai-intelligent/src/router/dict.ts @@ -0,0 +1,15 @@ +const dict = { + path: '/dict', + name: 'dict', + meta: { title: '字典', icon: 'zidian', index: 7, hideChildren: true }, + redirect: { name: 'dictIndex' }, + children: [ + { + path: 'index', + name: 'dictIndex', + meta: { title: '字典', hideChildren: true, icon: 'zidian' }, + component: () => import('/@/view/dict/index.vue'), + }, + ], +}; +export default dict; diff --git a/hx-ai-intelligent/src/view/dict/config.ts b/hx-ai-intelligent/src/view/dict/config.ts new file mode 100644 index 0000000..898176f --- /dev/null +++ b/hx-ai-intelligent/src/view/dict/config.ts @@ -0,0 +1,51 @@ +export const tableColumns = [ + // { + // title: '序号', + // customRender: (text: any) => { + // return text.index + 1; + // }, + // }, + { + title: 'id', + dataIndex: 'id', + }, + { + title: '字典组名', + dataIndex: 'grp', + }, + { + title: '字典组名描述', + dataIndex: 'grpDesc', + }, + { + title: '字典Key', + dataIndex: 'dicKey', + }, + { + title: '字典中文Value', + dataIndex: 'cnValue', + }, + { + title: '字典英文Value', + dataIndex: 'enValue', + }, + { + title: '字典描述', + dataIndex: 'description', + }, + { + title: '父级ID', + dataIndex: 'parentId', + }, + { + title: '排序数字', + dataIndex: 'seq', + }, + { + title: '是否展示', + dataIndex: 'showed', + }, + { + title: '操作', + }, +]; diff --git a/hx-ai-intelligent/src/view/dict/index.vue b/hx-ai-intelligent/src/view/dict/index.vue new file mode 100644 index 0000000..1a85aac --- /dev/null +++ b/hx-ai-intelligent/src/view/dict/index.vue @@ -0,0 +1,302 @@ + + + + + From 69727fa6134dfa6b80db495d993b1af1709cfdfc Mon Sep 17 00:00:00 2001 From: fks-yangshouda Date: Mon, 22 Jul 2024 11:35:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BC=96=E8=BE=91=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hx-ai-intelligent/src/view/dict/index.vue | 92 ++++++++++++++++++------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/hx-ai-intelligent/src/view/dict/index.vue b/hx-ai-intelligent/src/view/dict/index.vue index 1a85aac..57d69dc 100644 --- a/hx-ai-intelligent/src/view/dict/index.vue +++ b/hx-ai-intelligent/src/view/dict/index.vue @@ -53,7 +53,7 @@ import { ref, onMounted, defineOptions } from 'vue'; import { http } from '/nerv-lib/util/http'; - import type { Rule } from 'ant-design-vue/es/form'; + import type { FormInstance, Rule } from 'ant-design-vue/es/form'; import { tableColumns } from './config'; import { dict } from '/@/api/dict'; import { NsMessage } from '/nerv-lib/component'; @@ -140,6 +140,7 @@ const data = ref([]); const updateInfo = ref({}); + const formRef = ref(null); const queryParams = ref({ grp: '', @@ -176,9 +177,9 @@ }; const visible = ref(false); - const formState = ref({ - orgId: orgId.value, - }); + // const formState = ref({ + // orgId: orgId.value, + // }); const labelCol = { span: 5 }; const wrapperCol = { span: 19 }; // 定义form表单的必填 @@ -190,25 +191,25 @@ seq: [{ required: true, message: '请输入排序数字', trigger: 'change' }], showed: [{ required: true, message: '请输入是否展示', trigger: 'change' }], }; - interface FormState { - energyType: string; - unit: string; - collectionNode: string; - emissionType: string | undefined; - isComputeCarbon: string; - janFlag: string; - febFlag: string; - marFlag: string; - aprFlag: string; - mayFlag: string; - junFlag: string; - julFlag: string; - augFlag: string; - sepFlag: string; - octFlag: string; - novFlag: string; - decFlag: string; - } + // interface FormState { + // energyType: string; + // unit: string; + // collectionNode: string; + // emissionType: string | undefined; + // isComputeCarbon: string; + // janFlag: string; + // febFlag: string; + // marFlag: string; + // aprFlag: string; + // mayFlag: string; + // junFlag: string; + // julFlag: string; + // augFlag: string; + // sepFlag: string; + // octFlag: string; + // novFlag: string; + // decFlag: string; + // } // 关闭新增抽屉 const onClose = () => { visible.value = false; @@ -226,29 +227,42 @@ // 打开新增页 const addDict = () => { updateInfo.value = {}; + updateInfo.value.showed = 1; visible.value = true; // todo 打开编辑页 }; // 点击确定提交 const onSubmit = () => { - if (updateInfo.value.id) { - fetch(dict.updateDictionary, updateInfo.value).then((res) => { - if (res.retcode == 0) { - visible.value = false; - NsMessage.success('保存成功'); - getTableList(); - } - }); - } else { - fetch(dict.createDictionary, updateInfo.value).then((res) => { - if (res.retcode == 0) { - visible.value = false; - NsMessage.success('保存成功'); - getTableList(); + debugger; + formRef.value + ?.validate() + .then((valid) => { + if (valid) { + if (updateInfo.value.id) { + fetch(dict.updateDictionary, updateInfo.value).then((res) => { + if (res.retcode == 0) { + visible.value = false; + NsMessage.success('保存成功'); + getTableList(); + } + }); + } else { + fetch(dict.createDictionary, updateInfo.value).then((res) => { + if (res.retcode == 0) { + visible.value = false; + NsMessage.success('保存成功'); + getTableList(); + } + }); + } + } else { + console.log('表单验证失败'); } + }) + .catch((error) => { + console.log('表单验证失败', error); }); - } }; // 删除字典