Showing
1 changed file
with
149 additions
and
66 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-05 19:27:33 | 4 | + * @LastEditTime: 2024-08-06 11:42:29 |
| 5 | * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue | 5 | * @FilePath: /data-table/src/components/OrgPickerField/MyComponent.vue |
| 6 | * @Description: 树形组件 | 6 | * @Description: 树形组件 |
| 7 | --> | 7 | --> |
| ... | @@ -323,6 +323,19 @@ const tabList = computed(() => { | ... | @@ -323,6 +323,19 @@ const tabList = computed(() => { |
| 323 | 323 | ||
| 324 | const maxWidth = ref(0); | 324 | const maxWidth = ref(0); |
| 325 | 325 | ||
| 326 | +/** | ||
| 327 | + * 计算选中框数量 | ||
| 328 | + * 选中框的数量 >= 1 | ||
| 329 | + * @returns {boolean} | ||
| 330 | + */ | ||
| 331 | +const treeCheckedCount = computed(() => { | ||
| 332 | + let dept_count = checkedGroup.value.dept.length; | ||
| 333 | + let user_count = checkedGroup.value.user.length; | ||
| 334 | + let role_count = checkedGroup.value.role.length; | ||
| 335 | + | ||
| 336 | + return dept_count + user_count + role_count >= 1; | ||
| 337 | +}); | ||
| 338 | + | ||
| 326 | onMounted(async () => { | 339 | onMounted(async () => { |
| 327 | // TAG: 获取后台数据 | 340 | // TAG: 获取后台数据 |
| 328 | const flowDeptList = await getFlowDeptListAPI({ form_code: $route.query.code }); | 341 | const flowDeptList = await getFlowDeptListAPI({ form_code: $route.query.code }); |
| ... | @@ -333,11 +346,12 @@ onMounted(async () => { | ... | @@ -333,11 +346,12 @@ onMounted(async () => { |
| 333 | if (flowRoleList.code) { | 346 | if (flowRoleList.code) { |
| 334 | dept_list = flowRoleList.data; | 347 | dept_list = flowRoleList.data; |
| 335 | } | 348 | } |
| 349 | + // TEST | ||
| 350 | + check_type.value = 'single'; // 默认单选 | ||
| 336 | // 获取已选中数据 | 351 | // 获取已选中数据 |
| 337 | // 如果有默认值处理 | 352 | // 如果有默认值处理 |
| 338 | props.value = props.component_props.default; | 353 | props.value = props.component_props.default; |
| 339 | - // TEST | 354 | + // |
| 340 | - check_type.value = ''; // 默认单选 | ||
| 341 | if (props.value) { | 355 | if (props.value) { |
| 342 | props.value.forEach(item => { | 356 | props.value.forEach(item => { |
| 343 | if (item.type === 'dept') { | 357 | if (item.type === 'dept') { |
| ... | @@ -357,7 +371,7 @@ onMounted(async () => { | ... | @@ -357,7 +371,7 @@ onMounted(async () => { |
| 357 | }) | 371 | }) |
| 358 | }); | 372 | }); |
| 359 | 373 | ||
| 360 | -const openTree = () => { | 374 | +const openTree = () => { // 点击组件展示框回调 |
| 361 | if (props.component_props.readonly) return false; // 只读判断 | 375 | if (props.component_props.readonly) return false; // 只读判断 |
| 362 | // 打开弹窗 | 376 | // 打开弹窗 |
| 363 | showPopover.value = true; | 377 | showPopover.value = true; |
| ... | @@ -377,10 +391,20 @@ const openTree = () => { | ... | @@ -377,10 +391,20 @@ const openTree = () => { |
| 377 | 391 | ||
| 378 | }); | 392 | }); |
| 379 | } | 393 | } |
| 380 | - | 394 | +/** |
| 395 | + * 点击节点详情 | ||
| 396 | + * @param {*} id | ||
| 397 | + * @param {*} type | ||
| 398 | + * @param {*} name | ||
| 399 | + * @param {*} mobile | ||
| 400 | + */ | ||
| 381 | const node_info = ref({}); | 401 | const node_info = ref({}); |
| 382 | const show_detail = ref(false); | 402 | const show_detail = ref(false); |
| 383 | -const clickNode = ({ id, type, name, mobile='' }) => { // 点击显示选择详情 | 403 | + |
| 404 | +/******************** END ****************/ | ||
| 405 | + | ||
| 406 | +// 点击显示框,显示节点详情 | ||
| 407 | +const clickNode = ({ id, type, name, mobile='' }) => { | ||
| 384 | if (!props.component_props.readonly) return false; // 非只读不予许操作 | 408 | if (!props.component_props.readonly) return false; // 非只读不予许操作 |
| 385 | const obj = { | 409 | const obj = { |
| 386 | dept: '部门', | 410 | dept: '部门', |
| ... | @@ -399,21 +423,36 @@ const clickNode = ({ id, type, name, mobile='' }) => { // 点击显示选择详 | ... | @@ -399,21 +423,36 @@ const clickNode = ({ id, type, name, mobile='' }) => { // 点击显示选择详 |
| 399 | show_detail.value = true; | 423 | show_detail.value = true; |
| 400 | } | 424 | } |
| 401 | 425 | ||
| 426 | +/** | ||
| 427 | + * 勾选数据结构 | ||
| 428 | + * @type {Object} | ||
| 429 | + * @property {Array} dept 组织结构 | ||
| 430 | + * @property {Array} role 角色 | ||
| 431 | + * @property {Array} user 成员 | ||
| 432 | + */ | ||
| 402 | const emitCheckedGroup = ref({ | 433 | const emitCheckedGroup = ref({ |
| 403 | dept: [], // 组织结构 | 434 | dept: [], // 组织结构 |
| 404 | role: [], // 角色 | 435 | role: [], // 角色 |
| 405 | user: [] // 成员 | 436 | user: [] // 成员 |
| 406 | }); | 437 | }); |
| 407 | 438 | ||
| 439 | +/** | ||
| 440 | + * 勾选数据---发送表单数据 | ||
| 441 | + * @type {Array} | ||
| 442 | + */ | ||
| 408 | const tree_select_value = ref([]); | 443 | const tree_select_value = ref([]); |
| 409 | 444 | ||
| 410 | -const onCancelClick = () => { | 445 | +/******* 搜索输入项 *******/ |
| 446 | +const showPopover = ref(false); // 显示/隐藏弹框 | ||
| 447 | + | ||
| 448 | +const onCancelClick = () => { // 取消操作 | ||
| 411 | showPopover.value = false; | 449 | showPopover.value = false; |
| 412 | } | 450 | } |
| 413 | -const onConfirmClick = () => { | 451 | + |
| 452 | +const onConfirmClick = () => { // 确定操作 | ||
| 414 | showPopover.value = false; | 453 | showPopover.value = false; |
| 415 | if (is_search.value) { | 454 | if (is_search.value) { |
| 416 | - onCloseSearch() | 455 | + onCloseSearch(); |
| 417 | } | 456 | } |
| 418 | // | 457 | // |
| 419 | emitCheckedGroup.value = _.cloneDeep(checkedGroup.value); | 458 | emitCheckedGroup.value = _.cloneDeep(checkedGroup.value); |
| ... | @@ -421,12 +460,10 @@ const onConfirmClick = () => { | ... | @@ -421,12 +460,10 @@ const onConfirmClick = () => { |
| 421 | tree_select_value.value = [].concat(...Object.values(emitCheckedGroup.value)); | 460 | tree_select_value.value = [].concat(...Object.values(emitCheckedGroup.value)); |
| 422 | } | 461 | } |
| 423 | 462 | ||
| 424 | -/******* 搜索输入项 *******/ | 463 | +const searchInputRef = ref(null); // 搜索输入框Ref |
| 425 | -const showPopover = ref(false); // 显示/隐藏弹框 | 464 | +const searchValue = ref(''); // 搜索输入框值 |
| 426 | - | ||
| 427 | -const searchInputRef = ref(null); | ||
| 428 | -const searchValue = ref(''); | ||
| 429 | const is_search = ref(false); // 默认不显示搜索框 | 465 | const is_search = ref(false); // 默认不显示搜索框 |
| 466 | + | ||
| 430 | /** | 467 | /** |
| 431 | * 搜索选中结果集 | 468 | * 搜索选中结果集 |
| 432 | * @param {Number} id | 469 | * @param {Number} id |
| ... | @@ -440,18 +477,24 @@ const onSearchBlur = async () => { // 搜索框失去焦点 | ... | @@ -440,18 +477,24 @@ const onSearchBlur = async () => { // 搜索框失去焦点 |
| 440 | if (check_type.value === 'single') { | 477 | if (check_type.value === 'single') { |
| 441 | if (treeCheckedCount.value) { | 478 | if (treeCheckedCount.value) { |
| 442 | let arr = [...checkedGroup.value.dept, ...checkedGroup.value.role, ...checkedGroup.value.user] | 479 | let arr = [...checkedGroup.value.dept, ...checkedGroup.value.role, ...checkedGroup.value.user] |
| 480 | + let current = arr[0]; // 单选模式下,勾选值只会有一个 | ||
| 481 | + // | ||
| 443 | for (const key in data) { | 482 | for (const key in data) { |
| 444 | const element = data[key]; | 483 | const element = data[key]; |
| 484 | + // 遍历数组,设置特定元素的禁用状态 | ||
| 445 | element.forEach(item => { | 485 | element.forEach(item => { |
| 446 | - if (item.id === arr[0].id) { // 禁用其他 | 486 | + if (item.id === current.id) { |
| 487 | + // 设置该项不禁用 | ||
| 447 | item.disabled = false; | 488 | item.disabled = false; |
| 448 | } else { | 489 | } else { |
| 490 | + // 设置该项禁用 | ||
| 449 | item.disabled = true; | 491 | item.disabled = true; |
| 450 | } | 492 | } |
| 451 | }); | 493 | }); |
| 452 | } | 494 | } |
| 453 | } | 495 | } |
| 454 | } | 496 | } |
| 497 | + // 赋值搜索结果集 | ||
| 455 | user_dept_role.value = data; | 498 | user_dept_role.value = data; |
| 456 | } | 499 | } |
| 457 | } | 500 | } |
| ... | @@ -507,17 +550,23 @@ const checkedGroup = ref({ | ... | @@ -507,17 +550,23 @@ const checkedGroup = ref({ |
| 507 | user: [] // 成员 | 550 | user: [] // 成员 |
| 508 | }); | 551 | }); |
| 509 | 552 | ||
| 510 | -const resetRoleDisabled = () => { | 553 | +/** |
| 554 | + * 重置角色Tab列表的disable状态 | ||
| 555 | + */ | ||
| 556 | +const resetRoleDisable = () => { | ||
| 511 | // 如果角色没有选中,解除禁用 | 557 | // 如果角色没有选中,解除禁用 |
| 512 | if (!role_checked.value.length) { | 558 | if (!role_checked.value.length) { |
| 513 | - roleList.value.forEach(item => { | 559 | + roleList.value.forEach(item => { |
| 514 | - item.disabled = false; | 560 | + item.disabled = false; |
| 515 | - }); | 561 | + }); |
| 516 | - } | 562 | + } |
| 517 | } | 563 | } |
| 518 | 564 | ||
| 519 | -const resetUserDisabled = () => { | 565 | +/** |
| 520 | - // 如果角色没有选中,解除禁用 | 566 | +* 重置成员Tab列表的disable状态 |
| 567 | +*/ | ||
| 568 | +const resetUserDisable = () => { | ||
| 569 | + // 如果成员没有选中,解除禁用 | ||
| 521 | if (!user_checked.value.length) { | 570 | if (!user_checked.value.length) { |
| 522 | userList.value.forEach(item => { | 571 | userList.value.forEach(item => { |
| 523 | item.disabled = false; | 572 | item.disabled = false; |
| ... | @@ -525,22 +574,27 @@ const resetUserDisabled = () => { | ... | @@ -525,22 +574,27 @@ const resetUserDisabled = () => { |
| 525 | } | 574 | } |
| 526 | } | 575 | } |
| 527 | 576 | ||
| 577 | +/** | ||
| 578 | +* 重置搜索结果列表的disable状态 | ||
| 579 | +*/ | ||
| 528 | const resetSearchDisable = () => { | 580 | const resetSearchDisable = () => { |
| 529 | for (const key in user_dept_role.value) { | 581 | for (const key in user_dept_role.value) { |
| 530 | const element = user_dept_role.value[key]; | 582 | const element = user_dept_role.value[key]; |
| 531 | element.forEach(item => { | 583 | element.forEach(item => { |
| 532 | item.disabled = false; | 584 | item.disabled = false; |
| 533 | - // search_result_checked.value.forEach(val => { | ||
| 534 | - // if (item.id === val) { // 禁用其他 | ||
| 535 | - // item.disabled = false; | ||
| 536 | - // } else { | ||
| 537 | - // item.disabled = true; | ||
| 538 | - // } | ||
| 539 | - // }) | ||
| 540 | }); | 585 | }); |
| 541 | } | 586 | } |
| 542 | } | 587 | } |
| 543 | 588 | ||
| 589 | +/** | ||
| 590 | + * 重置所有列表的disable状态 | ||
| 591 | + */ | ||
| 592 | +const resetAllDisable = () => { | ||
| 593 | + resetRoleDisable(); // 重置角色禁用状态 | ||
| 594 | + resetUserDisable(); // 重置成员禁用状态 | ||
| 595 | + resetSearchDisable(); // 重置搜索结果禁用状态 | ||
| 596 | +} | ||
| 597 | + | ||
| 544 | const onRemoveDeptTag = (dept) => { // 移除部门标签 | 598 | const onRemoveDeptTag = (dept) => { // 移除部门标签 |
| 545 | // 移除选中框显示 | 599 | // 移除选中框显示 |
| 546 | const index = checkedGroup.value.dept.findIndex(item => JSON.stringify(item) === JSON.stringify(dept)); | 600 | const index = checkedGroup.value.dept.findIndex(item => JSON.stringify(item) === JSON.stringify(dept)); |
| ... | @@ -552,9 +606,7 @@ const onRemoveDeptTag = (dept) => { // 移除部门标签 | ... | @@ -552,9 +606,7 @@ const onRemoveDeptTag = (dept) => { // 移除部门标签 |
| 552 | search_result_checked.value.splice(idx, 1); | 606 | search_result_checked.value.splice(idx, 1); |
| 553 | // 单选模式 | 607 | // 单选模式 |
| 554 | if (check_type.value === 'single') { | 608 | if (check_type.value === 'single') { |
| 555 | - resetRoleDisabled();// 重置角色禁用状态 | 609 | + resetAllDisable(); |
| 556 | - resetUserDisabled(); // 重置成员禁用状态 | ||
| 557 | - resetSearchDisable(); // 重置搜索结果禁用状态 | ||
| 558 | } | 610 | } |
| 559 | } | 611 | } |
| 560 | 612 | ||
| ... | @@ -569,9 +621,7 @@ const onRemoveRoleTag = (role) => { // 移除角色标签 | ... | @@ -569,9 +621,7 @@ const onRemoveRoleTag = (role) => { // 移除角色标签 |
| 569 | search_result_checked.value.splice(i, 1); | 621 | search_result_checked.value.splice(i, 1); |
| 570 | // 单选模式 | 622 | // 单选模式 |
| 571 | if (check_type.value === 'single') { | 623 | if (check_type.value === 'single') { |
| 572 | - resetRoleDisabled();// 重置角色禁用状态 | 624 | + resetAllDisable(); |
| 573 | - resetUserDisabled(); // 重置成员禁用状态 | ||
| 574 | - resetSearchDisable(); // 重置搜索结果禁用状态 | ||
| 575 | } | 625 | } |
| 576 | } | 626 | } |
| 577 | 627 | ||
| ... | @@ -586,9 +636,7 @@ const onRemoveUserTag = (user) => { // 移除成员标签 | ... | @@ -586,9 +636,7 @@ const onRemoveUserTag = (user) => { // 移除成员标签 |
| 586 | search_result_checked.value.splice(i, 1); | 636 | search_result_checked.value.splice(i, 1); |
| 587 | // 单选模式 | 637 | // 单选模式 |
| 588 | if (check_type.value === 'single') { | 638 | if (check_type.value === 'single') { |
| 589 | - resetRoleDisabled(); // 重置角色禁用状态 | 639 | + resetAllDisable(); |
| 590 | - resetUserDisabled(); // 重置成员禁用状态 | ||
| 591 | - resetSearchDisable(); // 重置搜索结果禁用状态 | ||
| 592 | } | 640 | } |
| 593 | } | 641 | } |
| 594 | 642 | ||
| ... | @@ -597,9 +645,6 @@ const tabRef = ref(null); | ... | @@ -597,9 +645,6 @@ const tabRef = ref(null); |
| 597 | const tabActive = ref(0); | 645 | const tabActive = ref(0); |
| 598 | const deptTreeRef = ref(); | 646 | const deptTreeRef = ref(); |
| 599 | 647 | ||
| 600 | - | ||
| 601 | -const userList = ref([]); | ||
| 602 | - | ||
| 603 | const onClickTab = ({ title }) => { // tab点击事件 | 648 | const onClickTab = ({ title }) => { // tab点击事件 |
| 604 | nextTick(() => { | 649 | nextTick(() => { |
| 605 | if (title === '组织结构') { | 650 | if (title === '组织结构') { |
| ... | @@ -647,6 +692,7 @@ const roleListReset = () => { // 角色重置列表 | ... | @@ -647,6 +692,7 @@ const roleListReset = () => { // 角色重置列表 |
| 647 | const userListReset = () => { // 成员重置列表 | 692 | const userListReset = () => { // 成员重置列表 |
| 648 | userTreeRef.value.setData(role_list); | 693 | userTreeRef.value.setData(role_list); |
| 649 | userTreeRef.value.setExpand(35697, true); | 694 | userTreeRef.value.setExpand(35697, true); |
| 695 | + // 单选模式 | ||
| 650 | if (check_type.value === 'single') { | 696 | if (check_type.value === 'single') { |
| 651 | if (treeCheckedCount.value) { // 已勾选值一个 | 697 | if (treeCheckedCount.value) { // 已勾选值一个 |
| 652 | if (checkedGroup.value.user.length) { | 698 | if (checkedGroup.value.user.length) { |
| ... | @@ -673,13 +719,18 @@ const userListReset = () => { // 成员重置列表 | ... | @@ -673,13 +719,18 @@ const userListReset = () => { // 成员重置列表 |
| 673 | const select_dept_value = ref(); // 组织结构树形选中值 | 719 | const select_dept_value = ref(); // 组织结构树形选中值 |
| 674 | const deptTreeDisableAll = ref(false); // 组织结构树形禁用 | 720 | const deptTreeDisableAll = ref(false); // 组织结构树形禁用 |
| 675 | 721 | ||
| 676 | -const getDeptTreeData = () => { // 获取组织结构数据 | 722 | +// const getDeptTreeData = () => { // 获取组织结构数据 |
| 677 | - deptTreeRef.value.setData(role_list); | 723 | +// deptTreeRef.value.setData(role_list); |
| 678 | - // 默认展开第一个 | 724 | +// // 默认展开第一个 |
| 679 | - deptTreeRef.value.setExpand(35697, true); | 725 | +// deptTreeRef.value.setExpand(35697, true); |
| 680 | -} | 726 | +// } |
| 681 | 727 | ||
| 682 | -const deptTreeCheck = (node) => { // 组织结构单选勾中 | 728 | +/** |
| 729 | + * 组织结构单选勾中 | ||
| 730 | + * @param {*} node | ||
| 731 | + */ | ||
| 732 | +const deptTreeCheck = (node) => { | ||
| 733 | + // 单选模式 | ||
| 683 | if (check_type.value === 'single') { | 734 | if (check_type.value === 'single') { |
| 684 | if (treeCheckedCount.value) { | 735 | if (treeCheckedCount.value) { |
| 685 | showToast('单选模式下,只能勾选一个') | 736 | showToast('单选模式下,只能勾选一个') |
| ... | @@ -689,7 +740,12 @@ const deptTreeCheck = (node) => { // 组织结构单选勾中 | ... | @@ -689,7 +740,12 @@ const deptTreeCheck = (node) => { // 组织结构单选勾中 |
| 689 | } | 740 | } |
| 690 | } | 741 | } |
| 691 | 742 | ||
| 692 | -const deptTreeUncheck = (node) => { // 组织结构单选取消 | 743 | +/** |
| 744 | + * 组织结构单选取消 | ||
| 745 | + * @param {*} node | ||
| 746 | + */ | ||
| 747 | +const deptTreeUncheck = (node) => { | ||
| 748 | + // 单选模式 | ||
| 693 | if (check_type.value === 'single') { | 749 | if (check_type.value === 'single') { |
| 694 | // 移除选中框显示 | 750 | // 移除选中框显示 |
| 695 | const index = checkedGroup.value['dept'].findIndex(item => item.id === node.id); | 751 | const index = checkedGroup.value['dept'].findIndex(item => item.id === node.id); |
| ... | @@ -697,15 +753,12 @@ const deptTreeUncheck = (node) => { // 组织结构单选取消 | ... | @@ -697,15 +753,12 @@ const deptTreeUncheck = (node) => { // 组织结构单选取消 |
| 697 | } | 753 | } |
| 698 | } | 754 | } |
| 699 | 755 | ||
| 700 | -const treeCheckedCount = computed(() => { // 选中框的数量是否大于一 | 756 | +/** |
| 701 | - let dept_count = checkedGroup.value.dept.length; | 757 | + * 组织结构勾选回调 |
| 702 | - let user_count = checkedGroup.value.user.length; | 758 | + * @param {*} arr |
| 703 | - let role_count = checkedGroup.value.role.length; | 759 | + */ |
| 704 | - | 760 | +const deptTreeCheckedChange = (arr) => { |
| 705 | - return dept_count + user_count + role_count >= 1; | 761 | + // 单选模式 |
| 706 | -}); | ||
| 707 | - | ||
| 708 | -const deptTreeCheckedChange = (arr) => { // 组织结构勾选回调 | ||
| 709 | if (check_type.value === 'single') { | 762 | if (check_type.value === 'single') { |
| 710 | if (treeCheckedCount.value) { | 763 | if (treeCheckedCount.value) { |
| 711 | return false | 764 | return false |
| ... | @@ -723,10 +776,21 @@ const deptTreeCheckedChange = (arr) => { // 组织结构勾选回调 | ... | @@ -723,10 +776,21 @@ const deptTreeCheckedChange = (arr) => { // 组织结构勾选回调 |
| 723 | /**************** END *****************/ | 776 | /**************** END *****************/ |
| 724 | 777 | ||
| 725 | /************* 角色模块 ***************/ | 778 | /************* 角色模块 ***************/ |
| 726 | -const role_checked = ref([]); // 角色多选选中值 | 779 | +/** |
| 780 | + * 角色选中值集合 | ||
| 781 | + */ | ||
| 782 | +const role_checked = ref([]); | ||
| 783 | +/** | ||
| 784 | + * 角色列表数据集合 | ||
| 785 | + */ | ||
| 727 | const roleList = ref([]); | 786 | const roleList = ref([]); |
| 728 | 787 | ||
| 729 | -const roleChangeMethod = (val) => { // 角色多选组点击回调 | 788 | +/** |
| 789 | + * 角色多选值变化回调 | ||
| 790 | + * @param {*} val | ||
| 791 | + */ | ||
| 792 | +const roleChangeMethod = (val) => { | ||
| 793 | + // 单选模式 | ||
| 730 | if (check_type.value === 'single') { | 794 | if (check_type.value === 'single') { |
| 731 | if (treeCheckedCount.value) { | 795 | if (treeCheckedCount.value) { |
| 732 | return; | 796 | return; |
| ... | @@ -738,11 +802,17 @@ const roleChangeMethod = (val) => { // 角色多选组点击回调 | ... | @@ -738,11 +802,17 @@ const roleChangeMethod = (val) => { // 角色多选组点击回调 |
| 738 | checkedGroup.value.role = result.filter(item => item !== undefined); | 802 | checkedGroup.value.role = result.filter(item => item !== undefined); |
| 739 | } | 803 | } |
| 740 | 804 | ||
| 741 | -const onRoleClick = (role, evt) => { // 角色单击回调 | 805 | +/** |
| 806 | + * 角色单击选项回调 | ||
| 807 | + * @param {*} role | ||
| 808 | + * @param {*} evt | ||
| 809 | + */ | ||
| 810 | +const onRoleClick = (role, evt) => { | ||
| 742 | if (role.disabled) { // 节点禁用时不能操作 | 811 | if (role.disabled) { // 节点禁用时不能操作 |
| 743 | showToast('单选模式下,只能勾选一个') | 812 | showToast('单选模式下,只能勾选一个') |
| 744 | return; | 813 | return; |
| 745 | } | 814 | } |
| 815 | + // 单选模式 | ||
| 746 | if (check_type.value === 'single') { | 816 | if (check_type.value === 'single') { |
| 747 | // 移除选中框显示 | 817 | // 移除选中框显示 |
| 748 | const index = checkedGroup.value['role'].findIndex(item => item === role.id); | 818 | const index = checkedGroup.value['role'].findIndex(item => item === role.id); |
| ... | @@ -758,7 +828,7 @@ const onRoleClick = (role, evt) => { // 角色单击回调 | ... | @@ -758,7 +828,7 @@ const onRoleClick = (role, evt) => { // 角色单击回调 |
| 758 | }); | 828 | }); |
| 759 | } | 829 | } |
| 760 | // 如果没有选中,解除禁用 | 830 | // 如果没有选中,解除禁用 |
| 761 | - resetRoleDisabled(); | 831 | + resetRoleDisable(); |
| 762 | } | 832 | } |
| 763 | } | 833 | } |
| 764 | /**************** END *****************/ | 834 | /**************** END *****************/ |
| ... | @@ -766,12 +836,20 @@ const onRoleClick = (role, evt) => { // 角色单击回调 | ... | @@ -766,12 +836,20 @@ const onRoleClick = (role, evt) => { // 角色单击回调 |
| 766 | /************* 成员模块 ***************/ | 836 | /************* 成员模块 ***************/ |
| 767 | const userTreeRef = ref(); | 837 | const userTreeRef = ref(); |
| 768 | const select_user_value = ref(); // 成员树形选中值 | 838 | const select_user_value = ref(); // 成员树形选中值 |
| 769 | -const user_checked = ref([]); // 成员多选选中值 | 839 | +/** |
| 840 | + * 成员选中值集合 | ||
| 841 | + */ | ||
| 842 | +const user_checked = ref([]); | ||
| 843 | + | ||
| 844 | +/** | ||
| 845 | + * 成员Tab列表 | ||
| 846 | + */ | ||
| 847 | +const userList = ref([]); | ||
| 770 | 848 | ||
| 771 | const onUserTreeClick = (node) => { // 点击成员树形回调 | 849 | const onUserTreeClick = (node) => { // 点击成员树形回调 |
| 772 | userList.value = node.user; | 850 | userList.value = node.user; |
| 773 | user_checked.value = checkedGroup.value.user.map(item => item.id); | 851 | user_checked.value = checkedGroup.value.user.map(item => item.id); |
| 774 | - // 单选模式判断 | 852 | + // 单选模式 |
| 775 | if (check_type.value === 'single') { | 853 | if (check_type.value === 'single') { |
| 776 | if (treeCheckedCount.value) { // 已勾选值一个 | 854 | if (treeCheckedCount.value) { // 已勾选值一个 |
| 777 | if (checkedGroup.value.user.length) { // 成员列表有勾选值 | 855 | if (checkedGroup.value.user.length) { // 成员列表有勾选值 |
| ... | @@ -789,7 +867,7 @@ const onUserTreeClick = (node) => { // 点击成员树形回调 | ... | @@ -789,7 +867,7 @@ const onUserTreeClick = (node) => { // 点击成员树形回调 |
| 789 | userList.value = [] | 867 | userList.value = [] |
| 790 | } | 868 | } |
| 791 | } else { | 869 | } else { |
| 792 | - resetUserDisabled(); | 870 | + resetUserDisable(); |
| 793 | } | 871 | } |
| 794 | } | 872 | } |
| 795 | } | 873 | } |
| ... | @@ -830,10 +908,12 @@ const onCheckUserChange = (val, evt) => { | ... | @@ -830,10 +908,12 @@ const onCheckUserChange = (val, evt) => { |
| 830 | } | 908 | } |
| 831 | } | 909 | } |
| 832 | }); | 910 | }); |
| 833 | - if (val.disabled) { // 节点禁用时不能操作 | 911 | + // 节点禁用时不能操作 |
| 912 | + if (val.disabled) { | ||
| 834 | showToast('单选模式下,只能勾选一个') | 913 | showToast('单选模式下,只能勾选一个') |
| 835 | return; | 914 | return; |
| 836 | } | 915 | } |
| 916 | + // 单选模式 | ||
| 837 | if (check_type.value === 'single') { | 917 | if (check_type.value === 'single') { |
| 838 | // 移除选中框显示 | 918 | // 移除选中框显示 |
| 839 | const index = checkedGroup.value['user'].findIndex(item => item === val.id); | 919 | const index = checkedGroup.value['user'].findIndex(item => item === val.id); |
| ... | @@ -849,12 +929,15 @@ const onCheckUserChange = (val, evt) => { | ... | @@ -849,12 +929,15 @@ const onCheckUserChange = (val, evt) => { |
| 849 | }); | 929 | }); |
| 850 | } | 930 | } |
| 851 | // 如果没有选中,解除禁用 | 931 | // 如果没有选中,解除禁用 |
| 852 | - resetUserDisabled(); | 932 | + resetUserDisable(); |
| 853 | } | 933 | } |
| 854 | } | 934 | } |
| 855 | /**************** END *****************/ | 935 | /**************** END *****************/ |
| 856 | 936 | ||
| 857 | /***************** 搜索结果集模块 ********************/ | 937 | /***************** 搜索结果集模块 ********************/ |
| 938 | +/** | ||
| 939 | + * 搜索结果集合 | ||
| 940 | + */ | ||
| 858 | const user_dept_role = ref({ | 941 | const user_dept_role = ref({ |
| 859 | dept: [], | 942 | dept: [], |
| 860 | role: [], | 943 | role: [], | ... | ... |
-
Please register or login to post a comment