cy-element-ui 1.1.26 → 1.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -605,7 +605,7 @@ __webpack_require__.r(__webpack_exports__);
605
605
  // EXPORTS
606
606
  __webpack_require__.d(__webpack_exports__, "TabDialogDirective", function() { return /* binding */ tabDialog_TabDialogDirective; });
607
607
 
608
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cy/tabDialog/src/main.vue?vue&type=template&id=1a478a44
608
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cy/tabDialog/src/main.vue?vue&type=template&id=509a6ce0
609
609
  var render = function () {
610
610
  var _vm = this
611
611
  var _h = _vm.$createElement
@@ -706,7 +706,7 @@ var staticRenderFns = []
706
706
  render._withStripped = true
707
707
 
708
708
 
709
- // CONCATENATED MODULE: ./packages/cy/tabDialog/src/main.vue?vue&type=template&id=1a478a44
709
+ // CONCATENATED MODULE: ./packages/cy/tabDialog/src/main.vue?vue&type=template&id=509a6ce0
710
710
 
711
711
  // EXTERNAL MODULE: ./packages/dialog/index.js + 5 modules
712
712
  var dialog = __webpack_require__(49);
@@ -764,7 +764,14 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
764
764
  //
765
765
  //
766
766
  //
767
+ //
768
+ //
769
+ //
770
+ //
771
+ //
772
+ //
767
773
 
774
+ // 引入 Element UI 底层 Dialog 组件(直接引用源码而非全量注册)
768
775
 
769
776
 
770
777
 
@@ -779,7 +786,7 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
779
786
  type: Boolean,
780
787
  default: false
781
788
  },
782
- // Dialog 的标题,也可通过具名 slot
789
+ // Dialog 的标题,也可通过具名 slot 自定义
783
790
  title: {
784
791
  type: String,
785
792
  default: ''
@@ -809,7 +816,7 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
809
816
  type: Boolean,
810
817
  default: false
811
818
  },
812
- // 是否在 Dialog 出现时将 body或上层 滚动锁定
819
+ // 是否在 Dialog 出现时将 body 或上层滚动锁定
813
820
  lockScroll: {
814
821
  type: Boolean,
815
822
  default: true
@@ -844,7 +851,7 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
844
851
  type: Boolean,
845
852
  default: false
846
853
  },
847
- // 是否放到tagsView中,即当前app-views下面,此属性true时,appendToBody无效
854
+ // 是否放到 tagsView 中(即当前 app-views 下面);此属性为 trueappendToBody 无效
848
855
  appendToTagsView: {
849
856
  type: Boolean,
850
857
  default: false
@@ -861,18 +868,21 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
861
868
  },
862
869
  data: function data() {
863
870
  return {
864
- // 判断dialog是否已经放到对应的div下
871
+ // 判断 dialog 是否已经放到对应的 div
865
872
  rendered: false,
873
+ // 自管遮罩层的 z-index
866
874
  modelZIndex: 1000,
875
+ // 自管遮罩层的高度(根据父容器动态计算)
867
876
  modelHeight: 0,
868
- // 当前app-views的dom元素
877
+ // 当前 app-views dom 元素
869
878
  parentDom: null,
870
- // 当前el-dialog的dom元素
879
+ // 当前 el-dialog dom 元素
871
880
  elDialogDom: null
872
881
  };
873
882
  },
874
883
 
875
884
  watch: {
885
+ // 监听 visible:控制 dialog 显示/隐藏、挂载位置、键盘事件、遮罩层级
876
886
  visible: {
877
887
  immediate: true,
878
888
  handler: function handler(val) {
@@ -882,20 +892,20 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
882
892
  this.$emit('open');
883
893
  external_vue_default.a.nextTick(function () {
884
894
  var dom = _this.$el;
885
- // 首次打开
895
+ // 首次打开时处理挂载位置
886
896
  if (!_this.rendered) {
887
897
  _this.rendered = true;
888
898
  if (_this.appendToTagsView) {
889
- // 将当前dialog挪到当前app-views里面 app-container
899
+ // 将当前 dialog 挪到当前 app-views 里面的 app-container
890
900
  _this.parentDom = dom.closest('.app-container');
891
901
  if (!_this.parentDom) _this.parentDom = document.body;
892
902
  _this.parentDom.append(dom);
893
903
  } else if (_this.appendToBody) {
894
- // 将当前dialog挪到当前body里面
904
+ // 将当前 dialog 挪到当前 body 里面
895
905
  _this.parentDom = document.body;
896
906
  _this.parentDom.append(dom);
897
907
  }
898
- // 添加键盘监听事件
908
+ // 添加键盘监听事件(用于 ESC 关闭)
899
909
  if (_this.closeOnPressEscape) {
900
910
  document.addEventListener('keydown', _this.escKeyDown);
901
911
  }
@@ -903,9 +913,9 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
903
913
 
904
914
  setTimeout(function () {
905
915
  if (_this.parentDom) _this.modelHeight = _this.parentDom.scrollHeight + 'px';
906
- // 当前VDialog不在body中时
916
+ // 当前 VDialog 不在 body 中时
907
917
  if (!_this.parentDom || _this.parentDom.tagName.toUpperCase() !== 'BODY') {
908
- // 获取el-dialog的宽度,如果大于app-views的宽度,则el-dialog不居中显示
918
+ // 获取 el-dialog 的宽度,如果大于 app-views 的宽度,则 el-dialog 不居中显示
909
919
  var elDialogWidth = dom.getElementsByClassName('el-dialog')[0].clientWidth;
910
920
  if (!_this.parentDom || elDialogWidth < _this.parentDom.clientWidth) {
911
921
  dom.getElementsByClassName('el-dialog')[0].style.left = '50%';
@@ -917,41 +927,70 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
917
927
  dom.getElementsByClassName('el-dialog')[0].style.marginTop = _this.top;
918
928
  }, 50);
919
929
 
920
- // 获取el-dialog的z-index,赋值给model,用于处理model的层级问题
930
+ // 获取 el-dialog z-index,赋值给 model,用于处理 model 的层级问题
921
931
  _this.elDialogDom = dom.children[1];
922
932
  setTimeout(function () {
923
933
  _this.modelZIndex = _this.elDialogDom.style.zIndex;
924
934
  }, 50);
925
935
  });
926
936
  } else {
927
- // immediate=true时,首次打开不需要触发close事件
937
+ // immediate=true 时,首次打开不需要触发 close 事件
928
938
  if (this.rendered) this.$emit('close');
929
939
  }
930
940
  }
931
941
  }
932
942
  },
933
943
  methods: {
944
+ /**
945
+ * 打开回调,透传 open 事件
946
+ * @fires {Event} open
947
+ * @returns {void}
948
+ */
934
949
  handleOpen: function handleOpen() {
935
950
  this.$emit('open');
936
951
  },
952
+
953
+
954
+ /**
955
+ * 打开动画结束回调,透传 opened 事件
956
+ * @fires {Event} opened
957
+ * @returns {void}
958
+ */
937
959
  handleOpened: function handleOpened() {
938
960
  this.$emit('opened');
939
961
  },
962
+
963
+
964
+ /**
965
+ * 关闭回调:同步 visible 并透传 close 事件
966
+ * @fires {Event} update:visible
967
+ * @fires {Event} close
968
+ * @returns {void}
969
+ */
940
970
  handleClose: function handleClose() {
941
971
  this.$emit('update:visible', false);
942
972
  this.$emit('close');
943
973
  },
974
+
975
+
976
+ /**
977
+ * 关闭动画结束回调,透传 closed 事件
978
+ * @fires {Event} closed
979
+ * @returns {void}
980
+ */
944
981
  handleClosed: function handleClosed() {
945
982
  this.$emit('closed');
946
983
  },
947
984
 
948
985
 
949
- /**
950
- * 监听esc
951
- */
986
+ /**
987
+ * 监听 esc 键,按层级优先级关闭最上层 dialog
988
+ * @param {KeyboardEvent} event - 键盘事件对象
989
+ * @returns {void}
990
+ */
952
991
  escKeyDown: function escKeyDown(event) {
953
992
  if (event.keyCode === 27) {
954
- // 获取body下的直接子节点中的已打开的vDialog
993
+ // 获取 body 下的直接子节点中的已打开的 VDialog
955
994
  var bodyVDialogDomArr = [];
956
995
  var bodyChildrenArr = document.body.childNodes;
957
996
  for (var i = 0; i < bodyChildrenArr.length; i++) {
@@ -960,23 +999,23 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
960
999
  bodyVDialogDomArr.push(item);
961
1000
  }
962
1001
  }
963
- // 判断body中是否有已打开的vDialog,如果有,优先关闭body下的vDialog
1002
+ // 判断 body 中是否有已打开的 VDialog,如果有,优先关闭 body 下的 VDialog
964
1003
  if (bodyVDialogDomArr.length > 0) {
965
- // 获取当前cy-tab-dialog在当前body中的下标
1004
+ // 获取当前 cy-tab-dialog 在当前 body 中的下标
966
1005
  var curDomIndex = [].indexOf.call(bodyVDialogDomArr, this.$el);
967
1006
  if (curDomIndex === bodyVDialogDomArr.length - 1) {
968
1007
  this.handleClose();
969
1008
  }
970
1009
  } else if (document.getElementById('tags-view-container') && this.parentDom.parentElement.getAttribute('include_name')) {
971
- // 获取当前app-views对应的include_name值
1010
+ // 获取当前 app-views 对应的 include_name
972
1011
  var includeName = this.parentDom.parentElement.getAttribute('include_name');
973
- // 根据includeName获取tagsView中的tag标签页
1012
+ // 根据 includeName 获取 tagsView 中的 tag 标签页
974
1013
  var tagDom = document.getElementById('tags-view-container').querySelectorAll('[include_name=' + includeName + ']');
975
1014
  if (tagDom && tagDom[0]) {
976
- // 判断此标签页是否为选中状态,只有选中状态中的vDialog才可以进行关闭
1015
+ // 判断此标签页是否为选中状态,只有选中状态中的 VDialog 才可以进行关闭
977
1016
  if (tagDom[0].className.split(' ').includes('active')) {
978
1017
  var vDialogList = this.parentDom.getElementsByClassName('cy-tab-dialog-opened');
979
- // 获取当前cy-tab-dialog在当前app-views中的下标
1018
+ // 获取当前 cy-tab-dialog 在当前 app-views 中的下标
980
1019
  var _curDomIndex = [].indexOf.call(vDialogList, this.$el);
981
1020
  if (_curDomIndex === vDialogList.length - 1) {
982
1021
  this.handleClose();
@@ -989,6 +1028,11 @@ var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_);
989
1028
  }
990
1029
  }
991
1030
  },
1031
+
1032
+ /**
1033
+ * 组件销毁前移除键盘监听,避免内存泄漏
1034
+ * @returns {void}
1035
+ */
992
1036
  beforeDestroy: function beforeDestroy() {
993
1037
  document.removeEventListener('keydown', this.escKeyDown);
994
1038
  }
@@ -213,7 +213,7 @@ module.exports = require("element-ui/lib/utils/shared");
213
213
  // ESM COMPAT FLAG
214
214
  __webpack_require__.r(__webpack_exports__);
215
215
 
216
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cy/treeSelect/src/main.vue?vue&type=template&id=5e4054a3
216
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/cy/treeSelect/src/main.vue?vue&type=template&id=7e2add3e
217
217
  var render = function () {
218
218
  var _vm = this
219
219
  var _h = _vm.$createElement
@@ -273,7 +273,7 @@ var render = function () {
273
273
  1
274
274
  )
275
275
  : _vm._e(),
276
- _vm.showCheckStrictly
276
+ _vm.showCheckStrictly && _vm.multiple
277
277
  ? _c(
278
278
  "div",
279
279
  { staticClass: "cy-tree-select-select-con-t" },
@@ -304,9 +304,9 @@ var render = function () {
304
304
  attrs: {
305
305
  data: _vm.treeOptions,
306
306
  "show-checkbox": _vm.multiple,
307
- "node-key": _vm.defaultOptions.id,
307
+ "node-key": _vm.treeFieldMap.id,
308
308
  "check-strictly": !_vm.isCheckStrictly,
309
- props: _vm.defaultOptions,
309
+ props: _vm.treeFieldMap,
310
310
  "expand-on-click-node": false,
311
311
  "default-expand-all": _vm.defaultExpandAll,
312
312
  "filter-node-method": _vm.filterNode,
@@ -339,7 +339,7 @@ var render = function () {
339
339
  _vm._s(
340
340
  _vm.checkedArr
341
341
  .map(function (item) {
342
- return item[_vm.defaultOptions.label]
342
+ return item[_vm.treeFieldMap.label]
343
343
  })
344
344
  .join()
345
345
  )
@@ -391,7 +391,7 @@ var staticRenderFns = []
391
391
  render._withStripped = true
392
392
 
393
393
 
394
- // CONCATENATED MODULE: ./packages/cy/treeSelect/src/main.vue?vue&type=template&id=5e4054a3
394
+ // CONCATENATED MODULE: ./packages/cy/treeSelect/src/main.vue?vue&type=template&id=7e2add3e
395
395
 
396
396
  // EXTERNAL MODULE: ./packages/checkbox/index.js + 5 modules
397
397
  var packages_checkbox = __webpack_require__(16);
@@ -455,7 +455,17 @@ var tree = __webpack_require__(46);
455
455
  //
456
456
  //
457
457
  //
458
+ //
459
+ //
460
+ //
461
+ //
462
+ //
463
+ //
464
+ //
465
+ //
466
+ //
458
467
 
468
+ // 引入 Element UI 底层组件,避免走全量注册
459
469
 
460
470
 
461
471
 
@@ -469,55 +479,66 @@ var tree = __webpack_require__(46);
469
479
  ElInput: input["default"],
470
480
  ElTree: tree["default"]
471
481
  },
482
+ // 自定义 v-model:使用 value 作为 prop,change 作为回调事件
472
483
  model: {
473
484
  prop: 'value',
474
485
  event: 'change'
475
486
  },
476
487
  props: {
488
+ // 绑定值:单选时为节点 id(String/Number),多选时为 id 数组
477
489
  value: {
478
490
  type: [String, Number, Array],
479
491
  default: ''
480
492
  },
481
493
 
494
+ // 树形数据源(children 嵌套结构)
482
495
  options: {
483
496
  type: Array,
484
497
  default: []
485
498
  },
486
499
 
500
+ // 未选中时的占位提示文本
487
501
  placeholder: {
488
502
  type: String,
489
503
  default: ''
490
504
  },
491
505
 
506
+ // 组件尺寸(medium / small / mini)
492
507
  size: {
493
508
  type: String
494
509
  },
495
510
 
511
+ // 是否显示搜索过滤输入框
496
512
  filterable: {
497
513
  type: Boolean,
498
514
  default: false
499
515
  },
500
516
 
517
+ // 是否显示「父子节点联动」开关
501
518
  showCheckStrictly: {
502
519
  type: Boolean,
503
520
  default: true
504
521
  },
505
522
 
523
+ // 父子节点是否互相关联(默认联动)
506
524
  checkStrictly: {
507
525
  type: Boolean,
508
526
  default: true
509
527
  },
510
528
 
529
+ // 是否显示清空按钮
511
530
  clearable: {
512
531
  type: Boolean,
513
532
  default: false
514
533
  },
515
534
 
535
+ // 是否多选模式(多选时树节点带 checkbox)
516
536
  multiple: {
517
537
  type: Boolean,
518
538
  default: false
519
539
  },
520
540
 
541
+ // 树节点字段映射配置:指定 id / label / children 对应的字段名
521
542
  defaultOptions: {
522
543
  type: Object,
523
544
  default: function _default() {
@@ -529,16 +550,19 @@ var tree = __webpack_require__(46);
529
550
  }
530
551
  },
531
552
 
553
+ // 触发区域(reference)的自定义样式
532
554
  vStyle: {
533
555
  type: [Array, String, Object],
534
556
  default: ''
535
557
  },
536
558
 
559
+ // 弹出层自定义类名
537
560
  popperClass: {
538
561
  type: String,
539
562
  default: ''
540
563
  },
541
564
 
565
+ // 是否默认展开所有节点
542
566
  defaultExpandAll: {
543
567
  type: Boolean,
544
568
  default: false
@@ -546,18 +570,40 @@ var tree = __webpack_require__(46);
546
570
  },
547
571
  data: function data() {
548
572
  return {
573
+ // 当前是否父子联动(受 checkStrictly 控制)
549
574
  isCheckStrictly: true,
575
+ // 弹出层是否展开
550
576
  popoverOpen: false,
577
+ // 鼠标是否悬浮在图标区(控制清空/箭头图标切换)
551
578
  isClearIcon: false,
552
579
 
580
+ // 原始树数据(来自 options)
553
581
  treeOptions: [],
582
+ // 扁平化后的树数据(便于按 id 反查节点)
554
583
  treeArr: [],
584
+ // 搜索关键字
555
585
  filterText: '',
586
+ // 搜索命中的节点 id 集合
556
587
  matchedNodeIds: []
557
588
  };
558
589
  },
559
590
 
560
591
  computed: {
592
+ /**
593
+ * 字段映射配置:将用户传入的 defaultOptions 与默认值合并,
594
+ * 保证 children / label / id 三个 key 始终存在,
595
+ * 避免只传部分字段时取到的 key 为 undefined 而导致层级/选中/搜索失效
596
+ * @returns {Object} 合并后的字段映射
597
+ */
598
+ treeFieldMap: function treeFieldMap() {
599
+ return Object.assign({ children: 'children', label: 'label', id: 'id' }, this.defaultOptions);
600
+ },
601
+
602
+
603
+ /**
604
+ * 根据 value 反查当前选中节点对象数组,用于回显文本
605
+ * @returns {Array} 选中节点对象数组
606
+ */
561
607
  checkedArr: function checkedArr() {
562
608
  var _this = this;
563
609
 
@@ -565,20 +611,21 @@ var tree = __webpack_require__(46);
565
611
  var arr = [];
566
612
  this.value && this.value.forEach(function (id) {
567
613
  var cItem = _this.treeArr.filter(function (tItem) {
568
- return tItem[_this.defaultOptions.id] === id;
614
+ return tItem[_this.treeFieldMap.id] === id;
569
615
  })[0];
570
616
  if (cItem) arr.push(cItem);
571
617
  });
572
618
  return arr;
573
619
  } else {
574
620
  var cItem = this.treeArr.filter(function (tItem) {
575
- return tItem[_this.defaultOptions.id] === Number(_this.value);
621
+ return tItem[_this.treeFieldMap.id] === Number(_this.value);
576
622
  })[0];
577
623
  return cItem ? [cItem] : [];
578
624
  }
579
625
  }
580
626
  },
581
627
  watch: {
628
+ // 监听 checkStrictly:同步到内部状态 isCheckStrictly
582
629
  checkStrictly: {
583
630
  immediate: true,
584
631
  handler: function handler() {
@@ -586,6 +633,7 @@ var tree = __webpack_require__(46);
586
633
  }
587
634
  },
588
635
 
636
+ // 监听 value:变化时重新设置树节点的勾选状态
589
637
  value: {
590
638
  immediate: true,
591
639
  deep: true,
@@ -598,6 +646,7 @@ var tree = __webpack_require__(46);
598
646
  }
599
647
  },
600
648
 
649
+ // 监听 options:数据变化时重新扁平化
601
650
  options: {
602
651
  deep: true,
603
652
  immediate: true,
@@ -607,6 +656,7 @@ var tree = __webpack_require__(46);
607
656
  }
608
657
  },
609
658
 
659
+ // 监听搜索关键字:过滤树节点并自动展开命中节点
610
660
  filterText: function filterText(val) {
611
661
  var _this3 = this;
612
662
 
@@ -625,10 +675,25 @@ var tree = __webpack_require__(46);
625
675
  created: function created() {},
626
676
 
627
677
  methods: {
678
+ /**
679
+ * 树节点过滤方法:根据命中 id 集合决定节点是否显示
680
+ * @param {*} value - 搜索关键字
681
+ * @param {Object} data - 当前树节点数据
682
+ * @returns {boolean}
683
+ */
628
684
  filterNode: function filterNode(value, data) {
629
685
  if (!value) return true;
630
- return this.matchedNodeIds.includes(data[this.defaultOptions.id]);
686
+ return this.matchedNodeIds.includes(data[this.treeFieldMap.id]);
631
687
  },
688
+
689
+
690
+ /**
691
+ * 递归查找名称包含关键字的节点 id(父节点命中则连带子节点)
692
+ * @param {*} value - 搜索关键字
693
+ * @param {Array} nodes - 待查找的树节点数组
694
+ * @param {boolean} [parentMatched=false] - 父节点是否已命中
695
+ * @returns {Array<number>} 命中节点 id 集合
696
+ */
632
697
  findMatchedNodes: function findMatchedNodes(value, nodes) {
633
698
  var _this4 = this;
634
699
 
@@ -637,21 +702,27 @@ var tree = __webpack_require__(46);
637
702
  var matchedIds = [];
638
703
 
639
704
  nodes.forEach(function (node) {
640
- var currentNodeMatched = node[_this4.defaultOptions.label].indexOf(value) !== -1;
705
+ var currentNodeMatched = node[_this4.treeFieldMap.label].indexOf(value) !== -1;
641
706
  var shouldShow = currentNodeMatched || parentMatched;
642
707
 
643
708
  if (shouldShow) {
644
- matchedIds.push(node[_this4.defaultOptions.id]);
709
+ matchedIds.push(node[_this4.treeFieldMap.id]);
645
710
  }
646
711
 
647
- if (node[_this4.defaultOptions.children] && node[_this4.defaultOptions.children].length > 0) {
648
- var childIds = _this4.findMatchedNodes(value, node[_this4.defaultOptions.children], shouldShow);
712
+ if (node[_this4.treeFieldMap.children] && node[_this4.treeFieldMap.children].length > 0) {
713
+ var childIds = _this4.findMatchedNodes(value, node[_this4.treeFieldMap.children], shouldShow);
649
714
  matchedIds = matchedIds.concat(childIds);
650
715
  }
651
716
  });
652
717
 
653
718
  return matchedIds;
654
719
  },
720
+
721
+
722
+ /**
723
+ * 将搜索命中的节点自动展开
724
+ * @returns {void}
725
+ */
655
726
  expandMatchedNodes: function expandMatchedNodes() {
656
727
  var _this5 = this;
657
728
 
@@ -662,6 +733,12 @@ var tree = __webpack_require__(46);
662
733
  }
663
734
  });
664
735
  },
736
+
737
+
738
+ /**
739
+ * 根据 value 初始化树节点勾选状态(单选/多选分别处理)
740
+ * @returns {void}
741
+ */
665
742
  init: function init() {
666
743
  var _this6 = this;
667
744
 
@@ -675,6 +752,16 @@ var tree = __webpack_require__(46);
675
752
  _this6.$refs.tree.setCheckedKeys(arr);
676
753
  });
677
754
  },
755
+
756
+
757
+ /**
758
+ * 多选时勾选变化回调:向外 emit 选中 id 数组及节点数组
759
+ * @param {*} value - el-tree 回调的勾选节点数据
760
+ * @param checkedKeys
761
+ * @param {Object} checkedNodes - 选中节点对象数组
762
+ * @fires {Event} change
763
+ * @returns {void}
764
+ */
678
765
  treeCheck: function treeCheck(value, _ref) {
679
766
  var _this7 = this;
680
767
 
@@ -684,31 +771,57 @@ var tree = __webpack_require__(46);
684
771
  var arr = [];
685
772
  arr = checkedNodes;
686
773
  var idArr = arr.map(function (item) {
687
- return item[_this7.defaultOptions.id];
774
+ return item[_this7.treeFieldMap.id];
688
775
  });
689
776
  this.$emit('change', this.multiple ? idArr : idArr[0], this.multiple ? arr : arr[0]);
690
777
  },
778
+
779
+
780
+ /**
781
+ * 单选时点击节点回调:直接选中并关闭弹出层
782
+ * @param {Object} value - 当前点击的树节点对象
783
+ * @param {Object} node - 节点对象
784
+ * @param {Object} event - 点击事件对象
785
+ * @fires {Event} change
786
+ * @returns {void}
787
+ */
691
788
  treeClick: function treeClick(value, node, event) {
692
789
  if (this.multiple) return;
693
790
 
694
- this.$emit('change', value.id, value);
791
+ this.$emit('change', value[this.treeFieldMap.id], value);
695
792
  this.popoverOpen = false;
696
793
  },
794
+
795
+
796
+ /**
797
+ * 清空选择:emit 空值并清空树勾选
798
+ * @fires {Event} change
799
+ * @returns {void}
800
+ */
697
801
  handleClear: function handleClear() {
698
802
  this.$emit('change', this.multiple ? [] : '', this.multiple ? [] : null);
699
803
  this.$refs.tree.setCheckedKeys([]);
700
804
  },
805
+
806
+
807
+ /**
808
+ * 将嵌套树数据拍平为一维数组,并补充父节点 id(pId)便于反查
809
+ * @param {Array} arr - 输出的一维数组(原地收集)
810
+ * @param {Array} data - 当前层级的树节点数组
811
+ * @param {number} pId - 父节点 id
812
+ * @returns {Array} 拍平后的一维节点数组
813
+ */
701
814
  turnFormatTreeData: function turnFormatTreeData(arr, data, pId) {
702
815
  var _this8 = this;
703
816
 
704
817
  data.forEach(function (item) {
705
818
  var cItem = JSON.parse(JSON.stringify(item));
706
- delete cItem[_this8.defaultOptions.children];
819
+ delete cItem[_this8.treeFieldMap.children];
707
820
  cItem.pId = pId;
708
821
  arr.push(cItem);
709
822
 
710
- if (item[_this8.defaultOptions.children] && item[_this8.defaultOptions.children].length > 0) {
711
- _this8.turnFormatTreeData(arr, item[_this8.defaultOptions.children], item[_this8.defaultOptions.id]);
823
+ if (item[_this8.treeFieldMap.children] && item[_this8.treeFieldMap.children].length > 0) {
824
+ _this8.turnFormatTreeData(arr, item[_this8.treeFieldMap.children], item[_this8.treeFieldMap.id]);
712
825
  }
713
826
  });
714
827
  return arr;