全部接口加密

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", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" "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": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",

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

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

@ -2,6 +2,7 @@ import { _local } from "./util.db";
import { Message } from "element-ui"; import { Message } from "element-ui";
import store from "@/store"; import store from "@/store";
import Setting from '@/setting' import Setting from '@/setting'
import JSEncrypt from "jsencrypt"
// 文件后缀集合 // 文件后缀集合
const exts = { const exts = {
@ -112,6 +113,12 @@ const util = {
Message.closeAll(); Message.closeAll();
return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration }); 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; export default util;

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

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

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

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

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

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

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

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

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

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

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

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

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

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