Commit 1c69f9a2 by cwq0219

员工

1 parent 4e7b7e95
......@@ -5126,7 +5126,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
......@@ -5550,7 +5551,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -5606,6 +5608,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -5649,12 +5652,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
......
import { http } from '@/main'
var defaultPath = 'cn.com.glsx.merchants.'
const getListApi = params => {
params.method = `${defaultPath}staff.findStaffByPage`
return http({
url: '/rop-merchants/router',
method: 'POST',
data: params,
sign: true
})
}
const getAllMerchantListApi = params => {
params.method = `${defaultPath}menu.findAllMerchant`
return http({
url: '/rop-merchants/router',
method: 'POST',
data: params,
sign: true
})
}
const getRoleListApi = params => {
params.method = 'org.ore.api.role.list'
return http({
url: '/rop-merchants/router',
method: 'POST',
data: params,
sign: true
})
}
const getAllDictApi = params => {
params.method = `${defaultPath}menu.findAllDictData`
return http({
url: '/rop-merchants/router',
method: 'POST',
data: params,
sign: true
})
}
const getMerchantTreeApi = params => {
params.method = `${defaultPath}merchant.findMerchantTree`
return http({
url: '/rop-merchants/router',
method: 'POST',
data: params,
sign: true
})
}
export { getListApi, getAllMerchantListApi, getRoleListApi, getAllDictApi, getMerchantTreeApi }
const staticRoutes = Object.freeze([{
name: 'home',
path: '/',
meta: {},
component: resolve => require([`@/views/home/index.vue`], resolve)
},
{
name: 'addAccount',
path: '/acount/addAccount',
meta: {},
component: resolve => require([`@/views/home/addAccount.vue`], resolve)
},
{
name: 'editAccount',
path: '/acount/editAccount',
meta: {},
component: resolve => require([`@/views/home/editAccount.vue`], resolve)
}
const staticRoutes = Object.freeze([
{
name: 'home',
path: '/',
meta: {},
component: resolve => require([`@/views/home/index.vue`], resolve)
},
{
name: 'addAccount',
path: '/acount/addAccount',
meta: {},
component: resolve => require([`@/views/home/addAccount.vue`], resolve)
},
{
name: 'editAccount',
path: '/acount/editAccount',
meta: {},
component: resolve => require([`@/views/home/editAccount.vue`], resolve)
},
{
name: 'employeeList',
path: '/employee/index',
meta: {},
component: resolve => require([`@/views/employee/index.vue`], resolve)
},
{
name: 'employee',
path: '/employee/editEmployee',
meta: {},
component: resolve => require([`@/views/employee/editEmployee.vue`], resolve)
}
])
export default staticRoutes
\ No newline at end of file
export default staticRoutes
<!-- 选择分页 -->
<template>
<div>
<el-popover popper-class="select-page" ref="popover" placement="bottom-start" trigger="click" v-model="popoverVisible" :disabled="targetItem.isDisabled" @show="onShowPopover" @hide="onHidePopover">
<el-radio-group class="select-tree" v-model="form[targetItem.name]" @change="handleChangeRadio">
<el-radio class="page-radio" :title="item.merchantName" v-for="item in currList" :key="item.id" :label="item.id">{{ item.merchantName }}</el-radio>
</el-radio-group>
<div class="btns">
<el-button :size="size" :disabled="page.pageNum == 1" @click="handlePage(false)">上一页</el-button>
<span>{{ page.pageNum }}/{{ page.totalPage }}</span>
<el-button :size="size" :disabled="page.pageNum == page.totalPage" @click="handlePage(true)">下一页</el-button>
</div>
<!-- <el-tree ref="tree" class="select-tree" highlight-current default-expand-all node-key="id" :expand-on-click-node="isExpand" :style="`min-width: ${treeWidth}`" :data="treeData" :current-node-key="form[targetItem.name]" :props="defaultProps" :filter-node-method="handleFilterNode" @current-change="handleNodeClick"></el-tree> -->
<el-input slot="reference" ref="input" v-model="form[targetItem.nameLabel]" clearable :disabled="targetItem.isDisabled" :style="`width: ${width}px`" :class="{ rotate: popoverVisible }" suffix-icon="el-icon-arrow-down" :placeholder="'请选择' + targetItem.label" @change="handleClear"></el-input>
</el-popover>
</div>
</template>
<script>
import { getAllMerchantListApi } from '@/api/modules/employee'
export default {
name: 'selectPage',
data() {
return {
size: 'small',
isExpand: false,
// 树状菜单显示状态
popoverVisible: false,
treeWidth: 'auto',
currList: [],
allMerchantList: [],
page: {
pageSize: 20,
pageNum: 1,
total: 0,
totalPage: 0
}
}
},
props: {
// 输入框宽度
width: {
type: String,
default: '300px'
},
form: {
type: Object,
default: () => {}
},
targetItem: {
type: Object,
default: () => {}
},
treeData: {
type: Array,
default: () => []
}
// defaultProps: {
// type: Object,
// default: () => ({
// parent: 'parentId',
// value: 'id',
// label: 'menuName',
// children: 'childlist'
// })
// }
},
// watch: {
// form(val) {
// if (this.form[this.targetItem.name]) {
// this.form[this.targetItem.nameLabel] = this.queryTree(this.treeData, this.form[this.targetItem.name])
// this.$nextTick().then(() => {
// this.$refs.tree.setCheckedKeys([this.form[this.targetItem.name]])
// })
// }
// }
// },
created() {
// 获取输入框宽度同步至树状菜单宽度
this.$nextTick(() => {
this.treeWidth = `${(this.width || this.$refs.input.$refs.input.clientWidth) - 24}px`
})
},
mounted() {
this.getAllMerchantList()
// if (this.form[this.targetItem.name]) {
// // console.log(this.treeData)
// // console.log(this.form)
// this.form[this.targetItem.nameLabel] = this.queryTree(this.treeData, this.form[this.targetItem.name])
// this.$nextTick().then(() => {
// this.$refs.tree.setCheckedKeys([this.form[this.targetItem.name]])
// })
// }
},
methods: {
getCurrList() {
this.currList = this.allMerchantList.slice((this.page.pageNum - 1) * this.page.pageSize, this.page.pageNum * this.page.pageSize)
},
getAllMerchantList() {
getAllMerchantListApi({}).then(res => {
this.allMerchantList = res
this.page.total = res.length
this.page.totalPage = Math.ceil(res.length / this.page.pageSize)
this.getCurrList()
// index + (page[this.pageConf.pageNum] - 1) * page[this.pageConf.pageSize] + 1
})
},
handlePage(isNext) {
this.page.pageNum = isNext ? this.page.pageNum + 1 : this.page.pageNum - 1
this.getCurrList()
},
handleChangeRadio(val) {
this.form[this.targetItem.nameLabel] = this.currList.find(item => item.id == val).merchantName
this.$emit('handleChange', val)
this.onHidePopover()
},
// handleClickRadio(item) {
// console.log(item)
// },
// 显示时触发
onShowPopover() {
this.popoverVisible = true
// this.$refs.tree.filter(false)
},
// 隐藏时触发
onHidePopover() {
this.popoverVisible = false
},
// 树节点过滤方法
// handleFilterNode(query, data) {
// if (!query) return true
// return data[this.defaultProps.label].indexOf(query) !== -1
// },
// handleNodeClick(val) {
// this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
// this.onHidePopover()
// },
handleClear(val) {
this.form[this.targetItem.name] = ''
this.form[this.targetItem.nameLabel] = ''
this.$emit('handleChange')
// this.$emit('selected', { val: val, targetItem: this.targetItem, formName: this.targetItem.formName })
// window.event.stopPropagation()
}
// 搜索树状数据中的 ID
// queryTree(tree, id) {
// let stark = []
// stark = stark.concat(tree)
// while (stark.length) {
// const temp = stark.shift()
// if (temp[this.defaultProps.children]) {
// stark = stark.concat(temp[this.defaultProps.children])
// }
// if (temp[this.defaultProps.value] === id) {
// return temp[this.defaultProps.label]
// }
// }
// return
// }
}
}
</script>
<style>
.el-input.el-input--suffix.rotate .el-input__suffix .el-icon-arrow-down {
transform: rotate(-180deg);
}
.select-tree {
max-height: 400px;
overflow-y: scroll;
}
.page-radio {
display: block;
width: 320px;
height: 36px;
line-height: 36px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.select-page {
padding-bottom: 6px;
}
.select-page .btns {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>
<!-- 编辑员工 -->
<template>
<div class="config-employee">
<div class="container">
<p class="edit-title">{{ title }}</p>
</div>
<div class="container">
<p class="edit-sub-title p-rl-20">员工基本信息</p>
<glsx-combi-form class="p-rl-20" ref="editFormRef" labelWidth="160px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<template slot="merchantId" slot-scope="item">
<select-page :form="editForm" width="300px" :targetItem="item.scope"></select-page>
<!-- <el-select v-model="editForm.merchantId" placeholder="请选择所属商户" @change="handleChangeMerchant($event, item)">
<el-option v-for="subItem in baseData.allMerchantList" :key="subItem.id" :label="subItem.merchantName" :value="subItem.id" :disabled="subItem.isDisabled || false"></el-option>
</el-select> -->
</template>
</glsx-combi-form>
</div>
<!-- <template
slot="menuTree"
slot-scope="scope"
>
<select-tree
:form="searchForm"
:targetItem="scope.scope"
:treeData="baseData.searchMenuTreeList"
:defaultProps="treeDefaultProps"
@selected="handleTreeSelect"
></select-tree>
</template> -->
<div class="footer">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div>
</template>
<script>
import { utils } from 'glsx-common'
import selectPage from './components/selectPage'
import glsxCombiForm from './glsx-combi-form'
import { getAllMerchantListApi, getRoleListApi, getMerchantTreeApi } from '@/api/modules/employee'
export default {
name: 'editEmployee',
data() {
return {
title: '新增员工',
titleObj: {
1: '新增员工',
2: '编辑员工'
},
editChildRef: 'editChildRef',
routeInfo: {
// 1-新增;2-编辑
addOrEdit: 1,
id: ''
},
editForm: {
merchantId: '',
merchantName: '',
staffName: '',
staffPhone: '',
password: '',
searchMerchant: '',
roleId: '',
merhcnatImg: ''
},
editRule: {
merchantId: [{ required: true, message: '请选择所属商户', trigger: 'change' }],
staffName: [{ required: true, message: '请输入员工姓名', trigger: 'change' }],
staffPhone: [{ required: true, message: '请输入登录手机号', trigger: 'change' }],
password: [{ required: true, message: '请输入登录密码', trigger: 'change' }],
searchMerchant: [{ required: true, message: '请选择可见商户', trigger: 'change' }],
roleId: [{ required: true, message: '请选择角色权限', trigger: 'change' }]
},
isBlock: true,
editFormData: [
{
label: '所属商户',
name: 'merchantId',
nameLabel: 'merchantName',
optionList: [],
optionId: 'id',
optionLabel: 'merchantName',
optionsName: 'allMerchantList',
addHtml: 'merchantId'
},
{
label: '员工姓名',
name: 'staffName',
width: '360px',
type: 'input',
maxlength: 15
},
{
label: '登录手机号',
name: 'staffPhone',
width: '360px',
type: 'input',
placeholder: '请输入您有效的手机号作为登录账户',
maxlength: 11
},
{
label: '登录密码',
name: 'password',
width: '360px',
type: 'input',
maxlength: 15
},
{
label: '可见商户',
name: 'searchMerchant',
addHtml: 'searchMerchant'
},
{
label: '角色权限',
name: 'roleId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'roleName',
optionsName: 'roleList'
},
{
label: '头像',
name: 'merhcnatImg',
type: 'upload',
maxPhotoNum: 1,
wdithLt: 800,
heightLt: 640,
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
// uploadImg({ file: base64, fileType: 'image' }).then(res => {
// this.editForm[targetItem.name] = res
// this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
// })
}
},
{
label: '邮箱',
name: 'staffEmail',
width: '360px',
type: 'input',
maxlength: 30
},
{
label: '主要职务',
name: 'staffJob',
width: '360px',
type: 'input',
maxlength: 10
}
],
baseData: {
allMerchantList: [],
merchantTree: [],
roleList: []
}
}
},
components: {
glsxCombiForm,
selectPage
},
computed: {},
mounted() {
this.routeInfo = this.$route.params
this.getAllMerchantList()
},
methods: {
getAllMerchantList() {
getAllMerchantListApi({}).then(res => {
this.baseData.allMerchantList = res
})
},
handleChangeMerchant(e, item) {
console.log(e)
console.log(item)
this.editForm.roleId = ''
// this.editForm.roleId = ''
this.getRoleList(e)
this.getMerchantTree(e)
},
getMerchantTree(value) {
getMerchantTreeApi({ id: value }).then(res => {
this.baseData.merchantTree = res
})
},
getRoleList(value) {
getRoleListApi({ id: value }).then(res => {
this.baseData.roleList = res
this.getOptionsList('editFormData', false, 'roleId')
})
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
// this.$set(this[formName][index], 'optionList', _.cloneDeep(this.baseData[item.optionsName]))
this.$set(this[formName][index], 'optionList', utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
}
}
}
</script>
<style scoped>
.config-employee {
margin-bottom: 64px;
}
.config-employee .container {
margin-top: 20px;
background: #ffffff;
box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
padding: 20px;
}
.config-employee .p-rl-20 {
padding: 0 20px;
}
.config-employee .flex {
display: flex;
justify-content: space-between;
}
.config-employee .edit-container {
margin-bottom: 84px;
}
.config-employee .footer {
position: fixed;
bottom: 0;
width: 100%;
height: 64px;
text-align: center;
line-height: 64px;
background: #ffffff;
z-index: 999;
}
.config-employee .flex {
display: flex;
justify-content: space-between;
}
.config-employee .edit-title {
font-size: 20px;
font-weight: bold;
color: #333333;
line-height: 38px;
height: 38px;
margin: 0 0;
}
/* .config-employee .edit-sub-title::before {
position: absolute;
display: inline-block;
content: '';
height: 18px;
width: 4px;
top: 2px;
left: 0;
background-color: #0947C6;
} */
.config-employee .edit-sub-title {
height: 48px;
line-height: 48px;
font-size: 16px;
color: #333333;
font-weight: 600;
border-bottom: 1px solid #e7eaec;
margin: 0 0;
}
</style>
/**
* 时间控件-限制月份
*/
export const beforeRangePickerOptions = {
disabledDate(date) {
if (date > new Date()) {
return true
}
return false
}
}
export const afterRangePickerOptions = {
disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1))
if (date < yesterday) {
return true
}
return false
}
}
<!-- 员工管理 -->
<template>
<div class="config-employee">
<div class="container">
<div class="flex">
<div style="margin-top: 16px;">
<el-button :size="size" type="primary" @click="handleEdit(1)">创建员工</el-button>
</div>
<glsx-combi-form ref="showSearch" labelWidth="100px" :formObj="searchForm" :searchSelectObj="searchSelectObj" :formData="searchFormData">
<template slot="merchantId" slot-scope="item">
<select-page :form="searchForm" width="300px" :targetItem="item.scope" @handleChange="handleChangeMerchant"></select-page>
</template>
<template slot="footer">
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" type="primary">导出</el-button>
</template>
</glsx-combi-form>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="employeeRef" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<template slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleDetail(scope.scope)">查看</el-button>
<el-button type="text" @click="handleEdit(2, scope.scope)">修改</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
</template>
</GLTable>
<!-- 表格区域 end -->
</div>
</div>
</template>
<script>
import { utils } from 'glsx-common'
import { getListApi, getAllMerchantListApi, getRoleListApi, getAllDictApi } from '@/api/modules/employee'
import glsxCombiForm from './glsx-combi-form'
import selectPage from './components/selectPage'
export default {
name: 'index',
data() {
return {
size: 'small',
searchForm: {
merchantId: '',
merchantName: '',
roleId: '',
status: ''
},
tableSearchForm: {},
searchSelectObj: {
staffNameOrPhone: {
attr: 'staffName',
value: ''
}
},
// 搜索
searchFormData: [
{
label: '商户名称',
name: 'merchantId',
nameLabel: 'merchantName',
optionList: [],
optionId: 'id',
optionLabel: 'merchantName',
optionsName: 'allMerchantList',
addHtml: 'merchantId'
},
{
label: '角色',
name: 'roleId',
type: 'select',
width: '192px',
optionList: [],
optionId: 'id',
optionLabel: 'roleName',
optionsName: 'roleList'
},
{
label: '状态',
name: 'status',
type: 'select',
width: '192px',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'staffStatusList'
},
{
type: 'selectInput',
selectName: 'staffNameOrPhone',
isClear: true,
selectOption: [
{
label: '员工姓名',
name: 'staffName'
},
{
label: '手机号',
name: 'staffPhone'
}
],
handleSelectChange: value => {
this.searchSelectObj.staffNameOrPhone.value = ''
}
}
],
// 表格
getListApi: getListApi,
tableParams: {
listName: 'data',
tableOption: true,
tableColumns: [
{
label: '员工姓名',
prop: 'staffName'
},
{
label: '员工企微号',
prop: 'entmicroName',
line: 2
},
{
label: '角色',
prop: 'roleName',
line: 2
},
{
label: '登录手机号',
prop: 'staffPhone',
line: 2
},
{
label: '所属门店',
prop: 'merchantName',
line: 2
},
{
label: '所属企微',
prop: 'belongingEntmicroName',
line: 2
},
{
label: '状态',
prop: 'statusName',
width: '80px'
},
{
label: '更新时间',
prop: 'updatedTime',
line: 2
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
baseData: {
allMerchantList: [],
roleList: [],
staffStatusList: []
}
}
},
components: {
glsxCombiForm,
selectPage
},
mounted() {
this.getBaseData().then(res => {
this.getOptionsList('searchFormData')
})
},
methods: {
getAllMerchantList() {
getAllMerchantListApi({}).then(res => {
this.baseData.allMerchantList = res
})
},
getBaseData() {
// 1.product(产品) 2.account_type(账户类型) 3.(functional_attributes) 功能属性 4.(owned_customer_group)所属客户群 5.channel渠道 6.account_level(商户层级)
return new Promise(resolve => {
Promise.all([getAllMerchantListApi({}), getAllDictApi({ dictType: 'staff_status' })]).then(([allMerchant, staffStatus]) => {
this.baseData.allMerchantList = allMerchant
this.baseData.staffStatusList = staffStatus
resolve()
})
})
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
// this.$set(this[formName][index], 'optionList', _.cloneDeep(this.baseData[item.optionsName]))
this.$set(this[formName][index], 'optionList', utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
handleChangeMerchant(value) {
this.searchForm.roleId = ''
this.baseData.roleList = []
this.getOptionsList('searchFormData', true, 'roleId')
value &&
getRoleListApi({ id: value }).then(res => {
this.baseData.roleList = res
this.getOptionsList('searchFormData', true, 'roleId')
})
},
getSelectInputParams() {
const list = Object.keys(this.searchSelectObj)
var params = {}
list.forEach(i => {
const item = this.searchSelectObj[i]
item.value && (params[item.attr] = item.value)
})
return params
},
getParams() {
var params = utils.deepClone(this.searchForm)
// params.productId.includes('') && (params.productId = [])
const tempParams = this.getSelectInputParams()
params = {
...params,
...tempParams
}
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
// 1-新增;2-编辑
handleEdit(addOrEdit, row) {
console.log(addOrEdit)
this.$router.push({
name: 'employee',
// name: 'ConfigEmployeeIndex',
params: {
addOrEdit: addOrEdit,
id: row ? row.id : '-1'
}
})
},
// handleReset() {
// this.searchForm = {
// name: ''
// }
// this.handleSearch()
// },
handleSearch() {
this.$refs.employeeRef.refreshTable()
}
}
}
</script>
<style lang="scss">
.config-employee .container {
margin-top: 20px;
background: #ffffff;
box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
padding: 10px;
}
.config-employee .flex {
display: flex;
justify-content: space-between;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!