Showing
2 changed files
with
22 additions
and
6 deletions
| 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-08-29 13:22:00 | 4 | + * @LastEditTime: 2024-11-21 12:41:40 |
| 5 | * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue | 5 | * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue |
| 6 | * @Description: 树形组件 | 6 | * @Description: 树形组件 |
| 7 | --> | 7 | --> |
| ... | @@ -284,6 +284,7 @@ import '@wsfe/vue-tree/style.css'; | ... | @@ -284,6 +284,7 @@ import '@wsfe/vue-tree/style.css'; |
| 284 | import $ from 'jquery'; | 284 | import $ from 'jquery'; |
| 285 | import _ from 'lodash'; | 285 | import _ from 'lodash'; |
| 286 | import { showDialog, showToast } from 'vant'; | 286 | import { showDialog, showToast } from 'vant'; |
| 287 | +import Cookies from 'js-cookie'; | ||
| 287 | 288 | ||
| 288 | // 获取父组件传值 | 289 | // 获取父组件传值 |
| 289 | const props = inject('props'); | 290 | const props = inject('props'); |
| ... | @@ -378,15 +379,17 @@ const openTree = () => { // 点击组件展示框回调 | ... | @@ -378,15 +379,17 @@ const openTree = () => { // 点击组件展示框回调 |
| 378 | if (props.component_props.readonly) return false; // 只读判断 | 379 | if (props.component_props.readonly) return false; // 只读判断 |
| 379 | // 打开弹窗 | 380 | // 打开弹窗 |
| 380 | showPopover.value = true; | 381 | showPopover.value = true; |
| 382 | + | ||
| 381 | // 获取数据 | 383 | // 获取数据 |
| 382 | nextTick(() => { | 384 | nextTick(() => { |
| 383 | // 动态判断点击显示的tab,默认点击第一个 | 385 | // 动态判断点击显示的tab,默认点击第一个 |
| 384 | onClickTab({ title: tabList.value[0]['title'] }) | 386 | onClickTab({ title: tabList.value[0]['title'] }) |
| 385 | // getDeptTreeData(); | 387 | // getDeptTreeData(); |
| 386 | - // 获取已选择的数据 | 388 | + setTimeout(() => { // 延时处理,防止数据未加载完就执行 |
| 387 | - checkedGroup.value = _.cloneDeep(emitCheckedGroup.value); | 389 | + // 获取已选择的数据 |
| 388 | - syncResultToList(); // 同步勾选状态 | 390 | + checkedGroup.value = _.cloneDeep(emitCheckedGroup.value); |
| 389 | - | 391 | + syncResultToList(); // 同步勾选状态 |
| 392 | + }, 100); | ||
| 390 | // 树形结构底部高度可视度 | 393 | // 树形结构底部高度可视度 |
| 391 | if (!$('#deptTree').find('.tree-placeholder').length) { | 394 | if (!$('#deptTree').find('.tree-placeholder').length) { |
| 392 | $('#deptTree').find('.ctree-tree__block-area').append('<div class="tree-placeholder" style="height: 10vh;"></div>'); | 395 | $('#deptTree').find('.ctree-tree__block-area').append('<div class="tree-placeholder" style="height: 10vh;"></div>'); |
| ... | @@ -461,6 +464,19 @@ const onConfirmClick = () => { // 确定操作 | ... | @@ -461,6 +464,19 @@ const onConfirmClick = () => { // 确定操作 |
| 461 | emitCheckedGroup.value = _.cloneDeep(checkedGroup.value); | 464 | emitCheckedGroup.value = _.cloneDeep(checkedGroup.value); |
| 462 | // 发送到表单数据 | 465 | // 发送到表单数据 |
| 463 | tree_select_value.value = [].concat(...Object.values(emitCheckedGroup.value)); | 466 | tree_select_value.value = [].concat(...Object.values(emitCheckedGroup.value)); |
| 467 | + // 适配cookie保存未完成表单 | ||
| 468 | + const currentValue = tree_select_value.value; | ||
| 469 | + const existingCookie = Cookies.get($route.query.code); | ||
| 470 | + | ||
| 471 | + if (existingCookie) { | ||
| 472 | + // 如果Cookie存在,更新它 | ||
| 473 | + let obj = JSON.parse(existingCookie); | ||
| 474 | + obj[props.key] = currentValue; // 替换掉旧值 | ||
| 475 | + Cookies.set($route.query.code, JSON.stringify(obj)); | ||
| 476 | + } else { | ||
| 477 | + // 如果Cookie不存在,新增它 | ||
| 478 | + Cookies.set($route.query.code, JSON.stringify({ [props.key]: currentValue })); | ||
| 479 | + } | ||
| 464 | } | 480 | } |
| 465 | 481 | ||
| 466 | const searchInputRef = ref(null); // 搜索输入框Ref | 482 | const searchInputRef = ref(null); // 搜索输入框Ref | ... | ... |
| 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-08-07 18:14:41 | 4 | + * @LastEditTime: 2024-11-21 12:29:18 |
| 5 | * @FilePath: /data-table/src/components/OrgPickerField/index.vue | 5 | * @FilePath: /data-table/src/components/OrgPickerField/index.vue |
| 6 | * @Description: 树形组件 | 6 | * @Description: 树形组件 |
| 7 | --> | 7 | --> | ... | ... |
-
Please register or login to post a comment