Commit f09a265e by 胡悦

新建员工创建角色交互修改

1 parent f37e5094
...@@ -34,4 +34,8 @@ ...@@ -34,4 +34,8 @@
img { img {
width: 64px; width: 64px;
} }
}
.message-z {
z-index: 9999 !important;
} }
\ No newline at end of file \ No newline at end of file
<!--
* @Description:
* @Author: huyue
* @Date: 2022-06-10 15:36:06
* @LastEditors: huyue
* @LastEditTime: 2022-06-17 16:39:38
-->
<template>
<div>
<GLDialog :width="'1080px'" :visible="roleVisible" :close-on-click-modal="false" @close="handleClose" title="创建角色" :showClose="true">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item class="aa" v-if="$globalState.session.accountLevel != 4" label="所属商户" prop="merchantId">
<el-select size="small" style="width: 40%" v-model="ruleForm.merchantId" clearable filterable placeholder="请选择" @change="merchantChange">
<el-option v-for="item in merchantList" :key="item.id" :label="item.merchantName" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属商户" prop="merchantName" v-else>
<span>{{ $globalState.session.merchantName }}</span>
</el-form-item>
<el-form-item label="角色名称" prop="roleName">
<el-input size="small" maxlength="20" style="width: 40%; padding-right: 50px" @input="changeInput" v-model="ruleForm.roleName" placeholder="请输入角色名称"></el-input>
</el-form-item>
<el-form-item label="角色说明" prop="roleDesc">
<el-input size="small" maxlength="50" style="width: 40%; padding-right: 50px" @input="changeInput" v-model="ruleForm.roleDesc" placeholder="请输入角色说明"></el-input>
</el-form-item>
<el-form-item label="角色权限" prop="roleAuth">
<el-checkbox-group v-model="ruleForm.roleAuth">
<el-checkbox v-for="(itm, idx) in accountListSelect" :label="itm.accounttypeName" @change="selectCurAccount(itm, idx)" :key="idx">{{ itm.accounttypeName }}</el-checkbox>
</el-checkbox-group>
<SelectProduct ref="productFrom" :roleType="true" title="角色权限"></SelectProduct>
</el-form-item>
</el-form>
<div slot="footer">
<el-button :size="size" @click="handleClose">取消</el-button>
<el-button :size="size" type="primary" @click="toCreateRole">提交</el-button>
</div>
</GLDialog>
</div>
</template>
<script>
import SelectProduct from './selectProduct'
export default {
name: 'CreateRole',
components: {
SelectProduct
},
data() {
return {
roleVisible: false,
ruleForm: {
merchantId: '',
roleName: '',
roleDesc: '',
roleAuth: ''
},
rules: {
roleName: [{ required: true, message: '请输入角色名称', trigger: 'blur' }],
merchantId: [{ required: true, message: '请选择所属商户', trigger: 'change' }],
roleAuth: [{ required: true, message: '请选择角色权限', trigger: 'change' }]
},
//商户下拉框
merchantList: [],
accountListSelect: [],
rootList: []
}
},
methods: {
init() {
this.roleVisible = true
this.getMerchantName()
},
handleClose() {
this.roleVisible = false
},
getMerchantName() {
this.$apis.role.merchantDataList({ source: 'glsx' }).then(res => {
this.merchantList = res
if (this.$globalState.session.accountLevel == 4) {
this.ruleForm.merchantId = this.merchantList[0].id
this.selectMerchant(this.merchantList[0].id)
}
// this.filterList()
})
},
// 选择商户----获取权限
async selectMerchant(id, list) {
let res = await this.$refs.productFrom.findMenuFunTreeByMerId({ id })
console.log(res)
this.accountListSelect = res.map(item => {
item.select = false
return item
})
},
// 选择商户权限
selectCurAccount(item, index) {
console.log(item, index)
this.isChangeEdit = true
this.roleRootRules = false
this.accountListSelect[index].select = !item.select
this.curRootIndex = 0
if (this.accountListSelect[index].select) {
this.rootList.push(item)
} else {
let arr = this.rootList.filter(el => {
return item.accounttypeId != el.accounttypeId
})
this.rootList = arr
}
let accounttypeId = []
this.rootList.forEach(item => {
accounttypeId.push(item.accounttypeId)
})
console.log(this.rootList, accounttypeId, '99999')
this.accounttypeIds = accounttypeId
this.$refs.productFrom.findMenuFunTree(item.accounttypeId, item.select)
},
toCreateRole() {
console.log(this.ruleForm, this.$refs.productFrom.getSelectInfo())
this.$refs.ruleForm.validate(valid => {
if (valid) {
let { merchantId, roleDesc, roleName } = this.ruleForm
let product = this.$refs.productFrom.getSelectInfo()
if (product && product.every(item => item.productList.length == 0)) {
this.$message({
type: 'error',
message: '请至少选择一个产品',
customClass: 'message-z'
})
return
}
let accountTypes = JSON.stringify(this.$refs.productFrom.getSelectInfo())
let para = {
merchantId: merchantId,
roleName: roleName,
roleDescription: roleDesc,
delFlag: 0,
requestList: accountTypes
}
console.log(para)
this.$apis.role.createRole(para).then(res => {
res ? this.$message.success('操作成功') : this.$message.error('操作失败')
this.$emit('updataRole', true)
this.roleVisible = !res
})
} else {
return false
}
})
}
}
}
</script>
<style scoped lang="scss">
/deep/ {
.el-dialog__body {
padding: 20px;
}
.el-form-item {
display: inline-block;
width: 50%;
vertical-align: text-top;
margin-bottom: 0 !important;
.el-input {
width: 360px !important;
}
&:last-child {
width: 100%;
}
}
}
</style>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</template> </template>
<template v-if="userInfo.accountLevel == 4 && routeInfo.addOrEdit == 1" slot="roleIdsSlot"> <template v-if="userInfo.accountLevel == 4 && routeInfo.addOrEdit == 1" slot="roleIdsSlot">
<el-button class="m-l-10" type="primary" @click="handleJumpRole">创建角色</el-button> <el-button class="m-l-10" type="primary" @click="handleJumpRole">创建角色</el-button>
<el-button class="m-l-10 el-icon-refresh" type="primary" @click="handleRefresh">刷新</el-button> <!-- <el-button class="m-l-10 el-icon-refresh" type="primary" @click="handleRefresh">刷新</el-button> -->
</template> </template>
<template slot="visibleInferiorMer" slot-scope="item"> <template slot="visibleInferiorMer" slot-scope="item">
<el-input :style="{ width: item.width || '320px' }" placeholder="可见商户" v-model="filterText"></el-input> <el-input :style="{ width: item.width || '320px' }" placeholder="可见商户" v-model="filterText"></el-input>
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
</template> </template>
</glsx-combi-form> </glsx-combi-form>
</div> </div>
<CreateRole ref="createRole" @updataRole="updataRole"></CreateRole>
<GLFooter> <GLFooter>
<el-button type="primary" @click="handleConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button> <el-button type="default" @click="handleCancel">取消</el-button>
...@@ -35,6 +37,7 @@ ...@@ -35,6 +37,7 @@
</template> </template>
<script> <script>
import CreateRole from './components/createRole'
import { utils } from 'glsx-common' import { utils } from 'glsx-common'
// import selectPage from './components/selectPage' // import selectPage from './components/selectPage'
import glsxCombiForm from './glsx-combi-form' import glsxCombiForm from './glsx-combi-form'
...@@ -42,7 +45,8 @@ export default { ...@@ -42,7 +45,8 @@ export default {
name: 'editEmployee', name: 'editEmployee',
components: { components: {
glsxCombiForm glsxCombiForm,
CreateRole
// selectPage // selectPage
}, },
...@@ -103,8 +107,22 @@ export default { ...@@ -103,8 +107,22 @@ export default {
} }
], ],
visibleInferiorMer: [{ required: true, message: '请选择可见商户', trigger: 'change' }], visibleInferiorMer: [{ required: true, message: '请选择可见商户', trigger: 'change' }],
roleIds: [{ required: true, message: '请选择角色权限', trigger: 'change' }] roleIds: [{ required: true, message: '请选择角色权限', trigger: 'change' }],
// staffEmail: [{ required: false, validator: (rule, value, callback) => {}, trigger: 'change' }] staffEmail: [
{
required: false,
validator: (rule, value, callback) => {
var reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
console.log(reg.test(value))
if (!reg.test(value)) {
return callback(new Error('请输入正确格式的邮箱'))
} else {
return callback()
}
},
trigger: 'change'
}
]
}, },
isBlock: true, isBlock: true,
editFormData: [ editFormData: [
...@@ -321,8 +339,10 @@ export default { ...@@ -321,8 +339,10 @@ export default {
this.editForm.password = '' this.editForm.password = ''
}, },
handleJumpRole() { handleJumpRole() {
let path = document.location.pathname.split('/')[1] console.log('创建角色', this.$refs.createRole)
this.$history.push('/' + path + '/role/create') // let path = document.location.pathname.split('/')[1]
// this.$history.push('/' + path + '/role/create')
this.$refs.createRole.init()
}, },
handleRefresh() { handleRefresh() {
this.editForm.merchantId this.editForm.merchantId
...@@ -404,6 +424,9 @@ export default { ...@@ -404,6 +424,9 @@ export default {
this.$refs.tree.setCheckedKeys(allId) this.$refs.tree.setCheckedKeys(allId)
} }
this.isCheckAll = !this.isCheckAll this.isCheckAll = !this.isCheckAll
},
updataRole() {
this.getRoleList(this.editForm.merchantId)
} }
}, },
...@@ -418,7 +441,7 @@ export default { ...@@ -418,7 +441,7 @@ export default {
this.routeInfo.addOrEdit != 1 ? this.getInfo() : '' this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
} }
} }
</script> </script>
<style> <style>
.config-employee { .config-employee {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!