| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="关联批号:" prop="shippingId"> |
| | | <el-select v-model="form.shippingId" filterable placeholder="请选择关联批号" @change="outboundNoChange"> |
| | | <el-form-item label="发货信息:" prop="shippingId"> |
| | | <el-select |
| | | v-model="form.shippingId" |
| | | filterable |
| | | placeholder="请选择发货信息" |
| | | :disabled="!form.customerId" |
| | | @change="outboundNoChange" |
| | | > |
| | | <el-option |
| | | v-for="item in outboundOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | :key="item.shippingId" |
| | | :label="item.displayLabel" |
| | | :value="item.shippingId" |
| | | :disabled="item.returnStatus === '全部退货'" |
| | | > |
| | | <div style="display: flex; justify-content: space-between; align-items: center;"> |
| | | <span>{{ item.displayLabel }}</span> |
| | | <el-tag |
| | | size="small" |
| | | :type="getReturnStatusType(item.returnStatus)" |
| | | style="margin-left: 8px;" |
| | | > |
| | | {{ item.returnStatus || '无退货' }} |
| | | </el-tag> |
| | | </div> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-col :span="4"> |
| | | <el-form-item label="退款总额:" prop="refundAmount"> |
| | | <el-input v-model="form.refundAmount" disabled placeholder="自动计算" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- 发货信息回显 --> |
| | | <el-row :gutter="30" v-if="form.shippingId"> |
| | | <el-col :span="4"> |
| | | <el-form-item label="批次号:"> |
| | | <el-input v-model="form.batchNo" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="车牌号:"> |
| | | <el-input v-model="form.shippingCarNumber" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="产品名称:"> |
| | | <el-input v-model="form.productName" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="规格型号:"> |
| | | <el-input v-model="form.model" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="发货数量:"> |
| | | <el-input v-model="form.shippingQuantity" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="4"> |
| | | <el-form-item label="销售合同号:"> |
| | | <el-input v-model="form.salesContractNo" disabled placeholder="--" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | |
| | | <script setup> |
| | | import { reactive, ref, toRefs, getCurrentInstance } from "vue"; |
| | | import { returnManagementAdd, returnManagementUpdate, returnManagementGetByShippingId, getSalesLedger, returnManagementGetById } from "@/api/salesManagement/returnOrder.js"; |
| | | import { returnManagementAdd, returnManagementUpdate, returnManagementGetByShippingId, getSalesLedger, returnManagementGetById, getShippingInfoForReturn } from "@/api/salesManagement/returnOrder.js"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | import { userListNoPageByTenantId } from "@/api/system/user.js"; |
| | | import { listProject } from "@/api/projectManagement/project.js"; |
| | |
| | | status: 0, |
| | | returnReason: "", |
| | | refundAmount: "", |
| | | // 发货信息回显字段 |
| | | batchNo: "", |
| | | shippingCarNumber: "", |
| | | productName: "", |
| | | model: "", |
| | | shippingQuantity: null, |
| | | salesContractNo: "", |
| | | shippingNo: "", |
| | | }, |
| | | rules: { |
| | | returnNo: [{ |
| | |
| | | }, trigger: "blur" |
| | | }], |
| | | customerId: [{ required: true, message: "请选择客户", trigger: "change" }], |
| | | shippingId: [{ required: true, message: "请选择关联出库单号", trigger: "change" }], |
| | | shippingId: [{ required: true, message: "请选择发货信息", trigger: "change" }], |
| | | } |
| | | }); |
| | | const { form, rules } = toRefs(data); |
| | |
| | | status: 0, |
| | | returnReason: "", |
| | | refundAmount: "", |
| | | batchNo: "", |
| | | shippingCarNumber: "", |
| | | productName: "", |
| | | model: "", |
| | | shippingQuantity: null, |
| | | salesContractNo: "", |
| | | shippingNo: "", |
| | | }); |
| | | form.value.maker = userStore.nickName || userStore.name || ""; |
| | | form.value.makeTime = new Date().toISOString().replace('T', ' ').split('.')[0]; // Default to now |
| | |
| | | if (clearDownstream) { |
| | | form.value.shippingId = ""; |
| | | outboundOptions.value = []; |
| | | clearShippingInfo(); |
| | | } |
| | | |
| | | // Find customer name for getSalesLedger if it requires name |
| | | |
| | | // Find customer name for API |
| | | const customer = customerNameOptions.value.find(c => c.id === val); |
| | | if (!customer) return; |
| | | |
| | | // Assuming getSalesLedger takes customerName. If it takes ID, adjust accordingly. |
| | | // Previous code used customerName. Let's try passing customerName. |
| | | getSalesLedger({ |
| | | customerName: customer.label, |
| | | // 使用新接口 getShippingInfoForReturn |
| | | getShippingInfoForReturn({ |
| | | customerName: customer.label, |
| | | }).then(res => { |
| | | if(res.code === 200){ |
| | | outboundOptions.value = res.data.map(item => ({ |
| | | label: item.shippingNo, // Or whatever the outbound number field is |
| | | value: item.id, |
| | | })) |
| | | outboundOptions.value = res.data || []; |
| | | } |
| | | }) |
| | | }; |
| | | |
| | | // 清空发货信息 |
| | | const clearShippingInfo = () => { |
| | | form.value.batchNo = ""; |
| | | form.value.shippingCarNumber = ""; |
| | | form.value.productName = ""; |
| | | form.value.model = ""; |
| | | form.value.shippingQuantity = null; |
| | | form.value.salesContractNo = ""; |
| | | form.value.shippingNo = ""; |
| | | }; |
| | | |
| | | // 获取退货状态标签类型 |
| | | const getReturnStatusType = (returnStatus) => { |
| | | const statusMap = { |
| | | '无退货': 'success', |
| | | '部分退货': 'warning', |
| | | '全部退货': 'danger', |
| | | }; |
| | | return statusMap[returnStatus] || 'info'; |
| | | }; |
| | | |
| | | const outboundNoChange = async (val, clearTable = true) => { |
| | | // val is shippingId |
| | | // 从 outboundOptions 中找到选中的发货信息 |
| | | const selected = outboundOptions.value.find(item => item.shippingId === val); |
| | | |
| | | if (selected) { |
| | | // 回显数据 |
| | | form.value.batchNo = selected.batchNo || ""; |
| | | form.value.shippingCarNumber = selected.shippingCarNumber || ""; |
| | | form.value.productName = selected.productName || ""; |
| | | form.value.model = selected.model || ""; |
| | | form.value.shippingQuantity = selected.shippingQuantity || 0; |
| | | form.value.salesContractNo = selected.salesContractNo || ""; |
| | | form.value.shippingNo = selected.shippingNo || ""; |
| | | } else { |
| | | clearShippingInfo(); |
| | | } |
| | | |
| | | // 获取产品列表 |
| | | let res = await returnManagementGetByShippingId({ shippingId: val }); |
| | | if(res.code === 200){ |
| | | // If backend returns project info, set it |
| | | if (res.data.projectId) form.value.projectId = res.data.projectId; |
| | | |
| | | |
| | | availableProducts.value = mergeShippingProductLists(res.data); |
| | | if (clearTable) tableData.value = []; |
| | | } |