Commit cedd2d1d authored by RuoYi's avatar RuoYi
Browse files

优化导出数据操作

parent 2ab96587
...@@ -42,12 +42,3 @@ export function delPost(postId) { ...@@ -42,12 +42,3 @@ export function delPost(postId) {
method: 'delete' method: 'delete'
}) })
} }
// 导出岗位
export function exportPost(query) {
return request({
url: '/system/post/export',
method: 'get',
params: query
})
}
\ No newline at end of file
...@@ -65,15 +65,6 @@ export function delRole(roleId) { ...@@ -65,15 +65,6 @@ export function delRole(roleId) {
}) })
} }
// 导出角色
export function exportRole(query) {
return request({
url: '/system/role/export',
method: 'get',
params: query
})
}
// 查询角色已授权用户列表 // 查询角色已授权用户列表
export function allocatedUserList(query) { export function allocatedUserList(query) {
return request({ return request({
......
...@@ -44,15 +44,6 @@ export function delUser(userId) { ...@@ -44,15 +44,6 @@ export function delUser(userId) {
}) })
} }
// 导出用户
export function exportUser(query) {
return request({
url: '/system/user/export',
method: 'get',
params: query
})
}
// 用户密码重置 // 用户密码重置
export function resetUserPwd(userId, password) { export function resetUserPwd(userId, password) {
const data = { const data = {
...@@ -118,14 +109,6 @@ export function uploadAvatar(data) { ...@@ -118,14 +109,6 @@ export function uploadAvatar(data) {
}) })
} }
// 下载用户导入模板
export function importTemplate() {
return request({
url: '/system/user/importTemplate',
method: 'get'
})
}
// 查询授权角色 // 查询授权角色
export function getAuthRole(userId) { export function getAuthRole(userId) {
return request({ return request({
......
...@@ -12,6 +12,7 @@ import store from './store' ...@@ -12,6 +12,7 @@ import store from './store'
import router from './router' import router from './router'
import directive from './directive' //directive import directive from './directive' //directive
import plugins from './plugins' // plugins import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import './assets/icons' // icon import './assets/icons' // icon
import './permission' // permission control import './permission' // permission control
...@@ -43,6 +44,7 @@ Vue.prototype.resetForm = resetForm ...@@ -43,6 +44,7 @@ Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
// 全局组件挂载 // 全局组件挂载
......
import { saveAs } from 'file-saver'
import axios from 'axios' import axios from 'axios'
import { getToken } from '@/utils/auth'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import { saveAs } from 'file-saver'
import { getToken } from '@/utils/auth'
import { blobValidate } from "@/utils/ruoyi";
const baseURL = process.env.VUE_APP_BASE_API const baseURL = process.env.VUE_APP_BASE_API
...@@ -48,7 +49,7 @@ export default { ...@@ -48,7 +49,7 @@ export default {
responseType: 'blob', responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() } headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(async (res) => { }).then(async (res) => {
const isLogin = await this.blobValidate(res.data); const isLogin = await blobValidate(res.data);
if (isLogin) { if (isLogin) {
const blob = new Blob([res.data], { type: 'application/zip' }) const blob = new Blob([res.data], { type: 'application/zip' })
this.saveAs(blob, name) this.saveAs(blob, name)
...@@ -59,15 +60,6 @@ export default { ...@@ -59,15 +60,6 @@ export default {
}, },
saveAs(text, name, opts) { saveAs(text, name, opts) {
saveAs(text, name, opts); saveAs(text, name, opts);
}, }
async blobValidate(data) {
try {
const text = await data.text();
JSON.parse(text);
return false;
} catch (error) {
return true;
}
},
} }
import axios from 'axios' import axios from 'axios'
import { Notification, MessageBox, Message } from 'element-ui' import { Notification, MessageBox, Message, Loading } from 'element-ui'
import store from '@/store' import store from '@/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode' import errorCode from '@/utils/errorCode'
import { tansParams, blobValidate } from "@/utils/ruoyi";
import { saveAs } from 'file-saver'
let downloadLoadingInstance;
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例 // 创建axios实例
...@@ -12,6 +16,7 @@ const service = axios.create({ ...@@ -12,6 +16,7 @@ const service = axios.create({
// 超时 // 超时
timeout: 10000 timeout: 10000
}) })
// request拦截器 // request拦截器
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
// 是否需要设置 token // 是否需要设置 token
...@@ -21,24 +26,7 @@ service.interceptors.request.use(config => { ...@@ -21,24 +26,7 @@ service.interceptors.request.use(config => {
} }
// get请求映射params参数 // get请求映射params参数
if (config.method === 'get' && config.params) { if (config.method === 'get' && config.params) {
let url = config.url + '?'; let url = config.url + '?' + tansParams(config.params);
for (const propName of Object.keys(config.params)) {
const value = config.params[propName];
var part = encodeURIComponent(propName) + "=";
if (value !== null && typeof(value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
let params = propName + '[' + key + ']';
let subPart = encodeURIComponent(params) + '=';
url += subPart + encodeURIComponent(value[key]) + '&';
}
}
} else {
url += part + encodeURIComponent(value) + "&";
}
}
}
url = url.slice(0, -1); url = url.slice(0, -1);
config.params = {}; config.params = {};
config.url = url; config.url = url;
...@@ -55,17 +43,24 @@ service.interceptors.response.use(res => { ...@@ -55,17 +43,24 @@ service.interceptors.response.use(res => {
const code = res.data.code || 200; const code = res.data.code || 200;
// 获取错误信息 // 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default'] const msg = errorCode[code] || res.data.msg || errorCode['default']
// 二进制数据则直接返回
if(res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer'){
return res.data
}
if (code === 401) { if (code === 401) {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { let doms = document.getElementsByClassName('el-message-box')[0]
if(doms === undefined){
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录', confirmButtonText: '重新登录',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
} }
).then(() => { ).then(() => {
store.dispatch('LogOut').then(() => { store.dispatch('LogOut').then(() => {
location.href = '/index'; location.href = '/index';
}) })
}).catch(() => {}); }).catch(() => {});
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) { } else if (code === 500) {
Message({ Message({
...@@ -103,4 +98,27 @@ service.interceptors.response.use(res => { ...@@ -103,4 +98,27 @@ service.interceptors.response.use(res => {
} }
) )
// 通用下载方法
export function download(url, params, filename) {
downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return service.post(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob'
}).then(async (data) => {
const isLogin = await blobValidate(data);
if (isLogin) {
const blob = new Blob([data])
saveAs(blob, filename)
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
Message.error('下载文件出现错误,请联系管理员!')
downloadLoadingInstance.close();
})
}
export default service export default service
...@@ -181,3 +181,40 @@ export function handleTree(data, id, parentId, children) { ...@@ -181,3 +181,40 @@ export function handleTree(data, id, parentId, children) {
} }
return tree; return tree;
} }
/**
* 参数处理
* @param {*} params 参数
*/
export function tansParams(params) {
let result = ''
for (const propName of Object.keys(params)) {
const value = params[propName];
var part = encodeURIComponent(propName) + "=";
if (value !== null && typeof (value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
let params = propName + '[' + key + ']';
var subPart = encodeURIComponent(params) + "=";
result += subPart + encodeURIComponent(value[key]) + "&";
}
}
} else {
result += part + encodeURIComponent(value) + "&";
}
}
}
return result
}
// 验证是否为blob格式
export async function blobValidate(data) {
try {
const text = await data.text();
JSON.parse(text);
return false;
} catch (error) {
return true;
}
}
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:job:export']" v-hasPermi="['monitor:job:export']"
>导出</el-button> >导出</el-button>
...@@ -295,7 +294,7 @@ ...@@ -295,7 +294,7 @@
</template> </template>
<script> <script>
import { listJob, getJob, delJob, addJob, updateJob, exportJob, runJob, changeJobStatus } from "@/api/monitor/job"; import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job";
import Crontab from '@/components/Crontab' import Crontab from '@/components/Crontab'
export default { export default {
...@@ -306,8 +305,6 @@ export default { ...@@ -306,8 +305,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -510,14 +507,9 @@ export default { ...@@ -510,14 +507,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('monitor/job/export', {
this.$modal.confirm('是否确认导出所有定时任务数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `job_${new Date().getTime()}.xlsx`)
return exportJob(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -89,7 +89,6 @@ ...@@ -89,7 +89,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:job:export']" v-hasPermi="['monitor:job:export']"
>导出</el-button> >导出</el-button>
...@@ -186,7 +185,7 @@ ...@@ -186,7 +185,7 @@
<script> <script>
import { getJob} from "@/api/monitor/job"; import { getJob} from "@/api/monitor/job";
import { listJobLog, delJobLog, exportJobLog, cleanJobLog } from "@/api/monitor/jobLog"; import { listJobLog, delJobLog, cleanJobLog } from "@/api/monitor/jobLog";
export default { export default {
name: "JobLog", name: "JobLog",
...@@ -195,8 +194,6 @@ export default { ...@@ -195,8 +194,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非多个禁用 // 非多个禁用
...@@ -293,14 +290,9 @@ export default { ...@@ -293,14 +290,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('/monitor/jobLog/export', {
this.$modal.confirm('是否确认导出所有调度日志数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `log_${new Date().getTime()}.xlsx`)
return exportJobLog(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:logininfor:export']" v-hasPermi="['monitor:logininfor:export']"
>导出</el-button> >导出</el-button>
...@@ -123,7 +122,7 @@ ...@@ -123,7 +122,7 @@
</template> </template>
<script> <script>
import { list, delLogininfor, cleanLogininfor, exportLogininfor } from "@/api/monitor/logininfor"; import { list, delLogininfor, cleanLogininfor } from "@/api/monitor/logininfor";
export default { export default {
name: "Logininfor", name: "Logininfor",
...@@ -132,8 +131,6 @@ export default { ...@@ -132,8 +131,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非多个禁用 // 非多个禁用
...@@ -216,14 +213,9 @@ export default { ...@@ -216,14 +213,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('monitor/logininfor/export', {
this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `logininfor_${new Date().getTime()}.xlsx`)
return exportLogininfor(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['monitor:operlog:export']" v-hasPermi="['monitor:operlog:export']"
>导出</el-button> >导出</el-button>
...@@ -196,7 +195,7 @@ ...@@ -196,7 +195,7 @@
</template> </template>
<script> <script>
import { list, delOperlog, cleanOperlog, exportOperlog } from "@/api/monitor/operlog"; import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog";
export default { export default {
name: "Operlog", name: "Operlog",
...@@ -205,8 +204,6 @@ export default { ...@@ -205,8 +204,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非多个禁用 // 非多个禁用
...@@ -303,14 +300,9 @@ export default { ...@@ -303,14 +300,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('monitor/operlog/export', {
this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `operlog_${new Date().getTime()}.xlsx`)
return exportOperlog(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:config:export']" v-hasPermi="['system:config:export']"
>导出</el-button> >导出</el-button>
...@@ -185,7 +184,7 @@ ...@@ -185,7 +184,7 @@
</template> </template>
<script> <script>
import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig, refreshCache } from "@/api/system/config"; import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
export default { export default {
name: "Config", name: "Config",
...@@ -194,8 +193,6 @@ export default { ...@@ -194,8 +193,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -334,14 +331,9 @@ export default { ...@@ -334,14 +331,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/config/export', {
this.$modal.confirm('是否确认导出所有参数数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `config_${new Date().getTime()}.xlsx`)
return exportConfig(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
}, },
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleRefreshCache() { handleRefreshCache() {
......
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:dict:export']" v-hasPermi="['system:dict:export']"
>导出</el-button> >导出</el-button>
...@@ -183,7 +182,7 @@ ...@@ -183,7 +182,7 @@
</template> </template>
<script> <script>
import { listData, getData, delData, addData, updateData, exportData } from "@/api/system/dict/data"; import { listData, getData, delData, addData, updateData } from "@/api/system/dict/data";
import { listType, getType } from "@/api/system/dict/type"; import { listType, getType } from "@/api/system/dict/type";
export default { export default {
...@@ -193,8 +192,6 @@ export default { ...@@ -193,8 +192,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -380,14 +377,9 @@ export default { ...@@ -380,14 +377,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/dict/data/export', {
this.$modal.confirm('是否确认导出所有数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `data_${new Date().getTime()}.xlsx`)
return exportData(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -94,7 +94,6 @@ ...@@ -94,7 +94,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:dict:export']" v-hasPermi="['system:dict:export']"
>导出</el-button> >导出</el-button>
...@@ -193,7 +192,7 @@ ...@@ -193,7 +192,7 @@
</template> </template>
<script> <script>
import { listType, getType, delType, addType, updateType, exportType, refreshCache } from "@/api/system/dict/type"; import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
export default { export default {
name: "Dict", name: "Dict",
...@@ -202,8 +201,6 @@ export default { ...@@ -202,8 +201,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -338,14 +335,9 @@ export default { ...@@ -338,14 +335,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/dict/type/export', {
this.$modal.confirm('是否确认导出所有类型数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `type_${new Date().getTime()}.xlsx`)
return exportType(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
}, },
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleRefreshCache() { handleRefreshCache() {
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:post:export']" v-hasPermi="['system:post:export']"
>导出</el-button> >导出</el-button>
...@@ -160,7 +159,7 @@ ...@@ -160,7 +159,7 @@
</template> </template>
<script> <script>
import { listPost, getPost, delPost, addPost, updatePost, exportPost } from "@/api/system/post"; import { listPost, getPost, delPost, addPost, updatePost } from "@/api/system/post";
export default { export default {
name: "Post", name: "Post",
...@@ -169,8 +168,6 @@ export default { ...@@ -169,8 +168,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -305,14 +302,9 @@ export default { ...@@ -305,14 +302,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/post/export', {
this.$modal.confirm('是否确认导出所有岗位数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `post_${new Date().getTime()}.xlsx`)
return exportPost(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -94,7 +94,6 @@ ...@@ -94,7 +94,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:role:export']" v-hasPermi="['system:role:export']"
>导出</el-button> >导出</el-button>
...@@ -259,7 +258,7 @@ ...@@ -259,7 +258,7 @@
</template> </template>
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role"; import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role";
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
...@@ -270,8 +269,6 @@ export default { ...@@ -270,8 +269,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -613,14 +610,9 @@ export default { ...@@ -613,14 +610,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/role/export', {
this.$modal.confirm('是否确认导出所有用户数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `role_${new Date().getTime()}.xlsx`)
return exportRole(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
} }
} }
}; };
......
...@@ -131,7 +131,6 @@ ...@@ -131,7 +131,6 @@
plain plain
icon="el-icon-download" icon="el-icon-download"
size="mini" size="mini"
:loading="exportLoading"
@click="handleExport" @click="handleExport"
v-hasPermi="['system:user:export']" v-hasPermi="['system:user:export']"
>导出</el-button> >导出</el-button>
...@@ -346,7 +345,7 @@ ...@@ -346,7 +345,7 @@
</template> </template>
<script> <script>
import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user"; import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept"; import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
...@@ -360,8 +359,6 @@ export default { ...@@ -360,8 +359,6 @@ export default {
return { return {
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组 // 选中数组
ids: [], ids: [],
// 非单个禁用 // 非单个禁用
...@@ -643,14 +640,9 @@ export default { ...@@ -643,14 +640,9 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; this.download('system/user/export', {
this.$modal.confirm('是否确认导出所有用户数据项?').then(() => { ...this.queryParams
this.exportLoading = true; }, `user_${new Date().getTime()}.xlsx`)
return exportUser(queryParams);
}).then(response => {
this.$download.name(response.msg);
this.exportLoading = false;
}).catch(() => {});
}, },
/** 导入按钮操作 */ /** 导入按钮操作 */
handleImport() { handleImport() {
...@@ -659,9 +651,9 @@ export default { ...@@ -659,9 +651,9 @@ export default {
}, },
/** 下载模板操作 */ /** 下载模板操作 */
importTemplate() { importTemplate() {
importTemplate().then(response => { this.download('system/user/importTemplate', {
this.$download.name(response.msg); ...this.queryParams
}); }, `user_template_${new Date().getTime()}.xlsx`)
}, },
// 文件上传中处理 // 文件上传中处理
handleFileUploadProgress(event, file, fileList) { handleFileUploadProgress(event, file, fileList) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment