| | |
| | | @change="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="客户合同号"> |
| | | <el-input |
| | | v-model="searchForm.customerContractNo" |
| | | placeholder="请输入客户合同号" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="项目名称"> |
| | | <el-input |
| | | v-model="searchForm.projectName" |
| | | placeholder="请输入项目名称" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | <br> |
| | | <el-form-item label="产品大类:"> |
| | | <el-input v-model="searchForm.productCategory" placeholder="请输入" clearable prefix-icon="Search" |
| | | @change="handleQuery" /> |
| | |
| | | width="200" |
| | | /> |
| | | <el-table-column |
| | | label="客户合同号" |
| | | prop="customerContractNo" |
| | | width="200" |
| | | show-overflow-tooltip |
| | | /> |
| | | <el-table-column |
| | | label="客户名称" |
| | | prop="customerName" |
| | | show-overflow-tooltip |
| | | width="240" |
| | | /> |
| | | <el-table-column label="业务员" prop="salesman" show-overflow-tooltip width="90"/> |
| | | <el-table-column |
| | | label="项目名称" |
| | | prop="projectName" |
| | | show-overflow-tooltip |
| | | width="200" |
| | | /> |
| | | <el-table-column |
| | | label="合同金额(元)" |
| | | prop="contractAmount" |
| | |
| | | <el-form-item label="业务员:" prop="salesman"> |
| | | <el-input |
| | | v-model="form.salesman" |
| | | placeholder="自动填充" |
| | | disabled |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="项目名称:" prop="projectName"> |
| | | <el-input |
| | | v-model="form.projectName" |
| | | placeholder="自动填充" |
| | | disabled |
| | | /> |
| | |
| | | searchForm: { |
| | | customerName: "", |
| | | status: false, |
| | | customerContractNo: undefined, // 客户合同号 |
| | | projectName: undefined, // 项目名称 |
| | | createUer: undefined, // 登记人 |
| | | issueDate: undefined, // 开票日期 |
| | | createTime: undefined, // 录入日期: |
| | |
| | | result.productData.forEach(item => { |
| | | allProductData.push({ |
| | | ...item, |
| | | id: contractId, // 明确设置合同ID |
| | | // 保留原有产品 id,不再覆盖;额外挂上所属合同 id |
| | | salesLedgerId: contractId, |
| | | salesContractNo: contract.salesContractNo, // 添加销售合同号 |
| | | customerName: contract.customerName, // 添加客户名称 |
| | | customerContractNo: contract.customerContractNo // 添加客户合同号 |
| | |
| | | const submitForm = () => { |
| | | proxy.$refs["formRef"].validate((valid) => { |
| | | if (valid) { |
| | | // 如果是批量操作,将所有合同的数据放在一个数组里,只调用一次接口 |
| | | if (selectedRows.value.length > 1) { |
| | | // 创建包含所有合同数据的数组 |
| | | const batchData = selectedRows.value.map(contract => { |
| | | // 筛选出属于当前合同的产品数据 |
| | | const contractProductData = productData.value.filter(item => |
| | | item.salesLedgerId === contract.id |
| | | ); |
| | | |
| | | // 为每个销售合同号创建独立的对象 |
| | | return { |
| | | // 基础表单数据 |
| | | issueDate: form.value.issueDate, |
| | | createTime: form.value.createTime, |
| | | createUer: form.value.createUer, |
| | | invoiceNo: form.value.invoiceNo, |
| | | |
| | | // 合同实际信息 |
| | | id: contract.id, // 使用id作为字段名,值为salesLedgerId |
| | | salesContractNo: contract.salesContractNo, // 使用实际的销售合同号 |
| | | customerName: contract.customerName, // 使用实际的客户名称 |
| | | customerId: contract.customerId, // 添加客户ID |
| | | customerContractNo: contract.customerContractNo, // 使用实际的客户合同号 |
| | | projectName: contract.projectName, // 使用实际的项目名称 |
| | | salesman: contract.salesman, // 使用实际的业务员 |
| | | |
| | | // 产品数据 |
| | | productData: proxy.HaveJson(contractProductData), |
| | | |
| | | // 批量标识 |
| | | isBatch: true |
| | | }; |
| | | }); |
| | | // 统一将所有合同的数据放在一个数组里,单个和批量都使用数组格式 |
| | | const submitData = selectedRows.value.map(contract => { |
| | | // 筛选出属于当前合同的产品数据(根据 salesLedgerId 关联合同) |
| | | const contractProductData = productData.value.filter(item => |
| | | item.salesLedgerId === contract.id |
| | | ); |
| | | |
| | | // 只调用一次接口,传递包含所有合同数据的数组 |
| | | invoiceRegistrationSave(batchData).then(() => { |
| | | proxy.$modal.msgSuccess("批量新增成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } else { |
| | | // 单个合同提交逻辑 |
| | | const singleContract = selectedRows.value[0]; |
| | | const singleForm = { |
| | | // 为每个销售合同号创建独立的对象 |
| | | return { |
| | | // 基础表单数据 |
| | | issueDate: form.value.issueDate, |
| | | createTime: form.value.createTime, |
| | |
| | | invoiceNo: form.value.invoiceNo, |
| | | |
| | | // 合同实际信息 |
| | | id: singleContract.id, // 使用id作为字段名,值为salesLedgerId |
| | | salesContractNo: singleContract.salesContractNo, // 使用实际的销售合同号 |
| | | customerName: singleContract.customerName, // 使用实际的客户名称 |
| | | customerId: singleContract.customerId, // 添加客户ID |
| | | customerContractNo: singleContract.customerContractNo, // 使用实际的客户合同号 |
| | | projectName: singleContract.projectName, // 使用实际的项目名称 |
| | | salesman: singleContract.salesman, // 使用实际的业务员 |
| | | id: contract.id, // 使用id作为字段名,值为salesLedgerId |
| | | salesContractNo: contract.salesContractNo, // 使用实际的销售合同号 |
| | | customerName: contract.customerName, // 使用实际的客户名称 |
| | | customerId: contract.customerId, // 添加客户ID |
| | | customerContractNo: contract.customerContractNo, // 使用实际的客户合同号 |
| | | projectName: contract.projectName, // 使用实际的项目名称 |
| | | salesman: contract.salesman, // 使用实际的业务员 |
| | | |
| | | // 产品数据 |
| | | productData: proxy.HaveJson(productData.value), |
| | | productData: proxy.HaveJson(contractProductData), |
| | | |
| | | // 批量标识 |
| | | isBatch: false |
| | | isBatch: selectedRows.value.length > 1 |
| | | }; |
| | | invoiceRegistrationSave(singleForm).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | // 统一调用接口,传递数组格式的数据 |
| | | invoiceRegistrationSave(submitData).then(() => { |
| | | proxy.$modal.msgSuccess(selectedRows.value.length > 1 ? "批量新增成功" : "提交成功"); |
| | | closeDia(); |
| | | getList(); |
| | | }); |
| | | } |
| | | }); |
| | | }; |