微调
This commit is contained in:
@@ -33,8 +33,8 @@
|
||||
import { addDictTree, updateDictTree } from '@/api/system/dictionary/dictTree'
|
||||
import { computed, type Ref, ref } from 'vue';
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type ResultData } from '@/api/interface';
|
||||
const dictStore = useDictStore()
|
||||
const selectedStatMethods = ref<string[]>([])
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
function useMetaInfo() {
|
||||
@@ -48,7 +48,7 @@
|
||||
code: ' ',
|
||||
sort: 100,
|
||||
remark: '',
|
||||
status: 1,
|
||||
state: 0,
|
||||
children: [],
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
@@ -59,13 +59,13 @@
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
pid: '0',
|
||||
pids: '0',
|
||||
name: '',
|
||||
code: ' ',
|
||||
sort: 100,
|
||||
remark: '',
|
||||
status: 1,
|
||||
state: 0,
|
||||
children: [],
|
||||
}
|
||||
}
|
||||
@@ -76,8 +76,8 @@
|
||||
|
||||
// 定义表单校验规则
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
dataType: [{ required: true, message: '数据模型必选!', trigger: 'change' }],
|
||||
name: [{ required: true, message: '指标名称必填!', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '字典名称必填!', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '编码必填!', trigger: 'blur' }],
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
@@ -87,7 +87,6 @@
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
selectedStatMethods.value = []
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
@@ -96,13 +95,18 @@
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (formContent.value.id) {
|
||||
const result = await updateDictTree(formContent.value);
|
||||
let result: ResultData<unknown>;
|
||||
if( titleType.value == 'add'){
|
||||
result = await addDictTree(formContent.value);
|
||||
}else{
|
||||
result = await updateDictTree(formContent.value);
|
||||
}
|
||||
|
||||
if(result.code != 'A0000'){
|
||||
ElMessage.error({ message: result.message})
|
||||
}else{
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
}
|
||||
|
||||
} else {
|
||||
const result = await addDictTree(formContent.value);
|
||||
if(result.code != 'A0000'){
|
||||
@@ -126,7 +130,12 @@
|
||||
titleType.value = sign
|
||||
dialogVisible.value = true
|
||||
if (data.id) {
|
||||
formContent.value = { ...data }
|
||||
if(sign == 'add'){
|
||||
resetFormContent()
|
||||
formContent.value.pid = data.id
|
||||
}else{
|
||||
formContent.value = { ...data }
|
||||
}
|
||||
} else {
|
||||
resetFormContent()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user