|
|
@ -8,36 +8,36 @@ |
|
|
|
</BasicModal> |
|
|
|
</BasicModal> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
|
|
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
|
|
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
|
|
|
* 采用vben-动态表格表单封装组件编写,采用 setup 写法 |
|
|
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
|
|
* Copyright © 2020-2022 <a href="http://www.entfrm.com/">entfrm</a> All rights reserved. |
|
|
|
* author entfrm开发团队-王翔 |
|
|
|
* author entfrm开发团队-王翔 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
import { ref, unref } from 'vue'; |
|
|
|
import { ref, unref } from 'vue'; |
|
|
|
import { BasicForm, useForm } from '/@/components/Form'; |
|
|
|
import { BasicForm, useForm } from '/@/components/Form'; |
|
|
|
import { formSchema } from './project.data'; |
|
|
|
import { formSchema } from './project.data'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import {listProject, addProject, editProject, getProject} from '/@/api/platform/common/controller/project'; |
|
|
|
import {listProject, addProject, editProject, getProject} from '/@/api/platform/common/controller/project'; |
|
|
|
import { listToTree } from '/@/utils/helper/treeHelper'; |
|
|
|
import { listToTree } from '/@/utils/helper/treeHelper'; |
|
|
|
|
|
|
|
|
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
const tag = ref<Nullable<string>>(''); |
|
|
|
const tag = ref<Nullable<string>>(''); |
|
|
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
|
|
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate, clearValidate }] = useForm({ |
|
|
|
const [registerForm, { resetFields, setFieldsValue, updateSchema, validate, clearValidate }] = useForm({ |
|
|
|
labelWidth: 100, |
|
|
|
labelWidth: 100, |
|
|
|
schemas: formSchema, |
|
|
|
schemas: formSchema, |
|
|
|
showActionButtonGroup: false, |
|
|
|
showActionButtonGroup: false, |
|
|
|
baseColProps: { span: 24 } |
|
|
|
baseColProps: { span: 24 } |
|
|
|
}); |
|
|
|
}); |
|
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
|
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: WindowInnerData = { _tag: '' }) => { |
|
|
|
// 处理清除脏数据 |
|
|
|
// 处理清除脏数据 |
|
|
|
await resetFields(); |
|
|
|
await resetFields(); |
|
|
|
await clearValidate(); |
|
|
|
await clearValidate(); |
|
|
|
// 处理设置数据 |
|
|
|
// 处理设置数据 |
|
|
|
tag.value = data._tag; |
|
|
|
tag.value = data._tag; |
|
|
|
const topProject = { projectId: '0', name: '顶级项目', children: [] }; |
|
|
|
const topProject = { id: '0', name: '顶级项目', children: [] }; |
|
|
|
topProject.children = listToTree(await listProject()); |
|
|
|
topProject.children = listToTree(await listProject()); |
|
|
|
await updateSchema({ |
|
|
|
await updateSchema({ |
|
|
|
field: 'parentId', |
|
|
|
field: 'parentId', |
|
|
@ -45,25 +45,25 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data |
|
|
|
treeData: [topProject] |
|
|
|
treeData: [topProject] |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
const projectId = data.record?.projectId; |
|
|
|
const id = data.record?.id; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
// 采用tag标签区分操作 |
|
|
|
// 采用tag标签区分操作 |
|
|
|
switch (unref(tag)) { |
|
|
|
switch (unref(tag)) { |
|
|
|
case 'add': |
|
|
|
case 'add': |
|
|
|
props.title = '新增项目'; |
|
|
|
props.title = '新增项目'; |
|
|
|
projectId && await setFieldsValue({ parentId: projectId }); |
|
|
|
id && await setFieldsValue({ parentId: id }); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'edit': |
|
|
|
case 'edit': |
|
|
|
props.title = '编辑项目'; |
|
|
|
props.title = '编辑项目'; |
|
|
|
await setFieldsValue(await getProject(projectId)); |
|
|
|
await setFieldsValue(await getProject(id)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
// 尾部:设置处理后的最终配置数据 |
|
|
|
// 尾部:设置处理后的最终配置数据 |
|
|
|
setModalProps(props); |
|
|
|
setModalProps(props); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** 处理弹出框提交 */ |
|
|
|
/** 处理弹出框提交 */ |
|
|
|
async function handleSubmit() { |
|
|
|
async function handleSubmit() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 提取验证数据 |
|
|
|
// 提取验证数据 |
|
|
|
const formData = await validate(); |
|
|
|
const formData = await validate(); |
|
|
@ -84,6 +84,5 @@ async function handleSubmit() { |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
setModalProps({ confirmLoading: false }); |
|
|
|
setModalProps({ confirmLoading: false }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|