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/OperaCategoryDcaProblemWindow.vue | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 39 insertions(+), 12 deletions(-) diff --git a/admin/src/components/business/OperaCategoryDcaProblemWindow.vue b/admin/src/components/business/OperaCategoryDcaProblemWindow.vue index bfec319..537ad98 100644 --- a/admin/src/components/business/OperaCategoryDcaProblemWindow.vue +++ b/admin/src/components/business/OperaCategoryDcaProblemWindow.vue @@ -10,12 +10,23 @@ <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" + <treeselect + v-model="form.parentId" + placeholder="璇烽�夋嫨" + :options="categorys" + :normalizer="normalizeOptions" + :default-expand-level="1" + noChildrenText="娌℃湁瀛愰�夐」" + noOptionsText="娌℃湁鍙�夐」" + noResultsText="娌℃湁鍖归厤鐨勭粨鏋�" + @select="node => treeHandleSelect(node)" + /> +<!-- <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>--> </el-form-item> <el-form-item label="鎺掑簭鐮�" prop="sortnum"> <el-input v-model="form.sortnum" placeholder="璇疯緭鍏ユ帓搴忕爜锛堝崌搴忥級" v-trim/> @@ -66,6 +77,23 @@ }) }, methods: { + normalizeOptions (node) { + if (node.childList && !node.childList.length) { + // 鍘绘帀children=[]鐨刢hildren灞炴�� + delete node.childList + } + return { + id: node.id, + label: node.name, + children: node.childList + } + }, + treeHandleSelect (node) { + if (this.form.id != null && node.id && this.form.id === node.id) { + this.$tip.error('瀵逛笉璧凤紝鐖剁骇涓嶈兘璁剧疆涓鸿嚜韬紒') + this.form.parentId = null + } + }, handleChangeCategory (value) { this.form.parentId = null if (this.form.categoryList && this.form.categoryList.length >= 1) { @@ -94,10 +122,9 @@ } 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||[])); console.log(this.categorys) this.visible = true this.form = { @@ -107,7 +134,7 @@ categoryList: [], sortnum: null, remark: '', - parentId: null + parentId: parentId } this.form.type = categoryType // 鏂板缓 @@ -116,8 +143,8 @@ this.$nextTick(() => { this.$refs.form.resetFields() this.form[this.configData['field.id']] = null - this.form.categoryList = [] - if (parentIdPath && parentIdPath != null) { + // this.form.categoryList = [] + /*if (parentIdPath && parentIdPath != null) { var array = parentIdPath.split('/') array.forEach(item => { if (item && item != null && item !== '') { @@ -125,7 +152,7 @@ } }) that.handleChangeCategory() - } + }*/ }) return } @@ -134,7 +161,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 => { @@ -142,7 +169,7 @@ that.form.categoryList.push(parseInt(item)) } }) - } + }*/ }) } } -- Gitblit v1.9.3