@@ -84,23 +103,48 @@
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
+ treeOption:{
+ addBtn: false,
+ editBtn: false,
+ delBtn:false,
+ filter:false,
+ props:{ label: 'category_name', value: 'category_id', children:'sub' }
+ },
}
},
created() {
this.fetchData()
},
mounted() {
- // 在组件挂载后立即获取焦点
- this.$nextTick(() => {
- // 获取 el-cascader 的输入框元素
- const inputEl = this.$refs.cascader.$el.querySelector('.el-input__inner');
- // 设置焦点
- if (inputEl) {
- inputEl.click();
- }
- });
+ // 挂载后强制关闭下拉,且监听防止弹出
+ this.$nextTick(() => {
+ const cascader = this.$refs.cascaderRef;
+ if (cascader) {
+ // 禁用下拉显示
+ cascader.dropdownVisible = false;
+ // 重写下拉显示方法,直接返回false
+ cascader.showPopper = () => false;
+ }
+ });
},
methods: {
+ //当搜索框失去焦点
+ searchOutFocus(){
+ this.$refs.cascader.destroyPopper()
+ this.$refs.cascader.dropDownVisible = false
+ },
+ //当搜索框成为焦点
+ searchOnFocus(){
+ this.$refs.cascader.destroyPopper()
+ this.$refs.cascader.dropDownVisible = false
+ this.$refs.tree.filterValue = ''
+ this.$refs.cascader.inputValue = ''
+ },
+ //当节点被点击
+ treeNodeClick(row){
+ this.category_id = row.category_id
+ console.log(row.category_id)
+ },
showEdit(row) {
const sub = row.sub
if (sub && sub.length > 0) return false
@@ -115,16 +159,13 @@
const { data } = await categoryTree()
this.list = this.tree(data);
-
this.listLoading = false
},
- async onCategoryChange(row) {
- if (row.length > 0) {
- this.category_id = row[row.length-1];
- } else {
- this.category_id = null;
- }
+ async onCategoryChange() {
+ this.$refs.cascader.destroyPopper()
+ this.$refs.cascader.dropDownVisible = false
+ this.$refs.tree.filterValue = this.$refs.cascader.inputValue
},
tree(data) {
@@ -162,9 +203,9 @@
},
submit() {
const category = this.findTree(this.list, this.category_id)
-
- if (category != null) {
- this.handleEdit(category)
+ console.log(this.category_id)
+ if (this.category_id != null) {
+ this.handleEdit(this.category_id)
} else {
this.$baseMessage("请选择商品分类", 'error')
}
@@ -180,9 +221,8 @@
align-items: center; /* 垂直居中 */
height: 80vh; /* 100%视窗高度 */
}
-
.centered {
/* 可以添加其他样式 */
}
-
+
\ No newline at end of file
From 2a825e765f1407298c598c8eb42718d598f0bf8f Mon Sep 17 00:00:00 2001
From: hufflzp <1395188856@qq.com>
Date: Mon, 12 Jan 2026 16:49:07 +0800
Subject: [PATCH 4/4] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E5=95=86?=
=?UTF-8?q?=E5=93=81=E5=9B=BE=E7=89=87=E6=96=B0=E5=A2=9E=E5=9B=BE=E5=BA=93?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/product/goodsImg/goodsImgs.vue | 17 +-
src/views/product/goodsImg/imgAdd.vue | 193 +++++++++++++++++++++++
2 files changed, 209 insertions(+), 1 deletion(-)
create mode 100644 src/views/product/goodsImg/imgAdd.vue
diff --git a/src/views/product/goodsImg/goodsImgs.vue b/src/views/product/goodsImg/goodsImgs.vue
index db2ca0c..6990231 100644
--- a/src/views/product/goodsImg/goodsImgs.vue
+++ b/src/views/product/goodsImg/goodsImgs.vue
@@ -32,6 +32,14 @@
批量编辑
+