| | |
| | | > |
| | | 保存 |
| | | </el-button> |
| | | <el-button color="#4C34FF" :loading="submitting" :disabled="submitting" @click="handleApply">申请</el-button> |
| | | <el-button color="#4C34FF" :loading="submitting" :disabled="submitting" @click="handleApply" >申请</el-button> |
| | | |
| | | </template> |
| | | |
| | | <!-- 申请弹框 --> |
| | | <el-dialog |
| | | class="gd-dialog" |
| | | v-model="showApplyDialog" |
| | | title="申请" |
| | | @closed="handleApplyDialogClosed" |
| | | width="500px" |
| | | destroy-on-close |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form class="gd-dialog-form" ref="applyFormRef" :model="applyFormData" :rules="applyRules"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="申请对象部门" prop="applyTargetDeptId"> |
| | | <el-tree-select |
| | | class="gd-select" |
| | | popper-class="gd-tree-select-popper" |
| | | v-model="applyFormData.applyTargetDeptId" |
| | | node-key="id" |
| | | :data="deptTree" |
| | | :props="treeProps" |
| | | check-strictly |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button color="#F2F3F5" @click="showApplyDialog = false">取消</el-button> |
| | | <el-button class="" color="#4C34FF" :loading="applying" :disabled="applying" @click="handleApplySubmit"> |
| | | 确认 |
| | | </el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | |
| | | const dialogReadonly = computed(() => dialogMode.value === 'view') |
| | | const titleEnum = ref({ edit: '编辑', view: '查看', add: '新增' }) |
| | | |
| | | // 申请弹框相关 |
| | | const showApplyDialog = ref(false) |
| | | const applyFormRef = ref(null) |
| | | const applying = ref(false) |
| | | const applyFormData = ref({ |
| | | applyTargetDeptId: '' |
| | | }) |
| | | |
| | | const rules = { |
| | | demandName: fieldRules(true), |
| | | demandType: fieldRules(true), |
| | |
| | | responsibleDeptId: fieldRules(true), |
| | | dataSource: fieldRules(true), |
| | | demandInfo: fieldRules(true), |
| | | } |
| | | |
| | | // 申请弹框校验规则 |
| | | const applyRules = { |
| | | applyTargetDeptId: fieldRules(true), |
| | | } |
| | | // 根据部门ID获取部门名称 |
| | | function getDeptNameById(deptId, deptList) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 申请提交 |
| | | // 申请弹框关闭处理 |
| | | function handleApplyDialogClosed() { |
| | | applyFormData.value.applyTargetDeptId = '' |
| | | } |
| | | // 申请 |
| | | async function handleApply() { |
| | | const isValid = await formRef.value?.validate().catch(() => false) |
| | | // 先验证主表单 |
| | | const mainFormValid = await formRef.value?.validate().catch(() => false) |
| | | if (!mainFormValid) return |
| | | |
| | | showApplyDialog.value = true |
| | | } |
| | | // 申请提交 |
| | | async function handleApplySubmit() { |
| | | const isValid = await applyFormRef.value?.validate().catch(() => false) |
| | | if (!isValid) return |
| | | submitting.value = true |
| | | applying.value = true |
| | | try { |
| | | formData.value.demandStatus = '1' |
| | | await gdSupplyDemandSubmitApi(formData.value) |
| | | // 构建申请数据 |
| | | const applyData = { |
| | | ...formData.value, |
| | | demandStatus: '1', |
| | | applyTargetDeptId: applyFormData.value.applyTargetDeptId |
| | | } |
| | | await gdSupplyDemandSubmitApi(applyData) |
| | | ElMessage.success('申请成功') |
| | | showApplyDialog.value = false |
| | | visible.value = false |
| | | emit('success') |
| | | } finally { |
| | | submitting.value = false |
| | | applying.value = false |
| | | } |
| | | } |
| | | |