| | |
| | | </up-form-item> |
| | | <up-form-item label="销售合同号" |
| | | prop="salesContractNo" |
| | | required |
| | | @click="showPicker = true"> |
| | | required> |
| | | <up-input v-model="form.salesContractNo" |
| | | readonly="" |
| | | @click="showPicker = true" |
| | | readonly |
| | | :disabled="isReadOnly" |
| | | @click="!isReadOnly && (showPicker = true)" |
| | | placeholder="点击选择销售合同号" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | v-if="!isReadOnly" |
| | | @click="showPicker = true"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <up-form-item label="供应商名称" |
| | | prop="supplierName" |
| | | required |
| | | @click="showCustomerPicker = true"> |
| | | > |
| | | <up-input v-model="form.supplierName" |
| | | readonly="" |
| | | @click="showCustomerPicker = true" |
| | | readonly |
| | | :disabled="isReadOnly" |
| | | @click="!isReadOnly && (showCustomerPicker = true)" |
| | | placeholder="点击选择供应商" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | v-if="!isReadOnly" |
| | | @click="showCustomerPicker = true"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | prop="projectName" |
| | | required> |
| | | <up-input v-model="form.projectName" |
| | | :disabled="isReadOnly" |
| | | placeholder="请输入项目名称" /> |
| | | </up-form-item> |
| | | <up-form-item label="付款方式" |
| | | prop="paymentMethod"> |
| | | <up-input v-model="form.paymentMethod" |
| | | :disabled="isReadOnly" |
| | | placeholder="请输入付款方式" /> |
| | | </up-form-item> |
| | | <up-form-item label="签订日期" |
| | |
| | | prop="executionDate"> |
| | | <up-input v-model="form.executionDate" |
| | | placeholder="请选择" |
| | | readonly="" /> |
| | | readonly |
| | | :disabled="isReadOnly" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | v-if="!isReadOnly" |
| | | @click="showTimePicker = true"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | |
| | | <text class="approver-name">{{ step.nickName }}</text> |
| | | </view> |
| | | <view class="delete-approver-btn" |
| | | v-if="!isReadOnly" |
| | | @click="removeApprover(stepIndex)">×</view> |
| | | </view> |
| | | <view v-else |
| | | <view v-else-if="!isReadOnly" |
| | | class="add-approver-btn" |
| | | @click="addApprover(stepIndex)"> |
| | | <view class="add-circle">+</view> |
| | |
| | | <view class="step-line" |
| | | v-if="stepIndex < approverNodes.length - 1"></view> |
| | | <view class="delete-step-btn" |
| | | v-if="approverNodes.length > 1" |
| | | v-if="approverNodes.length > 1 && !isReadOnly" |
| | | @click="removeApprovalStep(stepIndex)">删除节点</view> |
| | | </view> |
| | | </view> |
| | | <view class="add-step-btn"> |
| | | <view class="add-step-btn" v-if="!isReadOnly"> |
| | | <u-button icon="plus" |
| | | plain |
| | | type="primary" |
| | |
| | | const operationType = ref(""); |
| | | const editData = ref(null); |
| | | const formRef = ref(null); |
| | | // 审批通过(approvalStatus === 3)后,禁止编辑/删除产品 |
| | | // 审批通过(approvalStatus === 3)后,整单禁止编辑(含产品、基本信息、审批流程) |
| | | const isApprovalPassed = computed(() => { |
| | | const status = editData.value?.approvalStatus ?? form.value?.approvalStatus; |
| | | return Number(status) === 3; |
| | |
| | | const canEditProducts = computed(() => { |
| | | return operationType.value !== "view" && !isApprovalPassed.value; |
| | | }); |
| | | // 是否整体只读:查看模式 或 已审批通过 |
| | | const isReadOnly = computed(() => { |
| | | return operationType.value === "view" || isApprovalPassed.value; |
| | | }); |
| | | |
| | | const userStore = useUserStore(); |
| | | const form = ref({ |
| | | id: "", |
| | | salesContractNo: "", |
| | | // 关联销售台账ID(编辑回显时可能缺失,需要从合同号反查补齐) |
| | | salesLedgerId: "", |
| | | purchaseContractNumber: "", |
| | | supplierId: "", |
| | | supplierName: "", |
| | |
| | | form.value.salesLedgerId = selectedItem.value; |
| | | } |
| | | showPicker.value = false; |
| | | }; |
| | | |
| | | // 编辑回显场景:只有 salesContractNo,没有 salesLedgerId 时,尝试从列表反查补齐 |
| | | const syncSalesLedgerIdFromContractNo = () => { |
| | | if (form.value.salesLedgerId) return; |
| | | if (!form.value.salesContractNo) return; |
| | | const selectedItem = salesContractList.value.find( |
| | | contract => contract.text === form.value.salesContractNo |
| | | ); |
| | | if (selectedItem) { |
| | | form.value.salesLedgerId = selectedItem.value; |
| | | } |
| | | }; |
| | | |
| | | // 供应商选择事件 |
| | |
| | | }; |
| | | |
| | | const onSubmit = () => { |
| | | // 审批通过的台账禁止再次修改 |
| | | if (isApprovalPassed.value) { |
| | | uni.showToast({ |
| | | title: "已审批通过的台账不允许修改", |
| | | icon: "none", |
| | | }); |
| | | return; |
| | | } |
| | | const hasEmptyApprover = approverNodes.value.some(node => !node.userId); |
| | | if (hasEmptyApprover) { |
| | | uni.showToast({ |
| | |
| | | }); |
| | | return; |
| | | } |
| | | // 如果salesLedgerId为空,则不传递salesContractNo |
| | | if (!form.value.salesLedgerId) { |
| | | form.value.salesContractNo = ""; |
| | | } |
| | | // 编辑回显时可能只有合同号,提交前尝试补齐 salesLedgerId |
| | | syncSalesLedgerIdFromContractNo(); |
| | | if (operationType.value == "add") { |
| | | delete form.value.id; |
| | | } |
| | |
| | | text: user.salesContractNo, |
| | | value: user.id, |
| | | })); |
| | | // 列表回来后,补齐编辑回显的 salesLedgerId |
| | | syncSalesLedgerIdFromContractNo(); |
| | | }); |
| | | }; |
| | | |
| | |
| | | }; |
| | | |
| | | const addApprover = stepIndex => { |
| | | if (isReadOnly.value) return; |
| | | // 跳转到联系人选择页面 |
| | | uni.setStorageSync("stepIndex", stepIndex); |
| | | uni.navigateTo({ |
| | |
| | | }; |
| | | |
| | | const addApprovalStep = () => { |
| | | if (isReadOnly.value) return; |
| | | // 添加新的审批步骤 |
| | | approverNodes.value.push({ userId: null, nickName: null }); |
| | | console.log(approverNodes.value, "approverNodes.value"); |
| | | }; |
| | | |
| | | const removeApprover = stepIndex => { |
| | | if (isReadOnly.value) return; |
| | | // 移除审批人 |
| | | approverNodes.value[stepIndex].userId = null; |
| | | approverNodes.value[stepIndex].nickName = null; |
| | | }; |
| | | |
| | | const removeApprovalStep = stepIndex => { |
| | | if (isReadOnly.value) return; |
| | | // 确保至少保留一个审批步骤 |
| | | if (approverNodes.value.length > 1) { |
| | | approverNodes.value.splice(stepIndex, 1); |