zhangwencui
2026-05-29 7de7862e8feaaefdf5e9492867db12013a88e9fc
src/views/salesManagement/salesLedger/index.vue
@@ -105,6 +105,10 @@
                                       @confirm="handleProcessFlowSelectConfirm" />
        <el-space wrap>
          <el-button type="primary"
                     @click="handleAudit">审核</el-button>
          <el-button type="primary"
                     @click="handleReverseAudit">反审</el-button>
          <el-button type="primary"
                     @click="handleSalesStock">入库</el-button>
          <el-button type="primary"
                     @click="openForm('add')">新增台账</el-button>
@@ -255,7 +259,7 @@
                               align="center">
                <template #default="scope">
                  <el-tag v-if="scope.row.productStockStatus == 1"
                  type="warning">部分入库</el-tag>
                          type="warning">部分入库</el-tag>
                  <el-tag v-else-if="scope.row.productStockStatus == 2"
                          type="success">已入库</el-tag>
                  <el-tag v-else-if="scope.row.productStockStatus == 0"
@@ -381,6 +385,18 @@
                    type="info">-</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="审核状态"
                         width="120"
                         align="center">
          <template #default="scope">
            <el-tag v-if="Number(scope.row.reviewStatus) === 0"
                    type="warning">待审核</el-tag>
            <el-tag v-else-if="Number(scope.row.reviewStatus) === 1"
                    type="success">已审核</el-tag>
            <el-tag v-else
                    type="info">待审核</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="入库状态"
                         width="120"
                         align="center">
@@ -433,7 +449,7 @@
            <el-button link
                       type="primary"
                       @click="openProcessFlowSelect(scope.row)"
                       :disabled="!scope.row.isEdit">工艺路线</el-button>
                       :disabled="!scope.row.isEdit || Number(scope.row.reviewStatus) === 1">工艺路线</el-button>
            <el-button link
                       type="primary"
                       @click="downLoadFile(scope.row)">附件</el-button>
@@ -491,7 +507,7 @@
              <el-select v-model="form.salesman"
                         placeholder="请选择"
                         clearable
                         :disabled="operationType === 'view'">
                         :disabled="operationType === 'view' || Number(form.reviewStatus) === 1">
                <el-option v-for="item in userList"
                           :key="item.nickName"
                           :label="item.nickName"
@@ -508,7 +524,7 @@
                         filterable
                         placeholder="请选择"
                         clearable
                         :disabled="operationType === 'view'">
                         :disabled="operationType === 'view' || Number(form.reviewStatus) === 1">
                <el-option v-for="item in customerOption"
                           :key="item.id"
                           :label="item.customerName"
@@ -524,7 +540,7 @@
              <el-input v-model="form.projectName"
                        placeholder="请输入"
                        clearable
                        :disabled="operationType === 'view'" />
                        :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -539,7 +555,7 @@
                              type="date"
                              placeholder="请选择"
                              clearable
                              :disabled="operationType === 'view'" />
                              :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -551,7 +567,8 @@
                              format="YYYY-MM-DD"
                              type="date"
                              placeholder="请选择"
                              clearable />
                              clearable
                              :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -565,7 +582,8 @@
                         :reserve-keyword="false"
                         placeholder="请选择"
                         clearable
                         @change="changs">
                         @change="changs"
                         :disabled="operationType === 'view' || Number(form.reviewStatus) === 1">
                <el-option v-for="item in userList"
                           :key="item.userId"
                           :label="item.nickName"
@@ -582,7 +600,8 @@
                              format="YYYY-MM-DD"
                              type="date"
                              placeholder="请选择"
                              clearable />
                              clearable
                              :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -591,13 +610,14 @@
                        prop="entryDate">
            <el-button v-if="operationType !== 'view'"
                       type="primary"
                       :disabled="hasEditingProductRow()"
                       :disabled="hasEditingProductRow() || Number(form.reviewStatus) === 1"
                       @click="addProductInline">
              添加
            </el-button>
            <el-button v-if="operationType !== 'view'"
                       plain
                       type="danger"
                       :disabled="Number(form.reviewStatus) === 1"
                       @click="deleteProduct">删除</el-button>
          </el-form-item>
        </el-row>
@@ -629,7 +649,8 @@
                              :render-after-expand="false"
                              style="width: 100%"
                              :filter-node-method="filterProductCategoryNode"
                              @change="(val) => handleInlineProductCategoryChange(scope.row, val)" />
                              @change="(val) => handleInlineProductCategoryChange(scope.row, val)"
                              :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.productCategory ?? "" }}</span>
            </template>
          </el-table-column>
@@ -643,7 +664,8 @@
                         clearable
                         filterable
                         style="width: 100%"
                         @change="(val) => handleInlineProductModelChange(scope.row, val)">
                         @change="(val) => handleInlineProductModelChange(scope.row, val)"
                         :disabled="Number(form.reviewStatus) === 1">
                <el-option v-for="item in modelOptions"
                           :key="item.id"
                           :label="item.model"
@@ -664,7 +686,8 @@
                               :precision="2"
                               style="width: 100%"
                               placeholder="请输入"
                               clearable />
                               clearable
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.thickness ?? "" }}</span>
            </template>
          </el-table-column>
@@ -677,7 +700,8 @@
                        v-model="scope.row.floorCode"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
                        style="width: 100%"
                        :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.floorCode ?? "" }}</span>
            </template>
          </el-table-column>
@@ -712,7 +736,8 @@
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineSizeChange(scope.row)"
                               @input="() => handleInlineSizeChange(scope.row)" />
                               @input="() => handleInlineSizeChange(scope.row)"
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.width ?? "" }}</span>
            </template>
          </el-table-column>
@@ -730,7 +755,8 @@
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineSizeChange(scope.row)"
                               @input="() => handleInlineSizeChange(scope.row)" />
                               @input="() => handleInlineSizeChange(scope.row)"
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.height ?? "" }}</span>
            </template>
          </el-table-column>
@@ -748,7 +774,8 @@
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineQuantityChange(scope.row)"
                               @input="() => handleInlineQuantityChange(scope.row)" />
                               @input="() => handleInlineQuantityChange(scope.row)"
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.quantity ?? "" }}</span>
            </template>
          </el-table-column>
@@ -765,7 +792,8 @@
                               style="width: 100%"
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineSettleAreaChange(scope.row)" />
                               @change="() => handleInlineSettleAreaChange(scope.row)"
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.settlePieceArea ? Number(scope.row.settlePieceArea).toFixed(4) : "" }}</span>
            </template>
          </el-table-column>
@@ -780,7 +808,8 @@
                               :step="1"
                               :precision="4"
                               style="width: 100%"
                               placeholder="自动计算" />
                               placeholder="自动计算"
                               :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.actualTotalArea ? Number(scope.row.actualTotalArea).toFixed(4) : "" }}</span>
            </template>
          </el-table-column>
@@ -793,7 +822,8 @@
                         placeholder="请选择"
                         clearable
                         style="width: 100%"
                         @change="() => handleInlineTaxRateChange(scope.row)">
                         @change="() => handleInlineTaxRateChange(scope.row)"
                         :disabled="Number(form.reviewStatus) === 1">
                <el-option label="1"
                           value="1" />
                <el-option label="3"
@@ -825,10 +855,11 @@
                        v-model="scope.row.processRequirement"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
                        style="width: 100%"
                        :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.processRequirement ?? "" }}</span>
            </template>
          </el-table-column>
          </el-table-column>
          <el-table-column label="发票类型"
                           prop="invoiceType"
                           min-width="120">
@@ -837,7 +868,8 @@
                         v-model="scope.row.invoiceType"
                         placeholder="请选择"
                         clearable
                         style="width: 100%">
                         style="width: 100%"
                         :disabled="Number(form.reviewStatus) === 1">
                <el-option label="增普票"
                           value="增普票" />
                <el-option label="增专票"
@@ -855,7 +887,8 @@
                        v-model="scope.row.remark"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
                        style="width: 100%"
                        :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.remark ?? "" }}</span>
            </template>
          </el-table-column>
@@ -867,7 +900,8 @@
                        v-model="scope.row.heavyBox"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
                        style="width: 100%"
                        :disabled="Number(form.reviewStatus) === 1" />
              <span v-else>{{ scope.row.heavyBox ?? "" }}</span>
            </template>
          </el-table-column>
@@ -978,7 +1012,7 @@
                <el-button link
                           type="primary"
                           size="small"
                           :disabled="isProductShipped(scope.row) || hasEditingProductRow()"
                           :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1"
                           @click="copyProductInline(scope.row, scope.$index)">
                  复制新建
                </el-button>
@@ -1003,7 +1037,7 @@
                    <el-button type="primary"
                               plain
                               size="small"
                               :disabled="isProductShipped(scope.row)"
                               :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1"
                               @click="startAddOtherAmountForRow(scope.row)">
                      新增
                    </el-button>
@@ -1016,7 +1050,7 @@
                               clearable
                               placeholder="请选择额外加工项目"
                               style="width: 100%;"
                               :disabled="isProductShipped(scope.row)">
                               :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1">
                      <el-option v-for="item in otherAmountSelectOptions"
                                 :key="item.id"
                                 :label="item.processName"
@@ -1024,13 +1058,13 @@
                    </el-select>
                    <div style="display:flex; justify-content:flex-end; gap: 8px;">
                      <el-button size="small"
                                 :disabled="isProductShipped(scope.row)"
                                 :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1"
                                 @click="scope.row.__inlineOtherAmountAdding = false; scope.row.__inlineOtherAmountAddId = null">
                        取消
                      </el-button>
                      <el-button type="primary"
                                 size="small"
                                 :disabled="isProductShipped(scope.row) || scope.row.__inlineOtherAmountAddId === null || scope.row.__inlineOtherAmountAddId === undefined || scope.row.__inlineOtherAmountAddId === ''"
                                 :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1 || scope.row.__inlineOtherAmountAddId === null || scope.row.__inlineOtherAmountAddId === undefined || scope.row.__inlineOtherAmountAddId === ''"
                                 @click="confirmAddOtherAmountForRow(scope.row)">
                        确认添加
                      </el-button>
@@ -1051,12 +1085,12 @@
                                       :precision="0"
                                       style="width: 120px;"
                                       placeholder="数量"
                                       :disabled="operationType === 'view' || isProductShipped(scope.row)"
                                       :disabled="operationType === 'view' || isProductShipped(scope.row) || Number(form.reviewStatus) === 1"
                                       @change="handleOtherAmountQuantityChange(scope.row)" />
                      <el-button type="danger"
                                 link
                                 size="small"
                                 :disabled="isProductShipped(scope.row)"
                                 :disabled="isProductShipped(scope.row) || Number(form.reviewStatus) === 1"
                                 @click="removeOtherAmountAtForRow(scope.row, idx)">
                        删除
                      </el-button>
@@ -1080,7 +1114,7 @@
                        clearable
                        type="textarea"
                        :rows="2"
                        :disabled="operationType === 'view'" />
                        :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -1093,7 +1127,7 @@
                        clearable
                        type="textarea"
                        :rows="2"
                        :disabled="operationType === 'view'" />
                        :disabled="operationType === 'view' || Number(form.reviewStatus) === 1" />
            </el-form-item>
          </el-col>
        </el-row>
@@ -1941,9 +1975,14 @@
            const ctx = canvas.getContext("2d");
            canvas.width = Math.max(QR_SIZE + horizontalPad * 2, 280);
            ctx.font = `${fontSize}px "Microsoft YaHei", "PingFang SC", sans-serif`;
            const lines = wrapLedgerQrTextLines(ctx, label, canvas.width - horizontalPad * 2);
            const lines = wrapLedgerQrTextLines(
              ctx,
              label,
              canvas.width - horizontalPad * 2
            );
            const textBlockHeight = lines.length * lineHeight;
            canvas.height = padTop + QR_SIZE + gapAfterQr + textBlockHeight + bottomPad;
            canvas.height =
              padTop + QR_SIZE + gapAfterQr + textBlockHeight + bottomPad;
            ctx.fillStyle = "#ffffff";
            ctx.fillRect(0, 0, canvas.width, canvas.height);
@@ -2011,6 +2050,7 @@
      entryDateEnd: undefined,
      deliveryStatus: undefined, // 发货状态:1未发货 2审批中 3审批不通过 4审批通过 5已发货 6部分发货
      stockStatus: undefined, // 入库状态:0未入库 1部分入库 2已入库
      reviewStatus: undefined, // 审核状态:0待审核 1已审核 2已反审
    },
    form: {
      salesContractNo: "",
@@ -2022,6 +2062,8 @@
      maintenanceTime: "",
      productData: [],
      executionDate: "",
      reviewStatus: undefined,
      stockStatus: undefined,
    },
    rules: {
      salesman: [{ required: true, message: "请选择", trigger: "change" }],
@@ -2219,7 +2261,9 @@
    copied.productModelId = row.productModelId ?? null;
    copied.specificationModel = row.specificationModel ?? "";
    copied.thickness =
      row.thickness !== null && row.thickness !== undefined && row.thickness !== ""
      row.thickness !== null &&
      row.thickness !== undefined &&
      row.thickness !== ""
        ? Number(row.thickness)
        : null;
    copied.floorCode = row?.floorCode ?? row?.floor_code ?? "";
@@ -2354,10 +2398,6 @@
    }
    if (row.actualTotalArea <= 0) {
      proxy.$modal.msgWarning("面积必须大于0");
      return false;
    }
    if (row.taxInclusiveUnitPrice <= 0) {
      proxy.$modal.msgWarning("含税单价必须大于0");
      return false;
    }
    if (!row.productModelId) {
@@ -2956,6 +2996,67 @@
    expandedRowKeys.value = [];
    getList();
  };
  /** 审核按钮操作 */
  const handleAudit = async () => {
    if (selectedRows.value.length === 0) {
      proxy.$modal.msgWarning("请选择要审核的数据");
      return;
    }
    const canNotAudit = selectedRows.value.filter(
      row => Number(row.reviewStatus) !== 0
    );
    if (canNotAudit.length > 0) {
      proxy.$modal.msgWarning("选中的数据中包含非待审核项,请重新选择");
      return;
    }
    try {
      await ElMessageBox.confirm("是否确认审核选中的销售台账?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      });
      for (const row of selectedRows.value) {
        await addOrUpdateSalesLedger({ ...row, reviewStatus: 1 });
      }
      proxy.$modal.msgSuccess("审核成功");
      getList();
    } catch (error) {
      console.log(error);
    }
  };
  /** 反审按钮操作 */
  const handleReverseAudit = async () => {
    if (selectedRows.value.length === 0) {
      proxy.$modal.msgWarning("请选择要反审的数据");
      return;
    }
    const canNotReverse = selectedRows.value.filter(
      row => Number(row.reviewStatus) !== 1
    );
    if (canNotReverse.length > 0) {
      proxy.$modal.msgWarning("选中的数据中包含非已审核项,请重新选择");
      return;
    }
    try {
      await ElMessageBox.confirm("是否确认反审选中的销售台账?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      });
      for (const row of selectedRows.value) {
        await addOrUpdateSalesLedger({ ...row, reviewStatus: 2 });
      }
      proxy.$modal.msgSuccess("反审成功");
      getList();
    } catch (error) {
      console.log(error);
    }
  };
  const paginationChange = obj => {
    page.current = obj.page;
    page.size = obj.limit;
@@ -2965,7 +3066,7 @@
    tableLoading.value = true;
    const { entryDate, ...rest } = searchForm;
    // 将范围日期字段传递给后端
    const params = { ...rest, ...page };
    const params = { ...rest, ...page, reviewStatusList: [0, 1] };
    // 移除录入日期的默认值设置,只保留范围日期字段
    delete params.entryDate;
    // 查询客户名称与新增保持一致:先选 customerId,再映射为 customerName 查询
@@ -2983,15 +3084,13 @@
        delete params.customerName;
      }
    }
    const widthValue =
      params.width != null ? String(params.width).trim() : "";
    const widthValue = params.width != null ? String(params.width).trim() : "";
    if (widthValue) {
      params.width = widthValue;
    } else {
      delete params.width;
    }
    const heightValue =
      params.height != null ? String(params.height).trim() : "";
    const heightValue = params.height != null ? String(params.height).trim() : "";
    if (heightValue) {
      params.height = heightValue;
    } else {
@@ -3065,7 +3164,9 @@
      const res = await productList({ salesLedgerId: id, type: 1 });
      stockProductList.value = [];
      stockProductList.value =
        res.data.filter(item => item.productStockStatus == 0 || item.productStockStatus == 1) || [];
        res.data.filter(
          item => item.productStockStatus == 0 || item.productStockStatus == 1
        ) || [];
    } catch (e) {
      proxy?.$modal?.msgError?.("获取产品或审批人失败");
    } finally {
@@ -3096,9 +3197,16 @@
    proxy?.$modal?.loading?.("正在入库,请稍候...");
    try {
      const approveUserIds = stockApproverNodes.value.map(node => node.userId).join(",");
      const approveUserIds = stockApproverNodes.value
        .map(node => node.userId)
        .join(",");
      const approveUserName = stockApproverNodes.value
        .map(node => stockApproverOptions.value.find(item => String(item.userId) === String(node.userId))?.userName)
        .map(
          node =>
            stockApproverOptions.value.find(
              item => String(item.userId) === String(node.userId)
            )?.userName
        )
        .filter(Boolean)
        .join(",");
      await salesStock({
@@ -3656,6 +3764,8 @@
        }
        form.value.tempFileIds = tempFileIds;
        form.value.type = 1;
        form.value.reviewStatus = 0; // 默认审核状态为待审核
        form.value.stockStatus = 0; // 默认入库状态为未入库
        const submitPayload = { ...form.value };
        delete submitPayload.paymentMethod;
        addOrUpdateSalesLedger(submitPayload).then(res => {
@@ -3919,7 +4029,11 @@
      const templateUrl = HISTORY_IMPORT_TEMPLATE_URL_MAP[command];
      const fileName = HISTORY_IMPORT_TEMPLATE_FILE_NAME_MAP[command];
      if (templateUrl) {
        proxy.download(templateUrl, {}, fileName || "销售发货历史数据导入模板.xlsx");
        proxy.download(
          templateUrl,
          {},
          fileName || "销售发货历史数据导入模板.xlsx"
        );
        return;
      }
    }
@@ -3981,6 +4095,15 @@
      return;
    }
    const ids = selectedRows.value.map(item => item.id);
    // 检查是否有已审核的台账
    const audited = selectedRows.value.filter(
      row => Number(row.reviewStatus) === 1
    );
    if (audited.length > 0) {
      proxy.$modal.msgWarning("选中的数据中包含已审核项,不能删除");
      return;
    }
    // 检查是否有已进行发货或发货完成的销售订单,若有则不允许删除
    const cannotDeleteNames = [];
@@ -4099,7 +4222,8 @@
        const processCardData = res?.data ?? {};
        // 补齐二维码所需的台账标识(后端数据有时不带 id)
        if (processCardData && typeof processCardData === "object") {
          processCardData.salesLedgerId = processCardData.salesLedgerId ?? selectedId;
          processCardData.salesLedgerId =
            processCardData.salesLedgerId ?? selectedId;
          processCardData.salesContractNo =
            (processCardData.salesContractNo ?? "").trim() ||
            String(selectedRow?.salesContractNo ?? "").trim();
@@ -4583,8 +4707,7 @@
    // 允许:1未发货、3审批不通过、4审批通过、6部分发货;不允许:2审批中、5已发货
    const statusItem = selectedRows.value[0].deliveryStatus;
    const ledgerAllowsDelivery = s =>
      [1, 3, 4, 6].includes(Number(s));
    const ledgerAllowsDelivery = s => [1, 3, 4, 6].includes(Number(s));
    let isTrue = true;
    selectedRows.value.forEach(row => {
      if (!ledgerAllowsDelivery(row.deliveryStatus)) {
@@ -4811,7 +4934,7 @@
        const run = async () => {
          for (const salesLedgerId of uniqueLedgerIds) {
            await addShippingInfo({
              scanOutbound:  false,
              scanOutbound: false,
              salesLedgerId,
              type: deliveryForm.value.type,
              approveUserIds,