修改字典新增编辑规则
This commit is contained in:
@@ -53,7 +53,7 @@
|
|||||||
<a-drawer
|
<a-drawer
|
||||||
:width="600"
|
:width="600"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:title="updateInfo.id ? '编辑' : '新增'"
|
:title="updateInfo && updateInfo.id ? '编辑' : '新增'"
|
||||||
:body-style="{ paddingBottom: '80px' }"
|
:body-style="{ paddingBottom: '80px' }"
|
||||||
:footer-style="{ textAlign: 'right' }"
|
:footer-style="{ textAlign: 'right' }"
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onMounted, defineOptions } from 'vue';
|
import { ref, onMounted, defineOptions } from 'vue';
|
||||||
import { http } from '/nerv-lib/util/http';
|
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 { tableColumns } from './config';
|
||||||
import { dict } from '/@/api/dict';
|
import { dict } from '/@/api/dict';
|
||||||
import { NsMessage } from '/nerv-lib/component';
|
import { NsMessage } from '/nerv-lib/component';
|
||||||
@@ -140,6 +140,7 @@
|
|||||||
|
|
||||||
const data = ref([]);
|
const data = ref([]);
|
||||||
const updateInfo = ref({});
|
const updateInfo = ref({});
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
grp: '',
|
grp: '',
|
||||||
@@ -176,9 +177,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const formState = ref({
|
// const formState = ref({
|
||||||
orgId: orgId.value,
|
// orgId: orgId.value,
|
||||||
});
|
// });
|
||||||
const labelCol = { span: 5 };
|
const labelCol = { span: 5 };
|
||||||
const wrapperCol = { span: 19 };
|
const wrapperCol = { span: 19 };
|
||||||
// 定义form表单的必填
|
// 定义form表单的必填
|
||||||
@@ -190,25 +191,25 @@
|
|||||||
seq: [{ required: true, message: '请输入排序数字', trigger: 'change' }],
|
seq: [{ required: true, message: '请输入排序数字', trigger: 'change' }],
|
||||||
showed: [{ required: true, message: '请输入是否展示', trigger: 'change' }],
|
showed: [{ required: true, message: '请输入是否展示', trigger: 'change' }],
|
||||||
};
|
};
|
||||||
interface FormState {
|
// interface FormState {
|
||||||
energyType: string;
|
// energyType: string;
|
||||||
unit: string;
|
// unit: string;
|
||||||
collectionNode: string;
|
// collectionNode: string;
|
||||||
emissionType: string | undefined;
|
// emissionType: string | undefined;
|
||||||
isComputeCarbon: string;
|
// isComputeCarbon: string;
|
||||||
janFlag: string;
|
// janFlag: string;
|
||||||
febFlag: string;
|
// febFlag: string;
|
||||||
marFlag: string;
|
// marFlag: string;
|
||||||
aprFlag: string;
|
// aprFlag: string;
|
||||||
mayFlag: string;
|
// mayFlag: string;
|
||||||
junFlag: string;
|
// junFlag: string;
|
||||||
julFlag: string;
|
// julFlag: string;
|
||||||
augFlag: string;
|
// augFlag: string;
|
||||||
sepFlag: string;
|
// sepFlag: string;
|
||||||
octFlag: string;
|
// octFlag: string;
|
||||||
novFlag: string;
|
// novFlag: string;
|
||||||
decFlag: string;
|
// decFlag: string;
|
||||||
}
|
// }
|
||||||
// 关闭新增抽屉
|
// 关闭新增抽屉
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
@@ -226,29 +227,42 @@
|
|||||||
// 打开新增页
|
// 打开新增页
|
||||||
const addDict = () => {
|
const addDict = () => {
|
||||||
updateInfo.value = {};
|
updateInfo.value = {};
|
||||||
|
updateInfo.value.showed = 1;
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
// todo 打开编辑页
|
// todo 打开编辑页
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击确定提交
|
// 点击确定提交
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if (updateInfo.value.id) {
|
debugger;
|
||||||
fetch(dict.updateDictionary, updateInfo.value).then((res) => {
|
formRef.value
|
||||||
if (res.retcode == 0) {
|
?.validate()
|
||||||
visible.value = false;
|
.then((valid) => {
|
||||||
NsMessage.success('保存成功');
|
if (valid) {
|
||||||
getTableList();
|
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);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
fetch(dict.createDictionary, updateInfo.value).then((res) => {
|
|
||||||
if (res.retcode == 0) {
|
|
||||||
visible.value = false;
|
|
||||||
NsMessage.success('保存成功');
|
|
||||||
getTableList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除字典
|
// 删除字典
|
||||||
|
Reference in New Issue
Block a user