gongchunyi
2 天以前 0c116b0f5624786bd06990b86c467be25e2411fd
src/views/salesManagement/deliveryLedger/index.vue
@@ -32,15 +32,33 @@
        <el-table-column align="center" type="selection" width="55" />
        <el-table-column align="center" label="序号" type="index" width="60" />
        <el-table-column label="销售订单" prop="salesContractNo" show-overflow-tooltip />
        <el-table-column label="发货订单号" prop="shippingNo" show-overflow-tooltip />
        <el-table-column label="客户名称" prop="customerName" show-overflow-tooltip />
        <el-table-column label="发货时间" prop="shippingDate" show-overflow-tooltip />
        <el-table-column label="发货车牌号" prop="shippingCarNumber" show-overflow-tooltip />
        <el-table-column label="快递公司" prop="expressCompany" show-overflow-tooltip />
        <el-table-column label="快递单号" prop="expressNumber" show-overflow-tooltip />
        <el-table-column label="审核状态" prop="status" align="center" width="120">
          <template #default="scope">
            <el-tag :type="getApprovalStatusType(scope.row.status)">
              {{ getApprovalStatusText(scope.row.status) }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="150" align="center">
          <template #default="scope">
            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button>
            <el-button link type="danger" size="small" @click="handleDeleteSingle(scope.row)">删除</el-button>
            <el-button
              link
              type="primary"
              size="small"
              :disabled="!isApproved(scope.row.status)"
              @click="openForm('edit', scope.row)">编辑</el-button>
            <el-button
              link
              type="danger"
              size="small"
              :disabled="!isApproved(scope.row.status)"
              @click="handleDeleteSingle(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
@@ -266,6 +284,12 @@
// 打开弹框
const openForm = async (type, row) => {
  // 编辑时检查审核状态
  if (type === 'edit' && row && !isApproved(row.status)) {
    proxy.$modal.msgWarning("只能编辑审核通过的数据");
    return;
  }
  operationType.value = type;
  const baseUrl = import.meta.env.VITE_APP_BASE_API;
  
@@ -401,13 +425,19 @@
// 批量删除
const handleDelete = () => {
  let ids = [];
  if (selectedRows.value.length > 0) {
    ids = selectedRows.value.map((item) => item.id);
  } else {
  if (selectedRows.value.length === 0) {
    proxy.$modal.msgWarning("请选择数据");
    return;
  }
  // 检查选中的行是否都是"审核通过"状态
  const notApprovedRows = selectedRows.value.filter(row => !isApproved(row.status));
  if (notApprovedRows.length > 0) {
    proxy.$modal.msgWarning("只能删除审核通过的数据");
    return;
  }
  const ids = selectedRows.value.map((item) => item.id);
  ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "删除", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
@@ -426,6 +456,12 @@
// 单个删除
const handleDeleteSingle = (row) => {
  // 检查是否为"审核通过"状态
  if (!isApproved(row.deliveryLedger)) {
    proxy.$modal.msgWarning("只能删除审核通过的数据");
    return;
  }
  ElMessageBox.confirm("此操作将删除该记录,是否确认?", "删除", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
@@ -525,6 +561,80 @@
  }
};
// 获取审核状态文本
const getApprovalStatusText = (status) => {
  if (status === null || status === undefined || status === '') {
    return '待审核';
  }
  // 如果是数字
  if (typeof status === 'number') {
    const statusMap = {
      0: '待审核',
      1: '审核中',
      2: '审核拒绝',
      3: '审核通过'
    };
    return statusMap[status] || '待审核';
  }
  // 如果是字符串,直接返回或映射
  const statusStr = String(status).trim();
  const statusTextMap = {
    '待审核': '待审核',
    '审核中': '审核中',
    '审核拒绝': '审核拒绝',
    '审核通过': '审核通过',
    '0': '待审核',
    '1': '审核中',
    '2': '审核拒绝',
    '3': '审核通过'
  };
  return statusTextMap[statusStr] || statusStr || '待审核';
};
// 获取审核状态标签类型(颜色)
const getApprovalStatusType = (status) => {
  if (status === null || status === undefined || status === '') {
    return 'info';
  }
  // 如果是数字
  if (typeof status === 'number') {
    const typeMap = {
      0: 'info',      // 待审核 - 灰色
      1: 'warning',   // 审核中 - 黄色
      2: 'danger',    // 审核拒绝 - 红色
      3: 'success'    // 审核通过 - 绿色
    };
    return typeMap[status] || 'info';
  }
  // 如果是字符串
  const statusStr = String(status).trim();
  const typeTextMap = {
    '待审核': 'info',
    '审核中': 'warning',
    '审核拒绝': 'danger',
    '审核通过': 'success',
    '0': 'info',
    '1': 'warning',
    '2': 'danger',
    '3': 'success'
  };
  return typeTextMap[statusStr] || 'info';
};
// 检查审核状态是否为"审核通过"
const isApproved = (status) => {
  if (status === null || status === undefined || status === '') {
    return false;
  }
  // 如果是数字,3 表示审核通过
  if (typeof status === 'number') {
    return status === 3;
  }
  // 如果是字符串
  const statusStr = String(status).trim();
  return statusStr === '审核通过' || statusStr === '3';
};
onMounted(() => {
  getList();
});