导出方法修改成文件流形式
This commit is contained in:
parent
25142f5cc5
commit
ec270b7df4
@ -1,11 +1,12 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
import { downFile } from '@/utils/request'
|
||||||
|
|
||||||
// 查询操作日志列表
|
// 查询操作日志列表
|
||||||
export function list(query) {
|
export function list(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/monitor/operlog/list',
|
url: '/monitor/operlog/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export function list(query) {
|
|||||||
export function delOperlog(operId) {
|
export function delOperlog(operId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/monitor/operlog/' + operId,
|
url: '/monitor/operlog/' + operId,
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,15 +22,16 @@ export function delOperlog(operId) {
|
|||||||
export function cleanOperlog() {
|
export function cleanOperlog() {
|
||||||
return request({
|
return request({
|
||||||
url: '/monitor/operlog/clean',
|
url: '/monitor/operlog/clean',
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出操作日志
|
// 导出操作日志
|
||||||
export function exportOperlog(query) {
|
export async function exportOperlog(query) {
|
||||||
return request({
|
// return request({
|
||||||
url: '/monitor/operlog/export',
|
// url: '/monitor/operlog/export',
|
||||||
method: 'get',
|
// method: 'get',
|
||||||
params: query
|
// params: query
|
||||||
})
|
// })
|
||||||
|
await downFile('/monitor/operlog/export', query)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
import { downFile } from '@/utils/request'
|
||||||
|
|
||||||
// 查询岗位列表
|
// 查询岗位列表
|
||||||
export function listPost(query) {
|
export function listPost(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/list',
|
url: '/system/post/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ export function listPost(query) {
|
|||||||
export function getPost(postId) {
|
export function getPost(postId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/' + postId,
|
url: '/system/post/' + postId,
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ export function addPost(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/post',
|
url: '/system/post',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ export function updatePost(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/post',
|
url: '/system/post',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,15 +40,16 @@ export function updatePost(data) {
|
|||||||
export function delPost(postId) {
|
export function delPost(postId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/post/' + postId,
|
url: '/system/post/' + postId,
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出岗位
|
// 导出岗位
|
||||||
export function exportPost(query) {
|
export async function exportPost(query) {
|
||||||
return request({
|
// return request({
|
||||||
url: '/system/post/export',
|
// url: '/system/post/export',
|
||||||
method: 'get',
|
// method: 'get',
|
||||||
params: query
|
// params: query
|
||||||
})
|
// })
|
||||||
|
await downFile('/system/post/export', { ...query })
|
||||||
}
|
}
|
||||||
@ -1,12 +1,13 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { praseStrZero } from "@/utils/ruoyi";
|
import { praseStrZero } from '@/utils/ruoyi'
|
||||||
|
import { downFile } from '@/utils/request'
|
||||||
|
|
||||||
// 查询用户列表
|
// 查询用户列表
|
||||||
export function listUser(query) {
|
export function listUser(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/list',
|
url: '/system/user/list',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ export function listUser(query) {
|
|||||||
export function getUser(userId) {
|
export function getUser(userId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/' + praseStrZero(userId),
|
url: '/system/user/' + praseStrZero(userId),
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ export function addUser(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/edit',
|
url: '/system/user/edit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ export function updateUser(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/edit',
|
url: '/system/user/edit',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,29 +41,30 @@ export function updateUser(data) {
|
|||||||
export function delUser(userId) {
|
export function delUser(userId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/' + userId,
|
url: '/system/user/' + userId,
|
||||||
method: 'delete'
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出用户
|
// 导出用户
|
||||||
export function exportUser(query) {
|
export async function exportUser(query) {
|
||||||
return request({
|
// return request({
|
||||||
url: '/system/User/export',
|
// url: '/system/User/export',
|
||||||
method: 'get',
|
// method: 'get',
|
||||||
params: query
|
// params: query
|
||||||
})
|
// })
|
||||||
|
await downFile('/system/user/export', { ...query })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户密码重置
|
// 用户密码重置
|
||||||
export function resetUserPwd(userId, password) {
|
export function resetUserPwd(userId, password) {
|
||||||
const data = {
|
const data = {
|
||||||
userId,
|
userId,
|
||||||
password
|
password,
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/resetPwd',
|
url: '/system/user/resetPwd',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +72,12 @@ export function resetUserPwd(userId, password) {
|
|||||||
export function changeUserStatus(userId, status) {
|
export function changeUserStatus(userId, status) {
|
||||||
const data = {
|
const data = {
|
||||||
userId,
|
userId,
|
||||||
status
|
status,
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/changeStatus',
|
url: '/system/user/changeStatus',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +85,7 @@ export function changeUserStatus(userId, status) {
|
|||||||
export function getUserProfile() {
|
export function getUserProfile() {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/Profile',
|
url: '/system/user/Profile',
|
||||||
method: 'get'
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ export function updateUserProfile(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile',
|
url: '/system/user/profile',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,12 +102,12 @@ export function updateUserProfile(data) {
|
|||||||
export function updateUserPwd(oldPassword, newPassword) {
|
export function updateUserPwd(oldPassword, newPassword) {
|
||||||
const data = {
|
const data = {
|
||||||
oldPassword,
|
oldPassword,
|
||||||
newPassword
|
newPassword,
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile/updatePwd',
|
url: '/system/user/profile/updatePwd',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
params: data
|
params: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ export function uploadAvatar(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile/avatar',
|
url: '/system/user/profile/avatar',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +125,6 @@ export function importTemplate() {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/importTemplate',
|
url: '/system/user/importTemplate',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
responseType: 'blob'//1.首先设置responseType对象格式为 blob:
|
responseType: 'blob', //1.首先设置responseType对象格式为 blob:
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import router from './router'
|
|||||||
import permission from './directive/permission'
|
import permission from './directive/permission'
|
||||||
import plugins from './plugins' // plugins
|
import plugins from './plugins' // plugins
|
||||||
import signalR from '@/utils/signalR'
|
import signalR from '@/utils/signalR'
|
||||||
|
import { downFile } 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.selectDictLabels = selectDictLabels
|
|||||||
Vue.prototype.download = download
|
Vue.prototype.download = download
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
Vue.prototype.handleDict = handleDict
|
Vue.prototype.handleDict = handleDict
|
||||||
|
Vue.prototype.downFile = downFile
|
||||||
|
|
||||||
Vue.prototype.msgSuccess = function (msg) {
|
Vue.prototype.msgSuccess = function (msg) {
|
||||||
this.$message({ showClose: true, message: msg, type: "success" });
|
this.$message({ showClose: true, message: msg, type: "success" });
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { MessageBox, Message } from 'element-ui'
|
import { 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 { blobValidate } from "@/utils/ruoyi";
|
import { blobValidate } from '@/utils/ruoyi'
|
||||||
// import errorCode from '@/utils/errorCode'
|
import errorCode from '@/utils/errorCode'
|
||||||
// import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
|
|
||||||
|
let downloadLoadingInstance
|
||||||
// 解决后端跨域获取不到cookie问题
|
// 解决后端跨域获取不到cookie问题
|
||||||
axios.defaults.withCredentials = true
|
axios.defaults.withCredentials = true
|
||||||
axios.defaults.headers['Content-Type'] = 'application/json'
|
axios.defaults.headers['Content-Type'] = 'application/json'
|
||||||
@ -14,45 +15,49 @@ const service = axios.create({
|
|||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_BASE_API,
|
baseURL: process.env.VUE_APP_BASE_API,
|
||||||
// 超时
|
// 超时
|
||||||
timeout: 30000
|
timeout: 30000,
|
||||||
})
|
})
|
||||||
|
|
||||||
// request拦截器
|
// request拦截器
|
||||||
service.interceptors.request.use(config => {
|
service.interceptors.request.use(
|
||||||
// 是否需要设置 token
|
(config) => {
|
||||||
if (getToken()) {
|
// 是否需要设置 token
|
||||||
//将token放到请求头发送给服务器,将tokenkey放在请求头中
|
if (getToken()) {
|
||||||
config.headers['Authorization'] = 'Bearer ' + getToken();
|
//将token放到请求头发送给服务器,将tokenkey放在请求头中
|
||||||
config.headers['userid'] = store.getters.userId;
|
config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||||
} else {
|
config.headers['userid'] = store.getters.userId
|
||||||
// console.log(config)
|
} else {
|
||||||
}
|
// console.log(config)
|
||||||
return config;
|
}
|
||||||
}, error => {
|
return config
|
||||||
console.log(error)
|
},
|
||||||
Promise.reject(error)
|
(error) => {
|
||||||
})
|
console.log(error)
|
||||||
|
Promise.reject(error)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(res => {
|
service.interceptors.response.use(
|
||||||
|
(res) => {
|
||||||
if (res.status !== 200) {
|
if (res.status !== 200) {
|
||||||
Promise.reject('network error');
|
Promise.reject('network error')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
// 未设置状态码则默认成功状态
|
// 未设置状态码则默认成功状态
|
||||||
const { code, msg } = res.data;
|
const { code, msg } = res.data
|
||||||
// 二进制数据则直接返回
|
// 二进制数据则直接返回
|
||||||
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
||||||
return res.data
|
return res
|
||||||
}
|
}
|
||||||
if (code == 401) {
|
if (code == 401) {
|
||||||
MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
|
MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
|
||||||
confirmButtonText: '重新登录',
|
confirmButtonText: '重新登录',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning',
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = process.env.VUE_APP_ROUTER_PREFIX + 'index';
|
location.href = process.env.VUE_APP_ROUTER_PREFIX + 'index'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -60,33 +65,33 @@ service.interceptors.response.use(res => {
|
|||||||
} else if (code == 0 || code == 1 || code == 110 || code == 101 || code == 403 || code == 500 || code == 429) {
|
} else if (code == 0 || code == 1 || code == 110 || code == 101 || code == 403 || code == 500 || code == 429) {
|
||||||
Message({
|
Message({
|
||||||
message: msg,
|
message: msg,
|
||||||
type: 'error'
|
type: 'error',
|
||||||
})
|
})
|
||||||
return Promise.reject(res.data)
|
return Promise.reject(res.data)
|
||||||
} else {
|
} else {
|
||||||
//返回标准 code/msg/data字段
|
//返回标准 code/msg/data字段
|
||||||
return res.data;
|
return res.data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
(error) => {
|
||||||
console.log('err' + error)
|
console.log('err' + error)
|
||||||
let { message } = error;
|
let { message } = error
|
||||||
if (message == "Network Error") {
|
if (message == 'Network Error') {
|
||||||
message = "后端接口连接异常";
|
message = '后端接口连接异常'
|
||||||
} else if (message.includes("timeout")) {
|
} else if (message.includes('timeout')) {
|
||||||
message = "系统接口请求超时";
|
message = '系统接口请求超时'
|
||||||
} else if (message.includes("Request failed with status code 429")) {
|
} else if (message.includes('Request failed with status code 429')) {
|
||||||
message = "请求过于频繁,请稍后再试";
|
message = '请求过于频繁,请稍后再试'
|
||||||
} else if (message.includes("Request failed with status code")) {
|
} else if (message.includes('Request failed with status code')) {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = '系统接口' + message.substr(message.length - 3) + '异常'
|
||||||
}
|
}
|
||||||
Message({
|
Message({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
duration: 5 * 1000
|
duration: 5 * 1000,
|
||||||
})
|
})
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,12 +103,12 @@ export function get(url, params) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios
|
axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
params: params
|
params: params,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -113,12 +118,12 @@ export function post(url, params) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios
|
axios
|
||||||
.post(url, {
|
.post(url, {
|
||||||
params: params
|
params: params,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch((err) => {
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -131,39 +136,53 @@ export function post(url, params) {
|
|||||||
*/
|
*/
|
||||||
export function postForm(url, data, config) {
|
export function postForm(url, data, config) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post(url, data, config).then(res => {
|
axios
|
||||||
resolve(res.data)
|
.post(url, data, config)
|
||||||
}).catch(err => {
|
.then((res) => {
|
||||||
reject(err)
|
resolve(res.data)
|
||||||
})
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 通用下载方法
|
// 通用下载方法
|
||||||
// export function download(url, params, filename) {
|
export async function downFile(url, params, config) {
|
||||||
// //downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
|
downloadLoadingInstance = Loading.service({ text: '正在下载数据,请稍候', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' })
|
||||||
// return service.post(url, params, {
|
return service
|
||||||
// //transformRequest: [(params) => { return tansParams(params) }],
|
.get(url, {
|
||||||
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
params,
|
||||||
// responseType: 'blob'
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
// }).then(async (data) => {
|
responseType: 'blob',
|
||||||
// const isLogin = await blobValidate(data);
|
...config,
|
||||||
// if (isLogin) {
|
})
|
||||||
// const blob = new Blob([data])
|
.then(async (resp) => {
|
||||||
// saveAs(blob, filename)
|
const { data } = resp
|
||||||
// } else {
|
|
||||||
// const resText = await data.text();
|
const isLogin = await blobValidate(data)
|
||||||
// const rspObj = JSON.parse(resText);
|
if (isLogin) {
|
||||||
// const errMsg = "出錯了";// errorCode[rspObj.code] || rspObj.msg || errorCode['default']
|
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
||||||
// Message.error(errMsg);
|
var contentDisposition = decodeURI(resp.headers['content-disposition'])
|
||||||
// }
|
var result = patt.exec(contentDisposition)
|
||||||
// // downloadLoadingInstance.close();
|
var fileName = result[1]
|
||||||
// }).catch((r) => {
|
fileName = fileName.replace(/\"/g, '')
|
||||||
// console.error(r)
|
|
||||||
// Message.error('下载文件出现错误,请联系管理员!')
|
const blob = new Blob([data])
|
||||||
// // downloadLoadingInstance.close();
|
saveAs(blob, fileName)
|
||||||
// })
|
} else {
|
||||||
// }
|
const resText = await data.text()
|
||||||
|
const rspObj = JSON.parse(resText)
|
||||||
|
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
|
||||||
|
Message.error(errMsg)
|
||||||
|
}
|
||||||
|
downloadLoadingInstance.close()
|
||||||
|
})
|
||||||
|
.catch((r) => {
|
||||||
|
console.error(r)
|
||||||
|
Message.error('下载文件出现错误,请联系管理员!')
|
||||||
|
downloadLoadingInstance.close()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default service
|
export default service
|
||||||
@ -2,10 +2,24 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="系统模块" prop="title">
|
<el-form-item label="系统模块" prop="title">
|
||||||
<el-input v-model="queryParams.title" placeholder="请输入系统模块" clearable style="width: 200px;" size="small" @keyup.enter.native="handleQuery" />
|
<el-input
|
||||||
|
v-model="queryParams.title"
|
||||||
|
placeholder="请输入系统模块"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作人员" prop="operName">
|
<el-form-item label="操作人员" prop="operName">
|
||||||
<el-input v-model="queryParams.operName" placeholder="请输入操作人员" clearable style="width: 160px;" size="small" @keyup.enter.native="handleQuery" />
|
<el-input
|
||||||
|
v-model="queryParams.operName"
|
||||||
|
placeholder="请输入操作人员"
|
||||||
|
clearable
|
||||||
|
style="width: 160px"
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="类型" prop="businessType">
|
<el-form-item label="类型" prop="businessType">
|
||||||
<el-select v-model="queryParams.businessType" placeholder="操作类型" clearable size="small" style="width: 240px">
|
<el-select v-model="queryParams.businessType" placeholder="操作类型" clearable size="small" style="width: 240px">
|
||||||
@ -18,7 +32,16 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="操作时间">
|
<el-form-item label="操作时间">
|
||||||
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -28,13 +51,25 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['monitor:operlog:remove']">删除</el-button>
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['monitor:operlog:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:operlog:remove']">清空</el-button>
|
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:operlog:remove']"
|
||||||
|
>清空</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:operlog:export']">导出
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:operlog:export']"
|
||||||
|
>导出
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
@ -54,14 +89,15 @@
|
|||||||
<el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
|
<el-table-column label="主机" align="center" prop="operIp" width="130" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
|
<el-table-column label="操作地点" align="center" prop="operLocation" :show-overflow-tooltip="true" />
|
||||||
<el-table-column label="操作状态" align="center" prop="status">
|
<el-table-column label="操作状态" align="center" prop="status">
|
||||||
<template slot-scope="{row}">
|
<template slot-scope="{ row }">
|
||||||
<dict-tag :options="statusOptions" :value="row.status"></dict-tag>
|
<dict-tag :options="statusOptions" :value="row.status"></dict-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="用时" align="center" prop="elapsed">
|
<el-table-column label="用时" align="center" prop="elapsed">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span :style="scope.row.elapsed < 1000 ? 'color:green':scope.row.elapsed <3000 ?'color:orange':'color:red'">{{ scope.row.elapsed }}
|
<span :style="scope.row.elapsed < 1000 ? 'color:green' : scope.row.elapsed < 3000 ? 'color:orange' : 'color:red'"
|
||||||
ms</span>
|
>{{ scope.row.elapsed }} ms</span
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="日志内容" align="center" prop="errorMsg" :show-overflow-tooltip="true" />
|
<el-table-column label="日志内容" align="center" prop="errorMsg" :show-overflow-tooltip="true" />
|
||||||
@ -72,13 +108,14 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)" v-hasPermi="['monitor:operlog:query']">详细
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row, scope.index)" v-hasPermi="['monitor:operlog:query']"
|
||||||
|
>详细
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<!-- 操作日志详细 -->
|
<!-- 操作日志详细 -->
|
||||||
<el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body>
|
<el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body>
|
||||||
@ -129,15 +166,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { list, delOperlog, cleanOperlog, exportOperlog } from '@/api/monitor/operlog'
|
||||||
list,
|
|
||||||
delOperlog,
|
|
||||||
cleanOperlog,
|
|
||||||
exportOperlog,
|
|
||||||
} from "@/api/monitor/operlog";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "operlog",
|
name: 'operlog',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
@ -171,117 +203,102 @@ export default {
|
|||||||
businessType: undefined,
|
businessType: undefined,
|
||||||
status: undefined,
|
status: undefined,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList()
|
||||||
var dictParams = [
|
var dictParams = [
|
||||||
{ dictType: "sys_oper_type", columnName: "businessTypeOptions" },
|
{ dictType: 'sys_oper_type', columnName: 'businessTypeOptions' },
|
||||||
{ dictType: "sys_common_status", columnName: "statusOptions" },
|
{ dictType: 'sys_common_status', columnName: 'statusOptions' },
|
||||||
];
|
]
|
||||||
this.getDicts(dictParams).then((response) => {
|
this.getDicts(dictParams).then((response) => {
|
||||||
response.data.forEach((element) => {
|
response.data.forEach((element) => {
|
||||||
this[element.columnName] = element.list;
|
this[element.columnName] = element.list
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询登录日志 */
|
/** 查询登录日志 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true
|
||||||
list(this.addDateRange(this.queryParams, this.dateRange)).then(
|
list(this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
|
||||||
(response) => {
|
this.loading = false
|
||||||
this.loading = false;
|
if (response.code == 200) {
|
||||||
if (response.code == 200) {
|
this.list = response.data.result
|
||||||
this.list = response.data.result;
|
this.total = response.data.totalNum
|
||||||
this.total = response.data.totalNum;
|
} else {
|
||||||
} else {
|
this.total = 0
|
||||||
this.total = 0;
|
this.list = []
|
||||||
this.list = [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
})
|
||||||
},
|
},
|
||||||
// 操作日志状态字典翻译
|
// 操作日志状态字典翻译
|
||||||
statusFormat(row, column) {
|
statusFormat(row, column) {
|
||||||
return this.selectDictLabel(this.statusOptions, row.status);
|
return this.selectDictLabel(this.statusOptions, row.status)
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.dateRange = [];
|
this.dateRange = []
|
||||||
this.resetForm("queryForm");
|
this.resetForm('queryForm')
|
||||||
this.handleQuery();
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map((item) => item.operId);
|
this.ids = selection.map((item) => item.operId)
|
||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 详细按钮操作 */
|
/** 详细按钮操作 */
|
||||||
handleView(row) {
|
handleView(row) {
|
||||||
this.open = true;
|
this.open = true
|
||||||
this.form = row;
|
this.form = row
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const operIds = row.operId || this.ids;
|
const operIds = row.operId || this.ids
|
||||||
this.$confirm(
|
this.$confirm('是否确认删除日志编号为"' + operIds + '"的数据项?', '警告', {
|
||||||
'是否确认删除日志编号为"' + operIds + '"的数据项?',
|
confirmButtonText: '确定',
|
||||||
"警告",
|
cancelButtonText: '取消',
|
||||||
{
|
type: 'warning',
|
||||||
confirmButtonText: "确定",
|
})
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return delOperlog(operIds);
|
return delOperlog(operIds)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess('删除成功')
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 清空按钮操作 */
|
/** 清空按钮操作 */
|
||||||
handleClean() {
|
handleClean() {
|
||||||
this.$confirm("是否确认清空所有操作日志数据项?", "警告", {
|
this.$confirm('是否确认清空所有操作日志数据项?', '警告', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning',
|
||||||
})
|
})
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return cleanOperlog();
|
return cleanOperlog()
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.msgSuccess("清空成功");
|
this.msgSuccess('清空成功')
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
const queryParams = this.queryParams
|
||||||
this.$confirm("是否确认导出所有操作日志?", "警告", {
|
this.$confirm('是否确认导出所有操作日志?', '警告', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning',
|
||||||
}).then(() => {
|
}).then(async () => {
|
||||||
exportOperlog(queryParams).then((response) => {
|
await exportOperlog(queryParams)
|
||||||
const { code, data } = response;
|
})
|
||||||
if (code == 200) {
|
|
||||||
this.msgSuccess("导出成功");
|
|
||||||
this.download(data.path);
|
|
||||||
} else {
|
|
||||||
this.msgError("导出失败");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -23,13 +23,26 @@
|
|||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:post:edit']">修改</el-button>
|
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:post:edit']"
|
||||||
|
>修改</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:post:remove']">删除</el-button>
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['system:post:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:post:export']">导出</el-button>
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:post:export']"
|
||||||
|
>导出</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -53,12 +66,14 @@
|
|||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:post:edit']">修改</el-button>
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:post:edit']">修改</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:post:remove']">删除</el-button>
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:post:remove']"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
|
||||||
|
|
||||||
<!-- 添加或修改岗位对话框 -->
|
<!-- 添加或修改岗位对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
@ -74,7 +89,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="岗位状态" prop="status">
|
<el-form-item label="岗位状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
|
<el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{ dict.dictLabel }}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
@ -90,17 +105,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { listPost, getPost, delPost, addPost, updatePost, exportPost } from '@/api/system/post'
|
||||||
listPost,
|
|
||||||
getPost,
|
|
||||||
delPost,
|
|
||||||
addPost,
|
|
||||||
updatePost,
|
|
||||||
exportPost,
|
|
||||||
} from "@/api/system/post";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "post",
|
name: 'post',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
@ -118,7 +126,7 @@ export default {
|
|||||||
// 岗位表格数据
|
// 岗位表格数据
|
||||||
postList: [],
|
postList: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: '',
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 状态数据字典
|
// 状态数据字典
|
||||||
@ -135,33 +143,27 @@ export default {
|
|||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
postName: [
|
postName: [{ required: true, message: '岗位名称不能为空', trigger: 'blur' }],
|
||||||
{ required: true, message: "岗位名称不能为空", trigger: "blur" },
|
postCode: [{ required: true, message: '岗位编码不能为空', trigger: 'blur' }],
|
||||||
],
|
postSort: [{ required: true, message: '岗位顺序不能为空', trigger: 'blur' }],
|
||||||
postCode: [
|
|
||||||
{ required: true, message: "岗位编码不能为空", trigger: "blur" },
|
|
||||||
],
|
|
||||||
postSort: [
|
|
||||||
{ required: true, message: "岗位顺序不能为空", trigger: "blur" },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.getDicts("sys_normal_disable").then((response) => {
|
this.getDicts('sys_normal_disable').then((response) => {
|
||||||
this.statusOptions = response.data;
|
this.statusOptions = response.data
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询岗位列表 */
|
/** 查询岗位列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true
|
||||||
listPost(this.queryParams).then((response) => {
|
listPost(this.queryParams).then((response) => {
|
||||||
this.postList = response.data.result;
|
this.postList = response.data.result
|
||||||
this.total = response.data.totalNum;
|
this.total = response.data.totalNum
|
||||||
this.loading = false;
|
this.loading = false
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
// 岗位状态字典翻译
|
// 岗位状态字典翻译
|
||||||
// statusFormat(row, column) {
|
// statusFormat(row, column) {
|
||||||
@ -169,8 +171,8 @@ export default {
|
|||||||
// },
|
// },
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.reset();
|
this.reset()
|
||||||
},
|
},
|
||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
@ -179,98 +181,93 @@ export default {
|
|||||||
postCode: undefined,
|
postCode: undefined,
|
||||||
postName: undefined,
|
postName: undefined,
|
||||||
postSort: 0,
|
postSort: 0,
|
||||||
status: "0",
|
status: '0',
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
};
|
}
|
||||||
this.resetForm("form");
|
this.resetForm('form')
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.resetForm("queryForm");
|
this.resetForm('queryForm')
|
||||||
this.handleQuery();
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map((item) => item.postId);
|
this.ids = selection.map((item) => item.postId)
|
||||||
this.single = selection.length != 1;
|
this.single = selection.length != 1
|
||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset()
|
||||||
this.open = true;
|
this.open = true
|
||||||
this.title = "添加岗位";
|
this.title = '添加岗位'
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset()
|
||||||
const postId = row.postId || this.ids;
|
const postId = row.postId || this.ids
|
||||||
getPost(postId).then((response) => {
|
getPost(postId).then((response) => {
|
||||||
this.form = response.data;
|
this.form = response.data
|
||||||
this.open = true;
|
this.open = true
|
||||||
this.title = "修改岗位";
|
this.title = '修改岗位'
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function () {
|
submitForm: function () {
|
||||||
this.$refs["form"].validate((valid) => {
|
this.$refs['form'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.postId != undefined) {
|
if (this.form.postId != undefined) {
|
||||||
updatePost(this.form).then((response) => {
|
updatePost(this.form).then((response) => {
|
||||||
this.msgSuccess("修改成功");
|
this.msgSuccess('修改成功')
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.getList();
|
this.getList()
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
addPost(this.form).then((response) => {
|
addPost(this.form).then((response) => {
|
||||||
this.msgSuccess("新增成功");
|
this.msgSuccess('新增成功')
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.getList();
|
this.getList()
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const postIds = row.postId || this.ids;
|
const postIds = row.postId || this.ids
|
||||||
this.$confirm(
|
this.$confirm('是否确认删除岗位编号为"' + postIds + '"的数据项?', '警告', {
|
||||||
'是否确认删除岗位编号为"' + postIds + '"的数据项?',
|
confirmButtonText: '确定',
|
||||||
"警告",
|
cancelButtonText: '取消',
|
||||||
{
|
type: 'warning',
|
||||||
confirmButtonText: "确定",
|
})
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return delPost(postIds);
|
return delPost(postIds)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess('删除成功')
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
const queryParams = this.queryParams
|
||||||
this.$confirm("是否确认导出所有岗位数据项?", "警告", {
|
this.$confirm('是否确认导出所有岗位数据项?', '警告', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning',
|
||||||
|
}).then(async () => {
|
||||||
|
await exportPost(queryParams)
|
||||||
})
|
})
|
||||||
.then(function () {
|
// .then((response) => {
|
||||||
return exportPost(queryParams);
|
// this.download(response.data.path);
|
||||||
})
|
// });
|
||||||
.then((response) => {
|
|
||||||
this.download(response.data.path);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -4,23 +4,49 @@
|
|||||||
<!--部门数据-->
|
<!--部门数据-->
|
||||||
<el-col :lg="4" :sm="24">
|
<el-col :lg="4" :sm="24">
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
|
<el-input
|
||||||
|
v-model="deptName"
|
||||||
|
placeholder="请输入部门名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
prefix-icon="el-icon-search"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree"
|
<el-tree
|
||||||
default-expand-all @node-click="handleNodeClick" />
|
:data="deptOptions"
|
||||||
|
:props="defaultProps"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
ref="tree"
|
||||||
|
default-expand-all
|
||||||
|
@node-click="handleNodeClick"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!--用户数据-->
|
<!--用户数据-->
|
||||||
<el-col :lg="20" :sm="24">
|
<el-col :lg="20" :sm="24">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="用户名称" prop="userName">
|
<el-form-item label="用户名称" prop="userName">
|
||||||
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" style="width: 240px"
|
<el-input
|
||||||
@keyup.enter.native="handleQuery" />
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="手机号码" prop="phonenumber">
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
<el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small" style="width: 240px"
|
<el-input
|
||||||
@keyup.enter.native="handleQuery" />
|
v-model="queryParams.phonenumber"
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px">
|
<el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px">
|
||||||
@ -28,8 +54,16 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="创建时间">
|
||||||
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-"
|
<el-date-picker
|
||||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
v-model="dateRange"
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
@ -46,10 +80,13 @@
|
|||||||
v-hasPermi="['system:user:edit']">修改</el-button>
|
v-hasPermi="['system:user:edit']">修改</el-button>
|
||||||
</el-col> -->
|
</el-col> -->
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button>
|
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']"
|
||||||
|
>导入</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']"
|
||||||
|
>导出
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||||
@ -80,11 +117,15 @@
|
|||||||
<el-table-column label="创建人" align="center" prop="createBy" v-if="columns[2].checked"></el-table-column>
|
<el-table-column label="创建人" align="center" prop="createBy" v-if="columns[2].checked"></el-table-column>
|
||||||
<el-table-column label="备注" align="center" prop="remark" v-if="columns[3].checked"></el-table-column>
|
<el-table-column label="备注" align="center" prop="remark" v-if="columns[3].checked"></el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
|
||||||
<template slot-scope="scope" v-if="scope.row.userId !== 1 | scope.row.userName != 'admin'">
|
<template slot-scope="scope" v-if="(scope.row.userId !== 1) | (scope.row.userName != 'admin')">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button>
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']"
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除
|
>修改</el-button
|
||||||
|
>
|
||||||
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']"
|
||||||
|
>删除
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']">重置
|
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"
|
||||||
|
>重置
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -184,17 +225,25 @@
|
|||||||
|
|
||||||
<!-- 用户导入对话框 -->
|
<!-- 用户导入对话框 -->
|
||||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||||
<el-upload name="file" ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
|
<el-upload
|
||||||
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
name="file"
|
||||||
:on-success="handleFileSuccess" :auto-upload="false" drag>
|
ref="upload"
|
||||||
|
:limit="1"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
:headers="upload.headers"
|
||||||
|
:action="upload.url + '?updateSupport=' + upload.updateSupport"
|
||||||
|
:disabled="upload.isUploading"
|
||||||
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:on-success="handleFileSuccess"
|
||||||
|
:auto-upload="false"
|
||||||
|
drag
|
||||||
|
>
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
<div class="el-upload__tip text-center" slot="tip">
|
<div class="el-upload__tip text-center" slot="tip">
|
||||||
<div class="el-upload__tip" slot="tip">
|
<div class="el-upload__tip" slot="tip"><el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据</div>
|
||||||
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
|
|
||||||
</div>
|
|
||||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||||
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
|
||||||
</div>
|
</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
@ -206,23 +255,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus } from '@/api/system/user'
|
||||||
listUser,
|
import { getToken } from '@/utils/auth'
|
||||||
getUser,
|
import { treeselect } from '@/api/system/dept'
|
||||||
delUser,
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
addUser,
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
updateUser,
|
|
||||||
exportUser,
|
|
||||||
resetUserPwd,
|
|
||||||
changeUserStatus,
|
|
||||||
} from "@/api/system/user";
|
|
||||||
import { getToken } from "@/utils/auth";
|
|
||||||
import { treeselect } from "@/api/system/dept";
|
|
||||||
import Treeselect from "@riophae/vue-treeselect";
|
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "user",
|
name: 'user',
|
||||||
components: { Treeselect },
|
components: { Treeselect },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -241,7 +281,7 @@ export default {
|
|||||||
// 用户表格数据
|
// 用户表格数据
|
||||||
userList: [],
|
userList: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: '',
|
||||||
// 部门树选项
|
// 部门树选项
|
||||||
deptOptions: undefined,
|
deptOptions: undefined,
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
@ -263,23 +303,23 @@ export default {
|
|||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
children: "children",
|
children: 'children',
|
||||||
label: "label",
|
label: 'label',
|
||||||
},
|
},
|
||||||
// 用户导入参数
|
// 用户导入参数
|
||||||
upload: {
|
upload: {
|
||||||
// 是否显示弹出层(用户导入)
|
// 是否显示弹出层(用户导入)
|
||||||
open: false,
|
open: false,
|
||||||
// 弹出层标题(用户导入)
|
// 弹出层标题(用户导入)
|
||||||
title: "",
|
title: '',
|
||||||
// 是否禁用上传
|
// 是否禁用上传
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
// 是否更新已经存在的用户数据
|
// 是否更新已经存在的用户数据
|
||||||
updateSupport: 0,
|
updateSupport: 0,
|
||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
headers: { Authorization: "Bearer " + getToken() },
|
headers: { Authorization: 'Bearer ' + getToken() },
|
||||||
// 上传的地址
|
// 上传的地址
|
||||||
url: process.env.VUE_APP_BASE_API + "/system/user/importData",
|
url: process.env.VUE_APP_BASE_API + '/system/user/importData',
|
||||||
},
|
},
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
@ -306,111 +346,97 @@ export default {
|
|||||||
],
|
],
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
userName: [
|
userName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }],
|
||||||
{ required: true, message: "用户名称不能为空", trigger: "blur" },
|
nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
|
||||||
],
|
deptId: [{ required: true, message: '归属部门不能为空', trigger: 'change' }],
|
||||||
nickName: [
|
password: [{ required: true, message: '用户密码不能为空', trigger: 'blur' }],
|
||||||
{ required: true, message: "用户昵称不能为空", trigger: "blur" },
|
|
||||||
],
|
|
||||||
deptId: [
|
|
||||||
{ required: true, message: "归属部门不能为空", trigger: "change" },
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{ required: true, message: "用户密码不能为空", trigger: "blur" },
|
|
||||||
],
|
|
||||||
email: [
|
email: [
|
||||||
{ required: false, message: "邮箱地址不能为空", trigger: "blur" },
|
{ required: false, message: '邮箱地址不能为空', trigger: 'blur' },
|
||||||
{
|
{
|
||||||
type: "email",
|
type: 'email',
|
||||||
message: "'请输入正确的邮箱地址",
|
message: "'请输入正确的邮箱地址",
|
||||||
trigger: ["blur", "change"],
|
trigger: ['blur', 'change'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
phonenumber: [
|
phonenumber: [
|
||||||
{ required: false, message: "手机号码不能为空", trigger: "blur" },
|
{ required: false, message: '手机号码不能为空', trigger: 'blur' },
|
||||||
{
|
{
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||||
message: "请输入正确的手机号码",
|
message: '请输入正确的手机号码',
|
||||||
trigger: "blur",
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 根据名称筛选部门树
|
// 根据名称筛选部门树
|
||||||
deptName(val) {
|
deptName(val) {
|
||||||
this.$refs.tree.filter(val);
|
this.$refs.tree.filter(val)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.getTreeselect();
|
this.getTreeselect()
|
||||||
|
|
||||||
this.getDicts("sys_normal_disable").then((response) => {
|
this.getDicts('sys_normal_disable').then((response) => {
|
||||||
this.statusOptions = response.data;
|
this.statusOptions = response.data
|
||||||
});
|
})
|
||||||
this.getDicts("sys_user_sex").then((response) => {
|
this.getDicts('sys_user_sex').then((response) => {
|
||||||
this.sexOptions = response.data;
|
this.sexOptions = response.data
|
||||||
});
|
})
|
||||||
this.getConfigKey("sys.user.initPassword").then((response) => {
|
this.getConfigKey('sys.user.initPassword').then((response) => {
|
||||||
this.initPassword = response.data;
|
this.initPassword = response.data
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true
|
||||||
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
|
listUser(this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
|
||||||
(response) => {
|
this.userList = response.data.result
|
||||||
this.userList = response.data.result;
|
this.total = response.data.totalNum
|
||||||
this.total = response.data.totalNum;
|
this.loading = false
|
||||||
this.loading = false;
|
})
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
getTreeselect() {
|
getTreeselect() {
|
||||||
treeselect().then((response) => {
|
treeselect().then((response) => {
|
||||||
this.deptOptions = response.data;
|
this.deptOptions = response.data
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
// 筛选节点
|
// 筛选节点
|
||||||
filterNode(value, data) {
|
filterNode(value, data) {
|
||||||
if (!value) return true;
|
if (!value) return true
|
||||||
return data.label.indexOf(value) !== -1;
|
return data.label.indexOf(value) !== -1
|
||||||
},
|
},
|
||||||
// 节点单击事件
|
// 节点单击事件
|
||||||
handleNodeClick(data) {
|
handleNodeClick(data) {
|
||||||
this.queryParams.deptId = data.id;
|
this.queryParams.deptId = data.id
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
// 用户状态修改
|
// 用户状态修改
|
||||||
handleStatusChange(row) {
|
handleStatusChange(row) {
|
||||||
let text = row.status === "0" ? "启用" : "停用";
|
let text = row.status === '0' ? '启用' : '停用'
|
||||||
this.$confirm(
|
this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', '警告', {
|
||||||
'确认要"' + text + '""' + row.userName + '"用户吗?',
|
confirmButtonText: '确定',
|
||||||
"警告",
|
cancelButtonText: '取消',
|
||||||
{
|
type: 'warning',
|
||||||
confirmButtonText: "确定",
|
})
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return changeUserStatus(row.userId, row.status);
|
return changeUserStatus(row.userId, row.status)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.msgSuccess(text + "成功");
|
this.msgSuccess(text + '成功')
|
||||||
})
|
})
|
||||||
.catch(function () {
|
.catch(function () {
|
||||||
row.status = row.status === "0" ? "1" : "0";
|
row.status = row.status === '0' ? '1' : '0'
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.reset();
|
this.reset()
|
||||||
},
|
},
|
||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
@ -423,58 +449,58 @@ export default {
|
|||||||
phonenumber: undefined,
|
phonenumber: undefined,
|
||||||
email: undefined,
|
email: undefined,
|
||||||
sex: undefined,
|
sex: undefined,
|
||||||
status: "0",
|
status: '0',
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
postIds: [],
|
postIds: [],
|
||||||
roleIds: [],
|
roleIds: [],
|
||||||
};
|
}
|
||||||
this.resetForm("form");
|
this.resetForm('form')
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.page = 1;
|
this.queryParams.page = 1
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.dateRange = [];
|
this.dateRange = []
|
||||||
this.queryParams.deptId = undefined;
|
this.queryParams.deptId = undefined
|
||||||
this.resetForm("queryForm");
|
this.resetForm('queryForm')
|
||||||
this.handleQuery();
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map((item) => item.userId);
|
this.ids = selection.map((item) => item.userId)
|
||||||
this.single = selection.length != 1;
|
this.single = selection.length != 1
|
||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length
|
||||||
},
|
},
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset();
|
this.reset()
|
||||||
this.getTreeselect();
|
this.getTreeselect()
|
||||||
getUser().then((response) => {
|
getUser().then((response) => {
|
||||||
this.postOptions = response.data.posts;
|
this.postOptions = response.data.posts
|
||||||
this.roleOptions = response.data.roles;
|
this.roleOptions = response.data.roles
|
||||||
this.open = true;
|
this.open = true
|
||||||
this.title = "添加用户";
|
this.title = '添加用户'
|
||||||
this.form.password = this.initPassword;
|
this.form.password = this.initPassword
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset()
|
||||||
this.getTreeselect();
|
this.getTreeselect()
|
||||||
const userId = row.userId || this.ids;
|
const userId = row.userId || this.ids
|
||||||
|
|
||||||
getUser(userId).then((response) => {
|
getUser(userId).then((response) => {
|
||||||
// this.form = response.data.user;
|
// this.form = response.data.user;
|
||||||
var data = response.data;
|
var data = response.data
|
||||||
this.form = {
|
this.form = {
|
||||||
userId: data.user.userId,
|
userId: data.user.userId,
|
||||||
deptId: data.user.deptId,
|
deptId: data.user.deptId,
|
||||||
userName: data.user.userName,
|
userName: data.user.userName,
|
||||||
nickName: data.user.nickName,
|
nickName: data.user.nickName,
|
||||||
password: "",
|
password: '',
|
||||||
phonenumber: data.user.phonenumber,
|
phonenumber: data.user.phonenumber,
|
||||||
email: data.user.email,
|
email: data.user.email,
|
||||||
sex: data.user.sex,
|
sex: data.user.sex,
|
||||||
@ -482,124 +508,121 @@ export default {
|
|||||||
remark: data.user.remark,
|
remark: data.user.remark,
|
||||||
postIds: data.postIds,
|
postIds: data.postIds,
|
||||||
roleIds: data.roleIds,
|
roleIds: data.roleIds,
|
||||||
};
|
}
|
||||||
this.roleOptions = response.data.roles;
|
this.roleOptions = response.data.roles
|
||||||
this.postOptions = response.data.posts;
|
this.postOptions = response.data.posts
|
||||||
|
|
||||||
this.open = true;
|
this.open = true
|
||||||
this.title = "修改用户";
|
this.title = '修改用户'
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 重置密码按钮操作 */
|
/** 重置密码按钮操作 */
|
||||||
handleResetPwd(row) {
|
handleResetPwd(row) {
|
||||||
this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
this.$prompt('请输入"' + row.userName + '"的新密码', '提示', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
})
|
})
|
||||||
.then(({ value }) => {
|
.then(({ value }) => {
|
||||||
resetUserPwd(row.userId, value).then((response) => {
|
resetUserPwd(row.userId, value).then((response) => {
|
||||||
this.msgSuccess("修改成功,新密码是:" + value);
|
this.msgSuccess('修改成功,新密码是:' + value)
|
||||||
});
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {})
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function () {
|
submitForm: function () {
|
||||||
this.$refs["form"].validate((valid) => {
|
this.$refs['form'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log(JSON.stringify(this.form));
|
console.log(JSON.stringify(this.form))
|
||||||
// return;
|
// return;
|
||||||
if (this.form.userId != undefined) {
|
if (this.form.userId != undefined) {
|
||||||
updateUser(this.form).then((response) => {
|
updateUser(this.form).then((response) => {
|
||||||
this.msgSuccess("修改成功");
|
this.msgSuccess('修改成功')
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.getList();
|
this.getList()
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
addUser(this.form).then((response) => {
|
addUser(this.form).then((response) => {
|
||||||
this.msgSuccess("新增成功");
|
this.msgSuccess('新增成功')
|
||||||
this.open = false;
|
this.open = false
|
||||||
this.getList();
|
this.getList()
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const userIds = row.userId || this.ids;
|
const userIds = row.userId || this.ids
|
||||||
if (userIds == 1 || row.userName == "admin") {
|
if (userIds == 1 || row.userName == 'admin') {
|
||||||
this.msgError("不能对管理进行删除");
|
this.msgError('不能对管理进行删除')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
this.$confirm(
|
this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', '警告', {
|
||||||
'是否确认删除用户编号为"' + userIds + '"的数据项?',
|
confirmButtonText: '确定',
|
||||||
"警告",
|
cancelButtonText: '取消',
|
||||||
{
|
type: 'warning',
|
||||||
confirmButtonText: "确定",
|
})
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return delUser(userIds);
|
return delUser(userIds)
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.getList();
|
this.getList()
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess('删除成功')
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
handleExport() {
|
handleExport() {
|
||||||
const queryParams = this.queryParams;
|
const queryParams = this.queryParams
|
||||||
this.$confirm("是否确认导出所有用户数据项?", "警告", {
|
this.$confirm('是否确认导出所有用户数据项?', '警告', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning',
|
||||||
}).then(() => {
|
}).then(async () => {
|
||||||
exportUser(queryParams).then((response) => {
|
// exportUser(queryParams).then((response) => {
|
||||||
const { code, data } = response;
|
// const { code, data } = response;
|
||||||
if (code == 200) {
|
// if (code == 200) {
|
||||||
this.msgSuccess("导出成功");
|
// this.msgSuccess("导出成功");
|
||||||
this.download(data.path);
|
// this.download(data.path);
|
||||||
} else {
|
// } else {
|
||||||
this.msgError("导出失败");
|
// this.msgError("导出失败");
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
});
|
await exportUser(queryParams)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
/** 导入按钮操作 */
|
/** 导入按钮操作 */
|
||||||
handleImport() {
|
handleImport() {
|
||||||
this.upload.title = "用户导入";
|
this.upload.title = '用户导入'
|
||||||
this.upload.open = true;
|
this.upload.open = true
|
||||||
},
|
},
|
||||||
/** 下载模板操作 */
|
/** 下载模板操作 */
|
||||||
importTemplate() {
|
importTemplate() {
|
||||||
this.download("/system/user/importTemplate", "用户数据导入模板");
|
this.download('/system/user/importTemplate', '用户数据导入模板')
|
||||||
},
|
},
|
||||||
// 文件上传中处理
|
// 文件上传中处理
|
||||||
handleFileUploadProgress(event, file, fileList) {
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
this.upload.isUploading = true;
|
this.upload.isUploading = true
|
||||||
},
|
},
|
||||||
// 文件上传成功处理
|
// 文件上传成功处理
|
||||||
handleFileSuccess(response, file, fileList) {
|
handleFileSuccess(response, file, fileList) {
|
||||||
this.upload.open = false;
|
this.upload.open = false
|
||||||
this.upload.isUploading = false;
|
this.upload.isUploading = false
|
||||||
this.$refs.upload.clearFiles();
|
this.$refs.upload.clearFiles()
|
||||||
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
|
this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
|
||||||
this.getList();
|
this.getList()
|
||||||
},
|
},
|
||||||
// 提交上传文件
|
// 提交上传文件
|
||||||
submitFileForm() {
|
submitFileForm() {
|
||||||
this.$refs.upload.submit();
|
this.$refs.upload.submit()
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 解决编辑时角色选中不了问题
|
* 解决编辑时角色选中不了问题
|
||||||
*/
|
*/
|
||||||
selectRole(e) {
|
selectRole(e) {
|
||||||
console.log(e, JSON.stringify(this.form));
|
console.log(e, JSON.stringify(this.form))
|
||||||
this.$forceUpdate();
|
this.$forceUpdate()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user