| | |
| | | @click="openForm('add')"> |
| | | 新增台账 |
| | | </el-button> |
| | | <el-button type="primary" plain :disabled="selectedRows.length === 0" @click="handleBatchExportContract"> |
| | | 导出合同 |
| | | </el-button> |
| | | <el-button type="primary" |
| | | plain |
| | | @click="handleImport">导入 |
| | |
| | | </el-table-column> |
| | | <el-table-column label="数量" |
| | | prop="quantity" /> |
| | | <el-table-column label="每件数量" |
| | | prop="singleQuantity" /> |
| | | <el-table-column label="待发货数量" |
| | | prop="noQuantity" /> |
| | | <el-table-column label="税率(%)" |
| | |
| | | <el-button link |
| | | type="primary" |
| | | @click="openForm('edit', scope.row)" |
| | | :disabled="!scope.row.isEdit || scope.row.hasProductionRecord || !canEditLedger(scope.row)">编辑 |
| | | :disabled="!canEditLedger(scope.row)">编辑 |
| | | </el-button> |
| | | <el-button link |
| | | type="primary" |
| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="销售合同号:" |
| | | prop="salesContractNo"> |
| | | <el-input v-model="form.salesContractNo" |
| | | placeholder="自动生成" |
| | | clearable |
| | | disabled /> |
| | | <div style="display: flex; align-items: center; gap: 12px;width: 100%;"> |
| | | <el-checkbox v-model="form.autoGenerateContractNo" v-if="operationType === 'add'">自动生成 |
| | | </el-checkbox> |
| | | <el-input v-model="form.salesContractNo" |
| | | :placeholder="form.autoGenerateContractNo ? '自动生成' : '请输入'" |
| | | clearable |
| | | :disabled="form.autoGenerateContractNo" /> |
| | | |
| | | </div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | prop="unit" /> |
| | | <el-table-column label="数量" |
| | | prop="quantity" /> |
| | | <el-table-column label="每件数量" |
| | | prop="singleQuantity" /> |
| | | <el-table-column label="税率(%)" |
| | | prop="taxRate" /> |
| | | <el-table-column label="含税单价(元)" |
| | |
| | | :precision="2" |
| | | @change="calculateFromQuantity" |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="每件数量:" |
| | | prop="singleQuantity"> |
| | | <el-input-number :step="1" |
| | | :min="1" |
| | | v-model="productForm.singleQuantity" |
| | | placeholder="请输入" |
| | | clearable |
| | | :precision="0" |
| | | @change="calculateFromSingleQuantity" |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="总数:" |
| | | prop="totalQuantity"> |
| | | <el-input v-model="productForm.totalQuantity" |
| | | placeholder="自动计算" |
| | | disabled |
| | | style="width: 100%" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </el-row> |
| | | <el-row :gutter="30"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="批号:" |
| | | <el-form-item label="库存:" |
| | | prop="batchNo"> |
| | | <el-table :data="deliveryForm.batchNoList" |
| | | border |
| | |
| | | <el-table-column label="批号" |
| | | prop="batchNo" |
| | | min-width="180" /> |
| | | <el-table-column label="产品大类" |
| | | prop="productName" |
| | | min-width="100" /> |
| | | <el-table-column label="规格型号" |
| | | prop="model" |
| | | min-width="100" /> |
| | | <el-table-column label="单位" |
| | | prop="unit" |
| | | min-width="100" /> |
| | | <el-table-column label="库存数量" |
| | | min-width="120" |
| | | align="center"> |
| | |
| | | }, |
| | | form: { |
| | | salesContractNo: "", |
| | | autoGenerateContractNo: true, |
| | | salesman: "", |
| | | customerId: "", |
| | | entryPerson: "", |
| | |
| | | maintenanceTime: "", |
| | | productData: [], |
| | | executionDate: "", |
| | | hasProductionRecord: false, |
| | | }, |
| | | rules: { |
| | | salesman: [{ required: true, message: "请选择", trigger: "change" }], |
| | |
| | | specificationModel: "", |
| | | unit: "", |
| | | quantity: "", |
| | | singleQuantity: 1, |
| | | totalQuantity: "", |
| | | taxInclusiveUnitPrice: "", |
| | | taxRate: "", |
| | | taxInclusiveTotalPrice: "", |
| | |
| | | selectedQuotation.value = null; |
| | | let userLists = await userListNoPage(); |
| | | userList.value = userLists.data; |
| | | listCustomer({ current: -1, size: -1 }).then(res => { |
| | | listCustomer({ current: -1, size: -1, type: 0 }).then(res => { |
| | | customerOption.value = res.data.records; |
| | | }); |
| | | form.value.entryPerson = userStore.id; |
| | |
| | | form.value.entryDate = getCurrentDate(); |
| | | // 签订日期默认为当天 |
| | | form.value.executionDate = getCurrentDate(); |
| | | // 默认自动生成销售合同号 |
| | | form.value.autoGenerateContractNo = true; |
| | | } else { |
| | | currentId.value = row.id; |
| | | getSalesLedgerWithProducts({ id: row.id, type: 1 }).then(res => { |
| | |
| | | form.value.entryPerson = Number(res.entryPerson); |
| | | productData.value = form.value.productData; |
| | | fileList.value = form.value.storageBlobVOs; |
| | | // 编辑时设置自动生成为false,允许手动修改 |
| | | form.value.autoGenerateContractNo = false; |
| | | }); |
| | | } |
| | | // let userAll = await userStore.getInfo() |
| | |
| | | taxExclusiveTotalPrice: taxExclusiveTotalPrice, |
| | | invoiceType: "增普票", |
| | | isProduction: true, |
| | | productId: p.productId, |
| | | productModelId: p.productModelId |
| | | }; |
| | | }); |
| | | |
| | |
| | | } |
| | | form.value.storageBlobDTOs = fileList; |
| | | form.value.type = 1; |
| | | if (form.value.autoGenerateContractNo) { |
| | | form.value.salesContractNo = ''; |
| | | } |
| | | addOrUpdateSalesLedger(form.value).then(res => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | |
| | | if (type === "edit") { |
| | | productForm.value = { ...row }; |
| | | productIndex.value = index; |
| | | // 如果没有 totalQuantity,自动计算:总数 = 每件数量 * 数量 |
| | | if (!productForm.value.totalQuantity && productForm.value.quantity) { |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | } |
| | | // 编辑时根据产品大类名称反查 tree 节点 id,并加载规格型号列表 |
| | | try { |
| | | const options = |
| | |
| | | ); |
| | | } |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | | |
| | |
| | | inclusiveTotalPrice / quantity |
| | | ).toFixed(2); |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | | |
| | |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 |
| | | // 计算含税总价 = 单价 * 数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | |
| | | productForm.value.taxRate |
| | | ); |
| | | } |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算含税总价 |
| | | // 计算含税总价 = 单价 * 数量 |
| | | productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2); |
| | | |
| | | // 如果有税率,计算不含税总价 |
| | |
| | | productForm.value.taxRate |
| | | ); |
| | | } |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | | |
| | | // 根据每件数量变化计算总数 |
| | | const calculateFromSingleQuantity = () => { |
| | | if (isCalculating.value) return; |
| | | |
| | | const quantity = parseFloat(productForm.value.quantity); |
| | | |
| | | if (!quantity || quantity <= 0) { |
| | | return; |
| | | } |
| | | |
| | | isCalculating.value = true; |
| | | |
| | | // 计算总数 = 每件数量 * 数量 |
| | | const singleQuantity = parseInt(productForm.value.singleQuantity) || 1; |
| | | productForm.value.totalQuantity = (quantity * singleQuantity).toFixed(0); |
| | | |
| | | isCalculating.value = false; |
| | | }; |
| | |
| | | |
| | | // 发货状态必须是"待发货"或"审核拒绝" |
| | | const statusStr = shippingStatus ? String(shippingStatus).trim() : ""; |
| | | return statusStr === "待发货" || statusStr === "审核拒绝"; |
| | | return statusStr === "待发货" || statusStr === "审核拒绝" || statusStr === "部分发货"; |
| | | }; |
| | | |
| | | // 打开附件弹窗 |
| | |
| | | recordId.value = row.id; |
| | | fileDialogVisible.value = true; |
| | | }; |
| | | |
| | | const handleBatchExportContract = () => { |
| | | if (selectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning("请选择要导出的台账"); |
| | | return; |
| | | } |
| | | const firstCustomerKey = |
| | | selectedRows.value[0].customerId ?? selectedRows.value[0].customerName ?? ""; |
| | | const hasDifferentCustomer = selectedRows.value.some((row) => { |
| | | const customerKey = row.customerId ?? row.customerName ?? ""; |
| | | return String(customerKey) !== String(firstCustomerKey); |
| | | }); |
| | | if (hasDifferentCustomer) { |
| | | proxy.$modal.msgWarning("仅支持同一客户同时导出合同"); |
| | | return; |
| | | } |
| | | const ids = selectedRows.value |
| | | .map((row) => row.id) |
| | | .filter((id) => id !== null && id !== undefined); |
| | | if (ids.length === 0) { |
| | | proxy.$modal.msgWarning("未获取到合同ID"); |
| | | return; |
| | | } |
| | | proxy.download( |
| | | "/sales/ledger/exportContract", |
| | | ids, |
| | | `销售合同_批量_${dayjs().format("YYYYMMDDHHmmss")}.docx`, |
| | | { |
| | | method: "post", |
| | | filename: `销售合同_批量_${dayjs().format("YYYYMMDDHHmmss")}.docx`, |
| | | headers: { "Content-Type": "application/json;charset=utf-8" }, |
| | | transformRequest: [(data) => JSON.stringify(data)], |
| | | } |
| | | ); |
| | | } |
| | | // 打开发货弹框 |
| | | const openDeliveryForm = async row => { |
| | | // 检查是否可以发货 |
| | |
| | | page-break-after: avoid; |
| | | } |
| | | } |
| | | </style> |
| | | </style> |