From eceaba0ba7f9c836b0e50529bfd7eb1268501619 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 20 Oct 2023 15:14:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/dist/index.html | 2 +- client/src/utils/exportExcel.js | 45 +++++++++++++++++++++++++++ client/src/views/login/index.vue | 2 +- client/src/views/system/user.vue | 52 +++++++++++++++++++++++++++++--- 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 client/src/utils/exportExcel.js diff --git a/client/dist/index.html b/client/dist/index.html index 9772179..3c4dacb 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -1 +1 @@ -vue Admin Template
\ No newline at end of file +vue Admin Template
\ No newline at end of file diff --git a/client/src/utils/exportExcel.js b/client/src/utils/exportExcel.js new file mode 100644 index 0000000..dcf69fc --- /dev/null +++ b/client/src/utils/exportExcel.js @@ -0,0 +1,45 @@ +import * as XLSX from 'xlsx'; +/** + * eg: .columns = [ + * { header: 'Id', key: 'id', wpx: 10 }, + * { header: 'Name', key: 'name', wch: 32 }, + * { header: 'D.O.B.', key: 'dob', width: 10, hidden: true } + * ] + * data: [{id: 1, name: 'John Doe', dob: new Date(1970,1,1)}] + * @param columns 定义列属性数组 + * @param data 数据 + * @param name 文件名 + */ +export const generateExcel = (columns = [], data = [], name = '') => { + const headers = columns.map((item) => item.header); + // https://docs.sheetjs.com/docs/csf/features/#row-and-column-properties + const otherConfigs = columns.map(({ key, header, ...item }) => item); + const dataList = data.map((item) => { + let obj = {}; + columns.forEach((col) => { + obj[col.header] = item[col.key]; + }); + return obj; + }); + const workbook = XLSX.utils.book_new(); + workbook.SheetNames.push(name); + const worksheet = XLSX.utils.json_to_sheet(dataList, { + header: headers, + }); + worksheet['!cols'] = otherConfigs; + workbook.Sheets[name] = worksheet; + // 生成Blob数据 + const excelData = XLSX.write(workbook, { type: 'array', bookType: 'xlsx' }); + const blobData = new Blob([excelData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); + // 创建Blob URL + const blobUrl = URL.createObjectURL(blobData); + // 创建一个隐藏的标签并设置href属性为Blob URL + const link = document.createElement('a'); + link.href = blobUrl; + link.target = '_blank'; + link.download = `${name}.xlsx`; + // 触发点击操作,开始下载文件 + link.click(); + // 释放Blob URL + URL.revokeObjectURL(blobUrl); +}; \ No newline at end of file diff --git a/client/src/views/login/index.vue b/client/src/views/login/index.vue index af952a6..571de2b 100644 --- a/client/src/views/login/index.vue +++ b/client/src/views/login/index.vue @@ -229,7 +229,7 @@ export default { getTimer() { const TIME_COUNT = 60; if (!this.timer) { - this.count = TIME_COUNT; + this.count = COUNT; this.disabled = true; this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { diff --git a/client/src/views/system/user.vue b/client/src/views/system/user.vue index b0cbab5..72e6c12 100644 --- a/client/src/views/system/user.vue +++ b/client/src/views/system/user.vue @@ -68,16 +68,22 @@ type="primary" icon="el-icon-search" @click="handleFilter" - >搜索 + >搜索 重置 + >重置 + 导出
{}); }); }, + //导出 + exportExcel(){ + let that = this; + this.listLoading = true; + //获取全部人员数据 + let promises = [1,2, 3, 4].map(function (page) { + return getUserList({page:page,page_size:500}).then((res)=>{return res.data.results}) + }); + Promise.all(promises).then(function (posts) { + let data = JSON.parse(JSON.stringify(posts)) + let list = [...data[0], ...data[1],...data[2], ...data[3]]; + let exportData = []; + for(let i=0;i{ + return item.name; + }) + obj.roles=roles.toString(); + exportData.push(obj) + } + generateExcel(that.columns,exportData,'账号清单'); + that.listLoading = false; + }).catch(function(reason){ + console.log('出错了',reason) + that.listLoading = false; + }); + }, }, }; From e62a7368859293c806a411b76dfa100f9bfa0806 Mon Sep 17 00:00:00 2001 From: shijing Date: Fri, 20 Oct 2023 15:39:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=83=A8=E9=97=A8=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/dist/index.html | 2 +- client/src/store/modules/user.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/dist/index.html b/client/dist/index.html index 3c4dacb..2ea54b6 100644 --- a/client/dist/index.html +++ b/client/dist/index.html @@ -1 +1 @@ -vue Admin Template
\ No newline at end of file +vue Admin Template
\ No newline at end of file diff --git a/client/src/store/modules/user.js b/client/src/store/modules/user.js index 8766130..32e0b6c 100644 --- a/client/src/store/modules/user.js +++ b/client/src/store/modules/user.js @@ -117,7 +117,7 @@ const actions = { reject('没有任何权限!') }else{ if(dept==5||dept==33||dept==34||dept==55||dept==36||dept==37||dept==38 - ||dept==39||dept==40||dept==41||dept==42||dept==67||dept==97){ + ||dept==39||dept==40||dept==41||dept==42||dept==67||dept==97||dept==100){ perms.push('test') commit('SET_PERMS', perms); }else{ From ab7f69c418d0429121086f0f01280c3ca8ed9d4b Mon Sep 17 00:00:00 2001 From: shijing Date: Tue, 31 Oct 2023 10:34:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E5=A4=8D=EF=BC=8C?= =?UTF-8?q?=E6=80=BB=E9=83=A8=E6=96=87=E4=BB=B6=E6=9D=83=E9=99=90=E6=94=B9?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/store/modules/user.js | 3 ++- client/src/views/login/index.vue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/store/modules/user.js b/client/src/store/modules/user.js index 32e0b6c..9a083d5 100644 --- a/client/src/store/modules/user.js +++ b/client/src/store/modules/user.js @@ -116,7 +116,8 @@ const actions = { if (!perms || perms.length <= 0) { reject('没有任何权限!') }else{ - if(dept==5||dept==33||dept==34||dept==55||dept==36||dept==37||dept==38 + debugger; + if(dept==5||dept==35||dept==33||dept==34||dept==55||dept==36||dept==37||dept==38 ||dept==39||dept==40||dept==41||dept==42||dept==67||dept==97||dept==100){ perms.push('test') commit('SET_PERMS', perms); diff --git a/client/src/views/login/index.vue b/client/src/views/login/index.vue index 571de2b..af952a6 100644 --- a/client/src/views/login/index.vue +++ b/client/src/views/login/index.vue @@ -229,7 +229,7 @@ export default { getTimer() { const TIME_COUNT = 60; if (!this.timer) { - this.count = COUNT; + this.count = TIME_COUNT; this.disabled = true; this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { From 501249ad030f598dd8dcc2af540126caebc63981 Mon Sep 17 00:00:00 2001 From: shijing Date: Wed, 1 Nov 2023 15:33:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=97=A0=E8=AE=B0=E5=BD=95=E6=8C=89?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/views/supervisionNew/mytask.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/views/supervisionNew/mytask.vue b/client/src/views/supervisionNew/mytask.vue index 70df6c4..cf9b91e 100644 --- a/client/src/views/supervisionNew/mytask.vue +++ b/client/src/views/supervisionNew/mytask.vue @@ -374,7 +374,7 @@
超期报告/证书
- 无记录 + 无记录 导入 导出