diff --git a/client/dist/index.html b/client/dist/index.html index 9772179..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..9a083d5 100644 --- a/client/src/store/modules/user.js +++ b/client/src/store/modules/user.js @@ -116,8 +116,9 @@ const actions = { if (!perms || perms.length <= 0) { 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){ + 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); }else{ 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/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 @@
超期报告/证书
- 无记录 + 无记录 导入 导出 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; + }); + }, }, };