From 8bf8713da9f9ebf844af7ceefd462c2966070128 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期一, 15 七月 2024 08:34:37 +0800 Subject: [PATCH] 修改 --- web/src/views/modules/basicInfo/ProductModelTree.vue | 37 ++++++++++++++++++++++++++----------- 1 files changed, 26 insertions(+), 11 deletions(-) diff --git a/web/src/views/modules/basicInfo/ProductModelTree.vue b/web/src/views/modules/basicInfo/ProductModelTree.vue index a8edb11..5949b1d 100644 --- a/web/src/views/modules/basicInfo/ProductModelTree.vue +++ b/web/src/views/modules/basicInfo/ProductModelTree.vue @@ -7,7 +7,7 @@ size="small" clearable ></el-input> - <el-button type="primary" @click="add()" style="margin: 10px 0 0 10px;padding: 9px 18px !important;">鏂板</el-button> + <el-button 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 +15,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" @@ -35,12 +37,17 @@ type: Boolean, default: true }, + basic: { + type: Number, + default: 1 + }, }, data() { return { filterText: '', productList: [], + defaultId: '', defaultProps: { children: 'children', label: 'name' @@ -60,30 +67,38 @@ , mounted() { this.getProductList() - } - , + }, methods: { // 鑾峰彇绯荤粺鍒楄〃 async getProductList() { let params = { - showXdy:this.showXdy + showXdy: this.showXdy, + ztShow: this.basic } - let res = await this.$http.get('/basicInfo/XhProductModel/tree',{params:params}) + let res = await this.$http.get('/basicInfo/XhProductModel/tree', {params: params}) this.productList = res.data + if (this.basic) { + if (this.productList && this.productList[0].children) { + this.defaultId = this.productList[0].children[0].id + console.log(this.defaultId, 'this.defaultID') + 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 return data.name.indexOf(value) !== -1 }, handleNodeClick(data) { this.$emit('on-selected', data) - } + }, } } </script> -- Gitblit v1.9.1