增加用户分配功能和用户分配按钮功能
This commit is contained in:
parent
62ed476d09
commit
d13186e759
@ -47,8 +47,8 @@
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<a @click="handleSetFunction(record)">分配功能</a>
|
||||
<a-divider type="vertical" />
|
||||
<!-- <a @click="handleSetPushBtn(record.id)">分配按钮</a>-->
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<a @click="handleSetPushBtn(record)">分配按钮</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="handleEdit(record)">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
|
||||
@ -136,13 +136,10 @@
|
||||
this.$refs.roleFunctionModal.title = "分配功能";
|
||||
this.$refs.roleFunctionModal.disableSubmit = false;
|
||||
},
|
||||
handleSetPushBtn(id) {
|
||||
this.$refs.rolePushBtnModal.add();
|
||||
handleSetPushBtn(record) {
|
||||
this.$refs.rolePushBtnModal.edit(record);
|
||||
this.$refs.rolePushBtnModal.title = "分配按钮";
|
||||
this.$refs.rolePushBtnModal.disableSubmit = false;
|
||||
},
|
||||
onChangeDate(date, dateString) {
|
||||
console.log(date, dateString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,19 +27,11 @@
|
||||
<div class="table-operator" style="border-top: 5px">
|
||||
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<a-menu slot="overlay" @click="handleMenuClick">
|
||||
<a-menu slot="overlay">
|
||||
<a-menu-item key="1">
|
||||
<a-icon type="delete" @click="batchDel"/>
|
||||
删除
|
||||
</a-menu-item>
|
||||
<a-menu-item key="2">
|
||||
<a-icon type="lock" @click="batchFrozen('2')"/>
|
||||
冻结
|
||||
</a-menu-item>
|
||||
<a-menu-item key="3">
|
||||
<a-icon type="unlock" @click="batchFrozen('1')"/>
|
||||
解冻
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
<a-button style="margin-left: 8px">
|
||||
批量操作
|
||||
@ -60,12 +52,11 @@
|
||||
:loading="loading"
|
||||
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
||||
@change="handleTableChange">
|
||||
<template slot="avatarslot" slot-scope="text, record, index">
|
||||
<div class="anty-img-wrap">
|
||||
<a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user"/>
|
||||
</div>
|
||||
</template>
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<a @click="btnSetDepot(record)">分配仓库</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="btnSetCustomer(record)">分配客户</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="handleEdit(record)">编辑</a>
|
||||
<a-divider type="vertical"/>
|
||||
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
|
||||
@ -80,18 +71,16 @@
|
||||
</div>
|
||||
<!-- table区域-end -->
|
||||
<user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
|
||||
<password-modal ref="passwordmodal" @ok="passwordModalOk"></password-modal>
|
||||
<sys-user-agent-modal ref="sysUserAgentModal"></sys-user-agent-modal>
|
||||
<!-- 用户回收站 -->
|
||||
<user-recycle-bin-modal :visible.sync="recycleBinVisible" @ok="modalFormOk"/>
|
||||
<user-depot-modal ref="userDepotModal" @ok="modalFormOk"></user-depot-modal>
|
||||
<user-customer-modal ref="userCustomerModal" @ok="modalFormOk"></user-customer-modal>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UserModal from './modules/UserModal'
|
||||
import PasswordModal from './modules/PasswordModal'
|
||||
import {postAction,getFileAccessHttpUrl} from '@/api/manage';
|
||||
import {frozenBatch} from '@/api/api'
|
||||
import UserDepotModal from './modules/UserDepotModal'
|
||||
import UserCustomerModal from './modules/UserCustomerModal'
|
||||
import {postAction} from '@/api/manage';
|
||||
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
|
||||
import JInput from '@/components/jeecg/JInput'
|
||||
export default {
|
||||
@ -99,14 +88,13 @@
|
||||
mixins: [JeecgListMixin],
|
||||
components: {
|
||||
UserModal,
|
||||
PasswordModal,
|
||||
UserDepotModal,
|
||||
UserCustomerModal,
|
||||
JInput
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
description: '这是用户管理页面',
|
||||
queryParam: {},
|
||||
recycleBinVisible: false,
|
||||
columns: [
|
||||
{
|
||||
title: '#',
|
||||
@ -123,16 +111,14 @@
|
||||
{ title: '用户类型', dataIndex: 'userType', width: 80, align: "center" },
|
||||
{ title: '角色', dataIndex: 'roleName', width: 100, align: "center"},
|
||||
{ title: '机构', dataIndex: 'orgAbr', width: 115, align: "center"},
|
||||
{ title: '职位', dataIndex: 'position', width: 115, align: "center"},
|
||||
{ title: '电话号码', dataIndex: 'phonenum', width: 150, align: "center"},
|
||||
{ title: '电子邮箱', dataIndex: 'email', width: 150, align: "center"},
|
||||
{ title: '电话号码', dataIndex: 'phonenum', width: 120, align: "center"},
|
||||
{ title: '排序', dataIndex: 'userBlngOrgaDsplSeq', width: 60, align: "center"},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
scopedSlots: {customRender: 'action'},
|
||||
align: "center",
|
||||
width: 170
|
||||
width: 260
|
||||
}
|
||||
],
|
||||
url: {
|
||||
@ -143,61 +129,7 @@
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
importExcelUrl: function(){
|
||||
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getAvatarView: function (avatar) {
|
||||
return getFileAccessHttpUrl(avatar)
|
||||
},
|
||||
batchFrozen: function (status) {
|
||||
if (this.selectedRowKeys.length <= 0) {
|
||||
this.$message.warning('请选择一条记录!');
|
||||
return false;
|
||||
} else {
|
||||
let ids = "";
|
||||
let that = this;
|
||||
let isAdmin = false;
|
||||
that.selectionRows.forEach(function (row) {
|
||||
if (row.username == 'admin') {
|
||||
isAdmin = true;
|
||||
}
|
||||
});
|
||||
if (isAdmin) {
|
||||
that.$message.warning('管理员账号不允许此操作,请重新选择!');
|
||||
return;
|
||||
}
|
||||
that.selectedRowKeys.forEach(function (val) {
|
||||
ids += val + ",";
|
||||
});
|
||||
that.$confirm({
|
||||
title: "确认操作",
|
||||
content: "是否" + (status == 1 ? "解冻" : "冻结") + "选中账号?",
|
||||
onOk: function () {
|
||||
frozenBatch({ids: ids, status: status}).then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message);
|
||||
that.loadData();
|
||||
that.onClearSelected();
|
||||
} else {
|
||||
that.$message.warning(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleMenuClick(e) {
|
||||
if (e.key == 1) {
|
||||
this.batchDel();
|
||||
} else if (e.key == 2) {
|
||||
this.batchFrozen(2);
|
||||
} else if (e.key == 3) {
|
||||
this.batchFrozen(1);
|
||||
}
|
||||
},
|
||||
handleReset(id) {
|
||||
let that = this;
|
||||
postAction(that.url.resetPwd, {id: id}).then((res) => {
|
||||
@ -208,9 +140,18 @@
|
||||
that.$message.warning(res.data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
btnSetDepot(record) {
|
||||
this.$refs.userDepotModal.edit(record);
|
||||
this.$refs.userDepotModal.title = "分配仓库";
|
||||
this.$refs.userDepotModal.disableSubmit = false;
|
||||
},
|
||||
btnSetCustomer(record) {
|
||||
this.$refs.userCustomerModal.edit(record);
|
||||
this.$refs.userCustomerModal.title = "分配客户";
|
||||
this.$refs.userCustomerModal.disableSubmit = false;
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
@ -10,78 +10,120 @@
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;height: 95%;overflow-y: hidden">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form">
|
||||
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="按钮名称">
|
||||
<a-input placeholder="请输入角色名称" v-decorator.trim="[ 'name', validatorRules.name]" />
|
||||
</a-form-item>
|
||||
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="数据类型">
|
||||
<a-select placeholder="请选择数据类型" v-decorator="[ 'type', validatorRules.type]">
|
||||
<a-select-option value="全部数据">全部数据</a-select-option>
|
||||
<a-select-option value="本机构数据">本机构数据</a-select-option>
|
||||
<a-select-option value="个人数据">个人数据</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="描述">
|
||||
<a-textarea :rows="5" placeholder="请输入描述" v-decorator="[ 'description', validatorRules.description ]" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<div class="table-page-search-wrapper">
|
||||
<!-- 按钮区域 -->
|
||||
<a-form layout="inline">
|
||||
<a-row :gutter="24">
|
||||
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
||||
<a-col :md="12" :sm="24">
|
||||
<a-button @click="toggleChecked">
|
||||
{{ !checked ? '全选' : '全取消' }}
|
||||
</a-button>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<!-- table区域-begin -->
|
||||
<div>
|
||||
<a-table
|
||||
ref="table"
|
||||
size="middle"
|
||||
bordered
|
||||
rowKey="id"
|
||||
:pagination="false"
|
||||
:columns="columns"
|
||||
:dataSource="dataSource"
|
||||
:loading="loading">
|
||||
<span slot="action" slot-scope="text, record">
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(1)>-1" value="1" :checked="checked" @change="onChange">编辑</a-checkbox>
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(2)>-1" value="2" :checked="checked" @change="onChange">审核反审核</a-checkbox>
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(3)>-1" value="3" :checked="checked" @change="onChange">导入导出</a-checkbox>
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(4)>-1" value="4" :checked="checked" @change="onChange">启用禁用</a-checkbox>
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(5)>-1" value="5" :checked="checked" @change="onChange">打印</a-checkbox>
|
||||
<a-checkbox v-if="record.pushBtn.indexOf(6)>-1" value="6" :checked="checked" @change="onChange">作废</a-checkbox>
|
||||
</span>
|
||||
</a-table>
|
||||
</div>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
||||
import { getAction } from '@/api/manage'
|
||||
import {addRole,editRole,checkRole } from '@/api/api'
|
||||
export default {
|
||||
name: "RolePushBtnModal",
|
||||
mixins:[JeecgListMixin],
|
||||
data () {
|
||||
return {
|
||||
title:"操作",
|
||||
visible: false,
|
||||
model: {},
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
},
|
||||
checked: false,
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
validatorRules:{
|
||||
name:{
|
||||
rules: [
|
||||
{ required: true, message: '请输入角色名称!' },
|
||||
{ min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
|
||||
{ validator: this.validateRoleName}
|
||||
]
|
||||
/* 数据源 */
|
||||
dataSource:[],
|
||||
// 表头
|
||||
columns: [
|
||||
{
|
||||
title: '#',
|
||||
dataIndex: '',
|
||||
key:'rowIndex',
|
||||
width:40,
|
||||
align:"center",
|
||||
customRender:function (t,r,index) {
|
||||
return parseInt(index)+1;
|
||||
}
|
||||
},
|
||||
type:{
|
||||
rules: [
|
||||
{ required: true, message: '请选择数据类型!' }
|
||||
]
|
||||
{
|
||||
title: '名称',
|
||||
align:"center",
|
||||
dataIndex: 'name'
|
||||
},
|
||||
description:{
|
||||
rules: [
|
||||
{ min: 0, max: 126, message: '长度不超过 126 个字符', trigger: 'blur' }
|
||||
]
|
||||
{
|
||||
title: '按钮列表',
|
||||
dataIndex: 'action',
|
||||
align:"center",
|
||||
scopedSlots: { customRender: 'action' }
|
||||
}
|
||||
},
|
||||
],
|
||||
url: {
|
||||
list: "/function/findByIds",
|
||||
getBasicData: "/userBusiness/getBasicData"
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
add () {
|
||||
this.edit({});
|
||||
},
|
||||
edit (record) {
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, record);
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
|
||||
});
|
||||
getAction(this.url.getBasicData, {Type: 'RoleFunctions', KeyId: record.id}).then((res) => {
|
||||
if (res && res.code === 200) {
|
||||
let ubList = res.data.userBusinessList;
|
||||
let getValue = ubList[0].value;
|
||||
getValue = getValue.substring(1, getValue.length - 1);
|
||||
if (getValue.indexOf("][")) {
|
||||
let arr = getValue.split("][");
|
||||
arr = arr.toString();
|
||||
getAction(this.url.list, { functionsIds: arr }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.dataSource = res.data.rows;
|
||||
this.ipagination.total = res.data.total;
|
||||
}
|
||||
if (res.code === 510) {
|
||||
this.$message.warning(res.data)
|
||||
}
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
close () {
|
||||
this.$emit('close');
|
||||
@ -116,22 +158,11 @@
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
validateRoleName(rule, value, callback){
|
||||
let params = {
|
||||
name: value,
|
||||
id: this.model.id?this.model.id:0
|
||||
};
|
||||
checkRole(params).then((res)=>{
|
||||
if(res && res.code===200) {
|
||||
if(!res.data.status){
|
||||
callback();
|
||||
} else {
|
||||
callback("名称已经存在");
|
||||
}
|
||||
} else {
|
||||
callback(res.data);
|
||||
}
|
||||
});
|
||||
toggleChecked() {
|
||||
this.checked = !this.checked;
|
||||
},
|
||||
onChange(e) {
|
||||
this.checked = e.target.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
209
jshERP-web/src/views/system/modules/UserCustomerModal.vue
Normal file
209
jshERP-web/src/views/system/modules/UserCustomerModal.vue
Normal file
@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:title="title"
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
cancelText="关闭"
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;height: 95%;overflow-y: hidden">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<div class="drawer-bootom-button">
|
||||
<a-dropdown :trigger="['click']" placement="topCenter">
|
||||
<a-menu slot="overlay">
|
||||
<a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
|
||||
<a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
|
||||
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
|
||||
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
|
||||
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
|
||||
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
|
||||
</a-menu>
|
||||
<a-button>
|
||||
树操作 <a-icon type="up" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
<a-col :md="10" :sm="24">
|
||||
<template>
|
||||
<a-tree
|
||||
checkable
|
||||
multiple
|
||||
@check="onCheck"
|
||||
:selectedKeys="selectedKeys"
|
||||
:checkedKeys="checkedKeys"
|
||||
:treeData="roleFunctionTree"
|
||||
:checkStrictly="checkStrictly"
|
||||
:expandedKeys="iExpandedKeys"
|
||||
:autoExpandParent="true"
|
||||
@expand="onExpand"/>
|
||||
</template>
|
||||
</a-col>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import {addUserBusiness,editUserBusiness,checkUserBusiness} from '@/api/api'
|
||||
import {getAction} from '../../../api/manage'
|
||||
export default {
|
||||
name: "UserCustomerModal",
|
||||
data () {
|
||||
return {
|
||||
title:"操作",
|
||||
visible: false,
|
||||
model: {},
|
||||
roleId: 0,
|
||||
iExpandedKeys: [],
|
||||
roleFunctionTree: [],
|
||||
checkedKeys: [],
|
||||
selectedKeys: [],
|
||||
checkStrictly: false,
|
||||
hiding: true,
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
edit (record) {
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, {});
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
|
||||
});
|
||||
this.roleId = record.id
|
||||
this.checkedKeys = []
|
||||
this.loadTree(record.id)
|
||||
},
|
||||
close () {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
},
|
||||
handleOk () {
|
||||
const that = this;
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
that.confirmLoading = true;
|
||||
let formData = Object.assign(this.model, values);
|
||||
formData.type = 'UserCustomer'
|
||||
formData.keyId = this.roleId
|
||||
formData.value = this.checkedKeys
|
||||
let obj;
|
||||
checkUserBusiness({'type': 'UserCustomer','keyId': this.roleId}).then((res)=>{
|
||||
if(res.data && res.data.id) {
|
||||
formData.id=res.data.id
|
||||
obj=editUserBusiness(formData);
|
||||
} else {
|
||||
obj=addUserBusiness(formData);
|
||||
}
|
||||
obj.then((res)=>{
|
||||
if(res.code === 200){
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
that.$message.warning(res.data.message);
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
loadTree(id) {
|
||||
let that = this
|
||||
that.treeData = []
|
||||
that.roleFunctionTree = []
|
||||
let params = {};
|
||||
params.id='';
|
||||
getAction('/supplier/findUserCustomer?UBType=UserCustomer&UBKeyId='+id).then((res) => {
|
||||
if (res) {
|
||||
//机构全选后,再添加机构,选中数量增多
|
||||
this.allTreeKeys = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
let temp = res[i]
|
||||
that.treeData.push(temp)
|
||||
that.roleFunctionTree.push(temp)
|
||||
that.setThisExpandedKeys(temp)
|
||||
that.getAllKeys(temp);
|
||||
}
|
||||
console.log(JSON.stringify(this.checkedKeys))
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
onCheck(checkedKeys, info) {
|
||||
console.log('onCheck', checkedKeys, info)
|
||||
this.hiding = false
|
||||
if(this.checkStrictly){
|
||||
this.checkedKeys = checkedKeys.checked;
|
||||
}else{
|
||||
this.checkedKeys = checkedKeys
|
||||
}
|
||||
},
|
||||
setThisExpandedKeys(node) {
|
||||
if(node.checked==true) {
|
||||
this.checkedKeys.push(node.key)
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
this.iExpandedKeys.push(node.key)
|
||||
for (let a = 0; a < node.children.length; a++) {
|
||||
this.setThisExpandedKeys(node.children[a])
|
||||
}
|
||||
}
|
||||
},
|
||||
getAllKeys(node) {
|
||||
// console.log('node',node);
|
||||
this.allTreeKeys.push(node.key)
|
||||
if (node.children && node.children.length > 0) {
|
||||
for (let a = 0; a < node.children.length; a++) {
|
||||
this.getAllKeys(node.children[a])
|
||||
}
|
||||
}
|
||||
},
|
||||
expandAll () {
|
||||
this.iExpandedKeys = this.allTreeKeys
|
||||
},
|
||||
closeAll () {
|
||||
this.iExpandedKeys = []
|
||||
},
|
||||
checkALL () {
|
||||
this.checkStriccheckStrictlytly = false
|
||||
this.checkedKeys = this.allTreeKeys
|
||||
},
|
||||
cancelCheckALL () {
|
||||
this.checkedKeys = []
|
||||
},
|
||||
switchCheckStrictly (v) {
|
||||
if(v==1){
|
||||
this.checkStrictly = false
|
||||
}else if(v==2){
|
||||
this.checkStrictly = true
|
||||
}
|
||||
},
|
||||
onExpand(expandedKeys) {
|
||||
console.log('onExpand', expandedKeys)
|
||||
this.iExpandedKeys = expandedKeys
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
209
jshERP-web/src/views/system/modules/UserDepotModal.vue
Normal file
209
jshERP-web/src/views/system/modules/UserDepotModal.vue
Normal file
@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:title="title"
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
cancelText="关闭"
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;height: 95%;overflow-y: hidden">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<div class="drawer-bootom-button">
|
||||
<a-dropdown :trigger="['click']" placement="topCenter">
|
||||
<a-menu slot="overlay">
|
||||
<a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
|
||||
<a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
|
||||
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
|
||||
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
|
||||
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
|
||||
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
|
||||
</a-menu>
|
||||
<a-button>
|
||||
树操作 <a-icon type="up" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
<a-col :md="10" :sm="24">
|
||||
<template>
|
||||
<a-tree
|
||||
checkable
|
||||
multiple
|
||||
@check="onCheck"
|
||||
:selectedKeys="selectedKeys"
|
||||
:checkedKeys="checkedKeys"
|
||||
:treeData="roleFunctionTree"
|
||||
:checkStrictly="checkStrictly"
|
||||
:expandedKeys="iExpandedKeys"
|
||||
:autoExpandParent="true"
|
||||
@expand="onExpand"/>
|
||||
</template>
|
||||
</a-col>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script>
|
||||
import pick from 'lodash.pick'
|
||||
import {addUserBusiness,editUserBusiness,checkUserBusiness} from '@/api/api'
|
||||
import {getAction} from '../../../api/manage'
|
||||
export default {
|
||||
name: "UserDepotModal",
|
||||
data () {
|
||||
return {
|
||||
title:"操作",
|
||||
visible: false,
|
||||
model: {},
|
||||
roleId: 0,
|
||||
iExpandedKeys: [],
|
||||
roleFunctionTree: [],
|
||||
checkedKeys: [],
|
||||
selectedKeys: [],
|
||||
checkStrictly: false,
|
||||
hiding: true,
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
},
|
||||
confirmLoading: false,
|
||||
form: this.$form.createForm(this),
|
||||
}
|
||||
},
|
||||
created () {
|
||||
},
|
||||
methods: {
|
||||
edit (record) {
|
||||
this.form.resetFields();
|
||||
this.model = Object.assign({}, {});
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model,'name', 'type', 'description'))
|
||||
});
|
||||
this.roleId = record.id
|
||||
this.checkedKeys = []
|
||||
this.loadTree(record.id)
|
||||
},
|
||||
close () {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
},
|
||||
handleOk () {
|
||||
const that = this;
|
||||
// 触发表单验证
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
that.confirmLoading = true;
|
||||
let formData = Object.assign(this.model, values);
|
||||
formData.type = 'UserDepot'
|
||||
formData.keyId = this.roleId
|
||||
formData.value = this.checkedKeys
|
||||
let obj;
|
||||
checkUserBusiness({'type': 'UserDepot','keyId': this.roleId}).then((res)=>{
|
||||
if(res.data && res.data.id) {
|
||||
formData.id=res.data.id
|
||||
obj=editUserBusiness(formData);
|
||||
} else {
|
||||
obj=addUserBusiness(formData);
|
||||
}
|
||||
obj.then((res)=>{
|
||||
if(res.code === 200){
|
||||
that.$emit('ok');
|
||||
}else{
|
||||
that.$message.warning(res.data.message);
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.close();
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
loadTree(id) {
|
||||
let that = this
|
||||
that.treeData = []
|
||||
that.roleFunctionTree = []
|
||||
let params = {};
|
||||
params.id='';
|
||||
getAction('/depot/findUserDepot?UBType=UserDepot&UBKeyId='+id).then((res) => {
|
||||
if (res) {
|
||||
//机构全选后,再添加机构,选中数量增多
|
||||
this.allTreeKeys = [];
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
let temp = res[i]
|
||||
that.treeData.push(temp)
|
||||
that.roleFunctionTree.push(temp)
|
||||
that.setThisExpandedKeys(temp)
|
||||
that.getAllKeys(temp);
|
||||
}
|
||||
console.log(JSON.stringify(this.checkedKeys))
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
onCheck(checkedKeys, info) {
|
||||
console.log('onCheck', checkedKeys, info)
|
||||
this.hiding = false
|
||||
if(this.checkStrictly){
|
||||
this.checkedKeys = checkedKeys.checked;
|
||||
}else{
|
||||
this.checkedKeys = checkedKeys
|
||||
}
|
||||
},
|
||||
setThisExpandedKeys(node) {
|
||||
if(node.checked==true) {
|
||||
this.checkedKeys.push(node.key)
|
||||
}
|
||||
if (node.children && node.children.length > 0) {
|
||||
this.iExpandedKeys.push(node.key)
|
||||
for (let a = 0; a < node.children.length; a++) {
|
||||
this.setThisExpandedKeys(node.children[a])
|
||||
}
|
||||
}
|
||||
},
|
||||
getAllKeys(node) {
|
||||
// console.log('node',node);
|
||||
this.allTreeKeys.push(node.key)
|
||||
if (node.children && node.children.length > 0) {
|
||||
for (let a = 0; a < node.children.length; a++) {
|
||||
this.getAllKeys(node.children[a])
|
||||
}
|
||||
}
|
||||
},
|
||||
expandAll () {
|
||||
this.iExpandedKeys = this.allTreeKeys
|
||||
},
|
||||
closeAll () {
|
||||
this.iExpandedKeys = []
|
||||
},
|
||||
checkALL () {
|
||||
this.checkStriccheckStrictlytly = false
|
||||
this.checkedKeys = this.allTreeKeys
|
||||
},
|
||||
cancelCheckALL () {
|
||||
this.checkedKeys = []
|
||||
},
|
||||
switchCheckStrictly (v) {
|
||||
if(v==1){
|
||||
this.checkStrictly = false
|
||||
}else if(v==2){
|
||||
this.checkStrictly = true
|
||||
}
|
||||
},
|
||||
onExpand(expandedKeys) {
|
||||
console.log('onExpand', expandedKeys)
|
||||
this.iExpandedKeys = expandedKeys
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@ -70,22 +70,12 @@
|
||||
return {
|
||||
title:"操作",
|
||||
visible: false,
|
||||
departDisabled: false, //是否是我的部门调用该页面
|
||||
roleDisabled: false, //是否是角色维护调用该页面
|
||||
modalWidth:800,
|
||||
drawerWidth:700,
|
||||
modaltoggleFlag:true,
|
||||
confirmDirty: false,
|
||||
orgaTree: [],
|
||||
roleList: [],
|
||||
selectedDepartKeys:[], //保存用户选择部门id
|
||||
checkedDepartKeys:[],
|
||||
checkedDepartNames:[], // 保存部门的名称 =>title
|
||||
checkedDepartNameString:"", // 保存部门的名称 =>title
|
||||
resultDepartOptions:[],
|
||||
userId:"", //保存用户id
|
||||
disableSubmit:false,
|
||||
userDepartModel:{userId:'',departIdList:[]}, // 保存SysUserDepart的用户部门中间表数据需要的对象
|
||||
dateFormat:"YYYY-MM-DD",
|
||||
validatorRules:{
|
||||
loginName:{
|
||||
@ -99,10 +89,7 @@
|
||||
}]
|
||||
}
|
||||
},
|
||||
departIdShow:false,
|
||||
departIds:[], //负责部门id
|
||||
model: {},
|
||||
selectedRole:[],
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 5 },
|
||||
@ -114,14 +101,7 @@
|
||||
uploadLoading:false,
|
||||
confirmLoading: false,
|
||||
headers:{},
|
||||
form:this.$form.createForm(this),
|
||||
picUrl: "",
|
||||
url: {
|
||||
userId:"/sys/user/generateUserId", // 引入生成添加用户情况下的url
|
||||
syncUserByUserName:"/process/extActProcess/doSyncUserByUserName",//同步用户到工作流
|
||||
},
|
||||
identity:"1",
|
||||
fileList:[],
|
||||
form:this.$form.createForm(this)
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -130,47 +110,13 @@
|
||||
const token = Vue.ls.get(ACCESS_TOKEN);
|
||||
this.headers = {"X-Access-Token":token}
|
||||
},
|
||||
computed:{
|
||||
uploadAction:function () {
|
||||
return this.url.fileUpload;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isDisabledAuth(code){
|
||||
return disabledAuthFilter(code);
|
||||
},
|
||||
//窗口最大化切换
|
||||
toggleScreen(){
|
||||
if(this.modaltoggleFlag){
|
||||
this.modalWidth = window.innerWidth;
|
||||
}else{
|
||||
this.modalWidth = 800;
|
||||
}
|
||||
this.modaltoggleFlag = !this.modaltoggleFlag;
|
||||
},
|
||||
refresh () {
|
||||
this.selectedDepartKeys=[];
|
||||
this.checkedDepartKeys=[];
|
||||
this.checkedDepartNames=[];
|
||||
this.checkedDepartNameString = "";
|
||||
this.userId=""
|
||||
this.resultDepartOptions=[];
|
||||
this.departId=[];
|
||||
this.departIdShow=false;
|
||||
},
|
||||
add () {
|
||||
this.picUrl = "";
|
||||
this.edit({activitiSync:'1'});
|
||||
this.edit({});
|
||||
},
|
||||
edit (record) {
|
||||
let that = this;
|
||||
that.checkedDepartNameString = "";
|
||||
that.form.resetFields();
|
||||
if(record.hasOwnProperty("id")){
|
||||
setTimeout(() => {
|
||||
this.fileList = record.avatar;
|
||||
}, 5)
|
||||
}
|
||||
that.userId = record.id;
|
||||
that.visible = true;
|
||||
that.model = Object.assign({}, record);
|
||||
@ -178,57 +124,11 @@
|
||||
that.form.setFieldsValue(pick(this.model,'loginName','username','roleId','orgaId','position',
|
||||
'phonenum','email','userBlngOrgaDsplSeq','description'))
|
||||
});
|
||||
// 调用查询用户对应的部门信息的方法
|
||||
that.checkedDepartKeys = [];
|
||||
that.loadCheckedDeparts();
|
||||
},
|
||||
loadCheckedDeparts(){
|
||||
let that = this;
|
||||
if(!that.userId){return}
|
||||
getAction(that.url.userWithDepart,{userId:that.userId}).then((res)=>{
|
||||
that.checkedDepartNames = [];
|
||||
if(res.success){
|
||||
var depart=[];
|
||||
var departId=[];
|
||||
for (let i = 0; i < res.result.length; i++) {
|
||||
that.checkedDepartNames.push(res.result[i].title);
|
||||
this.checkedDepartNameString = this.checkedDepartNames.join(",");
|
||||
that.checkedDepartKeys.push(res.result[i].key);
|
||||
//新增负责部门选择下拉框
|
||||
depart.push({
|
||||
key:res.result[i].key,
|
||||
title:res.result[i].title
|
||||
})
|
||||
departId.push(res.result[i].key)
|
||||
}
|
||||
that.resultDepartOptions=depart;
|
||||
//判断部门id是否存在,不存在择直接默认当前所在部门
|
||||
if(this.model.departIds){
|
||||
this.departIds=this.model.departIds.split(",");
|
||||
}else{
|
||||
this.departIds=departId;
|
||||
}
|
||||
that.userDepartModel.departIdList = that.checkedDepartKeys
|
||||
}else{
|
||||
console.log(res.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.visible = false;
|
||||
this.disableSubmit = false;
|
||||
this.selectedRole = [];
|
||||
this.userDepartModel = {userId:'',departIdList:[]};
|
||||
this.checkedDepartNames = [];
|
||||
this.checkedDepartNameString='';
|
||||
this.checkedDepartKeys = [];
|
||||
this.selectedDepartKeys = [];
|
||||
this.resultDepartOptions=[];
|
||||
this.departIds=[];
|
||||
this.departIdShow=false;
|
||||
this.identity="1";
|
||||
this.fileList=[];
|
||||
},
|
||||
handleOk() {
|
||||
const that = this;
|
||||
@ -236,27 +136,7 @@
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
that.confirmLoading = true;
|
||||
if(!values.birthday){
|
||||
values.birthday = '';
|
||||
}else{
|
||||
values.birthday = values.birthday.format(this.dateFormat);
|
||||
}
|
||||
let formData = Object.assign(this.model, values);
|
||||
if(that.fileList != ''){
|
||||
formData.avatar = that.fileList;
|
||||
}else{
|
||||
formData.avatar = null;
|
||||
}
|
||||
formData.selectedroles = this.selectedRole.length>0?this.selectedRole.join(","):'';
|
||||
formData.selecteddeparts = this.userDepartModel.departIdList.length>0?this.userDepartModel.departIdList.join(","):'';
|
||||
formData.userIdentity=this.identity;
|
||||
//如果是上级择传入departIds,否则为空
|
||||
if(this.identity==="2"){
|
||||
formData.departIds=this.departIds.join(",");
|
||||
}else{
|
||||
formData.departIds="";
|
||||
}
|
||||
// that.addDepartsToUser(that,formData); // 调用根据当前用户添加部门信息的方法
|
||||
let obj;
|
||||
if(!this.model.id){
|
||||
formData.id = this.userId;
|
||||
@ -272,8 +152,6 @@
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false;
|
||||
that.checkedDepartNames = [];
|
||||
that.userDepartModel.departIdList = {userId:'',departIdList:[]};
|
||||
that.close();
|
||||
})
|
||||
|
||||
@ -283,28 +161,6 @@
|
||||
handleCancel() {
|
||||
this.close()
|
||||
},
|
||||
handleConfirmBlur(e) {
|
||||
const value = e.target.value;
|
||||
this.confirmDirty = this.confirmDirty || !!value
|
||||
},
|
||||
handleChange(info) {
|
||||
this.picUrl = "";
|
||||
if (info.file.status === 'uploading') {
|
||||
this.uploadLoading = true;
|
||||
return
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
var response = info.file.response;
|
||||
this.uploadLoading = false;
|
||||
console.log(response);
|
||||
if(response.success){
|
||||
this.model.avatar = response.message;
|
||||
this.picUrl = "Has no pic url yet";
|
||||
}else{
|
||||
this.$message.warning(response.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
loadOrgaData(){
|
||||
let that = this;
|
||||
let params = {};
|
||||
@ -332,34 +188,5 @@
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.avatar-uploader > .ant-upload {
|
||||
width:104px;
|
||||
height:104px;
|
||||
}
|
||||
.ant-upload-select-picture-card i {
|
||||
font-size: 49px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.ant-upload-select-picture-card .ant-upload-text {
|
||||
margin-top: 8px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.ant-table-tbody .ant-table-row td{
|
||||
padding-top:10px;
|
||||
padding-bottom:10px;
|
||||
}
|
||||
|
||||
.drawer-bootom-button {
|
||||
position: absolute;
|
||||
bottom: -8px;
|
||||
width: 100%;
|
||||
border-top: 1px solid #e8e8e8;
|
||||
padding: 10px 16px;
|
||||
text-align: right;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user