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 | 113 ++++++++++++++++++++++++++------------------------------ 1 files changed, 52 insertions(+), 61 deletions(-) diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue index 4f47266..907d60d 100644 --- a/src/views/basicInformation/index.vue +++ b/src/views/basicInformation/index.vue @@ -56,9 +56,6 @@ @edit="handleEdit" @viewRow="handleView" @selection-change="handleSelectionChange" - :showOperations="true" - :showIndex="true" - :showPagination="false" :operations="['edit', 'viewRow']" :operationsWidth="200" > @@ -170,7 +167,6 @@ import Coal from "./mould/coal.vue"; import coalQualityMaintenance from "./mould/coalQualityMaintenance.vue"; import coalMeiZhiZiDuanWeiHu from "./mould/coalMeiZhiZiDuanWeiHu.vue"; -import Descriptions from "@/components/dialog/Descriptions.vue"; // ===== API 鏈嶅姟瀵煎叆 ===== import { delSupply, getSupply } from "@/api/basicInformation/supplier.js"; @@ -188,16 +184,12 @@ import { getCoalFieldList, getCoalPlanList, + delCoalPlan, } from "@/api/basicInformation/coalQualityMaintenance"; - +import { useDelete } from "@/hooks/useDelete.js"; const { proxy } = getCurrentInstance(); // ===== 鍝嶅簲寮忕姸鎬佺鐞� ===== -// 寮圭獥鎺у埗鐘舵�� -const showDialog = ref(false); -const currentViewData = ref({}); // 褰撳墠鏌ョ湅鐨勬暟鎹� - - const dialogFormVisible = ref(false); const form = ref({}); const title = ref(""); @@ -371,11 +363,11 @@ */ const searchPlaceholder = computed(() => { const placeholderMap = { - supplier: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", - customer: "渚涘簲鍟�/璇嗗埆鐮�/璇︾粏鍦板潃", - coal: "璇疯緭鍏ユ悳绱俊鎭�", - coalQualityMaintenance: "璇疯緭鍏ユ悳绱俊鎭�", - coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ユ悳绱俊鎭�", + supplier: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃", + customer: "渚涘簲鍟�/缁熶竴璇嗗埆鐮�/璇︾粏鍦板潃", + coal: "璇疯緭鍏ョ叅绉嶄俊鎭�", + coalQualityMaintenance: "璇疯緭鍏ョ叅璐ㄦ柟妗堜俊鎭�", + coalMeiZhiZiDuanWeiHu: "璇疯緭鍏ョ叅璐ㄥ瓧娈典俊鎭�", }; return placeholderMap[tabName.value] || "璇疯緭鍏ユ悳绱俊鎭�"; }); @@ -723,57 +715,22 @@ * 鎵归噺鍒犻櫎澶勭悊 * @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, }; - - 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: "鍒犻櫎鎴愬姛", +}) /** * 鍏抽棴寮圭獥澶勭悊 @@ -865,6 +822,40 @@ } }; +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); +}; + + // ===== 鐢熷懡鍛ㄦ湡閽╁瓙 ===== /** -- Gitblit v1.9.3