gongchunyi
7 天以前 aa802302cfe650e08806c8b87d5a8c5d3a79ffe1
src/views/salesManagement/salesLedger/index.vue
@@ -64,12 +64,14 @@
                       :value="1" />
            <el-option label="审批中"
                       :value="2" />
            <el-option label="审批失败"
            <el-option label="审批不通过"
                       :value="3" />
            <el-option label="审批通过"
                       :value="4" />
            <el-option label="已发货"
                       :value="5" />
            <el-option label="部分发货"
                       :value="6" />
          </el-select>
        </el-form-item>
        <el-form-item label="入库状态:">
@@ -240,6 +242,8 @@
                <template #default="scope">
                  <el-tag v-if="scope.row.approveStatus === 1 && (!scope.row.shippingDate || !scope.row.shippingCarNumber)"
                          type="success">充足</el-tag>
                  <el-tag v-else-if="scope.row.approveStatus === 1 && scope.row.shippingDate && scope.row.shippingCarNumber"
                          type="success">已出库</el-tag>
                  <el-tag v-else-if="scope.row.approveStatus === 0 && (scope.row.shippingDate || scope.row.shippingCarNumber)"
                          type="success">已出库</el-tag>
                  <el-tag v-else
@@ -371,6 +375,8 @@
                    type="primary">审批通过</el-tag>
            <el-tag v-else-if="Number(scope.row.deliveryStatus) === 5"
                    type="success">已发货</el-tag>
            <el-tag v-else-if="Number(scope.row.deliveryStatus) === 6"
                    type="warning">部分发货</el-tag>
            <el-tag v-else
                    type="info">-</el-tag>
          </template>
@@ -662,6 +668,36 @@
              <span v-else>{{ scope.row.thickness ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="楼层编号"
                           prop="floorCode"
                           min-width="250"
                           show-overflow-tooltip>
            <template #default="scope">
              <el-input v-if="scope.row.__editing"
                        v-model="scope.row.floorCode"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
              <span v-else>{{ scope.row.floorCode ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="含税单价(元)"
                           prop="taxInclusiveUnitPrice"
                           min-width="160">
            <template #default="scope">
              <el-input-number v-if="scope.row.__editing"
                               :step="0.01"
                               :min="0"
                               :precision="2"
                               style="width: 100%"
                               v-model="scope.row.taxInclusiveUnitPrice"
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineUnitPriceChange(scope.row)"
                               @input="() => handleInlineUnitPriceChange(scope.row)" />
              <span v-else>{{ formattedNumber(null, null, scope.row.taxInclusiveUnitPrice) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="宽(mm)"
                           prop="width"
                           min-width="160">
@@ -698,23 +734,6 @@
              <span v-else>{{ scope.row.height ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="结算单片面积(㎡)"
                           prop="settlePieceArea"
                           min-width="200">
            <template #default="scope">
              <el-input-number v-if="scope.row.__editing"
                               controls-position="right"
                               v-model="scope.row.settlePieceArea"
                               :min="0"
                               :step="1"
                               :precision="4"
                               style="width: 100%"
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineSettleAreaChange(scope.row)" />
              <span v-else>{{ scope.row.settlePieceArea ? Number(scope.row.settlePieceArea).toFixed(4) : "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="数量"
                           prop="quantity"
                           min-width="150">
@@ -733,6 +752,23 @@
              <span v-else>{{ scope.row.quantity ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="结算单片面积(㎡)"
                           prop="settlePieceArea"
                           min-width="200">
            <template #default="scope">
              <el-input-number v-if="scope.row.__editing"
                               controls-position="right"
                               v-model="scope.row.settlePieceArea"
                               :min="0"
                               :step="1"
                               :precision="4"
                               style="width: 100%"
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineSettleAreaChange(scope.row)" />
              <span v-else>{{ scope.row.settlePieceArea ? Number(scope.row.settlePieceArea).toFixed(4) : "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="面积(m²)"
                           prop="actualTotalArea"
                           min-width="200">
@@ -746,23 +782,6 @@
                               style="width: 100%"
                               placeholder="自动计算" />
              <span v-else>{{ scope.row.actualTotalArea ? Number(scope.row.actualTotalArea).toFixed(4) : "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="含税单价(元)"
                           prop="taxInclusiveUnitPrice"
                           min-width="160">
            <template #default="scope">
              <el-input-number v-if="scope.row.__editing"
                               :step="0.01"
                               :min="0"
                               :precision="2"
                               style="width: 100%"
                               v-model="scope.row.taxInclusiveUnitPrice"
                               placeholder="请输入"
                               clearable
                               @change="() => handleInlineUnitPriceChange(scope.row)"
                               @input="() => handleInlineUnitPriceChange(scope.row)" />
              <span v-else>{{ formattedNumber(null, null, scope.row.taxInclusiveUnitPrice) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="税率(%)"
@@ -797,6 +816,19 @@
                           prop="taxExclusiveTotalPrice"
                           :formatter="formattedNumber"
                           min-width="120" />
          <el-table-column label="加工要求"
                           prop="processRequirement"
                           min-width="160"
                           show-overflow-tooltip>
            <template #default="scope">
              <el-input v-if="scope.row.__editing"
                        v-model="scope.row.processRequirement"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
              <span v-else>{{ scope.row.processRequirement ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="发票类型"
                           prop="invoiceType"
                           min-width="120">
@@ -814,19 +846,6 @@
              <span v-else>{{ scope.row.invoiceType ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="加工要求"
                           prop="processRequirement"
                           min-width="160"
                           show-overflow-tooltip>
            <template #default="scope">
              <el-input v-if="scope.row.__editing"
                        v-model="scope.row.processRequirement"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
              <span v-else>{{ scope.row.processRequirement ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备注"
                           prop="remark"
                           min-width="140"
@@ -838,19 +857,6 @@
                        clearable
                        style="width: 100%" />
              <span v-else>{{ scope.row.remark ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="楼层编号"
                           prop="floorCode"
                           min-width="250"
                           show-overflow-tooltip>
            <template #default="scope">
              <el-input v-if="scope.row.__editing"
                        v-model="scope.row.floorCode"
                        placeholder="请输入"
                        clearable
                        style="width: 100%" />
              <span v-else>{{ scope.row.floorCode ?? "" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="重箱"
@@ -2003,7 +2009,7 @@
      entryDate: null, // 录入日期
      entryDateStart: undefined,
      entryDateEnd: undefined,
      deliveryStatus: undefined, // 发货状态:1未发货 2审批中 3审批失败 4已发货
      deliveryStatus: undefined, // 发货状态:1未发货 2审批中 3审批不通过 4审批通过 5已发货 6部分发货
      stockStatus: undefined, // 入库状态:0未入库 1部分入库 2已入库
    },
    form: {
@@ -2216,10 +2222,17 @@
      row.thickness !== null && row.thickness !== undefined && row.thickness !== ""
        ? Number(row.thickness)
        : null;
    copied.floorCode = row?.floorCode ?? row?.floor_code ?? "";
    // 复制新建仅带出产品大类与规格型号,其他数字字段全部留空,避免出现 0.00
    const srcUnit = row?.taxInclusiveUnitPrice;
    const unitNum =
      srcUnit !== null && srcUnit !== undefined && srcUnit !== ""
        ? Number(srcUnit)
        : NaN;
    copied.taxInclusiveUnitPrice = Number.isFinite(unitNum) ? unitNum : null;
    // 复制新建带出:产品大类、规格型号、厚度、楼层编号、单价;其余数量/面积/总价等留空,避免出现 0.00
    copied.quantity = null;
    copied.taxInclusiveUnitPrice = null;
    copied.taxInclusiveTotalPrice = null;
    copied.taxExclusiveTotalPrice = null;
    copied.width = null;
@@ -4504,15 +4517,15 @@
      return false;
    }
    // 如果后端返回了台账级发货状态(deliveryStatus)
    // 1=已发货,则禁止再次发货
    // 台账级发货状态(deliveryStatus):2审批中、5已发货 时不可再发起本行发货;6部分发货仍可按明细继续发
    const deliveryStatus = row.deliveryStatus;
    if (
      deliveryStatus !== null &&
      deliveryStatus !== undefined &&
      String(deliveryStatus).trim() !== ""
    ) {
      if (Number(deliveryStatus) === 1) return false;
      const ds = Number(deliveryStatus);
      if (ds === 2 || ds === 5) return false;
    }
    // 获取发货状态
@@ -4568,12 +4581,16 @@
      return;
    }
    // 只允许【未发货/审批失败】进入发货流程
    // 允许:1未发货、3审批不通过、4审批通过、6部分发货;不允许:2审批中、5已发货
    const statusItem = selectedRows.value[0].deliveryStatus;
    const ledgerAllowsDelivery = s =>
      [1, 3, 4, 6].includes(Number(s));
    let isTrue = true;
    selectedRows.value.forEach(row => {
      if (row.deliveryStatus != 1 && row.deliveryStatus != 3) {
        proxy.$modal.msgWarning("仅未发货或审批失败的台账可以发货");
      if (!ledgerAllowsDelivery(row.deliveryStatus)) {
        proxy.$modal.msgWarning(
          "仅未发货、审批不通过、审批通过或部分发货的台账可以发货"
        );
        isTrue = false;
        return;
      }
@@ -4610,9 +4627,9 @@
      return;
    }
    // 已发货台账:弹窗提醒,不能再次发货(4 视为已发货)
    // 已全部发货(5)的台账:弹窗提醒,不能再次发货
    const shippedLedgers = selectedRows.value.filter(
      r => Number(r.deliveryStatus) === 4
      r => Number(r.deliveryStatus) === 5
    );
    if (shippedLedgers.length === selectedRows.value.length) {
      try {
@@ -4669,9 +4686,9 @@
    try {
      const targets = [];
      for (const ledger of selectedRows.value) {
        //如果已经是“审批中(2)”或“已发货(4)”,则跳过,不允许重复操作
        // 审批中(2)、已全部发货(5) 跳过;部分发货(6) 等仍收集可发明细
        const status = Number(ledger.deliveryStatus);
        if (status === 2 || status === 4) {
        if (status === 2 || status === 5) {
          console.warn(
            `台账编号 ${ledger.salesContractNo} 状态为 ${status},跳过发货`
          );
@@ -4727,10 +4744,11 @@
  // 打开发货弹框(单条)
  const openDeliveryForm = async row => {
    // 只允许【未发货/审批失败】发货;已发货/审批中不允许
    const status = Number(row.deliveryStatus);
    if (status !== 1 && status !== 3) {
      proxy.$modal.msgWarning("只有发货状态为未发货或审批失败的记录才可以发货");
    if (![1, 3, 4, 6].includes(status)) {
      proxy.$modal.msgWarning(
        "只有发货状态为未发货、审批不通过、审批通过或部分发货的记录才可以发货"
      );
      return;
    }
@@ -4793,6 +4811,7 @@
        const run = async () => {
          for (const salesLedgerId of uniqueLedgerIds) {
            await addShippingInfo({
              scanOutbound:  false,
              salesLedgerId,
              type: deliveryForm.value.type,
              approveUserIds,