| | |
| | | |
| | | <div style="width: 26%"> |
| | | <a-tabs> |
| | | <a-tab-pane tab="设备列表"> |
| | | <a-tab-pane tab="产品列表"> |
| | | <a-spin :spinning="spinning"> |
| | | <div style="display: flex;flex-direction: column;"> |
| | | <div style="display: flex"> |
| | | <a-input placeholder="输入关键字进行搜索" allowClear v-model="searchInput" |
| | | @change="handleSearchInputChange"/> |
| | | <a-button type="primary" @click="isExpandAllTreeNode=!isExpandAllTreeNode" style="margin: 0 8px"> |
| | | 展开/折叠 |
| | | <a-button type="primary" @click="expandCurrentActiveTreeNodeSon" style="margin: 0 8px" |
| | | :disabled="!currentActiveTreeNode.children||(currentActiveTreeNode.children&¤tActiveTreeNode.children.length===0)"> |
| | | <span v-if="!expandedKeys.includes(currentActiveTreeNode.id)">展开</span> |
| | | <span v-else>折叠</span> |
| | | 当前节点 |
| | | </a-button> |
| | | </div> |
| | | |
| | |
| | | :autoExpandParent="autoExpandParent" @select="handleTreeNodeSelect" checkStrictly |
| | | :treeData="treeDataSource" @check="handleTreeNodeCheck" @expand="handleTreeNodeExpand"> |
| | | <template slot="title" slot-scope="{ label, parentId, entity, key:treeKey,type}"> |
| | | <!--nc文件层级--> |
| | | <a-tooltip :title="label" v-if="type==99"> |
| | | <span v-if="label.indexOf(searchValue) > -1"> |
| | | {{ label.substr(0, label.indexOf(searchValue)) }} |
| | |
| | | </span> |
| | | <span v-else>{{ label }}</span> |
| | | </a-tooltip> |
| | | |
| | | <!--非文件层级--> |
| | | <template v-else> |
| | | <span v-if="label.indexOf(searchValue) > -1"> |
| | | {{ label.substr(0, label.indexOf(searchValue)) }} |
| | |
| | | autoExpandParent: true, |
| | | isExpandAllTreeNode: false, |
| | | confirmLoading: false, |
| | | currentActiveTreeNode: {}, |
| | | date: [], |
| | | url: { |
| | | list: '/nc/doc/find/list' |
| | |
| | | |
| | | /** |
| | | * 树节点复选框选中时触发 |
| | | * @param selectedKeys 选中节点key |
| | | * @param checkedObj 选中节点对象 |
| | | * @param {node} node 节点对象 |
| | | */ |
| | | handleTreeNodeCheck(checkedObj, { node }) { |
| | | console.log('checkedObj', checkedObj) |
| | | console.log('node', node.dataRef) |
| | | let record = node.dataRef |
| | | if (record.type !== 99) return |
| | | this.checkedKeys = checkedObj.checked.slice(-1) |
| | |
| | | * @param {node} node 节点对象 |
| | | */ |
| | | handleTreeNodeSelect(selectedKeys, { node }) { |
| | | const record = node.dataRef |
| | | node.$el.childNodes[1].click() |
| | | if (this.currentActiveTreeNode.key === record.key) { |
| | | this.currentActiveTreeNode = {} |
| | | return |
| | | } |
| | | this.currentActiveTreeNode = Object.assign({}, record) |
| | | }, |
| | | |
| | | // 展开当前选中树节点下所有子项 |
| | | expandCurrentActiveTreeNodeSon() { |
| | | const activeNode = this.currentActiveTreeNode |
| | | const sonKeys = this.getCurrentTreeNodeSonKeys(activeNode) |
| | | if (!this.expandedKeys.includes(activeNode.id)) { |
| | | this.expandedKeys = [...this.expandedKeys, this.currentActiveTreeNode.id, ...sonKeys] |
| | | } else { |
| | | this.expandedKeys = this.expandedKeys.filter(expandKey => !sonKeys.includes(expandKey) && expandKey !== activeNode.id) |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 递归获取选中节点所有子节点key |
| | | * @param treeNode 树节点 |
| | | */ |
| | | getCurrentTreeNodeSonKeys(treeNode) { |
| | | let sonKeys = [] |
| | | if (treeNode.children && treeNode.children.length > 0) { |
| | | for (let index = 0; index < treeNode.children.length; index++) { |
| | | const node = treeNode.children[index] |
| | | sonKeys.push(node.id) |
| | | sonKeys = [...sonKeys, ...this.getCurrentTreeNodeSonKeys(node)] |
| | | } |
| | | } |
| | | return sonKeys |
| | | }, |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 递归获得所有树节点key |
| | | * @param data 设备树数据 |
| | | * @param data 树数据 |
| | | */ |
| | | generateList(data) { |
| | | for (let i = 0; i < data.length; i++) { |
| | |
| | | this.searchInput = this.searchValue = '' |
| | | this.expandedKeys = [] |
| | | this.selectedRowKeys = [] |
| | | this.selectionRows = {} |
| | | this.selectionRows = this.currentActiveTreeNode = {} |
| | | this.checkedKeys = [] |
| | | this.filters = {} |
| | | this.isorter = Object.assign({}, this.defaultSorter) |