<template>
|
<div>
|
<div class="body" style="background-color: #ffffff; padding: 20px 10px 0 20px;" :style="{height:mainHeight+'px'}">
|
<div style="height: 50px;">
|
<el-form
|
ref="form"
|
:model="form"
|
label-width="80px"
|
inline
|
style="display: flex;justify-content: space-between"
|
>
|
<div style="display: flex;justify-content: space-around;width: 85%">
|
<el-form-item label="用户编码" style=" display: flex;">
|
<el-input v-model="form.UserCode" placeholder="请输入" style="width: calc(100%-30px)" />
|
</el-form-item>
|
<el-form-item label="用户名称" style=" display: flex;">
|
<el-input v-model="form.UserName" placeholder="请输入" style="width: calc(100%-30px)" />
|
</el-form-item>
|
<el-form-item label="所属组织" style=" display: flex;">
|
<el-cascader
|
ref="cascader"
|
:options="StuOrgArr"
|
:props="defaultProps"
|
@change="cascaderChange"
|
/>
|
</el-form-item>
|
<el-form-item label="工资类型" style=" display: flex;">
|
<el-select v-model="form.wagetype" style="width: calc(100%-30px)" placeholder="请选择">
|
<el-option
|
v-for="item in wagetypeArr"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="在职状态" style=" display: flex;">
|
<el-select v-model="form.Enable" style="width: calc(100%-30px)" placeholder="请选择">
|
<el-option
|
v-for="item in EnableArr"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</div>
|
<div style="display: flex;align-items: start;margin-top: 5px;">
|
<el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
|
<el-button type="info" icon="el-icon-refresh" @click="reset">重置</el-button>
|
</div>
|
</el-form>
|
</div>
|
<div style="margin-bottom: 20px;display: flex">
|
<el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
|
<el-button type="primary" icon="el-icon-upload2" @click="upload">导入</el-button>
|
</div>
|
|
<div style="display: flex;border: 1px solid #eee">
|
<el-table
|
:data="tableData"
|
border
|
highlight-current-row
|
:style="{width: 100+'%',height:tableHeight+'px'}"
|
:header-cell-style="this.$headerCellStyle"
|
:cell-style="this.$cellStyle"
|
@sort-change="sortChange"
|
>
|
<!-- <el-table-column-->
|
<!-- type="selection"-->
|
<!-- width="50"-->
|
<!-- />-->
|
<el-table-column
|
prop="RowNum"
|
width="50"
|
label="序号"
|
/>
|
<el-table-column
|
prop="usercode"
|
label="用户编码"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="username"
|
label="用户名称"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="password"
|
label="用户密码"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="org_name"
|
label="所属组织"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="wagetype"
|
label="所属组织"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.wagetype==='1'">计时制</div>
|
<div v-if="row.wagetype==='2'">计件制</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="mobile"
|
label="联系方式"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="email"
|
label="电子邮箱"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop=""
|
label="在职状态"
|
sortable="custom"
|
>
|
<template slot-scope="{row}">
|
<div v-if="row.enable==='Y'">在职</div>
|
<div v-if="row.enable==='N'">离职</div>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="lm_user"
|
label="创建人员"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="lm_date"
|
label="创建时间"
|
width="200"
|
sortable="custom"
|
/>
|
<el-table-column
|
prop="is_role"
|
label="关联角色"
|
>
|
<template slot-scope="{row}">
|
<i class="el-icon-share" @click="roleClick({row})" />
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
>
|
<template slot-scope="{row}">
|
<div class="operationClass">
|
<el-button type="text" @click="edit('edit',row)">修改</el-button>
|
<el-button type="text" @click="del(row.id)">删除</el-button>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<!--分页-->
|
<pagination
|
v-show="total>0"
|
:total="total"
|
:page.sync="form.page"
|
:limit.sync="form.rows"
|
align="right"
|
layout="prev, pager, next,sizes"
|
popper-class="select_bottom"
|
@pagination="getUserSearch"
|
/>
|
</div>
|
|
<!-- 用户清单新增、修改-->
|
<el-dialog
|
:title="operation==='add'?'添加':'修改'"
|
:visible.sync="dialogVisible"
|
width="50%"
|
top="15vh"
|
@closed="handleClose"
|
>
|
<el-form ref="dialogForm" :rules="dialogFormRules" inline :model="dialogForm" label-width="80px">
|
<el-form-item label="用户编码" prop="UserCode">
|
<el-input v-model="dialogForm.UserCode" :disabled="operation!=='add'" style="width: 220px" />
|
</el-form-item>
|
<el-form-item label="用户名称" prop="UserName">
|
<el-input v-model="dialogForm.UserName" style="width: 220px" />
|
</el-form-item>
|
<el-form-item label="用户密码" prop="Password">
|
<el-input v-model="dialogForm.Password" style="width: 220px" />
|
</el-form-item>
|
<el-form-item label="在职状态" prop="Enable">
|
<el-select
|
v-model="dialogForm.Enable"
|
style="width: 220px"
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="item in EnableArr"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<div style="display: flex">
|
<el-form-item label="所属组织" prop="StuOrg" style="display: flex">
|
<el-cascader
|
ref="dialogCascader"
|
key="cascaderKey"
|
:options="StuOrgArr"
|
:props="defaultProps"
|
style="width: 220px;"
|
@change="dialogCascaderChange"
|
/>
|
</el-form-item>
|
<el-form-item label="工资类型" prop="wagetype">
|
<el-select
|
v-model="dialogForm.wagetype"
|
style="width: 220px"
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="item in wagetypeArr"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
</div>
|
<el-form-item label="联系方式">
|
<el-input v-model="dialogForm.Mobile" style="width: 220px" />
|
</el-form-item>
|
<el-form-item label="电子邮箱">
|
<el-input v-model="dialogForm.Email" style="width: 220px" />
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="dialogVisibleCancel">取 消</el-button>
|
<el-button type="primary" @click="dialogVisibleConfirm">确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
|
<!-- 关联角色-->
|
<el-dialog
|
title="关联角色"
|
:visible.sync="dialogVisibleRoles"
|
width="50%"
|
top="15vh"
|
@closed="handleCloseRoles"
|
>
|
|
<div>
|
<i class="el-icon-s-comment" style="color:#42b983;" /> 用户名称:{{ dialogFormRoles.username }}
|
</div>
|
<el-divider />
|
<div>
|
<div style="margin-bottom:20px">
|
<i class="el-icon-s-operation" style="color:#42b983;" /> 角色类型集合:
|
</div>
|
<el-checkbox-group v-model="dialogFormRoles.rolesArrSelectedArr" @change="dialogCheckboxChange">
|
<el-checkbox
|
v-for="item in dialogFormRoles.rolesArr"
|
:key="item.code"
|
:label="item.name"
|
border
|
size="medium"
|
/>
|
</el-checkbox-group>
|
</div>
|
<el-divider />
|
<div>
|
<div style="margin-bottom:20px">
|
<i class="el-icon-s-operation" style="color:#42b983;" /> 角色:
|
</div>
|
<el-tree
|
ref="roleTree"
|
:data="dialogFormRoles.roleTree"
|
show-checkbox
|
node-key="code"
|
default-expand-all
|
:props="defaultPropsOfRoleTree"
|
/>
|
</div>
|
<span slot="footer" class="dialog-footer">
|
<div class="footerButton">
|
<el-button @click="rolesDialogVisibleCancel">取 消</el-button>
|
<el-button type="primary" @click="rolesDialogVisibleConfirm">确 定</el-button>
|
</div>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import Pagination from '@/components/Pagination'
|
import {
|
AddUpdateUser,
|
DeleteUser, UserAssociationRole,
|
UserOrganization,
|
UserSearch
|
} from '@/api/jcsz'
|
import { getCookie } from '@/utils/auth'
|
|
const SER_HZ = /^[\u4e00-\u9fa5]+$/
|
export default {
|
name: 'Zzjg',
|
components: {
|
Pagination
|
},
|
data() {
|
const validateName = (rule, value, callback) => {
|
if (!value) {
|
return callback(new Error('请输入编码'))
|
} else {
|
if (SER_HZ.test(value)) {
|
return callback(new Error('编码不能为中文'))
|
} else {
|
callback()
|
}
|
}
|
}
|
return {
|
mainHeight: 0,
|
tableHeight: 0,
|
form: {
|
UserCode: '', // 用户编码
|
UserName: '', // 用户名称
|
StuOrg: '', // 所属组织
|
wagetype: '', // 工资类型
|
Enable: '', // 在职状态
|
prop: 'lm_date', // 排序字段
|
order: 'desc', // 排序字段
|
page: 1, // 第几页
|
rows: 10 // 每页多少条
|
},
|
StuOrgArr: [], // 所属组织数组
|
defaultProps: {
|
checkStrictly: true,
|
value: 'code',
|
label: 'name',
|
children: 'children'
|
},
|
EnableArr: [
|
{ value: 'Y', label: '在职' },
|
{ value: 'N', label: '离职' }
|
], // 在职状态
|
total: 10,
|
tableData: [],
|
dialogVisible: false,
|
dialogForm: {
|
id: '',
|
UserCode: '',
|
UserName: '',
|
Password: '',
|
Enable: '',
|
StuOrg: '',
|
Mobile: '',
|
Email: '',
|
Operator: '',
|
OperType: '',
|
wagetype: ''
|
},
|
wagetypeArr: [
|
{ value: '1', label: '计件制' },
|
{ value: '2', label: '计时制' }
|
],
|
operation: '',
|
dialogFormRules: {
|
UserCode: [
|
{ required: true, validator: validateName, trigger: ['blur', 'change'] }
|
],
|
UserName: [
|
{ required: true, message: '请输入用户名称', trigger: ['blur', 'change'] }
|
],
|
Password: [
|
{ required: true, message: '请输入用户密码', trigger: ['blur', 'change'] }
|
],
|
Enable: [
|
{ required: true, message: '请选择在职状态', trigger: ['blur', 'change'] }
|
],
|
StuOrg: [
|
{ required: true, message: '请选择所属组织', trigger: ['blur', 'change'] }
|
],
|
wagetype: [
|
{ required: true, message: '请选择工资类型', trigger: ['blur', 'change'] }
|
]
|
},
|
// cascaderKey: 0, // 级联选择器key
|
dialogVisibleRoles: false,
|
dialogFormRoles: {
|
username: '', // 用户名称
|
rolesArrSelectedArr: [], // 角色类型数组选中
|
rolesArrSelected: [], // 角色类型选中
|
rolesArr: [], // 角色类型集合
|
roleTree: [], // 角色树
|
rolesAll: []// 角色所有
|
},
|
|
defaultPropsOfRoleTree: {
|
value: 'code',
|
label: 'name',
|
children: 'children'
|
}
|
|
}
|
},
|
created() {
|
this.getUserSearch()
|
this.getUserOrganization()
|
},
|
mounted() {
|
window.addEventListener('resize', this.getHeight)
|
this.getHeight()
|
},
|
methods: {
|
// 获取用户清单
|
async getUserSearch() {
|
const res = await UserSearch(this.form)
|
this.tableData = res.data
|
this.total = res.count
|
},
|
// 获取所属组织
|
async getUserOrganization() {
|
const { data: res } = await UserOrganization()
|
this.StuOrgArr = res
|
},
|
// 导入按钮
|
upload() {
|
|
},
|
// 排序改变时
|
sortChange({ column, prop, order }) {
|
if (order === 'descending') {
|
order = 'desc'
|
} else if (order === 'ascending') {
|
order = 'asc'
|
} else {
|
order = 'desc'
|
}
|
this.form.order = order
|
this.form.prop = prop
|
this.getUserSearch()
|
},
|
// 查询
|
search() {
|
this.getUserSearch()
|
},
|
// 重置
|
reset() {
|
this.form.UserCode = ''
|
this.form.UserName = ''
|
this.form.StuOrg = ''
|
this.form.Enable = ''
|
this.form.wagetype = ''
|
this.$refs.cascader.checkedValue = ''// 级联选择器的清空
|
this.getUserSearch()
|
},
|
// 级联选择器改变事件
|
cascaderChange(val) {
|
this.form.StuOrg = val[val.length - 1]
|
},
|
dialogCascaderChange(val) {
|
this.dialogForm.StuOrg = val[val.length - 1]
|
},
|
// 新增按钮
|
add(operation) {
|
this.operation = operation
|
this.dialogVisible = true
|
},
|
// 修改按钮
|
edit(operation, row) {
|
this.operation = operation
|
this.dialogVisible = true
|
console.log(row)
|
|
this.$nextTick(() => {
|
this.dialogForm.id = row.id
|
this.dialogForm.UserCode = row.usercode
|
this.dialogForm.UserName = row.username
|
this.dialogForm.Password = row.password
|
this.dialogForm.Enable = row.enable
|
this.dialogForm.StuOrg = row.stu_torgcode
|
this.$refs.dialogCascader.checkedValue = row.stu_torgcode
|
this.dialogForm.Mobile = row.mobile
|
this.dialogForm.Email = row.email
|
this.dialogForm.wagetype = row.wagetype
|
})
|
},
|
// 删除按钮
|
async del(id) {
|
this.$confirm('是否确认删除?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
DeleteUser({ Userid: id }).then(res => {
|
if (res.code === '200') {
|
this.$message.success('删除成功!')
|
this.getUserSearch()
|
}
|
})
|
}).catch(() => {
|
this.$message.info('已取消删除')
|
})
|
},
|
// 对话框关闭事件
|
handleClose() {
|
this.dialogForm.UserCode = ''
|
this.dialogForm.UserCode = ''
|
this.dialogForm.UserName = ''
|
this.dialogForm.Password = ''
|
this.dialogForm.Enable = ''
|
this.$refs.dialogCascader.checkedValue = ''
|
this.dialogForm.StuOrg = ''
|
this.dialogForm.Mobile = ''
|
this.dialogForm.Email = ''
|
this.dialogForm.wagetype = ''
|
this.$refs.dialogForm.clearValidate()
|
},
|
// 对话框取消
|
dialogVisibleCancel() {
|
this.dialogVisible = false
|
},
|
// 对话框确认
|
dialogVisibleConfirm() {
|
this.$refs.dialogForm.validate(valid => {
|
if (valid) {
|
const data = {
|
id: this.dialogForm.id,
|
UserCode: this.dialogForm.UserCode,
|
UserName: this.dialogForm.UserName,
|
Password: this.dialogForm.Password,
|
Enable: this.dialogForm.Enable,
|
// StuOrg: this.dialogForm.StuOrg,
|
StuOrg: this.$refs.dialogCascader.checkedValue[this.$refs.dialogCascader.checkedValue.length - 1].length === 4 ? this.$refs.dialogCascader.checkedValue[this.$refs.dialogCascader.checkedValue.length - 1] : this.$refs.dialogCascader.checkedValue,
|
Mobile: this.dialogForm.Mobile,
|
Email: this.dialogForm.Email,
|
wagetype: this.dialogForm.wagetype,
|
OperType: this.operation === 'add' ? 'Add' : 'Update',
|
Operator: getCookie('admin')
|
}
|
AddUpdateUser(data).then(res => {
|
if (res.code === '200') {
|
this.$message.success(this.operation === 'add' ? '添加成功!' : '修改成功!')
|
this.getUserSearch()
|
} else {
|
this.$message.error(this.operation === 'add' ? '添加失败!' : '修改失败!')
|
}
|
this.dialogVisible = false
|
})
|
}
|
})
|
},
|
// 获取页面高度
|
getHeight() {
|
this.$nextTick(() => {
|
this.mainHeight = window.innerHeight - 200
|
this.tableHeight = this.mainHeight - 100
|
})
|
},
|
// 关联角色点击事件
|
async roleClick({ row }) {
|
this.dialogFormRoles.rolesArr = []
|
this.dialogVisibleRoles = true
|
this.dialogFormRoles.username = row.username
|
const { data: res } = await UserAssociationRole({ usercode: row.usercode })
|
this.rolesAll = res
|
res.forEach(item => {
|
this.dialogFormRoles.rolesArr.push({ code: item.code, name: item.name, flag: item.flag })
|
})
|
},
|
dialogCheckboxChange(val, aa) {
|
// this.dialogFormRoles.rolesArrSelectedArr = ['管理人员']
|
this.dialogFormRoles.rolesArrSelected = val[val.length - 1]
|
this.dialogFormRoles.roleTree = this.rolesAll.filter(item => item.name === this.dialogFormRoles.rolesArrSelected)
|
},
|
// 处理用户关联对话框关闭事件
|
handleCloseRoles() {
|
|
},
|
// 用户关联对话框取消事件
|
rolesDialogVisibleCancel() {
|
this.dialogVisibleRoles = false
|
},
|
// 用户关联对话框确认事件
|
rolesDialogVisibleConfirm() {
|
this.dialogVisibleRoles = false
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
$main_color: #42b983;
|
::v-deep .el-button--primary {
|
background-color: $main_color !important;
|
height: 30px;
|
display: flex;
|
align-items: center;
|
}
|
|
::v-deep .el-button--info {
|
//background-color: $main_color !important;
|
height: 30px;
|
display: flex;
|
align-items: center;
|
}
|
|
::v-deep .el-pagination.is-background .el-pager li:not(.disabled).active {
|
background-color: $main_color !important;
|
}
|
|
.footerButton {
|
display: flex;
|
justify-content: end;
|
}
|
|
::v-deep .el-button--default {
|
background-color: #ffffff !important;
|
height: 30px;
|
display: flex;
|
align-items: center;
|
}
|
|
::v-deep .el-button--default:hover {
|
color: #606266;
|
}
|
|
::v-deep .el-dialog__body {
|
padding: 20px 100px !important;
|
}
|
|
::v-deep .el-radio__input.is-checked .el-radio__inner {
|
background-color: $main_color;
|
border-color: $main_color;
|
}
|
|
::v-deep .el-radio__input.is-checked + .el-radio__label {
|
color: $main_color !important;
|
}
|
|
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
|
border-color: $main_color;
|
background-color: $main_color;
|
}
|
|
::v-deep .el-input__inner {
|
height: 30px
|
}
|
|
::v-deep .el-table .caret-wrapper {
|
//float: right;
|
transform: scale(0.8);
|
}
|
|
::v-deep .cell {
|
display: flex !important;
|
align-items: center !important;
|
justify-content: space-between !important;
|
}
|
|
::v-deep .el-button--text {
|
color: $main_color;
|
font-size: 14px;
|
cursor: pointer;
|
}
|
|
.operationClass {
|
height: 23px;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.el-icon-share {
|
color: $main_color;
|
cursor: pointer;
|
}
|
|
.el-checkbox.is-bordered.is-checked {
|
border-color: $main_color;
|
}
|
::v-deep .el-radio__input.is-checked .el-radio__inner {
|
border-color: $main_color;
|
background: $main_color;
|
}
|
|
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner{
|
border-color: $main_color;
|
background: $main_color;
|
}
|
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
|
color: $main_color !important;
|
}
|
</style>
|