<template>
|
<a-card
|
:loading="cardLoading"
|
:bordered="false"
|
title="工厂模型"
|
style="height: 100%;"
|
>
|
<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="onClearSelected"
|
>取消</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>
|
<div>
|
<a-row :gutter="24" style="margin-top:15px">
|
<a-col
|
:md="12"
|
>
|
企业:
|
<a-select
|
style="width:82%"
|
placeholder="选择企业"
|
v-model="factoryInfo['enterpriseId']"
|
>
|
<a-select-option v-for="item of enterpriseList" :value="item.id" :key="item.id" >
|
<span :style="getEnterpriseOptionStyle(item.versionStatus)">{{item.name}} <a-icon type="tag" /> {{"V"+item.version+".0"+"("+getVersionStatusDetail(item.versionStatus)+")"}}</span>
|
</a-select-option>
|
</a-select>
|
</a-col>
|
<a-col
|
:md="12"
|
>
|
工厂版本:
|
<a-select
|
style="width:70%"
|
placeholder="选择工厂版本"
|
v-model="factoryInfo['version']"
|
>
|
<a-select-option v-for="item of versionList" :value="item.version" :key="item.version" >
|
<span :style="getEnterpriseOptionStyle(item.versionStatus)">{{"V"+item.version+".0"+"("+getVersionStatusDetail(item.versionStatus)+")"}}</span>
|
</a-select-option>
|
</a-select>
|
</a-col>
|
</a-row>
|
</div>
|
<a-tree
|
selectable
|
showLine
|
:showIcon="true"
|
:checkStrictly="checkStrictly"
|
:expandedKeys.sync="expandedKeys"
|
:selectedKeys="selectedKeys"
|
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
|
:treeData="treeDataSource"
|
:autoExpandParent="autoExpandParent"
|
@select="onSelect"
|
@expand="onExpand"
|
rowKey="id"
|
style="padding:20px"
|
>
|
<svg slot="total" t="1675649233812" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10262"><path d="M839.91992188 863.47460938c-19.42382813 0-35.15625-15.73242188-35.15625001-35.15625001V584.94921875c0-19.42382813-15.73242188-35.15625-35.15625-35.15625H556.6484375v272.19726563c0 19.42382813-15.73242188 35.15625-35.15625 35.15624999s-35.15625-15.73242188-35.15625-35.15625v-533.49609375c0-19.42382813-15.73242188-35.15625-35.15625-35.15625H254.04101562c-19.42382813 0-35.15625 15.73242188-35.15624999 35.15625v533.40820313c0 19.42382813-15.73242188 35.15625-35.15625 35.15625s-35.15625-15.73242188-35.15625-35.15625V288.49414062c0-58.18359375 47.28515625-105.46875 105.46874999-105.46874999h197.13867188c58.18359375 0 105.46875 47.28515625 105.46875 105.46875V479.48046875h212.95898438c58.18359375 0 105.46875 47.28515625 105.46874999 105.46875v243.36914063c0 19.42382813-15.73242188 35.15625-35.15625 35.15624999z" p-id="10263" fill="#8a8a8a"></path><path d="M382.53710937 414.96875h-59.94140624c-9.66796875 0-17.578125-7.91015625-17.578125-17.578125v-59.94140625c0-9.66796875 7.91015625-17.578125 17.578125-17.578125h59.94140625c9.66796875 0 17.578125 7.91015625 17.578125 17.578125v59.94140625c0 9.66796875-7.91015625 17.578125-17.578125 17.578125z m17.57812501 140.625v-59.94140625c0-9.66796875-7.91015625-17.578125-17.578125-17.578125h-59.94140625c-9.66796875 0-17.578125 7.91015625-17.578125 17.578125v59.94140625c0 9.66796875 7.91015625 17.578125 17.578125 17.578125h59.94140625c9.66796875 0 17.578125-7.91015625 17.578125-17.578125zM875.42773438 876.74609375H149.1875c-16.96289063 0-30.76171875-13.79882813-30.76171875-30.76171875s13.79882813-30.76171875 30.76171875-30.76171875h726.24023438c16.96289063 0 30.76171875 13.79882813 30.76171875 30.76171875s-13.79882813 30.76171875-30.76171875 30.76171875zM732.4296875 762.13671875H629.86132813c-16.96289063 0-30.76171875-13.79882813-30.76171876-30.76171875s13.79882813-30.76171875 30.76171875-30.76171875h102.48046876c16.96289063 0 30.76171875 13.79882813 30.76171875 30.76171875s-13.7109375 30.76171875-30.67382813 30.76171875z m0-105.46875H629.86132813c-16.96289063 0-30.76171875-13.79882813-30.76171876-30.76171875s13.79882813-30.76171875 30.76171875-30.76171875h102.48046876c16.96289063 0 30.76171875 13.79882813 30.76171875 30.76171875s-13.7109375 30.76171875-30.67382813 30.76171875z" p-id="10264" fill="#8a8a8a"></path></svg>
|
</a-tree>
|
</a-spin>
|
</a-card>
|
</template>
|
<script>
|
import { getAction } from '@/api/manage'
|
import { mixinDevice } from '@/utils/mixin'
|
import Tooltip from 'ant-design-vue/es/tooltip'
|
import JEllipsis from '@/components/jeecg/JEllipsis'
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
|
export default {
|
name: 'WorkCenterTree',
|
components: {
|
Tooltip,
|
JEllipsis,
|
JeecgListMixin,
|
mixinDevice
|
},
|
data() {
|
return {
|
disableMixinCreated:true,
|
userId: '',
|
parentId:'',
|
enterpriseList:[],
|
factoryInfo:{},
|
versionList:[],
|
searchInput: '',
|
cardLoading: false,
|
loading: false,
|
treeDataSource: [],
|
selectedKeys: [],
|
expandedKeys: [],
|
url: {
|
getUsableEnterpriseList:'/base/enterprise/getUsableList',
|
loadTree: '/base/factoryModel/loadTree', //根据企业id查工厂树
|
getEnterpriseList:"/base/enterprise/mapList",
|
getDepartId:'/base/workCenterUser/getDeaprtId',
|
getVersionList: "/base/workCenter/getFactoryVersionList",
|
getFactoryInfo:"/base/factoryModel/getFactoryInfo",
|
},
|
searchValue: '',
|
dataList: [],
|
autoExpandParent: true,
|
checkStrictly: true,
|
allTreeKeys: [],
|
currSelected: {},
|
hiding: false,
|
}
|
},
|
created() {
|
this.cardLoading=true;
|
this.getVersionList();
|
this.getEnterpriseList();
|
this.getFactoryInfo();
|
},
|
methods: {
|
getCurrSelectedTitle() {
|
return !this.currSelected.title ? '' : this.currSelected.title
|
},
|
onClearSelected() {
|
this.currSelected = {};
|
this.selectedKeys = [];
|
},
|
onSelect(selectedKeys, e) {
|
let record = e.node.dataRef;
|
this.currSelected = Object.assign({}, record);
|
this.selectedKeys = selectedKeys;
|
this.parentId=selectedKeys[0];
|
console.log(record.children.length==0)
|
this.$emit("getAddDisabled",record.children.length==0&&record.key!=this.factoryInfo.enterpriseId)
|
},
|
onExpand(expandedKeys) {
|
this.expandedKeys = expandedKeys;
|
this.autoExpandParent = false
|
},
|
queryTreeData(data) {
|
this.loading = true
|
this.cardLoading = true
|
getAction(this.url.loadTree,data).then((res) => {
|
if (res.success) {
|
this.dataList = [];
|
this.allTreeKeys = [];
|
this.generateList(res.result);
|
this.expandAll();
|
this.selectedKeys=[res.result[0].key];
|
this.currSelected = res.result[0];
|
this.parentId = res.result[0].key
|
} else {
|
this.$message.warn(res.message)
|
}
|
}).finally(res=>{
|
this.loading = false;
|
this.cardLoading = false;
|
});
|
},
|
getEnterpriseList(){
|
getAction(this.url.getEnterpriseList).then(res=>{
|
if(res.success){
|
this.enterpriseList = res.result
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
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) {
|
const list = data;
|
for (let i = 0; i < list.length; i++) {
|
const key = list[i].key
|
list[i].type = 'total';
|
list[i].scopedSlots = {
|
switcherIcon:"total"
|
};
|
this.allTreeKeys.push(key);
|
if (list[i].children) {
|
this.generateList(list[i].children)
|
}
|
}
|
this.treeDataSource=list
|
},
|
expandAll() {
|
this.expandedKeys = this.allTreeKeys
|
},
|
closeAll() {
|
this.expandedKeys = ['-1']
|
},
|
|
refreshTree() {
|
this.queryTreeData(this.factoryInfo)
|
},
|
getVersionStatusDetail(data){
|
if(data=='0'){
|
return '新建'
|
}else if(data=='1'){
|
return '编辑'
|
}else if(data=='2'){
|
return '生效'
|
}else if(data=='3'){
|
return '失效'
|
}else if(data=='4'){
|
return '待生效'
|
}
|
},
|
getEnterpriseOptionStyle(data){
|
if(data=='0'||data=='1'){
|
return {
|
color:"darkOrange !important",
|
}
|
}else if(data=='2'){
|
return {
|
color:"green !important",
|
}
|
}else if(data=='3'){
|
return {
|
color:"red !important",
|
}
|
}else{
|
return {
|
color:"skyblue !important",
|
}
|
}
|
},
|
getVersionList(){
|
getAction(this.url.getVersionList).then(res=>{
|
if(res.success){
|
this.versionList = res.result;
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
getFactoryInfo(){
|
getAction(this.url.getFactoryInfo).then(res=>{
|
if(res.success){
|
this.factoryInfo = res.result;
|
}
|
else{
|
this.$message.error(res.message);
|
}
|
})
|
},
|
},
|
watch: {
|
parentId:{
|
handler(val) {
|
this.$emit('getParentId',val);
|
}
|
},
|
factoryInfo:{
|
deep:true,
|
handler(val) {
|
this.queryTreeData({enterpriseId:val.enterpriseId,version:val.version});
|
this.$emit('getFactoryInfo',val);
|
}
|
},
|
'factoryInfo.enterpriseId'(newval,oldval){
|
for(var i=0;i<this.enterpriseList.length;i++ ){
|
if(this.enterpriseList[i].id==newval&&this.enterpriseList[i].versionStatus=='2'){
|
this.$emit('getUpdatePermission',true);
|
}else if(this.enterpriseList[i].id==newval){
|
this.$emit('getUpdatePermission',false)
|
}
|
}
|
},
|
'factoryInfo.version'(newval,oldval){
|
for(var i=0;i<this.versionList.length;i++ ){
|
if(this.versionList[i].version==newval&&this.versionList[i].versionStatus=='2'){
|
this.$emit('getFactoryStatus',true);
|
}else if(this.versionList[i].version==newval){
|
this.$emit('getFactoryStatus',false)
|
}
|
}
|
}
|
}
|
}
|
</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>
|