全部接口加密

master
yujialong 9 months ago
parent 8ba50079cc
commit e0cbcb37d0
  1. 5
      package-lock.json
  2. 1
      package.json
  3. 11
      src/api/index.js
  4. 7
      src/libs/util.js
  5. 86
      src/pages/account/login/index.vue
  6. 160
      src/pages/annex/list/index.vue
  7. 69
      src/pages/article/add/index.vue
  8. 38
      src/pages/article/list/index.vue
  9. 6
      src/pages/column/add/index.vue
  10. 36
      src/pages/column/list/index.vue
  11. 186
      src/pages/role/list/index.vue
  12. 72
      src/pages/setting/list/index.vue
  13. 281
      src/pages/setting/list/info.vue
  14. 513
      src/pages/user/list/index.vue
  15. 146
      src/pages/userGroup/list/index.vue
  16. 13
      src/setting.js
  17. 2
      src/store/modules/user.js
  18. 3
      vue.config.js

5
package-lock.json generated

@ -7450,6 +7450,11 @@
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
"jsencrypt": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/jsencrypt/-/jsencrypt-3.3.2.tgz",
"integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A=="
},
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",

@ -16,6 +16,7 @@
"element-ui": "^2.13.0",
"image-conversion": "^2.1.1",
"js-cookie": "^2.2.1",
"jsencrypt": "^3.3.2",
"mavon-editor": "^2.6.17",
"postcss-px2rem": "^0.3.0",
"px2rem-loader": "^0.1.9",

@ -9,10 +9,15 @@ export default {
delFile: `iasf/sysFiles/delete`,
updateFile: `iasf/sysFiles/update`,
dept: `iasf/sys/dept`,
deleteDept: `iasf/sys/deleteDept`,
updateDept: `iasf/sys/updateDept`,
deptTree: `iasf/sys/dept/tree`,
depts: `iasf/sys/dept/tree`,
users: `iasf/sys/users`,
user: `iasf/sys/user`,
updateUser: `iasf/sys/updateUser`,
queryUser: `iasf/sys/queryUser`,
deletedUser: `iasf/sys/deletedUser`,
sendPhoneOrEmailCode: `iasf/sys/sendPhoneOrEmailCode`,
updatePhoneOrEmail: `iasf/sys/updatePhoneOrEmail`,
updateUserAvatars: `${host}iasf/sys/updateUserAvatars`,
@ -25,12 +30,14 @@ export default {
importStaff: `${host}iasf/sys/importStaff`,
roles: `iasf/sys/roles`,
role: `iasf/sys/role`,
addRole: `iasf/sys/addRole`,
updateRole: `iasf/sys/updateRole`,
deleteRole: `iasf/sys/role/deleted`,
perTree: `iasf/sys/permission/tree/all`,
groupAdd: `iasf/sys/userGroup/add`,
groupDel: `iasf/sys/userGroup/delete`,
groupDel: `iasf/sys/userGroup/deleteUserGroup`,
groupList: `iasf/sys/userGroup/list`,
groupUpdate: `iasf/sys/userGroup/update`,
groupUpdate: `iasf/sys/userGroup/updateUserGroup`,
site: `iasf/sys/site/list`,
updateSite: `iasf/sys/site/update`,
listWithTree: `iasf/sysColumn/listWithTree`,

@ -2,6 +2,7 @@ import { _local } from "./util.db";
import { Message } from "element-ui";
import store from "@/store";
import Setting from '@/setting'
import JSEncrypt from "jsencrypt"
// 文件后缀集合
const exts = {
@ -112,6 +113,12 @@ const util = {
Message.closeAll();
return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration });
},
// rsa加密
rsa(data) {
const jse = new JSEncrypt(); // 实例化一个 jsEncrypt 对象
jse.setPublicKey(Setting.publicKey); //配置公钥
return jse.encrypt(JSON.stringify(data))
},
};
export default util;

@ -2,7 +2,8 @@
<div class="wrap">
<div class="left-bg">
<div class="logo">
<img src="@/assets/images/logo.png" alt="">
<img src="@/assets/images/logo.png"
alt="">
网站管理后台
</div>
</div>
@ -10,43 +11,46 @@
<p class="title">欢迎登录</p>
<div class="item">
<label class="phone"></label>
<el-input v-model.trim="loginForm.username" placeholder="请输入账号"></el-input>
<el-input v-model.trim="loginForm.username"
placeholder="请输入账号"></el-input>
</div>
<div class="item">
<label class="pw"></label>
<el-input
type="password"
<el-input type="password"
placeholder="请输入密码"
v-model.trim="loginForm.password"
>
v-model.trim="loginForm.password">
</el-input>
</div>
<div class="item">
<label class="code"></label>
<el-input
placeholder="请输入验证码"
<el-input placeholder="请输入验证码"
v-model.trim="loginForm.captcha"
@keyup.enter.native="submit"
>
@keyup.enter.native="submit">
</el-input>
<img @click="getVerImg" :src="verificationIMG" class="verification" alt="">
<img @click="getVerImg"
:src="verificationIMG"
class="verification"
alt="">
</div>
<!-- <div class="forget">忘记密码</div> -->
<el-button class="submit" type="primary" @click="submit">登录</el-button>
<el-button class="submit"
type="primary"
@click="submit">登录</el-button>
</div>
<div class="home">
<img src="@/assets/images/home.png" alt="">
<img src="@/assets/images/home.png"
alt="">
回到官网
</div>
</div>
</template>
<script>
import { mapMutations } from 'vuex'
import util from '@/libs/util'
import Util from '@/libs/util'
import Setting from '@/setting'
import addRoutes from '@/libs/route/addRoutes'
export default {
data: function() {
data: function () {
return {
loginForm: {
username: "",
@ -66,10 +70,10 @@ export default {
phoneBtnText: "发送验证码"
};
},
mounted() {
mounted () {
this.getVerImg()
//
this.$once("hook:beforeDestroy", function() {
this.$once("hook:beforeDestroy", function () {
clearInterval(this.phoneTimer)
this.phoneTimer = null
})
@ -79,15 +83,15 @@ export default {
'setUserId', 'setUserName', 'setAvatar'
]),
//
getVerImg() {
getVerImg () {
this.loginForm.random = Math.floor(Math.random() * 999999999);
this.verificationIMG = this.api.verification + "?random=" + `${this.loginForm.random}`;
},
submit() {
this.$post(this.api.logins, this.loginForm).then(({ data }) => {
util.local.set(Setting.tokenKey, data.accessToken, Setting.tokenExpires)
submit () {
this.$post(this.api.logins, Util.rsa(this.loginForm)).then(({ data }) => {
Util.local.set(Setting.tokenKey, data.accessToken, Setting.tokenExpires)
addRoutes(data.permissionList[0].children)
util.successMsg('登录成功')
Util.successMsg('登录成功')
this.setUserId(data.id || 1)
this.setUserName(data.username)
this.setAvatar(data.userAvatars)
@ -97,7 +101,7 @@ export default {
this.loginForm.captcha = ''
})
},
phoneCountdown() {
phoneCountdown () {
let count = 60;
if (!this.phoneTimer) {
this.phoneDisabled = true;
@ -115,9 +119,9 @@ export default {
}, 1000);
}
},
sendPhoneCode() {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
sendPhoneCode () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
let data = {
platform: Setting.platformId,
phone: this.phone,
@ -128,14 +132,14 @@ export default {
this.phoneCountdown();
this.phoneOpener = res.message.opener;
} else {
util.errorMsg(res.message);
Util.errorMsg(res.message);
}
}).catch(res => {});
}).catch(res => { });
},
phoneSubmit() {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return util.warningMsg("请输入验证码");
phoneSubmit () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return Util.warningMsg("请输入验证码");
let data = {
phone: this.phone,
types: 2,
@ -145,14 +149,14 @@ export default {
username: this.loginForm.username
};
this.$post(this.api.bindPhoneOrEmail, data).then(res => {
util.successMsg("绑定成功");
Util.successMsg("绑定成功");
this.loginForm.phone = this.phone;
this.phoneVisible = false;
util.local.set(Setting.tokenKey, res.token, Setting.tokenExpires);
Util.local.set(Setting.tokenKey, res.token, Setting.tokenExpires);
let redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : "/index";
this.$router.replace(redirect);
util.successMsg("登录成功");
Util.successMsg("登录成功");
this.queryCustomer();
}).catch(res => {
});
@ -170,7 +174,7 @@ export default {
.left-bg {
width: 420px;
height: 100%;
background: url(../../../assets/images/login-bg1.png) 0 0/cover no-repeat;
background: url(../../../assets/images/login-bg1.png) 0 0 / cover no-repeat;
.logo {
display: flex;
align-items: center;
@ -178,7 +182,7 @@ export default {
font-size: 20px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
color: #ffffff;
}
img {
margin-right: 10px;
@ -192,7 +196,7 @@ export default {
padding: 75px 30px 85px;
transform: translateY(-50%);
background-color: #fff;
box-shadow: 0px 4px 20px 0px rgba(203,209,218,0.15);
box-shadow: 0px 4px 20px 0px rgba(203, 209, 218, 0.15);
border-radius: 8px;
.title {
margin-bottom: 36px;
@ -206,7 +210,7 @@ export default {
position: relative;
margin-bottom: 23px;
border-radius: 4px;
border: 1px solid #D9DDEB;
border: 1px solid #d9ddeb;
label {
z-index: 2;
position: absolute;
@ -214,8 +218,8 @@ export default {
width: 46px;
height: 100%;
border-radius: 4px 0px 0px 4px;
border-right: 1px solid #D9DDEB;
background: #F7F9FC url(../../../assets/images/phone.png) center center/auto no-repeat;
border-right: 1px solid #d9ddeb;
background: #f7f9fc url(../../../assets/images/phone.png) center center/auto no-repeat;
}
.pw {
background-image: url(../../../assets/images/pw.png);

@ -4,10 +4,11 @@
<ul class="filter">
<li>
<label>站点选择</label>
<el-select v-model="form.site" @change="initData">
<el-option label="不限" value=""></el-option>
<el-option
v-for="item in sites"
<el-select v-model="form.site"
@change="initData">
<el-option label="不限"
value=""></el-option>
<el-option v-for="item in sites"
:key="item.id"
:label="item.siteName"
:value="item.siteName">
@ -16,9 +17,9 @@
</li>
<li>
<label>文件类型</label>
<el-select v-model="form.type" @change="initData">
<el-option
v-for="item in types"
<el-select v-model="form.type"
@change="initData">
<el-option v-for="item in types"
:key="item.name"
:label="item.name"
:value="item.name">
@ -29,64 +30,110 @@
</div>
<div class="tool">
<div class="search-wrap">
<el-select v-model="field" @change="initData">
<el-option
v-for="(item, i) in keywords"
<el-select v-model="field"
@change="initData">
<el-option v-for="(item, i) in keywords"
:key="i"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-input class="keyword" :placeholder="'请输入' + keywords.find(e => e.id === field).name" v-model.trim="keyword" clearable></el-input>
<el-input class="keyword"
:placeholder="'请输入' + keywords.find(e => e.id === field).name"
v-model.trim="keyword"
clearable></el-input>
</div>
<div class="actions">
<el-button v-auth @click="batchDel">删除</el-button>
<el-button v-auth
@click="batchDel">删除</el-button>
</div>
</div>
<el-table ref="table" :data="list" class="table" header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column type="selection" width="50" align="center" :reserve-selection="true" :selectable="row => !row.quote"></el-table-column>
<el-table-column type="index" width="60" label="ID"></el-table-column>
<el-table-column prop="site" label="站点" min-width="180"></el-table-column>
<el-table-column prop="quote" label="文章名称" min-width="180" show-overflow-tooltip>
<el-table ref="table"
:data="list"
class="table"
header-align="center"
@selection-change="handleSelectionChange"
row-key="id">
<el-table-column type="selection"
width="50"
align="center"
:reserve-selection="true"
:selectable="row => !row.quote"></el-table-column>
<el-table-column type="index"
width="60"
label="ID"></el-table-column>
<el-table-column prop="site"
label="站点"
min-width="180"></el-table-column>
<el-table-column prop="quote"
label="文章名称"
min-width="180"
show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.quote || '--' }}
</template>
</el-table-column>
<el-table-column prop="fileName" label="名称" min-width="180" show-overflow-tooltip></el-table-column>
<el-table-column prop="type" label="文件类型" min-width="80"></el-table-column>
<el-table-column prop="format" label="格式" min-width="80"></el-table-column>
<el-table-column prop="fileSize" label="大小" min-width="80">
<el-table-column prop="fileName"
label="名称"
min-width="180"
show-overflow-tooltip></el-table-column>
<el-table-column prop="type"
label="文件类型"
min-width="80"></el-table-column>
<el-table-column prop="format"
label="格式"
min-width="80"></el-table-column>
<el-table-column prop="fileSize"
label="大小"
min-width="80">
<template slot-scope="scope">
{{ (scope.row.fileSize / 1000).toFixed(2) }}kb
</template>
</el-table-column>
<el-table-column prop="createDate" label="上传时间" min-width="150"></el-table-column>
<el-table-column prop="uploader" label="上传人" min-width="100"></el-table-column>
<el-table-column prop="deleted" label="是否使用" min-width="100">
<el-table-column prop="createDate"
label="上传时间"
min-width="150"></el-table-column>
<el-table-column prop="uploader"
label="上传人"
min-width="100"></el-table-column>
<el-table-column prop="deleted"
label="是否使用"
min-width="100">
<template slot-scope="scope">
{{ scope.row.quote ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column label="操作" width="150">
<el-table-column label="操作"
width="150">
<template slot-scope="scope">
<el-button type="text" @click="show(scope.row, 'edit')">查看</el-button>
<el-button v-auth type="text" :disabled="scope.row.quote !== ''" @click="del(scope.row)">删除</el-button>
<el-button v-auth type="text" @click="download(scope.row)">下载</el-button>
<el-button type="text"
@click="show(scope.row, 'edit')">查看</el-button>
<el-button v-auth
type="text"
:disabled="scope.row.quote !== ''"
@click="del(scope.row)">删除</el-button>
<el-button v-auth
type="text"
@click="download(scope.row)">下载</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background layout="total, prev, pager, next" :total="total" @current-change="handleCurrentChange" :current-page="page"></el-pagination>
<el-pagination background
layout="total, prev, pager, next"
:total="total"
@current-change="handleCurrentChange"
:current-page="page"></el-pagination>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
import util from '@/libs/util'
import Util from '@/libs/util'
export default {
data() {
data () {
return {
sites: [],
types: [
@ -136,14 +183,14 @@ export default {
])
},
watch: {
keyword: function(val) {
keyword: function (val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initData()
}, 500)
}
},
mounted() {
mounted () {
this.$store.commit('user/setCrumbs', [
{
name: '附件管理'
@ -153,7 +200,7 @@ export default {
this.getSite()
},
methods: {
getData() {
getData () {
const { form } = this
this.$post(this.api.listByPage, {
page: this.page,
@ -166,64 +213,64 @@ export default {
}).then(({ data }) => {
this.list = data.records
this.total = +data.total
}).catch(err => {})
}).catch(err => { })
},
//
getSite() {
getSite () {
this.$post(this.api.site, {
page: 1,
limit: 1000,
siteName: ''
}).then(({ data }) => {
this.sites = util.getSite(data.records)
}).catch(e => {})
this.sites = Util.getSite(data.records)
}).catch(e => { })
},
initData() {
initData () {
this.$refs.table.clearSelection()
this.page = 1
this.getData()
},
//
show(row) {
show (row) {
const format = row.format
window.open((util.isDoc(format) ? 'https://view.officeapps.live.com/op/view.aspx?src=' : '') + row.url)
window.open((Util.isDoc(format) ? 'https://view.officeapps.live.com/op/view.aspx?src=' : '') + row.url)
},
//
download(row) {
util.downloadFile(row.fileName, row.url)
download (row) {
Util.downloadFile(row.fileName, row.url)
},
//
del(row) {
del (row) {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$del(`${this.api.delFile}`, [row.id]).then(res => {
util.successMsg('删除成功')
this.$post(this.api.delFile, Util.rsa([row.id])).then(res => {
Util.successMsg('删除成功')
this.getData()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
//
batchDel() {
batchDel () {
const list = this.multipleSelection
if (list.length) {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$del(`${this.api.delFile}`, list.map(e => e.id)).then(res => {
this.$del(this.api.delFile, Util.rsa(list.map(e => e.id))).then(res => {
this.$refs.table.clearSelection()
util.successMsg('删除成功')
Util.successMsg('删除成功')
this.getData()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
} else {
util.errorMsg('请先选择数据 !')
Util.errorMsg('请先选择数据 !')
}
},
handleSelectionChange(val) {
handleSelectionChange (val) {
this.multipleSelection = val
},
handleCurrentChange(val) {
handleCurrentChange (val) {
this.page = val
this.$router.push(`list?page=${val}`)
this.getData()
@ -233,5 +280,4 @@ export default {
</script>
<style lang="scss" scoped>
</style>

@ -893,7 +893,8 @@ export default {
labels: [],
labelVisible: false,
originalName: '',
originColumnId: ''
originColumnId: '',
repeatMsg: '',
};
},
computed: {
@ -1011,13 +1012,13 @@ export default {
},
//
getList () {
this.$post(this.api.listWithTree, {
this.$post(this.api.listWithTree, Util.rsa({
siteId: this.site.id,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
}).then(({ data }) => {
})).then(({ data }) => {
this.columns = data
let { columnId } = this.$route.query
// idid
@ -1049,20 +1050,20 @@ export default {
const inner = this.form.connectionType === 1
const id = inner ? this.links[this.links.length - 1] : this.otherLink[this.otherLink.length - 1]
this[inner ? 'article' : 'otherArticle'] = ''
this.$post(this.api.queryArticle, {
this.$post(this.api.queryArticle, Util.rsa({
siteId: inner ? this.site.id : this.form.siteSelection,
columnIds: [id],
pageNum: 1,
pageSize: 1000,
title: '',
isDisable: 0
}).then(({ data }) => {
})).then(({ data }) => {
this[inner ? 'articles' : 'otherArticles'] = data.records.filter(e => e.isRelease) //
}).catch(err => { })
},
//
getData () {
this.$post(`${this.api.findArticle}?id=${this.form.id}`).then(({ data }) => {
this.$post(this.api.findArticle, Util.rsa(this.form.id)).then(({ data }) => {
data.lableId = data.lableId ? data.lableId.split(',').map(e => +e) : []
// if (data.activityStartTime && data.activityEndTime) data.time = [data.activityStartTime, data.activityEndTime]
//
@ -1079,14 +1080,14 @@ export default {
const article = columnArticle[1] || '' // ididlinkAddress-
const { connectionType } = data
//
this.$post(this.api.queryArticle, {
this.$post(this.api.queryArticle, Util.rsa({
siteId: connectionType === 1 ? this.site.id : data.siteSelection,
columnIds: [column[column.length - 1]], // ididid
pageNum: 1,
pageSize: 1000,
title: '',
isDisable: 0
}).then(res => {
})).then(res => {
this[connectionType === 1 ? 'articles' : 'otherArticles'] = res.data.records
// /
if (connectionType === 1) {
@ -1118,7 +1119,7 @@ export default {
},
//
getColumn () {
this.$post(`${this.api.findColumn}?id=${this.$route.query.columnId}`).then(({ data }) => {
this.$post(this.api.findColumn, Util.rsa(this.$route.query.columnId)).then(({ data }) => {
this.columnInfo = data
const { form } = this
// /23
@ -1181,13 +1182,13 @@ export default {
},
//
getOtherColumn (val) {
this.$post(this.api.listWithTree, {
this.$post(this.api.listWithTree, Util.rsa({
siteId: this.form.siteSelection,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
}).then(({ data }) => {
})).then(({ data }) => {
if (val) {
this.otherArticles = []
this.otherArticle = ''
@ -1208,7 +1209,10 @@ export default {
},
//
getClassification () {
this.$post(`${this.api.queryClassif}?siteId=${this.site.id}&templateId=${this.columnInfo.templateId}`).then(({ data }) => {
this.$post(this.api.queryClassif, Util.rsa({
siteId: this.site.id,
templateId: this.columnInfo.templateId
})).then(({ data }) => {
this.classifications = data
}).catch(err => { })
},
@ -1234,7 +1238,7 @@ export default {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$post(`${this.api.delClassif}?id=${row.id}`).then(res => {
this.$post(this.api.delClassif, Util.rsa(row.id)).then(res => {
Util.successMsg('删除成功')
this.getClassification()
}).catch(res => { })
@ -1246,15 +1250,19 @@ export default {
//
submitClass (row, showMsg = 1) {
if (!row.classificationName) return Util.errorMsg('请输入分类名称')
this.$post(`${this.api.checkClassif}?classificationName=${row.classificationName}&siteId=${this.site.id}&classificationId=${row.id}`).then(res => {
this.$post(this.api[row.id ? 'updateClassif' : 'saveClassif'], {
this.$post(this.api.checkClassif, Util.rsa({
classificationName: row.classificationName,
siteId: this.site.id,
classificationId: row.id
})).then(res => {
this.$post(this.api[row.id ? 'updateClassif' : 'saveClassif'], Util.rsa({
classificationName: row.classificationName,
templateId: this.columnInfo.templateId,
id: row.id,
siteId: this.site.id,
editorId: this.userId,
founderId: this.userId
}).then(res => {
})).then(res => {
showMsg && Util.successMsg((row.id ? '修改' : '新增') + '成功')
this.getClassification()
}).catch(res => { })
@ -1282,7 +1290,7 @@ export default {
//
getLabel () {
this.$post(`${this.api.queryLabel}?siteId=${this.site.id}`).then(({ data }) => {
this.$post(this.api.queryLabel, Util.rsa(this.site.id)).then(({ data }) => {
this.labels = data
}).catch(err => { })
},
@ -1308,7 +1316,7 @@ export default {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$post(`${this.api.delLabel}?id=${row.id}`).then(res => {
this.$post(this.api.delLabel, Util.rsa(row.id)).then(res => {
Util.successMsg('删除成功')
this.getLabel()
}).catch(res => { })
@ -1320,14 +1328,18 @@ export default {
//
submitLabel (row, showMsg = 1) {
if (!row.labelName) return Util.errorMsg('请输入主题名称')
this.$post(`${this.api.checkLabel}?labelName=${row.labelName}&siteId=${this.site.id}&labelId=${row.id}`).then(res => {
this.$post(this.api[row.id ? 'updateLabel' : 'saveLabel'], {
this.$post(this.api.checkLabel, Util.rsa({
labelName: row.labelName,
siteId: this.site.id,
labelId: row.id,
})).then(res => {
this.$post(this.api[row.id ? 'updateLabel' : 'saveLabel'], Util.rsa({
labelName: row.labelName,
id: row.id,
siteId: this.site.id,
editorId: this.userId,
founderId: this.userId
}).then(res => {
})).then(res => {
showMsg && Util.successMsg((row.id ? '修改' : '新增') + '成功')
this.getLabel()
}).catch(res => { })
@ -1356,16 +1368,19 @@ export default {
nameChange () {
const { title, level, id } = this.form
if (title && title !== this.originalName) {
this.$post(this.api.checkIfTheTitleIsRepeat, {
this.$post(this.api.checkIfTheTitleIsRepeat, Util.rsa({
siteId: this.site.id,
title,
id: id || ''
}).then(res => {
})).then(res => {
this.repeatMsg = ''
this.nameRepeat = false
}).catch(res => {
if (res.msg) this.repeatMsg = res.msg
this.nameRepeat = true
})
} else {
this.repeatMsg = ''
this.nameRepeat = false
}
},
@ -1454,7 +1469,7 @@ export default {
},
//
handleRemove (e, fileList) {
e.id ? this.$post(`${this.api.delContentFile}?id=${e.id}`).then(res => {
e.id ? this.$post(this.api.delContentFile, Util.rsa(e.id)).then(res => {
this.form.fileList = fileList
}).catch(res => { }) : (this.form.fileList = fileList)
},
@ -1497,14 +1512,14 @@ export default {
uploadSuccessFile (res) {
this.uploading--
this.form.id ?
this.$post(this.api.saveContentFile, {
this.$post(this.api.saveContentFile, Util.rsa({
contentId: this.form.id,
editorId: this.userId,
founderId: this.userId,
id: '',
fileName: res.original,
filePath: res.url
}).then(({ data }) => {
})).then(({ data }) => {
this.form.fileList.push({
name: res.original,
url: res.url,
@ -1554,7 +1569,7 @@ export default {
if (this.submiting) return false
const form = JSON.parse(JSON.stringify(this.form))
if (!form.title) return Util.errorMsg('请填写标题')
if (this.nameRepeat) return Util.errorMsg('该标题已重复!')
if (this.nameRepeat) return Util.errorMsg(this.repeatMsg)
if (typeof form.fatherId === 'object') form.fatherId = form.fatherId[form.fatherId.length - 1]
const tId = form.articleTemplate
//

@ -193,7 +193,7 @@
<script>
import Setting from '@/setting'
import util from '@/libs/util'
import Util from '@/libs/util'
import { mapMutations } from 'vuex'
import ColumnConst from '@/const/column'
export default {
@ -319,13 +319,13 @@ export default {
]),
//
getColumn () {
this.$post(this.api.listWithTree, {
this.$post(this.api.listWithTree, Util.rsa({
siteId: this.$store.state.content.site.id,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
}).then(({ data }) => {
})).then(({ data }) => {
this.columns = data
this.$nextTick(() => {
this.$refs.column.setCurrentKey(this.$route.query.columnId || data[0].id)
@ -351,7 +351,7 @@ export default {
}
if (this.modifiedTimeSort !== '') data.modifiedTimeSort = this.modifiedTimeSort
if (this.publicationTimeSort !== '') data.publicationTimeSort = this.publicationTimeSort
this.$post(this.api.queryArticle, data).then(({ data }) => {
this.$post(this.api.queryArticle, Util.rsa(data)).then(({ data }) => {
data.records.map(e => {
e.editing = false
e.releaseTime = e.releaseTime.split(' ')[0]
@ -388,8 +388,8 @@ export default {
//
submitSequence (row) {
const { sequence } = row
if (!sequence) return util.errorMsg('请输入排序')
if (isNaN(sequence)) return util.errorMsg('请输入数字')
if (!sequence) return Util.errorMsg('请输入排序')
if (isNaN(sequence)) return Util.errorMsg('请输入数字')
this.$post(`${this.api.modifiedSort}?articleId=${row.id}&sequenceNumber=${sequence > this.total ? this.total : sequence}`).then(res => {
this.initData()
}).catch(res => { })
@ -408,18 +408,14 @@ export default {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
const data = []
list.map(e => {
data.push('ids=' + e.id)
})
this.$post(`${this.api.deleteArticle}?${data.join('&')}`).then(res => {
this.$post(this.api.deleteArticle, Util.rsa(list.map(e => e.id))).then(res => {
this.$refs.table.clearSelection()
util.successMsg("删除成功")
Util.successMsg("删除成功")
this.getData()
}).catch(res => { })
}).catch(() => { })
} else {
util.errorMsg('请先选择数据 !')
Util.errorMsg('请先选择数据 !')
}
},
//
@ -427,19 +423,22 @@ export default {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$post(`${this.api.deleteArticle}?ids=${row.id}`).then(res => {
util.successMsg('删除成功')
this.$post(this.api.deleteArticle, Util.rsa([row.id])).then(res => {
Util.successMsg('删除成功')
this.getData()
}).catch(res => { })
}).catch(() => { })
},
//
switchOff (val, row) {
this.$post(`${this.api.articleEnableOrDisable}?id=${row.id}&isDisable=${val}`).then(res => { }).catch((res) => { })
this.$post(this.api.articleEnableOrDisable, Util.rsa({
id: row.id,
isDisable: val
})).then(res => { }).catch((res) => { })
},
//
add () {
if (!this.columns.length) return util.errorMsg('请添加栏目')
if (!this.columns.length) return Util.errorMsg('请添加栏目')
this.setColumn(this.$refs.column.getCurrentNode())
this.$router.push(`add?columnId=${this.$refs.column.getCurrentKey()}&columnName=${this.$refs.column.getCurrentNode().columnName}`)
},
@ -474,7 +473,10 @@ export default {
},
//
sticky (row) {
this.$post(`${this.api.articleTopOperation}?articleId=${row.id}&isTop=${row.isTop ? 0 : 1}`).then(res => {
this.$post(this.api.articleTopOperation, Util.rsa({
articleId: row.id,
isTop: row.isTop ? 0 : 1
})).then(res => {
this.initData()
}).catch(res => { })
},

@ -439,20 +439,20 @@ export default {
const inner = this.form.connectionType === 1
const id = inner ? this.links[this.links.length - 1] : this.otherLink[this.otherLink.length - 1]
this[inner ? 'article' : 'otherArticle'] = ''
this.$post(this.api.queryArticle, {
this.$post(this.api.queryArticle, Util.rsa({
siteId: inner ? this.site.id : this.form.siteSelection,
columnIds: [id],
pageNum: 1,
pageSize: 1000,
title: '',
isDisable: 0
}).then(({ data }) => {
})).then(({ data }) => {
this[inner ? 'articles' : 'otherArticles'] = data.records.filter(e => e.isRelease) //
}).catch(err => { })
},
//
getData () {
this.$post(`${this.api.findColumn}?id=${this.form.id}`).then(({ data }) => {
this.$post(this.api.findColumn, Util.rsa(this.form.id)).then(({ data }) => {
this.form = data
if (data.typeId === 1 || data.typeId === 4) this.getStyle(0)
this.originTypeId = data.typeId

@ -216,7 +216,7 @@
<script>
import Setting from '@/setting'
import ColumnConst from '@/const/column'
import util from '@/libs/util'
import Util from '@/libs/util'
export default {
data () {
return {
@ -311,13 +311,13 @@ export default {
},
methods: {
getData () {
this.$post(this.api.listWithTree, {
this.$post(this.api.listWithTree, Util.rsa({
siteId: this.siteId,
columnName: this.keyword,
templateId: '',
typeId: '',
isSort: 1
}).then(({ data }) => {
})).then(({ data }) => {
this.list = data
this.listLoading = false
}).catch(err => {
@ -326,7 +326,7 @@ export default {
},
// id
getStyle () {
this.$post(`${this.api.theTemplateIdGetsTheStyle}?templateId=${this.form.templateId}`).then(({ data }) => {
this.$post(this.api.theTemplateIdGetsTheStyle, Util.rsa(this.form.templateId)).then(({ data }) => {
this.listStyle = data.listingTemplateTypes
this.detailStyle = data.detailsTypeOfTheTemplate
}).catch(err => { })
@ -351,8 +351,8 @@ export default {
this.$confirm("删除栏目将会同时把栏目下的文章一并删除,是否确认删除栏目?", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.deleteColumn}?ids=${row.id}`).then(res => {
util.successMsg("删除成功")
this.$post(this.api.deleteColumn, Util.rsa([row.id])).then(res => {
Util.successMsg("删除成功")
this.getData()
}).catch(res => { })
}).catch(() => { })
@ -377,18 +377,14 @@ export default {
this.$confirm('删除栏目将会同时把栏目下的文章一并删除,是否确认删除栏目?', '提示', {
type: 'warning'
}).then(() => {
const data = []
list.map(e => {
data.push('ids=' + e.id)
})
this.$post(`${this.api.deleteColumn}?${data.join('&')}`).then(res => {
this.$post(this.api.deleteColumn, Util.rsa(list.map(e => e.id))).then(res => {
this.$refs.table.clearSelection()
util.successMsg("删除成功")
Util.successMsg("删除成功")
this.getData()
}).catch(res => { })
}).catch(() => { })
} else {
util.errorMsg('请先选择数据 !')
Util.errorMsg('请先选择数据 !')
}
},
handleSelectionChange (val) {
@ -414,13 +410,13 @@ export default {
sort () {
this.$post(this.api.deleteUselessData).then(res => { }).catch(err => { })
this.$post(this.api.listWithTree, {
this.$post(this.api.listWithTree, Util.rsa({
siteId: this.siteId,
columnName: '',
templateId: '',
typeId: '',
isSort: 1
}).then(({ data }) => {
})).then(({ data }) => {
this.sortColumns = data
}).catch(err => { })
this.sortVisible = true
@ -445,8 +441,8 @@ export default {
sortSubmit () {
const result = []
this.sortList(this.sortColumns, result)
this.$post(this.api.sortByColumn, result).then(({ data }) => {
util.successMsg('修改成功')
this.$post(this.api.sortByColumn, Util.rsa(result)).then(({ data }) => {
Util.successMsg('修改成功')
this.sortVisible = false
this.getData()
}).catch(err => { })
@ -454,13 +450,13 @@ export default {
//
styleSet () {
this.styleVisible = true
this.$post(`${this.api.searchAllBySite}?siteId=${this.siteId}`).then(({ data }) => {
this.$post(this.api.searchAllBySite, Util.rsa(this.siteId)).then(({ data }) => {
// id
if (data.length) {
this.form = data[0]
} else {
this.$post(this.api.saveStyle, this.form).then(res => {
this.$post(`${this.api.searchAllBySite}?siteId=${this.siteId}`).then(({ data }) => {
this.$post(this.api.searchAllBySite, Util.rsa(this.siteId)).then(({ data }) => {
this.form = data[0]
}).catch(res => { })
}).catch(res => { })
@ -470,7 +466,7 @@ export default {
//
styleSubmit () {
this.$post(this.api.updateStyle, this.form).then(res => {
util.successMsg('修改成功')
Util.successMsg('修改成功')
this.styleVisible = false
}).catch(res => { })
}

@ -2,43 +2,92 @@
<div class="page">
<div class="tool">
<div class="search-wrap">
<el-input placeholder="请输入角色名称" v-model.trim="keyword" clearable></el-input>
<el-input placeholder="请输入角色名称"
v-model.trim="keyword"
clearable></el-input>
</div>
<div class="actions">
<el-button v-auth type="primary" @click="addRole">新增</el-button>
<el-button v-auth="'批量删除'" @click="batchDel">删除</el-button>
<el-button v-auth
type="primary"
@click="addRole">新增</el-button>
<el-button v-auth="'批量删除'"
@click="batchDel">删除</el-button>
</div>
</div>
<el-table :data="list" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column type="selection" width="55" align="center" :reserve-selection="true" :selectable="row => row.name !== '超级管理员'"></el-table-column>
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="name" label="角色名称" align="center" min-width="250" show-overflow-tooltip></el-table-column>
<el-table-column prop="description" label="角色描述" min-width="400" align="center"></el-table-column>
<el-table-column label="操作" align="center" width="200">
<el-table :data="list"
class="table"
ref="table"
stripe
header-align="center"
@selection-change="handleSelectionChange"
row-key="id">
<el-table-column type="selection"
width="55"
align="center"
:reserve-selection="true"
:selectable="row => row.name !== '超级管理员'"></el-table-column>
<el-table-column type="index"
width="60"
label="序号"
align="center"></el-table-column>
<el-table-column prop="name"
label="角色名称"
align="center"
min-width="250"
show-overflow-tooltip></el-table-column>
<el-table-column prop="description"
label="角色描述"
min-width="400"
align="center"></el-table-column>
<el-table-column label="操作"
align="center"
width="200">
<template slot-scope="scope">
<el-button v-auth type="text" @click="showRole(scope.row)">查看</el-button>
<el-button v-auth v-if="scope.row.name !== '超级管理员'" type="text" @click="editRole(scope.row)">编辑</el-button>
<el-button v-auth v-if="scope.row.name !== '超级管理员'" type="text" @click="handleDelete(scope.row)">删除</el-button>
<el-button v-auth
type="text"
@click="showRole(scope.row)">查看</el-button>
<el-button v-auth
type="text"
@click="editRole(scope.row)">编辑</el-button>
<el-button v-auth
v-if="scope.row.name !== '超级管理员'"
type="text"
@click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
<el-pagination background
@current-change="currentChange"
:current-page="page"
layout="total, prev, pager, next"
:total="total"></el-pagination>
</div>
<el-dialog :title="isDetail ? '查看角色' : (isAdd ? '新增角色' : '编辑角色')" :visible.sync="roleVisible" width="30%" @close="closeRole" class="dialog" :close-on-click-modal="false">
<el-form ref="form" label-width="80px" :disabled="isDetail">
<el-dialog :title="isDetail ? '查看角色' : (isAdd ? '新增角色' : '编辑角色')"
:visible.sync="roleVisible"
width="30%"
@close="closeRole"
class="dialog"
:close-on-click-modal="false">
<el-form ref="form"
label-width="80px"
:disabled="isDetail">
<el-form-item label="角色名称">
<el-input v-model="form.name" placeholder="请输入角色名称"></el-input>
<el-input v-model="form.name"
placeholder="请输入角色名称"></el-input>
</el-form-item>
<el-form-item label="角色描述">
<el-input v-model="form.description" placeholder="请输入角色描述" type="textarea" rows="5"></el-input>
<el-input v-model="form.description"
placeholder="请输入角色描述"
type="textarea"
rows="5"></el-input>
</el-form-item>
<el-form-item prop="role" label="角色权限">
<el-form-item prop="role"
label="角色权限">
<div style="max-height: 300px; overflow: auto">
<el-tree
ref="per"
<el-tree ref="per"
:data="permissions"
show-checkbox
default-expand-all
@ -50,19 +99,22 @@
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<span slot="footer"
class="dialog-footer"
v-if="!isDetail">
<el-button @click="roleVisible = false"> </el-button>
<el-button type="primary" @click="saveData"> </el-button>
<el-button type="primary"
@click="saveData"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import util from "@/libs/util";
import Util from "@/libs/util";
import Setting from "@/setting";
export default {
data() {
data () {
return {
keyword: "",
isDetail: false,
@ -88,14 +140,14 @@ export default {
};
},
watch: {
keyword: function(val) {
keyword: function (val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initData()
}, 500)
}
},
mounted() {
mounted () {
this.$store.commit('user/setCrumbs', [
{
name: '用户管理'
@ -107,58 +159,59 @@ export default {
this.getData()
},
methods: {
getData() {
this.$post(this.api.roles, {
getData () {
this.$post(this.api.roles, Util.rsa({
page: this.page,
limit: this.pageSize,
name: this.keyword,
}).then(({ data }) => {
const list = data.records.filter(e => e.id !== 1) //
})).then(({ data }) => {
// const list = data.records.filter(e => e.id !== 1) //
const list = data.records
this.list = list
this.total = data.total == 0 ? 0 : +data.total - 1
}).catch(res => {})
}).catch(res => { })
},
initData() {
initData () {
this.$refs.table.clearSelection()
this.page = 1
this.getData()
},
currentChange(val) {
currentChange (val) {
this.page = val
this.getData()
},
handleDelete(row) {
handleDelete (row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$del(this.api.deleteRole, [row.id]).then(res => {
util.successMsg("删除成功");
this.$post(this.api.deleteRole, Util.rsa([row.id])).then(res => {
Util.successMsg("删除成功");
this.getData()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
handleSelectionChange(val) {
handleSelectionChange (val) {
this.multipleSelection = val;
},
batchDel() {
batchDel () {
if (this.multipleSelection.length) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$del(this.api.deleteRole, this.multipleSelection.map(e => e.id)).then(res => {
this.$post(this.api.deleteRole, Util.rsa(this.multipleSelection.map(e => e.id))).then(res => {
this.$refs.table.clearSelection();
util.successMsg("删除成功");
Util.successMsg("删除成功");
this.getData();
}).catch(res => {});
if(this.multipleSelection.length === this.list.length && this.page>1) {
}).catch(res => { });
if (this.multipleSelection.length === this.list.length && this.page > 1) {
this.handleCurrentChange(this.page - 1)
}
}).catch(() => {});
}).catch(() => { });
} else {
util.errorMsg("请先选择数据!");
Util.errorMsg("请先选择数据!");
}
},
closeRole() {
closeRole () {
this.isDetail = false;
this.form = {
id: "",
@ -170,15 +223,15 @@ export default {
this.permissions = [];
},
//
getPer(row) {
getPer (row) {
if (!this.permissions.length) {
this.$get(this.api.perTree).then(({ data }) => {
this.permissions = data
row && this.getDetail(row)
}).catch(res => {})
}).catch(res => { })
}
},
addRole() {
addRole () {
this.isAdd = true
this.getPer()
this.checkedIds = []
@ -186,7 +239,7 @@ export default {
this.roleVisible = true
},
//
handleRolePer(data, permissions) {
handleRolePer (data, permissions) {
let result = data
if (permissions.length) {
permissions.map(e => {
@ -200,8 +253,8 @@ export default {
return result
},
//
async getDetail(row) {
this.$get(`${this.api.role}/${row.id}`).then(({ data }) => {
async getDetail (row) {
this.$post(this.api.role, Util.rsa(row.id)).then(({ data }) => {
const { role } = data
this.form.name = role.name
this.form.description = role.description
@ -210,46 +263,45 @@ export default {
// list[0] === '1' && list.shift() // 11
this.checkedIds = this.handleRolePer(list, this.permissions)
this.$refs.per.setCheckedNodes(this.checkedIds)
}).catch(err => {})
}).catch(err => { })
},
showRole(row) {
showRole (row) {
this.isDetail = true
this.isAdd = false
this.getPer(row)
this.roleVisible = true
},
editRole(row) {
editRole (row) {
this.isAdd = false
this.getPer(row)
this.roleVisible = true
},
async saveData() {
async saveData () {
const { form } = this
if (!form.name) return util.warningMsg("请填写角色名称")
if (!form.description) return util.warningMsg("请填写角色描述")
if (!form.name) return Util.warningMsg("请填写角色名称")
if (!form.description) return Util.warningMsg("请填写角色描述")
const checked = [...this.$refs.per.getHalfCheckedKeys(), ...this.$refs.per.getCheckedKeys()]
if (!checked.length) return util.warningMsg("请选择角色权限")
if (!checked.length) return Util.warningMsg("请选择角色权限")
let data = {
...form,
permissions: checked
}
if (form.id) {
this.$put(this.api.role, data).then(res => {
util.successMsg("修改成功")
this.$post(this.api.updateRole, Util.rsa(data)).then(res => {
Util.successMsg("修改成功")
this.getData()
this.roleVisible = false
}).catch(res => {})
}).catch(res => { })
} else {
this.$post(this.api.role, data).then(res => {
util.successMsg("新增成功")
this.$post(this.api.addRole, Util.rsa(data)).then(res => {
Util.successMsg("新增成功")
this.getData()
this.roleVisible = false
}).catch(res => {})
}).catch(res => { })
}
}
}
};
</script>
<style lang="scss" scoped>
</style>

@ -3,33 +3,47 @@
<div class="left">
<div class="inner">
<div class="text-center">
<img :src="avatar" class="avatar" />
<el-upload :action="this.api.updateUserAvatars" name="file" :data="{ userId }" :limit="10" :show-file-list="false" :headers="headers" :on-success="changeAvatar">
<el-button type="text" size="small">点击更换头像</el-button>
<img :src="avatar"
class="avatar" />
<el-upload :action="this.api.updateUserAvatars"
name="file"
:limit="10"
accept="image/*"
:show-file-list="false"
:headers="headers"
:before-upload="beforeUpload"
:on-success="changeAvatar">
<el-button type="text"
size="small">点击更换头像</el-button>
</el-upload>
</div>
<ul class="menu">
<li v-for="item in typeList" :key="item.index" :class="{active: item.index == active}">
<li v-for="item in typeList"
:key="item.index"
:class="{active: item.index == active}">
{{ item.title }}
</li>
</ul>
</div>
</div>
<info class="flex-1" ref="info" @updateStatus="updateStatus" @back="back"></info>
<info class="flex-1"
ref="info"
@updateStatus="updateStatus"
@back="back"></info>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import Setting from '@/setting'
import util from '@/libs/util'
import Util from '@/libs/util'
import info from './info'
export default {
data() {
data () {
return {
headers: {
token: util.local.get(Setting.tokenKey)
token: Util.local.get(Setting.tokenKey)
},
typeList: [
{
@ -48,8 +62,8 @@ export default {
]),
},
// ,
beforeRouteLeave(to, from, next) {
if(this.edited){
beforeRouteLeave (to, from, next) {
if (this.edited) {
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
}).then(() => {
@ -58,26 +72,34 @@ export default {
}).catch(() => {
next()
})
}else{
} else {
next()
}
},
mounted() {
mounted () {
},
methods: {
...mapMutations('user', [
'setAvatar'
]),
changeAvatar(res) {
//
beforeUpload (file) {
if (!Util.isImg(file.name.split('.').pop())) {
Util.warningMsg(`请上传图片!`)
return false
}
return true
},
changeAvatar (res) {
this.setAvatar(res.data)
},
updateStatus(status){
updateStatus (status) {
this.edited = status
},
//
back() {
if(this.edited){
back () {
if (this.edited) {
this.edited = false
this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', {
type: 'warning'
@ -87,7 +109,7 @@ export default {
}).catch(() => {
this.$router.back()
})
}else{
} else {
this.$router.back()
}
}
@ -96,31 +118,31 @@ export default {
</script>
<style lang="scss" scoped>
.main{
.main {
display: flex;
margin: 0 auto;
.left{
.left {
margin-right: 12px;
background-color: #fff;
box-shadow: 2px 0px 6px 0px #EEEEEE;
.inner{
box-shadow: 2px 0px 6px 0px #eeeeee;
.inner {
width: 170px;
padding: 20px 0;
}
.avatar{
.avatar {
width: 80px;
height: 80px;
border-radius: 50%;
}
.menu{
.menu {
margin-top: 32px;
li{
li {
padding: 0 20px;
color: #303133;
font-size: 14px;
line-height: 38px;
cursor: pointer;
&.active{
&.active {
color: #fff;
background-color: $main-color;
}

@ -1,127 +1,193 @@
<template>
<div class="relative" v-loading="loading">
<div class="relative"
v-loading="loading">
<div class="page">
<h6 class="l-title"><img src="@/assets/images/info1.png" alt=""> 基本信息</h6>
<h6 class="l-title"><img src="@/assets/images/info1.png"
alt=""> 基本信息</h6>
<div class="page-content">
<ul class="list">
<li>
<label>姓名</label>
<el-input placeholder="请输入姓名" type="text" v-model="form.realName" />
<el-input placeholder="请输入姓名"
type="text"
v-model="form.realName" />
</li>
<li>
<label>性别</label>
<el-select size="small" v-model="form.sex">
<el-option v-for="item in sexList" :key="item.value" :label="item.name" :value="item.value"></el-option>
<el-select size="small"
v-model="form.sex">
<el-option v-for="item in sexList"
:key="item.value"
:label="item.name"
:value="item.value"></el-option>
</el-select>
</li>
<li>
<label>账号</label>
<el-input class="m-r-10" type="text" size="small" v-model="form.username"></el-input>
<el-input class="m-r-10"
type="text"
size="small"
v-model="form.username"></el-input>
<!-- <el-button type="text" size="small" @click="showAccount">修改</el-button> -->
</li>
<li>
<label>工号</label>
<el-input size="small" v-model="form.jobNumber" clearable></el-input>
<el-input size="small"
v-model="form.jobNumber"
clearable></el-input>
</li>
<li>
<label>邮箱</label>
<el-input class="m-r-10" size="small" v-model="form.email"></el-input>
<el-input class="m-r-10"
size="small"
v-model="form.email"></el-input>
<!-- <el-button v-if="form.email" type="text" size="small" @click="bindEmail">更换</el-button>
<el-button v-else type="text" size="small" @click="bindEmail">添加</el-button> -->
</li>
<li>
<label>手机号</label>
<el-input class="m-r-10" type="text" size="small" maxlength="11" v-model="form.phone"></el-input>
<el-input class="m-r-10"
type="text"
size="small"
maxlength="11"
v-model="form.phone"></el-input>
<!-- <el-button type="text" size="small" @click="bindPhone">{{ form.phone ? '更换' : '绑定' }}</el-button>
<el-button v-if="form.phone" type="text" size="small" @click="unbind">解绑</el-button> -->
</li>
<li>
<label>密码</label>
<el-input class="m-r-10" size="small" value="******" disabled></el-input>
<el-button type="text" size="small" @click="bindPassword">修改</el-button>
<el-input class="m-r-10"
size="small"
value="******"
disabled></el-input>
<el-button type="text"
size="small"
@click="bindPassword">修改</el-button>
</li>
</ul>
</div>
<div class="btn-wrap">
<el-button size="small" v-throttle @click="$emit('back')">取消</el-button>
<el-button type="primary" size="small" v-throttle @click="submit">更新</el-button>
<el-button size="small"
@click="$emit('back')">取消</el-button>
<el-button type="primary"
size="small"
@click="submit">更新</el-button>
</div>
</div>
<el-dialog
:title="form.email ? '更换邮箱' : '绑定邮箱'"
<el-dialog :title="form.email ? '更换邮箱' : '绑定邮箱'"
:visible.sync="emailVisible"
:close-on-click-modal="false"
@close="closeEmail"
width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form ref="form"
:model="form"
label-width="60px">
<el-form-item label="邮箱">
<el-input placeholder="请输入邮箱" v-model="email"></el-input>
<el-input placeholder="请输入邮箱"
v-model="email"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<el-input v-model="emailCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendEmailCode" :disabled="emailDisabled">{{ emailBtnText }}</el-button>
<el-input v-model="emailCode"
placeholder="请输入验证码"
maxlength="6"></el-input>
<el-button style="margin-left: 10px"
type="text"
@click="sendEmailCode"
:disabled="emailDisabled">{{ emailBtnText }}</el-button>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<span slot="footer"
class="dialog-footer">
<el-button @click="emailVisible = false"> </el-button>
<el-button type="primary" @click="emailSubmit"> </el-button>
<el-button type="primary"
@click="emailSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog
:title="form.phone ? '更换手机号' : '绑定手机号'"
<el-dialog :title="form.phone ? '更换手机号' : '绑定手机号'"
:visible.sync="phoneVisible"
:close-on-click-modal="false"
@close="closePhone"
width="30%">
<el-form ref="form" :model="form" label-width="60px">
<el-form ref="form"
:model="form"
label-width="60px">
<el-form-item label="手机号">
<el-input style="width: 404px;" placeholder="请输入手机号" v-model="phone" maxlength="11"></el-input>
<el-input style="width: 404px;"
placeholder="请输入手机号"
v-model="phone"
maxlength="11"></el-input>
</el-form-item>
<el-form-item label="验证码">
<div class="flex-between">
<el-input v-model="phoneCode" placeholder="请输入验证码" maxlength="6"></el-input>
<el-button style="margin-left: 10px" type="text" @click="sendPhoneCode" :disabled="phoneDisabled">{{ phoneBtnText }}</el-button>
<el-input v-model="phoneCode"
placeholder="请输入验证码"
maxlength="6"></el-input>
<el-button style="margin-left: 10px"
type="text"
@click="sendPhoneCode"
:disabled="phoneDisabled">{{ phoneBtnText }}</el-button>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<span slot="footer"
class="dialog-footer">
<el-button @click="phoneVisible = false"> </el-button>
<el-button type="primary" @click="phoneSubmit"> </el-button>
<el-button type="primary"
@click="phoneSubmit"> </el-button>
</span>
</el-dialog>
<el-dialog
title="更换密码"
<el-dialog title="更换密码"
:visible.sync="pwdVisible"
:close-on-click-modal="false"
@close="closePassword"
width="30%">
<el-form ref="pwdForm" :model="form" label-width="60px">
<el-form ref="pwdForm"
:model="form"
label-width="60px">
<el-form-item label="原密码">
<el-input type="password" v-model="pwdForm.password" placeholder="请输入原密码"></el-input>
<el-input type="password"
v-model="pwdForm.password"
placeholder="请输入原密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.newPassword" placeholder="请输入新密码" @keyup.enter.native="editPassword"></el-input>
<el-input type="password"
v-model="pwdForm.newPassword"
placeholder="请输入新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="pwdForm.reNewPassword" placeholder="请确认新密码" @keyup.enter.native="editPassword"></el-input>
<el-input type="password"
v-model="pwdForm.reNewPassword"
placeholder="请确认新密码"
@keyup.enter.native="editPassword"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<span slot="footer"
class="dialog-footer">
<el-button @click="pwdVisible = false"> </el-button>
<el-button type="primary" @click="editPassword"> </el-button>
<el-button type="primary"
@click="editPassword"> </el-button>
</span>
</el-dialog>
<el-dialog title="修改账号" :visible.sync="accountVisible" :close-on-click-modal="false" width="30%">
<el-dialog title="修改账号"
:visible.sync="accountVisible"
:close-on-click-modal="false"
width="30%">
<el-form label-width="70px">
<el-form-item label="账号">
<el-input v-model="editUsername" placeholder="请输入账号"></el-input>
<el-input v-model="editUsername"
placeholder="请输入账号"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="accountVisible = false"> </el-button>
<el-button size="small" type="primary" @click="confirmAccount"> </el-button>
<span slot="footer"
class="dialog-footer">
<el-button size="small"
@click="accountVisible = false"> </el-button>
<el-button size="small"
type="primary"
@click="confirmAccount"> </el-button>
</span>
</el-dialog>
</div>
@ -129,16 +195,16 @@
<script>
import Setting from '@/setting'
import util from '@/libs/util'
import Util from '@/libs/util'
import { mapState, mapMutations } from 'vuex'
export default {
data() {
data () {
return {
loading: false,
editUsername: '',
accountVisible: false,
updateTime: 0,
token: util.local.get(Setting.tokenKey),
token: Util.local.get(Setting.tokenKey),
form: {
userName: "",
name: "",
@ -191,14 +257,14 @@ export default {
watch: {
// ,
form: {
handler(){
handler () {
this.updateTime++
if(this.updateTime > 1) this.$emit('updateStatus', this.updateTime > 1)
if (this.updateTime > 1) this.$emit('updateStatus', this.updateTime > 1)
},
deep:true
deep: true
}
},
mounted() {
mounted () {
this.getData()
},
methods: {
@ -206,80 +272,80 @@ export default {
'setUserName'
]),
//
getData() {
getData () {
this.loading = true
this.$get(`${this.api.user}/${this.userId}`).then(({ data }) => {
this.$post(this.api.queryUser, Util.rsa(this.userId)).then(({ data }) => {
this.form = data
this.loading = false
}).catch(err => {})
}).catch(err => { })
},
//
showAccount() {
showAccount () {
this.accountVisible = true
},
//
confirmAccount() {
confirmAccount () {
if (this.editUsername) {
form.username = this.editUsername
this.accountVisible = false
const { form } = this
this.$put(this.api.user, form).then(res => {
this.$post(this.api.updateUser, Util.rsa(form)).then(res => {
this.setUserName(form.username)
this.$message.success("提交成功!")
}).catch(res => {})
}).catch(res => { })
} else {
util.errorMsg('请输入账号')
Util.errorMsg('请输入账号')
}
},
bindEmail() {
bindEmail () {
this.email = this.form.email
this.emailVisible = true
},
bindPhone() {
bindPhone () {
this.phone = this.form.phone
this.phoneVisible = true
},
//
unbind() {
unbind () {
this.$confirm('确定要解绑该手机号吗?', '提示', {
type: 'warning'
}).then(() => {
this.$get(this.api.unbindMobilePhone).then(res => {
this.$message.success('解绑成功')
this.getData()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
bindPassword() {
bindPassword () {
this.pwdVisible = true
},
editPassword() {
editPassword () {
const data = this.pwdForm
if (!data.password) return util.warningMsg("请输入原密码")
if (!data.newPassword) return util.warningMsg("请输入新密码")
if (!data.reNewPassword) return util.warningMsg("请确认新密码")
if (data.newPassword.length < 6 || data.reNewPassword.length < 6) return util.warningMsg("请输入6位数以上的密码")
if (data.newPassword !== data.reNewPassword) return util.warningMsg("输入的新密码不一致,请重新确认")
if (data.password === data.newPassword) return util.warningMsg("原密码跟新密码不能一致")
if (!data.password) return Util.warningMsg("请输入原密码")
if (!data.newPassword) return Util.warningMsg("请输入新密码")
if (!data.reNewPassword) return Util.warningMsg("请确认新密码")
if (data.newPassword.length < 6 || data.reNewPassword.length < 6) return Util.warningMsg("请输入6位数以上的密码")
if (data.newPassword !== data.reNewPassword) return Util.warningMsg("输入的新密码不一致,请重新确认")
if (data.password === data.newPassword) return Util.warningMsg("原密码跟新密码不能一致")
this.$put(this.api.pwd, {
id: this.form.id,
oldPwd: data.password,
newPwd: data.newPassword
}).then(res => {
util.successMsg("更换成功")
Util.successMsg("更换成功")
this.pwdVisible = false
}).catch(err => {})
}).catch(err => { })
},
closePassword() {
closePassword () {
this.pwdForm = {
password: "",
newPassword: "",
reNewPassword: ""
}
},
submit() {
submit () {
const { form } = this
this.$put(this.api.user, {
this.$post(this.api.updateUser, Util.rsa({
id: form.id,
jobNumber: form.jobNumber,
phone: form.phone,
@ -287,13 +353,13 @@ export default {
username: form.username,
email: form.email,
sex: form.sex,
}).then(res => {
})).then(res => {
this.$emit('updateStatus', false)
this.setUserName(form.realName)
this.$message.success("提交成功!")
}).catch(res => {})
}).catch(res => { })
},
emailCountdown() {
emailCountdown () {
let count = 60;
if (!this.emailTimer) {
this.emailDisabled = true;
@ -311,7 +377,7 @@ export default {
}, 1000);
}
},
phoneCountdown() {
phoneCountdown () {
let count = 60;
if (!this.phoneTimer) {
this.phoneDisabled = true;
@ -329,14 +395,14 @@ export default {
}, 1000);
}
},
closeEmail() {
closeEmail () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendEmailCode() {
if (!this.email) return util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg("请输入正确的邮箱")
sendEmailCode () {
if (!this.email) return Util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return Util.warningMsg("请输入正确的邮箱")
this.$post(this.api.sendPhoneOrEmailCode, {
email: this.email,
types: 1
@ -345,14 +411,14 @@ export default {
this.emailCountdown();
this.emailOpener = res.message.opener;
} else {
util.errorMsg(res.message);
Util.errorMsg(res.message);
}
}).catch(res => {})
}).catch(res => { })
},
emailSubmit() {
if (!this.email) return util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return util.warningMsg("请输入正确的邮箱")
if (!this.emailCode) return util.warningMsg("请输入验证码")
emailSubmit () {
if (!this.email) return Util.warningMsg("请输入邮箱")
if (!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(this.email)) return Util.warningMsg("请输入正确的邮箱")
if (!this.emailCode) return Util.warningMsg("请输入验证码")
this.$put(this.api.bindPhoneOrEmail, {
userId: this.userId,
email: this.email,
@ -360,19 +426,19 @@ export default {
code: this.emailCode,
opener: this.emailOpener
}).then(res => {
util.successMsg("绑定成功")
Util.successMsg("绑定成功")
this.form.email = this.email
this.emailVisible = false
}).catch(res => {})
}).catch(res => { })
},
closePhone() {
closePhone () {
if (!this.emailDisabled) {
this.emailCode = "";
}
},
sendPhoneCode() {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
sendPhoneCode () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
let data = {
userId: this.userId,
phone: this.phone,
@ -383,15 +449,15 @@ export default {
this.phoneCountdown();
this.phoneOpener = res.message.opener;
} else {
util.errorMsg(res.message);
Util.errorMsg(res.message);
}
}).catch(res => {
});
},
phoneSubmit() {
if (!this.phone) return util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return util.warningMsg("请输入验证码");
phoneSubmit () {
if (!this.phone) return Util.warningMsg("请输入手机号");
if (!/^1[3456789]\d{9}$/.test(this.phone)) return Util.warningMsg("请输入正确的手机号");
if (!this.phoneCode) return Util.warningMsg("请输入验证码");
let data = {
userId: this.userId,
phone: this.phone,
@ -400,7 +466,7 @@ export default {
opener: this.phoneOpener
};
this.$post(this.api.bindPhoneOrEmail, data).then(res => {
util.successMsg("绑定成功");
Util.successMsg("绑定成功");
this.form.phone = this.phone;
this.phoneVisible = false;
}).catch(res => {
@ -424,22 +490,23 @@ export default {
margin-right: 5px;
}
}
.list{
.list {
.line {
display: flex;
margin-bottom: 24px;
}
.el-input, .el-select {
.el-input,
.el-select {
width: 220px;
.el-input__inner{
border-color: #CACFDB;
.el-input__inner {
border-color: #cacfdb;
}
}
li {
display: flex;
align-items: center;
margin-bottom: 20px;
&>label {
& > label {
width: 100px;
margin-right: 5px;
text-align: right;
@ -465,7 +532,7 @@ export default {
padding: 12px 0;
text-align: center;
background-color: #fff;
.el-button{
.el-button {
width: 80px;
}
}

@ -1,9 +1,11 @@
<template>
<div class="flex">
<div class="page" style="width: 300px;border-right: 1px solid #EBEDF0">
<div class="page"
style="width: 300px;border-right: 1px solid #EBEDF0">
<div class="m-b-20">
<p class="page-name mb">后台员工账号</p>
<el-radio-group v-model="staffType" @change="changeType">
<el-radio-group v-model="staffType"
@change="changeType">
<div class="m-b-20">
<el-radio :label="1">所有员工</el-radio>
</div>
@ -16,27 +18,50 @@
<div>
<div class="flex-between m-b-20">
<p class="page-name">组织管理</p>
<el-button v-auth="'新增部门'" type="text" @click="addOrg">添加</el-button>
<el-button v-auth="'新增部门'"
type="text"
@click="addOrg">添加</el-button>
</div>
<div style="height: 504px;overflow: auto;scrollbar-width: none;-ms-overflow-style: none;">
<el-tree class="org" ref="orgs" :data="orgs" :props="defaultProps" highlight-current :expand-on-click-node="false" default-expand-all node-key="id" @node-click="handleNodeClick">
<span class="node-wrap" slot-scope="{ node, data }">
<el-tree class="org"
ref="orgs"
:data="orgs"
:props="defaultProps"
highlight-current
:expand-on-click-node="false"
default-expand-all
node-key="id"
@node-click="handleNodeClick">
<span class="node-wrap"
slot-scope="{ node, data }">
<div class="left">
<img src="@/assets/images/node.png" alt="">
<img src="@/assets/images/node.png"
alt="">
<span class="name">{{ node.label }}</span>
</div>
<el-dropdown :hide-on-click="false">
<img class="expand" src="@/assets/images/expand.png" alt="">
<img class="expand"
src="@/assets/images/expand.png"
alt="">
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
<el-button v-auth class="org-btn" @click="() => editOrg(node, data)" type="text">编辑部门</el-button>
<el-button v-auth
class="org-btn"
@click="() => editOrg(node, data)"
type="text">编辑部门</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button v-auth="'新增部门'" class="org-btn add" @click="() => addOrg(node, data)" type="text">添加子部门</el-button>
<el-button v-auth="'新增部门'"
class="org-btn add"
@click="() => addOrg(node, data)"
type="text">添加子部门</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button v-auth="'删除部门'" class="org-btn del" @click="() => delOrg(node, data)" type="text">删除</el-button>
<el-button v-auth="'删除部门'"
class="org-btn del"
@click="() => delOrg(node, data)"
type="text">删除</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -44,98 +69,186 @@
</el-tree>
</div>
</div>
<el-dialog
:title="orgForm.id ? '编辑' : '新增' + '部门'"
<el-dialog :title="orgForm.id ? '编辑' : '新增' + '部门'"
:visible.sync="orgVisible"
:close-on-click-modal="false"
width="50%"
>
<el-form v-if="orgVisible" ref="orgForm" :model="orgForm" :rules="orgRules" label-width="100px">
<el-form-item label="部门名称" prop="name">
<el-input v-model.trim="orgForm.name" placeholder="请输入"></el-input>
width="50%">
<el-form v-if="orgVisible"
ref="orgForm"
:model="orgForm"
:rules="orgRules"
label-width="100px">
<el-form-item label="部门名称"
prop="name">
<el-input v-model.trim="orgForm.name"
placeholder="请输入"></el-input>
</el-form-item>
<el-form-item label="上级部门">
<span v-if="orgForm.pidName">{{ orgForm.pidName }}</span>
<el-cascader
v-else
<el-cascader v-else
:options="orgListDia"
v-model="cascaderValue"
:props="cascaderProps"
clearable
style="width: 100%"
>
style="width: 100%">
</el-cascader>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<span slot="footer"
class="dialog-footer">
<el-button @click="closeOrg"> </el-button>
<el-button type="primary" @click="orgSubmit"> </el-button>
<el-button type="primary"
@click="orgSubmit"> </el-button>
</span>
</el-dialog>
</div>
<div class="page list-wrap">
<div class="tool">
<el-input style="width: 250px;" placeholder="请输入员工姓名/账号/工号/手机号" v-model.trim="keyword" clearable></el-input>
<el-input style="width: 250px;"
placeholder="请输入员工姓名/账号/工号/手机号"
v-model.trim="keyword"
clearable></el-input>
<div class="actions">
<el-dropdown class="setting" trigger="click" :hide-on-click="false">
<img class="icon" src="@/assets/images/setting.png" alt="">
<el-dropdown class="setting"
trigger="click"
:hide-on-click="false">
<img class="icon"
src="@/assets/images/setting.png"
alt="">
<el-dropdown-menu>
<el-dropdown-item>
<el-button @click="resetColumns" type="text">列重置</el-button>
<el-button @click="resetColumns"
type="text">列重置</el-button>
</el-dropdown-item>
<el-dropdown-item v-for="(column, i) in settings" :key="i" :divided="i === 0">
<el-dropdown-item v-for="(column, i) in settings"
:key="i"
:divided="i === 0">
<el-checkbox v-model="column.show">{{ column.name }}</el-checkbox>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button v-auth type="primary" @click="addStaff">新增员工</el-button>
<el-button v-auth @click="batchImport">批量导入</el-button>
<el-button v-auth @click="batchDel">批量删除</el-button>
<el-button v-auth
type="primary"
@click="addStaff">新增员工</el-button>
<el-button v-auth
@click="batchImport">批量导入</el-button>
<el-button v-auth
@click="batchDel">批量删除</el-button>
</div>
</div>
<el-table :data="list" class="table" ref="table" @selection-change="handleSelectionChange" row-key="id">
<el-table-column v-if="settings[0].show" type="selection" width="55" :reserve-selection="true"></el-table-column>
<el-table-column type="index" width="60" label="序号"></el-table-column>
<el-table-column v-if="settings[1].show" prop="realName" label="员工姓名" min-width="100"></el-table-column>
<el-table-column v-if="settings[2].show" prop="username" label="账号" min-width="100"></el-table-column>
<el-table-column v-if="settings[3].show" prop="jobNumber" label="工号" min-width="100"></el-table-column>
<el-table-column v-if="settings[4].show" prop="phone" label="手机号" min-width="100" show-overflow-tooltip></el-table-column>
<el-table-column v-if="settings[5].show" prop="deptArchitectureName" label="所在部门" min-width="100"></el-table-column>
<el-table-column v-if="settings[6].show" prop="createTime" label="创建日期" min-width="150"></el-table-column>
<el-table-column v-if="settings[7].show" prop="roleName" label="授权角色" show-overflow-tooltip min-width="100"></el-table-column>
<el-table-column v-if="settings[8].show" prop="groupName" label="用户组" min-width="100"></el-table-column>
<el-table-column v-if="settings[9].show" prop="lastLoginTime" label="最后登录时间" min-width="150"></el-table-column>
<el-table-column v-if="settings[10].show" label="操作" width="180">
<el-table :data="list"
class="table"
ref="table"
@selection-change="handleSelectionChange"
row-key="id">
<el-table-column v-if="settings[0].show"
type="selection"
width="55"
:reserve-selection="true"></el-table-column>
<el-table-column type="index"
width="60"
label="序号"></el-table-column>
<el-table-column v-if="settings[1].show"
prop="realName"
label="员工姓名"
min-width="100"></el-table-column>
<el-table-column v-if="settings[2].show"
prop="username"
label="账号"
min-width="100"></el-table-column>
<el-table-column v-if="settings[3].show"
prop="jobNumber"
label="工号"
min-width="100"></el-table-column>
<el-table-column v-if="settings[4].show"
prop="phone"
label="手机号"
min-width="100"
show-overflow-tooltip></el-table-column>
<el-table-column v-if="settings[5].show"
prop="deptArchitectureName"
label="所在部门"
min-width="100"></el-table-column>
<el-table-column v-if="settings[6].show"
prop="createTime"
label="创建日期"
min-width="150"></el-table-column>
<el-table-column v-if="settings[7].show"
prop="roleName"
label="授权角色"
show-overflow-tooltip
min-width="100"></el-table-column>
<el-table-column v-if="settings[8].show"
prop="groupName"
label="用户组"
min-width="100"></el-table-column>
<el-table-column v-if="settings[9].show"
prop="lastLoginTime"
label="最后登录时间"
min-width="150"></el-table-column>
<el-table-column v-if="settings[10].show"
label="操作"
width="180">
<template slot-scope="scope">
<el-button v-auth type="text" @click="queryStaff(scope.row,true)">查看</el-button>
<el-button v-auth type="text" @click="queryStaff(scope.row,false)">编辑</el-button>
<el-button v-auth type="text" @click="resetPassword(scope.row)">重置密码</el-button>
<el-button v-auth type="text" @click="delStaff(scope.row)">删除</el-button>
<el-button v-auth
type="text"
@click="queryStaff(scope.row,true)">查看</el-button>
<el-button v-auth
type="text"
@click="queryStaff(scope.row,false)">编辑</el-button>
<el-button v-auth
type="text"
@click="resetPassword(scope.row)">重置密码</el-button>
<el-button v-auth
type="text"
@click="delStaff(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
<el-pagination background
@current-change="currentChange"
:current-page="page"
layout="total, prev, pager, next"
:total="total"></el-pagination>
</div>
<el-dialog :title="isDetail ? '查看' : (form.id ? '编辑' : '新增') + '员工'" :visible.sync="staffVisible" width="500px" class="dialog" :close-on-click-modal="false" @close="closeStaff">
<el-form ref="form" :model="form" :rules="rules" label-width="100px" :disabled="isDetail" style='margin-right: 60px;'>
<el-form-item prop="jobNumber" label="工号">
<el-input v-model.trim="form.jobNumber" placeholder="请输入工号"></el-input>
<el-dialog :title="isDetail ? '查看' : (form.id ? '编辑' : '新增') + '员工'"
:visible.sync="staffVisible"
width="500px"
class="dialog"
:close-on-click-modal="false"
@close="closeStaff">
<el-form ref="form"
:model="form"
:rules="rules"
label-width="100px"
:disabled="isDetail"
style='margin-right: 60px;'>
<el-form-item prop="jobNumber"
label="工号">
<el-input v-model.trim="form.jobNumber"
placeholder="请输入工号"></el-input>
</el-form-item>
<el-form-item prop="realName" label="姓名">
<el-input v-model.trim="form.realName" placeholder="请输入姓名"></el-input>
<el-form-item prop="realName"
label="姓名">
<el-input v-model.trim="form.realName"
placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item prop="username" label="账号">
<el-input v-model.trim="form.username" placeholder="请输入账号"></el-input>
<el-form-item prop="username"
label="账号">
<el-input v-model.trim="form.username"
placeholder="请输入账号"></el-input>
</el-form-item>
<el-form-item prop="roleIds" label="授权角色">
<el-select v-model="form.roleIds" multiple style="width: 100%">
<el-form-item prop="roleIds"
label="授权角色">
<el-select v-model="form.roleIds"
multiple
style="width: 100%">
<template v-for="item in roleIds">
<!-- 不显示超管 -->
<el-option
v-if="item.name !== '超级管理员'"
<el-option v-if="item.name !== '超级管理员'"
:key="item.id"
:label="item.name"
:value="item.id">
@ -144,24 +257,28 @@
</el-select>
</el-form-item>
<el-form-item label="所在部门">
<el-cascader
style="width: 100%"
<el-cascader style="width: 100%"
v-model="form.deptArchitectureId"
:options="orgs"
:props="casProps"
></el-cascader>
:props="casProps"></el-cascader>
</el-form-item>
<el-form-item prop="phone" label="手机号">
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"></el-input>
<el-form-item prop="phone"
label="手机号">
<el-input v-model.trim="form.phone"
placeholder="请输入手机号"
maxlength="11"></el-input>
</el-form-item>
<el-form-item prop="email" label="邮箱">
<el-input v-model.trim="form.email" placeholder="请输入邮箱"></el-input>
<el-form-item prop="email"
label="邮箱">
<el-input v-model.trim="form.email"
placeholder="请输入邮箱"></el-input>
</el-form-item>
<el-form-item prop="groupId" label="用户组">
<el-select v-model="form.groupId" style="width: 100%">
<el-form-item prop="groupId"
label="用户组">
<el-select v-model="form.groupId"
style="width: 100%">
<template v-for="item in userGroups">
<el-option
:key="item.id"
<el-option :key="item.id"
:label="item.groupName"
:value="item.id">
</el-option>
@ -169,19 +286,25 @@
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-if="!isDetail">
<span slot="footer"
class="dialog-footer"
v-if="!isDetail">
<el-button @click="staffVisible = false">取消</el-button>
<el-button type="primary" @click="submitStaff">确定</el-button>
<el-button type="primary"
@click="submitStaff">确定</el-button>
</span>
</el-dialog>
<el-dialog title="批量导入" :visible.sync="importVisible" width="24%" :close-on-click-modal="false">
<el-dialog title="批量导入"
:visible.sync="importVisible"
width="24%"
:close-on-click-modal="false">
<div style="text-align: center">
<div style="margin-bottom: 10px;">
<el-button type="primary" @click="download">模板下载<i class="el-icon-download el-icon--right"></i></el-button>
<el-button type="primary"
@click="download">模板下载<i class="el-icon-download el-icon--right"></i></el-button>
</div>
<el-upload
name="file"
<el-upload name="file"
accept=".xls,.xlsx"
:on-remove="handleRemove"
:on-error="uploadError"
@ -191,15 +314,21 @@
:on-exceed="handleExceed"
:action="this.api.importStaff"
:file-list="uploadList"
:headers="headers"
>
<el-button type="primary" class="ml20">上传文件<i class="el-icon-upload2 el-icon--right"></i></el-button>
:headers="headers">
<el-button type="primary"
class="ml20">上传文件<i class="el-icon-upload2 el-icon--right"></i></el-button>
</el-upload>
<el-link v-if="uploadFaild" type="primary" @click="showFaild">部分数据导入失败查看失败原因</el-link>
<el-link v-if="uploadFaild"
type="primary"
@click="showFaild">部分数据导入失败查看失败原因</el-link>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="importVisible = false"> </el-button>
<el-button size="small" type="primary" @click="uploadSure"> </el-button>
<span slot="footer"
class="dialog-footer">
<el-button size="small"
@click="importVisible = false"> </el-button>
<el-button size="small"
type="primary"
@click="uploadSure"> </el-button>
</span>
</el-dialog>
</div>
@ -207,20 +336,21 @@
</template>
<script>
import util from '@/libs/util'
import Util from '@/libs/util'
import Setting from '@/setting'
import Axios from 'axios'
import JSEncrypt from "jsencrypt"
export default {
data() {
data () {
const accountPass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入账号'))
} else {
const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){
if (pattern.test(value)) {
this.accountChange()
callback()
}else{
} else {
callback(new Error('请输入正确账号格式'))
}
}
@ -230,10 +360,10 @@ export default {
callback(new Error('请输入工号'))
} else {
const pattern = /^[A-Za-z0-9]*$/
if(pattern.test(value)){
if (pattern.test(value)) {
this.worknumberChange()
callback()
}else{
} else {
callback(new Error('请输入正确工号格式'))
}
}
@ -241,9 +371,9 @@ export default {
const phonePass = (rule, value, callback) => {
if (value) {
const pattern = /^1[3456789]\d{9}$/
if(pattern.test(value)){
if (pattern.test(value)) {
callback()
}else{
} else {
callback(new Error('请输入正确手机号格式'))
}
} else {
@ -253,9 +383,9 @@ export default {
const emailPass = (rule, value, callback) => {
if (value) {
const pattern = /^[a-zA-Z0-9][a-zA-Z0-9_]+\@[a-zA-Z0-9]+\.[a-zA-Z]{2,5}(\.[a-zA-Z]{2,5})*$/i
if(pattern.test(value)){
if (pattern.test(value)) {
callback()
}else{
} else {
callback(new Error('请输入正确邮箱格式'))
}
} else {
@ -353,13 +483,13 @@ export default {
},
rules: {
username: [
{ required: true,validator: accountPass, trigger: 'blur' }
{ required: true, validator: accountPass, trigger: 'blur' }
],
realName: [
{ required: true, message: "请输入姓名", trigger: "blur" }
],
jobNumber: [
{ required: true,validator: workNumberPass, trigger: 'blur' }
{ required: true, validator: workNumberPass, trigger: 'blur' }
],
roleIds: [
{ required: true, message: "请选择授权角色", trigger: "change" }
@ -401,13 +531,13 @@ export default {
uploadFaild: false,
exportCode: '',
headers: {
token: util.local.get(Setting.tokenKey)
token: Util.local.get(Setting.tokenKey)
},
disableds:false,
disableds: false,
submiting: false //
};
},
mounted() {
mounted () {
this.$store.commit('user/setCrumbs', [
{
name: '用户管理'
@ -423,19 +553,19 @@ export default {
this.originForm = JSON.parse(JSON.stringify(this.form))
},
watch: {
keyword: function(val) {
keyword: function (val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initData()
}, 500)
},
filterText(val) {
filterText (val) {
this.$refs.classTree.filter(val);
}
},
methods: {
//
getOrg() {
getOrg () {
this.$get(this.api.depts).then(({ data }) => {
const list = data[0].children
this.orgs = list
@ -443,22 +573,22 @@ export default {
this.$nextTick(() => {
this.getStaff()
})
}).catch(err => {})
}).catch(err => { })
},
// id
handleOrgId(list, ids) {
handleOrgId (list, ids) {
list.forEach(e => {
e.ids = ids ? [...ids, e.id] : [e.id]
e.children.length ? this.handleOrgId(e.children, e.ids) : delete e.children
})
},
//
changeType() {
changeType () {
this.$refs.orgs.setCurrentKey(null)
this.initData()
},
//
addOrg(node, data) {
addOrg (node, data) {
const list = JSON.parse(JSON.stringify(this.orgs))
this.handleOrg(list)
this.orgListDia = list
@ -471,7 +601,7 @@ export default {
this.orgVisible = true
},
//
editOrg(node, data) {
editOrg (node, data) {
const list = JSON.parse(JSON.stringify(this.orgs))
this.handleOrg(list, data.id, 0)
this.orgListDia = list
@ -485,7 +615,7 @@ export default {
this.cascaderValue = ids
},
//
handleOrg(list, id, disabled) {
handleOrg (list, id, disabled) {
list.forEach(e => {
// disabled
if (disabled) {
@ -502,18 +632,18 @@ export default {
})
},
//
delOrg(node, data) {
delOrg (node, data) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$del(`${this.api.dept}/${data.id}`).then(res => {
util.successMsg("删除成功")
this.$post(this.api.deleteDept, Util.rsa(data.id)).then(res => {
Util.successMsg("删除成功")
this.getOrg()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
// /
orgSubmit() {
orgSubmit () {
this.$refs.orgForm.validate((valid) => {
if (valid) {
const form = this.orgForm
@ -526,99 +656,99 @@ export default {
}
if (!form.id) {
//
this.$post(this.api.dept, form).then(res => {
util.successMsg("新增成功!")
this.$post(this.api.dept, Util.rsa(form)).then(res => {
Util.successMsg("新增成功!")
this.closeOrg()
}).catch(err => {})
}).catch(err => { })
} else {
//
this.$put(this.api.dept, form).then(res => {
util.successMsg("编辑成功!")
this.$post(this.api.updateDept, Util.rsa(form)).then(res => {
Util.successMsg("编辑成功!")
this.closeOrg()
}).catch(err => {})
}).catch(err => { })
}
}
})
},
//
handleNodeClick(data) {
handleNodeClick (data) {
this.staffType = null
this.initData()
},
//
closeOrg() {
closeOrg () {
this.orgVisible = false
this.cascaderValue = []
this.getOrg()
},
//
resetColumns() {
resetColumns () {
this.settings = JSON.parse(JSON.stringify(this.originSettings))
},
//
getStaff() {
this.$post(this.api.users, {
getStaff () {
this.$post(this.api.users, Util.rsa({
type: this.staffType || 1,
deptArchitectureId: this.$refs.orgs.getCurrentKey() || '',
keyWord: this.keyword,
pageNum: this.page,
pageSize: this.pageSize
}).then(({ data }) => {
})).then(({ data }) => {
this.list = data.records
this.total = +data.total
}).catch(err => {})
}).catch(err => { })
},
//
currentChange(val) {
currentChange (val) {
this.page = val
this.getStaff()
},
handleSelectionChange(val) { //
handleSelectionChange (val) { //
this.multipleSelection = val
},
initData() {
initData () {
this.$refs.table.clearSelection()
this.page = 1
this.getStaff()
},
//
delStaff(row) {
delStaff (row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$del(this.api.user, [row.id]).then(res => {
util.successMsg("删除成功")
this.$post(this.api.deletedUser, Util.rsa([row.id])).then(res => {
Util.successMsg("删除成功")
this.getStaff()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
//
batchDel() {
batchDel () {
const list = this.multipleSelection
if (list.length) {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$del(`${this.api.user}`, list.map(e => e.id)).then(res => {
this.$post(this.api.deletedUser, Util.rsa(list.map(e => e.id))).then(res => {
this.$refs.table.clearSelection()
util.successMsg('删除成功')
Util.successMsg('删除成功')
this.getStaff()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
} else {
util.errorMsg('请先选择数据 !')
Util.errorMsg('请先选择数据 !')
}
},
//
resetPassword(row) {
resetPassword (row) {
this.$confirm(`确定重置密码?重置后密码为111aaa。`, "提示", { type: "warning" }).then(() => {
this.$get(`${this.api.resetPwd}?userId=${row.id}`).then(res => {
util.successMsg("重置成功")
}).catch(res => {})
}).catch(() => {})
this.$post(this.api.resetPwd, Util.rsa(+row.id)).then(res => {
Util.successMsg("重置成功")
}).catch(res => { })
}).catch(() => { })
},
//
addStaff() {
addStaff () {
if (!this.staffType) {
this.archId = []
this.handleArchId(this.orgs, [this.$refs.orgs.getCurrentKey()])
@ -630,7 +760,7 @@ export default {
})
},
// id
handleArchId(list, ids, pid = []) {
handleArchId (list, ids, pid = []) {
list.map(e => {
// id[[1, 2], [3, 4]]idid
if (ids.includes(e.id)) {
@ -641,10 +771,11 @@ export default {
})
},
// /
queryStaff(row, isDetail) {
queryStaff (row, isDetail) {
this.isDetail = isDetail
this.staffVisible = true
this.$get(`${this.api.user}/${row.id}`).then(({ data }) => {
this.$post(this.api.queryUser, Util.rsa(row.id)).then(({ data }) => {
const { deptArchitectureId, roleId } = data
if (roleId) {
const ids = roleId.split(',').map(e => +e)
@ -658,7 +789,7 @@ export default {
}
}
if (!has) {
util.warningMsg('角色被删请重新选择')
Util.warningMsg('角色被删请重新选择')
data.roleIds = []
} else {
data.roleIds = ids
@ -684,28 +815,28 @@ export default {
}
this.originAccount = data.username
this.originWorkNumber = data.jobNumber
}).catch(res => {})
}).catch(res => { })
},
//
getRole() {
this.$post(this.api.roles, {
getRole () {
this.$post(this.api.roles, Util.rsa({
page: 1,
limit: 10000
}).then(({ data }) => {
})).then(({ data }) => {
this.roleIds = data.records
}).catch(res => {})
}).catch(res => { })
},
//
getUserGroup() {
this.$post(this.api.groupList, {
getUserGroup () {
this.$post(this.api.groupList, Util.rsa({
page: 1,
limit : 10000
}).then(({ data }) => {
limit: 10000
})).then(({ data }) => {
this.userGroups = data.records
}).catch(err => {})
}).catch(err => { })
},
//
accountChange() {
accountChange () {
const { username } = this.form
if (username === this.originAccount) {
this.accountReapeat = false
@ -718,7 +849,7 @@ export default {
}
},
//
worknumberChange() {
worknumberChange () {
const { jobNumber } = this.form
if (jobNumber === this.originWorkNumber) {
this.workNumberReapeat = false
@ -731,21 +862,21 @@ export default {
}
},
// /
submitStaff() {
submitStaff () {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
if (this.accountReapeat) return util.warningMsg("该账号已存在")
if (this.workNumberReapeat) return util.warningMsg("该工号已存在")
if (this.phoneRepeat) return util.warningMsg("该手机号已存在")
if (this.emailRepeat) return util.warningMsg("该邮箱已存在")
if (this.accountReapeat) return Util.warningMsg("该账号已存在")
if (this.workNumberReapeat) return Util.warningMsg("该工号已存在")
if (this.phoneRepeat) return Util.warningMsg("该手机号已存在")
if (this.emailRepeat) return Util.warningMsg("该邮箱已存在")
this.submiting = true
const form = JSON.parse(JSON.stringify(this.form))
const ids = form.deptArchitectureId
if (ids) form.deptArchitectureId = ids.map(e => e[e.length - 1])
if (form.id) {
this.$put(this.api.user, form).then(res => {
util.successMsg("编辑成功!")
this.$post(this.api.updateUser, Util.rsa(form)).then(res => {
Util.successMsg("编辑成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
@ -756,8 +887,8 @@ export default {
}, 2000)
})
} else {
this.$post(this.api.user, form).then(res => {
util.successMsg("新增成功!")
this.$post(this.api.user, Util.rsa(form)).then(res => {
Util.successMsg("新增成功!")
this.staffVisible = false
setTimeout(() => {
this.submiting = false
@ -772,7 +903,7 @@ export default {
})
},
//
closeStaff() {
closeStaff () {
this.form = {
id: '',
realName: '',
@ -788,57 +919,57 @@ export default {
this.getStaff()
},
//
batchImport() {
batchImport () {
this.importVisible = true
this.uploadList = []
this.uploadFaild = false
},
//
download() {
download () {
location.href = this.api.staffTemplate
},
//
handleExceed(files, fileList) {
util.warningMsg(
handleExceed (files, fileList) {
Util.warningMsg(
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`
)
},
//
showFaild() {
showFaild () {
Axios.get(`${this.api.exportFailure}?exportCode=${this.exportCode}`, {
headers: this.headers,
responseType: 'blob'
}).then((res) => {
util.downloadFileDirect(`导入用户失败原因.xls`, new Blob([res.data]))
}).catch(res => {})
Util.downloadFileDirect(`导入用户失败原因.xls`, new Blob([res.data]))
}).catch(res => { })
},
uploadSuccess(res, file, fileList) {
uploadSuccess (res, file, fileList) {
this.uploadFaild = false
if (res.code === 200) {
if (res.data.exportCode) {
this.exportCode = res.data.exportCode
this.uploadFaild = true
util.errorMsg(`本次上传有${res.data.failureNum}个错误信息录入`)
Util.errorMsg(`本次上传有${res.data.failureNum}个错误信息录入`)
}
} else {
res.msg ? util.errorMsg(res.msg) : util.errorMsg("上传失败,请检查数据")
res.msg ? Util.errorMsg(res.msg) : Util.errorMsg("上传失败,请检查数据")
}
},
uploadError(err, file, fileList) {
uploadError (err, file, fileList) {
this.$message({
message: "上传出错,请重试!",
type: "error",
center: true
})
},
beforeRemove(file, fileList) {
beforeRemove (file, fileList) {
return this.$confirm(`确定移除 ${file.name}`)
},
handleRemove(file, fileList) {
handleRemove (file, fileList) {
this.uploadList = fileList
this.uploadFaild = false
},
uploadSure() {
uploadSure () {
this.importVisible = false
this.staffType = 1
this.keyword = ''
@ -854,7 +985,7 @@ export default {
.el-tree-node__content {
height: 40px;
&:hover {
background-color: #F0F4FF;
background-color: #f0f4ff;
}
}
}
@ -883,7 +1014,7 @@ export default {
color: #666;
}
&.del {
color: #D0021B;
color: #d0021b;
}
}
.list-wrap {

@ -2,50 +2,94 @@
<div class="page">
<div class="tool">
<div class="search-wrap">
<el-input placeholder="请输入用户组名称" v-model.trim="keyword" clearable></el-input>
<el-input placeholder="请输入用户组名称"
v-model.trim="keyword"
clearable></el-input>
</div>
<div class="actions">
<el-button v-auth type="primary" @click="add" >新增</el-button>
<el-button v-auth @click="batchDel">删除</el-button>
<el-button v-auth
type="primary"
@click="add">新增</el-button>
<!-- <el-button v-auth
@click="batchDel">删除</el-button> -->
</div>
</div>
<el-table ref="table" :data="list" class="table" header-align="center" @selection-change="handleSelectionChange" row-key="id">
<el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column>
<el-table-column prop="groupName" label="名称" align="center" min-width="250" show-overflow-tooltip></el-table-column>
<el-table-column prop="description" label="角色描述" min-width="400" align="center"></el-table-column>
<el-table-column label="操作" width="170">
<el-table ref="table"
:data="list"
class="table"
header-align="center"
@selection-change="handleSelectionChange"
row-key="id">
<el-table-column type="selection"
width="55"
align="center"
:reserve-selection="true"></el-table-column>
<el-table-column prop="groupName"
label="名称"
align="center"
min-width="250"
show-overflow-tooltip></el-table-column>
<el-table-column prop="description"
label="角色描述"
min-width="400"
align="center"></el-table-column>
<el-table-column label="操作"
width="170">
<template slot-scope="scope">
<el-button v-auth type="text" @click="edit(scope.row)">编辑</el-button>
<el-button v-auth type="text" @click="del(scope.row)">删除</el-button>
<el-button v-auth
type="text"
@click="edit(scope.row)">编辑</el-button>
<el-button v-auth
type="text"
@click="del(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination>
<el-pagination background
@current-change="currentChange"
:current-page="page"
layout="total, prev, pager, next"
:total="total"></el-pagination>
</div>
<el-dialog :title="form.id ? '编辑' : '新增' + '用户组'" :visible.sync="formVisible" width="640px" class="dialog" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item prop="groupName" label="名称">
<el-input v-model="form.groupName" placeholder="请输入名称"></el-input>
<el-dialog :title="form.id ? '编辑' : '新增' + '用户组'"
:visible.sync="formVisible"
width="640px"
class="dialog"
:close-on-click-modal="false">
<el-form ref="form"
:model="form"
:rules="rules"
label-width="80px">
<el-form-item prop="groupName"
label="名称">
<el-input v-model="form.groupName"
placeholder="请输入名称"></el-input>
</el-form-item>
<el-form-item prop="description" label="描述">
<el-input v-model="form.description" placeholder="请输入描述" type="textarea" rows="5"></el-input>
<el-form-item prop="description"
label="描述">
<el-input v-model="form.description"
placeholder="请输入描述"
type="textarea"
rows="5"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<span slot="footer"
class="dialog-footer">
<el-button @click="formVisible = false"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
<el-button type="primary"
@click="submit"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import util from '@/libs/util'
import Util from '@/libs/util'
export default {
data() {
data () {
return {
keyword: '',
list: [],
@ -70,14 +114,14 @@ export default {
};
},
watch: {
keyword: function(val) {
keyword: function (val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.initData()
}, 500)
}
},
mounted() {
mounted () {
this.$store.commit('user/setCrumbs', [
{
name: '用户管理'
@ -89,58 +133,58 @@ export default {
this.getData()
},
methods: {
getData() {
this.$post(this.api.groupList, {
getData () {
this.$post(this.api.groupList, Util.rsa({
groupName: this.keyword,
page: this.page,
limit : this.pageSize
}).then(({ data }) => {
limit: this.pageSize
})).then(({ data }) => {
this.list = data.records
this.total = +data.total
}).catch(err => {})
}).catch(err => { })
},
initData() {
initData () {
this.$refs.table.clearSelection()
this.page = 1
this.getData()
},
del(row) {
del (row) {
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
}).then(() => {
this.$del(`${this.api.groupDel}/${row.id}`).then(res => {
util.successMsg("删除成功")
this.$post(this.api.groupDel, Util.rsa(row.id)).then(res => {
Util.successMsg("删除成功")
this.getData()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
},
//
batchDel() {
batchDel () {
const list = this.multipleSelection
if (list.length) {
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
}).then(() => {
this.$del(`${this.api.user}`, list.map(e => e.id)).then(res => {
this.$post(this.api.groupDel, Util.rsa(list.map(e => e.id))).then(res => {
this.$refs.table.clearSelection()
util.successMsg('删除成功')
Util.successMsg('删除成功')
this.getStaff()
}).catch(res => {})
}).catch(() => {})
}).catch(res => { })
}).catch(() => { })
} else {
util.errorMsg('请先选择数据 !')
Util.errorMsg('请先选择数据 !')
}
},
handleSelectionChange(val) {
handleSelectionChange (val) {
this.multipleSelection = val
},
currentChange(val) {
currentChange (val) {
this.page = val
this.getData()
},
//
add() {
add () {
this.form = {
id: '',
groupName: '',
@ -152,7 +196,7 @@ export default {
})
},
//
edit(row) {
edit (row) {
this.form = {
id: row.id,
groupName: row.groupName,
@ -161,15 +205,15 @@ export default {
this.formVisible = true
},
// /
submit() {
submit () {
this.$refs.form.validate((valid) => {
if (valid) {
if (this.submiting) return false
this.submiting = true
const { form } = this
if (form.id) {
this.$put(this.api.groupUpdate, form).then(res => {
util.successMsg("编辑成功!")
this.$post(this.api.groupUpdate, Util.rsa(form)).then(res => {
Util.successMsg("编辑成功!")
this.formVisible = false
this.getData()
setTimeout(() => {
@ -181,8 +225,8 @@ export default {
}, 2000)
})
} else {
this.$post(this.api.groupAdd, form).then(res => {
util.successMsg("新增成功!")
this.$post(this.api.groupAdd, Util.rsa(form)).then(res => {
Util.successMsg("新增成功!")
this.formVisible = false
this.getData()
setTimeout(() => {
@ -208,13 +252,13 @@ export default {
margin-right: 20px;
text-align: center;
&:hover .review {
border-color: #2962FF;
border-color: #2962ff;
}
}
.review {
padding: 18px;
margin-bottom: 10px;
border: 1px solid #DCDEE0;
border: 1px solid #dcdee0;
border-radius: 2px;
}
}

@ -1,14 +1,10 @@
/**
* 业务配置
* */
const url = location.host;
const isDev = process.env.NODE_ENV === 'development' // 开发环境
let host = `${location.origin}/`
if (isDev) {
// host = 'http://192.168.31.52:10000/'
host = 'http://192.168.31.136:10000/'
// host = 'http://10.10.11.7/'
host = 'http://192.168.31.51:10000/'
}
const Setting = {
@ -36,10 +32,6 @@ const Setting = {
* localStorage里保存的vuex的key
*/
storeKey: "IASF_server_store",
/**
* 默认密码
*/
initialPassword: "111aaa",
/**
* 多语言配置
* */
@ -59,7 +51,8 @@ const Setting = {
// 相同路由,不同参数间进行切换,是否强力更新
sameRouteForceUpdate: false,
// 是否使用动态路由(即角色权限,开启了的话就会取后端返回的权限树来显示头部导肮和页面按钮)
dynamicRoute: false
dynamicRoute: true,
publicKey: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA08Nz0zscnWtddmaNylIPt9v5ZO6U6pYyGochRrbpI+ocwoyV4E1uUu3J9/mmR8pyMBcYzE5KkBytlaiLnd6dMqo4R60aihN/TqfuI/03LzgAS/egT/Q4VB9yZSyZCmJhrgTtSX5kxotAbewp0gqsWpi+6BUYDuiwJ0WNlhDVV4FOQIppmvHh0RqYDhjiPNAuy7fEtytT+IY4rxm6LggvmNtIq5k2oLbDxEeI1GOyFHT6sLGMkmBLmHu7JYcrlyUGyGWsxh8hVame1zQsScivrZu757BTGhN4xObTivIdAbR7uFeeX4lp0X1JNtIe9TwB/aZzKJjZMPXeV7BJ01g3MQIDAQAB',
};
export default Setting;

@ -15,7 +15,7 @@ export default {
},
mutations: {
setAvatar: (state, avatar) => {
state.avatar = avatar
if (avatar) state.avatar = avatar
},
setUserId: (state, userId) => {
state.userId = userId

@ -15,5 +15,6 @@ module.exports = {
assetsDir: Setting.assetsDir,
devServer: {
port: 8088 // 固定端口
}
},
productionSourceMap: false,
}
Loading…
Cancel
Save