From 56cd2882d906227f3217daa0275f422059c097cd Mon Sep 17 00:00:00 2001 From: minimaxagent1 Date: Fri, 8 Aug 2025 15:34:01 +0800 Subject: [PATCH] =?UTF-8?q?floorSelector.vue=E6=A8=A1=E5=9D=97=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/memorial/index.js | 10 + pages/memorial/compositons/README.md | 145 +++++++ pages/memorial/compositons/floorSelector.vue | 381 +++++++++++++++++++ pages/memorial/memorial.vue | 51 ++- 4 files changed, 583 insertions(+), 4 deletions(-) create mode 100644 pages/memorial/compositons/README.md create mode 100644 pages/memorial/compositons/floorSelector.vue diff --git a/api/memorial/index.js b/api/memorial/index.js index 21c052d..47881af 100644 --- a/api/memorial/index.js +++ b/api/memorial/index.js @@ -73,4 +73,14 @@ export function getMemorialDetail(id) { return get(`/app/memorial/${id}`, {}, { showLoading: false }) +} + +/** + * 获取楼层树形结构 + * @returns {Promise} 返回楼层树形数据 + */ +export function getMemorialTree() { + return get('/app/memorial/listTree', {}, { + showLoading: false + }) } \ No newline at end of file diff --git a/pages/memorial/compositons/README.md b/pages/memorial/compositons/README.md new file mode 100644 index 0000000..aafe54a --- /dev/null +++ b/pages/memorial/compositons/README.md @@ -0,0 +1,145 @@ +# 楼层选择组件 (FloorSelector) + +## 功能描述 + +楼层选择组件是一个三层级联选择器,用于选择楼层、区域和单元。组件会根据接口返回的树形数据自动渲染选择项。 + +## 接口数据格式 + +组件期望的接口返回格式: + +```json +{ + "msg": "操作成功", + "code": 200, + "data": [ + { + "id": "12", + "label": "寒山寺", + "type": 1, + "children": [ + { + "id": "1", + "label": "1F", + "type": 2, + "children": [ + { + "id": "23", + "label": "A区", + "type": 3, + "children": [ + { + "id": "16", + "label": "A01", + "type": 4, + "children": null + } + ] + } + ] + } + ] + } + ] +} +``` + +## 组件属性 (Props) + +| 属性名 | 类型 | 默认值 | 说明 | +|--------|------|--------|------| +| defaultFloorId | String | '' | 默认选中的楼层ID | +| defaultAreaId | String | '' | 默认选中的区域ID | +| defaultUnitId | String | '' | 默认选中的单元ID | + +## 事件 (Events) + +| 事件名 | 参数 | 说明 | +|--------|------|------| +| selection-change | { floor, area, unit } | 选择发生变化时触发 | + +## 方法 (Methods) + +| 方法名 | 参数 | 返回值 | 说明 | +|--------|------|--------|------| +| getCurrentSelection | - | Object | 获取当前选中信息 | +| resetSelection | - | - | 重置选择到默认状态 | + +## 使用示例 + +### 基础使用 + +```vue + + + +``` + +### 设置默认选中项 + +```vue + +``` + +### 获取当前选择 + +```vue + + + +``` + +## 样式定制 + +组件使用了以下主要颜色: + +- 背景色: `#FFFBF5` +- 边框色: `#C7A26D` +- 未选中按钮: `#F5E6D3` +- 选中按钮: `#8B4513` +- 文字颜色: `#695347` + +可以通过修改组件的样式来调整外观。 + +## 注意事项 + +1. 组件会自动调用 `/app/memorial/listTree` 接口获取数据 +2. 选择楼层时会自动选中第一个区域 +3. 选择区域时会自动选中第一个单元 +4. 如果接口返回空数据,会显示空状态 +5. 网络异常时会显示错误提示 \ No newline at end of file diff --git a/pages/memorial/compositons/floorSelector.vue b/pages/memorial/compositons/floorSelector.vue new file mode 100644 index 0000000..24ff969 --- /dev/null +++ b/pages/memorial/compositons/floorSelector.vue @@ -0,0 +1,381 @@ + + + + + \ No newline at end of file diff --git a/pages/memorial/memorial.vue b/pages/memorial/memorial.vue index a94db8b..5a3e20a 100644 --- a/pages/memorial/memorial.vue +++ b/pages/memorial/memorial.vue @@ -29,6 +29,16 @@ @item-click="handleItemClick" ref="enshrinedList" /> + + + + @@ -117,7 +154,13 @@ export default { display: flex; align-items: center; flex-direction: column; - padding: 0 15rpx 40rpx 15rpx; + padding-bottom: 40rpx; box-sizing: border-box; } + +.floor-selector-container { + margin: 30rpx 0; + display: flex; + justify-content: center; +} \ No newline at end of file