Commit 7d0b08b0 authored by renjintao's avatar renjintao

productTree

parent fa7ccddd
<template> <template>
<div class="flex fd tree-menu"> <div class="flex fd tree-menu">
<h3> <h3>
产品结构 产品结构
<div class="fr mr10 mt10"> <div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small"> <ButtonGroup class="fr" size="small">
<Button <Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree"></Button> <Button icon="md-refresh" title="刷新" @click="loadTree"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button> <Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup> </ButtonGroup>
...@@ -22,7 +18,7 @@ ...@@ -22,7 +18,7 @@
<Tree :data="data" :render="renderContent" ref="tree" @on-select-change="change"></Tree> <Tree :data="data" :render="renderContent" ref="tree" @on-select-change="change"></Tree>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
...@@ -44,11 +40,12 @@ export default { ...@@ -44,11 +40,12 @@ export default {
.get(`${technologyUrl}productlevel/getproducttreenew`) .get(`${technologyUrl}productlevel/getproducttreenew`)
.then(r => { .then(r => {
setTree(r.result); setTree(r.result);
function setTree(data) { function setTree(data) {
data.map(u => { data.map(u => {
u.title = u.name; u.title = u.name;
u.value = u.id; u.value = u.id;
// u.expand = true; u.expand = true;
// u.selected = false; // u.selected = false;
// u.checked = false; // u.checked = false;
if (u.children) { if (u.children) {
...@@ -63,7 +60,11 @@ export default { ...@@ -63,7 +60,11 @@ export default {
toggle() { toggle() {
this.expand = !this.expand; this.expand = !this.expand;
}, },
renderContent(h, { root, node, data }) { renderContent(h, {
root,
node,
data
}) {
let type = "md-folder"; let type = "md-folder";
if (data.isProduct != 0) { if (data.isProduct != 0) {
type = "ios-image"; type = "ios-image";
...@@ -78,8 +79,7 @@ export default { ...@@ -78,8 +79,7 @@ export default {
} }
}), }),
h( h(
"span", "span", {
{
style: { style: {
color: data.isProduct == 0 ? "#000" : "rgba(38, 128, 235, 1)" color: data.isProduct == 0 ? "#000" : "rgba(38, 128, 235, 1)"
} }
...@@ -98,6 +98,7 @@ export default { ...@@ -98,6 +98,7 @@ export default {
productIds.push(b.value); productIds.push(b.value);
if (b.children) { if (b.children) {
addId(b.children); addId(b.children);
function addId(data) { function addId(data) {
data.map(u => { data.map(u => {
if (u.bomId !== 0) { if (u.bomId !== 0) {
...@@ -122,6 +123,7 @@ export default { ...@@ -122,6 +123,7 @@ export default {
let expand = this.expand; let expand = this.expand;
let result = []; let result = [];
search(this.keys, items); search(this.keys, items);
function search(keys, data) { function search(keys, data) {
data.map(u => { data.map(u => {
if (keys.length < 2) { if (keys.length < 2) {
...@@ -145,6 +147,7 @@ export default { ...@@ -145,6 +147,7 @@ export default {
<style lang="less"> <style lang="less">
@import "../../assets/css/custom.less"; @import "../../assets/css/custom.less";
.tree-menu { .tree-menu {
h3 { h3 {
height: 50px; height: 50px;
...@@ -157,16 +160,19 @@ export default { ...@@ -157,16 +160,19 @@ export default {
opacity: 1; opacity: 1;
padding-left: 10px; padding-left: 10px;
} }
.search { .search {
height: 50px; height: 50px;
padding: 5px 10px; padding: 5px 10px;
} }
.fg { .fg {
flex: none; flex: none;
// height:0; // height:0;
overflow: auto; overflow: auto;
padding-left: 10px; padding-left: 10px;
} }
.tree { .tree {
height: calc(100vh - 215px); height: calc(100vh - 215px);
overflow: auto; overflow: auto;
......
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