Commit 9e0461c0 authored by renjintao's avatar renjintao

tree

parent 00540e2a
...@@ -43,7 +43,15 @@ export default { ...@@ -43,7 +43,15 @@ export default {
default: 0 default: 0
} }
}, },
mounted() {}, mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.divHeight = window.innerHeight - 180 + "px";
})();
};
},
created() { created() {
this.loadTree() this.loadTree()
var theight = window.innerHeight - 180 + 'px' var theight = window.innerHeight - 180 + 'px'
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<Row> <Row>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('projectId')" prop="projectId"> <FormItem :label="l('projectId')" prop="projectId">
<InputNumber v-model="entity.projectId" style="width:240px"></InputNumber> <InputNumber v-model="entity.projectId" :min="1" style="width:240px"></InputNumber>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
...@@ -50,7 +50,9 @@ export default { ...@@ -50,7 +50,9 @@ export default {
data() { data() {
return { return {
disabled: false, disabled: false,
entity: {}, entity: {
projectId:1
},
rules: { rules: {
name: [{ required: true, message: '必填', trigger: 'blur' }] name: [{ required: true, message: '必填', trigger: 'blur' }]
}, },
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<Row> <Row>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('projectId')" prop="projectId"> <FormItem :label="l('projectId')" prop="projectId">
<InputNumber v-model="entity.projectId" style="width:240px"></InputNumber> <InputNumber v-model="entity.projectId" :min="1" style="width:240px"></InputNumber>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
:action="action" :action="action"
:conditions="easySearch" :conditions="easySearch"
style="margin-top: 45px;" style="margin-top: 45px;"
:height="tdHeight"
> >
<template slot="easySearch"> <template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline> <Form ref="formInline" :model="easySearch" inline>
...@@ -103,6 +104,7 @@ export default { ...@@ -103,6 +104,7 @@ export default {
editModal: false, editModal: false,
detailModal: false, detailModal: false,
deletelModal: false, deletelModal: false,
tdHeight: "",
curId: 0, curId: 0,
curId1: 0, curId1: 0,
curShopName: '', curShopName: '',
...@@ -250,8 +252,17 @@ export default { ...@@ -250,8 +252,17 @@ export default {
}, },
mounted() { mounted() {
this.loadData() this.loadData()
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tdHeight = window.screenHeight - 265;
})();
};
},
created() {
this.tdHeight = window.innerHeight - 265;
}, },
created() {},
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch('loadDictionary') // 加载数据字典 await store.dispatch('loadDictionary') // 加载数据字典
}, },
...@@ -352,6 +363,6 @@ export default { ...@@ -352,6 +363,6 @@ export default {
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.full { .full {
margin-top: 0; margin-top:0;
} }
</style> </style>
\ No newline at end of file
...@@ -16,21 +16,22 @@ ...@@ -16,21 +16,22 @@
</Button> </Button>
</ButtonGroup> </ButtonGroup>
</h3> </h3>
<div class="tree"> <div class="tree" :style="{height:divHeight}">
<Tree ref="tree" :data="tree" @on-select-change="change" :render="renderContent" /> <Tree ref="tree" :data="tree" @on-select-change="change" :render="renderContent" />
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import Api from './api' import Api from "./api";
export default { export default {
name: 'shopTreeLeft', name: "shopTreeLeft",
data() { data() {
return { return {
expand: true, expand: true,
ids: [], ids: [],
tree: [] tree: [],
} divHeight: ""
};
}, },
props: { props: {
CId: { CId: {
...@@ -38,57 +39,67 @@ export default { ...@@ -38,57 +39,67 @@ export default {
default: 0 default: 0
} }
}, },
mounted() {}, mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.divHeight = window.innerHeight - 240 + "px";
})();
};
},
created() { created() {
this.loadTree() this.loadTree();
var theight = window.innerHeight - 240 + "px";
this.divHeight = theight;
}, },
methods: { methods: {
toggle() { toggle() {
this.expand = !this.expand this.expand = !this.expand;
this.getTrees(this.tree) this.getTrees(this.tree);
//this.loadTree() //this.loadTree()
}, },
async loadTree() { async loadTree() {
//alert(this.CId) //alert(this.CId)
Api.getshoptree({ Id: this.CId }).then((r) => { Api.getshoptree({ Id: this.CId }).then(r => {
if (r.success) { if (r.success) {
if (r.result.length > 0) { if (r.result.length > 0) {
this.tree = r.result this.tree = r.result;
this.change1(this.tree) this.change1(this.tree);
} else { } else {
this.tree = [ (this.tree = [
{ title: '暂无组织信息', value: -100, expand: true, children: [] } { title: "暂无组织信息", value: -100, expand: true, children: [] }
], ]),
this.$emit('storeIds', [-100]) this.$emit("storeIds", [-100]);
this.$emit('treeData', r.result) this.$emit("treeData", r.result);
} }
} }
}) });
}, },
//重构左侧树 //重构左侧树
getTrees(trees) { getTrees(trees) {
var expand = this.expand var expand = this.expand;
trees.forEach((data, index) => { trees.forEach((data, index) => {
var that = this var that = this;
data.expand = expand data.expand = expand;
if (data.children.length > 0) { if (data.children.length > 0) {
this.getTrees(data.children) this.getTrees(data.children);
} }
}) });
return trees return trees;
}, },
renderContent(h, { root, node, data }) { renderContent(h, { root, node, data }) {
return h( return h(
'span', "span",
{ {
style: { style: {
color: '#000', //根据选中状态设置样式 color: "#000", //根据选中状态设置样式
cursor: 'pointer', cursor: "pointer",
background: node.node.selected ? '#AAD8D4' : '#ffffff', background: node.node.selected ? "#AAD8D4" : "#ffffff",
paddingLeft: '10px', paddingLeft: "10px",
paddingRight: '10px', paddingRight: "10px",
paddingTop: '3px', paddingTop: "3px",
paddingBottom: '3px' paddingBottom: "3px"
}, },
on: { on: {
// click: () => { // click: () => {
...@@ -99,47 +110,47 @@ export default { ...@@ -99,47 +110,47 @@ export default {
} }
}, },
data.title data.title
) );
}, },
//得到此树节点下所有是产品的Id //得到此树节点下所有是产品的Id
getAllIds(trees) { getAllIds(trees) {
trees.forEach((data, index) => { trees.forEach((data, index) => {
var that = this var that = this;
this.ids.push(data.value) this.ids.push(data.value);
if (data.children.length > 0) { if (data.children.length > 0) {
this.getAllIds(data.children) this.getAllIds(data.children);
} }
}) });
}, },
change(value) { change(value) {
if (value.length > 0) { if (value.length > 0) {
this.ids = [] this.ids = [];
this.getAllIds(value) this.getAllIds(value);
if (this.ids.length > 0) { if (this.ids.length > 0) {
this.$emit('storeIds', this.ids) this.$emit("storeIds", this.ids);
//this.easySearch.storeId.value = this.ids //this.easySearch.storeId.value = this.ids
} else { } else {
this.$emit('storeIds', [-1]) this.$emit("storeIds", [-1]);
} }
} else { } else {
this.$emit('storeIds', [-1]) this.$emit("storeIds", [-1]);
} }
this.$emit('treeData', value) this.$emit("treeData", value);
}, },
change1(value) { change1(value) {
if (value.length > 0) { if (value.length > 0) {
this.ids = [] this.ids = [];
this.getAllIds(value) this.getAllIds(value);
if (this.ids.length > 0) { if (this.ids.length > 0) {
this.$emit('storeIds', this.ids) this.$emit("storeIds", this.ids);
} else { } else {
this.$emit('storeIds', [-1]) this.$emit("storeIds", [-1]);
} }
} else { } else {
this.$emit('storeIds', [-1]) this.$emit("storeIds", [-1]);
} }
} }
} }
} };
</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