diff --git a/src/views/bst/part/components/PartTree.vue b/src/views/bst/part/components/PartTree.vue
new file mode 100644
index 0000000..9b8fd65
--- /dev/null
+++ b/src/views/bst/part/components/PartTree.vue
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+ {{ node.label }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/bst/part/index.vue b/src/views/bst/part/index.vue
index 4b0c8b1..36c889d 100644
--- a/src/views/bst/part/index.vue
+++ b/src/views/bst/part/index.vue
@@ -1,131 +1,119 @@
-
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
-
-
- 新增
-
+
+
+ 新增
+
+
+
+ 删除
+
+
+
+ 导出
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ row.partName }}
+
+
+
+
+
+
+
+
+
+
+ {{ row.orderNum }}
+
+
+
+
+
+ 修改
+
+ 删除
+
+
+
+
+
-
- 删除
-
-
-
- 导出
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ row.parentName }}/
-
- {{ row.partName }}
-
-
-
-
-
-
-
-
- 修改
-
- 删除
-
-
-
-
-
-
@@ -183,6 +171,7 @@ import FormCol from "@/components/FormCol/index.vue";
import {listStore} from "@/api/bst/store";
import DeptSelect from "@/components/Business/Dept/DeptSelect.vue";
import StoreLink from "@/views/bst/store/StoreLink.vue";
+import PartTree from "@/views/bst/part/components/PartTree.vue";
// 默认排序字段
const defaultSort = {
@@ -193,9 +182,12 @@ const defaultSort = {
export default {
name: "Part",
mixins: [$showColumns],
- components: {StoreLink, DeptSelect, FormCol},
+ components: {PartTree, StoreLink, DeptSelect, FormCol},
data() {
return {
+ // 是否展开,默认全部展开
+ isExpandAll: true,
+ refreshTable: true,
storeOptions: [], // 店铺域树数据
parentOptions: [], // 父区域树数据
cascaderProps: {
@@ -229,8 +221,6 @@ export default {
defaultSort,
// 查询参数
queryParams: {
- pageNum: 1,
- pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
storeId: null,
@@ -262,6 +252,11 @@ export default {
this.getStoreList();
},
methods: {
+ // 分类树节点点击事件
+ handlePartNodeClick(node) {
+ this.queryParams.partId = node.id;
+ this.getList();
+ },
loadParentTree(storeId) {
listPart({
storeId: storeId,
@@ -302,17 +297,52 @@ export default {
});
},
/** 查询区域列表列表 */
- getList() {
+ async getList() {
this.loading = true;
- listPart(this.queryParams).then(response => {
- this.partList = response.data.rows || response.data;
+ try {
+ // 获取所有店铺
+ const stores = await listStore();
+ // 获取所有区域
+ const parts = await listPart(this.queryParams);
+
+ // 构建混合树形结构
+ this.parentOptions = stores.rows.map(store => ({
+ id: `store_${store.storeId}`, // 添加唯一标识前缀
+ storeId: store.storeId,
+ storeName: store.storeName,
+ partName: store.storeName, // 统一使用partName字段显示名称
+ isStore: true, // 标记为店铺节点
+ children: this.buildStoreTree(parts.data, store.storeId)
+ })).filter(storeNode => storeNode.children.length > 0);
+
+ console.log('完整树形结构:', this.parentOptions);
+ } catch (e) {
+ console.error(e);
+ } finally {
this.loading = false;
- });
+ }
},
+ buildStoreTree(parts, storeId) {
+ const storeParts = parts.filter(p => p.storeId === storeId);
+ return this.handleTree(storeParts.map(p => ({
+ ...p,
+ id: `part_${p.partId}`, // 区域复合主键
+ parentId: p.parentId ? `part_${p.parentId}` : `store_${storeId}`
+ })), 'id', 'parentId', 'children');
+ },
+ // getList() {
+ // this.loading = true;
+ // listPart(this.queryParams).then(response => {
+ // this.parentOptions = this.handleTree(response.data, "partId", "parentId", "children");
+ // console.log("树形数据:", this.parentOptions); // 调试用
+ // this.loading = false;
+ // });
+ // },
// 取消按钮
cancel() {
this.open = false;
this.reset();
+ this.getList();
},
// 表单重置
reset() {
@@ -329,7 +359,6 @@ export default {
},
/** 搜索按钮操作 */
handleQuery() {
- this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */