|
@@ -2,6 +2,8 @@
|
|
|
import { toReactive } from '@vueuse/core'
|
|
|
import { ProjectId } from '@/interface/project'
|
|
|
import { useMutation } from '@tanstack/vue-query'
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
+import type { Action } from 'element-plus'
|
|
|
import { postSubProject } from '@/service/project'
|
|
|
import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
|
|
|
import DeptTree from '@/views/OaSystem/components/DeptTree/index.vue'
|
|
@@ -43,6 +45,12 @@ const _projectChildFormSource = {
|
|
|
projectTypeName: '',
|
|
|
xzqdm: ''
|
|
|
}
|
|
|
+const rules = reactive({
|
|
|
+ xmmc: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
|
|
+ xmjlId: [{ required: true, message: '请选择项目经理', trigger: 'change' }],
|
|
|
+ zrbmId: [{ required: true, message: '请选择责任部门', trigger: 'change' }]
|
|
|
+})
|
|
|
+const ruleFormRef = ref<FormInstance>()
|
|
|
const projectChildForm = ref(_projectChildFormSource)
|
|
|
const { mutate: addSubProject } = useMutation(postSubProject, {
|
|
|
onSuccess: () => {
|
|
@@ -50,6 +58,7 @@ const { mutate: addSubProject } = useMutation(postSubProject, {
|
|
|
projectChildForm.value = _projectChildFormSource
|
|
|
}
|
|
|
})
|
|
|
+const message = useMessage() // 消息弹窗
|
|
|
const submitProjectChild = () => {
|
|
|
projectChildForm.value.xmbh = projectNo.value
|
|
|
projectChildForm.value.shareRatio = props.parentData.shareRatio
|
|
@@ -60,7 +69,24 @@ const submitProjectChild = () => {
|
|
|
pid: props.parentData.mainProjectId,
|
|
|
...projectChildForm.value
|
|
|
}
|
|
|
- addSubProject(sendData)
|
|
|
+ if (sendData.xmmc === '') {
|
|
|
+ message.error('项目名称不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (sendData.xmjlId === '') {
|
|
|
+ message.error('项目经理不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (sendData.zrbmId === '') {
|
|
|
+ message.error('责任部门不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ElMessageBox.alert('添加子项目后将无法撤销,确认是否添加子项目?', '提交确认', {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ callback: (action: Action) => {
|
|
|
+ if (action === 'confirm') addSubProject(sendData)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
const nodeClickHandler = (data: any) => {
|
|
|
projectChildForm.value.zrbm = data.label
|
|
@@ -79,27 +105,27 @@ const xmjlNodeClickHandler = (data: any) => {
|
|
|
<div class="tabContent">
|
|
|
<div class="tabContentOne">
|
|
|
<div class="formBox">
|
|
|
- <el-form :model="projectChildForm">
|
|
|
+ <el-form :model="projectChildForm" ref="ruleFormRef" :rules="rules">
|
|
|
<h4>基本信息</h4>
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
- <el-form-item label="项目名称">
|
|
|
+ <el-form-item label="项目名称" class="required">
|
|
|
<el-input v-model="projectChildForm.xmmc" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="项目经理">
|
|
|
+ <el-form-item label="项目经理" class="required">
|
|
|
<UserOrgTree v-model="projectChildForm.xmjlId" @node-click="xmjlNodeClickHandler"
|
|
|
/></el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="责任部门">
|
|
|
+ <el-form-item label="责任部门" class="required">
|
|
|
<DeptTree
|
|
|
class="form-item-disable-style"
|
|
|
@node-click="nodeClickHandler"
|
|
|
- v-model="projectChildForm['zrbmId']"
|
|
|
+ v-model="projectChildForm.zrbmId"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
@@ -228,5 +254,19 @@ const xmjlNodeClickHandler = (data: any) => {
|
|
|
text-align: right;
|
|
|
padding-right: 20px;
|
|
|
}
|
|
|
+ .required {
|
|
|
+ position: relative;
|
|
|
+ &::before {
|
|
|
+ content: '*';
|
|
|
+ position: absolute;
|
|
|
+ left: -10px;
|
|
|
+ top: 12px;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
+ color: #f00;
|
|
|
+ border-radius: 50%;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|