diff --git a/src/views/finance/purchasingrequisition/accept/AcceptBatchForm.vue b/src/views/finance/purchasingrequisition/accept/AcceptBatchForm.vue index 10f3bf9..2875fa6 100644 --- a/src/views/finance/purchasingrequisition/accept/AcceptBatchForm.vue +++ b/src/views/finance/purchasingrequisition/accept/AcceptBatchForm.vue @@ -74,13 +74,53 @@ + + + + + + + + + + +
- - + + + + + + + + 删除
+ 增加成员 @@ -149,11 +189,13 @@ const form = reactive({ acceptDate: '', acceptContents: [] as any[], acceptTeam: [ - { name: '', deptCode: '', deptName: '' }, - { name: '', deptCode: '', deptName: '' }, - { name: '', deptCode: '', deptName: '' }, + { name: '', deptCode: '', deptName: '', roleType: '' }, + { name: '', deptCode: '', deptName: '', roleType: '' }, + { name: '', deptCode: '', deptName: '', roleType: '' }, ] as any[], templateFileIds: [] as string[], + acceptAddress: '', + question: '', remark: '', ...props.modelValue, }) @@ -197,7 +239,7 @@ watch(() => form.templateFileIds, (arr) => { }, { immediate: true, deep: true }) const addTeam = () => { - form.acceptTeam.push({ name: '', deptCode: '', deptName: '' }) + form.acceptTeam.push({ name: '', deptCode: '', deptName: '', roleType: '' }) } const removeTeam = (idx: number) => { @@ -212,6 +254,7 @@ const onCopyFromBatch = (n: number | null) => { name: m.name || '', deptCode: m.deptCode || '', deptName: m.deptName || '', + roleType: m.roleType || '', })) } copyFromBatch.value = null @@ -222,6 +265,37 @@ const rules: FormRules = { acceptDate: [{ required: true, message: '请选择验收日期', trigger: 'change' }], } +const onRoleChange = (idx: number, val: string) => { + const isLeader = val === 'LEADER_IN' || val === 'LEADER_OUT' + if (isLeader) { + const hasOtherLeader = form.acceptTeam.some((m, i) => + i !== idx && (m.roleType === 'LEADER_IN' || m.roleType === 'LEADER_OUT') + ) + if (hasOtherLeader) { + // 只能有一个组长 + form.acceptTeam[idx].roleType = '' + return + } + } +} + +const onTeamUserChange = (idx: number, list: any[]) => { + const m = form.acceptTeam[idx] + if (!m) return + if (list && list.length) { + const u = list[0] + m.name = u.name || u.realName || '' + m.deptCode = u.deptCode || u.commonDeptCode || '' + m.deptName = u.deptName || u.commonDeptName || '' + m.userList = list + } else { + m.name = '' + m.deptCode = '' + m.deptName = '' + m.userList = [] + } +} + const validate = () => formRef.value?.validate() defineExpose({ validate, form }) diff --git a/src/views/finance/purchasingrequisition/accept/AcceptCommonForm.vue b/src/views/finance/purchasingrequisition/accept/AcceptCommonForm.vue index d07ca83..de696a6 100644 --- a/src/views/finance/purchasingrequisition/accept/AcceptCommonForm.vue +++ b/src/views/finance/purchasingrequisition/accept/AcceptCommonForm.vue @@ -94,17 +94,19 @@ const props = defineProps<{ const emit = defineEmits(['update:modelValue']) const formRef = ref() -const purchaserList = ref([]) -const assetAdminList = ref([]) const contractOptions = ref([]) const contractLoading = ref(false) const contractLoaded = ref(false) +const purchaserList = ref([]) +const assetAdminList = ref([]) const form = reactive({ hasContract: '0', contractId: '', isInstallment: '0', totalPhases: 1, + projectName: '', + deptName: '', supplierName: '', supplierContact: '', purchaserId: '', @@ -116,6 +118,7 @@ const form = reactive({ const syncFormFromModel = (val: Record | undefined) => { Object.assign(form, val || {}) + // 同步采购人员、资产管理员回 org-selector if (form.purchaserId && form.purchaserName) { purchaserList.value = [{ id: form.purchaserId, name: form.purchaserName, type: 'user' }] } else { @@ -168,6 +171,21 @@ watch(() => form.hasContract, (val) => { } }) +// 选择合同后,自动带出合同供应商名称 +watch( + () => form.contractId, + (val) => { + if (!val) { + form.supplierName = '' + return + } + const c = contractOptions.value.find((it: any) => it.id === val) + if (c && c.supplierName) { + form.supplierName = c.supplierName + } + } +) + onMounted(() => { if (form.hasContract === '1') { loadContractOptions() diff --git a/src/views/finance/purchasingrequisition/accept/PurchasingAcceptModal.vue b/src/views/finance/purchasingrequisition/accept/PurchasingAcceptModal.vue index b8b0140..b9a65b0 100644 --- a/src/views/finance/purchasingrequisition/accept/PurchasingAcceptModal.vue +++ b/src/views/finance/purchasingrequisition/accept/PurchasingAcceptModal.vue @@ -212,20 +212,16 @@ const loadData = async () => { if (config?.common) { applyInfo.value = config.common // 仅当存在已保存批次时,才用接口数据回填公共信息;否则保持 open() 中的默认清空值 - if (config?.batches?.length) { - Object.assign(commonForm.value, { - hasContract: config.common.hasContract || '0', - contractId: config.common.contractId || '', - isInstallment: config.common.isInstallment || '0', - totalPhases: config.common.totalPhases || 1, - supplierName: config.common.supplierName || '', - supplierContact: config.common.supplierContact || '', - purchaserId: config.common.purchaserId || '', - purchaserName: config.common.purchaserName || '', - assetAdminId: config.common.assetAdminId || '', - assetAdminName: config.common.assetAdminName || '', - }) - } + if (config?.batches?.length) { + Object.assign(commonForm.value, { + hasContract: config.common.hasContract || '0', + contractId: config.common.contractId || '', + isInstallment: config.common.isInstallment || '0', + totalPhases: config.common.totalPhases || 1, + supplierName: config.common.supplierName || '', + supplierContact: config.common.supplierContact || '', + }) + } } const projectType = applyInfo.value?.projectType || rowProjectType.value || 'A' @@ -273,6 +269,8 @@ const loadBatchDetails = async () => { batchForms[b.batch] = { acceptType: d.accept.acceptType || '1', acceptDate: d.accept.acceptDate || '', + acceptAddress: d.accept.acceptAddress || '', + question: d.accept.question || '', remark: d.accept.remark || '', templateFileIds: d.accept.templateFileIds || [], acceptContents: (d.contents || []).map((c: any) => { @@ -289,6 +287,7 @@ const loadBatchDetails = async () => { name: t.name, deptCode: t.deptCode, deptName: t.deptName, + roleType: t.roleType || '', })), } if (batchForms[b.batch].acceptTeam.length < 3) { @@ -378,6 +377,8 @@ const saveCurrentBatch = async () => { purchaseId: String(purchaseId.value), acceptType: form.acceptType, acceptDate: form.acceptDate, + acceptAddress: form.acceptAddress, + question: form.question, remark: form.remark, templateFileIds: form.templateFileIds || [], acceptContents: form.acceptContents || [],