gaoluyang
2 天以前 3a07f2ca675bbd3c55893f7731b8f49d854b0e07
src/views/salesManagement/salesLedger/index.vue
@@ -45,7 +45,7 @@
            <el-table :data="props.row.children" border show-summary :summary-method="summarizeChildrenTable">
              <el-table-column align="center" label="序号" type="index"/>
              <el-table-column label="产品大类" prop="productCategory" />
              <el-table-column label="规格型号" prop="specificationModel" />
              <el-table-column label="图纸编号" prop="specificationModel" />
              <el-table-column label="单位" prop="unit" />
                     <el-table-column label="产品状态"
                                              width="100px"
@@ -64,34 +64,15 @@
                           </el-tag>
                        </template>
                     </el-table-column>
                     <el-table-column label="快递公司" prop="expressCompany" show-overflow-tooltip />
                     <el-table-column label="快递单号" prop="expressNumber" show-overflow-tooltip />
              <el-table-column label="发货车牌" minWidth="100px" align="center">
                <template #default="scope">
                  <div>
                    <el-tag type="success" v-if="scope.row.shippingCarNumber">{{ scope.row.shippingCarNumber }}</el-tag>
                    <el-tag v-else type="info">-</el-tag>
                  </div>
                </template>
              </el-table-column>
                     <el-table-column label="发货日期"
                                              minWidth="100px"
                                              align="center">
                <template #default="scope">
                  <div>
                    <div v-if="scope.row.shippingDate">{{ scope.row.shippingDate }}</div>
                              <el-tag v-else
                                          type="info">-</el-tag>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="已发货数量" prop="shippingNum" align="center" />
              <el-table-column label="已退货数量" prop="returnNum" align="center" />
              <el-table-column label="数量" prop="quantity" />
              <el-table-column label="税率(%)" prop="taxRate" />
              <el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
              <el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
              <el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
            <!--操作-->
              <el-table-column Width="60px" label="操作" align="center">
              <el-table-column width="150" label="操作" align="center" fixed="right">
                <template #default="scope">
                  <el-button 
                    link 
@@ -100,6 +81,14 @@
                    :disabled="!canShip(scope.row)"
                    @click="openDeliveryForm(scope.row)">
                    发货
                  </el-button>
                  <el-button
                    link
                    type="danger"
                    size="small"
                    :disabled="!canRevokeShipping(scope.row)"
                    @click="handleRevokeShipping(scope.row)">
                    撤销发货
                  </el-button>
                </template>
              </el-table-column>
@@ -119,7 +108,7 @@
        <el-table-column label="签订日期" prop="executionDate" width="120" show-overflow-tooltip />
        <el-table-column label="交付日期" prop="deliveryDate" width="120" show-overflow-tooltip />
        <el-table-column label="备注" prop="remarks" width="200" show-overflow-tooltip />
        <el-table-column fixed="right" label="操作" min-width="100" align="center">
        <el-table-column fixed="right" label="操作" width="100" align="center">
          <template #default="scope">
            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button>
<!--            <el-button link type="primary" size="small" @click="openForm('view', scope.row)">详情</el-button>-->
@@ -145,7 +134,7 @@
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="销售合同号:" prop="salesContractNo">
              <el-input v-model="form.salesContractNo" placeholder="自动生成" clearable disabled />
              <el-input v-model="form.salesContractNo" placeholder="自动生成或手动输入" clearable :disabled="operationType === 'view'" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
@@ -226,7 +215,7 @@
                  :selectable="(row) => !isProductShipped(row)" />
               <el-table-column align="center" label="序号" type="index" width="60" />
               <el-table-column label="产品大类" prop="productCategory" />
               <el-table-column label="规格型号" prop="specificationModel" />
               <el-table-column label="图纸编号" prop="specificationModel" />
               <el-table-column label="单位" prop="unit" />
               <el-table-column label="数量" prop="quantity" />
               <el-table-column label="税率(%)" prop="taxRate" />
@@ -339,13 +328,13 @@
                        <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
                     </el-select> -->
                     <el-tree-select v-model="productForm.productCategory" placeholder="请选择" clearable check-strictly
                                             @change="getModels" :data="productOptions" :render-after-expand="false" style="width: 100%" />
                                             @change="getModels" :data="productOptions" :render-after-expand="false" filterable style="width: 100%" />
                  </el-form-item>
               </el-col>
            </el-row>
            <el-row :gutter="30">
               <el-col :span="24">
                  <el-form-item label="规格型号:" prop="productModelId">
                  <el-form-item label="图纸编号:" prop="productModelId">
                     <el-select v-model="productForm.productModelId" placeholder="请选择" clearable @change="getProductModel" filterable>
                        <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
                     </el-select>
@@ -472,7 +461,7 @@
               <div v-for="(item, index) in printData" :key="index" class="print-page">
                  <div class="delivery-note">
                     <div class="header">
                        <div class="company-name">鼎诚瑞实业有限责任公司</div>
                        <div class="company-name">军泰伟业机械有限公司</div>
                        <div class="document-title">零售发货单</div>
                     </div>
                     
@@ -502,7 +491,7 @@
                           <thead>
                           <tr>
                              <th>产品名称</th>
                              <th>规格型号</th>
                              <th>图纸编号</th>
                              <th>单位</th>
                              <th>单价</th>
                              <th>零售数量</th>
@@ -574,21 +563,6 @@
         @close="closeDeliveryDia"
      >
         <el-form :model="deliveryForm" label-width="120px" label-position="top" :rules="deliveryRules" ref="deliveryFormRef">
            <el-row :gutter="30">
               <el-col :span="24">
                  <el-form-item label="发货类型:" prop="type">
                     <el-select
                        v-model="deliveryForm.type"
                        placeholder="请选择发货类型"
                        style="width: 100%"
                     >
                        <el-option label="货车" value="货车" />
                        <el-option label="快递" value="快递" />
                     </el-select>
                  </el-form-item>
               </el-col>
            </el-row>
        <!-- 审批人选择(仿协同审批里的审批人节点选择) -->
        <el-row>
          <el-col :span="24">
@@ -665,7 +639,7 @@
   delLedger,
   addOrUpdateSalesLedgerProduct,
   delProduct,
   delLedgerFile, getProductInventory,
   delLedgerFile, getProductInventory, cancelDelivery,
} from "@/api/salesManagement/salesLedger.js";
import { modelList, productTreeList } from "@/api/basicData/product.js";
import useFormData from "@/hooks/useFormData.js";
@@ -787,14 +761,8 @@
const deliveryFormVisible = ref(false);
const currentDeliveryRow = ref(null);
const deliveryFormData = reactive({
  deliveryForm: {
    type: "货车", // 货车, 快递
  },
  deliveryRules: {
    type: [
      { required: true, message: "请选择发货类型", trigger: "change" }
    ]
  },
  deliveryForm: {},
  deliveryRules: {},
});
const { deliveryForm, deliveryRules } = toRefs(deliveryFormData);
@@ -922,6 +890,7 @@
      modelOptions.value = res;
   });
};
const getProductModel = (value) => {
   const index = modelOptions.value.findIndex((item) => item.id === value);
   if (index !== -1) {
@@ -1644,7 +1613,7 @@
      <div class="print-page">
        <div class="delivery-note">
          <div class="header">
            <div class="company-name">鼎诚瑞实业有限责任公司</div>
            <div class="company-name">军泰伟业机械有限公司</div>
            <div class="document-title">零售发货单</div>
          </div>
          
@@ -1670,7 +1639,7 @@
              <thead>
                <tr>
                  <th>产品名称</th>
                  <th>规格型号</th>
                  <th>图纸编号</th>
                  <th>单位</th>
                  <th>单价</th>
                  <th>零售数量</th>
@@ -1984,11 +1953,6 @@
 * @param row 行数据
 */
const getShippingStatusText = (row) => {
   // 如果已发货(有发货日期或车牌号),显示"已发货"
   if (row.shippingDate || row.shippingCarNumber) {
      return '已发货';
   }
   // 获取发货状态字段
   const status = row.shippingStatus;
   
@@ -1999,13 +1963,25 @@
   
   // 状态是字符串
   const statusStr = String(status).trim();
   // 如果状态是"已撤销",直接返回
   if (statusStr === '已撤销') {
      return '已撤销';
   }
   // 如果已发货(有发货日期或车牌号),显示"已发货"
   if (row.shippingDate || row.shippingCarNumber) {
      return '已发货';
   }
   const statusTextMap = {
      '待发货': '待发货',
      '待审核': '待审核',
      '审核中': '审核中',
      '审核拒绝': '审核拒绝',
      '审核通过': '审核通过',
      '已发货': '已发货'
      '已发货': '已发货',
      '已撤销': '已撤销'
   };
   return statusTextMap[statusStr] || '待发货';
};
@@ -2015,11 +1991,6 @@
 * @param row 行数据
 */
const getShippingStatusType = (row) => {
   // 如果已发货(有发货日期或车牌号),显示绿色
   if (row.shippingDate || row.shippingCarNumber) {
      return 'success';
   }
   // 获取发货状态字段
   const status = row.shippingStatus;
   
@@ -2030,11 +2001,23 @@
   
   // 状态是字符串
   const statusStr = String(status).trim();
   // 如果状态是"已撤销",显示橙色
   if (statusStr === '已撤销') {
      return 'warning';
   }
   // 如果已发货(有发货日期或车牌号),显示绿色
   if (row.shippingDate || row.shippingCarNumber) {
      return 'success';
   }
   const typeTextMap = {
      '待发货': 'info',
      '待审核': 'info',
      '审核中': 'warning',
      '审核拒绝': 'danger',
      '已撤销': 'warning',
      '审核通过': 'success',
      '已发货': 'success'
   };
@@ -2043,7 +2026,7 @@
/**
 * 判断是否可以发货
 * 只有在产品状态是充足,发货状态是待发货和审核拒绝的时候才可以发货
 * 只有在产品状态是充足,发货状态是待发货、审核拒绝和已撤销的时候才可以发货
 * @param row 行数据
 */
const canShip = (row) => {
@@ -2055,14 +2038,56 @@
   // 获取发货状态
   const shippingStatus = row.shippingStatus;
   
   // 如果状态为空或未定义,默认为"待发货"
   if (shippingStatus === null || shippingStatus === undefined || shippingStatus === '') {
      return true;
   }
   // 状态是字符串
   const statusStr = String(shippingStatus).trim();
   // 如果状态是"已撤销",允许发货
   if (statusStr === '已撤销') {
      return true;
   }
   // 如果已发货(有发货日期或车牌号),不能再次发货
   if (row.shippingDate || row.shippingCarNumber) {
      return false;
   }
   
   // 发货状态必须是"待发货"或"审核拒绝"
   const statusStr = shippingStatus ? String(shippingStatus).trim() : '';
   // 发货状态必须是"待发货"、"审核拒绝"或"已撤销"
   return statusStr === '待发货' || statusStr === '审核拒绝';
};
/**
 * 判断是否可以撤销发货
 * 只有当发货数量等于退货数量且都不为0时才可以撤销
 * @param row 行数据
 */
const canRevokeShipping = (row) => {
   const shippingNum = row.shippingNum || 0;
   const returnNum = row.returnNum || 0;
   return shippingNum > 0 && returnNum > 0 && shippingNum === returnNum;
};
/**
 * 撤销发货
 * @param row 行数据
 */
const handleRevokeShipping = (row) => {
   ElMessageBox.confirm("此操作将撤销该发货记录,是否确认?", "撤销发货", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
   })
      .then(() => {
         cancelDelivery({ id: row.id }).then(() => {
            proxy.$modal.msgSuccess("撤销成功");
            getList();
         });
      })
      .catch(() => {});
};
/**
@@ -2109,14 +2134,13 @@
        return;
      }
      const approveUserIds = approverNodes.value.map(node => node.userId).join(",");
      // 保存当前展开的行ID,以便发货后重新加载子表格数据
      const currentExpandedKeys = [...expandedRowKeys.value];
      const salesLedgerId = currentDeliveryRow.value.salesLedgerId;
      addShippingInfo({
        salesLedgerId: salesLedgerId,
        salesLedgerProductId: currentDeliveryRow.value.id,
        type: deliveryForm.value.type,
            approveUserIds,
        shippingTotal: currentDeliveryRow.value.quantity,
        approveUserIds,
      })
        .then(() => {
          proxy.$modal.msgSuccess("发货成功");
@@ -2170,19 +2194,19 @@
   margin-left: 10px;
}
::v-deep .yellow {
:deep(.yellow) {
  background-color: #FAF0DE;
}
::v-deep .pink {
:deep(.pink) {
  background-color: #FAE1DE;
}
::v-deep .red {
:deep(.red) {
  background-color: #FAE1DE;
}
::v-deep .purple{
:deep(.purple){
  background-color: #F4DEFA;
}