<template>
|
<a-card
|
:loading="cardLoading"
|
:bordered="false"
|
>
|
<a-spin :spinning="loading">
|
<a-alert
|
type="info"
|
:showIcon="true"
|
style="margin-right: 54px;"
|
>
|
<div slot="message">
|
当前:<span v-if="this.currSelected.title">{{ getCurrSelectedTitle() }}</span>
|
<a
|
v-if="this.currSelected.title"
|
style="margin-left: 10px"
|
@click="onClearSelectedAnother"
|
>取消</a>
|
</div>
|
</a-alert>
|
<div class="drawer-bootom-button">
|
<a-dropdown
|
:trigger="['click']"
|
placement="bottomCenter"
|
>
|
<a-menu slot="overlay">
|
<a-menu-item
|
key="1"
|
@click="expandAll"
|
>展开所有</a-menu-item>
|
<a-menu-item
|
key="2"
|
@click="closeAll"
|
>合并所有</a-menu-item>
|
<a-menu-item
|
key="3"
|
@click="refreshTree"
|
>刷新</a-menu-item>
|
</a-menu>
|
<a-button>
|
<a-icon type="bars" />
|
</a-button>
|
</a-dropdown>
|
</div>
|
<a-directory-tree
|
selectable
|
showLine
|
:checkStrictly="checkStrictly"
|
:expandedKeys.sync="expandedKeys"
|
:selectedKeys="selectedKeys"
|
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
|
:treeData="treeDataSource"
|
:autoExpandParent="autoExpandParent"
|
@select="onSelect"
|
@expand="onExpand"
|
rowKey="id"
|
>
|
</a-directory-tree>
|
</a-spin>
|
</a-card>
|
</template>
|
<script>
|
import { getAction } from '@/api/manage'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import { deleteAction } from '../../../../api/manage'
|
export default {
|
name: 'WarehouseFactoryModelLeft',
|
components: {
|
Tooltip,
|
JEllipsis
|
},
|
props:{
|
enterpriseId:{
|
type:String,
|
default:'',
|
required:false
|
}
|
},
|
data() {
|
return {
|
userId:'',
|
factoryInfo:{},
|
cardLoading: false,
|
loading: false,
|
treeDataSource: [],
|
selectedKeys: [],
|
expandedKeys: [],
|
url: {
|
loadTree: '/base/factoryModel/loadTree',
|
getFactoryInfo: "/base/factoryModel/getFactoryInfo",//根据企业id查工厂树
|
},
|
searchValue: '',
|
dataList: [],
|
autoExpandParent: true,
|
checkStrictly: true,
|
allTreeKeys: [],
|
currSelected: {},
|
hiding: false
|
}
|
},
|
created() {
|
this.getFactoryInfo();
|
},
|
methods: {
|
getCurrSelectedTitle() {
|
return !this.currSelected.title ? '' : this.currSelected.title
|
},
|
onClearSelected() {
|
this.hiding = true;
|
this.currSelected = {};
|
this.selectedKeys = [];
|
this.fristSelectKeys=[];
|
|
},
|
onClearSelectedAnother(){
|
this.hiding = true;
|
this.currSelected = {};
|
this.selectedKeys = [];
|
this.fristSelectKeys=[];
|
this.$emit('loadList',this.factoryInfo);
|
},
|
onSelect(selectedKeys, e) {
|
this.selectedKeys=[];
|
let record = e.node.dataRef;
|
this.currSelected = Object.assign({}, record);
|
console.log(this.currSelected);
|
this.selectedKeys = [record.key];
|
this.factoryInfo.parentId = selectedKeys[0]
|
},
|
onExpand(expandedKeys) {
|
this.expandedKeys = expandedKeys
|
this.autoExpandParent = false
|
},
|
getFactoryInfo(){
|
this.loading = true;
|
this.cardLoading = true;
|
getAction(this.url.getFactoryInfo).then(res=>{
|
if(res.success){
|
var params={
|
version:res.result.version,
|
enterpriseId:this.enterpriseId
|
}
|
this.queryTreeData(params);
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
}).finally(res=>{
|
this.loading = false
|
this.cardLoading = false
|
})
|
},
|
queryTreeData(params) {
|
getAction(this.url.loadTree,params).then((res) => {
|
if (res.success) {
|
this.dataList = []
|
this.allTreeKeys = []
|
this.treeDataSource = res.result
|
this.generateList(res.result);
|
this.expandAll();
|
this.selectedKeys=[res.result[0].key];
|
this.currSelected = res.result[0];
|
this.factoryInfo={
|
parentId:res.result[0].key,
|
version:params.version
|
}
|
} else {
|
this.$message.warn(res.message)
|
}
|
})
|
},
|
refreshTree(){
|
this.queryTreeData(this.factoryInfo);
|
},
|
getParentKey(key, tree) {
|
let parentKey
|
for (let i = 0; i < tree.length; i++) {
|
const node = tree[i]
|
if (node.children) {
|
if (node.children.some(item => item.key === key)) {
|
parentKey = node.key
|
} else if (
|
this.getParentKey(key, node.children)) {
|
parentKey = this.getParentKey(key, node.children)
|
}
|
}
|
}
|
return parentKey
|
},
|
generateList(data) {
|
for (let i = 0; i < data.length; i++) {
|
const node = data[i]
|
const key = node.key
|
const title = node.title
|
// const type = node.type;
|
|
this.dataList.push({ key, title: title })
|
this.allTreeKeys.push(key)
|
if (node.children) {
|
this.generateList(node.children)
|
}
|
}
|
},
|
expandAll() {
|
this.expandedKeys = this.allTreeKeys
|
},
|
closeAll() {
|
this.expandedKeys = ['-1']
|
},
|
},
|
// 监听
|
watch: {
|
factoryInfo:{
|
immediate:true,
|
deep:true,
|
handler(val){
|
this.$emit("loadList",val);
|
}
|
}
|
}
|
}
|
</script>
|
|
<style>
|
.replaceSearch {
|
color: #00090f;
|
font-weight: bold;
|
background-color: rgb(204, 204, 204);
|
}
|
/* .ant-select-disabled {
|
color: rgba(241, 16, 16, 0.25);
|
}
|
.ant-select-disabled .ant-select-selection {
|
background: #a76b6b;
|
} */
|
.ant-card-body .table-operator {
|
margin: 15px;
|
}
|
|
.anty-form-btn {
|
width: 100%;
|
text-align: center;
|
}
|
|
.anty-form-btn button {
|
margin: 0 5px;
|
}
|
|
.anty-node-layout .ant-layout-header {
|
padding-right: 0;
|
}
|
|
.header {
|
padding: 0 8px;
|
}
|
|
.header button {
|
margin: 0 3px;
|
}
|
|
.ant-modal-cust-warp {
|
height: 100%;
|
}
|
|
.ant-modal-cust-warp .ant-modal-body {
|
height: calc(100% - 110px) !important;
|
overflow-y: auto;
|
}
|
|
.ant-modal-cust-warp .ant-modal-content {
|
height: 90% !important;
|
overflow-y: hidden;
|
}
|
|
#app .desktop {
|
height: auto !important;
|
}
|
|
/** Button按钮间距 */
|
.ant-btn {
|
margin-left: 3px;
|
}
|
.ant-alert {
|
padding: 5px 15px 5px 37px;
|
}
|
.drawer-bootom-button {
|
position: absolute;
|
top: 1px;
|
/* padding: 10px 16px; */
|
text-align: left;
|
right: 0;
|
background: #fff;
|
border-radius: 0 0 2px 2px;
|
}
|
</style>
|