hookehuyr

fix 树形组件显示高度调整

1 <!-- 1 <!--
2 * @Date: 2022-08-29 14:31:20 2 * @Date: 2022-08-29 14:31:20
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-06-03 13:15:47 4 + * @LastEditTime: 2024-06-03 18:27:47
5 * @FilePath: /data-table/src/components/TreeField/MyComponent.vue 5 * @FilePath: /data-table/src/components/TreeField/MyComponent.vue
6 * @Description: 树形组件 6 * @Description: 树形组件
7 --> 7 -->
...@@ -61,8 +61,9 @@ ...@@ -61,8 +61,9 @@
61 <van-tab title="成员" :name="2"></van-tab> 61 <van-tab title="成员" :name="2"></van-tab>
62 </van-tabs> 62 </van-tabs>
63 63
64 - <div v-show="tabActive === 0" style="padding: 0 0 1rem 1rem;"> 64 + <div v-show="tabActive === 0" style="padding: 0 0 0 1rem;">
65 <Vtree 65 <Vtree
66 + id="deptTree"
66 ref="deptTreeRef" 67 ref="deptTreeRef"
67 v-model="select_dept_value" 68 v-model="select_dept_value"
68 checkable 69 checkable
...@@ -74,13 +75,13 @@ ...@@ -74,13 +75,13 @@
74 :cascade="false" 75 :cascade="false"
75 :defaultExpandAll="false" 76 :defaultExpandAll="false"
76 @checked-change="deptTreeCheckedChange" 77 @checked-change="deptTreeCheckedChange"
77 - style=" height: 55vh; overflow: scroll;" 78 + style=" height: 60vh; overflow: scroll;"
78 > 79 >
79 <span slot="empty">暂无数据</span> 80 <span slot="empty">暂无数据</span>
80 </Vtree> 81 </Vtree>
81 </div> 82 </div>
82 83
83 - <div v-if="tabActive === 1" style="padding: 0 0 1rem 1rem;"> 84 + <div v-if="tabActive === 1" style="padding: 0 0 0 1rem; overflow: scroll; height: 60vh;">
84 <van-checkbox-group 85 <van-checkbox-group
85 v-model="role_checked" 86 v-model="role_checked"
86 @change="roleChangeMethod" 87 @change="roleChangeMethod"
...@@ -95,12 +96,14 @@ ...@@ -95,12 +96,14 @@
95 style="margin-bottom: 0.5rem;" 96 style="margin-bottom: 0.5rem;"
96 >{{ role.name }}</van-checkbox> 97 >{{ role.name }}</van-checkbox>
97 </van-checkbox-group> 98 </van-checkbox-group>
99 + <div style="height: 4rem;"></div>
98 </div> 100 </div>
99 101
100 <div v-if="tabActive === 2" style="padding: 0 0 0 1rem;"> 102 <div v-if="tabActive === 2" style="padding: 0 0 0 1rem;">
101 <van-row gutter=""> 103 <van-row gutter="">
102 - <van-col span="10" style="border-right: 1px solid #eee; height: 55vh; overflow: scroll;"> 104 + <van-col span="10" style="border-right: 1px solid #eee; height: 60vh; overflow: scroll;">
103 <Vtree 105 <Vtree
106 + id="userTree"
104 ref="userTreeRef" 107 ref="userTreeRef"
105 v-model="select_user_value" 108 v-model="select_user_value"
106 selectable 109 selectable
...@@ -198,12 +201,12 @@ ...@@ -198,12 +201,12 @@
198 </div> 201 </div>
199 202
200 <div style="position: fixed; bottom: 0; left: 0; width: 100%;"> 203 <div style="position: fixed; bottom: 0; left: 0; width: 100%;">
201 - <van-row gutter="0"> 204 + <van-row gutter="10" style="padding: 0 10px 1rem;">
202 <van-col span="12"> 205 <van-col span="12">
203 - <van-button block type="default" @click="onCancelClick">取消</van-button> 206 + <van-button block round type="default" @click="onCancelClick">取消</van-button>
204 </van-col> 207 </van-col>
205 <van-col span="12"> 208 <van-col span="12">
206 - <van-button block type="primary" @click="onConfirmClick">确定</van-button> 209 + <van-button block round type="primary" @click="onConfirmClick">确定</van-button>
207 </van-col> 210 </van-col>
208 </van-row> 211 </van-row>
209 </div> 212 </div>
...@@ -260,6 +263,12 @@ const openTree = () => { ...@@ -260,6 +263,12 @@ const openTree = () => {
260 // 获取已选择的数据 263 // 获取已选择的数据
261 checkedGroup.value = _.cloneDeep(emitCheckedGroup.value); 264 checkedGroup.value = _.cloneDeep(emitCheckedGroup.value);
262 syncResultToList(); // 同步勾选状态 265 syncResultToList(); // 同步勾选状态
266 +
267 + // 树形结构底部高度可视度
268 + if (!$('#deptTree').find('.tree-placeholder').length) {
269 + $('#deptTree').find('.ctree-tree__block-area').append('<div class="tree-placeholder" style="height: 4rem;"></div>');
270 + }
271 +
263 }); 272 });
264 } 273 }
265 274
...@@ -397,6 +406,10 @@ const onClickTab = ({ title }) => { // tab点击事件 ...@@ -397,6 +406,10 @@ const onClickTab = ({ title }) => { // tab点击事件
397 } 406 }
398 if (title === '成员') { 407 if (title === '成员') {
399 userListReset(); 408 userListReset();
409 + // 树形结构底部高度可视度
410 + if (!$('#userTree').find('.tree-placeholder').length) {
411 + $('#userTree').find('.ctree-tree__block-area').append('<div class="tree-placeholder" style="height: 4rem;"></div>');
412 + }
400 } 413 }
401 }); 414 });
402 }; 415 };
......