Commit 95211591 by 夏新然

系统配置样式完成

1 parent b5008bdc
...@@ -17,7 +17,7 @@ service.interceptors.request.use( ...@@ -17,7 +17,7 @@ service.interceptors.request.use(
} }
if (config.method == 'get') { if (config.method == 'get') {
config.params = { config.params = {
// _t: Date.parse(new Date()) / 1000, _t: Date.parse(new Date()) / 1000,
...config.params ...config.params
} }
} }
......
...@@ -2,7 +2,7 @@ import api from '../index' ...@@ -2,7 +2,7 @@ import api from '../index'
import baseUrl from '../baseUrl' import baseUrl from '../baseUrl'
export default { export default {
getUserList(params,id){ getUserList(params,id){
return api.get(`${baseUrl}/api/v1/auth/users/${id}`, params) return api.get(`${baseUrl}/api/v1/auth/users`, params)
}, },
getRoleList(params,id) { getRoleList(params,id) {
return api.get(`${baseUrl}/api/v1/auth/roles`, params) return api.get(`${baseUrl}/api/v1/auth/roles`, params)
...@@ -11,16 +11,13 @@ export default { ...@@ -11,16 +11,13 @@ export default {
return api.post(`${baseUrl}/api/v1/auth/users`, params) return api.post(`${baseUrl}/api/v1/auth/users`, params)
}, },
editUser(params,id) { editUser(params,id) {
return api.post(`${baseUrl}/api/v1/devconf_fx/users/${id}`, params) return api.post(`${baseUrl}/api/v1/auth/users/${id}`, params)
}, },
resetPwd(params,id) { resetPwd(params,id) {
return api.post(`${baseUrl}/api/v1/devconf_fx/users/${id}/reset`, params) return api.post(`${baseUrl}/api/v1/devconf_fx/users/${id}/reset`, params)
}, },
delUser(params,id){ delUser(params,id){
return api.delete(`${baseUrl}/api/v1/devconf_fx/users/${id}`, params) return api.delete(`${baseUrl}/api/v1/auth/users/${id}`, params)
},
getMenuList(params){
return api.get(`${baseUrl}/api/v1/devconf_fx/menu/list`, params)
}, },
addRole(params){ addRole(params){
return api.post(`${baseUrl}/api/v1/auth/roles`, params) return api.post(`${baseUrl}/api/v1/auth/roles`, params)
...@@ -30,5 +27,14 @@ export default { ...@@ -30,5 +27,14 @@ export default {
}, },
bindperms(params,id){ bindperms(params,id){
return api.post(`${baseUrl}/api/v1/auth/roles/${id}/perms`, params) return api.post(`${baseUrl}/api/v1/auth/roles/${id}/perms`, params)
},
getPerms(params,id){
return api.get(`${baseUrl}/api/v1/auth/roles/${id}/perms`, params)
},
editRole(params,id){
return api.post(`${baseUrl}/api/v1/auth/roles/${id}`, params)
},
bindRole(params,id){
return api.post(`${baseUrl}/api/v1/auth/users/${id}/roles`, params)
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -187,4 +187,13 @@ ...@@ -187,4 +187,13 @@
} }
.el-form-item--mini.el-form-item, .el-form-item--small.el-form-item { .el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
margin-bottom: 4px; margin-bottom: 4px;
}
/* 切换 */
.el-tabs__item{
height: 52px;
line-height:52px;
}
.home-box .el-tabs__nav .el-tabs__item{
width: 14%!important;
padding:0 28px!important;
} }
\ No newline at end of file \ No newline at end of file
...@@ -7,6 +7,15 @@ $border-color:#e5e5e5; ...@@ -7,6 +7,15 @@ $border-color:#e5e5e5;
$title-color:#f4f4f4; $title-color:#f4f4f4;
$title-backgroud:#f3f3f3; $title-backgroud:#f3f3f3;
$dialog-title:#3BB7FF; $dialog-title:#3BB7FF;
.primaryButton{
background: $dialog-title!important;
border-color: $dialog-title!important;
}
.plainButton{
color:$dialog-title;
background: $white-back-color;
border-color: $dialog-title;
}
body{ body{
margin: 0; margin: 0;
color: $font-color; color: $font-color;
...@@ -32,6 +41,9 @@ a:active{ ...@@ -32,6 +41,9 @@ a:active{
text-decoration:none; text-decoration:none;
/* 指正在点的链接*/ /* 指正在点的链接*/
} }
.big .el-radio__label,.big{
font-size: 16px!important;
}
.inputBox{ .inputBox{
display: inline-block; display: inline-block;
width: 150px; width: 150px;
......
...@@ -187,6 +187,13 @@ export const asyncRouterMap = [ ...@@ -187,6 +187,13 @@ export const asyncRouterMap = [
}, },
component: resolve => require(["../views/ops/equipment_manage"], resolve), component: resolve => require(["../views/ops/equipment_manage"], resolve),
},{ },{
path: "/ops/system_manage",
name: "系统配置",
meta: {
icon: "el-icon-location"
},
component: resolve => require(["../views/ops/system_manage"], resolve),
},{
path: "/ops/user_manage", path: "/ops/user_manage",
name: "用户管理", name: "用户管理",
meta: { meta: {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="content"> <div class="content">
<div style="padding: 20px 15px 20px 23px;"> <div style="padding: 20px 15px 20px 23px;">
<span style="float: right;"> <span style="float: right;">
<el-button type="info" @click="addRole">添加新用户</el-button> <el-button type="info" @click="addRole">添加新角色</el-button>
</span> </span>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="role_name" prop="name"
label="角色名"> label="角色名">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</div> </div>
<!-- 新增 --> <!-- 新增 -->
<el-dialog <el-dialog
title="新增用户" title="新增角色"
:visible.sync="addVisible" :visible.sync="addVisible"
@open="openAddDialog" @open="openAddDialog"
width="30%"> width="30%">
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
@current-change="treeChange" @current-change="treeChange"
show-checkbox show-checkbox
ref="addTree" ref="addTree"
node-key="menu_unid" node-key="unid"
:props="defaultProps"> :props="defaultProps">
</el-tree> </el-tree>
</el-form-item> </el-form-item>
...@@ -95,23 +95,23 @@ ...@@ -95,23 +95,23 @@
</el-dialog> </el-dialog>
<!-- 编辑 --> <!-- 编辑 -->
<el-dialog <el-dialog
title="编辑用户" title="编辑角色"
:visible.sync="editVisible" :visible.sync="editVisible"
width="30%"> width="30%">
<div class="maxHeight"> <div class="maxHeight">
<el-form label-position="left" label-width="80px" :model="editForm" :rules="rules" ref="editForm" inline-message hide-required-asterisk> <el-form label-position="left" label-width="80px" :model="editForm" :rules="rules" ref="editForm" inline-message hide-required-asterisk>
<el-form-item label="角色选项" prop="role_unid"> <el-form-item label="角色名" prop="role_name">
<el-select v-model="editForm.role_unid" placeholder="请选择" :popper-append-to-body=false> <el-input v-model="editForm.role_name"></el-input>
<el-option </el-form-item>
v-for="item in roleList" <el-form-item label="权限菜单" prop="menu_unids">
:key="item.role_unid" <el-tree
:label="item.role_name" :data="treeData"
:value="item.role_unid"> @current-change="treeChange"
</el-option> show-checkbox
</el-select> ref="editTree"
</el-form-item> node-key="unid"
<el-form-item label="用户名" prop="user_name"> :props="defaultProps">
<el-input v-model="editForm.user_name"></el-input> </el-tree>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
...@@ -142,8 +142,8 @@ ...@@ -142,8 +142,8 @@
return{ return{
treeData:[], treeData:[],
defaultProps: { defaultProps: {
children: 'childs', children: 'children',
label: 'menu_name' label: 'name'
}, },
total:0, total:0,
page:1, page:1,
...@@ -195,13 +195,11 @@ ...@@ -195,13 +195,11 @@
}, },
getMenuList(){ getMenuList(){
this.treeData=[]; this.treeData=[];
this.$api.ops.getMenuList({ //获取菜单
limit: 9999, this.$api.login.getMenus({
offset: 0, "shape":"tree"
}).then((res)=>{ }).then(res=>{
this.treeData = res; this.treeData = res.menu_tree[0].children;
}).catch((error)=>{
}) })
}, },
getTableList(){ getTableList(){
...@@ -251,10 +249,15 @@ ...@@ -251,10 +249,15 @@
}); });
}, },
editUser(index,row){ editUser(index,row){
this.editForm.role_unid=row.role_unid; this.$api.ops.getPerms({
this.editForm.user_name=row.user_name; },row.role_unid).then(res=>{
this.editUnid=row.unid; this.editForm.role_name=row.name;
this.editVisible=true; res.list_data.forEach(item=>{
this.editForm.menu_unids.push(item.perm_unid)
})
this.editUnid=row.role_unid;
this.editVisible=true;
})
}, },
openAddDialog(){ openAddDialog(){
this.$refs['addForm'].resetFields(); this.$refs['addForm'].resetFields();
...@@ -267,15 +270,23 @@ ...@@ -267,15 +270,23 @@
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$api.ops.addRole({name:this.addForm.role_name}).then(res=>{ this.$api.ops.addRole({name:this.addForm.role_name}).then(res=>{
if(!res.ecode){ if(!res.ecode){
// this.$api.ops.bindperms({}) this.$api.ops.bindperms({perm_unids:this.addForm.menu_unids},res.role_unid).then(data=>{
this.$message({ if(!data.code){
type: 'success', this.$message({
message: '添加成功!' type: 'success',
}); message: '添加成功!'
this.addVisible=false; });
this.getTableList(); this.addVisible=false;
this.getTableList();
}else{
this.$message({
type: 'error',
message: data.enote
});
}
})
}else{ }else{
this.$message({ this.$message({
type: 'error', type: 'error',
...@@ -290,27 +301,39 @@ ...@@ -290,27 +301,39 @@
}, },
editFun(formName){ editFun(formName){
this.$refs[formName].validate((valid) => { this.editForm.menu_unids=this.$refs.editTree.getCheckedKeys().sort((a, b) => { return a - b; });
if (valid) { this.$refs[formName].validate((valid) => {
this.$api.ops.editUser(this.editForm,this.editUnid).then(res=>{ if (valid) {
if(!res.ecode){ this.$api.ops.editRole({name:this.editForm.role_name},this.editUnid).then(res=>{
this.$message({ if(!res.code){
type: 'success', this.$api.ops.bindperms({perm_unids:this.editForm.menu_unids},this.editUnid).then(data=>{
message: '修改成功!' if(!data.code){
}); this.$message({
this.editVisible=false; type: 'success',
this.getTableList(); message: '修改成功!'
}else{ });
this.$message({ this.addVisible=false;
type: 'error', this.getTableList();
message: '修改失败!' }else{
}); this.$message({
type: 'error',
message: data.enote
});
}
})
}else{
this.$message({
type: 'error',
message: res.enote
});
}
})
} else {
return false;
} }
}) });
} else {
return false;
}
});
} }
}, },
} }
......
<template>
<div style="padding-left: 28px;">
<el-form ref="form" label-width="100px">
<!-- 手动校时 -->
<div class="lineBox big">
<el-radio v-model="radio" label="1">手动校时</el-radio>
</div>
<div class="radioContent">
<div class="lineBox">
<el-form-item label="当前时间:">
<span>2020-02-11 16:08:01</span>
</el-form-item>
</div>
<div class="lineBox">
<el-form-item label="设备时间:">
<el-date-picker
v-model="systemTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间">
</el-date-picker>
<span style="margin-left: 30px;"> <el-checkbox v-model="syncTime">与计算机时间同步</el-checkbox></span>
<el-button type="primary" size="small" class="primaryButton rightButton">校时</el-button>
</el-form-item>
</div>
</div>
<div class="line"></div>
<!-- NTP校时 -->
<div class="lineBox big">
<el-radio v-model="radio" label="2">NTP校时</el-radio>
</div>
<div class="radioContent">
<div class="lineBox">
<el-form-item label="服务器地址:">
<span class="inputBox">
<el-input placeholder="请输入服务器地址" v-model="url"></el-input>
</span>
</el-form-item>
</div>
<div class="lineBox">
<el-form-item label="NTP端口:">
<span class="inputBox">
<el-input placeholder="请输入NTP端口" v-model="ntpPort"></el-input>
</span>
</el-form-item>
</div>
<div class="lineBox">
<el-radio v-model="ntpRadio" label="2">定时校时</el-radio>
</div>
<el-form ref="inlineform" label-width="100px" inline>
<div class="lineBox">
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
</div>
<div class="lineBox">
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label=" ">
<span>自动进行校时(可设置多个时间点,不得超过5个)</span>
</el-form-item>
</div>
</el-form>
<div class="lineBox">
<el-radio v-model="ntpRadio" label="2">周期校时</el-radio>
</div>
<div class="lineBox">
<el-form-item label="每隔:">
<span class="inputBox" style="width: 60px;">
<el-input placeholder="请输入NTP端口" v-model="ntpPort"></el-input>
</span>
<span style="margin-left: 14px;">秒,自动进行校时</span>
<el-button type="primary" size="small" class="primaryButton rightButton">保存设置</el-button>
</el-form-item>
</div>
</div>
</el-form>
</div>
</template>
<script>
export default {
data(){
return{
time:'',
url:'',
ntpPort:'',
activeName: 'first',
systemTime:'',
syncTime:false
}
},
components:{},
mounted(){},
methods:{
handleClick(tab, event) {
console.log(tab, event);
}
},
}
</script>
<style lang="scss" scoped>
.line{
height:1px;
background:rgba(232,232,232,1);
margin-top: 18px;
margin-bottom: 15px;
}
.lineBox{
padding: 12px 0 12px 50px;
}
.radioContent{
margin-left: 24px;
}
.rightButton{
float: right;
margin-right: 20%;
}
.inputBox{
width: 220px;
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div style="padding-left: 28px;">
<el-form ref="form" label-width="86px">
<!-- 恢复出厂设置 -->
<div class="lineBox big">
<i class="el-icon-share"></i>恢复出厂设置
</div>
<div class="radioContent">
<div class="lineBox">
<el-button type="primary" size="small" class="primaryButton">恢复出厂设置</el-button>
</div>
<div class="lineBox">
<span class="tip">恢复出厂设置说明:完全恢复设备参数到出厂设置</span>
</div>
</div>
<div class="line"></div>
<!-- 数据备份 -->
<div class="lineBox big">
<i class="el-icon-share"></i>数据备份
</div>
<div class="radioContent">
<div class="lineBox">
<span class="upTit">参数导入</span><span class="upTit2">选择导入文件</span>
<div class="upInput"><el-input v-model="selectFilename"></el-input></div>
<span style="display: inline-block;">
<el-upload
class="upload-demo"
ref="upload"
:on-change="fileChange"
:multiple="false"
:show-file-list="false"
action="https://jsonplaceholder.typicode.com/posts/"
:auto-upload="false">
<el-button slot="trigger" size="small" type="primary" class="primaryButton upButton">浏览</el-button>
<el-button size="small" type="primary" @click="submitUpload" plain class="plainButton">参数导入</el-button>
</el-upload>
</span>
</div>
<div class="lineBox">
<span class="upTit">参数导出</span><span class="upTit2"><el-button size="small" type="primary" class="primaryButton">参数导出</el-button></span>
</div>
</div>
<div class="line"></div>
<div class="lineBox big">
<i class="el-icon-share"></i>重启设置
</div>
<div class="radioContent">
<div class="lineBox">
<el-button size="small" type="primary" class="primaryButton">手动重启</el-button>
</div>
<div class="lineBox">
<el-checkbox v-model="openRestart">开启定时重启</el-checkbox>
</div>
<el-form ref="inlineform" label-width="100px" inline>
<div class="lineBox">
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
</div>
<div class="lineBox">
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label="每天:">
<el-time-select
v-model="time"
placeholder="选择时间">
</el-time-select>
</el-form-item>
<el-form-item label=" ">
<span>自动进行校时(可设置多个时间点,不得超过5个)</span>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" size="small" class="primaryButton rightButton">保存</el-button>
</el-form-item>
</div>
</el-form>
</div>
</el-form>
</div>
</template>
<script>
export default {
data(){
return{
openRestart:false,
selectFilename:'',
time:'',
url:'',
ntpPort:'',
activeName: 'first',
systemTime:'',
syncTime:false
}
},
components:{},
mounted(){},
methods:{
handleClick(tab, event) {
console.log(tab, event);
},
submitUpload(){
this.$refs.upload.submit();
},
fileChange(file,fileList){
console.log(file,fileList)
this.selectFilename=file.name;
}
},
}
</script>
<style lang="scss" scoped>
.upButton{
margin-right: 10px;
}
.upTit{
margin-right: 44px;
}
.upTit2{
margin-right: 6px;
}
.upInput{
display: inline-block;
width: 250px;
margin:0 12px;
}
.tip{
font-size:14px;
color:rgba(0,0,0,0.25);
}
.line{
height:1px;
background:rgba(232,232,232,1);
margin-top: 18px;
margin-bottom: 15px;
}
.lineBox{
padding: 12px 0 12px 50px;
}
.radioContent{
margin-left: 38px;
}
.rightButton{
float: right;
margin-right: 20%;
}
.inputBox{
width: 220px;
}
.big i{
font-size: 18px;
color: #CCCCCC;
margin-right:22px;
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="contentBox">
<div style="background: #FFFFFF;">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="校时设置" name="first">
<proofreadtime></proofreadtime>
</el-tab-pane>
<el-tab-pane label="系统维护" name="second">
<sytemset></sytemset>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import proofreadtime from './systemComponents/proofreadtime'
import sytemset from './systemComponents/sytemSet'
export default {
data(){
return{
activeName: 'first'
}
},
components:{
proofreadtime,sytemset
},
mounted(){},
methods:{
handleClick(tab, event) {
console.log(tab, event);
}
},
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file \ No newline at end of file
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
label="序号"> label="序号">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="user_name" prop="username"
align="center" align="center"
label="用户名"> label="用户名">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
prop="role_name" prop="roles[0].name"
label="角色名"> label="角色名">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
...@@ -45,10 +45,10 @@ ...@@ -45,10 +45,10 @@
<el-tooltip content="编辑用户" placement="bottom" effect="light" :visible-arrow=false> <el-tooltip content="编辑用户" placement="bottom" effect="light" :visible-arrow=false>
<span class="iconfont icon-xiugai editIcon" @click="editUser(scope.$index, scope.row)"></span> <span class="iconfont icon-xiugai editIcon" @click="editUser(scope.$index, scope.row)"></span>
</el-tooltip> </el-tooltip>
<span class="tableSpanBorder"></span> <!-- <span class="tableSpanBorder"></span>
<el-tooltip content="重置密码" placement="bottom" effect="light" :visible-arrow=false> <el-tooltip content="重置密码" placement="bottom" effect="light" :visible-arrow=false>
<span class="iconfont icon-xiugai editIcon2" @click="reset(scope.$index, scope.row)"></span> <span class="iconfont icon-xiugai editIcon2" @click="reset(scope.$index, scope.row)"></span>
</el-tooltip> </el-tooltip> -->
<span class="tableSpanBorder"></span> <span class="tableSpanBorder"></span>
<el-tooltip content="删除" placement="bottom" effect="light" :visible-arrow=false> <el-tooltip content="删除" placement="bottom" effect="light" :visible-arrow=false>
<span class="iconfont icon-detail delIcon" @click="delFun(scope.$index, scope.row)"></span> <span class="iconfont icon-detail delIcon" @click="delFun(scope.$index, scope.row)"></span>
...@@ -87,16 +87,19 @@ ...@@ -87,16 +87,19 @@
<el-option <el-option
v-for="item in roleList" v-for="item in roleList"
:key="item.role_unid" :key="item.role_unid"
:label="item.role_name" :label="item.name"
:value="item.role_unid"> :value="item.role_unid">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="用户名" prop="user_name"> <el-form-item label="用户名" prop="username">
<el-input v-model="addForm.user_name"></el-input> <el-input v-model="addForm.username"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="密码" prop="user_password"> <el-form-item label="密码" prop="password">
<el-input v-model="addForm.user_password" type="password"></el-input> <el-input v-model="addForm.password" type="password"></el-input>
</el-form-item>
<el-form-item label="确认新密码" prop="checkPass">
<el-input v-model="addForm.checkPass" type="checkPass"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
...@@ -113,18 +116,15 @@ ...@@ -113,18 +116,15 @@
<div> <div>
<el-form label-position="left" label-width="80px" :model="editForm" :rules="rules" ref="editForm" inline-message hide-required-asterisk> <el-form label-position="left" label-width="80px" :model="editForm" :rules="rules" ref="editForm" inline-message hide-required-asterisk>
<el-form-item label="角色选项" prop="role_unid"> <el-form-item label="角色选项" prop="role_unid">
<el-select v-model="editForm.role_unid" placeholder="请选择" :popper-append-to-body=false> <el-select v-model="editForm.role_unid" placeholder="请选择" :popper-append-to-body=false>
<el-option <el-option
v-for="item in roleList" v-for="item in roleList"
:key="item.role_unid" :key="item.role_unid"
:label="item.role_name" :label="item.name"
:value="item.role_unid"> :value="item.role_unid">
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="用户名" prop="user_name">
<el-input v-model="editForm.user_name"></el-input>
</el-form-item>
</el-form> </el-form>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
callback(); callback();
} }
}; };
var checkPass = (rule, value, callback) => { var validatePass = (rule, value, callback) => {
var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$/; var reg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$/;
if(!reg.test(value)){ if(!reg.test(value)){
callback(new Error('密码必须包含数字字母大于6位')); callback(new Error('密码必须包含数字字母大于6位'));
...@@ -159,6 +159,15 @@ ...@@ -159,6 +159,15 @@
callback(); callback();
} }
}; };
var validatePass2 = (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'));
} else if (value !== this.editForm.password) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
};
return{ return{
total:0, total:0,
page:1, page:1,
...@@ -167,28 +176,30 @@ ...@@ -167,28 +176,30 @@
norm_type:"login", norm_type:"login",
role_unid:'', role_unid:'',
username:'', username:'',
password:'' password:'',
checkPass:''
}, },
editForm:{ editForm:{
role_unid:'', role_unid:'',
user_name:'',
}, },
editUnid:'', editUnid:'',
tableData: [], tableData: [],
addVisible:false, addVisible:false,
editVisible:false, editVisible:false,
roleList:[], roleList:[],
userId:sessionStorage.getItem('user_unid'),
rules: { rules: {
role_unid: [ role_unid: [
{ validator: checkRole, trigger: 'change' } { validator: checkRole, trigger: 'change' }
], ],
user_name: [ username: [
{ validator: checkUser, trigger: 'change' } { validator: checkUser, trigger: 'change' }
], ],
user_password: [ password: [
{ validator: checkPass, trigger: 'change' } { validator: validatePass, trigger: 'change' }
], ],
checkPass:[
{ validator: validatePass2, trigger: 'change' }
]
} }
} }
}, },
...@@ -217,7 +228,7 @@ ...@@ -217,7 +228,7 @@
this.$api.ops.getUserList({ this.$api.ops.getUserList({
limit: this.pageSize, limit: this.pageSize,
offset: offset, offset: offset,
},this.userId).then((res)=>{ }).then((res)=>{
this.total=res.total_num; this.total=res.total_num;
if(res.list_data==null){ if(res.list_data==null){
...@@ -304,9 +315,8 @@ ...@@ -304,9 +315,8 @@
}); });
}, },
editUser(index,row){ editUser(index,row){
this.editForm.role_unid=row.role_unid; this.editForm.role_unid=row.roles[0].role_unid;
this.editForm.user_name=row.user_name; this.editUnid=row.user_unid;
this.editUnid=row.unid;
this.editVisible=true; this.editVisible=true;
}, },
openAddDialog(){ openAddDialog(){
...@@ -318,14 +328,29 @@ ...@@ -318,14 +328,29 @@
addFun(formName){ addFun(formName){
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$api.ops.addUser(this.addForm).then(res=>{ this.$api.ops.addUser({
norm_type:this.addForm.norm_type,
username:this.addForm.username,
password:this.addForm.password
}).then(res=>{
if(!res.ecode){ if(!res.ecode){
this.$message({ this.$api.ops.bindRole({
type: 'success', "role_unid":this.addForm.role_unid,
message: '添加成功!' },res.user_unid).then(data=>{
}); if(!data.ecode){
this.addVisible=false; this.$message({
this.getTableList(); type: 'success',
message: '添加成功!'
});
this.addVisible=false;
this.getTableList();
}else{
this.$message({
type: 'error',
message: '添加失败!'
});
}
})
}else{ }else{
this.$message({ this.$message({
type: 'error', type: 'error',
...@@ -342,23 +367,25 @@ ...@@ -342,23 +367,25 @@
editFun(formName){ editFun(formName){
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.$api.ops.editUser(this.editForm,this.editUnid).then(res=>{ this.$api.ops.bindRole({
if(!res.ecode){ role_unid:this.editForm.role_unid
this.$message({ },this.editUnid).then(res=>{
type: 'success', if(!res.ecode){
message: '修改成功!' this.$message({
}); type: 'success',
this.editVisible=false; message: '修改成功!'
this.getTableList(); });
}else{ this.editVisible=false;
this.$message({ this.getTableList();
type: 'error', }else{
message: '修改失败!' this.$message({
}); type: 'error',
} message: '修改失败!'
}) });
}
})
} else { } else {
return false; return false;
} }
}); });
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!