widget.qw 1.1.0 → 1.1.2

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.
package/build/style.css CHANGED
@@ -675,25 +675,25 @@
675
675
  margin:3px;
676
676
  }
677
677
 
678
- .cascader-pop[data-v-27ca3ce1] {
678
+ .cascader-pop[data-v-36e65e12] {
679
679
  width: 100%;
680
680
  overflow: hidden;
681
681
  }
682
- .cascader-selector[data-v-27ca3ce1] {
682
+ .cascader-selector[data-v-36e65e12] {
683
683
  padding: 10px;
684
684
  }
685
- .search-buttons[data-v-27ca3ce1] {
685
+ .search-buttons[data-v-36e65e12] {
686
686
  display: flex;
687
687
  gap: 10px;
688
688
  }
689
- .clear-btn[data-v-27ca3ce1] {
689
+ .clear-btn[data-v-36e65e12] {
690
690
  background-color: #f2f3f5;
691
691
  border: none;
692
692
  border-radius: 4px;
693
693
  padding: 4px 8px;
694
694
  font-size: 14px;
695
695
  }
696
- .confirm-btn[data-v-27ca3ce1] {
696
+ .confirm-btn[data-v-36e65e12] {
697
697
  background-color: #1989fa;
698
698
  color: white;
699
699
  border: none;
@@ -701,19 +701,19 @@
701
701
  padding: 4px 8px;
702
702
  font-size: 14px;
703
703
  }
704
- .no-results[data-v-27ca3ce1] {
704
+ .no-results[data-v-36e65e12] {
705
705
  text-align: center;
706
706
  padding: 20px;
707
707
  color: #969799;
708
708
  }
709
- .cascader-header[data-v-27ca3ce1] {
709
+ .cascader-header[data-v-36e65e12] {
710
710
  padding: 10px;
711
711
  border-bottom: 1px solid #ebedf0;
712
712
  display: flex;
713
713
  justify-content: space-between;
714
714
  align-items: center;
715
715
  }
716
- .current-path[data-v-27ca3ce1] {
716
+ .current-path[data-v-36e65e12] {
717
717
  flex: 1;
718
718
  font-size: 14px;
719
719
  margin-left: 5px;
@@ -722,25 +722,25 @@
722
722
  overflow: hidden;
723
723
  text-overflow: ellipsis;
724
724
  }
725
- .header-right[data-v-27ca3ce1] {
725
+ .header-right[data-v-36e65e12] {
726
726
  display: flex;
727
727
  gap: 8px;
728
728
  margin-left: auto;
729
729
  }
730
- .cancel-btn[data-v-27ca3ce1] {
730
+ .cancel-btn[data-v-36e65e12] {
731
731
  color: #969799;
732
732
  margin-right: 5px;
733
733
  }
734
- .scroll-container[data-v-27ca3ce1] {
734
+ .scroll-container[data-v-36e65e12] {
735
735
  height: calc(80vh - 150px);
736
736
  overflow-y: auto;
737
737
  }
738
- .cell-content[data-v-27ca3ce1] {
738
+ .cell-content[data-v-36e65e12] {
739
739
  display: flex;
740
740
  align-items: center;
741
741
  gap: 12px;
742
742
  }
743
- .circle-selector[data-v-27ca3ce1] {
743
+ .circle-selector[data-v-36e65e12] {
744
744
  width: 20px;
745
745
  height: 20px;
746
746
  border-radius: 50%;
@@ -750,29 +750,29 @@
750
750
  transition: all 0.2s;
751
751
  flex-shrink: 0;
752
752
  }
753
- .circle-selector.selected[data-v-27ca3ce1] {
753
+ .circle-selector.selected[data-v-36e65e12] {
754
754
  background-color: #1989fa;
755
755
  border-color: #1989fa;
756
756
  }
757
- .circle-selector.selected .van-icon[data-v-27ca3ce1] {
757
+ .circle-selector.selected .van-icon[data-v-36e65e12] {
758
758
  color: white;
759
759
  font-size: 14px;
760
760
  }
761
- .van-cell__right-icon[data-v-27ca3ce1] {
761
+ .van-cell__right-icon[data-v-36e65e12] {
762
762
  color: #969799;
763
763
  font-size: 16px;
764
764
  margin-left: 8px;
765
765
  }
766
- .name[data-v-27ca3ce1] {
766
+ .name[data-v-36e65e12] {
767
767
  flex: 1;
768
768
  overflow: hidden;
769
769
  text-overflow: ellipsis;
770
770
  white-space: nowrap;
771
771
  }
772
- .cancel-btn[data-v-27ca3ce1] {
772
+ .cancel-btn[data-v-36e65e12] {
773
773
  color: #969799;
774
774
  }
775
- .search-field[data-v-27ca3ce1] {
775
+ .search-field[data-v-36e65e12] {
776
776
  background: #fff;
777
777
  padding: 10px 16px;
778
778
  border-bottom: 1px solid #ebedf0;
@@ -38,7 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  step((generator = generator.apply(__this, __arguments)).next());
39
39
  });
40
40
  };
41
- import { computed, resolveComponent, openBlock, createElementBlock, unref, createVNode, createCommentVNode, createElementVNode, toDisplayString, onUnmounted, onDeactivated, isRef, watch, onMounted, nextTick, onActivated, ref, reactive, getCurrentInstance, provide, inject, isVNode, defineComponent, onBeforeUnmount, watchEffect, mergeProps, Transition, Teleport, withDirectives, vShow, Fragment, createApp, resolveDirective, createBlock, withCtx, renderList, createTextVNode, createSlots, withModifiers, onBeforeUpdate, normalizeClass, renderSlot } from "vue";
41
+ import { computed, resolveComponent, openBlock, createElementBlock, unref, createVNode, createCommentVNode, createElementVNode, toDisplayString, onUnmounted, onDeactivated, isRef, watch, onMounted, nextTick, onActivated, ref, reactive, getCurrentInstance, provide, inject, isVNode, defineComponent, onBeforeUnmount, watchEffect, mergeProps, Transition, Teleport, withDirectives, vShow, Fragment, createApp, resolveDirective, createBlock, withCtx, renderList, createTextVNode, createSlots, withModifiers, onBeforeUpdate, normalizeClass, renderSlot, pushScopeId, popScopeId } from "vue";
42
42
  var vm = {};
43
43
  var HeadBar_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.enterprise-header[data-v-435ecee6] {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n height: 48px;\r\n background-color: #2d8cf0; /* \u4F01\u4E1A\u5FAE\u4FE1\u98CE\u683C\u84DD\u8272 */\r\n background-color: #fff;\r\n color: white;\r\n color: #000;\r\n position: relative;\r\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);\r\n margin-bottom: 4px;\n}\n.header-title[data-v-435ecee6] {\r\n font-size: 14px;\r\n font-weight: 500;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n max-width: 70%;\n}\n.header-btn[data-v-435ecee6] {\r\n position: absolute;\r\n width: 48px;\r\n height: 48px;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n background: transparent;\r\n border: none;\r\n color: white;\r\n color: #000;\r\n font-size: 20px;\r\n cursor: pointer;\r\n padding: 0;\n}\n.header-btn[data-v-435ecee6]:disabled {\r\n opacity: 0.5;\r\n cursor: not-allowed;\n}\n.back-btn[data-v-435ecee6] {\r\n left: 0;\n}\n.home-btn[data-v-435ecee6] {\r\n right: 0;\n}\r\n \r\n \r\n ")();
44
44
  var _export_sfc = (sfc, props2) => {
@@ -6255,12 +6255,32 @@ function uniqCode(arr) {
6255
6255
  }
6256
6256
  return Array.from(uniqueMap.values());
6257
6257
  }
6258
+ function uniqMerge(arr1, arr2) {
6259
+ let totalArr = [...arr1, ...arr2];
6260
+ return uniq(totalArr);
6261
+ }
6262
+ function substractAry(arr1, arr2) {
6263
+ if (!Array.isArray(arr2) || !arr2 || arr2.length < 1)
6264
+ return arr1;
6265
+ return arr1.filter((item) => !arr2.includes(item));
6266
+ }
6267
+ function isContainAry(arr1, arr2) {
6268
+ if (!Array.isArray(arr1) || !Array.isArray(arr2))
6269
+ return false;
6270
+ if (arr2.length === 0)
6271
+ return true;
6272
+ const set2 = new Set(arr1);
6273
+ return arr2.every((item) => set2.has(item));
6274
+ }
6258
6275
  var ArrayUtil = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6259
6276
  __proto__: null,
6260
6277
  arySwapPrev,
6261
6278
  arySwapNext,
6262
6279
  uniq,
6263
- uniqCode
6280
+ uniqCode,
6281
+ uniqMerge,
6282
+ substractAry,
6283
+ isContainAry
6264
6284
  }, Symbol.toStringTag, { value: "Module" }));
6265
6285
  function fittingString(str, maxWidth, fontSize) {
6266
6286
  var fontWidth = fontSize * 1.3;
@@ -19521,8 +19541,8 @@ const _hoisted_10$1 = /* @__PURE__ */ createTextVNode(" \u5168\u9009 ");
19521
19541
  const _hoisted_11$1 = {
19522
19542
  class: "search-container"
19523
19543
  };
19524
- const _hoisted_12 = /* @__PURE__ */ createTextVNode("\u641C\u7D22");
19525
- const _hoisted_13 = {
19544
+ const _hoisted_12$1 = /* @__PURE__ */ createTextVNode("\u641C\u7D22");
19545
+ const _hoisted_13$1 = {
19526
19546
  class: "scroll-container"
19527
19547
  };
19528
19548
  const _sfc_main$h = {
@@ -19938,9 +19958,9 @@ const _sfc_main$h = {
19938
19958
  onClick: searchUserById,
19939
19959
  class: "search-btn"
19940
19960
  }, {
19941
- default: withCtx(() => [_hoisted_12]),
19961
+ default: withCtx(() => [_hoisted_12$1]),
19942
19962
  _: 1
19943
- })]), createElementVNode("div", _hoisted_13, [!searchUserId.value && currentDepartments.value.length > 0 ? (openBlock(), createBlock(_component_van_cell_group, {
19963
+ })]), createElementVNode("div", _hoisted_13$1, [!searchUserId.value && currentDepartments.value.length > 0 ? (openBlock(), createBlock(_component_van_cell_group, {
19944
19964
  key: 0
19945
19965
  }, {
19946
19966
  default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(currentDepartments.value, (dept) => {
@@ -21615,7 +21635,8 @@ const _sfc_main$4 = {
21615
21635
  }
21616
21636
  };
21617
21637
  var TreePicker = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ebc14630"]]);
21618
- var CascaderPop_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.cascader-pop[data-v-27ca3ce1] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.cascader-selector[data-v-27ca3ce1] {\r\n padding: 10px;\n}\n.search-buttons[data-v-27ca3ce1] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-27ca3ce1] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-27ca3ce1] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-27ca3ce1] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.cascader-header[data-v-27ca3ce1] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-27ca3ce1] {\r\n flex: 1;\r\n font-size: 14px;\r\n margin-left: 5px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-27ca3ce1] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-27ca3ce1] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-27ca3ce1] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\n.cell-content[data-v-27ca3ce1] {\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\n}\n.circle-selector[data-v-27ca3ce1] {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: all 0.2s;\r\n flex-shrink: 0;\n}\n.circle-selector.selected[data-v-27ca3ce1] {\r\n background-color: #1989fa;\r\n border-color: #1989fa;\n}\n.circle-selector.selected .van-icon[data-v-27ca3ce1] {\r\n color: white;\r\n font-size: 14px;\n}\n.van-cell__right-icon[data-v-27ca3ce1] {\r\n color: #969799;\r\n font-size: 16px;\r\n margin-left: 8px;\n}\n.name[data-v-27ca3ce1] {\r\n flex: 1;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\n}\n.cancel-btn[data-v-27ca3ce1] {\r\n color: #969799;\n}\n.search-field[data-v-27ca3ce1] {\r\n background: #fff;\r\n padding: 10px 16px;\r\n border-bottom: 1px solid #ebedf0;\r\n position: sticky;\r\n top: 0;\r\n z-index: 999;\r\n margin-bottom: 10px;\r\n flex-shrink: 0;\r\n /* \u9632\u6B62\u538B\u7F29 */\n}\r\n")();
21638
+ var CascaderPop_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.cascader-pop[data-v-36e65e12] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.cascader-selector[data-v-36e65e12] {\r\n padding: 10px;\n}\n.search-buttons[data-v-36e65e12] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-36e65e12] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-36e65e12] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-36e65e12] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.cascader-header[data-v-36e65e12] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-36e65e12] {\r\n flex: 1;\r\n font-size: 14px;\r\n margin-left: 5px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-36e65e12] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-36e65e12] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-36e65e12] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\n.cell-content[data-v-36e65e12] {\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\n}\n.circle-selector[data-v-36e65e12] {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: all 0.2s;\r\n flex-shrink: 0;\n}\n.circle-selector.selected[data-v-36e65e12] {\r\n background-color: #1989fa;\r\n border-color: #1989fa;\n}\n.circle-selector.selected .van-icon[data-v-36e65e12] {\r\n color: white;\r\n font-size: 14px;\n}\n.van-cell__right-icon[data-v-36e65e12] {\r\n color: #969799;\r\n font-size: 16px;\r\n margin-left: 8px;\n}\n.name[data-v-36e65e12] {\r\n flex: 1;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\n}\n.cancel-btn[data-v-36e65e12] {\r\n color: #969799;\n}\n.search-field[data-v-36e65e12] {\r\n background: #fff;\r\n padding: 10px 16px;\r\n border-bottom: 1px solid #ebedf0;\r\n position: sticky;\r\n top: 0;\r\n z-index: 999;\r\n margin-bottom: 10px;\r\n flex-shrink: 0;\r\n /* \u9632\u6B62\u538B\u7F29 */\n}\r\n")();
21639
+ const _withScopeId = (n) => (pushScopeId("data-v-36e65e12"), n = n(), popScopeId(), n);
21619
21640
  const _hoisted_1$3 = {
21620
21641
  class: "cascader-selector"
21621
21642
  };
@@ -21640,7 +21661,14 @@ const _hoisted_9$1 = {
21640
21661
  class: "cell-content"
21641
21662
  };
21642
21663
  const _hoisted_10 = ["onClick"];
21643
- const _hoisted_11 = {
21664
+ const _hoisted_11 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", {
21665
+ class: "name"
21666
+ }, "\u5168\u9009", -1));
21667
+ const _hoisted_12 = {
21668
+ class: "cell-content"
21669
+ };
21670
+ const _hoisted_13 = ["onClick"];
21671
+ const _hoisted_14 = {
21644
21672
  class: "name"
21645
21673
  };
21646
21674
  const _sfc_main$3 = {
@@ -21685,6 +21713,25 @@ const _sfc_main$3 = {
21685
21713
  keyword: "",
21686
21714
  selectedNodeIds: []
21687
21715
  });
21716
+ const isSelectAll = computed({
21717
+ get() {
21718
+ let optionIds = optionNodes.value.filter((item) => item.canCheck).map((item) => item.id);
21719
+ if (optionIds.length < 1)
21720
+ return false;
21721
+ return util.isContainAry(data2.selectedNodeIds, optionIds);
21722
+ },
21723
+ set(val) {
21724
+ let optionIds = optionNodes.value.filter((item) => item.canCheck).map((item) => item.id);
21725
+ if (val) {
21726
+ data2.selectedNodeIds = util.uniqMerge(data2.selectedNodeIds, optionIds);
21727
+ } else {
21728
+ data2.selectedNodeIds = util.substractAry(data2.selectedNodeIds, optionIds);
21729
+ }
21730
+ }
21731
+ });
21732
+ const onToggleAll = () => {
21733
+ isSelectAll.value = !isSelectAll.value;
21734
+ };
21688
21735
  onMounted(() => {
21689
21736
  });
21690
21737
  const optionNodes = computed(() => {
@@ -21770,8 +21817,12 @@ const _sfc_main$3 = {
21770
21817
  const onToggle = (node) => {
21771
21818
  if (data2.selectedNodeIds.includes(node.id))
21772
21819
  data2.selectedNodeIds = data2.selectedNodeIds.filter((item) => item != node.id);
21773
- else
21774
- data2.selectedNodeIds.push(node.id);
21820
+ else {
21821
+ if (props2.multiple)
21822
+ data2.selectedNodeIds.push(node.id);
21823
+ else
21824
+ data2.selectedNodeIds = [node.id];
21825
+ }
21775
21826
  };
21776
21827
  const onNextLevel = (node) => {
21777
21828
  props2.idQueryNode({
@@ -21783,15 +21834,6 @@ const _sfc_main$3 = {
21783
21834
  });
21784
21835
  };
21785
21836
  const query = () => __async(this, null, function* () {
21786
- if (!props2.multiple) {
21787
- if (modelValue2.value)
21788
- data2.selectedNodeIds = [modelValue2.value];
21789
- else
21790
- data2.selectedNodeIds = [];
21791
- } else if (modelValue2.value && modelValue2.value.length > 0)
21792
- data2.selectedNodeIds = modelValue2.value;
21793
- else
21794
- data2.selectedNodeIds = [];
21795
21837
  let params = {};
21796
21838
  if (data2.selectedNodeIds.length > 0)
21797
21839
  params.id = data2.selectedNodeIds[0];
@@ -21802,7 +21844,17 @@ const _sfc_main$3 = {
21802
21844
  data2.parentNode = node;
21803
21845
  });
21804
21846
  });
21805
- watch(() => [modelValue2.value, props2.show], (n, o) => __async(this, null, function* () {
21847
+ watch(() => [props2.show], (n, o) => __async(this, null, function* () {
21848
+ if (!props2.show)
21849
+ return;
21850
+ if (!props2.multiple) {
21851
+ data2.selectedNodeIds = [modelValue2.value];
21852
+ } else {
21853
+ if (modelValue2.value && modelValue2.value.length > 0)
21854
+ data2.selectedNodeIds = modelValue2.value;
21855
+ else
21856
+ data2.selectedNodeIds = [];
21857
+ }
21806
21858
  query();
21807
21859
  }), {
21808
21860
  immediate: true
@@ -21854,11 +21906,29 @@ const _sfc_main$3 = {
21854
21906
  }, "\u641C\u7D22")]),
21855
21907
  _: 1
21856
21908
  }, 8, ["modelValue", "placeholder"]), createElementVNode("div", _hoisted_8$1, [createVNode(_component_van_cell_group, null, {
21857
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(optionNodes), (item, i) => {
21909
+ default: withCtx(() => [props2.multiple ? (openBlock(), createBlock(_component_van_cell, {
21910
+ key: 0
21911
+ }, {
21912
+ title: withCtx(() => [createElementVNode("div", _hoisted_9$1, [createElementVNode("div", {
21913
+ class: "circle-selector",
21914
+ onClick: withModifiers(onToggleAll, ["stop"])
21915
+ }, [unref(isSelectAll) ? (openBlock(), createBlock(_component_van_icon, {
21916
+ key: 0,
21917
+ name: "success",
21918
+ size: "20",
21919
+ color: "#409eff"
21920
+ })) : createCommentVNode("", true), !unref(isSelectAll) ? (openBlock(), createBlock(_component_van_icon, {
21921
+ key: 1,
21922
+ name: "circle",
21923
+ size: "20",
21924
+ color: "#e0e0e0"
21925
+ })) : createCommentVNode("", true)], 8, _hoisted_10), _hoisted_11])]),
21926
+ _: 1
21927
+ })) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(unref(optionNodes), (item, i) => {
21858
21928
  return openBlock(), createBlock(_component_van_cell, {
21859
21929
  key: i
21860
21930
  }, createSlots({
21861
- title: withCtx(() => [createElementVNode("div", _hoisted_9$1, [item.canCheck ? (openBlock(), createElementBlock("div", {
21931
+ title: withCtx(() => [createElementVNode("div", _hoisted_12, [item.canCheck ? (openBlock(), createElementBlock("div", {
21862
21932
  key: 0,
21863
21933
  class: "circle-selector",
21864
21934
  onClick: withModifiers(($event) => onToggle(item), ["stop"])
@@ -21872,7 +21942,7 @@ const _sfc_main$3 = {
21872
21942
  name: "circle",
21873
21943
  size: "20",
21874
21944
  color: "#e0e0e0"
21875
- })) : createCommentVNode("", true)], 8, _hoisted_10)) : createCommentVNode("", true), createElementVNode("span", _hoisted_11, toDisplayString(item.label), 1)])]),
21945
+ })) : createCommentVNode("", true)], 8, _hoisted_13)) : createCommentVNode("", true), createElementVNode("span", _hoisted_14, toDisplayString(item.label), 1)])]),
21876
21946
  _: 2
21877
21947
  }, [item.canExpand ? {
21878
21948
  name: "right-icon",
@@ -21889,7 +21959,7 @@ const _sfc_main$3 = {
21889
21959
  };
21890
21960
  }
21891
21961
  };
21892
- var CascaderPop = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-27ca3ce1"]]);
21962
+ var CascaderPop = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-36e65e12"]]);
21893
21963
  const _hoisted_1$2 = {
21894
21964
  style: {
21895
21965
  "display": "flex",
@@ -21986,9 +22056,15 @@ const _sfc_main$2 = {
21986
22056
  }
21987
22057
  };
21988
22058
  const ids2nodes2 = () => __async(this, null, function* () {
21989
- if (!data2.selectedNodeIds || data2.selectedNodeIds.length < 1)
22059
+ let ids = [];
22060
+ if (!props2.multiple) {
22061
+ if (modelValue2.value)
22062
+ ids = [modelValue2.value];
22063
+ } else if (modelValue2.value && modelValue2.value.length > 0)
22064
+ ids = modelValue2.value;
22065
+ if (ids.length < 1)
21990
22066
  return [];
21991
- let promises = data2.selectedNodeIds.map((nodeId) => __async(this, null, function* () {
22067
+ let promises = ids.map((nodeId) => __async(this, null, function* () {
21992
22068
  let params = {};
21993
22069
  params.id = nodeId;
21994
22070
  params.isReturnParent = true;
@@ -22005,13 +22081,15 @@ const _sfc_main$2 = {
22005
22081
  return selectNodes;
22006
22082
  });
22007
22083
  watch(() => JSON.stringify(modelValue2.value), (n, o) => __async(this, null, function* () {
22008
- data2.selectedNodeIds = modelValue2.value;
22009
- data2.selectedNodes = yield ids2nodes2();
22010
22084
  if (!props2.multiple) {
22011
22085
  data2.selectedNodeIds = modelValue2.value;
22012
22086
  } else {
22013
- data2.selectedNodeIds = modelValue2.value;
22087
+ if (modelValue2.value && modelValue2.value.length > 0)
22088
+ data2.selectedNodeIds = modelValue2.value;
22089
+ else
22090
+ data2.selectedNodeIds = [];
22014
22091
  }
22092
+ data2.selectedNodes = yield ids2nodes2();
22015
22093
  }), {
22016
22094
  immediate: true
22017
22095
  });
@@ -6258,12 +6258,32 @@ var __async = (__this, __arguments, generator) => {
6258
6258
  }
6259
6259
  return Array.from(uniqueMap.values());
6260
6260
  }
6261
+ function uniqMerge(arr1, arr2) {
6262
+ let totalArr = [...arr1, ...arr2];
6263
+ return uniq(totalArr);
6264
+ }
6265
+ function substractAry(arr1, arr2) {
6266
+ if (!Array.isArray(arr2) || !arr2 || arr2.length < 1)
6267
+ return arr1;
6268
+ return arr1.filter((item) => !arr2.includes(item));
6269
+ }
6270
+ function isContainAry(arr1, arr2) {
6271
+ if (!Array.isArray(arr1) || !Array.isArray(arr2))
6272
+ return false;
6273
+ if (arr2.length === 0)
6274
+ return true;
6275
+ const set2 = new Set(arr1);
6276
+ return arr2.every((item) => set2.has(item));
6277
+ }
6261
6278
  var ArrayUtil = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6262
6279
  __proto__: null,
6263
6280
  arySwapPrev,
6264
6281
  arySwapNext,
6265
6282
  uniq,
6266
- uniqCode
6283
+ uniqCode,
6284
+ uniqMerge,
6285
+ substractAry,
6286
+ isContainAry
6267
6287
  }, Symbol.toStringTag, { value: "Module" }));
6268
6288
  function fittingString(str, maxWidth, fontSize) {
6269
6289
  var fontWidth = fontSize * 1.3;
@@ -19524,8 +19544,8 @@ var __async = (__this, __arguments, generator) => {
19524
19544
  const _hoisted_11$1 = {
19525
19545
  class: "search-container"
19526
19546
  };
19527
- const _hoisted_12 = /* @__PURE__ */ vue.createTextVNode("\u641C\u7D22");
19528
- const _hoisted_13 = {
19547
+ const _hoisted_12$1 = /* @__PURE__ */ vue.createTextVNode("\u641C\u7D22");
19548
+ const _hoisted_13$1 = {
19529
19549
  class: "scroll-container"
19530
19550
  };
19531
19551
  const _sfc_main$h = {
@@ -19941,9 +19961,9 @@ var __async = (__this, __arguments, generator) => {
19941
19961
  onClick: searchUserById,
19942
19962
  class: "search-btn"
19943
19963
  }, {
19944
- default: vue.withCtx(() => [_hoisted_12]),
19964
+ default: vue.withCtx(() => [_hoisted_12$1]),
19945
19965
  _: 1
19946
- })]), vue.createElementVNode("div", _hoisted_13, [!searchUserId.value && currentDepartments.value.length > 0 ? (vue.openBlock(), vue.createBlock(_component_van_cell_group, {
19966
+ })]), vue.createElementVNode("div", _hoisted_13$1, [!searchUserId.value && currentDepartments.value.length > 0 ? (vue.openBlock(), vue.createBlock(_component_van_cell_group, {
19947
19967
  key: 0
19948
19968
  }, {
19949
19969
  default: vue.withCtx(() => [(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(currentDepartments.value, (dept) => {
@@ -21618,7 +21638,8 @@ var __async = (__this, __arguments, generator) => {
21618
21638
  }
21619
21639
  };
21620
21640
  var TreePicker = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-ebc14630"]]);
21621
- var CascaderPop_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.cascader-pop[data-v-27ca3ce1] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.cascader-selector[data-v-27ca3ce1] {\r\n padding: 10px;\n}\n.search-buttons[data-v-27ca3ce1] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-27ca3ce1] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-27ca3ce1] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-27ca3ce1] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.cascader-header[data-v-27ca3ce1] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-27ca3ce1] {\r\n flex: 1;\r\n font-size: 14px;\r\n margin-left: 5px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-27ca3ce1] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-27ca3ce1] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-27ca3ce1] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\n.cell-content[data-v-27ca3ce1] {\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\n}\n.circle-selector[data-v-27ca3ce1] {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: all 0.2s;\r\n flex-shrink: 0;\n}\n.circle-selector.selected[data-v-27ca3ce1] {\r\n background-color: #1989fa;\r\n border-color: #1989fa;\n}\n.circle-selector.selected .van-icon[data-v-27ca3ce1] {\r\n color: white;\r\n font-size: 14px;\n}\n.van-cell__right-icon[data-v-27ca3ce1] {\r\n color: #969799;\r\n font-size: 16px;\r\n margin-left: 8px;\n}\n.name[data-v-27ca3ce1] {\r\n flex: 1;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\n}\n.cancel-btn[data-v-27ca3ce1] {\r\n color: #969799;\n}\n.search-field[data-v-27ca3ce1] {\r\n background: #fff;\r\n padding: 10px 16px;\r\n border-bottom: 1px solid #ebedf0;\r\n position: sticky;\r\n top: 0;\r\n z-index: 999;\r\n margin-bottom: 10px;\r\n flex-shrink: 0;\r\n /* \u9632\u6B62\u538B\u7F29 */\n}\r\n")();
21641
+ var CascaderPop_vue_vue_type_style_index_0_scoped_true_lang = /* @__PURE__ */ (() => "\n.cascader-pop[data-v-36e65e12] {\r\n width: 100%;\r\n overflow: hidden;\n}\n.cascader-selector[data-v-36e65e12] {\r\n padding: 10px;\n}\n.search-buttons[data-v-36e65e12] {\r\n display: flex;\r\n gap: 10px;\n}\n.clear-btn[data-v-36e65e12] {\r\n background-color: #f2f3f5;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.confirm-btn[data-v-36e65e12] {\r\n background-color: #1989fa;\r\n color: white;\r\n border: none;\r\n border-radius: 4px;\r\n padding: 4px 8px;\r\n font-size: 14px;\n}\n.no-results[data-v-36e65e12] {\r\n text-align: center;\r\n padding: 20px;\r\n color: #969799;\n}\n.cascader-header[data-v-36e65e12] {\r\n padding: 10px;\r\n border-bottom: 1px solid #ebedf0;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\n}\n.current-path[data-v-36e65e12] {\r\n flex: 1;\r\n font-size: 14px;\r\n margin-left: 5px;\r\n color: #323233;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\n}\n.header-right[data-v-36e65e12] {\r\n display: flex;\r\n gap: 8px;\r\n margin-left: auto;\n}\n.cancel-btn[data-v-36e65e12] {\r\n color: #969799;\r\n margin-right: 5px;\n}\n.scroll-container[data-v-36e65e12] {\r\n height: calc(80vh - 150px);\r\n overflow-y: auto;\n}\n.cell-content[data-v-36e65e12] {\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\n}\n.circle-selector[data-v-36e65e12] {\r\n width: 20px;\r\n height: 20px;\r\n border-radius: 50%;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n transition: all 0.2s;\r\n flex-shrink: 0;\n}\n.circle-selector.selected[data-v-36e65e12] {\r\n background-color: #1989fa;\r\n border-color: #1989fa;\n}\n.circle-selector.selected .van-icon[data-v-36e65e12] {\r\n color: white;\r\n font-size: 14px;\n}\n.van-cell__right-icon[data-v-36e65e12] {\r\n color: #969799;\r\n font-size: 16px;\r\n margin-left: 8px;\n}\n.name[data-v-36e65e12] {\r\n flex: 1;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\n}\n.cancel-btn[data-v-36e65e12] {\r\n color: #969799;\n}\n.search-field[data-v-36e65e12] {\r\n background: #fff;\r\n padding: 10px 16px;\r\n border-bottom: 1px solid #ebedf0;\r\n position: sticky;\r\n top: 0;\r\n z-index: 999;\r\n margin-bottom: 10px;\r\n flex-shrink: 0;\r\n /* \u9632\u6B62\u538B\u7F29 */\n}\r\n")();
21642
+ const _withScopeId = (n) => (vue.pushScopeId("data-v-36e65e12"), n = n(), vue.popScopeId(), n);
21622
21643
  const _hoisted_1$3 = {
21623
21644
  class: "cascader-selector"
21624
21645
  };
@@ -21643,7 +21664,14 @@ var __async = (__this, __arguments, generator) => {
21643
21664
  class: "cell-content"
21644
21665
  };
21645
21666
  const _hoisted_10 = ["onClick"];
21646
- const _hoisted_11 = {
21667
+ const _hoisted_11 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("span", {
21668
+ class: "name"
21669
+ }, "\u5168\u9009", -1));
21670
+ const _hoisted_12 = {
21671
+ class: "cell-content"
21672
+ };
21673
+ const _hoisted_13 = ["onClick"];
21674
+ const _hoisted_14 = {
21647
21675
  class: "name"
21648
21676
  };
21649
21677
  const _sfc_main$3 = {
@@ -21688,6 +21716,25 @@ var __async = (__this, __arguments, generator) => {
21688
21716
  keyword: "",
21689
21717
  selectedNodeIds: []
21690
21718
  });
21719
+ const isSelectAll = vue.computed({
21720
+ get() {
21721
+ let optionIds = optionNodes.value.filter((item) => item.canCheck).map((item) => item.id);
21722
+ if (optionIds.length < 1)
21723
+ return false;
21724
+ return util.isContainAry(data2.selectedNodeIds, optionIds);
21725
+ },
21726
+ set(val) {
21727
+ let optionIds = optionNodes.value.filter((item) => item.canCheck).map((item) => item.id);
21728
+ if (val) {
21729
+ data2.selectedNodeIds = util.uniqMerge(data2.selectedNodeIds, optionIds);
21730
+ } else {
21731
+ data2.selectedNodeIds = util.substractAry(data2.selectedNodeIds, optionIds);
21732
+ }
21733
+ }
21734
+ });
21735
+ const onToggleAll = () => {
21736
+ isSelectAll.value = !isSelectAll.value;
21737
+ };
21691
21738
  vue.onMounted(() => {
21692
21739
  });
21693
21740
  const optionNodes = vue.computed(() => {
@@ -21773,8 +21820,12 @@ var __async = (__this, __arguments, generator) => {
21773
21820
  const onToggle = (node) => {
21774
21821
  if (data2.selectedNodeIds.includes(node.id))
21775
21822
  data2.selectedNodeIds = data2.selectedNodeIds.filter((item) => item != node.id);
21776
- else
21777
- data2.selectedNodeIds.push(node.id);
21823
+ else {
21824
+ if (props2.multiple)
21825
+ data2.selectedNodeIds.push(node.id);
21826
+ else
21827
+ data2.selectedNodeIds = [node.id];
21828
+ }
21778
21829
  };
21779
21830
  const onNextLevel = (node) => {
21780
21831
  props2.idQueryNode({
@@ -21786,15 +21837,6 @@ var __async = (__this, __arguments, generator) => {
21786
21837
  });
21787
21838
  };
21788
21839
  const query = () => __async(this, null, function* () {
21789
- if (!props2.multiple) {
21790
- if (modelValue2.value)
21791
- data2.selectedNodeIds = [modelValue2.value];
21792
- else
21793
- data2.selectedNodeIds = [];
21794
- } else if (modelValue2.value && modelValue2.value.length > 0)
21795
- data2.selectedNodeIds = modelValue2.value;
21796
- else
21797
- data2.selectedNodeIds = [];
21798
21840
  let params = {};
21799
21841
  if (data2.selectedNodeIds.length > 0)
21800
21842
  params.id = data2.selectedNodeIds[0];
@@ -21805,7 +21847,17 @@ var __async = (__this, __arguments, generator) => {
21805
21847
  data2.parentNode = node;
21806
21848
  });
21807
21849
  });
21808
- vue.watch(() => [modelValue2.value, props2.show], (n, o) => __async(this, null, function* () {
21850
+ vue.watch(() => [props2.show], (n, o) => __async(this, null, function* () {
21851
+ if (!props2.show)
21852
+ return;
21853
+ if (!props2.multiple) {
21854
+ data2.selectedNodeIds = [modelValue2.value];
21855
+ } else {
21856
+ if (modelValue2.value && modelValue2.value.length > 0)
21857
+ data2.selectedNodeIds = modelValue2.value;
21858
+ else
21859
+ data2.selectedNodeIds = [];
21860
+ }
21809
21861
  query();
21810
21862
  }), {
21811
21863
  immediate: true
@@ -21857,11 +21909,29 @@ var __async = (__this, __arguments, generator) => {
21857
21909
  }, "\u641C\u7D22")]),
21858
21910
  _: 1
21859
21911
  }, 8, ["modelValue", "placeholder"]), vue.createElementVNode("div", _hoisted_8$1, [vue.createVNode(_component_van_cell_group, null, {
21860
- default: vue.withCtx(() => [(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(optionNodes), (item, i) => {
21912
+ default: vue.withCtx(() => [props2.multiple ? (vue.openBlock(), vue.createBlock(_component_van_cell, {
21913
+ key: 0
21914
+ }, {
21915
+ title: vue.withCtx(() => [vue.createElementVNode("div", _hoisted_9$1, [vue.createElementVNode("div", {
21916
+ class: "circle-selector",
21917
+ onClick: vue.withModifiers(onToggleAll, ["stop"])
21918
+ }, [vue.unref(isSelectAll) ? (vue.openBlock(), vue.createBlock(_component_van_icon, {
21919
+ key: 0,
21920
+ name: "success",
21921
+ size: "20",
21922
+ color: "#409eff"
21923
+ })) : vue.createCommentVNode("", true), !vue.unref(isSelectAll) ? (vue.openBlock(), vue.createBlock(_component_van_icon, {
21924
+ key: 1,
21925
+ name: "circle",
21926
+ size: "20",
21927
+ color: "#e0e0e0"
21928
+ })) : vue.createCommentVNode("", true)], 8, _hoisted_10), _hoisted_11])]),
21929
+ _: 1
21930
+ })) : vue.createCommentVNode("", true), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(optionNodes), (item, i) => {
21861
21931
  return vue.openBlock(), vue.createBlock(_component_van_cell, {
21862
21932
  key: i
21863
21933
  }, vue.createSlots({
21864
- title: vue.withCtx(() => [vue.createElementVNode("div", _hoisted_9$1, [item.canCheck ? (vue.openBlock(), vue.createElementBlock("div", {
21934
+ title: vue.withCtx(() => [vue.createElementVNode("div", _hoisted_12, [item.canCheck ? (vue.openBlock(), vue.createElementBlock("div", {
21865
21935
  key: 0,
21866
21936
  class: "circle-selector",
21867
21937
  onClick: vue.withModifiers(($event) => onToggle(item), ["stop"])
@@ -21875,7 +21945,7 @@ var __async = (__this, __arguments, generator) => {
21875
21945
  name: "circle",
21876
21946
  size: "20",
21877
21947
  color: "#e0e0e0"
21878
- })) : vue.createCommentVNode("", true)], 8, _hoisted_10)) : vue.createCommentVNode("", true), vue.createElementVNode("span", _hoisted_11, vue.toDisplayString(item.label), 1)])]),
21948
+ })) : vue.createCommentVNode("", true)], 8, _hoisted_13)) : vue.createCommentVNode("", true), vue.createElementVNode("span", _hoisted_14, vue.toDisplayString(item.label), 1)])]),
21879
21949
  _: 2
21880
21950
  }, [item.canExpand ? {
21881
21951
  name: "right-icon",
@@ -21892,7 +21962,7 @@ var __async = (__this, __arguments, generator) => {
21892
21962
  };
21893
21963
  }
21894
21964
  };
21895
- var CascaderPop = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-27ca3ce1"]]);
21965
+ var CascaderPop = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-36e65e12"]]);
21896
21966
  const _hoisted_1$2 = {
21897
21967
  style: {
21898
21968
  "display": "flex",
@@ -21989,9 +22059,15 @@ var __async = (__this, __arguments, generator) => {
21989
22059
  }
21990
22060
  };
21991
22061
  const ids2nodes2 = () => __async(this, null, function* () {
21992
- if (!data2.selectedNodeIds || data2.selectedNodeIds.length < 1)
22062
+ let ids = [];
22063
+ if (!props2.multiple) {
22064
+ if (modelValue2.value)
22065
+ ids = [modelValue2.value];
22066
+ } else if (modelValue2.value && modelValue2.value.length > 0)
22067
+ ids = modelValue2.value;
22068
+ if (ids.length < 1)
21993
22069
  return [];
21994
- let promises = data2.selectedNodeIds.map((nodeId) => __async(this, null, function* () {
22070
+ let promises = ids.map((nodeId) => __async(this, null, function* () {
21995
22071
  let params = {};
21996
22072
  params.id = nodeId;
21997
22073
  params.isReturnParent = true;
@@ -22008,13 +22084,15 @@ var __async = (__this, __arguments, generator) => {
22008
22084
  return selectNodes;
22009
22085
  });
22010
22086
  vue.watch(() => JSON.stringify(modelValue2.value), (n, o) => __async(this, null, function* () {
22011
- data2.selectedNodeIds = modelValue2.value;
22012
- data2.selectedNodes = yield ids2nodes2();
22013
22087
  if (!props2.multiple) {
22014
22088
  data2.selectedNodeIds = modelValue2.value;
22015
22089
  } else {
22016
- data2.selectedNodeIds = modelValue2.value;
22090
+ if (modelValue2.value && modelValue2.value.length > 0)
22091
+ data2.selectedNodeIds = modelValue2.value;
22092
+ else
22093
+ data2.selectedNodeIds = [];
22017
22094
  }
22095
+ data2.selectedNodes = yield ids2nodes2();
22018
22096
  }), {
22019
22097
  immediate: true
22020
22098
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "widget.qw",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.1.2",
5
5
  "description": "marqstree Vue3组件库",
6
6
  "main": "build/widget.qw.es.js",
7
7
  "keywords": [
@@ -16,8 +16,9 @@
16
16
  </template>
17
17
  </van-field>
18
18
 
19
- <CascaderPop :multiple="props.multiple" v-model:show="data.isShowPop" v-model="data.selectedNodeIds" :placeholder="props.placeholder"
20
- @select="onSelect" :keywordQueryNode="props.keywordQueryNode" :idQueryNode="props.idQueryNode" />
19
+ <CascaderPop :multiple="props.multiple" v-model:show="data.isShowPop" v-model="data.selectedNodeIds"
20
+ :placeholder="props.placeholder" @select="onSelect" :keywordQueryNode="props.keywordQueryNode"
21
+ :idQueryNode="props.idQueryNode" />
21
22
  </template>
22
23
 
23
24
  <script setup>
@@ -102,12 +103,6 @@ const onSelect = (nodes) => {
102
103
  data.selectedNodes = nodes
103
104
  emit('select', data.selectedNodes)
104
105
  modelValue.value = data.selectedNodes.map(item => item.id)
105
-
106
- // let one = data.selectedNodes.find(item => item.id === node.id)
107
- // if (!one)
108
- // data.selectedNodes = [...data.selectedNodes, node]
109
- // emit('select', data.selectedNodes)
110
- // modelValue.value = data.selectedNodes.map(item => item.id)
111
106
  }
112
107
  }
113
108
 
@@ -119,11 +114,19 @@ const onDelete = (idx) => {
119
114
  }
120
115
  }
121
116
 
122
- const ids2nodes = async() => {
123
- if(!data.selectedNodeIds || data.selectedNodeIds.length<1)
117
+ const ids2nodes = async () => {
118
+ let ids = []
119
+ if(!props.multiple){
120
+ if(modelValue.value)
121
+ ids = [modelValue.value]
122
+ }
123
+ else if(modelValue.value && modelValue.value.length>0)
124
+ ids = modelValue.value
125
+
126
+ if (ids.length < 1)
124
127
  return []
125
128
 
126
- let promises = data.selectedNodeIds.map(async(nodeId) => {
129
+ let promises = ids.map(async (nodeId) => {
127
130
  let params = {}
128
131
  params.id = nodeId
129
132
  params.isReturnParent = true
@@ -137,24 +140,24 @@ const ids2nodes = async() => {
137
140
  })
138
141
  return selectNode
139
142
  })
140
-
143
+
141
144
  let selectNodes = await Promise.all(promises)
142
145
 
143
146
  return selectNodes
144
147
  }
145
148
 
146
- watch(() => JSON.stringify(modelValue.value), async(n, o) => {
147
- data.selectedNodeIds = modelValue.value
148
- data.selectedNodes = await ids2nodes()
149
-
150
- //单用户选择时,将用户id记录在selectedNodeIds,用户对象存入selectedNodes的第一个元素
149
+ watch(() => JSON.stringify(modelValue.value), async (n, o) => {
151
150
  if (!props.multiple) {
152
151
  data.selectedNodeIds = modelValue.value
153
152
  }
154
- //多用户选择时,遍历回调接口获取多用户对象列表,记录在selectedNodes
155
153
  else {
156
- data.selectedNodeIds = modelValue.value
154
+ if (modelValue.value && modelValue.value.length > 0)
155
+ data.selectedNodeIds = modelValue.value
156
+ else
157
+ data.selectedNodeIds = []
157
158
  }
159
+
160
+ data.selectedNodes = await ids2nodes()
158
161
  }, {
159
162
  immediate: true
160
163
  })
@@ -27,6 +27,17 @@
27
27
  <div class="scroll-container">
28
28
  <!-- 遍历子节点列表 -->
29
29
  <van-cell-group>
30
+ <van-cell v-if="props.multiple">
31
+ <template #title>
32
+ <div class="cell-content">
33
+ <div class="circle-selector" @click.stop="onToggleAll">
34
+ <van-icon v-if="isSelectAll" name="success" size="20" color="#409eff" />
35
+ <van-icon v-if="!isSelectAll" name="circle" size="20" color="#e0e0e0" />
36
+ </div>
37
+ <span class="name">全选</span>
38
+ </div>
39
+ </template>
40
+ </van-cell>
30
41
  <van-cell v-for="(item, i) in optionNodes" :key="i">
31
42
  <template #title>
32
43
  <div class="cell-content">
@@ -94,6 +105,28 @@ const data = reactive({
94
105
  selectedNodeIds: []
95
106
  })
96
107
 
108
+ const isSelectAll = computed({
109
+ get() {
110
+ let optionIds = optionNodes.value.filter(item => item.canCheck).map(item => item.id)
111
+ if (optionIds.length < 1)
112
+ return false
113
+
114
+ return util.isContainAry(data.selectedNodeIds, optionIds)
115
+ },
116
+ set(val) {
117
+ let optionIds = optionNodes.value.filter(item => item.canCheck).map(item => item.id)
118
+ if (val) {
119
+ data.selectedNodeIds = util.uniqMerge(data.selectedNodeIds, optionIds)
120
+ } else {
121
+ data.selectedNodeIds = util.substractAry(data.selectedNodeIds, optionIds)
122
+ }
123
+ }
124
+ })
125
+
126
+ const onToggleAll = () => {
127
+ isSelectAll.value = !isSelectAll.value
128
+ }
129
+
97
130
  onMounted(() => {
98
131
  })
99
132
 
@@ -148,11 +181,11 @@ const reset = () => {
148
181
  data.selectedNodeIds = []
149
182
  }
150
183
 
151
- const ids2nodes = async() => {
152
- if(!data.selectedNodeIds || data.selectedNodeIds.length<1)
184
+ const ids2nodes = async () => {
185
+ if (!data.selectedNodeIds || data.selectedNodeIds.length < 1)
153
186
  return []
154
187
 
155
- let promises = data.selectedNodeIds.map(async(nodeId) => {
188
+ let promises = data.selectedNodeIds.map(async (nodeId) => {
156
189
  let params = {}
157
190
  params.id = nodeId
158
191
  params.isReturnParent = true
@@ -166,14 +199,14 @@ const ids2nodes = async() => {
166
199
  })
167
200
  return selectNode
168
201
  })
169
-
202
+
170
203
  let selectNodes = await Promise.all(promises)
171
204
 
172
205
  return selectNodes
173
206
  }
174
207
 
175
208
  // 确认按钮
176
- const onSubmit = async() => {
209
+ const onSubmit = async () => {
177
210
  if (!data.selectedNodeIds || data.selectedNodeIds.length < 1) {
178
211
  util.warnToast("请选择")
179
212
  return
@@ -203,8 +236,12 @@ const onCancel = () => {
203
236
  const onToggle = (node) => {
204
237
  if (data.selectedNodeIds.includes(node.id))
205
238
  data.selectedNodeIds = data.selectedNodeIds.filter(item => item != node.id)
206
- else
207
- data.selectedNodeIds.push(node.id)
239
+ else {
240
+ if (props.multiple)
241
+ data.selectedNodeIds.push(node.id)
242
+ else
243
+ data.selectedNodeIds = [node.id]
244
+ }
208
245
  }
209
246
 
210
247
  const onNextLevel = (node) => {
@@ -214,17 +251,6 @@ const onNextLevel = (node) => {
214
251
  }
215
252
 
216
253
  const query = async () => {
217
- if (!props.multiple)
218
- if (modelValue.value)
219
- data.selectedNodeIds = [modelValue.value]
220
- else
221
- data.selectedNodeIds = []
222
- else
223
- if (modelValue.value && modelValue.value.length > 0)
224
- data.selectedNodeIds = modelValue.value
225
- else
226
- data.selectedNodeIds = []
227
-
228
254
  let params = {}
229
255
  if (data.selectedNodeIds.length > 0)
230
256
  params.id = data.selectedNodeIds[0]
@@ -235,132 +261,27 @@ const query = async () => {
235
261
  await props.idQueryNode(params, (node) => {
236
262
  data.parentNode = node
237
263
  })
238
-
239
-
240
- // if (!props.multiple) {
241
- // //空id时,查带子节点的虚拟根节点
242
- // if (!data.selectedNodeIds) {
243
- // let params = {}
244
- // params.isReturnParent = true
245
- // params.hasChildren = true
246
- // params.hasPaths = true
247
-
248
- // await props.idQueryNode(params, (node) => {
249
- // data.parentNode = node
250
-
251
- // // if (!data.selectedNodeIds)
252
- // // return
253
-
254
- // // let childNode = util.findNode(modelValue.value, data.parentNode.children)
255
- // // emit('select', childNode)
256
- // })
257
- // }
258
- // //选中节点时
259
- // else {
260
- // //未显示底部弹窗时,只查节点本身
261
- // if (!props.show) {
262
- // let params = {}
263
- // params.id = modelValue.value
264
- // params.isReturnParent = true
265
- // params.hasChildren = false
266
- // params.hasPaths = true
267
-
268
- // await props.idQueryNode(params, (node) => {
269
- // data.parentNode = node
270
- // let childNode = util.findNode(modelValue.value, data.parentNode.children)
271
- // emit('select', childNode)
272
- // })
273
- // }
274
- // //显示底部弹窗时,查询带子节点的父节点
275
- // else {
276
- // let params = {}
277
- // params.id = modelValue.value
278
- // params.isReturnParent = true
279
- // params.hasChildren = true
280
- // params.hasPaths = true
281
-
282
- // await props.idQueryNode(params, (node) => {
283
- // data.parentNode = node
284
- // if (!modelValue.value)
285
- // return
286
- // let childNode = util.findNode(modelValue.value, data.parentNode.children)
287
- // emit('select', childNode)
288
- // })
289
- // }
290
- // }
291
- // } else {
292
- // //空数组时,查带子节点的虚拟根节点
293
- // if (!data.selectedNodeIds || data.selectedNodeIds.length < 1) {
294
- // let params = {}
295
- // params.isReturnParent = true
296
- // params.hasChildren = true
297
- // params.hasPaths = true
298
-
299
- // await props.idQueryNode(params, (node) => {
300
- // data.parentNode = node
301
-
302
- // if (!modelValue.value)
303
- // return
304
-
305
- // let childNode = util.findNode(modelValue.value, data.parentNode.children)
306
- // emit('select', childNode)
307
- // })
308
- // }
309
- // //选中节点时
310
- // else {
311
- // //未显示底部弹窗时,只查节点本身
312
- // if (!props.show) {
313
- // let selectNodes = data.selectedNodeIds.map(async(nodeId) => {
314
- // let params = {}
315
- // params.id = nodeId
316
- // params.isReturnParent = true
317
- // params.hasChildren = false
318
- // params.hasPaths = true
319
-
320
- // let selectNode = await props.idQueryNode(params, (node) => {
321
- // data.parentNode = node
322
- // let childNode = util.findNode(nodeId, data.parentNode.children)
323
- // return childNode
324
- // })
325
- // return selectNode
326
- // })
327
- // // emit('select', selectNodes)
328
- // }
329
- // //显示底部弹窗时,查询第一个选中节点的的父节点
330
- // else {
331
- // let params = {}
332
- // params.id = data.selectedNodeIds[0]
333
- // params.isReturnParent = true
334
- // params.hasChildren = true
335
- // params.hasPaths = true
336
-
337
- // await props.idQueryNode(params, (node) => {
338
- // data.parentNode = node
339
- // if (!data.selectedNodeIds[0])
340
- // return
341
- // let childNode = util.findNode(data.selectedNodeIds[0], data.parentNode.children)
342
- // // emit('select', childNode)
343
- // })
344
- // }
345
- // }
346
- // }
347
264
  }
348
265
 
349
266
  //根据id查询详情对象
350
- watch(() => [modelValue.value, props.show], async (n, o) => {
267
+ watch(() => [props.show], async (n, o) => {
268
+ if (!props.show)
269
+ return
270
+
271
+ if (!props.multiple) {
272
+ data.selectedNodeIds = [modelValue.value]
273
+ }
274
+ else {
275
+ if (modelValue.value && modelValue.value.length > 0)
276
+ data.selectedNodeIds = modelValue.value
277
+ else
278
+ data.selectedNodeIds = []
279
+ }
280
+
351
281
  query()
352
282
  }, {
353
283
  immediate: true
354
284
  })
355
-
356
- // watch(() => props.show, () => {
357
- // if (!props.show)
358
- // return
359
-
360
- // query()
361
- // }, {
362
- // immediate: true
363
- // })
364
285
  </script>
365
286
 
366
287
  <style scoped>
@@ -12,21 +12,43 @@ export function arySwapNext(arr, index) {
12
12
  return arr;
13
13
  }
14
14
 
15
- export function uniq(ary){
16
- // 去重
17
- let newAry = [...new Set(ary)]
18
- return newAry
15
+ export function uniq(ary) {
16
+ // 去重
17
+ let newAry = [...new Set(ary)]
18
+ return newAry
19
19
  }
20
20
 
21
21
  export function uniqCode(arr) {
22
22
  const uniqueMap = new Map();
23
23
  for (const item of arr) {
24
- const key = item.code
25
- if (!uniqueMap.has(key)) {
26
- uniqueMap.set(key, item);
27
- }
24
+ const key = item.code
25
+ if (!uniqueMap.has(key)) {
26
+ uniqueMap.set(key, item);
27
+ }
28
28
  }
29
29
  return Array.from(uniqueMap.values());
30
30
  }
31
31
 
32
+ //合并两个数组,合并后的数组去重
33
+ export function uniqMerge(arr1, arr2) {
34
+ let totalArr = [...arr1, ...arr2]
35
+ return uniq(totalArr)
36
+ }
37
+
38
+ //数组1减去数组2
39
+ export function substractAry(arr1, arr2) {
40
+ if (!Array.isArray(arr2) || !arr2 || arr2.length<1)
41
+ return arr1
32
42
 
43
+ return arr1.filter(item => !arr2.includes(item))
44
+ }
45
+
46
+ //判断数组1是否包含数组2
47
+ export function isContainAry(arr1, arr2){
48
+ // 非数组直接返回false
49
+ if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false
50
+ // 空数组2默认视为被包含
51
+ if (arr2.length === 0) return true
52
+ const set = new Set(arr1)
53
+ return arr2.every(item => set.has(item))
54
+ }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="page">
3
- <UserPicker label="项目经理" multiple v-model="data.userids" :auth="data.auth" />
3
+ <UserPicker label="项目经理" :multiple="data.multiple" v-model="data.userids" :auth="data.auth" />
4
4
  </div>
5
5
  </template>
6
6
 
@@ -9,8 +9,9 @@ import { reactive, onMounted } from "vue";
9
9
  import UserPicker from '../cascaderpicker/userpicker.vue'
10
10
 
11
11
  const data = reactive({
12
- auth: 'readonly',
13
- userids: ["HouMu"]
12
+ multiple:true,
13
+ auth: 'require',
14
+ userids: []
14
15
  })
15
16
 
16
17
  onMounted(() => {