From f8c827392607967121c5f9a57894645f18ad5953 Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期二, 15 四月 2025 18:14:13 +0800 Subject: [PATCH] 代码初始化 --- admin/src/components/business/OperaCategoryWindow.vue | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/admin/src/components/business/OperaCategoryWindow.vue b/admin/src/components/business/OperaCategoryWindow.vue index 829f064..252600a 100644 --- a/admin/src/components/business/OperaCategoryWindow.vue +++ b/admin/src/components/business/OperaCategoryWindow.vue @@ -10,12 +10,21 @@ <el-input v-model="form.name" placeholder="璇疯緭鍏ュ悕绉�" v-trim/> </el-form-item> <el-form-item label="閫夋嫨鐖剁骇" prop="parentId"> - <el-cascader v-model="form.categoryList" :options="categorys" @change="handleChangeCategory" :show-all-levels="false" +<!-- <el-cascader v-model="form.categoryList" :options="categorys" @change="handleChangeCategory" :show-all-levels="false" clearable filterable :props="categoryprops" > <template slot-scope="{ node, data }"> - <span>{{ data.name }}</span> <!-- 鑷畾涔夋樉绀哄唴瀹� --> + <span>{{ data.name }}</span> <!– 鑷畾涔夋樉绀哄唴瀹� –> </template> - </el-cascader> + </el-cascader>--> + <treeselect + v-model="form.parentId" + placeholder="璇烽�夋嫨" + :options="categorys" + :normalizer="normalizeOptions" + :default-expand-level="1" + noChildrenText="娌℃湁瀛愰�夐」" + noOptionsText="娌℃湁鍙�夐」" + noResultsText="娌℃湁鍖归厤鐨勭粨鏋�" /> </el-form-item> <el-form-item label="鎺掑簭鐮�" prop="sortnum"> <el-input v-model="form.sortnum" type="number" placeholder="璇疯緭鍏ユ帓搴忕爜锛堝崌搴忥級" v-trim/> @@ -66,6 +75,17 @@ }) }, methods: { + normalizeOptions (node) { + if (node.childList && !node.childList.length) { + // 鍘绘帀children=[]鐨刢hildren灞炴�� + delete node.childList + } + return { + id: node.id, + label: node.name, + children: node.childList + } + }, handleChangeCategory (value) { this.form.parentId = null if (this.form.categoryList && this.form.categoryList.length >= 1) { @@ -89,10 +109,10 @@ } return data }, - open (title, target, categorys, categoryType, parentIdPath) { + open (title, target, categorys, categoryType, parentId) { this.title = title - this.categorys = categorys || [] - this.categorys = this.getTreeData(this.categorys) + this.categorys = JSON.parse(JSON.stringify(categorys||[])); + // this.categorys = this.getTreeData(this.categorys) console.log(this.categorys) this.visible = true this.form = { @@ -102,7 +122,7 @@ remark: '', categoryList: [], sortnum: null, - parentId: null + parentId: parentId } this.form.type = categoryType // 鏂板缓 @@ -112,7 +132,7 @@ this.$refs.form.resetFields() this.form[this.configData['field.id']] = null this.form.categoryList = [] - if (parentIdPath && parentIdPath != null) { + /* if (parentIdPath && parentIdPath != null) { var array = parentIdPath.split('/') array.forEach(item => { if (item && item != null && item !== '') { @@ -120,7 +140,7 @@ } }) that.handleChangeCategory() - } + } */ }) return } @@ -129,7 +149,7 @@ for (const key in this.form) { this.form[key] = target[key] } - this.form.categoryList = [] + /* this.form.categoryList = [] if (target.parentId && target.idParentPath) { var array = target.idParentPath.split('/') array.forEach(item => { @@ -137,7 +157,7 @@ that.form.categoryList.push(parseInt(item)) } }) - } + } */ }) } } -- Gitblit v1.9.3