From d2d31b4bc54d2deb303c606acad3840d2f0984a5 Mon Sep 17 00:00:00 2001 From: qubiaobiao <3294694717@qq.com> Date: Thu, 4 Jun 2026 16:20:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=B9=B3=E5=8F=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/url.js | 47 ++ src/components/addNewData/SNForm/SNForm.vue | 2 +- .../addNewData/SNForm/multipleAdd.vue | 2 +- .../addNewData/SNForm/singleAdd.vue | 4 +- .../addNewData/bsideForm/multipleAdd.vue | 4 +- .../addNewData/businessForm/multipleAdd.vue | 4 +- .../contest/accountForm/multipleAdd.vue | 4 +- .../contest/choiceTopicForm/multipleAdd.vue | 4 +- .../contest/contestForm/multipleAdd.vue | 4 +- .../contest/tqxzContest/excleAdd.vue | 82 +++ .../contest/tqxzContest/multipleAdd.vue | 113 ++++ .../contest/tqxzContest/singleAdd.vue | 88 +++ .../addNewData/contest/tqxzContest/snForm.vue | 206 +++++++ .../addNewData/insidersForm/multipleAdd.vue | 4 +- .../organizationForm/multipleAdd.vue | 4 +- src/components/mainPage/SN.vue | 70 +++ src/components/mainPage/SNAdmin.vue | 124 +++-- .../mainPage/allocationSNRecord.vue | 69 +++ src/components/mainPage/bdCard.vue | 72 +++ src/components/mainPage/bindRecord.vue | 71 +++ src/components/mainPage/bindSNRecord.vue | 71 +++ src/components/mainPage/bside.vue | 76 +++ src/components/mainPage/business.vue | 77 +++ src/components/mainPage/contest/account.vue | 71 +++ .../mainPage/contest/choiceTopic.vue | 71 +++ src/components/mainPage/contest/contest.vue | 78 +++ .../mainPage/contest/examination.vue | 72 +++ .../contest/tqxzContest/snContestMsg.vue | 451 ++++++++++++++++ src/components/mainPage/cside.vue | 79 +++ src/components/mainPage/insiders.vue | 75 +++ src/components/mainPage/monitoring.vue | 73 +++ src/components/mainPage/organization.vue | 75 +++ src/components/mainPage/unknownBDCard.vue | 478 +++++++++++++++++ src/components/mainPage/unknownSN.vue | 503 ++++++++++++++++++ src/components/operate/downloadData.vue | 167 ++++++ src/components/operate/tabelTools.vue | 15 + src/router/index.js | 18 + .../contest/tqxzContest/snContestMsg.js | 45 ++ src/stores/unknownBDCardRecord.js | 43 ++ src/stores/unknownSNRecord.js | 43 ++ src/utils/downloadData.js | 21 + src/views/header/Contest.vue | 1 + src/views/header/Workspace.vue | 8 +- 43 files changed, 3533 insertions(+), 56 deletions(-) create mode 100644 src/components/addNewData/contest/tqxzContest/excleAdd.vue create mode 100644 src/components/addNewData/contest/tqxzContest/multipleAdd.vue create mode 100644 src/components/addNewData/contest/tqxzContest/singleAdd.vue create mode 100644 src/components/addNewData/contest/tqxzContest/snForm.vue create mode 100644 src/components/mainPage/contest/tqxzContest/snContestMsg.vue create mode 100644 src/components/mainPage/unknownBDCard.vue create mode 100644 src/components/mainPage/unknownSN.vue create mode 100644 src/components/operate/downloadData.vue create mode 100644 src/stores/contest/tqxzContest/snContestMsg.js create mode 100644 src/stores/unknownBDCardRecord.js create mode 100644 src/stores/unknownSNRecord.js create mode 100644 src/utils/downloadData.js diff --git a/src/api/url.js b/src/api/url.js index 3742d38..a8173c9 100644 --- a/src/api/url.js +++ b/src/api/url.js @@ -33,11 +33,15 @@ export default { editBdCard: "/accountManager/editBdCard", // 删除北斗卡 deleteBdCard: "/accountManager/deleteBdCard", + // 管理系统导出北斗卡 + downloadBDCard: "/accountManager/downloadBDCard", // 查看绑定记录 showBindRecord: "/accountManager/showBindRecord", // 删除绑定记录 deleteBindRecord: "/accountManager/deleteBindRecord", + // 管理系统导出绑定记录 + downloadBindRecord: "/accountManager/downloadBindRecord", // 注册公司业务 addBusiness: "/accountManager/addBusiness", @@ -49,6 +53,8 @@ export default { editBusiness: "/accountManager/editBusiness", // 删除公司业务 deleteBusiness: "/accountManager/deleteBusiness", + // 管理系统导出公司业务 + downloadBusiness: "/accountManager/downloadBusiness", // 注册B端用户 addBSide: "/accountManager/addBSide", @@ -58,6 +64,8 @@ export default { editBSide: "/accountManager/editBSide", // 删除B端用户 deleteBSide: "/accountManager/deleteBSide", + // 管理系统导出B端用户 + downloadBside: "/accountManager/downloadBside", // 查看C端用户 showCSide: "/accountManager/showCSide", @@ -65,6 +73,8 @@ export default { editCSide: "/accountManager/editCSide", // 删除C端用户 deleteCSide: "/accountManager/deleteCSide", + // 管理系统导出C端用户 + downloadCside: "/accountManager/downloadCside", // 注册管理系统用户 addInsiders: "/accountManager/addInsiders", @@ -74,6 +84,8 @@ export default { editInsiders: "/accountManager/editInsiders", // 删除管理系统用户 deleteInsiders: "/accountManager/deleteInsiders", + // 管理系统导出系统用户 + downloadInsiders: "/accountManager/downloadInsiders", // 注册B端用户单位 addOrganization: "/accountManager/addOrganization", @@ -85,11 +97,15 @@ export default { editOrganization: "/accountManager/editOrganization", // 删除B端用户单位 deleteOrganization: "/accountManager/deleteOrganization", + // 管理系统导出B端用户单位 + downloadOrganization: "/accountManager/downloadOrganization", // 查看监控记录 showMonitoring: "/accountManager/showMonitoring", // 删除监控记录 deleteMonitoring: "/accountManager/deleteMonitoring", + // 管理系统导出监控记录 + downloadMonitoring: "/accountManager/downloadMonitoring", // 管理系统检索竞赛 uid searchContestUid: "/accountManager/searchContestUid", @@ -101,6 +117,8 @@ export default { editContest: "/accountManager/editContest", // 管理系统删除竞赛信息 delContest: "/accountManager/delContest", + // 管理系统导出竞赛信息 + downloadContest: "/accountManager/downloadContest", // 管理系统导入选择题 importChoiceTopic: "/accountManager/importChoiceTopic", @@ -112,6 +130,8 @@ export default { editChoiceTopic: "/accountManager/editChoiceTopic", // 管理系统删除选择题 delChoiceTopic: "/accountManager/delChoiceTopic", + // 管理系统导出选择题 + downloadChoiceTopic: "/accountManager/downloadChoiceTopic", // 管理系统导入竞赛账号信息 importAccount: "/accountManager/importAccount", @@ -123,6 +143,8 @@ export default { editAccount: "/accountManager/editAccount", // 管理系统删除竞赛账号信息 delAccount: "/accountManager/delAccount", + // 管理系统导出竞赛账号信息 + downloadAccount: "/accountManager/downloadAccount", // 管理系统重置竞赛账号密码 resetAccount: "/accountManager/resetAccount", @@ -144,11 +166,15 @@ export default { editSN: "/accountManager/editSN", // 删除SN号 deleteSN: "/accountManager/deleteSN", + // 管理系统导出SN号 + downloadSN: "/accountManager/downloadSN", // 查看SN号绑定记录 showBindSNRecord: "/accountManager/showBindSNRecord", // 删除SN号绑定记录 deleteBindSNRecord: "/accountManager/deleteBindSNRecord", + // 管理系统导出SN号绑定记录 + downloadBindSNRecord: "/accountManager/downloadBindSNRecord", // 搜索可分配的SN号 searchAllocationSN: "/accountManager/searchAllocationSN", @@ -160,4 +186,25 @@ export default { showAllocationSNRecord: "/accountManager/showAllocationSNRecord", // 删除B端SN号分配记录 deleteAllocationSNRecord: "/accountManager/deleteAllocationSNRecord", + // 管理系统导出B端SN号分配记录 + downloadAllocationSN: "/accountManager/downloadAllocationSN", + + // 查看未知北斗卡消息 + showUnknownBDCard: "/accountManager/showUnknownBDCard", + // 删除未知北斗卡消息 + deleteUnknownBDCard: "/accountManager/deleteUnknownBDCard", + // 管理系统导出未知北斗卡消息 + downloadUnknownBDCard: "/accountManager/downloadUnknownBDCard", + + // 查看未知SN号消息 + showUnknownSN: "/accountManager/showUnknownSN", + // 删除未知SN号消息 + deleteUnknownSN: "/accountManager/deleteUnknownSN", + // 管理系统导出未知SN号消息 + downloadUnknownSNRecord: "/accountManager/downloadUnknownSNRecord", + + // 获取SN号竞赛消息 + getSNContestMsg: "/accountManager/getSNContestMsg", + // 管理系统导出SN号竞赛消息 + downloadSNConest: "/accountManager/downloadSNConest", } \ No newline at end of file diff --git a/src/components/addNewData/SNForm/SNForm.vue b/src/components/addNewData/SNForm/SNForm.vue index 5c668c9..696ca70 100644 --- a/src/components/addNewData/SNForm/SNForm.vue +++ b/src/components/addNewData/SNForm/SNForm.vue @@ -132,7 +132,7 @@ const confirm = () => { const addSN = (requestMsg) => { requestMsg.forEach((element) => { - element.sn_number = encrypt(String(element.sn_number)); + element.sn_number = encrypt(String(element.sn_number).padStart(8, '0')); }); const data = { requestMsg }; $http.post($url.addSN, data).then((res) => { diff --git a/src/components/addNewData/SNForm/multipleAdd.vue b/src/components/addNewData/SNForm/multipleAdd.vue index 038e6a8..fb27a79 100644 --- a/src/components/addNewData/SNForm/multipleAdd.vue +++ b/src/components/addNewData/SNForm/multipleAdd.vue @@ -53,7 +53,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `SN号${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/SNForm/singleAdd.vue b/src/components/addNewData/SNForm/singleAdd.vue index 623e2fe..d9c68bc 100644 --- a/src/components/addNewData/SNForm/singleAdd.vue +++ b/src/components/addNewData/SNForm/singleAdd.vue @@ -12,7 +12,7 @@ { const rules = reactive({ sn_number: [ - { required: true, message: "请输入卡号", trigger: "blur" }, + { required: true, message: "请输入SN号", trigger: "blur" }, { validator: checkLength(8), trigger: "blur" }, ] }); diff --git a/src/components/addNewData/bsideForm/multipleAdd.vue b/src/components/addNewData/bsideForm/multipleAdd.vue index b95c786..f4b61a8 100644 --- a/src/components/addNewData/bsideForm/multipleAdd.vue +++ b/src/components/addNewData/bsideForm/multipleAdd.vue @@ -33,7 +33,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "账号1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -61,7 +61,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `账号${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/businessForm/multipleAdd.vue b/src/components/addNewData/businessForm/multipleAdd.vue index 55a783a..614b62d 100644 --- a/src/components/addNewData/businessForm/multipleAdd.vue +++ b/src/components/addNewData/businessForm/multipleAdd.vue @@ -38,7 +38,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "业务1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -68,7 +68,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `业务${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/contest/accountForm/multipleAdd.vue b/src/components/addNewData/contest/accountForm/multipleAdd.vue index b146151..2de36fc 100644 --- a/src/components/addNewData/contest/accountForm/multipleAdd.vue +++ b/src/components/addNewData/contest/accountForm/multipleAdd.vue @@ -33,7 +33,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "账号1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -53,7 +53,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `账号${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/contest/choiceTopicForm/multipleAdd.vue b/src/components/addNewData/contest/choiceTopicForm/multipleAdd.vue index 56890b7..94ec2d5 100644 --- a/src/components/addNewData/contest/choiceTopicForm/multipleAdd.vue +++ b/src/components/addNewData/contest/choiceTopicForm/multipleAdd.vue @@ -33,7 +33,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "题目1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -53,7 +53,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `题目${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/contest/contestForm/multipleAdd.vue b/src/components/addNewData/contest/contestForm/multipleAdd.vue index 523253b..eb89161 100644 --- a/src/components/addNewData/contest/contestForm/multipleAdd.vue +++ b/src/components/addNewData/contest/contestForm/multipleAdd.vue @@ -33,7 +33,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "竞赛1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -54,7 +54,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `竞赛${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/contest/tqxzContest/excleAdd.vue b/src/components/addNewData/contest/tqxzContest/excleAdd.vue new file mode 100644 index 0000000..933f7d5 --- /dev/null +++ b/src/components/addNewData/contest/tqxzContest/excleAdd.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/src/components/addNewData/contest/tqxzContest/multipleAdd.vue b/src/components/addNewData/contest/tqxzContest/multipleAdd.vue new file mode 100644 index 0000000..3a26489 --- /dev/null +++ b/src/components/addNewData/contest/tqxzContest/multipleAdd.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/src/components/addNewData/contest/tqxzContest/singleAdd.vue b/src/components/addNewData/contest/tqxzContest/singleAdd.vue new file mode 100644 index 0000000..07a0cdd --- /dev/null +++ b/src/components/addNewData/contest/tqxzContest/singleAdd.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/src/components/addNewData/contest/tqxzContest/snForm.vue b/src/components/addNewData/contest/tqxzContest/snForm.vue new file mode 100644 index 0000000..98c28ae --- /dev/null +++ b/src/components/addNewData/contest/tqxzContest/snForm.vue @@ -0,0 +1,206 @@ + + + + + diff --git a/src/components/addNewData/insidersForm/multipleAdd.vue b/src/components/addNewData/insidersForm/multipleAdd.vue index 441d580..0ad3966 100644 --- a/src/components/addNewData/insidersForm/multipleAdd.vue +++ b/src/components/addNewData/insidersForm/multipleAdd.vue @@ -33,7 +33,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "账号1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -56,7 +56,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `账号${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/addNewData/organizationForm/multipleAdd.vue b/src/components/addNewData/organizationForm/multipleAdd.vue index e940e34..18e8d9f 100644 --- a/src/components/addNewData/organizationForm/multipleAdd.vue +++ b/src/components/addNewData/organizationForm/multipleAdd.vue @@ -30,7 +30,7 @@ import SingleAdd from "./singleAdd.vue"; const singleFormNum = ref(1); const checked = ref(true); -const input = ref([{ label: "卡1" }]); +const input = ref([{ label: "单位1" }]); const singleAddRef = ref(null); const formClone = ref([]); @@ -51,7 +51,7 @@ const createForm = () => { let difference = Math.abs(singleFormNum.value - input.value.length); for (let i = 0; i < difference; i++) { if (singleFormNum.value > input.value.length) { - input.value.push({ label: `卡${input.value.length + 1}` }); + input.value.push({ label: `单位${input.value.length + 1}` }); } else if (singleFormNum.value < input.value.length) { input.value.pop(); } diff --git a/src/components/mainPage/SN.vue b/src/components/mainPage/SN.vue index ab534a0..df2516d 100644 --- a/src/components/mainPage/SN.vue +++ b/src/components/mainPage/SN.vue @@ -206,6 +206,11 @@ operateLabel="删除SN号" @requestOperate="requestOperate" /> + @@ -215,6 +220,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -235,6 +241,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const SNActive = SNActiveStore(); @@ -262,6 +269,7 @@ const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addSNFormRef = ref(null); +const downloadDataRef = ref(null); const editSNFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -355,6 +363,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; SNActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -523,6 +534,65 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "SN号", + "绑定状态", + "绑定用户", + "注册时间", + "绑定状态变更时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadSN, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ SNMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/SNAdmin.vue b/src/components/mainPage/SNAdmin.vue index d6a2c96..79daab9 100644 --- a/src/components/mainPage/SNAdmin.vue +++ b/src/components/mainPage/SNAdmin.vue @@ -26,7 +26,8 @@ :key="sn" type="info" class="sn-tag" - effect="dark" + :effect="mode ? 'dark' : SNArr.includes(sn) ? 'dark' : 'plain'" + @click="unLoadSN(sn)" > {{ sn }} @@ -52,9 +53,18 @@ @change="validateSNCount" /> - 确认绑定 + 确认{{ mode ? "绑定" : "解绑" }} + + + {{ mode ? "解绑" : "绑定" }}管理 + @@ -62,12 +72,12 @@
{ + selectedSNs.value = []; selectedUser.value = user; SNAdminActive.selectedUser = user; + snCount.value = userObj.value[user].length; + const sn_set = userObj.value[user].sn_set.split(","); + if (userObj.value[user].sn_set !== "" && sn_set.length !== 0) { + selectedSNs.value.push(...sn_set); + } }; const toggleSelectSN = (sn) => { - if (selectedSNs.value.includes(sn)) { - selectedSNs.value = selectedSNs.value.filter((s) => s !== sn); - SNAdminActive.selectedSNs = selectedSNs.value.filter((s) => s !== sn); - } else { - if (selectedSNs.value.length < snCount.value) { + if (mode.value) { + if (selectedSNs.value.includes(sn)) { + selectedSNs.value = selectedSNs.value.filter((s) => s !== sn); + SNAdminActive.selectedSNs = selectedSNs.value.filter((s) => s !== sn); + } else if (selectedSNs.value.length < snCount.value) { selectedSNs.value.push(sn); } else { ElMessage.warning("已达到可绑定的SN号数量上限!"); } + } else { + SNArr.value = SNArr.value.filter((s) => s !== sn); + } +}; + +const unLoadSN = (sn) => { + if (!mode.value) { + if (SNArr.value.includes(sn)) { + SNArr.value = SNArr.value.filter((s) => s !== sn); + } else { + SNArr.value.push(sn); + } } }; @@ -143,11 +172,12 @@ const validateSNCount = () => { if (snCount.value < 0) { snCount.value = 0; ElMessage.warning("SN号数量不能为负数!"); - } else { - if (selectedSNs.value.length > snCount.value) { - snCount.value = selectedSNs.value.length; - ElMessage.warning("已达到可绑定的SN号数量上限!"); - } + } else if (mode.value && selectedSNs.value.length > snCount.value) { + snCount.value = selectedSNs.value.length; + ElMessage.warning("已达到可绑定的SN号数量上限!"); + } else if (!mode.value && selectedSNs.value.length > snCount.value) { + snCount.value = Math.abs(selectedSNs.value.length - SNArr.value.length); + ElMessage.warning("已达到可绑定的SN号数量上限!"); } SNAdminActive.snCount = snCount.value; }; @@ -162,14 +192,21 @@ const resetCheckForm = () => { }; const searchAllocationUser = () => { - $http.get($url.searchAllocationUser).then((res) => { + const data = { + mode: mode.value, + }; + $http.post($url.searchAllocationUser, data).then((res) => { if (res.data.code === 200) { - res.data.userArr.forEach(element => { - unbindUsers.value.push(element.account_name); - userObj.value[element.account_name] = element.uid; + res.data.userArr.forEach((element) => { + usersArr.value.push(element.account_name); + userObj.value[element.account_name] = { + uid: element.uid, + length: element.length, + sn_set: element.sn_set, + }; }); } else { - unbindUsers.value = []; + usersArr.value = []; resetCheckForm(); // ElMessage.error("未查找到相关数据!"); } @@ -177,13 +214,13 @@ const searchAllocationUser = () => { }; const searchAllocationSN = () => { - $http.get($url.searchAllocationSN).then((res) => { + $http.post($url.searchAllocationSN).then((res) => { if (res.data.code === 200) { - res.data.snArr.forEach(element => { - unbindSN.value.push(element.sn_number); + res.data.snArr.forEach((element) => { + SNArr.value.push(element.sn_number); }); } else { - unbindSN.value = []; + SNArr.value = []; resetCheckForm(); // ElMessage.error("未查找到相关数据!"); } @@ -191,32 +228,49 @@ const searchAllocationSN = () => { }; const allocationSN = () => { - if (selectedUser.value === "" || selectedSNs.value.length === 0) { + if ( + selectedUser.value === "" || + (mode.value && selectedSNs.value.length === 0) || + (!mode.value && SNArr.value.length === 0) + ) { ElMessage.warning("请选择用户和SN号!"); return; } const data = { - user_uid: userObj.value[selectedUser.value], + user_uid: userObj.value[selectedUser.value].uid, length: snCount.value, - sn_set: selectedSNs.value.join(","), + sn_set: mode.value + ? selectedSNs.value.join(",") + : selectedSNs.value.filter((s) => !SNArr.value.includes(s)).join(","), }; $http.post($url.allocationSN, data).then((res) => { if (res.data.code === 200) { resetCheckForm(); - unbindUsers.value = []; - unbindSN.value = []; + usersArr.value = []; + SNArr.value = []; searchAllocationUser(); searchAllocationSN(); ElMessage({ - message: "绑定成功!", + message: mode.value ? "绑定成功!" : "解绑成功!", type: "success", }); } else { - ElMessage.error("绑定失败!"); + ElMessage.error(mode.value ? "绑定失败!" : "解绑失败!"); } }); }; +const switchMode = () => { + mode.value = !mode.value; + usersArr.value = []; + SNArr.value = []; + resetCheckForm(); + searchAllocationUser(); + if (mode.value) { + searchAllocationSN(); + } +}; + const setContentBlockHeight = async () => { await nextTick(); if (contentBlockRef.value) { diff --git a/src/components/mainPage/allocationSNRecord.vue b/src/components/mainPage/allocationSNRecord.vue index aeee5e4..87c08de 100644 --- a/src/components/mainPage/allocationSNRecord.vue +++ b/src/components/mainPage/allocationSNRecord.vue @@ -141,6 +141,11 @@ operateLabel="删除SN号分配记录" @requestOperate="requestOperate" /> +
@@ -154,6 +159,7 @@ import SearchKey from "../search/searchKey.vue"; import Pagination from "../search/pagination.vue"; import DataShow from "../operate/dataShow.vue"; import PasswordOauth from "../operate/passwordOauth.vue"; +import DownloadData from "../operate/downloadData.vue"; import allocationSNRecordActiveStore from "../../stores/allocationSNRecord"; @@ -163,6 +169,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const allocationSNRecordActive = allocationSNRecordActiveStore(); @@ -179,6 +186,7 @@ const SearchLengthKeyRef = ref(null); const SearchSNKeyRef = ref(null); const PaginationRef = ref(null); const DataShowRef = ref(null); +const downloadDataRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); const dialogSortVisible = ref(false); @@ -218,6 +226,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; allocationSNRecordActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -331,6 +342,64 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账户名", + "账户uid", + "可管理的SN号数量", + "SN号" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadAllocationSNRecord, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的
标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ bindSNRecordMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/bdCard.vue b/src/components/mainPage/bdCard.vue index 9d646fb..52c9a40 100644 --- a/src/components/mainPage/bdCard.vue +++ b/src/components/mainPage/bdCard.vue @@ -243,6 +243,11 @@ operateLabel="删除北斗卡" @requestOperate="requestOperate" /> +
@@ -252,6 +257,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -272,6 +278,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const bdCardMsgActive = bdCardActiveStore(); @@ -303,6 +310,7 @@ const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addBdCardFormRef = ref(null); +const downloadDataRef = ref(null); const editBdCardFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -417,6 +425,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; bdCardMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -588,6 +599,67 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "卡号", + "IMSI号", + "白名单类型", + "绑定状态", + "绑定用户", + "注册时间", + "绑定状态变更时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadBDCard, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ bdCardMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/bindRecord.vue b/src/components/mainPage/bindRecord.vue index 7b07639..7f6bcc6 100644 --- a/src/components/mainPage/bindRecord.vue +++ b/src/components/mainPage/bindRecord.vue @@ -180,6 +180,11 @@ operateLabel="删除北斗卡绑定记录" @requestOperate="requestOperate" /> + @@ -195,6 +200,7 @@ import SelectSearch from "../search/selectSearch.vue"; import DateTimePicker from "../search/dateTimePicker.vue"; import Pagination from "../search/pagination.vue"; import PasswordOauth from "../operate/passwordOauth.vue"; +import DownloadData from "../operate/downloadData.vue"; import bindRecordActiveStore from "../../stores/bindRecord"; @@ -206,6 +212,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const bindRecordMsgActive = bindRecordActiveStore(); @@ -224,6 +231,7 @@ const SelectTypeSearchRef = ref(null); const createdDateTimePickerRef = ref(null); const createdSortDateTimeRef = ref(null); const PaginationRef = ref(null); +const downloadDataRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); const dialogSortVisible = ref(false); @@ -306,6 +314,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; bindRecordMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -451,6 +462,66 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账户名", + "用户类型", + "账户uid", + "卡号", + "操作类型", + "记录时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadBindRecord, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ bindRecordMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/bindSNRecord.vue b/src/components/mainPage/bindSNRecord.vue index 0616403..ccd667a 100644 --- a/src/components/mainPage/bindSNRecord.vue +++ b/src/components/mainPage/bindSNRecord.vue @@ -180,6 +180,11 @@ operateLabel="删除SN号绑定记录" @requestOperate="requestOperate" /> + @@ -195,6 +200,7 @@ import SelectSearch from "../search/selectSearch.vue"; import DateTimePicker from "../search/dateTimePicker.vue"; import Pagination from "../search/pagination.vue"; import PasswordOauth from "../operate/passwordOauth.vue"; +import DownloadData from "../operate/downloadData.vue"; import bindSNRecordActiveStore from "../../stores/bindSNRecord"; @@ -206,6 +212,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const bindSNRecordMsgActive = bindSNRecordActiveStore(); @@ -224,6 +231,7 @@ const SelectTypeSearchRef = ref(null); const createdDateTimePickerRef = ref(null); const createdSortDateTimeRef = ref(null); const PaginationRef = ref(null); +const downloadDataRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); const dialogSortVisible = ref(false); @@ -309,6 +317,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; bindSNRecordMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -454,6 +465,66 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账户名", + "用户类型", + "账户uid", + "SN号", + "操作类型", + "记录时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadBindSNRecord, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ bindSNRecordMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/bside.vue b/src/components/mainPage/bside.vue index 7cc8ea3..f1067b8 100644 --- a/src/components/mainPage/bside.vue +++ b/src/components/mainPage/bside.vue @@ -325,6 +325,11 @@ operateLabel="删除B端用户" @requestOperate="requestOperate" /> + @@ -334,6 +339,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -354,6 +360,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const bsideMsgActive = bsideActiveStore(); @@ -388,6 +395,7 @@ const updatedSortDateTimeRef = ref(null); const loginSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addBsideFormRef = ref(null); +const downloadDataRef = ref(null); const editBsideFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -506,6 +514,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; bsideMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -742,6 +753,71 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账号状态", + "账号角色", + "账号名称", + "单位名称", + "用户姓名", + "手机号码", + "基本信息", + "注册时间", + "账号状态变更时间", + "上次登录时间", + "登录状态" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadBside, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ bsideMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/business.vue b/src/components/mainPage/business.vue index fd6f176..59facd0 100644 --- a/src/components/mainPage/business.vue +++ b/src/components/mainPage/business.vue @@ -335,6 +335,11 @@ operateLabel="删除公司业务" @requestOperate="requestOperate" /> + @@ -344,6 +349,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -364,6 +370,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const businessMsgActive = businessActiveStore(); @@ -397,6 +404,7 @@ const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addBusinessFormRef = ref(null); +const downloadDataRef = ref(null); const editBusinessFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -528,6 +536,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; businessMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -749,6 +760,72 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "随机盐值", + "业务登录网址", + "业务网址", + "业务临时标识", + "业务ID", + "业务密钥", + "业务名称", + "业务类型", + "业务等级", + "业务状态", + "业务开通时间", + "业务变更时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadBusiness, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ businessMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/contest/account.vue b/src/components/mainPage/contest/account.vue index 812e83a..fec7500 100644 --- a/src/components/mainPage/contest/account.vue +++ b/src/components/mainPage/contest/account.vue @@ -231,6 +231,11 @@ operateLabel="重置账号密码" @requestOperate="resetAccount" /> + @@ -240,6 +245,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../../operate/tabelTools.vue"; import AddNewData from "../../operate/addNewData.vue"; +import DownloadData from "../../operate/downloadData.vue"; import TabelSelect from "../../operate/tabelSelect.vue"; import SearchKey from "../../search/searchKey.vue"; import SortSearch from "../../search/sortSearch.vue"; @@ -260,6 +266,7 @@ import $url from "../../../api/url"; import { encrypt } from "../../../utils/aes"; import { judgment } from "../../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../../utils/downloadData.js"; const accountMsgActive = accountActiveStore(); @@ -287,6 +294,7 @@ const SelectLoginStatusSearchRef = ref(null); const createdSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addAccountFormRef = ref(null); +const downloadDataRef = ref(null); const editAccountFormRef = ref(null); const delPasswordOauthRef = ref(null); const resetPasswordOauthRef = ref(null); @@ -394,6 +402,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; accountMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -586,6 +597,66 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账号uid", + "竞赛uid", + "账号名称", + "账号状态", + "注册时间", + "登录状态" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadAccount, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ accountMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/contest/choiceTopic.vue b/src/components/mainPage/contest/choiceTopic.vue index 6601f96..89a9cfe 100644 --- a/src/components/mainPage/contest/choiceTopic.vue +++ b/src/components/mainPage/contest/choiceTopic.vue @@ -200,6 +200,11 @@ operateLabel="删除单选题" @requestOperate="requestOperate" /> + @@ -209,6 +214,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../../operate/tabelTools.vue"; import AddNewData from "../../operate/addNewData.vue"; +import DownloadData from "../../operate/downloadData.vue"; import TabelSelect from "../../operate/tabelSelect.vue"; import SearchKey from "../../search/searchKey.vue"; import Pagination from "../../search/pagination.vue"; @@ -226,6 +232,7 @@ import $url from "../../../api/url"; import { encrypt } from "../../../utils/aes"; import { judgment } from "../../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../../utils/downloadData.js"; const choiceTopicMsgActive = choiceTopicActiveStore(); @@ -252,6 +259,7 @@ const SearchOptionsDKeyRef = ref(null); const SearchAnswerKeyRef = ref(null); const PaginationRef = ref(null); const addChoiceTopicFormRef = ref(null); +const downloadDataRef = ref(null); const editChoiceTopicFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -314,6 +322,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; choiceTopicMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -481,6 +492,66 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "题目", + "选项A", + "选项B", + "选项C", + "选项D", + "答案" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadChoiceTopic, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ choiceTopicMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/contest/contest.vue b/src/components/mainPage/contest/contest.vue index 3f423ed..e524b58 100644 --- a/src/components/mainPage/contest/contest.vue +++ b/src/components/mainPage/contest/contest.vue @@ -380,6 +380,11 @@ operateLabel="删除竞赛" @requestOperate="requestOperate" /> + @@ -389,6 +394,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../../operate/tabelTools.vue"; import AddNewData from "../../operate/addNewData.vue"; +import DownloadData from "../../operate/downloadData.vue"; import TabelSelect from "../../operate/tabelSelect.vue"; import SearchKey from "../../search/searchKey.vue"; import SortSearch from "../../search/sortSearch.vue"; @@ -409,6 +415,7 @@ import $url from "../../../api/url"; import { encrypt } from "../../../utils/aes"; import { judgment } from "../../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../../utils/downloadData.js"; const contestMsgActive = contestActiveStore(); @@ -449,6 +456,7 @@ const contestEndSortDateTimeRef = ref(null); const createdSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addContestFormRef = ref(null); +const downloadDataRef = ref(null); const editContestFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -571,6 +579,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; contestMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -829,6 +840,73 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "竞赛uid", + "竞赛名称", + "竞赛主办方", + "竞赛届数", + "竞赛类型", + "举办状态", + "线上赛开始时间", + "线上赛结束时间", + "线下赛开始时间", + "线下赛结束时间", + "竞赛开始时间", + "竞赛结束时间", + "创建时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadContest, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ contestMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/contest/examination.vue b/src/components/mainPage/contest/examination.vue index dfd31e7..8a7c2aa 100644 --- a/src/components/mainPage/contest/examination.vue +++ b/src/components/mainPage/contest/examination.vue @@ -234,6 +234,11 @@ operateLabel="删除答题信息" @requestOperate="requestOperate" /> + @@ -243,6 +248,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../../operate/tabelTools.vue"; import AddNewData from "../../operate/addNewData.vue"; +import DownloadData from "../../operate/downloadData.vue"; import TabelSelect from "../../operate/tabelSelect.vue"; import SearchKey from "../../search/searchKey.vue"; import SortSearch from "../../search/sortSearch.vue"; @@ -262,6 +268,7 @@ import $url from "../../../api/url"; import { encrypt } from "../../../utils/aes"; import { judgment } from "../../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../../utils/downloadData.js"; const examinationMsgActive = examinationActiveStore(); @@ -291,6 +298,7 @@ const SortScoreRef = ref(null); const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const PaginationRef = ref(null); +const downloadDataRef = ref(null); const editExaminationFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -401,6 +409,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; examinationMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -572,6 +583,67 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账号uid", + "竞赛uid", + "竞赛类型", + "题目类型", + "得分", + "开始答题时间", + "结束答题时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadExamination, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ examinationMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/contest/tqxzContest/snContestMsg.vue b/src/components/mainPage/contest/tqxzContest/snContestMsg.vue new file mode 100644 index 0000000..bbbf428 --- /dev/null +++ b/src/components/mainPage/contest/tqxzContest/snContestMsg.vue @@ -0,0 +1,451 @@ + + + + + diff --git a/src/components/mainPage/cside.vue b/src/components/mainPage/cside.vue index 7d9c5d8..6d42fc6 100644 --- a/src/components/mainPage/cside.vue +++ b/src/components/mainPage/cside.vue @@ -383,6 +383,11 @@ operateLabel="删除C端用户" @requestOperate="requestOperate" /> + @@ -399,6 +404,7 @@ import DateTimePicker from "../search/dateTimePicker.vue"; import Pagination from "../search/pagination.vue"; import EditCsideForm from "../editData/csideForm.vue"; import PasswordOauth from "../operate/passwordOauth.vue"; +import DownloadData from "../operate/downloadData.vue"; import csideActiveStore from "../../stores/cside"; @@ -410,6 +416,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const csideMsgActive = csideActiveStore(); @@ -447,6 +454,7 @@ const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const loginSortDateTimeRef = ref(null); const PaginationRef = ref(null); +const downloadDataRef = ref(null); const editCsideFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -574,6 +582,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; csideMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -769,6 +780,74 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "账号状态", + "账号角色", + "账号名称", + "用户姓名", + "手机号码", + "性别", + "年龄", + "电子邮箱", + "通信地址", + "邮政编码", + "注册时间", + "账号信息变更时间", + "上次登录时间", + "登录状态" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadCside, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ csideMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/insiders.vue b/src/components/mainPage/insiders.vue index 026e12e..b81c98d 100644 --- a/src/components/mainPage/insiders.vue +++ b/src/components/mainPage/insiders.vue @@ -301,6 +301,11 @@ operateLabel="删除公司员工" @requestOperate="requestOperate" /> + @@ -310,6 +315,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -330,6 +336,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const insidersMsgActive = insidersActiveStore(); @@ -363,6 +370,7 @@ const updatedSortDateTimeRef = ref(null); const loginSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addInsidersFormRef = ref(null); +const downloadDataRef = ref(null); const editInsidersFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -490,6 +498,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; insidersMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -679,6 +690,70 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "员工uid", + "账号状态", + "账号角色", + "员工姓名", + "所属部门", + "信息变更描述", + "注册时间", + "信息变更时间", + "上次登录时间", + "登录状态" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadInsiders, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ insidersMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/monitoring.vue b/src/components/mainPage/monitoring.vue index ea5f2a1..875bc69 100644 --- a/src/components/mainPage/monitoring.vue +++ b/src/components/mainPage/monitoring.vue @@ -216,6 +216,11 @@ operateLabel="删除系统记录" @requestOperate="requestOperate" /> + @@ -231,6 +236,7 @@ import SelectSearch from "../search/selectSearch.vue"; import DateTimePicker from "../search/dateTimePicker.vue"; import Pagination from "../search/pagination.vue"; import PasswordOauth from "../operate/passwordOauth.vue"; +import DownloadData from "../operate/downloadData.vue"; import monitoringActiveStore from "../../stores/monitoring"; @@ -242,6 +248,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const monitoringMsgActive = monitoringActiveStore(); @@ -261,6 +268,7 @@ const SearchNameKeyRef = ref(null); const createdDateTimePickerRef = ref(null); const createdSortDateTimeRef = ref(null); const PaginationRef = ref(null); +const downloadDataRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); const dialogSortVisible = ref(false); @@ -386,6 +394,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; monitoringMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -532,6 +543,68 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "操作名称", + "操作描述", + "危险等级", + "执行状态", + "影响到的数据数目", + "操作者uid", + "操作者姓名", + "行为记录时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadMonitoring, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ monitoringMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/organization.vue b/src/components/mainPage/organization.vue index 0ed30f5..2a4ce2b 100644 --- a/src/components/mainPage/organization.vue +++ b/src/components/mainPage/organization.vue @@ -282,6 +282,11 @@ operateLabel="删除用户单位" @requestOperate="requestOperate" /> + @@ -291,6 +296,7 @@ import { ElMessage } from "element-plus"; import TabelTools from "../operate/tabelTools.vue"; import AddNewData from "../operate/addNewData.vue"; +import DownloadData from "../operate/downloadData.vue"; import TabelSelect from "../operate/tabelSelect.vue"; import SearchKey from "../search/searchKey.vue"; import SortSearch from "../search/sortSearch.vue"; @@ -310,6 +316,7 @@ import $url from "../../api/url"; import { encrypt } from "../../utils/aes"; import { judgment } from "../../utils/judgment.js"; import { hasNullOrEmptyPropertyWithTypeof } from "../../utils/hasNullOrEmptyPropertyWithTypeof.js"; +import { downloadData } from "../../utils/downloadData.js"; const organizationMsgActive = organizationActiveStore(); @@ -342,6 +349,7 @@ const createdSortDateTimeRef = ref(null); const updatedSortDateTimeRef = ref(null); const PaginationRef = ref(null); const addOrganizationFormRef = ref(null); +const downloadDataRef = ref(null); const editOrganizationFormRef = ref(null); const delPasswordOauthRef = ref(null); const dialogSearchVisible = ref(false); @@ -390,6 +398,9 @@ const showTools = (operateType) => { dialogOperationVisible.value = !dialogOperationVisible.value; organizationMsgActive.dialogOperationVisible = dialogOperationVisible.value; break; + case "downloadData": + downloadDataRef.value.downloadDataDialogVisible = true; + break; default: break; } @@ -574,6 +585,70 @@ const requestOperate = () => { }); }; +const executeDownloadData = (form) => { + // 根据数据量大小来决定在前端还是后端导出数据 + if ( + tableData.value == [] || + tableData.value == undefined || + PaginationRef.value.dataCount == 0 || + PaginationRef.value.dataCount == null + ) { + ElMessage.error("暂无数据!"); + return; + } + let dataClone = JSON.parse(JSON.stringify(tableData.value)); + dataClone.forEach((item) => { + delete item.origin_time; + }); + const dataHeaders = [ + "单位uid", + "单位名称", + "通信地址", + "联系人姓名", + "联系人电话", + "单位邮箱", + "其他信息", + "邮政编码", + "添加时间", + "上次信息变更时间" + ]; + downloadData(form, dataClone, dataHeaders); + if (PaginationRef.value.dataCount <= PaginationRef.value.limit) { + downloadData(form, dataClone, dataHeaders); + } else { + const data = { + form, + searchMsg: { + searchOptions: searchOptions, + sortOptions: sortOptions, + }, + dataHeaders, + }; + $http.post($url.downloadOrganization, data).then((res) => { + if (res.data.code === 200) { + ElMessage({ + message: "数据导出成功!", + type: "success", + }); + // 创建一个隐藏的标签 + const link = document.createElement("a"); + link.style.display = "none"; + link.href = res.data.fileUrl; + // 设置下载的文件名 + link.download = res.data.fileName; + // 触发点击事件来下载文件 + document.body.appendChild(link); + link.click(); + // 清理 + document.body.removeChild(link); + URL.revokeObjectURL(link.href); + } else { + ElMessage.error("数据导出失败!"); + } + }); + } +}; + defineExpose({ organizationMsg }); watch(searchOptions, (value) => { diff --git a/src/components/mainPage/unknownBDCard.vue b/src/components/mainPage/unknownBDCard.vue new file mode 100644 index 0000000..f1c0bf2 --- /dev/null +++ b/src/components/mainPage/unknownBDCard.vue @@ -0,0 +1,478 @@ + + + + + diff --git a/src/components/mainPage/unknownSN.vue b/src/components/mainPage/unknownSN.vue new file mode 100644 index 0000000..3c7ecef --- /dev/null +++ b/src/components/mainPage/unknownSN.vue @@ -0,0 +1,503 @@ + + + + + diff --git a/src/components/operate/downloadData.vue b/src/components/operate/downloadData.vue new file mode 100644 index 0000000..a1b0dd8 --- /dev/null +++ b/src/components/operate/downloadData.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/src/components/operate/tabelTools.vue b/src/components/operate/tabelTools.vue index 606e513..1c1e4aa 100644 --- a/src/components/operate/tabelTools.vue +++ b/src/components/operate/tabelTools.vue @@ -36,6 +36,18 @@ + + + 导出数据 + + @@ -74,6 +86,9 @@ const showTools = (operateType) => { emit("showTools", "operation"); showOperation.value = !showOperation.value; break; + case "downloadData": + emit("showTools", "downloadData"); + break; default: break; } diff --git a/src/router/index.js b/src/router/index.js index cee21e6..6e6431a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -62,6 +62,12 @@ const router = createRouter({ meta: { label: "北斗卡绑定记录" }, component: () => import('../components/mainPage/bindRecord.vue') }, + { + path: "unknownBDCard", + name: "unknownBDCard", + meta: { label: "未知北斗短报文记录" }, + component: () => import('../components/mainPage/unknownBDCard.vue') + }, { path: "SNData", name: "SNData", @@ -80,6 +86,12 @@ const router = createRouter({ meta: { label: "SN号绑定记录" }, component: () => import('../components/mainPage/bindSNRecord.vue') }, + { + path: "unknownSN", + name: "unknownSN", + meta: { label: "未知天启消息记录" }, + component: () => import('../components/mainPage/unknownSN.vue') + }, ] }, { @@ -178,6 +190,12 @@ const router = createRouter({ name: "contestGrades", meta: { label: "竞赛成绩管理" }, component: () => import('../components/mainPage/contest/examination.vue') + }, + { + path: "snContestMsg", + name: "snContestMsg", + meta: { label: "SN号竞赛消息" }, + component: () => import('../components/mainPage/contest/tqxzContest/snContestMsg.vue') } ] }, diff --git a/src/stores/contest/tqxzContest/snContestMsg.js b/src/stores/contest/tqxzContest/snContestMsg.js new file mode 100644 index 0000000..f86c93e --- /dev/null +++ b/src/stores/contest/tqxzContest/snContestMsg.js @@ -0,0 +1,45 @@ +import { defineStore } from 'pinia'; +import { parse, stringify } from 'zipson'; + +const snContestMsgActiveStore = defineStore('snContestMsg', { + state: () => ({ + // 持久化数据 + activeIndex: "1", + subActiveIndex: "1", + SNArr: "", + time_at: "", + offset: 1, + limit: 10, + dataCount: 0, + pageCount: 0, + searchOptions: { + sn_number: "", + original_msg: "", + msg_data: "", + created_at: "", + }, + sortOptions: { + sn_number: false, + created_at: false, + }, + dialogSearchVisible: false, + dialogSortVisible: false, + dialogOperationVisible: false + }), + persist: { + enabled: true, // Store 中数据持久化生效 + strategies: [ + { + key: 'snContestMsgActive', // 存储的 key + storage: localStorage, // 存储位置 + paths: ["activeIndex", "subActiveIndex", "SNArr", "time_at", "offset", "limit", "dataCount", "pageCount", "searchOptions", "sortOptions", "dialogSearchVisible", "dialogSortVisible", "dialogOperationVisible"], // 需要持久化的字段 + serializer: { + deserialize: parse, + serialize: stringify, + }, + } + ] + }, +}); + +export default snContestMsgActiveStore; \ No newline at end of file diff --git a/src/stores/unknownBDCardRecord.js b/src/stores/unknownBDCardRecord.js new file mode 100644 index 0000000..5f2eb59 --- /dev/null +++ b/src/stores/unknownBDCardRecord.js @@ -0,0 +1,43 @@ +import { defineStore } from 'pinia'; +import { parse, stringify } from 'zipson'; + +const unknownBDCardRecordActiveStore = defineStore('unknownBDCardRecord', { + state: () => ({ + // 持久化数据 + activeIndex: "1", + offset: 1, + limit: 10, + dataCount: 0, + pageCount: 0, + searchOptions: { + original_msg: "", + msg_data: "", + created_at: "", + }, + sortOptions: { + created_at: false, + }, + dialogSearchVisible: false, + dialogSortVisible: false, + dialogOperationVisible: false, + dialogSingleVisible: true, + dialogMultipleVisible: false, + dialogExcleVisible: false, + }), + persist: { + enabled: true, // Store 中数据持久化生效 + strategies: [ + { + key: 'unknownBDCardRecordActiveStore', // 存储的 key + storage: localStorage, // 存储位置 + paths: ["activeIndex", "offset", "limit", "dataCount", "pageCount", "searchOptions", "sortOptions", "dialogSearchVisible", "dialogSortVisible", "dialogOperationVisible"], // 需要持久化的字段 + serializer: { + deserialize: parse, + serialize: stringify, + }, + } + ] + }, +}); + +export default unknownBDCardRecordActiveStore; \ No newline at end of file diff --git a/src/stores/unknownSNRecord.js b/src/stores/unknownSNRecord.js new file mode 100644 index 0000000..7c910ee --- /dev/null +++ b/src/stores/unknownSNRecord.js @@ -0,0 +1,43 @@ +import { defineStore } from 'pinia'; +import { parse, stringify } from 'zipson'; + +const unknownSNRecordActiveStore = defineStore('unknownSNRecord', { + state: () => ({ + // 持久化数据 + activeIndex: "1", + offset: 1, + limit: 10, + dataCount: 0, + pageCount: 0, + searchOptions: { + original_msg: "", + msg_data: "", + created_at: "", + }, + sortOptions: { + created_at: false, + }, + dialogSearchVisible: false, + dialogSortVisible: false, + dialogOperationVisible: false, + dialogSingleVisible: true, + dialogMultipleVisible: false, + dialogExcleVisible: false, + }), + persist: { + enabled: true, // Store 中数据持久化生效 + strategies: [ + { + key: 'unknownSNRecordActiveStore', // 存储的 key + storage: localStorage, // 存储位置 + paths: ["activeIndex", "offset", "limit", "dataCount", "pageCount", "searchOptions", "sortOptions", "dialogSearchVisible", "dialogSortVisible", "dialogOperationVisible"], // 需要持久化的字段 + serializer: { + deserialize: parse, + serialize: stringify, + }, + } + ] + }, +}); + +export default unknownSNRecordActiveStore; \ No newline at end of file diff --git a/src/utils/downloadData.js b/src/utils/downloadData.js new file mode 100644 index 0000000..6211cb4 --- /dev/null +++ b/src/utils/downloadData.js @@ -0,0 +1,21 @@ +import * as XLSX from 'xlsx'; + +export const downloadData = (form, data, dataHeaders) => { + const { sheetName, fileName, extensionType } = form; + let extensionName = ['.xlsx', '.xls', '.csv']; + // 将数据转换为工作表 + const ws = XLSX.utils.json_to_sheet(data); + + // 动态设置表头 + dataHeaders.forEach((header, index) => { + const cellRef = XLSX.utils.encode_cell({ r: 0, c: index }); // 生成单元格引用,如A1, B1等 + ws[cellRef] = { v: header, t: "s" }; // 设置单元格的值和类型 + }); + + // 创建一个新的工作簿并添加工作表 + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, sheetName); + + // 生成 Excel 文件并下载 + XLSX.writeFile(wb, fileName + extensionName[extensionType]); // 这里可以自定义文件名和扩展名}; +} \ No newline at end of file diff --git a/src/views/header/Contest.vue b/src/views/header/Contest.vue index 03af6e2..580ec5a 100644 --- a/src/views/header/Contest.vue +++ b/src/views/header/Contest.vue @@ -25,6 +25,7 @@ const menu = [ { label: "竞赛信息管理", path: "contestMsg", id: 2 }, { label: "竞赛账号管理", path: "contestAccount", id: 3 }, { label: "竞赛成绩管理", path: "contestGrades", id: 4 }, + { label: "SN号竞赛消息", path: "snContestMsg", id: 5 }, ]; onMounted(() => { diff --git a/src/views/header/Workspace.vue b/src/views/header/Workspace.vue index a966d1b..7937c43 100644 --- a/src/views/header/Workspace.vue +++ b/src/views/header/Workspace.vue @@ -23,9 +23,11 @@ const menu = [ { label: "北斗卡数据统计", path: "bdCardData", id: 0 }, { label: "北斗卡管理", path: "bdCard", id: 1 }, { label: "北斗卡绑定记录", path: "bindRecord", id: 2 }, - { label: "SN号数据统计", path: "SNData", id: 3 }, - { label: "SN号管理", path: "SN", id: 4 }, - { label: "SN号绑定记录", path: "bindSNRecord", id: 5 }, + { label: "未知北斗短报文消息记录", path: "unknownBDCard", id: 3 }, + { label: "SN号数据统计", path: "SNData", id: 4 }, + { label: "SN号管理", path: "SN", id: 5 }, + { label: "SN号绑定记录", path: "bindSNRecord", id: 6 }, + { label: "未知天启消息记录", path: "unknownSN", id: 7 }, ]; onMounted(() => {