From 1c4e88c1cb0639663f77a33dbab26c3cac71ad93 Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期四, 26 六月 2025 13:28:05 +0800
Subject: [PATCH] 开发通用 删除 优化文档管理模块

---
 src/views/basicInformation/index.vue | 1029 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 661 insertions(+), 368 deletions(-)

diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index 336ae2c..907d60d 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -1,10 +1,12 @@
 <template>
-  <div> <el-form :inline="true" :model="queryParams" class="search-form">
-      <el-form-item label="鎼滅储" v-if="tabName === 'supplier' || tabName === 'customer'">
-        <el-input v-model="queryParams.searchAll" placeholder="渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃" clearable />
-      </el-form-item>
-      <el-form-item label="鎼滅储" v-if="tabName === 'coal' || tabName === 'coalQualityMaintenance'">
-        <el-input v-model="queryParams.searchAll" placeholder="璇疯緭鍏ユ悳绱俊鎭�" clearable />
+  <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-form-item>
       <el-form-item>
         <el-button type="primary" @click="search">鏌ヨ</el-button>
@@ -13,45 +15,151 @@
     </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 type="primary" :icon="Plus" @click="handleAdd">鏂板缓</el-button>
-        <el-button type="danger" :icon="Delete" @click="handleDelete">鍒犻櫎</el-button>
-        <el-button type="info" :icon="Download" @click="handleExport" v-show="tabName === 'supplier' || tabName === 'customer'">瀵煎嚭</el-button>
+        <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 :loading="loading" :table-data="tableData" :columns="columns"
-          @selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true" />
+        <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"
+              >
+                {{ getFieldDisplayName(field.trim()) }}
+              </el-tag>
+            </template>
+            <template v-else>
+              <el-tag size="small" type="primary">
+                {{ getFieldDisplayName(row.fieldIds) || "--" }}
+              </el-tag>
+            </template>
+          </template>
+        </data-table>
       </div>
-      <pagination v-if="total > 0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination"
-        :layout="'total, prev, pager, next, jumper'" />
-      <Supplier v-if="tabName === 'supplier'" v-model:copyForm="copyForm"
-        v-model:supplierDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit"
-        @beforeClose="handleBeforeClose" @update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" />
-      <Customer v-if="tabName === 'customer'" v-model:copyForm="copyForm"
-        v-model:customerDialogFormVisible="dialogFormVisible" :form="form" :title="title" @submit="handleSubmit"
-        :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" />
-      <Coal v-if="tabName === 'coal'" v-model:copyForm="copyForm" v-model:coalDialogFormVisible="dialogFormVisible"
-        :form="form" :title="title" :addOrEdit="addOrEdit" @submit="handleSubmit" />
-      <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'"
-        v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" :form="form" :title="title"
-        :addOrEdit="addOrEdit" @submit="handleSubmit" />
-      <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'"
-        v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible" :form="form" :title="title"
-        :addOrEdit="addOrEdit" @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 { ref, reactive, onMounted, computed } from "vue";
+import {
+  computed,
+  getCurrentInstance,
+  onMounted,
+  reactive,
+  ref,
+  nextTick,
+} from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
-import { Plus, Edit, Delete, Download } from "@element-plus/icons-vue";
+import { Delete, Download, Plus } from "@element-plus/icons-vue";
+
+// ===== 缁勪欢瀵煎叆 =====
 import DataTable from "@/components/Table/ETable.vue";
 import Pagination from "@/components/Pagination";
 import Supplier from "./mould/supplier.vue";
@@ -59,61 +167,104 @@
 import Coal from "./mould/coal.vue";
 import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue";
 import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue";
-const { proxy } = getCurrentInstance()
-import { getSupply, addOrEditSupply, delSupply } from "@/api/basicInformation/supplier.js";
-import { getCoalInfo, delCoalInfo } from "@/api/basicInformation/coal.js";
-import { getCoalQuality, delCoalQuality } from "@/api/basicInformation/coalQualityMaintenance.js";
+
+// ===== 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 { getCustomerList, delCustomer } from "@/api/basicInformation/customer.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 coalMaintenanceFieldDialogVisible = ref(false);
-const coalQualityMaintenanceDialogFormVisible = ref(false);
-const customerDialogFormVisible = ref(false);
-const coalDialogFormVisible = ref(false);
-const supplierDialogFormVisible = ref(false);
+// ===== 鍝嶅簲寮忕姸鎬佺鐞� =====
 const dialogFormVisible = ref(false);
 const form = ref({});
 const title = ref("");
 const copyForm = ref({});
-// 鐢ㄦ埛鍒楄〃鏁版嵁
+const addOrEdit = ref("add");
+
+// 鏁版嵁缂撳瓨鏄犲皠
 const userList = ref([]);
-// 鐢ㄦ埛鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵�
-const userMap = ref({});
-// 鍦板潃鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵惧湴鍧�鍚嶇О
-const addressMap = ref({});
-// 褰撳墠鏍囩
+const userMap = ref({}); // 鐢ㄦ埛ID -> 鐢ㄦ埛鍚嶆槧灏勮〃
+const addressMap = ref({}); // 鍦板潃ID -> 鍦板潃淇℃伅鏄犲皠琛�
+const coalFieldList = ref([]); // 鐓よ川瀛楁鍒楄〃
+
+// 椤甸潰鐘舵�佹帶鍒�
 const tabName = ref("supplier");
-// 鐘舵�佸彉閲�
 const loading = ref(false);
-const total = ref(0);
+const activeTab = ref("supplier");
+
+// 鍒嗛〉鐘舵�佺鐞�
 const pageNum = ref(1);
 const pageSizes = ref(10);
-const activeTab = ref("supplier");
+const total = ref(0);
+
+// 琛ㄦ牸鐘舵�佺鐞�
 const selectedRows = ref([]);
+const tableData = ref([]);
+const columns = ref();
+
 // 鏌ヨ鍙傛暟
-const queryParams = reactive({
-});
+const queryParams = reactive({});
+
 // 鍦板潃閫夋嫨鏁版嵁
 const addressSelectOptions = ref([]);
-const fetchAreaOptions = async () => {
-  addressSelectOptions.value = [];
-  const res = await getAreaOptions();
-  if (res.code === 200) {
-    addressSelectOptions.value = res.data;
-    buildAddressMap(res.data); // 鏋勫缓鍦板潃鏄犲皠琛�
-  }
-}
 
-// 鏋勫缓鍦板潃鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵惧湴鍧�鍚嶇О
+// ===== 閰嶇疆甯搁噺 =====
+
+// 鏍囩椤甸厤缃�
+const tabs = reactive([
+  { name: "supplier", label: "渚涘簲鍟嗕俊鎭�" },
+  { name: "customer", label: "瀹㈡埛淇℃伅" },
+  { name: "coal", label: "鐓ょ淇℃伅" },
+  { name: "coalQualityMaintenance", label: "鐓よ川鏂规" },
+  { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" },
+]);
+
+// ===== 宸ュ叿鍑芥暟 =====
+
+/**
+ * 鑾峰彇鍦板潃閫夋嫨鏁版嵁骞舵瀯寤烘槧灏勮〃
+ * @description 寮傛鑾峰彇鍦板潃鏁版嵁锛屾瀯寤哄揩閫熸煡鎵剧殑鏄犲皠琛�
+ */
+const fetchAreaOptions = async () => {
+  try {
+    addressSelectOptions.value = [];
+    const res = await getAreaOptions();
+    if (res.code === 200) {
+      addressSelectOptions.value = res.data;
+      buildAddressMap(res.data);
+    }
+  } catch (error) {
+    console.error("鑾峰彇鍦板潃閫夐」澶辫触:", error);
+  }
+};
+
+/**
+ * 鏋勫缓鍦板潃鏄犲皠琛�
+ * @param {Array} areaData - 鍦板潃鏁版嵁
+ * @description 閫掑綊鏋勫缓鍦板潃鏄犲皠琛紝鏀寔澶氱骇鍦板潃鏌ユ壘
+ */
 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);
@@ -123,112 +274,159 @@
   buildMap(areaData);
 };
 
-// 鍦板潃鏍煎紡鍖栧嚱鏁�
+/**
+ * 鏍煎紡鍖栧湴鍧�鏁扮粍涓烘樉绀哄瓧绗︿覆
+ * @param {Array} addressIds - 鍦板潃ID鏁扮粍
+ * @returns {string} 鏍煎紡鍖栧悗鐨勫湴鍧�瀛楃涓�
+ * @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 => {
-    return addressMap.value[id]?.name || '--';
-  });
-  // 濡傛灉鎵�鏈夊湴鍧�鍚嶇О閮芥槸 '--'锛屽垯杩斿洖 '--'
-  if (addressNames.every(name => name === '--')) {
-    return '--';
+
+  const addressNames = addressIds.map(
+    (id) => addressMap.value[id]?.name || "--"
+  );
+
+  if (addressNames.every((name) => name === "--")) {
+    return "--";
   }
-  return addressNames.filter(name => name !== '--').join(' / ');
+
+  return addressNames.filter((name) => name !== "--").join(" / ");
 };
-// 鑾峰彇鐢ㄦ埛鍒楄〃鏁版嵁
+
+/**
+ * 鑾峰彇鐢ㄦ埛鍒楄〃鏁版嵁骞舵瀯寤烘槧灏勮〃
+ * @description 鑾峰彇鐢ㄦ埛鏁版嵁骞舵瀯寤篒D鍒扮敤鎴峰悕鐨勬槧灏勫叧绯�
+ */
 const getUserList = async () => {
   try {
     const res = await testUserList();
     if (res && res.data) {
       userList.value = res.data;
-      userList.value.forEach(user => {
+      userList.value.forEach((user) => {
         userMap.value[user.userId] = user.username;
       });
     }
   } catch (error) {
-    console.error('鑾峰彇鐢ㄦ埛鍒楄〃澶辫触:', error);
+    console.error("鑾峰彇鐢ㄦ埛鍒楄〃澶辫触:", error);
   }
 };
-onMounted(async () => {
-  await handleTabClick({ props: { name: "supplier" } });
-  await fetchAreaOptions(); // 鍏堣幏鍙栧湴鍧�閫夋嫨鏁版嵁骞舵瀯寤烘槧灏勮〃
-  await getUserList(); // 鑾峰彇鐢ㄦ埛鍒楄〃
+
+/**
+ * 鑾峰彇鐓よ川瀛楁鏁版嵁
+ * @description 鑾峰彇鐓よ川瀛楁鍒楄〃锛岀敤浜庡瓧娈靛悕绉板尮閰�
+ */
+const coalFieldData = async () => {
+  try {
+    const { data, code } = await getCoalFieldList();
+    if (code === 200) {
+      coalFieldList.value = data;
+    }
+  } catch (error) {
+    console.error("鑾峰彇鐓よ川瀛楁鏁版嵁澶辫触:", error);
+  }
+};
+
+/**
+ * 鏍规嵁瀛楁ID鑾峰彇瀛楁鏄剧ず鍚嶇О
+ * @param {string|number} fieldId - 瀛楁ID
+ * @returns {string} 瀛楁鏄剧ず鍚嶇О
+ * @description 閫氳繃瀛楁ID鍖归厤瀵瑰簲鐨勫瓧娈靛悕绉�
+ */
+const getFieldDisplayName = (fieldId) => {
+  if (!fieldId) return "--";
+
+  const numId = parseInt(fieldId);
+  const matchedField = coalFieldList.value.find((item) => item.id === numId);
+
+  return matchedField ? matchedField.fieldName : numId;
+};
+
+/**
+ * 褰撳墠鏍囩椤垫槸鍚︽敮鎸佸鍑哄姛鑳�
+ */
+const canExport = computed(() => {
+  return ["supplier", "customer"].includes(tabName.value);
 });
-const columns = ref();
-// 鏍囩椤垫暟鎹�
-const tabs = reactive([
-  { name: "supplier", label: "渚涘簲鍟嗕俊鎭�" },
-  { name: "customer", label: "瀹㈡埛淇℃伅" },
-  { name: "coal", label: "鐓ょ淇℃伅" },
-  { name: "coalQualityMaintenance", label: "鐓よ川鏂规" },
-  { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" }
-]);
-// 鏄惁缂栬緫
-const addOrEdit = ref("add");
-// 琛ㄦ牸鏁版嵁
-const tableData = ref([]);
-// supplier 渚涘簲鍟嗘暟鎹�
+
+/**
+ * 鎼滅储妗嗗崰浣嶇鏂囨湰
+ */
+const searchPlaceholder = computed(() => {
+  const placeholderMap = {
+    supplier: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃",
+    customer: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃",
+    coal: "璇疯緭鍏ョ叅绉嶄俊鎭�",
+    coalQualityMaintenance: "璇疯緭鍏ョ叅璐ㄦ柟妗堜俊鎭�",
+    coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ョ叅璐ㄥ瓧娈典俊鎭�",
+  };
+  return placeholderMap[tabName.value] || "璇疯緭鍏ユ悳绱俊鎭�";
+});
+
+/**
+ * 鏄惁鏄剧ず鎼滅储妗�
+ */
+const shouldShowSearch = computed(() => {
+  return [
+    "supplier",
+    "customer",
+    "coal",
+    "coalQualityMaintenance",
+    "coalMeiZhiZiDuanWeiHu",
+  ].includes(tabName.value);
+});
+
+/**
+ * 褰撳墠閫変腑琛屾暟閲�
+ */
+const selectedCount = computed(() => selectedRows.value.length);
+
+// ===== 琛ㄦ牸鍒楅厤缃� =====
+
+/**
+ * 渚涘簲鍟嗚〃鏍煎垪閰嶇疆
+ */
 const supplierColumns = ref([
   { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100 },
-  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170 }, {
+  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170 },
+  {
     prop: "bids",
     label: "缁忚惀鍦板潃",
     minWidth: 150,
     showOverflowTooltip: true,
-    formatter: (row, column, cellValue) => {
-      let arr = [
-        row.bprovinceId,
-        row.bcityId,
-        row.bdistrictId,
-      ]
-      return formatAddressArray(arr);
-    }
+    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: "cids",
     label: "鑱旂郴浜哄湴鍧�",
     minWidth: 150,
     showOverflowTooltip: true,
-    formatter: (row, column, cellValue) => {
-      let arr = [
-        row.cprovinceId,
-        row.ccityId,
-        row.cdistrictId,
-      ]
-      return formatAddressArray(arr);
-    }
-  }, { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 },
-  // { 
-  //   prop: "maintainerId", 
-  //   label: "缁存姢浜�", 
-  //   minWidth: 80,
-  //   formatter: (row, column, cellValue) => {
-  //     // 濡傛灉鐢ㄦ埛鏄犲皠琛ㄨ繕娌℃湁鍑嗗濂斤紝鏄剧ず --
-  //     if (!userMap.value || Object.keys(userMap.value).length === 0) {
-  //       return '--';
-  //     }
-  //     // 濡傛灉鍊间负绌烘垨null锛屾樉绀� --
-  //     if (cellValue === null || cellValue === undefined || cellValue === '') {
-  //       return '--';
-  //     }
-  //     // 濡傛灉鐢ㄦ埛鏄犲皠琛ㄤ腑鏈夊搴旂殑鐢ㄦ埛鍚嶏紝杩斿洖鐢ㄦ埛鍚�
-  //     if (userMap.value[cellValue]) {
-  //       return userMap.value[cellValue];
-  //     }
-  //     // 濡傛灉娌℃湁鍖归厤鐨勭敤鎴凤紝鏄剧ず --
-  //     return '--';
-  //   }
-  // },
-  { prop: "createTime", label: "缁存姢鏃ユ湡", minWidth: 120 },
+    formatter: (row) => {
+      const addressIds = [row.cprovinceId, row.ccityId, row.cdistrictId];
+      return formatAddressArray(addressIds);
+    },
+  },
+  { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 },
 ]);
-// customer 瀹㈡埛鏁版嵁
+
+/**
+ * 瀹㈡埛琛ㄦ牸鍒楅厤缃�
+ */
 const customerColumns = ref([
   { prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100 },
   { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 },
@@ -237,14 +435,14 @@
     label: "缁忚惀鍦板潃",
     minWidth: 150,
     showOverflowTooltip: true,
-    formatter: (row, column, cellValue) => {
-      let arr = [
+    formatter: (row) => {
+      const addressIds = [
         row.businessProvinceId,
         row.businessCityId,
         row.businessDistrictId,
-      ]
-      return formatAddressArray(arr);
-    }
+      ];
+      return formatAddressArray(addressIds);
+    },
   },
   { prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150 },
   { prop: "bankName", label: "寮�鎴疯", minWidth: 120 },
@@ -256,149 +454,197 @@
     label: "鑱旂郴浜哄湴鍧�",
     minWidth: 150,
     showOverflowTooltip: true,
-    formatter: (row, column, cellValue) => {
-      let arr = [
-        row.provinceId,
-        row.cityId,
-        row.districtId,
-      ]
-      return formatAddressArray(arr);
-    }
+    formatter: (row) => {
+      const addressIds = [row.provinceId, row.cityId, row.districtId];
+      return formatAddressArray(addressIds);
+    },
   },
   { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150 },
   { prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100 },
 ]);
-// coal 鐓ょ鏁版嵁
+
+/**
+ * 鐓ょ琛ㄦ牸鍒楅厤缃�
+ */
 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 "--";
       }
-      // 濡傛灉鍊间负绌烘垨null锛屾樉绀� --
-      if (cellValue === null || cellValue === undefined || cellValue === '') {
-        return '--';
+      if (cellValue === null || cellValue === undefined || cellValue === "") {
+        return "--";
       }
-      // 濡傛灉鐢ㄦ埛鏄犲皠琛ㄤ腑鏈夊搴旂殑鐢ㄦ埛鍚嶏紝杩斿洖鐢ㄦ埛鍚�
-      if (userMap.value[cellValue]) {
-        return userMap.value[cellValue];
-      }
-      // 濡傛灉娌℃湁鍖归厤鐨勭敤鎴凤紝鏄剧ず --
-      return '--';
-    }
+      return userMap.value[cellValue] || "--";
+    },
   },
   { prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150 },
 ]);
-// coalQualityMaintenance 鐓よ川缁存姢鏁版嵁
+
+/**
+ * 鐓よ川鏂规琛ㄦ牸鍒楅厤缃�
+ */
 const coalQualityMaintenanceColumns = ref([
-  { prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200 },
-  { prop: "totalMoisture", label: "鍏ㄦ按鍚噺鐧惧垎姣� (%)", minWidth: 200 },
-  { prop: "analysisMoisture", label: "鍒嗘瀽姘村惈閲忕櫨鍒嗘瘮 (%)", minWidth: 200 },
-  { prop: "volatileMatter", label: "鎸ュ彂鍒嗙櫨鍒嗘瘮 (%)", minWidth: 100 },
-  { prop: "sulfurContent", label: "纭惈閲忕櫨鍒嗘瘮 (%)", minWidth: 100 },
-  { prop: "contacts", label: "鍥哄畾纰崇櫨鍒嗘瘮 (%)", minWidth: 100 },
-  { prop: "contactAddress", label: "楂樹綅鍙戠儹閲�", minWidth: 100 },
-  { prop: "maintainer", label: "浣庝綅鍙戠儹閲�", minWidth: 100 },
+  { prop: "plan", label: "鏂规鍚嶇О", minWidth: 100 },
+  {
+    prop: "fieldIds",
+    label: "瀛楁鍚嶇О",
+    minWidth: 200,
+    showOverflowTooltip: true,
+    slot: true,
+    formatter: (row, column, cellValue) => {
+      if (Array.isArray(cellValue)) {
+        return cellValue.map((item) => item);
+      }
+      return cellValue || "--";
+    },
+  },
+  { prop: "schemeDesc", label: "瀛楁鎻忚堪", minWidth: 100 },
 ]);
+
+/**
+ * 鐓よ川瀛楁琛ㄦ牸鍒楅厤缃�
+ */
 const coalMeiZhiZiDuanWeiHuColumns = ref([
   { prop: "fieldName", label: "瀛楁鍚嶇О", minWidth: 200 },
   { prop: "fieldDescription", label: "瀛楁鎻忚堪", minWidth: 200 },
 ]);
-// 鏍囩椤电偣鍑�
+// ===== 浜嬩欢澶勭悊鍑芥暟 =====
+
+/**
+ * 鏍囩椤靛垏鎹簨浠跺鐞�
+ * @param {Object} tab - 鏍囩椤靛璞�
+ * @description 澶勭悊鏍囩椤靛垏鎹紝閲嶇疆琛ㄥ崟鍜岀姸鎬侊紝鍔犺浇瀵瑰簲鏁版嵁
+ */
 const handleTabClick = (tab) => {
+  // 閲嶇疆琛ㄥ崟鍜岀姸鎬�
   form.value = {};
   addOrEdit.value = "add";
   loading.value = true;
   tabName.value = tab.props.name;
   tableData.value = [];
-  switch (tabName.value) {
-    case "supplier":
+  pageNum.value = 1;
+  pageSizes.value = 10;
+  total.value = 0;
+  queryParams.searchAll = "";
+  // 鏍规嵁鏍囩椤电被鍨嬭缃搴旂殑鍒楅厤缃�
+  const tabConfig = {
+    supplier: () => {
       columns.value = supplierColumns.value;
-      dialogFormVisible.value = supplierDialogFormVisible.value;
-      getList("supplier");
-      break;
-    case "customer":
+      getList();
+    },
+    customer: () => {
       columns.value = customerColumns.value;
-      dialogFormVisible.value = customerDialogFormVisible.value;
-      getList("customer");
-      break;
-    case "coal":
+      getList();
+    },
+    coal: () => {
       columns.value = coalColumns.value;
-      dialogFormVisible.value = coalDialogFormVisible.value;
-      getList("coal");
-      break;
-    case "coalQualityMaintenance":
+      getList();
+    },
+    coalQualityMaintenance: () => {
       columns.value = coalQualityMaintenanceColumns.value;
-      dialogFormVisible.value = coalQualityMaintenanceDialogFormVisible.value;
-      getList("coalQualityMaintenance");
-      break;
-    case "coalMeiZhiZiDuanWeiHu":
+      getList();
+      coalFieldData(); // 鍔犺浇鐓よ川瀛楁鏁版嵁
+    },
+    coalMeiZhiZiDuanWeiHu: () => {
       columns.value = coalMeiZhiZiDuanWeiHuColumns.value;
-      dialogFormVisible.value = coalMaintenanceFieldDialogVisible.value;
-      getList("coalMeiZhiZiDuanWeiHu");
-      break;
+      getList();
+    },
+  };
+
+  // 鎵ц瀵瑰簲鐨勯厤缃嚱鏁�
+  const configFn = tabConfig[tabName.value];
+  if (configFn) {
+    configFn();
   }
 };
-// 閲嶇疆鏌ヨ
+
+/**
+ * 閲嶇疆鏌ヨ鏉′欢
+ * @description 閲嶇疆鏌ヨ鍙傛暟骞堕噸鏂板姞杞芥暟鎹�
+ */
 const resetQuery = () => {
   Object.keys(queryParams).forEach((key) => {
     if (key !== "pageNum" && key !== "pageSizes") {
       queryParams[key] = "";
     }
   });
-  getList()
+  getList();
 };
-// 鏂板
+
+/**
+ * 鎼滅储鍔熻兘
+ * @description 閲嶇疆椤电爜骞舵墽琛屾悳绱�
+ */
+const search = () => {
+  pageNum.value = 1;
+  getList();
+};
+
+/**
+ * 鏂板鎸夐挳鐐瑰嚮澶勭悊
+ */
 const handleAdd = () => {
   addOrEdit.value = "add";
   handleAddEdit(tabName.value);
 };
-// 鏂板缂栬緫
-const handleAddEdit = (tabName) => {
-  addOrEdit.value == "add" ? title.value = "鏂板" : title.value = "缂栬緫";
-  if (tabName === "supplier") {
-    dialogFormVisible.value = true;
-    title.value = title.value + "渚涘簲鍟嗕俊鎭�";
-    openDialog();
-  } else if (tabName === "customer") {
-    dialogFormVisible.value = true;
-    title.value = title.value + "瀹㈡埛淇℃伅";
-    openDialog();
-  } else if (tabName === "coal") {
-    dialogFormVisible.value = true;
-    title.value = title.value + "鐓ょ淇℃伅";
-    openDialog();
-  } else if (tabName === "coalQualityMaintenance") {
-    dialogFormVisible.value = true;
-    title.value = title.value + "鐓よ川鏂规缁存姢";
-    openDialog();
-  } else if (tabName === "coalMeiZhiZiDuanWeiHu") {
-    dialogFormVisible.value = true;
-    title.value = title.value + "鐓よ川瀛楁缁存姢";
-    openDialog();
-  }
+
+/**
+ * 鏂板/缂栬緫寮圭獥澶勭悊
+ * @param {string} currentTabName - 褰撳墠鏍囩椤靛悕绉�
+ * @description 鏍规嵁鏍囩椤电被鍨嬭缃脊绐楁爣棰樺苟鎵撳紑寮圭獥
+ */
+const handleAddEdit = (currentTabName) => {
+  const actionText =
+    addOrEdit.value === "add"
+      ? "鏂板"
+      : addOrEdit.value === "edit"
+      ? "缂栬緫"
+      : "鏌ョ湅";
+
+  const tabTitleMap = {
+    supplier: "渚涘簲鍟嗕俊鎭�",
+    customer: "瀹㈡埛淇℃伅",
+    coal: "鐓ょ淇℃伅",
+    coalQualityMaintenance: "鐓よ川鏂规缁存姢",
+    coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢",
+  };
+
+  title.value = `${actionText}${tabTitleMap[currentTabName] || ""}`;
+  openDialog();
 };
-// 鎵撳紑寮圭獥
+
+/**
+ * 鎵撳紑寮圭獥
+ * @description 鏍规嵁缂栬緫鐘舵�佸喅瀹氭槸鍚﹀鍒惰〃鍗曟暟鎹�
+ */
 const openDialog = () => {
-  if (addOrEdit.value === "edit") {
+  if (addOrEdit.value === "edit" || addOrEdit.value === "viewRow") {
     copyForm.value = JSON.parse(JSON.stringify(form.value));
-    dialogFormVisible.value = true;
-    return;
+  } else {
+    form.value = {};
   }
-  form.value = {};
   dialogFormVisible.value = true;
 };
-// 鍒嗛〉
+
+/**
+ * 鍒嗛〉澶勭悊
+ * @param {Object} val - 鍒嗛〉鍙傛暟瀵硅薄
+ */
 const handPagination = (val) => {
   pageNum.value = val.page;
   pageSizes.value = val.limit;
   getList();
 };
-// 鎻愪氦琛ㄥ崟
+
+/**
+ * 琛ㄥ崟鎻愪氦澶勭悊
+ * @param {Object} val - 鎻愪氦缁撴灉瀵硅薄
+ */
 const handleSubmit = async (val) => {
   if (val.result.code !== 200) {
     ElMessage.error("鎿嶄綔澶辫触锛�" + val.result.msg);
@@ -408,179 +654,226 @@
   dialogFormVisible.value = false;
   getList();
 };
+
+/**
+ * 寮圭獥鏄剧ず鐘舵�佸鐞�
+ * @param {boolean} value - 鏄剧ず鐘舵��
+ */
 const handleDialogFormVisible = (value) => {
   dialogFormVisible.value = value;
 };
-// 閫夋嫨琛�
+
+/**
+ * 琛ㄦ牸琛岄�夋嫨澶勭悊
+ * @param {Array} selection - 閫変腑鐨勮鏁版嵁
+ */
 const handleSelectionChange = (selection) => {
   selectedRows.value = selection;
 };
-// 缂栬緫
+/**
+ * 缂栬緫鎸夐挳鐐瑰嚮澶勭悊
+ * @param {Object} row - 琛屾暟鎹�
+ * @description 澶勭悊缂栬緫鎿嶄綔锛屾瀯寤哄湴鍧�鏁扮粍骞舵墦寮�缂栬緫寮圭獥
+ */
 const handleEdit = (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,
-    ];
+    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,
-    ];
+    form.value.cids = [row.cprovinceId, row.ccityId, row.cdistrictId];
   }
-  if (form.value.businessCityId && form.value.businessDistrictId && form.value.businessProvinceId) {
+
+  // 鏋勫缓瀹㈡埛涓氬姟鍦板潃鏁扮粍
+  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,
-    ];
+    form.value.cids = [row.provinceId, row.cityId, row.districtId];
   }
+
   addOrEdit.value = "edit";
   handleAddEdit(tabName.value);
 };
-// 鎵归噺鍒犻櫎
-const handleDelete = () => {
-  if (selectedRows.value.length === 0) {
-    ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
-    return;
-  }
-  let arr = reactive([]);
-  selectedRows.value.forEach(element => {
-    return arr.push(element.id);
-  });
-  ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", {
-    confirmButtonText: "纭畾",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
-    .then(async () => {
-      try {
-        let res;
-        if (tabName.value === "supplier") {
-          res = await delSupply(arr);
-        } else if (tabName.value === "coal") {
-          res = await delCoalInfo(arr);
-        } else if (tabName.value === "coalQualityMaintenance") {
-          res = await delCoalQuality(arr);
-        } else if (tabName.value === "customer") {
-          res = await delCustomer(arr);
-        }
-        if (res.code !== 200 && res.meg == "鎿嶄綔鎴愬姛") {
-          ElMessage.error("鍒犻櫎澶辫触锛�" + res.msg);
-          return;
-        }
-        ElMessage.success("鍒犻櫎鎴愬姛");
-        await getList();
-      } catch (e) {
-        console.error(e);
-        ElMessage.error("鍒犻櫎澶辫触锛岃绋嶅悗鍐嶈瘯");
-      } finally {
-        selectedRows.value = [];
-      }
-    }).catch(() => {
-      ElMessage.info("宸插彇娑堝垹闄ゆ搷浣�");
-    });
-}
-// 鍏抽棴寮圭獥
+
+
+/**
+ * 鎵归噺鍒犻櫎澶勭悊
+ * @description 鎵归噺鍒犻櫎閫変腑鐨勮褰�
+ */
+  const deleteApiMap = {
+      supplier: delSupply,
+      coal: delCoalInfo,
+      coalQualityMaintenance: delCoalPlan,
+      customer: delCustomer,
+      coalMeiZhiZiDuanWeiHu: deleteCoalField,
+    };
+const {handleDeleteBatch :handleDelete} = useDelete({
+  deleteApi: () => deleteApiMap[tabName.value],
+  selectedRows: selectedRows,
+  getList: () => getList,
+  tableData: tableData,
+  total: total,
+  confirmText: "纭鍒犻櫎閫変腑鐨勬暟鎹悧锛�",
+  successText: "鍒犻櫎鎴愬姛",
+})
+
+/**
+ * 鍏抽棴寮圭獥澶勭悊
+ */
 const handleBeforeClose = () => {
   dialogFormVisible.value = false;
   form.value = {};
 };
-const handleExport = () => {
-  if (tabName.value === "supplier") {
-    Export("/supply/export", "渚涘簲鍟嗕俊鎭�");
-  } else if (tabName.value === "customer") {
-    Export("/customer/export", "瀹㈡埛淇℃伅");
-  } else if (tabName.value === "coal") {
-    Export("/supply/export", "鐓ょ淇℃伅");
-  } else if (tabName.value === "coalQualityMaintenance") {
-    Export("/supply/export", "鐓よ川缁存姢淇℃伅");
 
+/**
+ * 瀵煎嚭鍔熻兘澶勭悊
+ */
+const handleExport = () => {
+  const exportConfig = {
+    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];
+  if (config) {
+    exportData(config.api, config.name);
   }
-}
-const Export = (api, name) => {
-  proxy.download(api, {
-    ...queryParams.value
-  }, `${name}${new Date().getTime()}.xlsx`)
+};
+
+/**
+ * 瀵煎嚭鏁版嵁
+ * @param {string} api - 瀵煎嚭鎺ュ彛璺緞
+ * @param {string} name - 瀵煎嚭鏂囦欢鍚嶅墠缂�
+ */
+const exportData = (api, name) => {
+  proxy.download(
+    api,
+    { ...queryParams },
+    `${name}${new Date().getTime()}.xlsx`
+  );
   ElMessage.success("瀵煎嚭鏁版嵁锛�" + name);
 };
-// 閫夋嫨鎺ュ彛
+// ===== 鏁版嵁鑾峰彇鍑芥暟 =====
+
+/**
+ * 鏍规嵁褰撳墠鏍囩椤甸�夋嫨瀵瑰簲鐨凙PI鎺ュ彛
+ * @returns {Promise} API璋冪敤Promise
+ * @description 缁熶竴鐨勬帴鍙i�夋嫨鍑芥暟锛屾牴鎹爣绛鹃〉绫诲瀷璋冪敤瀵瑰簲鐨凙PI
+ */
 const selectInterface = () => {
-  if (tabName.value === "supplier") {
-    return getSupply({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      searchAll: queryParams.searchAll,
-    });
-  } else if (tabName.value === "customer") {
-    return getCustomerList({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      searchAll: queryParams.searchAll,
-    });
-  } else if (tabName.value === "coal") {
-    return getCoalInfo({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      searchAll: queryParams.searchAll,
-    });
-  } else if (tabName.value === "coalQualityMaintenance") {
-    return getCoalQuality({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      searchAll: queryParams.searchAll,
-    });
-  } else if (tabName.value === "coalMeiZhiZiDuanWeiHu") {
-    return {
-      code: 200,
-          data: {
-          records: [
-            { fieldName: "瀛楁1", fieldDescription: "鎻忚堪1" },
-            { fieldName: "瀛楁2", fieldDescription: "鎻忚堪2" },
-            { fieldName: "瀛楁3", fieldDescription: "鎻忚堪3" }
-          ],
-            total: 10
-        }
-    };
-    // return getCoalQuality({
-    //   current: pageNum.value,
-    //   pageSize: pageSizes.value,
-    //   searchAll: queryParams.searchAll,
-    // });
-  }
-}
-const search = () => {
-  pageNum.value = 1; // 閲嶇疆椤电爜
-  getList();
+  const apiParams = {
+    current: pageNum.value,
+    pageSize: pageSizes.value,
+    searchAll: queryParams.searchAll,
+  };
+
+  const apiMap = {
+    supplier: () => getSupply(apiParams),
+    customer: () => getCustomerList(apiParams),
+    coal: () => getCoalInfo(apiParams),
+    coalQualityMaintenance: () => getCoalPlanList(apiParams),
+    coalMeiZhiZiDuanWeiHu: () => coalField(apiParams),
+  };
+
+  const apiFunction = apiMap[tabName.value];
+  return apiFunction
+    ? apiFunction()
+    : Promise.reject(new Error("鏈壘鍒板搴旂殑API鎺ュ彛"));
 };
-// 鑾峰彇鍒楄〃鏁版嵁
+
+/**
+ * 鑾峰彇鍒楄〃鏁版嵁
+ * @description 缁熶竴鐨勬暟鎹幏鍙栧嚱鏁帮紝澶勭悊鍔犺浇鐘舵�佸拰閿欒澶勭悊
+ */
 const getList = async () => {
-  loading.value = true;
-  /* if (Object.keys(addressMap.value).length === 0) {
-    await fetchAreaOptions();
-  } */
-  let { data, code } = await selectInterface()
-  console.log("鑾峰彇鏁版嵁锛�", code, data);
-  if (code !== 200) {
-    ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + data.msg);
+  try {
+    loading.value = true;
+    const { data, code } = await selectInterface();
+
+    if (code !== 200) {
+      ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + (data?.msg || "鏈煡閿欒"));
+      return;
+    }
+
+    tableData.value = data.records || [];
+    total.value = data.total || 0;
+  } catch (error) {
+    console.error("鑾峰彇鍒楄〃鏁版嵁澶辫触:", error);
+    ElMessage.error("鑾峰彇鏁版嵁澶辫触锛岃绋嶅悗鍐嶈瘯");
+  } finally {
     loading.value = false;
-    return;
   }
-  tableData.value = data.records;
-  total.value = data.total;
-  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);
+};
+
+
+// ===== 鐢熷懡鍛ㄦ湡閽╁瓙 =====
+
+/**
+ * 缁勪欢鎸傝浇鍚庣殑鍒濆鍖栨搷浣�
+ */
+onMounted(async () => {
+  try {
+    // 骞惰鎵ц鍒濆鍖栨搷浣�
+    await Promise.all([
+      handleTabClick({ props: { name: "supplier" } }),
+      fetchAreaOptions(),
+      getUserList(),
+    ]);
+  } catch (error) {
+    console.error("缁勪欢鍒濆鍖栧け璐�:", error);
+    ElMessage.error("椤甸潰鍒濆鍖栧け璐ワ紝璇峰埛鏂伴噸璇�");
+  }
+});
 </script>
 
 <style scoped>
@@ -617,7 +910,7 @@
 
 /* 琛ㄦ牸宸ュ叿鏍� */
 .table-toolbar,
-.table-toolbar>* {
+.table-toolbar > * {
   margin: 0 0 0 0 !important;
 }
 
@@ -632,4 +925,4 @@
 .main-container {
   background: red !important;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3