From 3ecb68c427a627ad8e90d8c555655e7724be2d96 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期五, 06 九月 2024 11:06:12 +0800 Subject: [PATCH] 修改 --- web/src/views/modules/basicInfo/ProductModelTree.vue | 91 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 69 insertions(+), 22 deletions(-) diff --git a/web/src/views/modules/basicInfo/ProductModelTree.vue b/web/src/views/modules/basicInfo/ProductModelTree.vue index 79e571f..7069d48 100644 --- a/web/src/views/modules/basicInfo/ProductModelTree.vue +++ b/web/src/views/modules/basicInfo/ProductModelTree.vue @@ -1,13 +1,15 @@ <template> <div class="product-tree-container"> - <el-input - placeholder="杈撳叆鍚嶇О杩涜杩囨护" - style="width: 60%" - v-model="filterText" - size="small" - clearable - ></el-input> - <el-button type="primary" @click="add()" style="margin: 10px 0 0 10px;padding: 9px 18px !important;">鏂板</el-button> + <!-- <el-input + placeholder="杈撳叆鍚嶇О杩涜杩囨护" + style="width: 60%" + v-model="filterText" + size="small" + clearable + ></el-input>--> + <el-button v-if="isShow" type="primary" @click="add()" + style="margin: 10px 0 0 10px;padding: 9px 18px !important;">鏂板鍨嬪彿 + </el-button> <el-divider></el-divider> <el-tree style="height: 90%;overflow: auto" @@ -15,6 +17,8 @@ :data="productList" :props="defaultProps" default-expand-all + node-key="id" + :current-node-key="defaultId" :expand-on-click-node="false" :highlight-current="true" @node-click="handleNodeClick" @@ -30,38 +34,81 @@ export default { name: 'ProductModelTree', - props: {}, + props: { + showXdy: { + type: Boolean, + default: true + }, + isShow: { + type: Boolean, + default: true + }, + basic: { + type: Number, + default: 1 + }, + productId: { + type: Number, + default: null + }, + }, data() { return { filterText: '', productList: [], + defaultId: '', defaultProps: { children: 'children', label: 'name' } } - }, + } + , watch: { filterText(val) { this.$refs.tree.filter(val) } - }, + } + , components: { AddOrUpdate - }, - mounted() { - this.getProductList() - }, + } + , + /* mounted() { + this.getProductList() + },*/ methods: { // 鑾峰彇绯荤粺鍒楄〃 async getProductList() { - let res = await this.$http.get('/basicInfo/XhProductModel/tree') + let params = { + showXdy: this.showXdy, + ztShow: this.basic, + productId: this.productId + } + let res = await this.$http.get('/basicInfo/XhProductModel/tree', {params: params}) this.productList = res.data - console.log(res.data,'async getProductList()') + if (this.basic === '3') { + if (this.productList && this.productList[0].children) { + this.defaultId = this.productList[0].children[0].id + this.$nextTick(() => { + this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉� + }); + this.$emit('on-default', this.defaultId) + } + } else{ + if (this.productList[0].id) { + this.defaultId = this.productList[0].id + this.$nextTick(() => { + this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉� + }); + this.$emit('on-default', this.defaultId) + } + } + console.log(res.data, 'async getProductList()') }, add() { - this.$refs.AddOrUpdate.$refs.dialog.init(null,{id: null, type: 'tree'}) + this.$refs.AddOrUpdate.$refs.dialog.init(null, {id: null, type: 'xh'}) }, filterNode(value, data) { if (!value) return true @@ -69,12 +116,12 @@ }, handleNodeClick(data) { this.$emit('on-selected', data) - } + }, } } </script> <style> -.product-tree-container{ - height: 100%; -} + .product-tree-container { + height: 100%; + } </style> -- Gitblit v1.9.1