From 00ef76a2e286e338fa3c648ce183e3533ce006ad Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 09 六月 2025 17:48:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 src/views/basicInformation/index.vue |  817 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 617 insertions(+), 200 deletions(-)

diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index e2007e9..9f5927e 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -1,12 +1,10 @@
 <template>
-  <div>
-    <el-form :inline="true" :model="queryParams" class="search-form">
-      <el-form-item label="渚涘簲鍟嗗悕绉�">
-        <el-input v-model="queryParams.searchAll" placeholder="璇疯緭鍏ュ叧閿瘝" clearable />
+  <div> <el-form :inline="true" :model="queryParams" class="search-form">
+      <el-form-item label="鎼滅储" v-if="shouldShowSearch">
+        <el-input v-model="queryParams.searchAll" :placeholder="searchPlaceholder" clearable />
       </el-form-item>
-  
       <el-form-item>
-        <el-button type="primary" @click="getList">鏌ヨ</el-button>
+        <el-button type="primary" @click="search">鏌ヨ</el-button>
         <el-button @click="resetQuery">閲嶇疆</el-button>
       </el-form-item>
     </el-form>
@@ -15,313 +13,732 @@
       <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">瀵煎嚭</el-button>
-      </el-row>
-      <!-- 琛ㄦ牸缁勪欢 -->
+        <el-button type="info" :icon="Download" @click="handleExport" v-show="canExport">瀵煎嚭</el-button>
+      </el-row> <!-- 琛ㄦ牸缁勪欢 -->
       <div>
         <data-table :loading="loading" :table-data="tableData" :columns="columns"
-          @selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true" />
-      </div>      <pagination v-if="total>0" :page="pageNum" :limit="pageSizes" :total="total" @pagination="handPagination"
+          @selection-change="handleSelectionChange" @edit="handleEdit" :show-selection="true" :border="true">          <!-- 瀛楁鍚嶇О鍒楃殑鑷畾涔夋彃妲� - 鏄剧ず涓烘爣绛� -->
+          <template v-if="tabName === 'coalQualityMaintenance'" #coalFields="{ row }">
+            <template v-if="typeof row.coalFields === 'string' && row.coalFields.includes(',')">
+              <el-tag v-for="(field, index) in row.coalFields.split(',')" :key="index" type="primary" size="small"
+                style="margin-right: 4px; margin-bottom: 2px;">
+                {{ getFieldDisplayName(field.trim()) }}
+              </el-tag>
+            </template>
+            <template v-else>
+              <el-tag type="primary" size="small">
+                {{ getFieldDisplayName(row.coalFields) || '--' }}
+              </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:supplierDialogFormVisible="dialogFormVisible" :form="form"
-        :title="title" @submit="handleSubmit" @beforeClose="handleBeforeClose"
-        @update:dialogFormVisible="handleDialogFormVisible" :addOrEdit="addOrEdit" />
-      <Customer v-if="tabName === 'customer'" v-model:customerDialogFormVisible="dialogFormVisible" :form="form"
-        :title="title" @submit="handleSubmit" :addOrEdit="addOrEdit" @beforeClose="handleBeforeClose" />
-      <Coal v-if="tabName === 'coal'" v-model:coalDialogFormVisible="dialogFormVisible" :form="form" :title="title"
-        :addOrEdit="addOrEdit" @submit="handleSubmit" />
-      <coalQualityMaintenance v-if="tabName === 'coalQualityMaintenance'"
+      <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:copyForm="copyForm"
         v-model:coalQualityMaintenanceDialogFormVisible="dialogFormVisible" :form="form" :title="title"
         :addOrEdit="addOrEdit" @submit="handleSubmit" />
+      <coalMeiZhiZiDuanWeiHu v-if="tabName === 'coalMeiZhiZiDuanWeiHu'" v-model:copyForm="copyForm"
+        v-model:coalMaintenanceFieldDialogVisible="dialogFormVisible" :form="form" :title="title" :addOrEdit="addOrEdit"
+        @submit="handleSubmit" />
     </el-card>
   </div>
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from "vue";
+// ===== 鏍稿績渚濊禆瀵煎叆 =====
+import { ref, reactive, onMounted, computed, getCurrentInstance } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import { Plus, Edit, Delete, Download } from "@element-plus/icons-vue";
+
+// ===== 缁勪欢瀵煎叆 =====
 import DataTable from "@/components/Table/ETable.vue";
 import Pagination from "@/components/Pagination";
 import Supplier from "./mould/supplier.vue";
 import Customer from "./mould/customer.vue";
 import Coal from "./mould/coal.vue";
 import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue";
-const { proxy } = getCurrentInstance()
-import { getSupply, addOrEditSupply, delSupply } from "@/api/basicInformation/supplier.js";
-import { getCoalInfo, addOrEditCoalInfo } from "@/api/basicInformation/coal.js";
-import { getCoalQuality, addOrEditCoalQuality } from "@/api/basicInformation/coalQualityMaintenance.js";
-// 寮圭獥
-const coalQualityMaintenanceDialogFormVisible = ref(false);
-const customerDialogFormVisible = ref(false);
-const coalDialogFormVisible = ref(false);
-const supplierDialogFormVisible = ref(false);
+import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue";
+
+// ===== API 鏈嶅姟瀵煎叆 =====
+import { getSupply, delSupply } from "@/api/basicInformation/supplier.js";
+import { getCoalInfo, delCoalInfo } 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 { coalField, deleteCoalField } from "@/api/basicInformation/coalFieldMaintenance.js";
+import { getCoalFieldList, getCoalPlanList } from "@/api/basicInformation/coalQualityMaintenance";
+
+const { proxy } = getCurrentInstance();
+
+// ===== 鍝嶅簲寮忕姸鎬佺鐞� =====
+
+// 寮圭獥鎺у埗鐘舵��
 const dialogFormVisible = ref(false);
 const form = ref({});
 const title = ref("");
 const copyForm = ref({});
-// 褰撳墠鏍囩
+const addOrEdit = ref("add");
+
+// 鏁版嵁缂撳瓨鏄犲皠
+const userList = 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 queryParams = reactive({
-  searchText: "",
-  supplierName: "",
-  identifyNumber: "",
-  address: "",
-});
-onMounted(() => {
-  handleTabClick({ props: { name: "supplier" } });
-});
+const tableData = ref([]);
 const columns = ref();
-// 鏍囩椤垫暟鎹�
+
+// 鏌ヨ鍙傛暟
+const queryParams = reactive({});
+
+// 鍦板潃閫夋嫨鏁版嵁
+const addressSelectOptions = ref([]);
+
+// ===== 閰嶇疆甯搁噺 =====
+
+// 鏍囩椤甸厤缃�
 const tabs = reactive([
   { name: "supplier", label: "渚涘簲鍟嗕俊鎭�" },
   { name: "customer", label: "瀹㈡埛淇℃伅" },
   { name: "coal", label: "鐓ょ淇℃伅" },
-  { name: "coalQualityMaintenance", label: "鐓よ川缁存姢" },
+  { name: "coalQualityMaintenance", label: "鐓よ川鏂规" },
+  { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" }
 ]);
-// 鏄惁缂栬緫
-const addOrEdit = ref("add");
-// 琛ㄦ牸鏁版嵁
-const tableData = ref([]);
-// 鏌ヨ鏂规硶
-const handleQuery = () => {
 
+// ===== 宸ュ叿鍑芥暟 =====
+
+/**
+ * 鑾峰彇鍦板潃閫夋嫨鏁版嵁骞舵瀯寤烘槧灏勮〃
+ * @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);
+  }
 };
-// supplier 渚涘簲鍟嗘暟鎹�
+
+/**
+ * 鏋勫缓鍦板潃鏄犲皠琛�
+ * @param {Array} areaData - 鍦板潃鏁版嵁
+ * @description 閫掑綊鏋勫缓鍦板潃鏄犲皠琛紝鏀寔澶氱骇鍦板潃鏌ユ壘
+ */
+const buildAddressMap = (areaData) => {
+  const buildMap = (list, pathList = []) => {
+    list.forEach(item => {
+      const currentPath = [...pathList, item.label];
+      addressMap.value[item.id] = {
+        name: item.label,
+        fullPath: currentPath.join(' / ')
+      };
+      if (item.children && item.children.length > 0) {
+        buildMap(item.children, currentPath);
+      }
+    });
+  };
+  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 '--';
+  }
+  
+  const addressNames = addressIds.map(id => addressMap.value[id]?.name || '--');
+  
+  if (addressNames.every(name => name === '--')) {
+    return '--';
+  }
+  
+  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 => {
+        userMap.value[user.userId] = user.username;
+      });
+    }
+  } catch (error) {
+    console.error('鑾峰彇鐢ㄦ埛鍒楄〃澶辫触:', error);
+  }
+};
+
+/**
+ * 鑾峰彇鐓よ川瀛楁鏁版嵁
+ * @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 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 hasSelectedRows = computed(() => selectedCount.value > 0);
+
+// ===== 琛ㄦ牸鍒楅厤缃� =====
+
+/**
+ * 渚涘簲鍟嗚〃鏍煎垪閰嶇疆
+ */
 const supplierColumns = ref([
-  { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 200 },
-  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 },
-  { prop: "businessAddress", label: "缁忚惀鍦板潃", minWidth: 150 },
-  { prop: "bids", label: "璇︾粏鍦板潃", minWidth: 150 },
+  { prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minWidth: 100 },
+  { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 170 },
+  {
+    prop: "bids",
+    label: "缁忚惀鍦板潃",
+    minWidth: 150,
+    showOverflowTooltip: true,
+    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: "contactAddress", label: "鑱旂郴鍦板潃", minWidth: 150 },
-  { prop: "maintainer", label: "缁存姢浜�", minWidth: 100 },
-  { prop: "createTime", label: "缁存姢鏃ユ湡", minWidth: 100 },
+  {
+    prop: "cids",
+    label: "鑱旂郴浜哄湴鍧�",
+    minWidth: 150,
+    showOverflowTooltip: true,
+    formatter: (row) => {
+      const addressIds = [row.cprovinceId, row.ccityId, row.cdistrictId];
+      return formatAddressArray(addressIds);
+    }
+  },
+  { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 },
+  { prop: "createTime", label: "缁存姢鏃ユ湡", minWidth: 120 },
 ]);
-// customer 瀹㈡埛鏁版嵁
+
+/**
+ * 瀹㈡埛琛ㄦ牸鍒楅厤缃�
+ */
 const customerColumns = ref([
-  { prop: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 200 },
-  { prop: "identifyNumber", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 },
-  { prop: "address", label: "缁忚惀鍦板潃", minWidth: 150 },
-  { prop: "detailedaddress", label: "璇︾粏鍦板潃", minWidth: 150 },
-  { prop: "bank", 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];
+      return formatAddressArray(addressIds);
+    }
+  },
+  { prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150 },
+  { prop: "bankName", label: "寮�鎴疯", minWidth: 120 },
   { prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150 },
-  { prop: "contacts", label: "鑱旂郴浜�", minWidth: 100 },
-  { prop: "contactAddress", label: "鑱旂郴鍦板潃", minWidth: 150 },
-  { prop: "maintainer", label: "缁存姢浜�", minWidth: 100 },
-  { prop: "maintainDate", label: "缁存姢鏃ユ湡", minWidth: 100 },
+  { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 },
+  { prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100 },
+  {
+    prop: "cids",
+    label: "鑱旂郴浜哄湴鍧�",
+    minWidth: 150,
+    showOverflowTooltip: true,
+    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: "coalName", label: "鐓ょ鍚嶇О", minWidth: 200 },
-  { prop: "maintainerId", label: "缁存姢浜�", minWidth: 120 },
+  { prop: "coal", label: "鐓ょ鍚嶇О", minWidth: 200 },
+  {
+    prop: "maintainerId",
+    label: "缁存姢浜�",
+    minWidth: 120,
+    formatter: (row, column, cellValue) => {
+      if (!userMap.value || Object.keys(userMap.value).length === 0) {
+        return '--';
+      }
+      if (cellValue === null || cellValue === undefined || cellValue === '') {
+        return '--';
+      }
+      return userMap.value[cellValue] || '--';
+    }
+  },
   { prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150 },
 ]);
-// coalQualityMaintenance 鐓よ川缁存姢鏁版嵁
+
+/**
+ * 鐓よ川鏂规琛ㄦ牸鍒楅厤缃�
+ */
 const coalQualityMaintenanceColumns = ref([
-  { prop: "supplierName", label: "鍏ㄦ按(<)", minWidth: 200 },
-  { prop: "identifyNumber", label: "姘村垎鏋�(<)", minWidth: 120 },
-  { prop: "address", label: "鐏板垎", minWidth: 150 },
-  { prop: "bank", label: "鎸ュ彂(>)", minWidth: 100 },
-  { prop: "bankAccount", label: "纭�(<)", minWidth: 100 },
-  { prop: "contacts", label: "鍥哄畾纰�", minWidth: 100 },
-  { prop: "contactAddress", label: "楂樹綅鍙戠儹閲�", minWidth: 100 },
-  { prop: "maintainer", label: "浣庝綅鍙戠儹閲�", minWidth: 100 },
+  { prop: "plan", label: "鏂规鍚嶇О", minWidth: 100 },
+  {
+    prop: "coalFields",
+    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":
-      columns.value = supplierColumns.value;
-      dialogFormVisible.value = supplierDialogFormVisible.value;
-      getList("supplier");
-      break;
-    case "customer":
-      columns.value = customerColumns.value;
-      dialogFormVisible.value = customerDialogFormVisible.value;
-      getList("customer");
 
-      break;
-    case "coal":
+  // 鏍规嵁鏍囩椤电被鍨嬭缃搴旂殑鍒楅厤缃�
+  const tabConfig = {
+    supplier: () => {
+      columns.value = supplierColumns.value;
+      getList();
+    },
+    customer: () => {
+      columns.value = customerColumns.value;
+      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;
+      getList();
+      coalFieldData(); // 鍔犺浇鐓よ川瀛楁鏁版嵁
+    },
+    coalMeiZhiZiDuanWeiHu: () => {
+      columns.value = coalMeiZhiZiDuanWeiHuColumns.value;
+      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();
 };
-// 鏂板
+
+/**
+ * 鎼滅储鍔熻兘
+ * @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();
-  }
+
+/**
+ * 鏂板/缂栬緫寮圭獥澶勭悊
+ * @param {string} currentTabName - 褰撳墠鏍囩椤靛悕绉�
+ * @description 鏍规嵁鏍囩椤电被鍨嬭缃脊绐楁爣棰樺苟鎵撳紑寮圭獥
+ */
+const handleAddEdit = (currentTabName) => {
+  const actionText = addOrEdit.value === "add" ? "鏂板" : "缂栬緫";
+  
+  const tabTitleMap = {
+    supplier: "渚涘簲鍟嗕俊鎭�",
+    customer: "瀹㈡埛淇℃伅", 
+    coal: "鐓ょ淇℃伅",
+    coalQualityMaintenance: "鐓よ川鏂规缁存姢",
+    coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢"
+  };
+
+  title.value = `${actionText}${tabTitleMap[currentTabName] || ''}`;
+  openDialog();
 };
-// 鎵撳紑寮圭獥
+
+/**
+ * 鎵撳紑寮圭獥
+ * @description 鏍规嵁缂栬緫鐘舵�佸喅瀹氭槸鍚﹀鍒惰〃鍗曟暟鎹�
+ */
 const openDialog = () => {
   if (addOrEdit.value === "edit") {
     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) => {
-  console.log("鍒嗛〉鍙傛暟锛�", val);
   pageNum.value = val.page;
   pageSizes.value = val.limit;
   getList();
 };
-// 鎻愪氦琛ㄥ崟
+
+/**
+ * 琛ㄥ崟鎻愪氦澶勭悊
+ * @param {Object} val - 鎻愪氦缁撴灉瀵硅薄
+ */
 const handleSubmit = async (val) => {
-  console.log(val)
-  if (val.code !== 200) {
-    ElMessage.error("鎿嶄綔澶辫触锛�" + result.msg);
+  if (val.result.code !== 200) {
+    ElMessage.error("鎿嶄綔澶辫触锛�" + val.result.msg);
     return;
   }
-  ElMessage.success("鏂板鎴愬姛锛�" + result.msg);
+  ElMessage.success(val.title + val.result.msg);
   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];
+  }
+  
+  // 鏋勫缓渚涘簲鍟嗚仈绯诲湴鍧�鏁扮粍
+  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 = "edit";
   handleAddEdit(tabName.value);
 };
-// 鎵归噺鍒犻櫎
-const handleDelete = () => {
+
+/**
+ * 鎵归噺鍒犻櫎澶勭悊
+ * @description 鎵归噺鍒犻櫎閫変腑鐨勮褰�
+ */
+const handleDelete = async () => {
   if (selectedRows.value.length === 0) {
     ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
     return;
   }
-  let arr = reactive([]);
-  selectedRows.value.forEach(element => {
-    return arr.push(element.id);
-  });
-  console.log("閫変腑鐨勬暟鎹甀D锛�", arr);
-  ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", {
-    confirmButtonText: "纭畾",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
-    .then(async () => {
-      try {
-        let res = await delSupply(arr)
-        console.log(res)
-        selectedRows.value = [];
-        getlist()
-      } catch {
-        ElMessage.error("鍒犻櫎澶辫触锛岃绋嶅悗鍐嶈瘯");
-        return;
-      }
-    }).catch(() => {
-      ElMessage.info("宸插彇娑堝垹闄ゆ搷浣�");
+
+  const deleteIds = selectedRows.value.map(item => item.id);
+  
+  try {
+    await ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", {
+      confirmButtonText: "纭畾",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
     });
-}
-// 鍏抽棴寮圭獥
+
+    const deleteApiMap = {
+      supplier: delSupply,
+      coal: delCoalInfo,
+      coalQualityMaintenance: () => { throw new Error('delCoalQuality API not imported'); },
+      customer: delCustomer,
+      coalMeiZhiZiDuanWeiHu: deleteCoalField
+    };
+
+    const deleteApi = deleteApiMap[tabName.value];
+    if (!deleteApi) {
+      ElMessage.error("鍒犻櫎鎺ュ彛鏈厤缃�");
+      return;
+    }
+
+    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 handleBeforeClose = () => {
   dialogFormVisible.value = false;
   form.value = {};
 };
-const handleExport = (row) => {
-  proxy.download("system/post/export", {
-    ...queryParams.value
-  }, `post_${new Date().getTime()}.xlsx`)
-  ElMessage.success("瀵煎嚭鏁版嵁锛�" + row.supplierName);
-};
-// 閫夋嫨鎺ュ彛
-const selectInterface = () => {
-  if (tabName.value === "supplier") {
-    return getSupply({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      searchAll: queryParams.searchAll,
-    });
-  } else if (tabName.value === "customer") {
-    return getSupply({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      ...queryParams
-    });
-  } else if (tabName.value === "coal") {
-    console.log(addOrEdit.value)
-    return getCoalInfo();
-  } else if (tabName.value === "coalQualityMaintenance") {
-    return getCoalQuality({
-      current: pageNum.value,
-      pageSize: pageSizes.value,
-      ...queryParams
-    });
+
+/**
+ * 瀵煎嚭鍔熻兘澶勭悊
+ */
+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 getList = async () => {
-  loading.value = true;
-  let { data, code } = await selectInterface()
-  console.log(data)
-  tableData.value = data.records;
-  total.value = data.total;
-  loading.value = false;
 };
+
+/**
+ * 瀵煎嚭鏁版嵁
+ * @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 = () => {
+  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 () => {
+  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;
+  }
+};
+
+// ===== 鐢熷懡鍛ㄦ湡閽╁瓙 =====
+
+/**
+ * 缁勪欢鎸傝浇鍚庣殑鍒濆鍖栨搷浣�
+ */
+onMounted(async () => {
+  try {
+    // 骞惰鎵ц鍒濆鍖栨搷浣�
+    await Promise.all([
+      handleTabClick({ props: { name: "supplier" } }),
+      fetchAreaOptions(),
+      getUserList()
+    ]);
+  } catch (error) {
+    console.error('缁勪欢鍒濆鍖栧け璐�:', error);
+    ElMessage.error("椤甸潰鍒濆鍖栧け璐ワ紝璇峰埛鏂伴噸璇�");
+  }
+});
 </script>
 
 <style scoped>

--
Gitblit v1.9.3