zouyu
4 小时以前 757d06679e650689be15e310c39450148ef12015
销售退货:调整新增和编辑时计算可退货数量的逻辑
已修改2个文件
89 ■■■■■ 文件已修改
src/views/salesManagement/returnOrder/components/detailDia.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/returnOrder/components/formDia.vue 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/salesManagement/returnOrder/components/detailDia.vue
@@ -21,9 +21,6 @@
      <div style="padding-top: 20px">
        <span class="descriptions">产品列表</span>
        <PIMTable :isShowPagination="false" rowKey="id" :column="tableColumn" :tableData="tableData">
          <template #totalReturnNum="{ row }">
            {{ calcAlreadyReturned(row) }}
          </template>
        </PIMTable>
      </div>
    </div>
@@ -252,8 +249,9 @@
  {align: "center", label: "规格型号", prop: "model"},
  {align: "center", label: "单位", prop: "unit", width: 80},
  {align: "center", label: "总数量", prop: "stockOutNum", width: 120},
  {align: "center", label: "已退货数量", prop: "totalReturnNum", width: 120, dataType: "slot", slot: "totalReturnNum"},
  {align: "center", label: "已退货数量", prop: "totalReturnNum", width: 120},
  {align: "center", label: "未退货数量", prop: "unQuantity", width: 120},
  {align: "center", label: "待处理退货数量", prop: "pendingReturnNum", width: 120},
  {align: "center", label: "退货数量", prop: "returnQuantity", width: 120},
  {align: "center", label: "退货产品单价", prop: "price", width: 120},
  {align: "center", label: "退货产品金额", prop: "amount", width: 120},
@@ -284,7 +282,7 @@
  try {
    const res = await returnManagementGetById({ returnManagementId: row.id });
    detail.value = res?.data ?? res ?? {};
    if (detail.value.shippingId) {
      const productRes = await returnManagementGetByShippingId({ shippingId: detail.value.shippingId });
      if (productRes.code === 200) {
src/views/salesManagement/returnOrder/components/formDia.vue
@@ -82,32 +82,29 @@
            <el-button type="primary" @click="openProductSelection" :disabled="!form.shippingId">添加产品</el-button>
          </div>
          <PIMTable :isShowPagination="false" rowKey="id" :column="tableColumn" :tableData="tableData">
            <template #totalReturnNum="{ row }">
              {{ calcAlreadyReturned(row) }}
            </template>
            <template #returnQuantity="{ row }">
              <el-input
                v-model="row.returnQuantity"
                style="width:100px"
                placeholder="请输入"
              <el-input
                v-model="row.returnQuantity"
                style="width:100px"
                placeholder="请输入"
                type="number"
                @input="(val) => handleReturnQuantityChange(val, row)"
              />
            </template>
            <template #price="{ row }">
              <el-input
                v-model="row.price"
                style="width:100px"
                placeholder="请输入"
              <el-input
                v-model="row.price"
                style="width:100px"
                placeholder="请输入"
                type="number"
                @input="(val) => handlePriceChange(val, row)"
              />
            </template>
            <template #amount="{ row }">
              <el-input
                v-model="row.amount"
                style="width:100px"
                placeholder="自动计算"
              <el-input
                v-model="row.amount"
                style="width:100px"
                placeholder="自动计算"
                type="number"
                disabled
              />
@@ -119,10 +116,10 @@
              </el-select>
            </template>
            <template #remark="{ row }">
              <el-input
                v-model="row.remark"
                style="width:130px"
                placeholder="请输入"
              <el-input
                v-model="row.remark"
                style="width:130px"
                placeholder="请输入"
              />
            </template>
            <template #action="{ index }">
@@ -140,9 +137,9 @@
    </el-dialog>
    <el-dialog v-model="productSelectionVisible" title="选择产品" width="70%" append-to-body>
      <el-table
        :data="availableProducts"
        style="width: 100%"
      <el-table
        :data="availableProducts"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        ref="productTableRef"
        row-key="id"
@@ -154,11 +151,9 @@
        <el-table-column align="center" prop="specificationModel" label="规格型号" />
        <el-table-column align="center" prop="unit" label="单位" />
        <el-table-column align="center" prop="stockOutNum" label="总数量" />
        <el-table-column align="center" label="已退货数量" prop="totalReturnNum"></el-table-column>
        <el-table-column align="center" prop="unQuantity" label="未退货数量" />
        <el-table-column align="center" label="已退货数量">
          <template #default="{ row }">{{ calcAlreadyReturned(row) }}</template>
        </el-table-column>
        <el-table-column align="center" prop="pendingReturnNum" label="待处理退货数量" />
      </el-table>
      <template #footer>
        <div class="dialog-footer">
@@ -226,7 +221,8 @@
  {align: "center", label: "规格型号", prop: "specificationModel" },
  {align: "center", label: "单位", prop: "unit", width: 80 },
  {align: "center", label: "总数量", prop: "stockOutNum", width: 120 },
  {align: "center", label: "已退货数量", prop: "totalReturnNum", width: 120, dataType: "slot", slot: "totalReturnNum" },
  {align: "center", label: "已退货数量", prop: "totalReturnNum", width: 120 },
  {align: "center", label: "待处理退货数量", prop: "pendingReturnNum", width: 120 },
  {align: "center", label: "未退货数量", prop: "unQuantity", width: 120 },
  {align: "center", label: "退货数量", prop: "returnQuantity", dataType: "slot", slot: "returnQuantity", width: 120 },
  {align: "center", label: "退货产品单价", prop: "price", dataType: "slot", slot: "price", width: 120 },
@@ -559,6 +555,18 @@
  proxy.resetForm("formRef");
  dialogFormVisible.value = false;
  emit('close');
  data.form = {
        returnNoCheckbox: true,
        returnNo: "",
        customerId: "",
        shippingId: "",
        projectId: "",
        maker: "",
        makeTime: "",
        status: 0,
        returnReason: "",
        refundAmount: "",
  }
};
const initCustomers = async () => {
@@ -601,7 +609,7 @@
    form.value.shippingId = "";
    outboundOptions.value = [];
  }
  // Find customer name for getSalesLedger if it requires name
  const customer = customerNameOptions.value.find(c => c.id === val);
  if (!customer) return;
@@ -609,7 +617,7 @@
  // Assuming getSalesLedger takes customerName. If it takes ID, adjust accordingly.
  // Previous code used customerName. Let's try passing customerName.
  getSalesLedger({
    customerName: customer.label,
    customerName: customer.label,
  }).then(res => {
    if(res.code === 200){
      outboundOptions.value = res.data.map(item => ({
@@ -626,7 +634,7 @@
  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 = [];
  }
@@ -634,9 +642,12 @@
const handleReturnQuantityChange = (val, row) => {
  if (val === "" || val === null) return;
  const max = row.unQuantity === undefined || row.unQuantity === null ? Infinity : Number(row.unQuantity || 0);
  const unQuantity = row.unQuantity === undefined || row.unQuantity === null ? Infinity : Number(row.unQuantity || 0);//未退货数量
  const pendingReturnNum = row.pendingReturnNum === undefined || row.pendingReturnNum === null ? Infinity : Number(row.pendingReturnNum || 0);//待处理退货数量
  //最大退货数量,如果为编辑状态加上待处理退货数量
  const max = operationType.value === 'edit' ? unQuantity + pendingReturnNum : unQuantity
  const current = Number(val);
  if (current > max) {
    proxy.$nextTick(() => {
      row.returnQuantity = max;
@@ -702,7 +713,7 @@
// Removed checkSelectable to allow toggling existing items
const confirmProductSelection = () => {
  const newTableData = [];
  selectedProducts.value.forEach(product => {
    const existing = tableData.value.find(item => item.id === product.id);
    if (existing) {
@@ -710,7 +721,7 @@
    } else {
      newTableData.push({
        ...product,
        returnSaleLedgerProductId: product.id,
        returnSaleLedgerProductId: product.id,
        productModelId: product.productModelId,
        returnQuantity: 0,
        num: 0,
@@ -728,7 +739,7 @@
      });
    }
  });
  tableData.value = newTableData;
  productSelectionVisible.value = false;
};