Commit 9d7c3ec9 by 潘建波

提交修改个人密码

1 parent ff0930a2
No preview for this file type
...@@ -4,7 +4,7 @@ console.log(process.env.NODE_ENV); ...@@ -4,7 +4,7 @@ console.log(process.env.NODE_ENV);
switch (process.env.NODE_ENV) { switch (process.env.NODE_ENV) {
case "development": case "development":
// baseUrl = "http://192.168.9.234:20080"; // 测试环境url // baseUrl = "http://192.168.9.234:20080"; // 测试环境url
baseUrl = "http://192.168.9.62:20080"; // 测试环境url baseUrl = "http://192.168.9.149:20080"; // 测试环境url
// baseUrl = "http://192.168.9.82:8080"; // 测试环境url // baseUrl = "http://192.168.9.82:8080"; // 测试环境url
// baseUrl = "http://192.168.9.61:8086"; // baseUrl = "http://192.168.9.61:8086";
// baseUrl = 'http://vion-panda.51vip.biz:52510'; // baseUrl = 'http://vion-panda.51vip.biz:52510';
......
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
return api.post(`${baseUrl}/api/v1/auth/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/auth/users/${id}/password`, params)
}, },
delUser(params,id){ delUser(params,id){
return api.delete(`${baseUrl}/api/v1/auth/users/${id}`, params) return api.delete(`${baseUrl}/api/v1/auth/users/${id}`, params)
......
...@@ -39,7 +39,14 @@ export const constantRouterMap = [ ...@@ -39,7 +39,14 @@ export const constantRouterMap = [
// this generates a separate chunk (about.[hash].js) for this route // this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited. // which is lazy-loaded when the route is visited.
component: resolve => require(["../views/Show.vue"], resolve) component: resolve => require(["../views/Show.vue"], resolve)
} },{
path: "/resetpass",
name: "resetpassword",
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: resolve => require(["../views/Resetpassword.vue"], resolve)
},
]; ];
export const asyncRouterMap = [ export const asyncRouterMap = [
{ {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
></span> ></span>
<div class="headRight"> <div class="headRight">
<span>{{ curdate }}</span> <span>{{ curdate }}</span>
<img src="../../assets/img/home/user.png" alt="" /> <img @click="resetpass" src="../../assets/img/home/user.png" alt="" />
<span class="exit" @click="logout()" <span class="exit" @click="logout()"
>退出<i class="el-icon-arrow-down"></i >退出<i class="el-icon-arrow-down"></i
></span> ></span>
...@@ -129,6 +129,9 @@ export default { ...@@ -129,6 +129,9 @@ export default {
this.$store.commit(types.ATOKEN, ""); this.$store.commit(types.ATOKEN, "");
localStorage.removeItem("atoken"); localStorage.removeItem("atoken");
this.$router.push("/login").catch(err => {err}); this.$router.push("/login").catch(err => {err});
},
resetpass(){
this.$router.push("/resetpass").catch(err => {err});
} }
}, },
created() { created() {
......
<template>
<div class="passform-box">
<div class="re-header">重置密码</div>
<el-form
:model="ruleForm"
:rules="rules"
ref="ruleForm"
label-width="100px"
class="passform"
>
<div class="passformitem">
<el-form-item label="旧密码" prop="oldpassword">
<el-input v-model="ruleForm.oldpassword" type="password"></el-input>
</el-form-item>
</div>
<div class="passformitem">
<el-form-item label="新密码" prop="newpassword">
<el-input v-model="ruleForm.newpassword" type="password"></el-input>
</el-form-item>
</div>
<div class="passformitem">
<el-form-item label="密码确认" prop="checknewpassword">
<el-input
v-model="ruleForm.checknewpassword"
type="password"
></el-input>
</el-form-item>
</div>
<el-form-item>
<el-button @click="back('ruleForm')">取消</el-button>
<el-button type="primary" @click="submitForm('ruleForm')"
>提交</el-button
>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
data() {
var validatePass = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入密码"));
} else {
if (this.ruleForm.checkPass !== "") {
this.$refs.ruleForm.validateField("checkPass");
}
callback();
}
};
var validatePass2 = (rule, value, callback) => {
if (value === "") {
callback(new Error("请再次输入密码"));
} else if (value !== this.ruleForm.newpassword) {
callback(new Error("两次输入密码不一致!"));
} else {
callback();
}
};
return {
ruleForm: {
oldpassword: "",
newpassword: "",
checknewpassword: ""
},
rules: {
oldpassword: [
{ required: true, message: "请输入旧密码", trigger: "blur" }
],
newpassword: [
{ validator: validatePass, trigger: "blur" },
{ required: true, message: "", trigger: "blur" }
],
checknewpassword: [
{ validator: validatePass2, trigger: "blur" },
{ required: true, message: "", trigger: "blur" }
]
}
};
},
methods: {
submitForm(formName) {
let data = {
old_pwd: this.ruleForm.oldpassword,
new_pwd: this.ruleForm.newpassword
};
this.$refs[formName].validate(valid => {
if (valid) {
let user_unid = sessionStorage.getItem("user_unid");
this.$api.ops.resetPwd(data, user_unid).then(res => {
this.$router.push("/login");
});
} else {
console.log("error submit!!");
return false;
}
});
},
back() {
this.$router.back(-1);
},
resetForm(formName) {
this.$refs[formName].resetFields();
}
}
};
</script>
<style>
.passform {
margin: 20px;
width: 400px;
}
.passformitem {
margin-bottom: 20px;
}
.passform-box{
width: 400px;
}
.re-header{
margin-left: 60px;
margin-top: 20px;
}
</style>
...@@ -161,6 +161,9 @@ ...@@ -161,6 +161,9 @@
<script> <script>
import { SVG } from "@svgdotjs/svg.js"; import { SVG } from "@svgdotjs/svg.js";
var draw = null; var draw = null;
var childgroup = null;
var levalgroup = null;
var levalinecolor = "#333";
export default { export default {
data() { data() {
return { return {
...@@ -222,9 +225,7 @@ export default { ...@@ -222,9 +225,7 @@ export default {
}; };
this.curDevData = dev; this.curDevData = dev;
this.$api.device.getSubdev(this.parentData, obj).then(res => { this.$api.device.getSubdev(this.parentData, obj).then(res => {
for (var i = 0; i < 10; i++) { this.slaveData = res.list_data;
this.slaveData.push(res.list_data);
}
this.createdLeval(ev, this.slaveData); this.createdLeval(ev, this.slaveData);
}); });
}, },
...@@ -266,13 +267,14 @@ export default { ...@@ -266,13 +267,14 @@ export default {
var _this = this; var _this = this;
var nested = draw var nested = draw
.nested() .nested()
.size(120, 40) .size(130, 40)
.move(50, 50) .move(50, 50)
.data("sdv", data); .data("sdv", data);
var rect = nested var rect = nested
.rect(120, 40) .rect(130, 40)
.attr({ fill: "#f06" }) .attr({ fill: "#123e6c", opacity: 0.6 })
.radius(5); .stroke({ color: "#333", opacity: 0.5, width: 1 })
.radius(3);
var text = nested.text(function(add) { var text = nested.text(function(add) {
add add
.tspan(`${data.device_name}`) .tspan(`${data.device_name}`)
...@@ -286,32 +288,38 @@ export default { ...@@ -286,32 +288,38 @@ export default {
}); });
}, },
createdChild(data) { createdChild(data) {
if (childgroup) {
childgroup.clear();
}
childgroup = draw.group();
var _this = this; var _this = this;
data.map((ele, index) => { data.map((ele, index) => {
let point = { let point = {
x: 200, x: 200,
y: 70 * (index + 1) + 50 y: 65 * (index + 1) + 70
}; };
var polyline = draw var polyline = childgroup
.polyline([ .polyline([
[110, 90], [110, point.y - 45],
[110, point.y + 20], [110, point.y + 20],
[200, point.y + 20] [200, point.y + 20]
]) ])
.stroke({ width: 1, color: "red" }); .stroke({ width: 1, color: "#ddd" });
polyline.fill("none").stroke({ polyline.fill("none").stroke({
width: 2, width: 1,
color: "red" color: "#333"
}); });
ele.color = this.setsubcolor(index);
var nested = draw var nested = draw
.nested() .nested()
.size(120, 40) .size(130, 40)
.move(point.x, point.y) .move(point.x, point.y)
.data("childsdv", ele); .data("childsdv", ele);
var rect = nested var rect = nested
.rect(120, 40) .rect(130, 40)
.attr({ fill: "#f06" }) .stroke({ color: "#333", opacity: 0.5, width: 1 })
.radius(5); .attr({ fill: `rgb(${_this.setsubcolor(index)})`, opacity: 0.6 })
.radius(3);
var text = nested.text(function(add) { var text = nested.text(function(add) {
add add
.tspan(`${ele.device_name}`) .tspan(`${ele.device_name}`)
...@@ -319,15 +327,23 @@ export default { ...@@ -319,15 +327,23 @@ export default {
.fill({ color: "#fff" }), .fill({ color: "#fff" }),
add.tspan(`${ele.in_ip}`).newLine(); add.tspan(`${ele.in_ip}`).newLine();
}); });
childgroup.add(nested);
nested.click(function() { nested.click(function() {
let data = this.data("childsdv"); let data = this.data("childsdv");
this.curDevData = data;
_this.getleval(this, data); _this.getleval(this, data);
levalinecolor = data.color;
}); });
}); });
}, },
createdLeval(ev, data) { createdLeval(ev, data) {
let num = Math.ceil(data.length/6); if (levalgroup) {
for(let i = 0; i < num; i++){ levalgroup.clear();
}
var polyline = "";
levalgroup = draw.group();
let num = Math.ceil(data.length / 6);
for (let i = 0; i <= num; i++) {
var laveData = this.setslaveData(data, i); var laveData = this.setslaveData(data, i);
//当前点击节点信息 //当前点击节点信息
let linepoint = { let linepoint = {
...@@ -335,45 +351,65 @@ export default { ...@@ -335,45 +351,65 @@ export default {
y: ev.y() + 20 y: ev.y() + 20
}; };
var _this = this; var _this = this;
console.log(laveData);
laveData.map((ele, index) => { laveData.map((ele, index) => {
let point = { let point = {
x: 330 * i + 430, x: 250 * i + 430,
y: linepoint.y + i * 70 + 30 y: linepoint.y + index * 65 + 30
}; };
if (index == 0) { if (index == 0 && i == num - 1) {
var line = draw var line = draw
.polyline([ .polyline([
[linepoint.x, linepoint.y], [linepoint.x, linepoint.y],
[400, point.y - (index == 0 ? 30 : 58)] [point.x - 50, point.y - (index == 0 ? 30 : 58)]
]) ])
.stroke({ width: 1, color: "red" }); .stroke({ width: 1, color: "red" });
line.fill("none").stroke({ line.fill("none").stroke({
width: 2, width: 1,
color: "green" color: `rgb(${levalinecolor})`
}); });
levalgroup.add(line);
} }
if (linepoint.y < 200) { if (linepoint.y < 500) {
var polyline = draw polyline = draw
.polyline([ .polyline([
[400, linepoint.y], [point.x - 50, linepoint.y],
[400, point.y + 20], [point.x - 50, point.y + 20],
[450, point.y + 20] [point.x + 50, point.y + 20]
]) ])
.stroke({ width: 1, color: "red" }); .stroke({ width: 1, color: `rgb(${levalinecolor})` });
polyline.fill("none").stroke({ polyline.fill("none").stroke({
width: 2, width: 1,
color: "red" color: `rgb(${levalinecolor})`
}); });
levalgroup.add(polyline);
} else {
point = {
x: 250 * i + 430,
y: linepoint.y - index * 70 - 90
};
polyline = draw
.polyline([
[point.x - 50, linepoint.y],
[point.x - 50, point.y + 20],
[point.x + 50, point.y + 20]
])
.stroke({ width: 1, color: `rgb(${levalinecolor})` });
polyline.fill("none").stroke({
width: 1,
color: `rgb(${levalinecolor})`
});
levalgroup.add(polyline);
} }
var nested = draw var nested = draw
.nested() .nested()
.size(120, 40) .size(130, 40)
.move(point.x, point.y) .move(point.x, point.y)
.data("childsdv", ele); .data("childsdv", ele);
var rect = nested var rect = nested
.rect(120, 40) .rect(130, 40)
.attr({ fill: "#f06" }) .attr({ fill: `rgb(${_this.setsubcolor(index)})` })
.radius(5); .radius(3);
var text = nested.text(function(add) { var text = nested.text(function(add) {
add add
.tspan(`${ele.device_name}`) .tspan(`${ele.device_name}`)
...@@ -381,14 +417,14 @@ export default { ...@@ -381,14 +417,14 @@ export default {
.fill({ color: "#fff" }), .fill({ color: "#fff" }),
add.tspan(`${ele.in_ip}`).newLine(); add.tspan(`${ele.in_ip}`).newLine();
}); });
levalgroup.add(nested);
//事件点击 //事件点击
nested.click(function() { nested.click(function() {
let data = this.data("childsdv"); let data = this.data("childsdv");
_this.getleval(this, data); this.curDevData = data;
}); });
}); });
} }
}, },
setslaveData(data, index) { setslaveData(data, index) {
return data.slice(index * 6, 6 * (index + 1)); return data.slice(index * 6, 6 * (index + 1));
......
<template> <template>
<div class="contentBox"> <div class="contentBox">
<div class="content"> <div class="content">
<div style="padding:8px 20px;"> <div style="padding:8px 20px;">
<span style="float: right;"> <span style="float: right;">
<el-button type="info" @click="addUser">添加新用户</el-button> <el-button type="info" @click="addUser">添加新用户</el-button>
</span> </span>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
<div style="padding: 0 15px 20px 23px;"> <div style="padding: 0 15px 20px 23px;">
<el-table <el-table
:height="tableHeight" :height="tableHeight"
:data="tableData" :data="tableData"
stripe stripe
border border
style="width: 100%"> style="width: 100%"
<el-table-column >
align="center" <el-table-column
prop="num" align="center"
:formatter="numFormatter" prop="num"
label="序号"> :formatter="numFormatter"
</el-table-column> label="序号"
<el-table-column >
prop="username" </el-table-column>
align="center" <el-table-column prop="username" align="center" label="用户名">
label="用户名"> </el-table-column>
</el-table-column> <el-table-column align="center" prop="roles[0].name" label="角色名">
<el-table-column </el-table-column>
align="center" <el-table-column
prop="roles[0].name" align="center"
label="角色名"> prop="create_dt"
</el-table-column> width="300"
<el-table-column label="创建时间"
align="center" >
prop="create_dt" </el-table-column>
width="300" <el-table-column
label="创建时间"> align="center"
</el-table-column> width="300"
<el-table-column prop="operation"
align="center" label="操作"
width="300" >
prop="operation" <template slot-scope="scope">
label="操作"> <el-tooltip
<template slot-scope="scope"> content="编辑用户"
<el-tooltip content="编辑用户" placement="bottom" effect="light" :visible-arrow=false> placement="bottom"
<span class="icon-fanxing-xiugai editIcon" @click="editUser(scope.$index, scope.row)"></span> effect="light"
</el-tooltip> :visible-arrow="false"
<!-- <span class="tableSpanBorder"></span> >
<span
class="icon-fanxing-xiugai editIcon"
@click="editUser(scope.$index, scope.row)"
></span>
</el-tooltip>
<!-- <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="icon-fanxing-xiugai editIcon2" @click="reset(scope.$index, scope.row)"></span> <span class="icon-fanxing-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
<span class="el-icon-delete delIcon" @click="delFun(scope.$index, scope.row)"></span> content="删除"
</el-tooltip> placement="bottom"
</template> effect="light"
</el-table-column> :visible-arrow="false"
</el-table> >
<div style="margin-top: 28px;"> <span
<el-pagination class="el-icon-delete delIcon"
style="float: right;" @click="delFun(scope.$index, scope.row)"
background ></span>
prev-text="上一页" </el-tooltip>
next-text="下一页" </template>
:page-sizes="[30, 50, 100, 200]" </el-table-column>
layout="total, prev, pager, next,sizes, jumper" </el-table>
:current-page="page" <div style="margin-top: 28px;">
@size-change="handleSizeChange" <el-pagination
@current-change="handleCurrentChange" style="float: right;"
:total="total"> background
</el-pagination> prev-text="上一页"
<div style="clear: both;"></div> next-text="下一页"
</div> :page-sizes="[30, 50, 100, 200]"
layout="total, prev, pager, next,sizes, jumper"
</div> :current-page="page"
</div> @size-change="handleSizeChange"
<!-- 新增 --> @current-change="handleCurrentChange"
<el-dialog :total="total"
title="新增用户" >
:visible.sync="addVisible" </el-pagination>
@open="openAddDialog" <div style="clear: both;"></div>
width="30%"> </div>
<div> </div>
<el-form label-position="left" label-width="80px" :model="addForm" :rules="rules" ref="addForm" inline-message hide-required-asterisk> </div>
<el-form-item label="角色选项" prop="role_unid"> <!-- 新增 -->
<el-select v-model="addForm.role_unid" placeholder="请选择" :popper-append-to-body=false> <el-dialog
<el-option title="新增用户"
v-for="item in roleList" :visible.sync="addVisible"
:key="item.role_unid" @open="openAddDialog"
:label="item.name" width="30%"
:value="item.role_unid"> >
</el-option> <div>
</el-select> <el-form
</el-form-item> label-position="left"
<el-form-item label="用户名" prop="username"> label-width="80px"
<el-input v-model="addForm.username"></el-input> :model="addForm"
</el-form-item> :rules="rules"
<el-form-item label="密码" prop="password"> ref="addForm"
<el-input v-model="addForm.password" type="password"></el-input> inline-message
</el-form-item> hide-required-asterisk
<el-form-item label="确认新密码" prop="checkPass"> >
<el-input v-model="addForm.checkPass" type="password"></el-input> <el-form-item label="角色选项" prop="role_unid">
</el-form-item> <el-select
</el-form> v-model="addForm.role_unid"
</div> placeholder="请选择"
<span slot="footer" class="dialog-footer"> :popper-append-to-body="false"
<el-button @click="addVisible = false">取 消</el-button> >
<el-button type="primary" @click="addFun('addForm')">确 定</el-button> <el-option
</span> v-for="item in roleList"
</el-dialog> :key="item.role_unid"
<!-- 编辑 --> :label="item.name"
<el-dialog :value="item.role_unid"
title="编辑用户" >
:visible.sync="editVisible" </el-option>
width="30%"> </el-select>
<div> </el-form-item>
<el-form label-position="left" label-width="80px" :model="editForm" :rules="rules" ref="editForm" inline-message hide-required-asterisk> <el-form-item label="用户名" prop="username">
<el-form-item label="角色选项" prop="role_unid"> <el-input v-model="addForm.username"></el-input>
<el-select v-model="editForm.role_unid" placeholder="请选择" :popper-append-to-body=false> </el-form-item>
<el-option <el-form-item label="密码" prop="password">
v-for="item in roleList" <el-input v-model="addForm.password" type="password"></el-input>
:key="item.role_unid" </el-form-item>
:label="item.name" <el-form-item label="确认新密码" prop="checkPass">
:value="item.role_unid"> <el-input v-model="addForm.checkPass" type="password"></el-input>
</el-option> </el-form-item>
</el-select> </el-form>
</el-form-item> </div>
</el-form> <span slot="footer" class="dialog-footer">
</div> <el-button @click="addVisible = false">取 消</el-button>
<span slot="footer" class="dialog-footer"> <el-button type="primary" @click="addFun('addForm')">确 定</el-button>
<el-button @click="editVisible = false">取 消</el-button> </span>
<el-button type="primary" @click="editFun('editForm')">确 定</el-button> </el-dialog>
</span> <!-- 编辑 -->
</el-dialog> <el-dialog title="编辑用户" :visible.sync="editVisible" width="30%">
<div>
<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-select
v-model="editForm.role_unid"
placeholder="请选择"
:popper-append-to-body="false"
>
<el-option
v-for="item in roleList"
:key="item.role_unid"
:label="item.name"
:value="item.role_unid"
>
</el-option>
</el-select>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="editVisible = false">取 消</el-button>
<el-button type="primary" @click="editFun('editForm')">确 定</el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data(){ data() {
var checkRole = (rule, value, callback) => { var checkRole = (rule, value, callback) => {
if (value === '') { if (value === "") {
callback(new Error('请选择角色')); callback(new Error("请选择角色"));
} else { } else {
callback(); callback();
} }
}; };
var checkUser = (rule, value, callback) => { var checkUser = (rule, value, callback) => {
if (value === '') { if (value === "") {
callback(new Error('请输入用户名')); callback(new Error("请输入用户名"));
} else { } else {
callback(); callback();
} }
}; };
var validatePass = (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位"));
}else{ } else {
callback(); callback();
} }
}; };
var validatePass2 = (rule, value, callback) => { var validatePass2 = (rule, value, callback) => {
console.log('aa',this.addForm.password) console.log("aa", this.addForm.password);
if (value === '') { if (value === "") {
callback(new Error('请再次输入密码')); callback(new Error("请再次输入密码"));
} else if (value !== this.addForm.password) { } else if (value !== this.addForm.password) {
callback(new Error('两次输入密码不一致!')); callback(new Error("两次输入密码不一致!"));
} else {
callback();
}
};
return {
total: 0,
page: 1,
pageSize: 30,
addForm: {
norm_type: "login",
role_unid: "",
username: "",
password: "",
checkPass: ""
},
editForm: {
role_unid: ""
},
editRoleUnid: "",
editUnid: "",
tableData: [],
addVisible: false,
editVisible: false,
roleList: [],
rules: {
role_unid: [{ validator: checkRole, trigger: "change" }],
username: [{ validator: checkUser, trigger: "change" }],
password: [{ validator: validatePass, trigger: "change" }],
checkPass: [{ validator: validatePass2, trigger: "change" }]
},
tableHeight: window.opsTableHeight
};
},
components: {},
mounted() {
this.getTableList();
this.getRoleList();
},
methods: {
numFormatter(row, column, cellValue, index) {
return (index + 1) * this.page;
},
handleSizeChange(val) {
this.pageSize = val;
this.getTableList();
},
handleCurrentChange(val) {
this.page = val;
this.getTableList();
},
getTableList() {
this.tableData = [];
console.log("aa", this.userId);
let offset = (this.page - 1) * this.pageSize;
this.$api.ops
.getUserList({
limit: this.pageSize,
offset: offset
})
.then(res => {
this.total = res.total_num;
if (res.list_data == null) {
this.tableData = [];
} else {
this.tableData = res.list_data;
}
})
.catch(error => {});
},
getRoleList() {
this.roleList = [];
this.$api.ops
.getRoleList({
limit: 9999,
offset: 0,
is_active: true
})
.then(res => {
if (res.list_data == null) {
this.roleList = [];
} else {
this.roleList = res.list_data;
}
})
.catch(error => {});
},
delFun(index, row) {
this.$confirm("此操作将永久删除该选项, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$api.ops.delUser({}, row.user_unid).then(res => {
if (!res.ecode) {
this.$message({
type: "success",
message: "删除成功!"
});
this.getTableList();
} else {
this.$message({
type: "error",
message: "删除失败!"
});
}
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除"
});
});
},
reset(index, row) {
this.$confirm("此操作将重置密码, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.$api.ops
.resetPwd(
{
reset_unid: row.unid
},
this.userId
)
.then(res => {
if (res.ecode == 200) {
this.$message({
type: "success",
message: "重置密码成功!"
});
} else {
this.$message({
type: "error",
message: "重置密码失败!"
});
}
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消"
});
});
},
editUser(index, row) {
this.editRoleUnid = row.roles[0].role_unid;
this.editForm.role_unid = row.roles[0].role_unid;
this.editUnid = row.user_unid;
this.editVisible = true;
},
openAddDialog() {
this.$refs["addForm"].resetFields();
},
addUser() {
this.addVisible = true;
},
addFun(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
this.$api.ops
.addUser({
norm_type: this.addForm.norm_type,
username: this.addForm.username,
password: this.addForm.password
})
.then(res => {
if (!res.ecode) {
this.$api.ops
.bindRole(
{
role_unid: this.addForm.role_unid
},
res.user_unid
)
.then(data => {
if (!data.ecode) {
this.$message({
type: "success",
message: "添加成功!"
});
this.addVisible = false;
this.getTableList();
} else {
this.$message({
type: "error",
message: "添加失败!"
});
}
});
} else {
this.$message({
type: "error",
message: "添加失败!"
});
}
});
} else { } else {
callback(); return false;
} }
}; });
return{ },
total:0, editFun(formName) {
page:1, this.$refs[formName].validate(valid => {
pageSize:30, if (valid) {
addForm:{ this.$api.ops
norm_type:"login", .unbindRole({}, this.editUnid, this.editRoleUnid)
role_unid:'', .then(res => {
username:'', this.$api.ops
password:'', .bindRole(
checkPass:'' {
}, role_unid: this.editForm.role_unid
editForm:{ },
role_unid:'', this.editUnid
}, )
editRoleUnid:'', .then(res => {
editUnid:'', if (!res.ecode) {
tableData: [], this.$message({
addVisible:false, type: "success",
editVisible:false, message: "修改成功!"
roleList:[], });
rules: { this.editVisible = false;
role_unid: [ this.getTableList();
{ validator: checkRole, trigger: 'change' } } else {
], this.$message({
username: [ type: "error",
{ validator: checkUser, trigger: 'change' } message: "修改失败!"
], });
password: [ }
{ validator: validatePass, trigger: 'change' } });
], });
checkPass:[ } else {
{ validator: validatePass2, trigger: 'change' } return false;
] }
}, });
tableHeight:window.opsTableHeight }
} }
}, };
components:{
},
mounted(){
this.getTableList();
this.getRoleList();
},
methods:{
numFormatter(row, column, cellValue, index) {
return (index+1)*this.page;
},
handleSizeChange(val) {
this.pageSize=val;
this.getTableList();
},
handleCurrentChange(val) {
this.page=val;
this.getTableList();
},
getTableList(){
this.tableData=[];
console.log('aa',this.userId)
let offset = (this.page - 1) * this.pageSize;
this.$api.ops.getUserList({
limit: this.pageSize,
offset: offset,
}).then((res)=>{
this.total=res.total_num;
if(res.list_data==null){
this.tableData=[]
}else{
this.tableData=res.list_data;
}
}).catch((error)=>{
})
},
getRoleList(){
this.roleList=[];
this.$api.ops.getRoleList({
limit: 9999,
offset: 0,
is_active:true
}).then((res)=>{
if(res.list_data==null){
this.roleList=[]
}else{
this.roleList=res.list_data;
}
}).catch((error)=>{
})
},
delFun(index,row){
this.$confirm('此操作将永久删除该选项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.ops.delUser({},row.user_unid).then(res=>{
if(!res.ecode){
this.$message({
type: 'success',
message: '删除成功!'
});
this.getTableList();
}else{
this.$message({
type: 'error',
message: '删除失败!'
});
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
reset(index,row){
this.$confirm('此操作将重置密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.ops.resetPwd({
reset_unid:row.unid
},this.userId).then(res=>{
if(res.ecode==200){
this.$message({
type: 'success',
message: '重置密码成功!'
});
}else{
this.$message({
type: 'error',
message: '重置密码失败!'
});
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
editUser(index,row){
this.editRoleUnid=row.roles[0].role_unid;
this.editForm.role_unid=row.roles[0].role_unid;
this.editUnid=row.user_unid;
this.editVisible=true;
},
openAddDialog(){
this.$refs['addForm'].resetFields();
},
addUser(){
this.addVisible=true;
},
addFun(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
this.$api.ops.addUser({
norm_type:this.addForm.norm_type,
username:this.addForm.username,
password:this.addForm.password
}).then(res=>{
if(!res.ecode){
this.$api.ops.bindRole({
"role_unid":this.addForm.role_unid,
},res.user_unid).then(data=>{
if(!data.ecode){
this.$message({
type: 'success',
message: '添加成功!'
});
this.addVisible=false;
this.getTableList();
}else{
this.$message({
type: 'error',
message: '添加失败!'
});
}
})
}else{
this.$message({
type: 'error',
message: '添加失败!'
});
}
})
} else {
return false;
}
});
},
editFun(formName){
this.$refs[formName].validate((valid) => {
if (valid) {
this.$api.ops.unbindRole({},this.editUnid,this.editRoleUnid).then(res=>{
this.$api.ops.bindRole({
role_unid:this.editForm.role_unid
},this.editUnid).then(res=>{
if(!res.ecode){
this.$message({
type: 'success',
message: '修改成功!'
});
this.editVisible=false;
this.getTableList();
}else{
this.$message({
type: 'error',
message: '修改失败!'
});
}
})
})
} else {
return false;
}
});
}
},
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.topCon{
background: $white-back-color;
margin-bottom: 12px;
height: 100px;
.left{
display: inline-block;
margin: {
top: 22px;
left: 30px;
};
img{
width:65px ;
height: 55px;
margin-right: 11px;
}
.topText{
font-size:24px;
font-family:MicrosoftYaHeiUI-Bold,MicrosoftYaHeiUI;
font-weight:bold;
margin-bottom: 4px;
}
.bottomText{
font-size:14px;
font-family:MicrosoftYaHeiUI;
}
}
.right{
float: right;
.topText{
font-size:28px;
font-family:MicrosoftYaHeiUI-Bold,MicrosoftYaHeiUI;
font-weight:bold;
}
.bottomText{
position: relative;
top: -1px;
font-size:14px;
font-family:MicrosoftYaHeiUI;
}
}
.textCon{
display: inline-block;
vertical-align: top;
}
.border{
display: inline-block;
height: 40px;
border: {
left: 2px solid $border-color;
};
}
.rightBox{
margin-top: 14px;
display: inline-block;
img{
margin:{
top:15px;
right: 22px;
}
}
}
.rightBox:nth-of-type(1){
img{
width: 34px;
height: 34px;
}
.textCon{
margin-right:114px ;
}
}
.rightBox:nth-of-type(2){
position: relative;
top: 4px;
img{
width: 40px;
height: 40px;
margin-left: 102px;
}
.textCon{
margin-right:101px ;
}
}
.rightBox:nth-of-type(3){
img{
width: 34px;
height: 35px;
margin-left: 104px;
}
.textCon{
margin-right:184px ;
}
}
}
.content{
background: #FFFFFF;
}
.inputBox{
margin-right: 20px;
}
.selectBox{
margin-right: 20px;
}
.editIcon{
cursor: pointer;
color:#0069ff;
font-size:16px;
}
.editIcon2{
cursor: pointer;
color:#87d14b;
font-size:16px;
}
.playIcon{
cursor: pointer;
color:#34b3a2;
font-size:16px;
}
.pauseIcon{
cursor: pointer;
color:#ffc62e;
font-size:14px;
}
.delIcon{
cursor: pointer;
color:#f2365a;
font-size:16px;
}
</style>
\ No newline at end of file \ No newline at end of file
.topCon {
background: $white-back-color;
margin-bottom: 12px;
height: 100px;
.left {
display: inline-block;
margin: {
top: 22px;
left: 30px;
}
img {
width: 65px;
height: 55px;
margin-right: 11px;
}
.topText {
font-size: 24px;
font-family: MicrosoftYaHeiUI-Bold, MicrosoftYaHeiUI;
font-weight: bold;
margin-bottom: 4px;
}
.bottomText {
font-size: 14px;
font-family: MicrosoftYaHeiUI;
}
}
.right {
float: right;
.topText {
font-size: 28px;
font-family: MicrosoftYaHeiUI-Bold, MicrosoftYaHeiUI;
font-weight: bold;
}
.bottomText {
position: relative;
top: -1px;
font-size: 14px;
font-family: MicrosoftYaHeiUI;
}
}
.textCon {
display: inline-block;
vertical-align: top;
}
.border {
display: inline-block;
height: 40px;
border: {
left: 2px solid $border-color;
}
}
.rightBox {
margin-top: 14px;
display: inline-block;
img {
margin: {
top: 15px;
right: 22px;
}
}
}
.rightBox:nth-of-type(1) {
img {
width: 34px;
height: 34px;
}
.textCon {
margin-right: 114px;
}
}
.rightBox:nth-of-type(2) {
position: relative;
top: 4px;
img {
width: 40px;
height: 40px;
margin-left: 102px;
}
.textCon {
margin-right: 101px;
}
}
.rightBox:nth-of-type(3) {
img {
width: 34px;
height: 35px;
margin-left: 104px;
}
.textCon {
margin-right: 184px;
}
}
}
.content {
background: #ffffff;
}
.inputBox {
margin-right: 20px;
}
.selectBox {
margin-right: 20px;
}
.editIcon {
cursor: pointer;
color: #0069ff;
font-size: 16px;
}
.editIcon2 {
cursor: pointer;
color: #87d14b;
font-size: 16px;
}
.playIcon {
cursor: pointer;
color: #34b3a2;
font-size: 16px;
}
.pauseIcon {
cursor: pointer;
color: #ffc62e;
font-size: 14px;
}
.delIcon {
cursor: pointer;
color: #f2365a;
font-size: 16px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!