hookehuyr

fix

1 <!-- 1 <!--
2 * @Date: 2023-11-01 10:18:53 2 * @Date: 2023-11-01 10:18:53
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-11-01 14:07:53 4 + * @LastEditTime: 2023-11-01 15:32:45
5 * @FilePath: /vue-flow-editor/doc/selectUserView.vue 5 * @FilePath: /vue-flow-editor/doc/selectUserView.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -205,16 +205,15 @@ const defaultProps = ref({ ...@@ -205,16 +205,15 @@ const defaultProps = ref({
205 }); 205 });
206 206
207 onMounted(() => { 207 onMounted(() => {
208 - // console.log(props.visible);
209 // axios.get('/srv/?a=query_form_all_field') 208 // axios.get('/srv/?a=query_form_all_field')
210 // .then(res => { 209 // .then(res => {
211 // console.warn(res.data); 210 // console.warn(res.data);
212 // }); 211 // });
213 - // $('.el-tabs__nav')
214 // 根据数据获取选中的tag标签 212 // 根据数据获取选中的tag标签
215 // setTagsList(userTabs); 213 // setTagsList(userTabs);
216 - // TODO:查询到的用户列表数据 214 + // TODO: 查询到的用户选中列表数据
217 userTags.value = [{ id: "user-1-1", name: "用户1-1" }]; 215 userTags.value = [{ id: "user-1-1", name: "用户1-1" }];
216 + // TODO: 查询到的用户列表数据
218 userTabs.value = [ 217 userTabs.value = [
219 { 218 {
220 id: "tab-1", 219 id: "tab-1",
...@@ -338,12 +337,12 @@ onMounted(() => { ...@@ -338,12 +337,12 @@ onMounted(() => {
338 ]; 337 ];
339 // 对比选中的用户的 ID,选中的 ID 同步状态到 userTabs 的数据结构上 338 // 对比选中的用户的 ID,选中的 ID 同步状态到 userTabs 的数据结构上
340 userTags.value.forEach(ele => { 339 userTags.value.forEach(ele => {
341 - modifyFieldValue(userTabs.value, "id", ele.id, true); 340 + modifyFieldValue(userTabs.value, "id", ele.id, "checked", true);
342 }); 341 });
343 }); 342 });
344 343
345 watch(() => { 344 watch(() => {
346 - // 345 + // 监听弹框状态
347 if (props.visible) { 346 if (props.visible) {
348 dialogUserFormVisible.value = true; 347 dialogUserFormVisible.value = true;
349 } else { 348 } else {
...@@ -351,14 +350,19 @@ watch(() => { ...@@ -351,14 +350,19 @@ watch(() => {
351 } 350 }
352 }); 351 });
353 352
353 +/**
354 + * 点击Tab切换回调
355 + *
356 + * @param {object} tab - The tab object that was clicked.
357 + * @param {object} event - The event object generated by the click event.
358 + * @param {number} idx - The index of the clicked tab.
359 + */
354 const handleTabClick = (tab, event, idx) => { 360 const handleTabClick = (tab, event, idx) => {
355 - // 点击Tab切换回调
356 tabSelectData.value = tab.data; // tab选中数据提供给list类型使用 361 tabSelectData.value = tab.data; // tab选中数据提供给list类型使用
357 userList.value = []; // 清空用户列表 362 userList.value = []; // 清空用户列表
358 checkedUserList.value = []; // 清空选中用户列表 363 checkedUserList.value = []; // 清空选中用户列表
359 activeTabContent.value = ""; // 清空侧边栏显示 364 activeTabContent.value = ""; // 清空侧边栏显示
360 currentNodeKey.value = []; // 清空树形的默认展开 365 currentNodeKey.value = []; // 清空树形的默认展开
361 - // console.log(tab, event);
362 // 设置当前激活的tab 366 // 设置当前激活的tab
363 userTabType.value = tab.type; 367 userTabType.value = tab.type;
364 activeTabId.value = tab.id; 368 activeTabId.value = tab.id;
...@@ -384,13 +388,16 @@ const handleTabClick = (tab, event, idx) => { ...@@ -384,13 +388,16 @@ const handleTabClick = (tab, event, idx) => {
384 // } 388 // }
385 }; 389 };
386 390
391 +/**
392 + * 侧边栏Tab点击回调
393 + *
394 + * @param {type} tab - description of parameter
395 + * @param {type} event - description of parameter
396 + */
387 const handleTabContentClick = (tab, event) => { 397 const handleTabContentClick = (tab, event) => {
388 - // 侧边栏Tab点击回调
389 - // console.log(activeTabContent.value);
390 - // console.log(tab);
391 - // console.log(event);
392 tabSelectData.value.forEach(ele => { 398 tabSelectData.value.forEach(ele => {
393 if (ele.label === tab.props.label) { 399 if (ele.label === tab.props.label) {
400 + // 设置右侧显示数据
394 userList.value = ele.list; 401 userList.value = ele.list;
395 checkedUserList.value = ele.list 402 checkedUserList.value = ele.list
396 .filter(ele => { 403 .filter(ele => {
...@@ -403,10 +410,15 @@ const handleTabContentClick = (tab, event) => { ...@@ -403,10 +410,15 @@ const handleTabContentClick = (tab, event) => {
403 }); 410 });
404 }; 411 };
405 412
413 +/**
414 + * 树形结构点击回调
415 + *
416 + * @param {object} data - The data associated with the clicked node.
417 + * @return {void}
418 + */
406 const handleNodeClick = data => { 419 const handleNodeClick = data => {
407 - // 树形结构点击回调
408 - // console.log(data);
409 if (data.list) { 420 if (data.list) {
421 + // 如果节点下存在 list 字段,设置为右侧显示数据列表
410 userList.value = data.list; 422 userList.value = data.list;
411 checkedUserList.value = data.list 423 checkedUserList.value = data.list
412 .filter(ele => { 424 .filter(ele => {
...@@ -415,41 +427,48 @@ const handleNodeClick = data => { ...@@ -415,41 +427,48 @@ const handleNodeClick = data => {
415 .map(ele => { 427 .map(ele => {
416 return ele.id; 428 return ele.id;
417 }); 429 });
418 - // console.warn(checkedUserList.value); 430 + // 默认展开相应ID节点
419 currentNodeKey.value = [data.id]; 431 currentNodeKey.value = [data.id];
420 } 432 }
421 }; 433 };
422 434
423 /** 435 /**
424 - * 递归查找匹配字段,并修改字段为新值 436 + * 递归查找匹配字段,并修改字段的值为新值
425 * 437 *
426 * @param {object} obj - 修改对象 438 * @param {object} obj - 修改对象
427 - * @param {string} fieldName - 修改字段 439 + * @param {string} fieldName - 查找字段
428 - * @param {any} targetValue - 匹配值 440 + * @param {any} fieldValue - 匹配值
441 + * @param {any} targetName - 目标字段
429 * @param {any} newValue - 修改新值 442 * @param {any} newValue - 修改新值
430 */ 443 */
431 -function modifyFieldValue(obj, fieldName, targetValue, newValue) { 444 +function modifyFieldValue(obj, fieldName, fieldValue, targetName, newValue) {
432 // 检查当前层级的字段值是否匹配目标值 445 // 检查当前层级的字段值是否匹配目标值
433 - if (obj[fieldName] === targetValue) { 446 + if (obj[fieldName] === fieldValue) {
434 - obj["checked"] = newValue; 447 + obj[targetName] = newValue;
435 } 448 }
436 449
437 // 遍历当前层级的子项(如果有) 450 // 遍历当前层级的子项(如果有)
438 for (var key in obj) { 451 for (var key in obj) {
439 if (typeof obj[key] === "object" && obj[key] !== null) { 452 if (typeof obj[key] === "object" && obj[key] !== null) {
440 - modifyFieldValue(obj[key], fieldName, targetValue, newValue); 453 + modifyFieldValue(obj[key], fieldName, fieldValue, targetName, newValue);
441 } 454 }
442 } 455 }
443 } 456 }
444 457
458 +/**
459 + * 操作勾选框回调
460 + *
461 + * @param {type} user - description of parameter
462 + * @param {type} checked - description of parameter
463 + * @return {type} description of return value
464 + */
445 const handleCheckedUserListChange = (user, checked) => { 465 const handleCheckedUserListChange = (user, checked) => {
446 - // 勾选用户回调
447 // 修改选中值状态 466 // 修改选中值状态
448 - modifyFieldValue(userTabs.value, "id", user.id, checked); 467 + modifyFieldValue(userTabs.value, "id", user.id, "checked", checked);
449 }; 468 };
450 469
451 /** 470 /**
452 - * 递归获取树形结构下的所有list字段数据 471 + * 递归获取树形结构下的所有 list 字段数据
453 * 472 *
454 * @param {Array} arr - The array to traverse. 473 * @param {Array} arr - The array to traverse.
455 * @return {Array} - The list items found. 474 * @return {Array} - The list items found.
...@@ -516,12 +535,17 @@ watch( ...@@ -516,12 +535,17 @@ watch(
516 { deep: true } 535 { deep: true }
517 ); 536 );
518 537
538 +/**
539 + * 移除 tags 成员标签回调
540 + *
541 + * @param {string} tag - The tag to be closed.
542 + * @return {undefined} No return value.
543 + */
519 const handleTagClose = tag => { 544 const handleTagClose = tag => {
520 - // 移除 tags 成员标签回调
521 userTags.value.splice(userTags.value.indexOf(tag), 1); // 删除标签列表中的项 545 userTags.value.splice(userTags.value.indexOf(tag), 1); // 删除标签列表中的项
522 // 移除数据结构中的选中值 546 // 移除数据结构中的选中值
523 - modifyFieldValue(userTabs.value, "id", tag.id, false); 547 + modifyFieldValue(userTabs.value, "id", tag.id, "checked", false);
524 - // 548 + // ID集合
525 let tagsId = userTags.value.map(ele => { 549 let tagsId = userTags.value.map(ele => {
526 return ele.id; 550 return ele.id;
527 }); 551 });
...@@ -544,27 +568,42 @@ const handleTagClose = tag => { ...@@ -544,27 +568,42 @@ const handleTagClose = tag => {
544 } 568 }
545 }; 569 };
546 570
571 +/**
572 + * 关闭用户列表表单回调
573 + *
574 + * @return {void} - No return value.
575 + */
547 const closeUserForm = () => { 576 const closeUserForm = () => {
548 - // 关闭用户列表表单回调
549 dialogUserFormVisible.value = false; 577 dialogUserFormVisible.value = false;
550 emit("close", dialogUserFormVisible.value); 578 emit("close", dialogUserFormVisible.value);
551 }; 579 };
580 +/**
581 + * 确认用户列表表单回调
582 + *
583 + * @return {void} No return value.
584 + */
552 const confirmUserForm = () => { 585 const confirmUserForm = () => {
553 - // 确认用户列表表单回调
554 dialogUserFormVisible.value = false; 586 dialogUserFormVisible.value = false;
555 - // console.log(userTags.value);
556 emit("close", dialogUserFormVisible.value); 587 emit("close", dialogUserFormVisible.value);
557 emit("confirm", userTags.value); 588 emit("confirm", userTags.value);
558 }; 589 };
559 590
591 +/**
592 + * 激活搜索按钮操作
593 + *
594 + * @return {void} No return value.
595 + */
560 const activeSearchBtn = () => { 596 const activeSearchBtn = () => {
561 - // 激活搜索按钮操作
562 is_active_search.value = !is_active_search.value; 597 is_active_search.value = !is_active_search.value;
563 searchUserList.value = []; // 清空搜索列表 598 searchUserList.value = []; // 清空搜索列表
564 }; 599 };
565 600
601 +/**
602 + * 在搜索框中同步显示tag框选中的用户
603 + *
604 + * @return {void}
605 + */
566 const checkSearchStatus = () => { 606 const checkSearchStatus = () => {
567 - // 在搜索框中同步显示tag框选中的用户
568 userTags.value.forEach(ele => { 607 userTags.value.forEach(ele => {
569 searchUserList.value.forEach(item => { 608 searchUserList.value.forEach(item => {
570 if (ele.id === item.id) { 609 if (ele.id === item.id) {
...@@ -577,8 +616,15 @@ const checkSearchStatus = () => { ...@@ -577,8 +616,15 @@ const checkSearchStatus = () => {
577 .filter(ele => ele.checked) 616 .filter(ele => ele.checked)
578 .map(ele => ele.id); 617 .map(ele => ele.id);
579 }; 618 };
619 +/**
620 + * 在搜索框中同步显示tag框选中的用户
621 + *
622 + * @param {Array} userTags - The array of selected user tags.
623 + * @param {Array} userList - The array of all users.
624 + * @param {Array} checkedUserList - The array of users with selected tags.
625 + * @return {void} No return value.
626 + */
580 const checkUserStatus = () => { 627 const checkUserStatus = () => {
581 - // 在搜索框中同步显示tag框选中的用户
582 userTags.value.forEach(ele => { 628 userTags.value.forEach(ele => {
583 userList.value.forEach(item => { 629 userList.value.forEach(item => {
584 if (ele.id === item.id) { 630 if (ele.id === item.id) {
...@@ -592,14 +638,22 @@ const checkUserStatus = () => { ...@@ -592,14 +638,22 @@ const checkUserStatus = () => {
592 .map(ele => ele.id); 638 .map(ele => ele.id);
593 }; 639 };
594 640
641 +/**
642 + * 清空搜索回调
643 + *
644 + * @return {void}
645 + */
595 const onClearSearch = () => { 646 const onClearSearch = () => {
596 - // 清空搜索回调
597 is_active_search.value = !is_active_search.value; 647 is_active_search.value = !is_active_search.value;
598 // 同步显示tag框选中的用户 648 // 同步显示tag框选中的用户
599 checkUserStatus(); 649 checkUserStatus();
600 }; 650 };
651 +/**
652 + * 搜索回调
653 + *
654 + * @return {void} No return value.
655 + */
601 const onSearch = () => { 656 const onSearch = () => {
602 - // 搜索回调
603 // TODO: 获取后台数据 657 // TODO: 获取后台数据
604 searchUserList.value = [ 658 searchUserList.value = [
605 { 659 {
......