| | |
| | | @edit="handleEdit" |
| | | @viewRow="handleView" |
| | | @selection-change="handleSelectionChange" |
| | | :showOperations="true" |
| | | :showIndex="true" |
| | | :showPagination="false" |
| | | :operations="['edit', 'viewRow']" |
| | | :operationsWidth="200" |
| | | > |
| | |
| | | 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"; |
| | |
| | | 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(""); |
| | |
| | | */ |
| | | const searchPlaceholder = computed(() => { |
| | | const placeholderMap = { |
| | | supplier: "供应商/识别码/详细地址", |
| | | customer: "供应商/识别码/详细地址", |
| | | coal: "请输入搜索信息", |
| | | coalQualityMaintenance: "请输入搜索信息", |
| | | coalMeiZhiZiDuanWeiHu: "请输入搜索信息", |
| | | supplier: "供应商/统一识别码/详细地址", |
| | | customer: "供应商/统一识别码/详细地址", |
| | | coal: "请输入煤种信息", |
| | | coalQualityMaintenance: "请输入煤质方案信息", |
| | | coalMeiZhiZiDuanWeiHu: "请输入煤质字段信息", |
| | | }; |
| | | return placeholderMap[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, |
| | | }; |
| | | |
| | | 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: "删除成功", |
| | | }) |
| | | |
| | | /** |
| | | * 关闭弹窗处理 |
| | |
| | | } |
| | | }; |
| | | |
| | | 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); |
| | | }; |
| | | |
| | | |
| | | // ===== 生命周期钩子 ===== |
| | | |
| | | /** |