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 | 475 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 306 insertions(+), 169 deletions(-) diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue index 9f5927e..26dc9b9 100644 --- a/src/views/basicInformation/index.vue +++ b/src/views/basicInformation/index.vue @@ -1,7 +1,12 @@ <template> - <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 /> + <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> @@ -10,59 +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 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="canExport">瀵煎嚭</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 :loading="loading" :table-data="tableData" :columns="columns" - @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;"> + <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 type="primary" size="small"> - {{ getFieldDisplayName(row.coalFields) || '--' }} + <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: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" /> + <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, getCurrentInstance } 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"; @@ -74,19 +169,27 @@ import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue"; // ===== API 鏈嶅姟瀵煎叆 ===== -import { getSupply, delSupply } from "@/api/basicInformation/supplier.js"; -import { getCoalInfo, delCoalInfo } from "@/api/basicInformation/coal.js"; +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 { coalField, deleteCoalField } from "@/api/basicInformation/coalFieldMaintenance.js"; -import { getCoalFieldList, getCoalPlanList } from "@/api/basicInformation/coalQualityMaintenance"; - +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 dialogFormVisible = ref(false); const form = ref({}); const title = ref(""); @@ -128,7 +231,7 @@ { name: "customer", label: "瀹㈡埛淇℃伅" }, { name: "coal", label: "鐓ょ淇℃伅" }, { name: "coalQualityMaintenance", label: "鐓よ川鏂规" }, - { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" } + { name: "coalMeiZhiZiDuanWeiHu", label: "鐓よ川瀛楁" }, ]); // ===== 宸ュ叿鍑芥暟 ===== @@ -146,7 +249,7 @@ buildAddressMap(res.data); } } catch (error) { - console.error('鑾峰彇鍦板潃閫夐」澶辫触:', error); + console.error("鑾峰彇鍦板潃閫夐」澶辫触:", error); } }; @@ -157,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); @@ -178,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 || '--'); - - 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(" / "); }; /** @@ -200,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); } }; @@ -222,7 +334,7 @@ coalFieldList.value = data; } } catch (error) { - console.error('鑾峰彇鐓よ川瀛楁鏁版嵁澶辫触:', error); + console.error("鑾峰彇鐓よ川瀛楁鏁版嵁澶辫触:", error); } }; @@ -233,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); }); /** @@ -255,11 +365,11 @@ */ const searchPlaceholder = computed(() => { const placeholderMap = { - supplier: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", - customer: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", - coal: "璇疯緭鍏ユ悳绱俊鎭�", - coalQualityMaintenance: "璇疯緭鍏ユ悳绱俊鎭�", - coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ユ悳绱俊鎭�" + supplier: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃", + customer: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃", + coal: "璇疯緭鍏ョ叅绉嶄俊鎭�", + coalQualityMaintenance: "璇疯緭鍏ョ叅璐ㄦ柟妗堜俊鎭�", + coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ョ叅璐ㄥ瓧娈典俊鎭�", }; return placeholderMap[tabName.value] || "璇疯緭鍏ユ悳绱俊鎭�"; }); @@ -268,18 +378,19 @@ * 鏄惁鏄剧ず鎼滅储妗� */ const shouldShowSearch = computed(() => { - return ['supplier', 'customer', 'coal', 'coalQualityMaintenance','coalMeiZhiZiDuanWeiHu'].includes(tabName.value); + return [ + "supplier", + "customer", + "coal", + "coalQualityMaintenance", + "coalMeiZhiZiDuanWeiHu", + ].includes(tabName.value); }); /** * 褰撳墠閫変腑琛屾暟閲� */ const selectedCount = computed(() => selectedRows.value.length); - -/** - * 鏄惁鏈夐�変腑鐨勮 - */ -const hasSelectedRows = computed(() => selectedCount.value > 0); // ===== 琛ㄦ牸鍒楅厤缃� ===== @@ -297,11 +408,10 @@ 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", @@ -311,10 +421,9 @@ formatter: (row) => { const addressIds = [row.cprovinceId, row.ccityId, row.cdistrictId]; return formatAddressArray(addressIds); - } + }, }, { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 120 }, - { prop: "createTime", label: "缁存姢鏃ユ湡", minWidth: 120 }, ]); /** @@ -329,9 +438,13 @@ 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 }, @@ -346,7 +459,7 @@ formatter: (row) => { const addressIds = [row.provinceId, row.cityId, row.districtId]; return formatAddressArray(addressIds); - } + }, }, { prop: "contactAddress", label: "鑱旂郴浜鸿缁嗗湴鍧�", minWidth: 150 }, { prop: "updateTime", label: "缁存姢鏃ユ湡", minWidth: 100 }, @@ -363,13 +476,13 @@ 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 }, ]); @@ -380,17 +493,17 @@ const coalQualityMaintenanceColumns = ref([ { prop: "plan", label: "鏂规鍚嶇О", minWidth: 100 }, { - prop: "coalFields", + prop: "fieldIds", label: "瀛楁鍚嶇О", minWidth: 200, showOverflowTooltip: true, 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 }, ]); @@ -416,7 +529,10 @@ loading.value = true; tabName.value = tab.props.name; tableData.value = []; - + pageNum.value = 1; + pageSizes.value = 10; + total.value = 0; + queryParams.searchAll = ""; // 鏍规嵁鏍囩椤电被鍨嬭缃搴旂殑鍒楅厤缃� const tabConfig = { supplier: () => { @@ -439,7 +555,7 @@ coalMeiZhiZiDuanWeiHu: () => { columns.value = coalMeiZhiZiDuanWeiHuColumns.value; getList(); - } + }, }; // 鎵ц瀵瑰簲鐨勯厤缃嚱鏁� @@ -485,17 +601,22 @@ * @description 鏍规嵁鏍囩椤电被鍨嬭缃脊绐楁爣棰樺苟鎵撳紑寮圭獥 */ const handleAddEdit = (currentTabName) => { - const actionText = addOrEdit.value === "add" ? "鏂板" : "缂栬緫"; - + const actionText = + addOrEdit.value === "add" + ? "鏂板" + : addOrEdit.value === "edit" + ? "缂栬緫" + : "鏌ョ湅"; + const tabTitleMap = { supplier: "渚涘簲鍟嗕俊鎭�", - customer: "瀹㈡埛淇℃伅", + customer: "瀹㈡埛淇℃伅", coal: "鐓ょ淇℃伅", coalQualityMaintenance: "鐓よ川鏂规缁存姢", - coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢" + coalMeiZhiZiDuanWeiHu: "鐓よ川瀛楁缁存姢", }; - title.value = `${actionText}${tabTitleMap[currentTabName] || ''}`; + title.value = `${actionText}${tabTitleMap[currentTabName] || ""}`; openDialog(); }; @@ -504,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 = {}; @@ -558,84 +679,60 @@ */ 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.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); }; + /** * 鎵归噺鍒犻櫎澶勭悊 * @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; - } - - 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: "鍒犻櫎鎴愬姛", +}) /** * 鍏抽棴寮圭獥澶勭悊 @@ -653,7 +750,7 @@ supplier: { api: "/supply/export", name: "渚涘簲鍟嗕俊鎭�" }, customer: { api: "/customer/export", name: "瀹㈡埛淇℃伅" }, coal: { api: "/supply/export", name: "鐓ょ淇℃伅" }, - coalQualityMaintenance: { api: "/supply/export", name: "鐓よ川缁存姢淇℃伅" } + coalQualityMaintenance: { api: "/supply/export", name: "鐓よ川缁存姢淇℃伅" }, }; const config = exportConfig[tabName.value]; @@ -668,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); }; // ===== 鏁版嵁鑾峰彇鍑芥暟 ===== @@ -690,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鎺ュ彛")); }; /** @@ -705,21 +808,55 @@ try { loading.value = true; 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); +}; + // ===== 鐢熷懡鍛ㄦ湡閽╁瓙 ===== @@ -732,10 +869,10 @@ await Promise.all([ handleTabClick({ props: { name: "supplier" } }), fetchAreaOptions(), - getUserList() + getUserList(), ]); } catch (error) { - console.error('缁勪欢鍒濆鍖栧け璐�:', error); + console.error("缁勪欢鍒濆鍖栧け璐�:", error); ElMessage.error("椤甸潰鍒濆鍖栧け璐ワ紝璇峰埛鏂伴噸璇�"); } }); @@ -775,7 +912,7 @@ /* 琛ㄦ牸宸ュ叿鏍� */ .table-toolbar, -.table-toolbar>* { +.table-toolbar > * { margin: 0 0 0 0 !important; } @@ -790,4 +927,4 @@ .main-container { background: red !important; } -</style> \ No newline at end of file +</style> -- Gitblit v1.9.3