Commit a82ff5c2 authored by wanglianghe's avatar wanglianghe

仓库绑定部门

parent 22cd91aa
...@@ -89,4 +89,23 @@ export function openedRouterList(data) { ...@@ -89,4 +89,23 @@ export function openedRouterList(data) {
}) })
} }
/**仓库绑定部门 */
export function deptBind(data) {
return request({
url: '/ecw/warehouse/deptBind',
method: 'post',
data: data
})
}
/**获取已绑定的部门列表 */
export function deptList(data) {
return request({
url: '/ecw/warehouse/deptList',
method: 'post',
data: data
})
}
...@@ -67,6 +67,9 @@ ...@@ -67,6 +67,9 @@
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['ecw:warehouse:update']">修改</el-button> v-hasPermi="['ecw:warehouse:update']">修改</el-button>
<el-button size="mini" type="text" @click="bindDept(scope.row)"
v-hasPermi="['system:dept:query']">绑定部门</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -113,6 +116,19 @@ ...@@ -113,6 +116,19 @@
@pagination="getRouteList"/> @pagination="getRouteList"/>
</el-dialog> </el-dialog>
<el-dialog title="绑定部门" :visible.sync="deptOpen" width="500px" append-to-body>
<el-header>
<el-button type="primary" @click="commitBind">提交</el-button>
</el-header>
<el-table ref="multipleTable" v-if="refreshTable" :data="deptList" row-key="id" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" @select="select" @select-all="selectAll" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="name" label="部门名称" ></el-table-column>
<!-- <el-table-column prop="leader" label="负责人" :formatter="userNicknameFormat" width="120"/> -->
</el-table>
</el-dialog>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="90px"> <el-form ref="form" :model="form" :rules="rules" label-width="90px">
...@@ -232,12 +248,14 @@ ...@@ -232,12 +248,14 @@
<script> <script>
import { createWarehouse, updateWarehouse, deleteWarehouse, getWarehouse, getWarehousePage, import { createWarehouse, updateWarehouse, deleteWarehouse, getWarehouse, getWarehousePage,
exportWarehouseExcel,routerList,changeRouteStatus } from "@/api/ecw/warehouse"; exportWarehouseExcel,routerList,changeRouteStatus,deptBind,deptList } from "@/api/ecw/warehouse";
import { getNodePage } from "@/api/ecw/node"; import { getNodePage } from "@/api/ecw/node";
import { getListTree } from "@/api/ecw/region"; import { getListTree } from "@/api/ecw/region";
import { getDictDatas, DICT_TYPE } from '@/utils/dict'; import { getDictDatas, DICT_TYPE } from '@/utils/dict';
import {CommonStatusEnum} from '@/utils/constants' import {CommonStatusEnum} from '@/utils/constants'
import { uploadFile } from "@/api/infra/file"; import { uploadFile } from "@/api/infra/file";
import { listDept } from "@/api/system/dept";
import { has } from 'min-dash';
export default { export default {
name: "Warehouse", name: "Warehouse",
...@@ -265,6 +283,19 @@ export default { ...@@ -265,6 +283,19 @@ export default {
// 显示搜索条件 // 显示搜索条件
showSearch: true, showSearch: true,
//显示绑定部门
deptOpen: false,
//部门列表
deptList:[],
// 是否展开,默认全部展开
isExpandAll: true,
// 重新渲染表格状态
refreshTable: true,
//选中的部门
selectDeptList:[],
//需要绑定部门的仓库id
deptWarhouse: null,
//洲际列表 //洲际列表
continentsList:[], continentsList:[],
//国家列表 //国家列表
...@@ -411,6 +442,70 @@ export default { ...@@ -411,6 +442,70 @@ export default {
}); });
}, },
/** 查询部门列表 */
getDeptList() {
listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "id");
//回选已选择的部门
this.recoveryChecked();
});
},
recoveryChecked() {
// console.log
for(let index in this.deptList) {
let dept = this.deptList[index];
this.deptChecked(dept);
}
},
deptChecked(dept) {
let deptIdList = this.deptWarhouse.deptIdList;
console.log(deptIdList);
const hasSelect = deptIdList.some(el => {
return dept.id === el
})
if(hasSelect) {
this.toggleSelection(dept, true);
}
if(dept.children) {
dept.children.map(j => {
this.deptChecked(j);
})
}
},
// 用户昵称展示
userNicknameFormat(row, column) {
if (!row.leaderUserId) {
return '未设置';
}
for (let index in this.users) {
let user = this.user[index];
if (row.leaderUserId === user.id) {
return user.nickname;
}
}
return '未知【' + row.leaderUserId + '';
},
/** 绑定部门 */
bindDept(row) {
this.deptWarhouse = row;
this.deptOpen = true;
this.getDeptList();
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
getSelectNode(nodeId) { getSelectNode(nodeId) {
for(let index in this.nodeList) { for(let index in this.nodeList) {
let node = this.nodeList[index]; let node = this.nodeList[index];
...@@ -691,7 +786,111 @@ export default { ...@@ -691,7 +786,111 @@ export default {
this.$download.excel(response, '${table.classComment}.xls'); this.$download.excel(response, '${table.classComment}.xls');
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {});
},
/**提交绑定部门 */
commitBind() {
if(!this.selectDeptList || this.selectDeptList.length == 0) {
this.$message.error('请先选择部门');
return;
}
//获取部门id列表
let deptIdList = [];
this.selectDeptList.map((item) => {
deptIdList.push(item.id);
return item;
});
let params = {deptIdList: deptIdList, warehouseId: this.deptWarhouse.id};
deptBind(params).then(response => {
this.$message.success('绑定成功');
let deptIdList = response.data;
// console.log(deptIdList);
for(let index in this.list) {
let warehouse = this.list[index];
if(warehouse.id == this.deptWarhouse.id) {
warehouse.deptIdList = deptIdList;
}
}
// console.log(this.list);
this.deptOpen = false;
})
},
handleSelectionChange(value) {
this.selectDeptList = value;
// console.log(this.selectDeptList);
},
setChildren(children, type) {
// 编辑多个子层级
children.map(j => {
this.toggleSelection(j, type)
if (j.children) {
this.setChildren(j.children, type)
}
})
},
// 选中父节点时,子节点一起选中取消
select(selection, row) {
const hasSelect = selection.some(el => {
return row.id === el.id
})
if (hasSelect) {
if (row.children) {
// 解决子组件没有被勾选到
this.setChildren(row.children, true)
}
//TODO 判断父节点的所有子节点是否都被选中
} else {
if (row.children) {
this.setChildren(row.children, false)
}
}
},
toggleSelection(row, select) {
if (row) {
this.$nextTick(() => {
this.$refs.multipleTable &&
this.$refs.multipleTable.toggleRowSelection(row, select)
})
}
},
// 选择全部
selectAll(selection) {
// console.log(selection);
// tabledata第一层只要有在selection里面就是全选
const isSelect = selection.some(el => {
const tableDataIds = this.deptList.map(j => j.id)
return tableDataIds.includes(el.id)
})
// tableDate第一层只要有不在selection里面就是全不选
const isCancel = !this.deptList.every(el => {
const selectIds = selection.map(j => j.id)
return selectIds.includes(el.id)
})
if (isSelect) {
selection.map(el => {
if (el.children) {
// 解决子组件没有被勾选到
this.setChildren(el.children, true)
}
})
}
if (isCancel) {
this.deptList.map(el => {
if (el.children) {
// 解决子组件没有被勾选到
this.setChildren(el.children, false)
}
})
}
} }
} }
}; };
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment