You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

483 lines
15 KiB

<template>
<div>
<div class="tab-header">
<el-form ref="form" :inline="true" :model="search" label-width="80px">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="用户名">
<el-input v-model="search.userName" clearable></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="search.name" clearable></el-input>
</el-form-item>
<el-form-item label="角色">
<el-select v-model="search.roleSid" filterable clearable placeholder="请选择">
<el-option v-for="item in roleListAll" :key="item.sid" :label="item.name" :value="item.sid"></el-option>
</el-select>
</el-form-item>
<el-form-item label="部门">
<el-input v-model="search.orgName" clearable></el-input>
<!-- <el-select v-model="search.roleSid" clearable placeholder="请选择">-->
<!-- <el-option v-for="(item,i) in roleListAll" :key="i" :label="item.name" :value="item.sid"></el-option>-->
<!-- </el-select>-->
</el-form-item>
<el-button @click="getOrgUserList(1)">查询</el-button>
</el-col>
</el-row>
</el-form>
</div>
<!-- table -->
<el-table :data="userTable" border style="width: 100%;">
<el-table-column label="序号" width="50px" type="index" align="center">
</el-table-column>
<el-table-column label="操作" width="300px" align="center">
<template slot-scope="scope">
<el-button @click="setRole(scope.row)" type="primary" size="mini">
设置角色
</el-button>
<el-button @click="initPwd(scope.row)" type="danger" size="mini">
初始化密码
</el-button>
<!-- <el-button @click="del(scope.row)" type="danger" size="mini">
删除
</el-button>-->
</template>
</el-table-column>
<el-table-column prop="userName" label="用户名" align="center">
<template slot-scope="scope">
<!-- <span class="tablerow-click" @click="userinfoChange(scope.row)">-->{{ scope.row.userName }}<!--</span>-->
</template>
</el-table-column>
<el-table-column prop="userType" label="用户类型" align="center"></el-table-column>
<el-table-column prop="name" label="姓名" width="120px" align="center"></el-table-column>
<el-table-column prop="departmentName" label="部门" align="center"></el-table-column>
<el-table-column prop="postName" label="岗位" align="center"></el-table-column>
<el-table-column prop="isEnable" label="是否可用" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.isEnable"
active-value='1'
inactive-value='0'
active-color="#13ce66"
inactive-color="#ff4949"
@change="enabledChange($event,scope.row)">
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination :total="page.total" :page.sync="page.current" :limit.sync="page.size" @pagination="pagination"/>
<!-- 角色设置 -->
<el-dialog title="设置角色" :visible.sync="roleDialog" width="30%">
<el-form :model="roleForm" :rules="rules" ref="roleForm">
<el-form-item label="角色名称" :label-width="formLabelWidth" prop="roleSid">
<el-select v-model="roleForm.roleSid" placeholder="请选择" filterable multiple>
<el-option v-for="(item,i) in roleList" :key="i" :label="item.name" :value="item.sid"></el-option>
</el-select>
<!--<el-button type="primary" size='mini' @click="toNav('RoleAdminister')" style="margin-left: 10px;" circle icon="el-icon-plus"></el-button>-->
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="saveRole('roleForm')">保 存</el-button>
<el-button @click="roleDialog = false">关 闭</el-button>
</div>
</el-dialog>
<!-- 部门设置 -->
<el-dialog title="部门设置" :visible.sync="bm_Dialog" width="30%">
<el-form :model="bm_Form" :rules="rules" ref="bm_Form">
<el-form-item label="部门名称" :label-width="formLabelWidth" prop="departmentSid">
<!-- <el-select v-model="bm_Form.departmentSid" placeholder="请选择">
<el-option v-for="item in bm_List"
:key="item.departmentSid"
:label="item.departmentName"
:value="item.departmentSid"
></el-option>
</el-select> -->
<el-cascader
v-model="bm_Form.departmentSid"
:options="treedata"
:props="props"></el-cascader>
<el-button type="primary" size='mini' @click="toNav('deptManage')" style="margin-left: 10px;" circle
icon="el-icon-plus"></el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="saveOrg('bm_Form')"> </el-button>
<el-button @click="bm_Dialog = false"> </el-button>
</div>
</el-dialog>
<!-- 编辑信息 -->
<el-dialog title="编辑用户信息" :visible.sync="editDialog" width="40%">
<table class="e-table" cellspacing="0">
<tr>
<td>姓名</td>
<td>
<el-input v-model="form.name" style="width:300px"></el-input>
</td>
</tr>
<tr>
<td>用户类型</td>
<td>
<el-select v-model="form.userTypeKey" @change="$forceUpdate()" style="width:300px">
<el-option v-for="(item, i) in userTypeData" :key="i" :label="item.name" :value="item.value">
</el-option>
</el-select>
</td>
</tr>
<tr>
<td>部门</td>
<td>
<el-select v-model="form.deptSid" placeholder="请选择" @change="$forceUpdate()" style="width:300px">
<el-option hidden :key="form.deptSid" :label="orgName" :value="form.deptSid"></el-option>
<el-tree :data="treedata" ref="Tree" show-checkbox accordion node-key="sid" :default-checked-keys="checkedId" :default-expand-all='true' :check-strictly='true' :props="defaultProps" @check-change="checkchange">
</el-tree>
</el-select>
</td>
</tr>
<tr>
<td>岗位</td>
<td>
<el-select v-model="form.postSid" @change="$forceUpdate()" style="width:300px">
<el-option v-for="(item, i) in postSidData" :key="i" :label="item.name" :value="item.sid"></el-option>
</el-select>
<!--<el-input v-model="form.postSid"></el-input>-->
</td>
</tr>
<tr>
<td>手机号码</td>
<td>
<el-input v-model="form.userName" style="width:300px"></el-input>
</td>
</tr>
<tr>
<td>手机验证码</td>
<td>
<el-input v-model="form.verificationCode" placeholder="请输入验证码" style="width:300px">
<el-button v-show="showCode" slot="append" @click.native="getIdentifying">获取验证码</el-button>
<el-button v-show="!showCode" slot="append">{{ phoneCodeCount }} s</el-button>
</el-input>
</td>
</tr>
</table>
<div style="margin-top: 20px; text-align: center;">
<el-button type="primary" @click="save()">保 存</el-button>
<el-button @click="editDialog = false">关 闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
userList,
delUser,
initPwd,
setRole,
orgList,
postList,
saveOrgRole,
roleList,
setRoleEnable,
userUpdata
} from '@/api/system/userManage/index.js'
export default {
data() {
return {
editDialog: false,
form: {},
userTypeData: [{
value: '1',
name: '员工'
}, {
value: '2',
name: '客户'
}, {
value: '3',
name: '供应商'
}],
checkedId: [],
orgName: '',
defaultProps: {
children: 'children',
label: 'name'
},
showCode: true,
postSidData: [],
phoneCodeCount: '',
timer: null,
roleListAll: [],
search: {
name: '',
userName: '',
roleSid: ''
},
props: {
value: 'sid',
label: 'name',
children: 'orgDepartmentVoList'
},
treedata: null,
page: {
total: 0, // 默认数据总数
current: 1, // 默认开始页面
size: 10 // 每页的数据条数
},
userTable: [],
clientTable: [],
// 设置角色
formLabelWidth: '100',
roleDialog: false,
roleList: [],
roleForm: {
roleSid: '',
userSid: ''
},
// 部门
bm_Dialog: false,
postSid: '',
bm_Form: { departmentSid: '' },
bm_List: [],
rules: {
roleSid: [{ required: true, message: '请选择角色名称', trigger: 'blur' }],
departmentSid: [{ required: true, message: '请选择部门名称', trigger: 'blur' }]
}
}
},
props: ['dataObj'],
watch: {
dataObj: {
handler(val) {
this.getOrgUserList()
},
deep: true
}
},
mounted() {
this.getOrgUserList()
this.getRoleList()
this.getOrgTree()
this.getOrgList()
},
methods: {
// 列表 + 初始化
getOrgUserList(flag) {
if (flag === '1') {
this.page.current = 1
}
let params = this.page
params.params = this.search
userList(params).then(res => {
this.page.total = res.data.total
this.userTable = res.data.records
})
},
getRoleList() {
var param = {}
roleList(param).then(res => {
if (res.code === '200') {
this.roleListAll = res.data
}
})
},
// 分页
pagination(val) {
this.page.current = val.pageNum
this.page.size = val.pageSize
this.getOrgUserList()
},
getOrgTree() { // 获取部门树形列表
function treeArr(data) {
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
if (data[i].orgDepartmentVoList.length > 0) {
treeArr(data[i].orgDepartmentVoList)
} else {
delete data[i].orgDepartmentVoList
}
}
}
}
// getOrgTree({organizationSid: this.$store.getters.userInfo.orgSid}).then(res => {
// let tree = res.data[0].orgDepartmentVoList
// treeArr(tree)
// this.treedata = tree
// })
},
// 设置角色 设置 用户ID
setRole(row) {
this.roleForm.roleSid = []
this.roleDialog = true
this.roleForm.sid = row.sid
this.roleForm.userSid = row.sid
setRole(this.roleForm).then(res => {
this.roleList = res.data
for (let i = 0; i < res.data.length; i++) {
if (res.data[i].checked === '0') {
this.roleForm.roleSid.push(res.data[i].sid)
}
}
// this.roleForm.roleSid = res.data.filter(item=> item.checked =='0')
})
},
// 设置角色 提交
saveRole(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.roleForm.roleSid = this.roleForm.roleSid.toString()
saveOrgRole(this.roleForm).then(res => {
if (res.code === '200') {
this.roleDialog = false
this.getOrgUserList()
this.$message({
message: res.msg,
type: 'success'
})
}
})
} else {
return false
}
})
},
// 设置部门 提交
saveOrg(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let params = { // 请求的参数
departmentSid: this.bm_Form.departmentSid[this.bm_Form.departmentSid.length - 1],
staffSid: this.bm_Form.staffSid
}
saveDepartment(params).then(res => {
if (res.code === '200') {
this.getOrgUserList()
this.bm_Dialog = false
this.$message({
message: res.msg,
type: 'success'
})
}
})
} else {
return false
}
});
},
// 设置部门 提交
save(formName) {
this.form.userType = this.form.userTypeKey;
userUpdata(this.form).then(res => {
if (res.code === '200') {
this.getOrgUserList()
this.bm_Dialog = false
this.$message({
message: res.msg,
type: 'success'
})
this.editDialog = false
}
this.reset()
})
},
initPwd(row) {
this.$confirm('此操作将初始化该用户密码, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
initPwd({sid: row.sid}).then(res => {
this.$message({
type: 'success',
message: res.msg
})
})
})
},
// 修改用户信息
userinfoChange(row) {
var postSid = row.postSid
this.editDialog = true
this.form = Object.assign({}, row)
this.postSid = postSid
this.$nextTick(() => {
this.$refs.Tree.setChecked(this.form.departmentSid, true, true)
})
// this.$emit('status',true)
// this.$emit('item',row)
},
// 删除
del(row) {
this.$confirm('此操作将删除该用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delUser({ sid: row.sid }).then(res => {
this.$message({
type: 'success',
message: res.msg
});
this.getOrgUserList()
})
})
},
toNav(src) {
this.$router.push('/' + src)
},
// 获取部门树形
getOrgList(row) {
// this.roleDialog = true
this.checkedId = []
this.Thisrow = row
this.loading = true
let params = {}
orgList(params).then(res => {
this.treedata = res.data
})
},
checkchange(data, checked, indeterminate) {
if (checked) {
this.form.deptSid = data.sid
this.orgName = data.name
let arr = []
arr = [data.sid]
this.$refs.Tree.setCheckedKeys(arr)
this.form.postSid = ''
this.getPost(data.sid)
return
}
},
getPost(orgSid) {
let params = {
sid: orgSid
}
postList(params).then(res => {
this.postSidData = res.data
})
this.form.postSid = this.postSid
},
reset() {
this.form = {}
},
enabledChange(value, row) {
setRoleEnable({
sid: row.sid,
isEnable: value
}).then(res => {
this.$message({
type: 'success',
message: res.msg
});
})
}
}
}
</script>
<style scoped="scoped">
.el-select > .el-input {
display: block;
width: 300px;
}
</style>