优化给仓库分配用户的功能

This commit is contained in:
jishenghua
2025-07-11 22:49:40 +08:00
parent c92320b4b7
commit 48aaa4d24f
3 changed files with 215 additions and 8 deletions

View File

@@ -49,6 +49,8 @@
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a v-if="btnEnableList.indexOf(1)>-1 && depotFlag === '1' && quickBtn.user.indexOf(1)>-1 " @click="btnSetUser(record)">分配用户</a>
<a-divider v-if="btnEnableList.indexOf(1)>-1 && depotFlag === '1' && quickBtn.user.indexOf(1)>-1 " type="vertical" />
<a-popconfirm v-if="btnEnableList.indexOf(1)>-1" title="确定设为默认吗?" @confirm="() => handleSetDefault(record.id)">
<a>设为默认</a>
</a-popconfirm>
@@ -73,21 +75,26 @@
<!-- table区域-end -->
<!-- 表单区域 -->
<depot-modal ref="modalForm" @ok="modalFormOk"></depot-modal>
<depot-user-modal ref="depotUserModal"></depot-user-modal>
</a-card>
</a-col>
</a-row>
</template>
<!-- BY cao_yu_li -->
<!-- BY cao_yu-li -->
<script>
import DepotModal from './modules/DepotModal'
import DepotUserModal from './modules/DepotUserModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JDate from '@/components/jeecg/JDate'
import { postAction } from '@api/manage'
import { getCurrentSystemConfig } from '@/api/api'
import Vue from 'vue'
export default {
name: "DepotList",
mixins:[JeecgListMixin],
components: {
DepotModal,
DepotUserModal,
JDate
},
data () {
@@ -101,6 +108,10 @@
},
// 查询条件
queryParam: {name:'',remark:''},
depotFlag: '0',
quickBtn: {
user: ''
},
// 表头
columns: [
{
@@ -143,10 +154,29 @@
}
}
},
computed: {
created() {
this.getSystemConfig()
this.initQuickBtn()
},
methods: {
getSystemConfig() {
getCurrentSystemConfig().then((res) => {
if(res.code === 200 && res.data){
this.depotFlag = res.data.depotFlag
}
})
},
//加载快捷按钮:分配用户
initQuickBtn() {
let btnStrList = Vue.ls.get('winBtnStrList') //按钮功能列表 JSON字符串
if (btnStrList) {
for (let i = 0; i < btnStrList.length; i++) {
if (btnStrList[i].btnStr) {
this.quickBtn.user = btnStrList[i].url === '/system/user'?btnStrList[i].btnStr:this.quickBtn.user
}
}
}
},
handleSetDefault: function (id) {
if(!this.url.setDefault){
this.$message.error("请设置url.delete属性!")
@@ -168,6 +198,11 @@
if(this.btnEnableList.indexOf(1)===-1) {
this.$refs.modalForm.isReadOnly = true
}
},
btnSetUser(record) {
this.$refs.depotUserModal.edit(record)
this.$refs.depotUserModal.title = "分配用户给" + record.name
this.$refs.depotUserModal.disableSubmit = false
}
}
}

View File

@@ -24,7 +24,7 @@
@check="onCheck"
:selectedKeys="selectedKeys"
:checkedKeys="checkedKeys"
:treeData="roleFunctionTree"
:treeData="customerUserTree"
:checkStrictly="checkStrictly"
:expandedKeys="iExpandedKeys"
:autoExpandParent="true"
@@ -50,7 +50,7 @@
model: {},
customerId: 0,
iExpandedKeys: [],
roleFunctionTree: [],
customerUserTree: [],
checkedKeys: [],
selectedKeys: [],
checkStrictly: false,
@@ -112,17 +112,17 @@
loadTree(id) {
let that = this
that.treeData = []
that.roleFunctionTree = []
that.customerUserTree = []
let params = {};
params.id='';
getAction('/supplier/getCustomerUser?UBType=UserCustomer&UBValue='+id).then((res) => {
getAction('/user/getUserWithChecked?UBType=UserCustomer&UBValue='+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.customerUserTree.push(temp)
that.setThisExpandedKeys(temp)
that.getAllKeys(temp);
}

View File

@@ -0,0 +1,172 @@
<template>
<div ref="container">
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
:getContainer="() => $refs.container"
:maskStyle="{'top':'93px','left':'154px'}"
:wrapClassName="wrapClassNameInfo()"
:mask="isDesktop()"
:maskClosable="false"
@ok="handleOk"
@cancel="handleCancel"
cancelText="取消"
okText="保存"
style="top:5%;height: 95%;">
<a-spin :spinning="confirmLoading">
<a-col :md="10" :sm="24">
<template>
<a-tree
checkable
multiple
@check="onCheck"
:selectedKeys="selectedKeys"
:checkedKeys="checkedKeys"
:treeData="depotUserTree"
:checkStrictly="checkStrictly"
:expandedKeys="iExpandedKeys"
:autoExpandParent="true"
@expand="onExpand"/>
</template>
</a-col>
</a-spin>
</a-modal>
</div>
</template>
<script>
import pick from 'lodash.pick'
import {mixinDevice} from '@/utils/mixin'
import {updateOneValueByKeyIdAndType} from '@/api/api'
import {getAction} from '../../../api/manage'
export default {
name: "DepotUserModal",
mixins: [mixinDevice],
data () {
return {
title:"操作",
visible: false,
model: {},
depotId: 0,
iExpandedKeys: [],
depotUserTree: [],
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.depotId = 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.keyIds = this.checkedKeys
formData.oneValue = this.depotId
updateOneValueByKeyIdAndType(formData).then((res)=>{
if(res.code === 200){
that.$message.info('保存成功');
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.depotUserTree = []
let params = {};
params.id='';
getAction('/user/getUserWithChecked?UBType=UserDepot&UBValue='+id).then((res) => {
if (res) {
//机构全选后,再添加机构,选中数量增多
this.allTreeKeys = [];
for (let i = 0; i < res.length; i++) {
let temp = res[i]
that.treeData.push(temp)
that.depotUserTree.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])
}
}
},
onExpand(expandedKeys) {
console.log('onExpand', expandedKeys)
this.iExpandedKeys = expandedKeys
}
}
}
</script>
<style scoped>
</style>