Merge remote-tracking branch 'origin/fencang' into fencang

fencang
anthonywj 3 years ago
commit 012c107f4f

@ -0,0 +1,7 @@
//封装字符串相关的方法
export function isBlank(value) {
value = value.trim();
if (value === "" || value === null || value === "string") {
return true;
}
}

@ -1,467 +1,482 @@
<template> <template>
<div> <div>
<el-card> <el-card>
<el-form :inline="true" :model="query" class="query-form" size="mini"> <el-form :inline="true" :model="query" class="query-form" size="mini">
<el-form-item class="query-form-item"> <el-form-item class="query-form-item">
<el-input v-model="query.userName" placeholder="用户账号"></el-input> <el-input v-model="query.userName" placeholder="用户账号"></el-input>
</el-form-item> </el-form-item>
<el-form-item class="query-form-item"> <el-form-item class="query-form-item">
<el-select v-model="query.userFlag" placeholder="状态"> <el-select v-model="query.userFlag" placeholder="状态">
<el-option label="全部" value=""></el-option> <el-option label="全部" value=""></el-option>
<el-option label="禁用" value="0"></el-option> <el-option label="禁用" value="0"></el-option>
<el-option label="正常" value="1"></el-option> <el-option label="正常" value="1"></el-option>
<el-option label="未验证" value="2"></el-option> <el-option label="未验证" value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <!--
<el-form-item class="query-form-item"> <el-form-item class="query-form-item">
<el-select v-model="query.roleId" placeholder="角色"> <el-select v-model="query.roleId" placeholder="角色">
<el-option label="全部角色" value=""></el-option> <el-option label="全部角色" value=""></el-option>
<el-option v-for="item in roles" :key="item.id" :label="item.name" :value="item.id"></el-option> <el-option v-for="item in roles" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
--> -->
<el-form-item> <el-form-item>
<el-button-group> <el-button-group>
<el-button <el-button
type="primary" type="primary"
icon="el-icon-refresh" icon="el-icon-refresh"
@click="onReset" @click="onReset"
></el-button> ></el-button>
<el-button type="primary" icon="search" @click="onSubmit" <el-button type="primary" icon="search" @click="onSubmit"
>查询 >查询
</el-button </el-button
> >
<el-button type="primary" @click.native="handleForm(null, null)" <el-button type="primary" @click.native="handleForm(null, null)"
:disabled="!configParms.sysUser && query.customerId == 110" :disabled="!configParms.sysUser && query.customerId == 110"
>新增 >新增
</el-button </el-button
> >
</el-button-group> </el-button-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="list" style="width: 100%"> <el-table v-loading="loading" :data="list" style="width: 100%">
<el-table-column label="用户账号" prop="userName" fixed></el-table-column> <el-table-column label="用户账号" prop="userName" fixed></el-table-column>
<el-table-column label="用户名称" prop="employeeName" fixed> <el-table-column label="用户名称" prop="employeeName" fixed>
</el-table-column> </el-table-column>
<el-table-column label="状态" fixed=""> <el-table-column label="状态" fixed="">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.userFlag | statusFilterType">{{ <el-tag :type="scope.row.userFlag | statusFilterType">{{
scope.row.userFlag | statusFilterName scope.row.userFlag | statusFilterName
}} }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" prop="comments" fixed></el-table-column> <el-table-column label="备注" prop="comments" fixed></el-table-column>
<el-table-column <el-table-column
label="登录时间" label="登录时间"
with="300" with="300"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<i class="el-icon-time"></i> <i class="el-icon-time"></i>
<span> {{ scope.row.lastLoginTime }}</span> <span> {{ scope.row.lastLoginTime }}</span>
<!-- <span>{{ formatTime(scope.row.lastLoginTime,"yyyy-MM-dd") }}</span> --> <!-- <span>{{ formatTime(scope.row.lastLoginTime,"yyyy-MM-dd") }}</span> -->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" fixed="right"> <el-table-column label="操作" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
type="text" type="text"
size="small" size="small"
@click.native="handleForm(scope.$index, scope.row)" @click.native="handleForm(scope.$index, scope.row)"
>编辑 >编辑
</el-button> </el-button>
<el-button <el-button
type="text" type="text"
size="small" size="small"
:disabled="scope.row.id === 1 || !configParms.sysUser" :disabled="scope.row.id === 1 || !configParms.sysUser"
@click.native="handleDel(scope.$index, scope.row)" @click.native="handleDel(scope.$index, scope.row)"
>删除 >删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-pagination <el-pagination
:page-size="query.limit" :page-size="query.limit"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
layout="prev, pager, next" layout="prev, pager, next"
:total="total" :total="total"
> >
</el-pagination> </el-pagination>
<!--表单--> <!--表单-->
<el-dialog <el-dialog
:title="formMap[formName]" :title="formMap[formName]"
:visible.sync="formVisible" :visible.sync="formVisible"
:before-close="hideForm" :before-close="hideForm"
:close-on-click-modal="false" :close-on-click-modal="false"
:close-on-press-escape="false" :close-on-press-escape="false"
width="70%" v-if="formVisible"
top="5vh" width="70%"
> top="5vh"
<el-form :model="formData" :rules="formRules" ref="dataForm"> >
<el-row :gutter="20" class="el-row" type="flex"> <el-form :model="formData" :rules="formRules" ref="dataForm">
<el-col :span="10" class="el-col" type="flex"> <el-row :gutter="20" class="el-row" type="flex">
<div class="text item"> <el-col :span="10" class="el-col" type="flex">
<el-form-item label="用户账号" prop="userName"> <div class="text item">
<el-input v-model="formData.userName" size="small"></el-input> <el-form-item label="用户账号" prop="userName">
</el-form-item> <el-input v-model="formData.userName" size="small"></el-input>
</div> </el-form-item>
</el-col> </div>
<el-col :span="10" class="el-col"> </el-col>
<div class="text item"> <el-col :span="10" class="el-col">
<div class="text item"> <div class="text item">
<el-form-item label="用户名称" prop="employeeName"> <div class="text item">
<el-input v-model="formData.employeeName" size="small"></el-input> <el-form-item label="用户名称" prop="employeeName">
</el-form-item> <el-input v-model="formData.employeeName" size="small"></el-input>
</div> </el-form-item>
</div> </div>
</el-col> </div>
</el-row> </el-col>
</el-row>
<el-row :gutter="20" class="el-row" type="flex"> <el-row :gutter="20" class="el-row" type="flex">
<el-col :span="10" class="el-col" type="flex"> <el-col :span="10" class="el-col" type="flex">
<div class="text item"> <div class="text item">
<el-form-item label="登录密码" prop="passWord"> <el-form-item label="登录密码" prop="passWord">
<el-input <el-input
type="password" type="password"
size="small" size="small"
v-model="formData.passWord" v-model="formData.passWord"
></el-input> ></el-input>
</el-form-item> </el-form-item>
</div> </div>
</el-col> </el-col>
<el-col :span="10" class="el-col"> <el-col :span="10" class="el-col">
<div class="text item"> <div class="text item">
<div class="text item"> <div class="text item">
<el-form-item label="确认密码" prop="checkPassword"> <el-form-item label="确认密码" prop="checkPassword">
<el-input <el-input
type="password" type="password"
size="small"
v-model="formData.checkPassword"
></el-input>
</el-form-item>
</div>
</div>
</el-col>
</el-row>
<el-form-item label="状态" prop="userFlag">
<el-radio-group v-model="formData.userFlag" :disabled="formData.id === 1">
<el-radio :label="0">禁用</el-radio>
<el-radio :label="1">正常</el-radio>
<!-- <el-radio :label="2">未验证</el-radio>-->
</el-radio-group>
</el-form-item>
<el-form-item label="角色">
<el-checkbox-group v-model="formData.roles" :disabled="formData.id === 1">
<el-checkbox
v-for="item in roles"
:key="item.id"
:label="item.id"
>{{ item.name }}
</el-checkbox
>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click.native="hideForm" size="small">取消</el-button>
<el-button
type="primary"
size="small" size="small"
v-model="formData.checkPassword" @click.native="formSubmit()"
></el-input> :loading="formLoading"
</el-form-item> >提交
</el-button
>
</div> </div>
</div> </el-dialog>
</el-col> </el-card>
</el-row> </div>
<el-form-item label="状态" prop="userFlag">
<el-radio-group v-model="formData.userFlag" :disabled="formData.id === 1">
<el-radio :label="0">禁用</el-radio>
<el-radio :label="1">正常</el-radio>
<!-- <el-radio :label="2">未验证</el-radio>-->
</el-radio-group>
</el-form-item>
<el-form-item label="角色">
<el-checkbox-group v-model="formData.roles" :disabled="formData.id === 1">
<el-checkbox
v-for="item in roles"
:key="item.id"
:label="item.id"
>{{ item.name }}
</el-checkbox
>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click.native="hideForm" size="small">取消</el-button>
<el-button
type="primary"
size="small"
@click.native="formSubmit()"
:loading="formLoading"
>提交
</el-button
>
</div>
</el-dialog>
</el-card>
</div>
</template> </template>
<script> <script>
import { import {
authAdminList, authAdminList,
authAdminRoleList, authAdminRoleList,
authAdminSave, authAdminSave,
authAdminDelete, authAdminDelete,
roleCustomers roleCustomers
} from "../../../api/auth/authAdmin"; } from "../../../api/auth/authAdmin";
import store from "../../../store/index"; import store from "../../../store/index";
import {findConfig} from "@/api/thrsys/spsSyncStatus"; import {findConfig} from "@/api/thrsys/spsSyncStatus";
import {isBlank} from "@/utils/strUtil";
const formJson = { const formJson = {
id: "", id: "",
passWord: "", passWord: "",
userName: "", userName: "",
checkPassword: "", checkPassword: "",
employeeName: "", employeeName: "",
userFlag: 1, userFlag: 1,
roles: [] roles: []
}; };
export default { export default {
data() { data() {
let validatePass = (rule, value, callback) => { let validatePass = (rule, value, callback) => {
if (value === "") { if (value === "") {
callback(new Error("请输入密码")); callback(new Error("请输入密码"));
} else { } else {
callback(); callback();
}
};
let validatePass2 = (rule, value, callback) => {
if (value === "") {
callback(new Error("请再次输入密码"));
} else if (value !== this.formData.passWord) {
callback(new Error("两次输入密码不一致!"));
} else {
callback();
}
};
return {
roles: [],
query: {
userName: "",
userFlag: "",
page: 1,
limit: 20,
roleId: "",
customerId: store.getters.customerId,
},
list: [],
total: 0,
loading: true,
index: null,
formName: null,
formMap: {
add: "新增",
edit: "编辑"
},
formLoading: false,
formVisible: false,
formData: formJson,
configParms: {},
formRules: {},
addRules: {
userName: [
{required: true, message: "请输入姓名", trigger: "blur"}
],
passWord: [
{required: true, message: "请输入密码", trigger: "blur"},
{validator: validatePass, trigger: "blur"}
],
checkPassword: [
{
required: true,
message: "请再次输入密码",
trigger: "blur"
},
{validator: validatePass2, trigger: "blur"}
],
userFlag: [
{required: true, message: "请选择状态", trigger: "change"}
]
},
editRules: {
userName: [
{required: true, message: "请输入姓名", trigger: "blur"}
],
userFlag: [
{required: true, message: "请选择状态", trigger: "change"}
],
passWord: [
{required: true, message: "请输入密码", trigger: "blur"}
]
},
deleteLoading: false
};
},
methods: {
onReset() {
this.$router.push({
path: ""
});
this.query = {
userName: "",
userFlag: "",
page: 1,
limit: 20,
roleId: "",
customerId: store.getters.customerId,
};
this.getList();
},
onSubmit() {
this.$router.push({
path: "",
query: this.query
});
this.getList();
},
handleCurrentChange(val) {
this.query.page = val;
this.getList();
},
getList() {
this.loading = true;
authAdminList(this.query)
.then(response => {
this.loading = false;
this.list = response.data.list || [];
this.total = response.data.total || 0;
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
this.roles = [];
});
},
getRoleList() {
roleCustomers(this.query)
.then(response => {
this.roles = response.data.list || [];
})
.catch(() => {
this.roles = [];
});
},
//
resetForm() {
if (this.$refs["dataForm"]) {
//
this.$refs["dataForm"].clearValidate();
//
this.$refs["dataForm"].resetFields();
}
},
//
hideForm() {
//
this.formVisible = !this.formVisible;
//
this.$refs["dataForm"].resetFields();
return true;
},
//
handleForm(index, row) {
this.formVisible = true;
this.formData = JSON.parse(JSON.stringify(formJson));
if (row !== null) {
this.formData = Object.assign({}, row);
}
this.formName = "add";
this.formRules = this.addRules;
if (index !== null) {
this.index = index;
this.formName = "edit";
this.formRules = this.editRules;
}
},
formSubmit() {
this.$refs["dataForm"].validate(valid => {
if (valid) {
this.formLoading = true;
let data = Object.assign({}, this.formData);
authAdminSave(data, this.formName).then(response => {
this.formLoading = false;
if (response.code !== 20000) {
this.$message.error(response.message);
return false;
} }
this.$message.success("操作成功"); };
this.formVisible = false; let validatePass2 = (rule, value, callback) => {
if (this.formName === "add") { if (value === "") {
// callback(new Error("请再次输入密码"));
if (response.data && response.data.id) { } else if (value !== this.formData.passWord) {
data.id = response.data.id; callback(new Error("两次输入密码不一致!"));
this.list.unshift(data);
}
} else { } else {
this.list.splice(this.index, 1, data); callback();
} }
// };
this.resetForm(); return {
}); roles: [],
} query: {
}); userName: "",
userFlag: "",
page: 1,
limit: 20,
roleId: "",
customerId: store.getters.customerId,
},
list: [],
total: 0,
loading: true,
index: null,
formName: null,
formMap: {
add: "新增",
edit: "编辑"
},
formLoading: false,
formVisible: false,
formData: formJson,
configParms: {},
formRules: {},
addRules: {
userName: [
{required: true, message: "请输入姓名", trigger: "blur"}
],
passWord: [
{required: true, message: "请输入密码", trigger: "blur"},
{validator: validatePass, trigger: "blur"}
],
checkPassword: [
{
required: true,
message: "请再次输入密码",
trigger: "blur"
},
{validator: validatePass2, trigger: "blur"}
],
userFlag: [
{required: true, message: "请选择状态", trigger: "change"}
]
},
editRules: {
userName: [
{required: true, message: "请输入姓名", trigger: "blur"}
],
userFlag: [
{required: true, message: "请选择状态", trigger: "change"}
],
passWord: [
{required: true, message: "请输入密码", trigger: "blur"}
]
},
deleteLoading: false
};
}, },
// methods: {
handleDel(index, row) { onReset() {
if (row.id) { this.$router.push({
this.$confirm("确认删除该记录吗?", "提示", { path: ""
type: "warning" });
}) this.query = {
.then(() => { userName: "",
let para = {id: row.id}; userFlag: "",
this.deleteLoading = true; page: 1,
authAdminDelete(para) limit: 20,
.then(response => { roleId: "",
this.deleteLoading = false; customerId: store.getters.customerId,
if (response.code !== 20000) { };
this.$message.error(response.message); this.getList();
return false; },
} onSubmit() {
this.$message.success("操作成功"); this.$router.push({
// path: "",
this.list.splice(index, 1); query: this.query
}) });
.catch(() => { this.getList();
this.deleteLoading = false; },
}); handleCurrentChange(val) {
this.query.page = val;
this.getList();
},
getList() {
this.loading = true;
authAdminList(this.query)
.then(response => {
this.loading = false;
this.list = response.data.list || [];
this.total = response.data.total || 0;
})
.catch(() => {
this.loading = false;
this.list = [];
this.total = 0;
this.roles = [];
});
},
getRoleList() {
roleCustomers(this.query)
.then(response => {
this.roles = response.data.list || [];
})
.catch(() => {
this.roles = [];
});
},
//
resetForm() {
this.$nextTick(() => {
this.$refs["dataForm"].resetFields();
this.$refs["dataForm"].clearValidate();
}) })
.catch(() => { },
this.$message.info("取消删除"); //
hideForm() {
//
this.formVisible = !this.formVisible;
//
this.$refs["dataForm"].resetFields(); //
return true;
},
//
handleForm(index, row) {
this.formVisible = true;
this.resetForm();
this.formData = JSON.parse(JSON.stringify(formJson));
if (row !== null) {
this.formData = Object.assign({}, row);
}
this.formName = "add";
this.formRules = this.addRules;
if (index !== null) {
this.index = index;
this.formName = "edit";
this.formRules = this.editRules;
}
},
formSubmit() {
if (isBlank(this.formData.userName)) {
this.$message.error("用户账号不能为空");
return;
} else if (isBlank(this.formData.passWord)) {
this.$message.error("密码不能为空")
return;
} else if (isBlank(this.formData.employeeName)) {
this.$message.error("用户名称不能为空");
return;
} else if (this.formData.roles.length === 0) {
this.$message.error("未指定角色!")
return;
}
this.$refs["dataForm"].validate(valid => {
if (valid) {
this.formLoading = true;
let data = Object.assign({}, this.formData);
authAdminSave(data, this.formName).then(response => {
this.formLoading = false;
if (response.code !== 20000) {
this.$message.error(response.message);
return false;
}
this.$message.success("操作成功");
this.formVisible = false;
if (this.formName === "add") {
//
if (response.data && response.data.id) {
data.id = response.data.id;
this.list.unshift(data);
}
} else {
this.list.splice(this.index, 1, data);
}
//
this.resetForm();
});
}
}); });
} },
}, //
getSyncConfig() { handleDel(index, row) {
findConfig() if (row.id) {
.then((response) => { this.$confirm("确认删除该记录吗?", "提示", {
if (response.code == 20000) { type: "warning"
this.configParms = response.data; })
.then(() => {
let para = {id: row.id};
this.deleteLoading = true;
authAdminDelete(para)
.then(response => {
this.deleteLoading = false;
if (response.code !== 20000) {
this.$message.error(response.message);
return false;
}
this.$message.success("操作成功");
//
this.list.splice(index, 1);
})
.catch(() => {
this.deleteLoading = false;
});
})
.catch(() => {
this.$message.info("取消删除");
});
} }
}) },
.catch(() => { getSyncConfig() {
}); findConfig()
.then((response) => {
if (response.code == 20000) {
this.configParms = response.data;
}
})
.catch(() => {
});
},
},
filters: {
statusFilterType(status) {
const statusMap = {
0: "gray",
1: "success",
2: "danger"
};
return statusMap[status];
},
statusFilterName(status) {
const statusMap = {
0: "禁用",
1: "正常",
2: "未验证"
};
return statusMap[status];
}
}, },
}, mounted() {
filters: {
statusFilterType(status) {
const statusMap = {
0: "gray",
1: "success",
2: "danger"
};
return statusMap[status];
}, },
statusFilterName(status) { created() {
const statusMap = { //
0: "禁用", let query = this.$route.query;
1: "正常", this.query = Object.assign(this.query, query);
2: "未验证" this.query.limit = parseInt(this.query.limit);
}; //
return statusMap[status]; this.getList();
//
this.getRoleList();
this.getSyncConfig();
} }
},
mounted() {
},
created() {
//
let query = this.$route.query;
this.query = Object.assign(this.query, query);
this.query.limit = parseInt(this.query.limit);
//
this.getList();
//
this.getRoleList();
this.getSyncConfig();
}
}; };
</script> </script>

Loading…
Cancel
Save