yaowanxin
4 天以前 62edc8fceb830c85f2a81a525fb9dbbefaac7153
src/views/salesManagement/salesLedger/index.vue
@@ -37,7 +37,7 @@
        </div>
      </div>
      <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
        :expand-row-keys="expandedRowKeys" :row-key="(row) => row.id" show-summary style="width: 100%"
        :expand-row-keys="expandedRowKeys" :row-key="(row) => row.id" :row-class-name="tableRowClassName" show-summary style="width: 100%"
        :summary-method="summarizeMainTable" @expand-change="expandChange" height="calc(100vh - 18.5em)">
        <el-table-column align="center" type="selection" width="55" fixed="left"/>
        <el-table-column type="expand" width="60" fixed="left">
@@ -117,6 +117,7 @@
        <el-table-column label="录入人" prop="entryPersonName" width="100" show-overflow-tooltip />
        <el-table-column label="录入日期" prop="entryDate" width="120" show-overflow-tooltip />
        <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 fixed="right" label="操作" min-width="100" align="center">
          <template #default="scope">
            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">编辑</el-button>
@@ -132,6 +133,14 @@
    <FormDialog v-model="dialogFormVisible" :title="operationType === 'add' ? '新增销售台账页面' : '编辑销售台账页面'" :width="'70%'"
      :operation-type="operationType" @close="closeDia" @confirm="submitForm" @cancel="closeDia">
      <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
            <!-- 报价单导入入口:放在表单顶部,选择后反显客户/业务员等 -->
            <el-row v-if="operationType === 'add'" style="margin-bottom: 10px;">
               <el-col :span="24" style="text-align: right;">
                  <el-button type="primary" plain @click="openQuotationDialog">
                     从销售报价导入
                  </el-button>
               </el-col>
            </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="销售合同号:" prop="salesContractNo">
@@ -196,6 +205,14 @@
                  </el-form-item>
               </el-col>
            </el-row>
        <el-row :gutter="30">
          <el-col :span="12">
            <el-form-item label="交货日期:" prop="entryDate">
              <el-date-picker style="width: 100%" v-model="form.deliveryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
                              type="date" placeholder="请选择" clearable />
            </el-form-item>
          </el-col>
        </el-row>
            <el-row>
               <el-form-item label="产品信息:" prop="entryDate">
                  <el-button v-if="operationType !== 'view'" type="primary" @click="openProductForm('add')">添加</el-button>
@@ -686,6 +703,7 @@
      customerId: "",
      entryPerson: "",
      entryDate: "",
    deliveryDate: "",
      maintenanceTime: "",
      productData: [],
      executionDate: "",
@@ -695,6 +713,7 @@
      customerId: [{ required: true, message: "请选择", trigger: "change" }],
      entryPerson: [{ required: true, message: "请选择", trigger: "change" }],
      entryDate: [{ required: true, message: "请选择", trigger: "change" }],
    deliveryDate: [{ required: true, message: "请选择", trigger: "change" }],
      executionDate: [{ required: true, message: "请选择", trigger: "change" }],
   },
});
@@ -979,6 +998,21 @@
      expandedRowKeys.value = [];
   }
};
// 添加表行类名方法
const tableRowClassName = ({ row }) => {
  const diff = row.deliveryDaysDiff;
  if (diff === 15) {
    return 'yellow';
  } else if (diff === 10) {
    return 'pink';
  } else if (diff === 2) {
    return 'purple';
  } else if (diff < 2) {
    return 'red';
  }
};
// 主表合计方法
const summarizeMainTable = (param) => {
   return proxy.summarizeTable(param, [
@@ -1076,10 +1110,14 @@
   selectedQuotation.value = row;
   
   // 业务员
   form.value.salesman = row.salesperson || "";
   form.value.salesman = (row.salesperson || "").trim();
   
   // 客户名称 -> customerId
   const customer = (customerOption.value || []).find((c) => c.customerName === row.customer);
   const qCustomerName = String(row.customer || "").trim();
   const customer = (customerOption.value || []).find((c) => {
      const name = String(c.customerName || "").trim();
      return name === qCustomerName || name.includes(qCustomerName) || qCustomerName.includes(name);
   });
   if (customer?.id) {
      form.value.customerId = customer.id;
   } else {
@@ -1324,15 +1362,47 @@
         proxy.$modal.msg("已取消");
      });
};
/** 判断销售订单下是否存在已发货/发货完成的产品(不可删除) */
const hasShippedProducts = (products) => {
   if (!products || !products.length) return false;
   return products.some((p) => {
      const status = String(p.shippingStatus || "").trim();
      // 有发货日期或车牌号视为已发货
      if (p.shippingDate || p.shippingCarNumber) return true;
      // 已进行发货、发货完成、已发货 均不可删除
      return status === "已进行发货" || status === "发货完成" || status === "已发货";
   });
};
// 删除
const handleDelete = () => {
   let ids = [];
   if (selectedRows.value.length > 0) {
      ids = selectedRows.value.map((item) => item.id);
   } else {
const handleDelete = async () => {
   if (selectedRows.value.length === 0) {
      proxy.$modal.msgWarning("请选择数据");
      return;
   }
   const ids = selectedRows.value.map((item) => item.id);
   // 检查是否有已进行发货或发货完成的销售订单,若有则不允许删除
   const cannotDeleteNames = [];
   for (const row of selectedRows.value) {
      let products = row.children && row.children.length > 0 ? row.children : null;
      if (!products) {
         try {
            const res = await productList({ salesLedgerId: row.id, type: 1 });
            products = res.data || [];
         } catch {
            products = [];
         }
      }
      if (hasShippedProducts(products)) {
         cannotDeleteNames.push(row.salesContractNo || `ID:${row.id}`);
      }
   }
   if (cannotDeleteNames.length > 0) {
      proxy.$modal.msgWarning("已进行发货或发货完成的销售订单不能删除:" + cannotDeleteNames.join("、"));
      return;
   }
   ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "导出", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
@@ -2072,6 +2142,22 @@
   margin-left: 10px;
}
::v-deep .yellow {
  background-color: #FAF0DE;
}
::v-deep .pink {
  background-color: #FAE1DE;
}
::v-deep .red {
  background-color: #FAE1DE;
}
::v-deep .purple{
  background-color: #F4DEFA;
}
.table_list {
   margin-top: unset;
}