| | |
| | | </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" |
| | |
| | | size="small" |
| | | @click="addProduct" |
| | | class="add-btn" |
| | | v-if="operationType !== 'view'"> |
| | | v-if="canEditProducts"> |
| | | 新增 |
| | | </up-button> |
| | | </view> |
| | |
| | | </view> |
| | | <!-- 操作按钮 --> |
| | | <view class="product-actions" |
| | | v-if="operationType !== 'view'"> |
| | | v-if="canEditProducts"> |
| | | <up-button type="error" |
| | | size="mini" |
| | | @click="removeProduct(idx)" |
| | |
| | | <up-input v-model="product.productCategory" |
| | | readonly |
| | | placeholder="请选择" |
| | | :disabled="!canEditProducts" |
| | | @click="openCategoryPicker(idx)" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | @click="showCategoryPicker = true"></up-icon> |
| | | v-if="canEditProducts" |
| | | @click="openCategoryPicker(idx)"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <!-- 规格型号 --> |
| | |
| | | <up-input v-model="product.specificationModel" |
| | | readonly |
| | | placeholder="请选择" |
| | | :disabled="!canEditProducts" |
| | | @click="openSpecificationPicker(idx)" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | @click="showSpecificationPicker = true"></up-icon> |
| | | v-if="canEditProducts" |
| | | @click="openSpecificationPicker(idx)"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <!-- 单位 --> |
| | |
| | | required |
| | | :rules="productRules"> |
| | | <up-input v-model="product.unit" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" /> |
| | | </up-form-item> |
| | | <!-- 税率 --> |
| | |
| | | <up-input v-model="product.taxRate" |
| | | readonly |
| | | placeholder="请选择" |
| | | :disabled="!canEditProducts" |
| | | @click="openTaxRatePicker(idx)" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | @click="showTaxRatePicker = true"></up-icon> |
| | | v-if="canEditProducts" |
| | | @click="openTaxRatePicker(idx)"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <!-- 含税单价 --> |
| | |
| | | :rules="productRules"> |
| | | <up-input v-model="product.taxInclusiveUnitPrice" |
| | | type="number" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" |
| | | @blur="formatTaxPrice(idx)" /> |
| | | </up-form-item> |
| | |
| | | :rules="productRules"> |
| | | <up-input v-model="product.quantity" |
| | | type="number" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" |
| | | @blur="formatAmount(idx)" /> |
| | | </up-form-item> |
| | |
| | | :rules="productRules"> |
| | | <up-input v-model="product.taxInclusiveTotalPrice" |
| | | type="number" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" |
| | | @blur="formatTaxTotal(idx)" /> |
| | | </up-form-item> |
| | |
| | | :rules="productRules"> |
| | | <up-input v-model="product.taxExclusiveTotalPrice" |
| | | type="number" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" |
| | | @blur="formatNoTaxTotal(idx)" /> |
| | | </up-form-item> |
| | |
| | | <up-input v-model="product.invoiceType" |
| | | readonly |
| | | placeholder="请选择" |
| | | :disabled="!canEditProducts" |
| | | @click="openInvoiceTypePicker(idx)" /> |
| | | <template #right> |
| | | <up-icon name="arrow-right" |
| | | @click="showInvoiceTypePicker = true"></up-icon> |
| | | v-if="canEditProducts" |
| | | @click="openInvoiceTypePicker(idx)"></up-icon> |
| | | </template> |
| | | </up-form-item> |
| | | <!-- 库存预警数量 --> |
| | |
| | | :rules="productRules"> |
| | | <up-input v-model="product.warnNum" |
| | | type="number" |
| | | :disabled="!canEditProducts" |
| | | placeholder="请输入" /> |
| | | </up-form-item> |
| | | <up-form-item label="是否质检" |
| | |
| | | required |
| | | :rules="productRules"> |
| | | <u-radio-group v-model="product.isChecked" |
| | | :disabled="!canEditProducts" |
| | | placement="row" |
| | | @change="groupChange"> |
| | | <u-radio :customStyle="{marginRight: '40rpx'}" |
| | | label="是" |
| | | :disabled="!canEditProducts" |
| | | :name="true"> |
| | | </u-radio> |
| | | <u-radio label="否" |
| | | :disabled="!canEditProducts" |
| | | :name="false"> |
| | | </u-radio> |
| | | </u-radio-group> |
| | |
| | | </view> |
| | | </view> |
| | | <!-- 使用公共底部按钮组件 --> |
| | | <FooterButtons :show="operationType !== 'view'" |
| | | <FooterButtons :show="operationType !== 'view' && !isApprovalPassed" |
| | | cancelText="取消" |
| | | confirmText="保存" |
| | | @cancel="goBack" |
| | |
| | | getSalesNo, |
| | | approveProcessGetInfo, |
| | | } from "@/api/procurementManagement/procurementLedger"; |
| | | import { delProduct } from "@/api/salesManagement/salesLedger"; |
| | | import PageHeader from "@/components/PageHeader.vue"; |
| | | import FooterButtons from "@/components/FooterButtons.vue"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user"; |
| | |
| | | const operationType = ref(""); |
| | | const editData = ref(null); |
| | | const formRef = ref(null); |
| | | // 审批通过(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: "", |
| | |
| | | })); |
| | | }); |
| | | |
| | | // 计算供应商选择列表 |
| | | // 计算供应商选择列表(只保留 isWhite === 0 的供应商) |
| | | const supplierActionList = computed(() => { |
| | | return supplierList.value.map(item => ({ |
| | | name: item.text, |
| | | value: item.value, |
| | | })); |
| | | return supplierList.value |
| | | .filter(item => item.isWhite === 0) |
| | | .map(item => ({ |
| | | name: item.text, |
| | | value: item.value, |
| | | })); |
| | | }); |
| | | |
| | | // 选择器相关变量 |
| | |
| | | }; |
| | | |
| | | const addProduct = () => { |
| | | if (!canEditProducts.value) return; |
| | | if (productData.value === null) { |
| | | productData.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 onCustomerSelect = item => { |
| | | form.value.supplierName = item.name; |
| | |
| | | }; |
| | | |
| | | const removeProduct = idx => { |
| | | productData.value.splice(idx, 1); |
| | | if (!canEditProducts.value) return; |
| | | const row = productData.value[idx]; |
| | | |
| | | // 新增模式或还未落库的产品,直接前端删除 |
| | | if (operationType.value === "add" || !row?.id) { |
| | | productData.value.splice(idx, 1); |
| | | return; |
| | | } |
| | | |
| | | uni.showModal({ |
| | | title: "提示", |
| | | content: "选中的产品将被删除,是否确认删除?", |
| | | confirmText: "确认", |
| | | cancelText: "取消", |
| | | success: res => { |
| | | if (!res.confirm) { |
| | | uni.showToast({ |
| | | title: "已取消", |
| | | icon: "none", |
| | | }); |
| | | return; |
| | | } |
| | | const ids = [row.id]; |
| | | delProduct(ids).then(() => { |
| | | uni.showToast({ |
| | | title: "删除成功", |
| | | icon: "success", |
| | | }); |
| | | const currentId = form.value.id || editData.value?.id; |
| | | if (currentId) { |
| | | getPurchaseById({ id: currentId, type: 2 }).then(res2 => { |
| | | productData.value = res2.productData || []; |
| | | }); |
| | | } else { |
| | | // 回退处理:如果没有当前ID,则本地删除 |
| | | productData.value.splice(idx, 1); |
| | | } |
| | | }); |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | | // 显示选择器 |
| | | const openCategoryPicker = idx => { |
| | | if (!canEditProducts.value) return; |
| | | currentProductIndex.value = idx; |
| | | showCategoryPicker.value = true; |
| | | }; |
| | | |
| | | const openSpecificationPicker = idx => { |
| | | if (!canEditProducts.value) return; |
| | | currentProductIndex.value = idx; |
| | | showSpecificationPicker.value = true; |
| | | }; |
| | | |
| | | const openTaxRatePicker = idx => { |
| | | if (!canEditProducts.value) return; |
| | | currentProductIndex.value = idx; |
| | | showTaxRatePicker.value = true; |
| | | }; |
| | | |
| | | const openInvoiceTypePicker = idx => { |
| | | if (!canEditProducts.value) return; |
| | | currentProductIndex.value = idx; |
| | | showInvoiceTypePicker.value = true; |
| | | }; |
| | |
| | | }; |
| | | |
| | | 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(); |
| | | }); |
| | | }; |
| | | |
| | |
| | | supplierList.value = res.data.map(item => ({ |
| | | text: item.supplierName, |
| | | value: item.id, |
| | | isWhite: item.isWhite, |
| | | })); |
| | | }); |
| | | }; |
| | |
| | | }; |
| | | |
| | | 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); |