From 40b5273e2540cee05bf3b9f11af5706989b5f699 Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期五, 27 六月 2025 16:42:11 +0800
Subject: [PATCH] 提交删除部分页面导出按钮 修改采购逻辑 取消供应商新增校验 完善vue打包以后找不到文件的问题

---
 src/views/basicInformation/index.vue |  507 +++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 316 insertions(+), 191 deletions(-)

diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index b41cf57..26dc9b9 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -2,7 +2,11 @@
   <div class="app-container">
     <el-form :inline="true" :model="queryParams" class="search-form">
       <el-form-item v-if="shouldShowSearch" label="鎼滅储">
-        <el-input v-model="queryParams.searchAll" :placeholder="searchPlaceholder" clearable/>
+        <el-input
+          v-model="queryParams.searchAll"
+          :placeholder="searchPlaceholder"
+          clearable
+        />
       </el-form-item>
       <el-form-item>
         <el-button type="primary" @click="search">鏌ヨ</el-button>
@@ -11,63 +15,149 @@
     </el-form>
     <el-card>
       <!-- 鏍囩椤� -->
-      <el-tabs v-model="activeTab" class="info-tabs" @tab-click="handleTabClick">
-        <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="tab.label" :name="tab.name"/>
+      <el-tabs
+        v-model="activeTab"
+        class="info-tabs"
+        @tab-click="handleTabClick"
+      >
+        <el-tab-pane
+          v-for="tab in tabs"
+          :key="tab.name"
+          :label="tab.label"
+          :name="tab.name"
+        />
       </el-tabs>
 
       <!-- 鎿嶄綔鎸夐挳鍖� -->
       <el-row :gutter="24" class="table-toolbar">
-        <el-button :icon="Plus" type="primary" @click="handleAdd">鏂板缓</el-button>
-        <el-button :icon="Delete" type="danger" @click="handleDelete">鍒犻櫎</el-button>
-        <el-button @click="jump">admins</el-button>
-        <el-button v-show="canExport" :icon="Download" type="info" @click="handleExport">瀵煎嚭</el-button>
-      </el-row> <!-- 琛ㄦ牸缁勪欢 -->
+        <el-button :icon="Plus" type="primary" @click="handleAdd"
+          >鏂板缓</el-button
+        >
+        <el-button :icon="Delete" type="danger" @click="handleDelete"
+          >鍒犻櫎</el-button
+        >
+        <el-button
+          v-show="canExport"
+          :icon="Download"
+          type="info"
+          @click="handleExport"
+          >瀵煎嚭</el-button
+        >
+      </el-row>
+      <!-- 琛ㄦ牸缁勪欢 -->
       <div>
-        <data-table :border="true" :columns="columns" :loading="loading" style="width: 100%;height: calc(100vh - 29em)"
-                    :show-selection="true" :table-data="tableData" @edit="handleEdit" @selection-change="handleSelectionChange">
+        <data-table
+          :border="true"
+          :columns="columns"
+          :loading="loading"
+          style="width: 100%; height: calc(100vh - 29em)"
+          :show-selection="true"
+          :table-data="tableData"
+          @edit="handleEdit"
+          @viewRow="handleView"
+          @selection-change="handleSelectionChange"
+          :operations="['edit', 'viewRow']"
+          :operationsWidth="200"
+        >
           <!-- 瀛楁鍚嶇О鍒楃殑鑷畾涔夋彃妲� - 鏄剧ず涓烘爣绛� -->
-          <template v-if="tabName === 'coalQualityMaintenance'" #fieldIds="{ row }">
-            <template v-if="typeof row.fieldIds === 'string' && row.fieldIds.includes(',')">
-              <el-tag v-for="(field, index) in row.fieldIds.split(',')" :key="index" size="small" style="margin-right: 4px; margin-bottom: 2px;"
-                      type="primary">
+          <template
+            v-if="tabName === 'coalQualityMaintenance'"
+            #fieldIds="{ row }"
+          >
+            <template
+              v-if="
+                typeof row.fieldIds === 'string' && row.fieldIds.includes(',')
+              "
+            >
+              <el-tag
+                v-for="(field, index) in row.fieldIds.split(',')"
+                :key="index"
+                size="small"
+                style="margin-right: 4px; margin-bottom: 2px"
+                type="primary"
+              >
                 {{ getFieldDisplayName(field.trim()) }}
               </el-tag>
             </template>
             <template v-else>
               <el-tag size="small" type="primary">
-                {{ getFieldDisplayName(row.fieldIds) || '--' }}
+                {{ getFieldDisplayName(row.fieldIds) || "--" }}
               </el-tag>
             </template>
           </template>
         </data-table>
       </div>
-      <pagination v-if="total > 0" :layout="'total, prev, pager, next, jumper'" :limit="pageSizes" :page="pageNum" :total="total"
-                  @pagination="handPagination"/>
-      <Supplier v-if="tabName === 'supplier'" v-model:copyForm="copyForm"
-                v-model:supplierDialogFormVisible="dialogFormVisible" :addOrEdit="addOrEdit" :form="form" :title="title"
-                @beforeClose="handleBeforeClose" @submit="handleSubmit"
-                @update:dialogFormVisible="handleDialogFormVisible"/>
-      <Customer v-if="tabName === 'customer'" v-model:copyForm="copyForm"
-                v-model:customerDialogFormVisible="dialogFormVisible" :addOrEdit="addOrEdit" :form="form" :title="title"
-                @beforeClose="handleBeforeClose" @submit="handleSubmit"/>
-      <Coal v-if="tabName === 'coal'" v-model:coalDialogFormVisible="dialogFormVisible" v-model:copyForm="copyForm"
-            :addOrEdit="addOrEdit" :form="form" :title="title" @submit="handleSubmit"/>
-      <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'" v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible"
-                              v-model:copyForm="copyForm" :addOrEdit="addOrEdit"
-                              :form="form"
-                              :title="title" @submit="handleSubmit"/>
-      <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'" v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible"
-                             v-model:copyForm="copyForm" :addOrEdit="addOrEdit" :form="form"
-                             :title="title"
-                             @submit="handleSubmit"/>
+      <pagination
+        v-if="total > 0"
+        :layout="'total, prev, pager, next, jumper'"
+        :limit="pageSizes"
+        :page="pageNum"
+        :total="total"
+        @pagination="handPagination"
+      />
+      <Supplier
+        v-if="tabName === 'supplier'"
+        v-model:copyForm="copyForm"
+        v-model:supplierDialogFormVisible="dialogFormVisible"
+        :addOrEdit="addOrEdit"
+        :form="form"
+        :title="title"
+        @beforeClose="handleBeforeClose"
+        @submit="handleSubmit"
+        @update:dialogFormVisible="handleDialogFormVisible"
+      />
+      <Customer
+        v-if="tabName === 'customer'"
+        v-model:copyForm="copyForm"
+        v-model:customerDialogFormVisible="dialogFormVisible"
+        :addOrEdit="addOrEdit"
+        :form="form"
+        :title="title"
+        @beforeClose="handleBeforeClose"
+        @submit="handleSubmit"
+      />
+      <Coal
+        v-if="tabName === 'coal'"
+        v-model:coalDialogFormVisible="dialogFormVisible"
+        v-model:copyForm="copyForm"
+        :addOrEdit="addOrEdit"
+        :form="form"
+        :title="title"
+        @submit="handleSubmit"
+      />
+      <coalQualityMaintenance
+        v-if="tabName === 'coalQualityMaintenance'"
+        v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible"
+        v-model:copyForm="copyForm"
+        :addOrEdit="addOrEdit"
+        :form="form"
+        :title="title"
+        @submit="handleSubmit"
+      />
+      <coalMeiZhiZiDuanWeiHu
+        v-if="tabName === 'coalMeiZhiZiDuanWeiHu'"
+        v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible"
+        v-model:copyForm="copyForm"
+        :addOrEdit="addOrEdit"
+        :form="form"
+        :title="title"
+        @submit="handleSubmit"
+      />
     </el-card>
   </div>
 </template>
 
 <script setup>
-import {computed, getCurrentInstance, onMounted, reactive, ref, nextTick} from "vue";
-import {ElMessage, ElMessageBox} from "element-plus";
-import {Delete, Download, Plus} from "@element-plus/icons-vue";
+import {
+  computed,
+  getCurrentInstance,
+  onMounted,
+  reactive,
+  ref,
+  nextTick,
+} from "vue";
+import { ElMessage, ElMessageBox } from "element-plus";
+import { Delete, Download, Plus } from "@element-plus/icons-vue";
 
 // ===== 缁勪欢瀵煎叆 =====
 import DataTable from "@/components/Table/ETable.vue";
@@ -79,21 +169,27 @@
 import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue";
 
 // ===== API 鏈嶅姟瀵煎叆 =====
-import {delSupply, getSupply} from "@/api/basicInformation/supplier.js";
-import {delCoalInfo, getCoalInfo} from "@/api/basicInformation/coal.js";
-import {testUserList} from "@/api/tool/publicInterface.js";
-import {getAreaOptions} from "@/api/system/area.js";
-import {delCustomer, getCustomerList} from "@/api/basicInformation/customer.js";
-import {coalField, deleteCoalField} from "@/api/basicInformation/coalFieldMaintenance.js";
-import {getCoalFieldList, getCoalPlanList} from "@/api/basicInformation/coalQualityMaintenance";
-
-const {proxy} = getCurrentInstance();
-import router from "@/router";
+import { delSupply, getSupply } from "@/api/basicInformation/supplier.js";
+import { delCoalInfo, getCoalInfo } from "@/api/basicInformation/coal.js";
+import { testUserList } from "@/api/tool/publicInterface.js";
+import { getAreaOptions } from "@/api/system/area.js";
+import {
+  delCustomer,
+  getCustomerList,
+} from "@/api/basicInformation/customer.js";
+import {
+  coalField,
+  deleteCoalField,
+} from "@/api/basicInformation/coalFieldMaintenance.js";
+import {
+  getCoalFieldList,
+  getCoalPlanList,
+  delCoalPlan,
+} from "@/api/basicInformation/coalQualityMaintenance";
+import { useDelete } from "@/hooks/useDelete.js";
+const { proxy } = getCurrentInstance();
 
 // ===== 鍝嶅簲寮忕姸鎬佺鐞� =====
-const jump = () => {
-};
-// 寮圭獥鎺у埗鐘舵��
 const dialogFormVisible = ref(false);
 const form = ref({});
 const title = ref("");
@@ -131,11 +227,11 @@
 
 // 鏍囩椤甸厤缃�
 const tabs = reactive([
-  {name: "supplier", label: "渚涘簲鍟嗕俊鎭�"},
-  {name: "customer", label: "瀹㈡埛淇℃伅"},
-  {name: "coal", label: "鐓ょ淇℃伅"},
-  {name: "coalQualityMaintenance", label: "鐓よ川鏂规"},
-  {name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁"}
+  { name: "supplier", label: "渚涘簲鍟嗕俊鎭�" },
+  { name: "customer", label: "瀹㈡埛淇℃伅" },
+  { name: "coal", label: "鐓ょ淇℃伅" },
+  { name: "coalQualityMaintenance", label: "鐓よ川鏂规" },
+  { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" },
 ]);
 
 // ===== 宸ュ叿鍑芥暟 =====
@@ -153,7 +249,7 @@
       buildAddressMap(res.data);
     }
   } catch (error) {
-    console.error('鑾峰彇鍦板潃閫夐」澶辫触:', error);
+    console.error("鑾峰彇鍦板潃閫夐」澶辫触:", error);
   }
 };
 
@@ -164,11 +260,11 @@
  */
 const buildAddressMap = (areaData) => {
   const buildMap = (list, pathList = []) => {
-    list.forEach(item => {
+    list.forEach((item) => {
       const currentPath = [...pathList, item.label];
       addressMap.value[item.id] = {
         name: item.label,
-        fullPath: currentPath.join(' / ')
+        fullPath: currentPath.join(" / "),
       };
       if (item.children && item.children.length > 0) {
         buildMap(item.children, currentPath);
@@ -185,19 +281,26 @@
  * @description 灏嗗湴鍧�ID鏁扮粍杞崲涓哄彲璇荤殑鍦板潃瀛楃涓�
  */
 const formatAddressArray = (addressIds) => {
-  if (!addressMap.value || Object.keys(addressMap.value).length === 0 ||
-      !addressIds || !Array.isArray(addressIds) || addressIds.length === 0 ||
-      addressIds.every(id => !id)) {
-    return '--';
+  if (
+    !addressMap.value ||
+    Object.keys(addressMap.value).length === 0 ||
+    !addressIds ||
+    !Array.isArray(addressIds) ||
+    addressIds.length === 0 ||
+    addressIds.every((id) => !id)
+  ) {
+    return "--";
   }
 
-  const addressNames = addressIds.map(id => addressMap.value[id]?.name || '--');
+  const addressNames = addressIds.map(
+    (id) => addressMap.value[id]?.name || "--"
+  );
 
-  if (addressNames.every(name => name === '--')) {
-    return '--';
+  if (addressNames.every((name) => name === "--")) {
+    return "--";
   }
 
-  return addressNames.filter(name => name !== '--').join(' / ');
+  return addressNames.filter((name) => name !== "--").join(" / ");
 };
 
 /**
@@ -207,14 +310,16 @@
 const getUserList = async () => {
   try {
     const res = await testUserList();
+    console.log("鑾峰彇鐢ㄦ埛鍒楄〃鏁版嵁:", res);
+    console.log("userMap:", userMap.value);
     if (res && res.data) {
       userList.value = res.data;
-      userList.value.forEach(user => {
-        userMap.value[user.userId] = user.username;
+      userList.value.forEach((user) => {
+        userMap.value[user.userId] = user.nickName;
       });
     }
   } catch (error) {
-    console.error('鑾峰彇鐢ㄦ埛鍒楄〃澶辫触:', error);
+    console.error("鑾峰彇鐢ㄦ埛鍒楄〃澶辫触:", error);
   }
 };
 
@@ -224,12 +329,12 @@
  */
 const coalFieldData = async () => {
   try {
-    const {data, code} = await getCoalFieldList();
+    const { data, code } = await getCoalFieldList();
     if (code === 200) {
       coalFieldList.value = data;
     }
   } catch (error) {
-    console.error('鑾峰彇鐓よ川瀛楁鏁版嵁澶辫触:', error);
+    console.error("鑾峰彇鐓よ川瀛楁鏁版嵁澶辫触:", error);
   }
 };
 
@@ -240,21 +345,19 @@
  * @description 閫氳繃瀛楁ID鍖归厤瀵瑰簲鐨勫瓧娈靛悕绉�
  */
 const getFieldDisplayName = (fieldId) => {
-  if (!fieldId) return '--';
+  if (!fieldId) return "--";
 
   const numId = parseInt(fieldId);
-  const matchedField = coalFieldList.value.find(item => item.id === numId);
+  const matchedField = coalFieldList.value.find((item) => item.id === numId);
 
   return matchedField ? matchedField.fieldName : numId;
 };
-
-// ===== 璁$畻灞炴�� =====
 
 /**
  * 褰撳墠鏍囩椤垫槸鍚︽敮鎸佸鍑哄姛鑳�
  */
 const canExport = computed(() => {
-  return ['supplier', 'customer'].includes(tabName.value);
+  return ["supplier", "customer"].includes(tabName.value);
 });
 
 /**
@@ -262,11 +365,11 @@
  */
 const searchPlaceholder = computed(() => {
   const placeholderMap = {
-    supplier: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃",
-    customer: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃",
-    coal: "璇疯緭鍏ユ悳绱俊鎭�",
-    coalQualityMaintenance: "璇疯緭鍏ユ悳绱俊鎭�",
-    coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ユ悳绱俊鎭�"
+    supplier: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃",
+    customer: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃",
+    coal: "璇疯緭鍏ョ叅绉嶄俊鎭�",
+    coalQualityMaintenance: "璇疯緭鍏ョ叅璐ㄦ柟妗堜俊鎭�",
+    coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ョ叅璐ㄥ瓧娈典俊鎭�",
   };
   return placeholderMap[tabName.value] || "璇疯緭鍏ユ悳绱俊鎭�";
 });
@@ -275,7 +378,13 @@
  * 鏄惁鏄剧ず鎼滅储妗�
  */
 const shouldShowSearch = computed(() => {
-  return ['supplier', 'customer', 'coal', 'coalQualityMaintenance', 'coalMeiZhiZiDuanWeiHu'].includes(tabName.value);
+  return [
+    "supplier",
+    "customer",
+    "coal",
+    "coalQualityMaintenance",
+    "coalMeiZhiZiDuanWeiHu",
+  ].includes(tabName.value);
 });
 
 /**
@@ -283,19 +392,14 @@
  */
 const selectedCount = computed(() => selectedRows.value.length);
 
-/**
- * 鏄惁鏈夐�変腑鐨勮
- */
-const hasSelectedRows = computed(() => selectedCount.value > 0);
-
 // ===== 琛ㄦ牸鍒楅厤缃� =====
 
 /**
  * 渚涘簲鍟嗚〃鏍煎垪閰嶇疆
  */
 const supplierColumns = ref([
-  {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100},
-  {prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170},
+  { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100 },
+  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170 },
   {
     prop: "bids",
     label: "缁忚惀鍦板潃",
@@ -304,12 +408,11 @@
     formatter: (row) => {
       const addressIds = [row.bprovinceId, row.bcityId, row.bdistrictId];
       return formatAddressArray(addressIds);
-    }
+    },
   },
-  {prop: "businessAddress", label: "缁忚惀璇︾粏鍦板潃", minWidth: 150},
-  {prop: "bankAccount", label: "寮�鎴疯", minWidth: 120},
-  {prop: "bankName", label: "閾惰璐﹀彿", minWidth: 150},
-  {prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100},
+  { prop: "businessAddress", label: "缁忚惀璇︾粏鍦板潃", minWidth: 150 },
+  { prop: "bankAccount", label: "寮�鎴疯", minWidth: 120 },
+  { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 },
   {
     prop: "cids",
     label: "鑱旂郴浜哄湴鍧�",
@@ -318,33 +421,36 @@
     formatter: (row) => {
       const addressIds = [row.cprovinceId, row.ccityId, row.cdistrictId];
       return formatAddressArray(addressIds);
-    }
+    },
   },
-  {prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120},
-  {prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 120},
+  { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 },
 ]);
 
 /**
  * 瀹㈡埛琛ㄦ牸鍒楅厤缃�
  */
 const customerColumns = ref([
-  {prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100},
-  {prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120},
+  { prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100 },
+  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 },
   {
     prop: "bids",
     label: "缁忚惀鍦板潃",
     minWidth: 150,
     showOverflowTooltip: true,
     formatter: (row) => {
-      const addressIds = [row.businessProvinceId, row.businessCityId, row.businessDistrictId];
+      const addressIds = [
+        row.businessProvinceId,
+        row.businessCityId,
+        row.businessDistrictId,
+      ];
       return formatAddressArray(addressIds);
-    }
+    },
   },
-  {prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150},
-  {prop: "bankName", label: "寮�鎴疯", minWidth: 120},
-  {prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150},
-  {prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100},
-  {prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100},
+  { prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150 },
+  { prop: "bankName", label: "寮�鎴疯", minWidth: 120 },
+  { prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150 },
+  { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 },
+  { prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100 },
   {
     prop: "cids",
     label: "鑱旂郴浜哄湴鍧�",
@@ -353,39 +459,39 @@
     formatter: (row) => {
       const addressIds = [row.provinceId, row.cityId, row.districtId];
       return formatAddressArray(addressIds);
-    }
+    },
   },
-  {prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150},
-  {prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100},
+  { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150 },
+  { prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100 },
 ]);
 
 /**
  * 鐓ょ琛ㄦ牸鍒楅厤缃�
  */
 const coalColumns = ref([
-  {prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200},
+  { prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200 },
   {
     prop: "maintainerId",
     label: "缁存姢浜�",
     minWidth: 120,
     formatter: (row, column, cellValue) => {
       if (!userMap.value || Object.keys(userMap.value).length === 0) {
-        return '--';
+        return "--";
       }
-      if (cellValue === null || cellValue === undefined || cellValue === '') {
-        return '--';
+      if (cellValue === null || cellValue === undefined || cellValue === "") {
+        return "--";
       }
-      return userMap.value[cellValue] || '--';
-    }
+      return userMap.value[cellValue] || "--";
+    },
   },
-  {prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150},
+  { prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150 },
 ]);
 
 /**
  * 鐓よ川鏂规琛ㄦ牸鍒楅厤缃�
  */
 const coalQualityMaintenanceColumns = ref([
-  {prop: "plan", label: "鏂规鍚嶇О", minWidth: 100},
+  { prop: "plan", label: "鏂规鍚嶇О", minWidth: 100 },
   {
     prop: "fieldIds",
     label: "瀛楁鍚嶇О",
@@ -394,20 +500,20 @@
     slot: true,
     formatter: (row, column, cellValue) => {
       if (Array.isArray(cellValue)) {
-        return cellValue.map(item => item);
+        return cellValue.map((item) => item);
       }
-      return cellValue || '--';
-    }
+      return cellValue || "--";
+    },
   },
-  {prop: "schemeDesc", label: "瀛楁鎻忚堪", minWidth: 100},
+  { prop: "schemeDesc", label: "瀛楁鎻忚堪", minWidth: 100 },
 ]);
 
 /**
  * 鐓よ川瀛楁琛ㄦ牸鍒楅厤缃�
  */
 const coalMeiZhiZiDuanWeiHuColumns = ref([
-  {prop: "fieldName", label: "瀛楁鍚嶇О", minWidth: 200},
-  {prop: "fieldDescription", label: "瀛楁鎻忚堪", minWidth: 200},
+  { prop: "fieldName", label: "瀛楁鍚嶇О", minWidth: 200 },
+  { prop: "fieldDescription", label: "瀛楁鎻忚堪", minWidth: 200 },
 ]);
 // ===== 浜嬩欢澶勭悊鍑芥暟 =====
 
@@ -449,7 +555,7 @@
     coalMeiZhiZiDuanWeiHu: () => {
       columns.value = coalMeiZhiZiDuanWeiHuColumns.value;
       getList();
-    }
+    },
   };
 
   // 鎵ц瀵瑰簲鐨勯厤缃嚱鏁�
@@ -495,17 +601,22 @@
  * @description 鏍规嵁鏍囩椤电被鍨嬭缃脊绐楁爣棰樺苟鎵撳紑寮圭獥
  */
 const handleAddEdit = (currentTabName) => {
-  const actionText = addOrEdit.value === "add" ? "鏂板" : "缂栬緫";
+  const actionText =
+    addOrEdit.value === "add"
+      ? "鏂板"
+      : addOrEdit.value === "edit"
+      ? "缂栬緫"
+      : "鏌ョ湅";
 
   const tabTitleMap = {
     supplier: "渚涘簲鍟嗕俊鎭�",
     customer: "瀹㈡埛淇℃伅",
     coal: "鐓ょ淇℃伅",
     coalQualityMaintenance: "鐓よ川鏂规缁存姢",
-    coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢"
+    coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢",
   };
 
-  title.value = `${actionText}${tabTitleMap[currentTabName] || ''}`;
+  title.value = `${actionText}${tabTitleMap[currentTabName] || ""}`;
   openDialog();
 };
 
@@ -514,7 +625,7 @@
  * @description 鏍规嵁缂栬緫鐘舵�佸喅瀹氭槸鍚﹀鍒惰〃鍗曟暟鎹�
  */
 const openDialog = () => {
-  if (addOrEdit.value === "edit") {
+  if (addOrEdit.value === "edit" || addOrEdit.value === "viewRow") {
     copyForm.value = JSON.parse(JSON.stringify(form.value));
   } else {
     form.value = {};
@@ -580,8 +691,16 @@
   }
 
   // 鏋勫缓瀹㈡埛涓氬姟鍦板潃鏁扮粍
-  if (form.value.businessCityId && form.value.businessDistrictId && form.value.businessProvinceId) {
-    form.value.bids = [row.businessProvinceId, row.businessCityId, row.businessDistrictId];
+  if (
+    form.value.businessCityId &&
+    form.value.businessDistrictId &&
+    form.value.businessProvinceId
+  ) {
+    form.value.bids = [
+      row.businessProvinceId,
+      row.businessCityId,
+      row.businessDistrictId,
+    ];
   }
 
   // 鏋勫缓瀹㈡埛鑱旂郴鍦板潃鏁扮粍
@@ -593,61 +712,27 @@
   handleAddEdit(tabName.value);
 };
 
+
 /**
  * 鎵归噺鍒犻櫎澶勭悊
  * @description 鎵归噺鍒犻櫎閫変腑鐨勮褰�
  */
-const handleDelete = async () => {
-  if (selectedRows.value.length === 0) {
-    ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
-    return;
-  }
-
-  const deleteIds = selectedRows.value.map(item => item.id);
-
-  try {
-    await ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", {
-      confirmButtonText: "纭畾",
-      cancelButtonText: "鍙栨秷",
-      type: "warning",
-    });
-
-    const deleteApiMap = {
+  const deleteApiMap = {
       supplier: delSupply,
       coal: delCoalInfo,
-      coalQualityMaintenance: () => {
-        throw new Error('delCoalQuality API not imported');
-      },
+      coalQualityMaintenance: delCoalPlan,
       customer: delCustomer,
-      coalMeiZhiZiDuanWeiHu: deleteCoalField
+      coalMeiZhiZiDuanWeiHu: deleteCoalField,
     };
-
-    const deleteApi = deleteApiMap[tabName.value];
-    if (!deleteApi) {
-      ElMessage.error("鍒犻櫎鎺ュ彛鏈厤缃�");
-      return;
-    }
-    console.log(deleteIds)
-    const res = await deleteApi(deleteIds);
-
-    if (res.code !== 200 && res.msg !== "鎿嶄綔鎴愬姛") {
-      ElMessage.error("鍒犻櫎澶辫触锛�" + res.msg);
-      return;
-    }
-
-    ElMessage.success("鍒犻櫎鎴愬姛");
-    await getList();
-  } catch (error) {
-    if (error.message !== 'cancel') {
-      console.error('鍒犻櫎鎿嶄綔澶辫触:', error);
-      ElMessage.error("鍒犻櫎澶辫触锛岃绋嶅悗鍐嶈瘯");
-    } else {
-      ElMessage.info("宸插彇娑堝垹闄ゆ搷浣�");
-    }
-  } finally {
-    selectedRows.value = [];
-  }
-};
+const {handleDeleteBatch :handleDelete} = useDelete({
+  deleteApi: () => deleteApiMap[tabName.value],
+  selectedRows: selectedRows,
+  getList: () => getList,
+  tableData: tableData,
+  total: total,
+  confirmText: "纭鍒犻櫎閫変腑鐨勬暟鎹悧锛�",
+  successText: "鍒犻櫎鎴愬姛",
+})
 
 /**
  * 鍏抽棴寮圭獥澶勭悊
@@ -662,10 +747,10 @@
  */
 const handleExport = () => {
   const exportConfig = {
-    supplier: {api: "/supply/export", name: "渚涘簲鍟嗕俊鎭�"},
-    customer: {api: "/customer/export", name: "瀹㈡埛淇℃伅"},
-    coal: {api: "/supply/export", name: "鐓ょ淇℃伅"},
-    coalQualityMaintenance: {api: "/supply/export", name: "鐓よ川缁存姢淇℃伅"}
+    supplier: { api: "/supply/export", name: "渚涘簲鍟嗕俊鎭�" },
+    customer: { api: "/customer/export", name: "瀹㈡埛淇℃伅" },
+    coal: { api: "/supply/export", name: "鐓ょ淇℃伅" },
+    coalQualityMaintenance: { api: "/supply/export", name: "鐓よ川缁存姢淇℃伅" },
   };
 
   const config = exportConfig[tabName.value];
@@ -680,7 +765,11 @@
  * @param {string} name - 瀵煎嚭鏂囦欢鍚嶅墠缂�
  */
 const exportData = (api, name) => {
-  proxy.download(api, {...queryParams}, `${name}${new Date().getTime()}.xlsx`);
+  proxy.download(
+    api,
+    { ...queryParams },
+    `${name}${new Date().getTime()}.xlsx`
+  );
   ElMessage.success("瀵煎嚭鏁版嵁锛�" + name);
 };
 // ===== 鏁版嵁鑾峰彇鍑芥暟 =====
@@ -702,11 +791,13 @@
     customer: () => getCustomerList(apiParams),
     coal: () => getCoalInfo(apiParams),
     coalQualityMaintenance: () => getCoalPlanList(apiParams),
-    coalMeiZhiZiDuanWeiHu: () => coalField(apiParams)
+    coalMeiZhiZiDuanWeiHu: () => coalField(apiParams),
   };
 
   const apiFunction = apiMap[tabName.value];
-  return apiFunction ? apiFunction() : Promise.reject(new Error('鏈壘鍒板搴旂殑API鎺ュ彛'));
+  return apiFunction
+    ? apiFunction()
+    : Promise.reject(new Error("鏈壘鍒板搴旂殑API鎺ュ彛"));
 };
 
 /**
@@ -716,22 +807,56 @@
 const getList = async () => {
   try {
     loading.value = true;
-    const {data, code} = await selectInterface();
+    const { data, code } = await selectInterface();
 
     if (code !== 200) {
-      ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + (data?.msg || '鏈煡閿欒'));
+      ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + (data?.msg || "鏈煡閿欒"));
       return;
     }
 
     tableData.value = data.records || [];
     total.value = data.total || 0;
   } catch (error) {
-    console.error('鑾峰彇鍒楄〃鏁版嵁澶辫触:', error);
+    console.error("鑾峰彇鍒楄〃鏁版嵁澶辫触:", error);
     ElMessage.error("鑾峰彇鏁版嵁澶辫触锛岃绋嶅悗鍐嶈瘯");
   } finally {
     loading.value = false;
   }
 };
+
+const handleView = (row) => {
+  form.value = JSON.parse(JSON.stringify(row));
+  // 鏋勫缓渚涘簲鍟嗕笟鍔″湴鍧�鏁扮粍
+  if (form.value.bprovinceId && form.value.bdistrictId && form.value.bcityId) {
+    form.value.bids = [row.bprovinceId, row.bcityId, row.bdistrictId];
+  }
+
+  // 鏋勫缓渚涘簲鍟嗚仈绯诲湴鍧�鏁扮粍
+  if (form.value.cprovinceId && form.value.cdistrictId && form.value.ccityId) {
+    form.value.cids = [row.cprovinceId, row.ccityId, row.cdistrictId];
+  }
+
+  // 鏋勫缓瀹㈡埛涓氬姟鍦板潃鏁扮粍
+  if (
+    form.value.businessCityId &&
+    form.value.businessDistrictId &&
+    form.value.businessProvinceId
+  ) {
+    form.value.bids = [
+      row.businessProvinceId,
+      row.businessCityId,
+      row.businessDistrictId,
+    ];
+  }
+
+  // 鏋勫缓瀹㈡埛鑱旂郴鍦板潃鏁扮粍
+  if (form.value.cityId && form.value.districtId && form.value.provinceId) {
+    form.value.cids = [row.provinceId, row.cityId, row.districtId];
+  }
+  addOrEdit.value = "viewRow";
+  handleAddEdit(tabName.value);
+};
+
 
 // ===== 鐢熷懡鍛ㄦ湡閽╁瓙 =====
 
@@ -742,12 +867,12 @@
   try {
     // 骞惰鎵ц鍒濆鍖栨搷浣�
     await Promise.all([
-      handleTabClick({props: {name: "supplier"}}),
+      handleTabClick({ props: { name: "supplier" } }),
       fetchAreaOptions(),
-      getUserList()
+      getUserList(),
     ]);
   } catch (error) {
-    console.error('缁勪欢鍒濆鍖栧け璐�:', error);
+    console.error("缁勪欢鍒濆鍖栧け璐�:", error);
     ElMessage.error("椤甸潰鍒濆鍖栧け璐ワ紝璇峰埛鏂伴噸璇�");
   }
 });
@@ -802,4 +927,4 @@
 .main-container {
   background: red !important;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3