@dt-frames/ui 1.0.11 → 1.0.12

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/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent, resolveComponent, openBlock, createBlock, computed, unref, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, ref, watch, Fragment, renderList, createTextVNode, toDisplayString, KeepAlive, createVNode, withCtx, reactive, toRaw, getCurrentInstance, watchEffect, nextTick, onUnmounted, toRefs, isVNode, inject, h, provide, onMounted, onBeforeUnmount, resolveDynamicComponent, renderSlot, createCommentVNode, mergeProps, readonly, isRef, withDirectives, resolveDirective, render, normalizeProps, guardReactiveProps, createSlots, useAttrs as useAttrs$1, useSlots as useSlots$1, withModifiers, vShow, toRef, Transition } from "vue";
1
+ import { defineComponent, resolveComponent, openBlock, createBlock, computed, unref, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, ref, watch, Fragment, renderList, createTextVNode, toDisplayString, KeepAlive, createVNode, withCtx, reactive, toRaw, getCurrentInstance, watchEffect, nextTick, onUnmounted, toRefs, isVNode, inject, h, provide, onMounted, onBeforeUnmount, resolveDynamicComponent, renderSlot, createCommentVNode, mergeProps, readonly, isRef, useAttrs as useAttrs$1, normalizeProps, guardReactiveProps, withDirectives, resolveDirective, render, createSlots, useSlots as useSlots$1, withModifiers, vShow, toRef, Transition } from "vue";
2
2
  import { isString, isArray as isArray$1, isObject, isFunction, error, useTimeoutFn, useAttrs, useSlots, dispatchResize, BAR_MAP, off, renderThumbStyle, on, useAppStore, addResizeListener, removeResizeListener, windowResizeFn, isNumber, isBoolean, isNull, DtCache, CacheKey, deepMerge, http, getDynamicProps, getDictValueByCode, formatNumber, isVnode, getPopupContainer, isNullAndUnDef, dateFormat, useMessage, isEmpty, useTheme, useMenu, useHeader, useGo, Pages, localeList, changeLocale, Theme, MenuMode, MenuType, useThemeStore, ContentMode, useMultipleTab, copyText, MenuSplitTye, isUrl, openWindow, RouteReuseStore, menuList2Map, useApp } from "@dt-frames/core";
3
3
  import { InputSearch, Tooltip, Modal as Modal$1, RadioGroup, RadioButton, InputGroup, Input, Button, Select, TreeSelect, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, Slider, Rate, Divider, Col, Form, FormItem, Row, Popover, Spin, Dropdown, Menu, MenuItem, CheckboxGroup, Table, Upload, Image, MenuDivider, Tree, Empty, BackTop, Breadcrumb, Avatar, Drawer, SubMenu, LayoutHeader, LayoutSider, Tabs, TabPane, LayoutFooter, LayoutContent, ConfigProvider, Layout } from "ant-design-vue";
4
- import { isEqual, cloneDeep, upperFirst, set, uniqBy, omit, difference, get, trim } from "lodash-es";
4
+ import { isEqual, omit, cloneDeep, upperFirst, set, uniqBy, difference, get, trim } from "lodash-es";
5
5
  import { tryOnUnmounted, isFunction as isFunction$1, useFullscreen, useDebounceFn, useThrottleFn } from "@vueuse/core";
6
6
  import Sortablejs from "sortablejs";
7
7
  import * as xlsx from "xlsx";
@@ -14,15 +14,15 @@ var _export_sfc = (sfc, props) => {
14
14
  }
15
15
  return target;
16
16
  };
17
- const _sfc_main$Y = defineComponent({
17
+ const _sfc_main$Z = defineComponent({
18
18
  name: "dt-base-router"
19
19
  });
20
20
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
21
21
  const _component_router_view = resolveComponent("router-view");
22
22
  return openBlock(), createBlock(_component_router_view);
23
23
  }
24
- var DtBaseRouter = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["render", _sfc_render$8]]);
25
- const _sfc_main$X = defineComponent({
24
+ var DtBaseRouter = /* @__PURE__ */ _export_sfc(_sfc_main$Z, [["render", _sfc_render$8]]);
25
+ const _sfc_main$Y = defineComponent({
26
26
  props: {
27
27
  iconClass: {
28
28
  type: String,
@@ -90,7 +90,7 @@ const _sfc_main$X = defineComponent({
90
90
  };
91
91
  }
92
92
  });
93
- const _hoisted_1$w = ["xlink:href", "fill"];
93
+ const _hoisted_1$x = ["xlink:href", "fill"];
94
94
  function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
95
95
  return _ctx.isSvgIcon ? (openBlock(), createElementBlock("svg", {
96
96
  key: 0,
@@ -105,7 +105,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
105
105
  createElementVNode("use", {
106
106
  "xlink:href": _ctx.iconName,
107
107
  fill: _ctx.color
108
- }, null, 8, _hoisted_1$w)
108
+ }, null, 8, _hoisted_1$x)
109
109
  ], 6)) : (openBlock(), createElementBlock("i", {
110
110
  key: 1,
111
111
  class: normalizeClass(["dt-icon i", [_ctx.iconName, _ctx.clsName]]),
@@ -115,7 +115,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
115
115
  })
116
116
  }, null, 6));
117
117
  }
118
- var DtIcon = /* @__PURE__ */ _export_sfc(_sfc_main$X, [["render", _sfc_render$7]]);
118
+ var DtIcon = /* @__PURE__ */ _export_sfc(_sfc_main$Y, [["render", _sfc_render$7]]);
119
119
  const Actions = [
120
120
  "ic:baseline-save",
121
121
  "ic:baseline-save-all",
@@ -1874,9 +1874,9 @@ const Icons = [
1874
1874
  children: Other
1875
1875
  }
1876
1876
  ];
1877
- const _hoisted_1$v = ["onClick"];
1877
+ const _hoisted_1$w = ["onClick"];
1878
1878
  const _hoisted_2$l = ["onClick"];
1879
- const _sfc_main$W = /* @__PURE__ */ defineComponent({
1879
+ const _sfc_main$X = /* @__PURE__ */ defineComponent({
1880
1880
  __name: "pick-icon",
1881
1881
  emits: ["chooseIcon"],
1882
1882
  setup(__props, { emit: emits }) {
@@ -1943,7 +1943,7 @@ const _sfc_main$W = /* @__PURE__ */ defineComponent({
1943
1943
  createTextVNode(toDisplayString(menu.type), 1),
1944
1944
  createElementVNode("span", null, "(" + toDisplayString(menu.total) + ")", 1)
1945
1945
  ])
1946
- ], 10, _hoisted_1$v);
1946
+ ], 10, _hoisted_1$w);
1947
1947
  }), 128))
1948
1948
  ], 2),
1949
1949
  createElementVNode("div", {
@@ -2384,8 +2384,8 @@ var Bar = defineComponent({
2384
2384
  }));
2385
2385
  }
2386
2386
  });
2387
- const _hoisted_1$u = { class: "scrollbar" };
2388
- const _sfc_main$V = /* @__PURE__ */ defineComponent({
2387
+ const _hoisted_1$v = { class: "scrollbar" };
2388
+ const _sfc_main$W = /* @__PURE__ */ defineComponent({
2389
2389
  __name: "scroll-bar",
2390
2390
  props: {
2391
2391
  wrapClass: {
@@ -2462,7 +2462,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
2462
2462
  }
2463
2463
  });
2464
2464
  return (_ctx, _cache) => {
2465
- return openBlock(), createElementBlock("div", _hoisted_1$u, [
2465
+ return openBlock(), createElementBlock("div", _hoisted_1$v, [
2466
2466
  createElementVNode("div", {
2467
2467
  ref_key: "wrap",
2468
2468
  ref: wrap,
@@ -2497,12 +2497,12 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
2497
2497
  };
2498
2498
  }
2499
2499
  });
2500
- const _sfc_main$U = /* @__PURE__ */ defineComponent({
2500
+ const _sfc_main$V = /* @__PURE__ */ defineComponent({
2501
2501
  __name: "scroll-container",
2502
2502
  setup(__props) {
2503
2503
  const scrollbarRef = ref(null);
2504
2504
  return (_ctx, _cache) => {
2505
- return openBlock(), createBlock(_sfc_main$V, mergeProps({
2505
+ return openBlock(), createBlock(_sfc_main$W, mergeProps({
2506
2506
  ref_key: "scrollbarRef",
2507
2507
  ref: scrollbarRef,
2508
2508
  class: "scroll-container"
@@ -2515,7 +2515,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
2515
2515
  };
2516
2516
  }
2517
2517
  });
2518
- const _sfc_main$T = /* @__PURE__ */ defineComponent({
2518
+ const _sfc_main$U = /* @__PURE__ */ defineComponent({
2519
2519
  __name: "modal-wrap",
2520
2520
  props: {
2521
2521
  loading: { type: Boolean },
@@ -2603,7 +2603,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
2603
2603
  }
2604
2604
  });
2605
2605
  return (_ctx, _cache) => {
2606
- return openBlock(), createBlock(unref(_sfc_main$U), {
2606
+ return openBlock(), createBlock(unref(_sfc_main$V), {
2607
2607
  ref_key: "wrapperRef",
2608
2608
  ref: wrapperRef
2609
2609
  }, {
@@ -2689,7 +2689,7 @@ function useFormValue(props, key = "value", changeEvent = "change", emitData) {
2689
2689
  });
2690
2690
  return [state, setState, defaultState];
2691
2691
  }
2692
- const _sfc_main$S = defineComponent({
2692
+ const _sfc_main$T = defineComponent({
2693
2693
  name: "radio-button",
2694
2694
  props: {
2695
2695
  value: {
@@ -2747,8 +2747,8 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
2747
2747
  _: 1
2748
2748
  }, 16, ["value"]);
2749
2749
  }
2750
- var RadioButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$S, [["render", _sfc_render$6]]);
2751
- const _sfc_main$R = /* @__PURE__ */ defineComponent({
2750
+ var RadioButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$T, [["render", _sfc_render$6]]);
2751
+ const _sfc_main$S = /* @__PURE__ */ defineComponent({
2752
2752
  __name: "formIcon",
2753
2753
  props: {
2754
2754
  value: String,
@@ -2800,7 +2800,7 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
2800
2800
  }),
2801
2801
  createVNode(unref(_sfc_main$L), { onRegister: unref(register) }, {
2802
2802
  default: withCtx(() => [
2803
- createVNode(unref(_sfc_main$W), {
2803
+ createVNode(unref(_sfc_main$X), {
2804
2804
  onChooseIcon: _cache[2] || (_cache[2] = ($event) => chooseIcon($event))
2805
2805
  })
2806
2806
  ]),
@@ -2810,8 +2810,47 @@ const _sfc_main$R = /* @__PURE__ */ defineComponent({
2810
2810
  };
2811
2811
  }
2812
2812
  });
2813
+ const _hoisted_1$u = { class: "input-with-dialog" };
2814
+ const _sfc_main$R = /* @__PURE__ */ defineComponent({
2815
+ __name: "formInputUseDialog",
2816
+ setup(__props) {
2817
+ const attrs = useAttrs$1();
2818
+ const bindProps = computed(() => {
2819
+ return {
2820
+ ...omit(attrs, [
2821
+ "formValues"
2822
+ ]),
2823
+ disabled: true
2824
+ };
2825
+ });
2826
+ function onClickInput() {
2827
+ const { model, schema = {} } = attrs.formValues;
2828
+ if (!schema.openDialog || !isFunction(schema.openDialog)) {
2829
+ error("openDialog\u5FC5\u987B\u662F\u51FD\u6570");
2830
+ return;
2831
+ }
2832
+ schema.openDialog(model);
2833
+ }
2834
+ function clearProps() {
2835
+ const { model, schema = {} } = attrs.formValues;
2836
+ [...schema.linkProps, schema.name].forEach((it) => model[it] = null);
2837
+ }
2838
+ return (_ctx, _cache) => {
2839
+ return openBlock(), createElementBlock("div", _hoisted_1$u, [
2840
+ createElementVNode("div", { onClick: onClickInput }, [
2841
+ createVNode(unref(Input), normalizeProps(guardReactiveProps(unref(bindProps))), null, 16)
2842
+ ]),
2843
+ createElementVNode("i", {
2844
+ class: "i mdi:close-circle",
2845
+ onClick: clearProps
2846
+ })
2847
+ ]);
2848
+ };
2849
+ }
2850
+ });
2813
2851
  const components = {
2814
2852
  Input,
2853
+ InputWithDialog: _sfc_main$R,
2815
2854
  InputTextArea: Input.TextArea,
2816
2855
  InputSearch: Input.Search,
2817
2856
  InputGroup: Input.Group,
@@ -2835,7 +2874,7 @@ const components = {
2835
2874
  Slider,
2836
2875
  Rate,
2837
2876
  Divider,
2838
- Icon: _sfc_main$R
2877
+ Icon: _sfc_main$S
2839
2878
  };
2840
2879
  const componentMap$1 = /* @__PURE__ */ new Map();
2841
2880
  for (let item in components) {
@@ -3180,7 +3219,7 @@ var _sfc_main$Q = defineComponent({
3180
3219
  const bindValue = {
3181
3220
  [valueField || (isCheck ? "checked" : "value")]: props.formModel[name]
3182
3221
  };
3183
- const compAttr = {
3222
+ let compAttr = {
3184
3223
  ...itemProps,
3185
3224
  ...bindValue,
3186
3225
  ...on2
@@ -4479,7 +4518,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
4479
4518
  return (_ctx, _cache) => {
4480
4519
  return openBlock(), createBlock(unref(Modal), mergeProps(unref(getBindValue), { onCancel: handleCancel }), createSlots({
4481
4520
  default: withCtx(() => [
4482
- createVNode(_sfc_main$T, mergeProps({
4521
+ createVNode(_sfc_main$U, mergeProps({
4483
4522
  useWrapper: unref(getBindValue).useWrapper,
4484
4523
  footerOffset: _ctx.wrapperFooterOffset,
4485
4524
  fullScreen: unref(fullScreenRef),
@@ -4685,6 +4724,7 @@ const TABLE_SIZE_HEIGHT = {
4685
4724
  const TableProps = {
4686
4725
  clickRowSelect: { type: Boolean, default: false },
4687
4726
  tableSetting: { type: Object, default: () => ({}) },
4727
+ clickToRowSelect: { type: Boolean, default: false },
4688
4728
  striped: { type: Boolean, default: true },
4689
4729
  canColDrag: { type: Boolean, default: true },
4690
4730
  resizable: { type: Boolean, default: true },
@@ -6215,7 +6255,7 @@ const _sfc_main$C = defineComponent({
6215
6255
  },
6216
6256
  props: {
6217
6257
  tableTools: {
6218
- type: Object
6258
+ type: [Object, Boolean]
6219
6259
  },
6220
6260
  toolbar: {
6221
6261
  type: Array,
@@ -6457,6 +6497,70 @@ function useTableScroll(propsRef, tableElRef, columnsRef, rowSelectionRef) {
6457
6497
  filterSource
6458
6498
  };
6459
6499
  }
6500
+ function useCustomRow(propsRef, { setSelectedRowKeys, getSelectRowKeys, clearSelectedRowKeys, emit }) {
6501
+ const customRow = (record, index) => {
6502
+ return {
6503
+ onClick: (e) => {
6504
+ e == null ? void 0 : e.stopPropagation();
6505
+ function handleClick() {
6506
+ var _a;
6507
+ const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef);
6508
+ if (!rowSelection || !clickToRowSelect)
6509
+ return;
6510
+ const keys = getSelectRowKeys();
6511
+ const key = record[rowKey];
6512
+ if (!key)
6513
+ return;
6514
+ const isCheckbox = rowSelection.type === "checkbox";
6515
+ if (isCheckbox) {
6516
+ const tr = (_a = e.composedPath) == null ? void 0 : _a.call(e).find((dom) => dom.tagName === "TR");
6517
+ if (!tr)
6518
+ return;
6519
+ const checkBox = tr.querySelector("input[type=checkbox]");
6520
+ if (!checkBox || checkBox.hasAttribute("disabled"))
6521
+ return;
6522
+ if (!keys.includes(key)) {
6523
+ setSelectedRowKeys([...keys, key]);
6524
+ return;
6525
+ }
6526
+ const keyIndex = keys.findIndex((item) => item === key);
6527
+ keys.splice(keyIndex, 1);
6528
+ setSelectedRowKeys(keys);
6529
+ return;
6530
+ }
6531
+ const isRadio = rowSelection.type === "radio";
6532
+ if (isRadio) {
6533
+ if (!keys.includes(key)) {
6534
+ if (keys.length) {
6535
+ clearSelectedRowKeys();
6536
+ }
6537
+ setSelectedRowKeys([key]);
6538
+ return;
6539
+ }
6540
+ clearSelectedRowKeys();
6541
+ }
6542
+ }
6543
+ handleClick();
6544
+ emit("row-click", record, index, e);
6545
+ },
6546
+ onDblclick: (event) => {
6547
+ emit("row-dbClick", record, index, event);
6548
+ },
6549
+ onContextmenu: (event) => {
6550
+ emit("row-contextmenu", record, index, event);
6551
+ },
6552
+ onMouseenter: (event) => {
6553
+ emit("row-mouseenter", record, index, event);
6554
+ },
6555
+ onMouseleave: (event) => {
6556
+ emit("row-mouseleave", record, index, event);
6557
+ }
6558
+ };
6559
+ };
6560
+ return {
6561
+ customRow
6562
+ };
6563
+ }
6460
6564
  const _sfc_main$B = defineComponent({
6461
6565
  name: "dt-table",
6462
6566
  props: TableProps,
@@ -6470,6 +6574,9 @@ const _sfc_main$B = defineComponent({
6470
6574
  "selection-change",
6471
6575
  "row-click",
6472
6576
  "row-dbClick",
6577
+ "row-contextmenu",
6578
+ "row-mouseenter",
6579
+ "row-mouseleave",
6473
6580
  "expanded-rows-change",
6474
6581
  "edit-change"
6475
6582
  ],
@@ -6495,7 +6602,8 @@ const _sfc_main$B = defineComponent({
6495
6602
  clearSelectedRowKeys,
6496
6603
  getRowSelection,
6497
6604
  getSelectRows,
6498
- getSelectRowKeys
6605
+ getSelectRowKeys,
6606
+ setSelectedRowKeys
6499
6607
  } = useRowSelection(getProps, emit);
6500
6608
  const { getScrollRef, filterSource } = useTableScroll(getProps, tableElRef, getColumnsRef, getRowSelectionRef);
6501
6609
  function setProps(props2) {
@@ -6526,6 +6634,12 @@ const _sfc_main$B = defineComponent({
6526
6634
  setPagination,
6527
6635
  clearSelectedRowKeys
6528
6636
  });
6637
+ const { customRow } = useCustomRow(getProps, {
6638
+ setSelectedRowKeys,
6639
+ getSelectRowKeys,
6640
+ clearSelectedRowKeys,
6641
+ emit
6642
+ });
6529
6643
  const getBind = computed(() => {
6530
6644
  return {
6531
6645
  ...attrs,
@@ -6538,7 +6652,8 @@ const _sfc_main$B = defineComponent({
6538
6652
  rowSelection: unref(getRowSelectionRef),
6539
6653
  rowKey: unref(getProps).rowKey,
6540
6654
  columns: unref(getViewColumns),
6541
- tableLayout: "fixed"
6655
+ tableLayout: "fixed",
6656
+ customRow
6542
6657
  };
6543
6658
  });
6544
6659
  createTableInstance({ ...tableAction, tableElRef, getBind });
@@ -6832,7 +6947,8 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
6832
6947
  ...{
6833
6948
  onRegister: { type: Function },
6834
6949
  formProps: {
6835
- type: Object
6950
+ type: Object,
6951
+ default: () => ({})
6836
6952
  },
6837
6953
  formsVal: {
6838
6954
  type: Object
@@ -6853,7 +6969,7 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
6853
6969
  destroyOnClose: true
6854
6970
  });
6855
6971
  const [registerForm, { getFormValues, setFormValues }] = useForm({
6856
- ...props.formProps.value || {},
6972
+ ...props.formProps || {},
6857
6973
  schemas: props.schemas,
6858
6974
  mode: "dialog"
6859
6975
  });
@@ -8465,7 +8581,7 @@ var _sfc_main$v = /* @__PURE__ */ defineComponent({
8465
8581
  const dtComponents = [
8466
8582
  { name: "dt-base-router", component: DtBaseRouter },
8467
8583
  { name: "dt-icon", component: DtIcon },
8468
- { name: "dt-pick-icon", component: _sfc_main$W },
8584
+ { name: "dt-pick-icon", component: _sfc_main$X },
8469
8585
  { name: "dt-modal", component: _sfc_main$L },
8470
8586
  { name: "dt-form", component: DtForm },
8471
8587
  { name: "dt-upload", component: _sfc_main$y },
@@ -9758,7 +9874,7 @@ var _sfc_main$b = defineComponent({
9758
9874
  }), null);
9759
9875
  }
9760
9876
  return () => {
9761
- return createVNode(Fragment, null, [renderHeader(), unref(getUseScroll) ? createVNode(_sfc_main$U, null, {
9877
+ return createVNode(Fragment, null, [renderHeader(), unref(getUseScroll) ? createVNode(_sfc_main$V, null, {
9762
9878
  default: () => renderMenu()
9763
9879
  }) : renderMenu()]);
9764
9880
  };
@@ -10602,7 +10718,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10602
10718
  }, {
10603
10719
  default: withCtx(() => [
10604
10720
  unref(getShowSidebar) ? (openBlock(), createBlock(_sfc_main$7, { key: 0 })) : createCommentVNode("", true),
10605
- createVNode(unref(_sfc_main$U), {
10721
+ createVNode(unref(_sfc_main$V), {
10606
10722
  ref_key: "wrapperRef",
10607
10723
  ref: wrapperRef,
10608
10724
  class: normalizeClass({ "fixedWrap": unref(getFixed) })
@@ -10635,4 +10751,4 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10635
10751
  };
10636
10752
  }
10637
10753
  });
10638
- export { DtBaseRouter, DtForm, DtIcon, _sfc_main$z as DtIframe, _sfc_main$L as DtModal, _sfc_main$W as DtPickIcon, DtTable, _sfc_main as DtTheme, _sfc_main$v as DtTree, _sfc_main$y as DtUpload, _sfc_main$x as DtUploadModal, FormButtons, authMounted, export2Excel, iconMounted, initComponents, initDirectives, useCurd, useForm, useModal, useModalOut, useSource, useTable };
10754
+ export { DtBaseRouter, DtForm, DtIcon, _sfc_main$z as DtIframe, _sfc_main$L as DtModal, _sfc_main$X as DtPickIcon, DtTable, _sfc_main as DtTheme, _sfc_main$v as DtTree, _sfc_main$y as DtUpload, _sfc_main$x as DtUploadModal, FormButtons, authMounted, export2Excel, iconMounted, initComponents, initDirectives, useCurd, useForm, useModal, useModalOut, useSource, useTable };
@@ -80,5 +80,28 @@
80
80
  }
81
81
  }
82
82
 
83
+ .input-with-dialog{
84
+ position: relative;
85
+ span{
86
+ background: none;
87
+ cursor: pointer;
88
+ }
89
+
90
+ i{
91
+ position: absolute;
92
+ right: 15px;
93
+ top: 0;
94
+ bottom: 0;
95
+ margin: auto;
96
+ line-height: 32px;
97
+ opacity: 0.3;
98
+ cursor: pointer;
99
+ }
100
+
101
+ .ant-input{
102
+ color: #333;
103
+ cursor: pointer;
104
+ }
105
+ }
83
106
 
84
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-frames/ui",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "keywords": [
5
5
  "ui",
6
6
  "dt-ui"
@@ -18,7 +18,8 @@
18
18
  ...{
19
19
  onRegister: { type: Function },
20
20
  formProps: {
21
- type: Object as PropType<Ref<Partial<FormProps>>>
21
+ type: Object as PropType<Partial<FormProps>>,
22
+ default: () => ({})
22
23
  },
23
24
  formsVal: {
24
25
  type: Object as PropType<Ref<Recordable>>
@@ -39,7 +40,7 @@
39
40
  })
40
41
 
41
42
  const [ registerForm, { getFormValues, setFormValues } ] = useForm({
42
- ...( props.formProps.value || {} ),
43
+ ...( props.formProps || {} ),
43
44
  schemas: props.schemas,
44
45
  mode: 'dialog'
45
46
  })
@@ -80,5 +80,28 @@
80
80
  }
81
81
  }
82
82
 
83
+ .input-with-dialog{
84
+ position: relative;
85
+ span{
86
+ background: none;
87
+ cursor: pointer;
88
+ }
89
+
90
+ i{
91
+ position: absolute;
92
+ right: 15px;
93
+ top: 0;
94
+ bottom: 0;
95
+ margin: auto;
96
+ line-height: 32px;
97
+ opacity: 0.3;
98
+ cursor: pointer;
99
+ }
100
+
101
+ .ant-input{
102
+ color: #333;
103
+ cursor: pointer;
104
+ }
105
+ }
83
106
 
84
107
 
@@ -3,10 +3,12 @@ import { Component } from "vue"
3
3
  import { Input, Select, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, TreeSelect, Slider, Rate, Divider } from 'ant-design-vue'
4
4
  import RadioButtonGroup from './components/radioButton.vue'
5
5
  import FormIcon from './components/formIcon.vue'
6
+ import formInputUseDialog from './components/formInputUseDialog.vue'
6
7
  import { ComponentType } from "./types/form.type"
7
8
 
8
9
  const components = {
9
10
  Input,
11
+ InputWithDialog: formInputUseDialog,
10
12
  InputTextArea: Input.TextArea,
11
13
  InputSearch: Input.Search,
12
14
  InputGroup: Input.Group,
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div class="input-with-dialog">
3
+ <div @click="onClickInput">
4
+ <Input v-bind="bindProps"></Input>
5
+ </div>
6
+ <i class="i mdi:close-circle" @click="clearProps"></i>
7
+ </div>
8
+ </template>
9
+
10
+ <script lang="ts" setup>
11
+ import { computed, useAttrs } from 'vue'
12
+ import { Input } from 'ant-design-vue'
13
+ import { omit } from 'lodash-es'
14
+ import { error, isFunction } from '@dt-frames/core'
15
+
16
+ const attrs = useAttrs()
17
+
18
+ const bindProps = computed(() => {
19
+ return {
20
+ ...omit(attrs, [
21
+ 'formValues'
22
+ ]),
23
+ disabled: true
24
+ }
25
+ })
26
+
27
+ function onClickInput() {
28
+ const { model, schema = { } } = attrs.formValues as any
29
+
30
+ if( !schema.openDialog || !isFunction(schema.openDialog) ) {
31
+ error('openDialog必须是函数')
32
+ return
33
+ }
34
+
35
+ schema.openDialog( model )
36
+ }
37
+
38
+ function clearProps() {
39
+ const { model, schema = { } } = attrs.formValues as any
40
+ [...schema.linkProps, schema.name].forEach( it => model[it] = null )
41
+ }
42
+
43
+ </script>
@@ -32,7 +32,7 @@
32
32
  const { defaultValues, formModel, schema } = props;
33
33
 
34
34
  return {
35
- name: schema.name,
35
+ name: (schema as FormSchema).name,
36
36
  model: formModel,
37
37
  values: {
38
38
  ...defaultValues,
@@ -44,7 +44,7 @@
44
44
 
45
45
  // 是否显示当前条目
46
46
  const getShow = computed(() => {
47
- const { show = true, isAdvanced = true } = props.schema
47
+ const { show = true, isAdvanced = true } = props.schema as FormSchema
48
48
 
49
49
  // 是否处于收缩状态
50
50
  if( !isAdvanced ) {
@@ -61,13 +61,13 @@
61
61
  // 设置表单绑定的特殊属性,如前后缀、禁用启用、日期格式等
62
62
  const getComponentProps = computed(() => {
63
63
  const { schema, formModel, formActionType } = props
64
- let { props: cProps = {} } = schema
64
+ let { props: cProps = {} } = schema as FormSchema
65
65
 
66
66
  if (isFunction(cProps)) {
67
67
  cProps = cProps( { schema, formModel, formActionType } ) ?? {}
68
68
  }
69
69
 
70
- if (schema.component === 'Divider') {
70
+ if ((schema as FormSchema).component === 'Divider') {
71
71
  cProps = Object.assign({ type: 'horizontal' }, cProps, {
72
72
  orientation: 'left',
73
73
  plain: true,
@@ -83,7 +83,7 @@
83
83
  * 支持的类型参照 ../types/form.type.ts 中 ComponentType
84
84
  */
85
85
  function renderItem() {
86
- const { component, props: cProps, slot, render, name, colon = appConf.ui.form.colon, suffix } = props.schema
86
+ const { component, props: cProps, slot, render, name, colon = appConf.ui.form.colon, suffix } = props.schema as FormSchema
87
87
 
88
88
  // 计算label的属性
89
89
  const { labelCol, wrapperCol } = unref( useLabelWidth( schema, formProps ) )
@@ -139,7 +139,7 @@
139
139
  * 渲染Label标签元素
140
140
  */
141
141
  function renderLabel() {
142
- const { label, toolTip, subLabel, toolTipProps } = props.schema
142
+ const { label, toolTip, subLabel, toolTipProps } = props.schema as FormSchema
143
143
 
144
144
  const renderLabel
145
145
  = subLabel
@@ -164,7 +164,7 @@
164
164
  */
165
165
  function renderFormItem() {
166
166
  const { schema, formModel, formActionType } = props
167
- const { component, name, changeEvent = 'change', valueField, renderComponent, props: sProps } = props.schema
167
+ const { component, name, changeEvent = 'change', valueField, renderComponent, props: sProps } = props.schema as FormSchema
168
168
 
169
169
  const isCheck = component && ['Switch', 'Checkbox'].includes(component)
170
170
 
@@ -216,7 +216,7 @@
216
216
  // 设置表单禁用启用
217
217
  const getDisable = computed(() => {
218
218
  const { disabled: gDisabled } = props.formProps as FormProps
219
- const { dynamicDisabled } = props.schema
219
+ const { dynamicDisabled } = props.schema as FormSchema
220
220
  const { disabled: itemDisabled = false } = unref( getComponentProps )
221
221
 
222
222
  let disabled = !!gDisabled || itemDisabled
@@ -261,7 +261,7 @@
261
261
  /**
262
262
  * 所有属性汇总,包括方法、属性及值的绑定
263
263
  */
264
- const compAttr: Recordable = {
264
+ let compAttr: Recordable = {
265
265
  ...itemProps,
266
266
  ...bindValue,
267
267
  ...on
@@ -288,7 +288,7 @@
288
288
  * 处理验证规则
289
289
  */
290
290
  function handleRules(): ValidationRule[] {
291
- const { rules: defaultRules = [], component, label, dynamicRules, required } = props.schema
291
+ const { rules: defaultRules = [], component, label, dynamicRules, required } = props.schema as FormSchema
292
292
 
293
293
  // 1、如果为动态规则,则直接返回rules
294
294
  if( isFunction( dynamicRules ) ) {
@@ -19,6 +19,7 @@ export type FormCallBackParams = {
19
19
  // 组件的类型
20
20
  export type ComponentType =
21
21
  | 'Input'
22
+ | 'InputWithDialog'
22
23
  | 'InputGroup'
23
24
  | 'InputPassword'
24
25
  | 'InputSearch'
@@ -236,6 +237,11 @@ export type FormSchema = {
236
237
 
237
238
  // 是否处于收缩状态 仅在 search 模式下使用
238
239
  isAdvanced?: boolean
240
+
241
+ // 只有当类型为inputWithDialog 是否才有此属性
242
+ openDialog?: (parms: Recordable) => void
243
+ // 点击删除按钮需要清空的属性
244
+ linkProps?: string[]
239
245
  }
240
246
 
241
247
 
@@ -61,7 +61,13 @@ export function useModalOut(): UseModalReturnType{
61
61
  getInstance()?.redoModalHeight?.()
62
62
  },
63
63
 
64
- openModal: (params?: Recordable, openOnSet = true) => {
64
+ openModal: (
65
+ params?: {
66
+ data?: Recordable,
67
+ afterClose?: ( data: Recordable ) => void
68
+ },
69
+ openOnSet = true
70
+ ) => {
65
71
  getInstance()?.setModalProps({
66
72
  visible: true
67
73
  })