From dd159ea51a7a77bd8cc00c70c0e900f472fb3395 Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期四, 05 六月 2025 18:00:17 +0800
Subject: [PATCH] 完善基础管理 供应商、客户、煤种等功能
---
src/views/basicInformation/index.vue | 358 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 292 insertions(+), 66 deletions(-)
diff --git a/src/views/basicInformation/index.vue b/src/views/basicInformation/index.vue
index e2007e9..ff27c0e 100644
--- a/src/views/basicInformation/index.vue
+++ b/src/views/basicInformation/index.vue
@@ -1,12 +1,13 @@
<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="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 />
+ </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>
@@ -20,20 +21,21 @@
<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-button type="info" :icon="Download" @click="handleExport" v-show="tabName === 'supplier' || tabName === 'customer'">瀵煎嚭</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"
+ </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"
+ <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:customerDialogFormVisible="dialogFormVisible" :form="form"
+ <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:coalDialogFormVisible="dialogFormVisible" :form="form" :title="title"
+ <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"
@@ -43,7 +45,7 @@
</template>
<script setup>
-import { ref, reactive, onMounted } from "vue";
+import { ref, reactive, onMounted, computed } 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";
@@ -54,8 +56,12 @@
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";
+import { getCoalInfo, delCoalInfo } from "@/api/basicInformation/coal.js";
+import { getCoalQuality, delCoalQuality } from "@/api/basicInformation/coalQualityMaintenance.js";
+import { testUserList } from "@/api/tool/publicInterface.js";
+import { getAreaOptions } from "@/api/system/area.js";
+import { getCustomerList, delCustomer } from "@/api/basicInformation/customer.js";
+
// 寮圭獥
const coalQualityMaintenanceDialogFormVisible = ref(false);
const customerDialogFormVisible = ref(false);
@@ -65,6 +71,12 @@
const form = ref({});
const title = ref("");
const copyForm = ref({});
+// 鐢ㄦ埛鍒楄〃鏁版嵁
+const userList = ref([]);
+// 鐢ㄦ埛鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵�
+const userMap = ref({});
+// 鍦板潃鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵惧湴鍧�鍚嶇О
+const addressMap = ref({});
// 褰撳墠鏍囩
const tabName = ref("supplier");
// 鐘舵�佸彉閲�
@@ -76,13 +88,72 @@
const selectedRows = ref([]);
// 鏌ヨ鍙傛暟
const queryParams = reactive({
- searchText: "",
- supplierName: "",
- identifyNumber: "",
- address: "",
});
-onMounted(() => {
- handleTabClick({ props: { name: "supplier" } });
+// 鍦板潃閫夋嫨鏁版嵁
+const addressSelectOptions = ref([]);
+const fetchAreaOptions = async () => {
+ addressSelectOptions.value = [];
+ const res = await getAreaOptions();
+ if (res.code === 200) {
+ addressSelectOptions.value = res.data;
+ buildAddressMap(res.data); // 鏋勫缓鍦板潃鏄犲皠琛�
+ }
+}
+
+// 鏋勫缓鍦板潃鏄犲皠琛紝鐢ㄤ簬蹇�熸煡鎵惧湴鍧�鍚嶇О
+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);
+};
+
+// 鍦板潃鏍煎紡鍖栧嚱鏁�
+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 => {
+ return addressMap.value[id]?.name || '--';
+ });
+
+ // 濡傛灉鎵�鏈夊湴鍧�鍚嶇О閮芥槸 '--'锛屽垯杩斿洖 '--'
+ if (addressNames.every(name => name === '--')) {
+ return '--';
+ }
+
+ return addressNames.filter(name => name !== '--').join(' / ');
+};
+// 鑾峰彇鐢ㄦ埛鍒楄〃鏁版嵁
+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);
+ }
+};
+
+onMounted(async () => {
+ await handleTabClick({ props: { name: "supplier" } });
+ await fetchAreaOptions(); // 鍏堣幏鍙栧湴鍧�閫夋嫨鏁版嵁骞舵瀯寤烘槧灏勮〃
+ await getUserList(); // 鑾峰彇鐢ㄦ埛鍒楄〃
});
const columns = ref();
// 鏍囩椤垫暟鎹�
@@ -96,40 +167,127 @@
const addOrEdit = ref("add");
// 琛ㄦ牸鏁版嵁
const tableData = ref([]);
-// 鏌ヨ鏂规硶
-const handleQuery = () => {
-
-};
// supplier 渚涘簲鍟嗘暟鎹�
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, column, cellValue) => {
+ let arr = [
+ row.bprovinceId,
+ row.bcityId,
+ row.bdistrictId,
+ ]
+ return formatAddressArray(arr);
+ }
+ },
+ { 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: "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 },
]);
// 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: "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: "customerName", label: "瀹㈡埛鍚嶇О", minWidth: 100 },
+ { prop: "taxpayerId", label: "缁熶竴浜鸿瘑鍒彿", minWidth: 120 },
+{
+ prop: "bids",
+ label: "缁忚惀鍦板潃",
+ minWidth: 150,
+ showOverflowTooltip: true,
+ formatter: (row, column, cellValue) => {
+ let arr = [
+ row.businessProvinceId,
+ row.businessCityId,
+ row.businessDistrictId,
+ ]
+ return formatAddressArray(arr);
+ }
+ },
+ { prop: "businessAddress", label: "璇︾粏鍦板潃", minWidth: 150 },
+ { prop: "bankName", label: "寮�鎴疯", minWidth: 120 },
+ { prop: "bankAccount", label: "閾惰璐﹀彿", minWidth: 150 },
+ { prop: "contactPerson", label: "鑱旂郴浜�", minWidth: 100 },
+ { prop: "contactPhone", label: "鑱旂郴浜虹數璇�", minWidth: 100 },
+{
+ prop: "cids",
+ label: "鑱旂郴浜哄湴鍧�",
+ minWidth: 150,
+ showOverflowTooltip: true,
+ formatter: (row, column, cellValue) => {
+ let arr = [
+ row.provinceId,
+ row.cityId,
+ row.districtId,
+ ]
+ return formatAddressArray(arr);
+ }
+ },
+ { 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 '--';
+ }
+ // 濡傛灉鍊间负绌烘垨null锛屾樉绀� --
+ if (cellValue === null || cellValue === undefined || cellValue === '') {
+ return '--';
+ }
+ // 濡傛灉鐢ㄦ埛鏄犲皠琛ㄤ腑鏈夊搴旂殑鐢ㄦ埛鍚嶏紝杩斿洖鐢ㄦ埛鍚�
+ if (userMap.value[cellValue]) {
+ return userMap.value[cellValue];
+ }
+ // 濡傛灉娌℃湁鍖归厤鐨勭敤鎴凤紝鏄剧ず --
+ return '--';
+ }
+ },
{ prop: "maintenanceDate", label: "缁存姢鏃ユ湡", minWidth: 150 },
]);
// coalQualityMaintenance 鐓よ川缁存姢鏁版嵁
@@ -181,6 +339,7 @@
queryParams[key] = "";
}
});
+ getList()
};
// 鏂板
const handleAdd = () => {
@@ -220,20 +379,19 @@
};
// 鍒嗛〉
const handPagination = (val) => {
- console.log("鍒嗛〉鍙傛暟锛�", val);
pageNum.value = val.page;
pageSizes.value = val.limit;
getList();
};
// 鎻愪氦琛ㄥ崟
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();
};
const handleDialogFormVisible = (value) => {
dialogFormVisible.value = value;
@@ -245,6 +403,34 @@
// 缂栬緫
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);
};
@@ -258,7 +444,6 @@
selectedRows.value.forEach(element => {
return arr.push(element.id);
});
- console.log("閫変腑鐨勬暟鎹甀D锛�", arr);
ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勬暟鎹悧锛�", "鎻愮ず", {
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
@@ -266,13 +451,27 @@
})
.then(async () => {
try {
- let res = await delSupply(arr)
- console.log(res)
- selectedRows.value = [];
- getlist()
- } catch {
+ 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("鍒犻櫎澶辫触锛岃绋嶅悗鍐嶈瘯");
- return;
+ } finally {
+ selectedRows.value = [];
}
}).catch(() => {
ElMessage.info("宸插彇娑堝垹闄ゆ搷浣�");
@@ -283,11 +482,23 @@
dialogFormVisible.value = false;
form.value = {};
};
-const handleExport = (row) => {
- proxy.download("system/post/export", {
+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 Export = (api,name) => {
+ proxy.download(api, {
...queryParams.value
- }, `post_${new Date().getTime()}.xlsx`)
- ElMessage.success("瀵煎嚭鏁版嵁锛�" + row.supplierName);
+ }, `${name}${new Date().getTime()}.xlsx`)
+ ElMessage.success("瀵煎嚭鏁版嵁锛�" + name);
};
// 閫夋嫨鎺ュ彛
const selectInterface = () => {
@@ -298,26 +509,41 @@
searchAll: queryParams.searchAll,
});
} else if (tabName.value === "customer") {
- return getSupply({
+ return getCustomerList({
current: pageNum.value,
pageSize: pageSizes.value,
- ...queryParams
+ searchAll: queryParams.searchAll,
});
} else if (tabName.value === "coal") {
- console.log(addOrEdit.value)
- return getCoalInfo();
+ return getCoalInfo({
+ current: pageNum.value,
+ pageSize: pageSizes.value,
+ searchAll: queryParams.searchAll,
+ });
} else if (tabName.value === "coalQualityMaintenance") {
return getCoalQuality({
current: pageNum.value,
pageSize: pageSizes.value,
- ...queryParams
+ searchAll: queryParams.searchAll,
});
}
}
+const search = () => {
+ pageNum.value = 1; // 閲嶇疆椤电爜
+ getList();
+};
+// 鑾峰彇鍒楄〃鏁版嵁
const getList = async () => {
loading.value = true;
+ /* if (Object.keys(addressMap.value).length === 0) {
+ await fetchAreaOptions();
+ } */
let { data, code } = await selectInterface()
- console.log(data)
+ if(code !== 200) {
+ ElMessage.error("鑾峰彇鏁版嵁澶辫触锛�" + data.msg);
+ loading.value = false;
+ return;
+ }
tableData.value = data.records;
total.value = data.total;
loading.value = false;
--
Gitblit v1.9.3