From c292e4e3ac3fdb20b67b4120ddf6e5515b413e76 Mon Sep 17 00:00:00 2001 From: fengachen <373943794@qq.com> Date: Wed, 25 Aug 2021 11:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=AE=A1=E7=90=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api.js | 5 +- src/mixins/JeroListMixin.js | 155 +++++++++++-------- src/views/system/RoleUserList.vue | 2 +- src/views/system/UserList.vue | 87 +++++++++++ src/views/system/modules/PermissionModal.vue | 4 +- src/views/system/modules/RoleModal.vue | 1 - src/views/system/modules/UserModal.vue | 55 ++++++- 7 files changed, 241 insertions(+), 68 deletions(-) diff --git a/src/api/api.js b/src/api/api.js index cd96141..2e72802 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -18,6 +18,8 @@ const frozenBatch = (params)=>putAction("/sys/user/frozenBatch",params); const checkOnlyUser = (params)=>getAction("/sys/user/checkOnlyUser",params); //改变密码 const changePassword = (params)=>putAction("/sys/user/changePassword",params); +// 重置密码 +const resetUserPassword = (params) => putAction('',params) //权限管理 const addPermission= (params)=>postAction("/sys/permission/add",params); @@ -153,7 +155,8 @@ export { saveDeptRolePermission, queryMyDepartTreeList, getUserNoticeInfo, - getDictItemsFromCache + getDictItemsFromCache, + resetUserPassword } diff --git a/src/mixins/JeroListMixin.js b/src/mixins/JeroListMixin.js index 96fea77..93553e1 100644 --- a/src/mixins/JeroListMixin.js +++ b/src/mixins/JeroListMixin.js @@ -3,25 +3,25 @@ * 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 */ -import { filterObj } from '@/utils/util'; -import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage' +import {filterObj} from '@/utils/util'; +import {deleteAction, getAction, downFile, getFileAccessHttpUrl} from '@/api/manage' import Vue from 'vue' -import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" +import {ACCESS_TOKEN, TENANT_ID} from "@/store/mutation-types" import store from '@/store' import {Modal} from 'ant-design-vue' -import { deleteByDepartId } from "@api/api"; +import {deleteByDepartId} from "@api/api"; export const JeroListMixin = { - data(){ + data() { return { /* 查询条件-请不要在queryParam中声明非字符串值的属性 */ queryParam: {}, // 记录上一次查询的条件,防止查询处输入框的数据发生变化,未点击查询按钮,再点击分页的时候数据发生变化 lastQueryParam: {}, /* 数据源 */ - dataSource:[], + dataSource: [], /* 分页参数 */ - ipagination:{ + ipagination: { current: 1, pageSize: 10, pageSizeOptions: ['10', '20', '30', '50'], @@ -33,22 +33,22 @@ export const JeroListMixin = { total: 0 }, /* 排序参数 */ - isorter:{ + isorter: { column: 'createTime', order: 'desc', }, /* 筛选参数 */ filters: {}, /* table加载状态 */ - loading:false, + loading: false, /* table选中keys*/ selectedRowKeys: [], /* table选中records*/ selectionRows: [], /* 查询折叠 */ - toggleSearchStatus:false, + toggleSearchStatus: false, /* 高级查询条件生效状态 */ - superQueryFlag:false, + superQueryFlag: false, /* 高级查询条件 */ superQueryParams: '', /** 高级查询拼接方式 */ @@ -56,26 +56,26 @@ export const JeroListMixin = { } }, created() { - if(!this.disableMixinCreated){ - this.loadData(); - //初始化字典配置 在自己页面定义 - this.initDictConfig(); - } + if (!this.disableMixinCreated) { + this.loadData(); + //初始化字典配置 在自己页面定义 + this.initDictConfig(); + } }, computed: { //token header - tokenHeader(){ + tokenHeader() { let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} let tenantid = Vue.ls.get(TENANT_ID) - if(tenantid){ + if (tenantid) { head['tenant_id'] = tenantid } return head; } }, - methods:{ + methods: { loadData(arg) { - if(!this.url.list){ + if (!this.url.list) { this.$message.error("请设置url.list属性!") return } @@ -88,34 +88,33 @@ export const JeroListMixin = { getAction(this.url.list, params).then((res) => { if (res.success) { //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ - this.dataSource = res.result.records||res.result; - if(res.result.total) - { + this.dataSource = res.result.records || res.result; + if (res.result.total) { this.ipagination.total = res.result.total; //清空列表选中 this.onClearSelected() - }else{ + } else { this.ipagination.total = 0; } //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ } - if(res.code===510){ + if (res.code === 510) { this.$message.warning(res.message) } this.loading = false; }) }, - initDictConfig(){ + initDictConfig() { }, handleSuperQuery(params, matchType) { //高级查询方法 - if(!params){ - this.superQueryParams='' + if (!params) { + this.superQueryParams = '' this.superQueryFlag = false - }else{ + } else { this.superQueryFlag = true - this.superQueryParams=JSON.stringify(params) + this.superQueryParams = JSON.stringify(params) this.superQueryMatchType = matchType } this.loadData(1) @@ -123,12 +122,12 @@ export const JeroListMixin = { getQueryParams() { //获取查询条件 let sqp = {} - if(this.superQueryParams){ - sqp['superQueryParams']=encodeURI(this.superQueryParams) + if (this.superQueryParams) { + sqp['superQueryParams'] = encodeURI(this.superQueryParams) sqp['superQueryMatchType'] = this.superQueryMatchType } // var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters); - var param = Object.assign(sqp, this.lastQueryParam, this.isorter ,this.filters); + var param = Object.assign(sqp, this.lastQueryParam, this.isorter, this.filters); param.field = this.getQueryField(); param.pageNo = this.ipagination.current; param.pageSize = this.ipagination.pageSize; @@ -152,7 +151,7 @@ export const JeroListMixin = { this.selectionRows = []; }, searchQuery() { - this.lastQueryParam = { ...this.queryParam } + this.lastQueryParam = {...this.queryParam} this.loadData(1); }, superQuery() { @@ -164,7 +163,7 @@ export const JeroListMixin = { this.loadData(1); }, batchDel: function () { - if(!this.url.deleteBatch){ + if (!this.url.deleteBatch) { this.$message.error("请设置url.deleteBatch属性!") return } @@ -204,7 +203,7 @@ export const JeroListMixin = { } }, handleDelete: function (id) { - if(!this.url.delete){ + if (!this.url.delete) { this.$message.error("请设置url.delete属性!") return } @@ -212,7 +211,7 @@ export const JeroListMixin = { this.$confirm({ title: "确认删除", content: "确定要删除此条数据吗?", - onOk: function() { + onOk: function () { deleteAction(that.url.delete, {id: id}).then((res) => { if (res.success) { that.$message.success(res.message); @@ -248,11 +247,11 @@ export const JeroListMixin = { this.ipagination = pagination; this.loadData(); }, - handleToggleSearch(){ + handleToggleSearch() { this.toggleSearchStatus = !this.toggleSearchStatus; }, // 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段) - getPopupField(fields){ + getPopupField(fields) { return fields.split(',')[0] }, modalFormOk() { @@ -261,39 +260,66 @@ export const JeroListMixin = { //清空列表选中 this.onClearSelected() }, - handleDetail:function(record){ + handleDetail: function (record) { this.$refs.modalForm.edit(record); - this.$refs.modalForm.title="详情"; + this.$refs.modalForm.title = "详情"; this.$refs.modalForm.disableSubmit = true; }, /* 导出 */ - handleExportXls2(){ + handleExportXls2() { let paramsStr = encodeURI(JSON.stringify(this.getQueryParams())); let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`; window.location.href = url; }, - handleExportXls(fileName){ - if(!fileName || typeof fileName != "string"){ + handleExportXls(fileName) { + if (!fileName || typeof fileName != "string") { fileName = "导出文件" } let param = this.getQueryParams(); - if(this.selectedRowKeys && this.selectedRowKeys.length>0){ + if (this.selectedRowKeys && this.selectedRowKeys.length > 0) { param['selections'] = this.selectedRowKeys.join(",") } - console.log("导出参数",param) - downFile(this.url.exportXlsUrl,param).then((data)=>{ + console.log("导出参数", param) + downFile(this.url.exportXlsUrl, param).then((data) => { if (!data) { this.$message.warning("文件下载失败") return } if (typeof window.navigator.msSaveBlob !== 'undefined') { - window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls') - }else{ - let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'})) + window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls') + } else { + let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'})) let link = document.createElement('a') link.style.display = 'none' link.href = url - link.setAttribute('download', fileName+'.xls') + link.setAttribute('download', fileName + '.xls') + document.body.appendChild(link) + link.click() + document.body.removeChild(link); //下载完成移除元素 + window.URL.revokeObjectURL(url); //释放掉blob对象 + } + }) + }, + /* + * 下载模板 + * */ + downTemplate(fileName) { + if (!fileName || typeof fileName != "string") { + fileName = "模板文件" + } + downFile(this.url.downTemplateUrl).then((data) => { + if (!data) { + this.$message.warning("文件下载失败") + return + } + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls') + } else { + let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'})) + let link = document.createElement('a') + link.style.display = 'none' + link.href = url + link.setAttribute('download', fileName + '.xls') document.body.appendChild(link) link.click() document.body.removeChild(link); //下载完成移除元素 @@ -302,7 +328,7 @@ export const JeroListMixin = { }) }, /* 导入 */ - handleImportExcel(info){ + handleImportExcel(info) { if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } @@ -310,14 +336,17 @@ export const JeroListMixin = { if (info.file.response.success) { // this.$message.success(`${info.file.name} 文件上传成功`); if (info.file.response.code === 201) { - let { message, result: { msg, fileUrl, fileName } } = info.file.response + let {message, result: {msg, fileUrl, fileName}} = info.file.response let href = window._CONFIG['domianURL'] + fileUrl this.$warning({ title: message, content: (
+ {msg} +