@dinert/element-plus 1.0.0 → 1.0.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.
Files changed (141) hide show
  1. package/README.md +335 -36
  2. package/dist/element-plus.umd.js +2 -0
  3. package/dist/element-plus.umd.js.map +1 -0
  4. package/dist/style.css +1 -0
  5. package/es/node_modules/@element-plus/icons-vue/dist/index.mjs +66 -0
  6. package/es/node_modules/@element-plus/icons-vue/dist/index.mjs.map +1 -0
  7. package/es/packages/assets/scss/dinert-form.scss.mjs +5 -0
  8. package/es/packages/assets/scss/dinert-form.scss.mjs.map +1 -0
  9. package/es/packages/assets/scss/dinert-table-page.scss.mjs +5 -0
  10. package/es/packages/assets/scss/dinert-table-page.scss.mjs.map +1 -0
  11. package/es/packages/assets/scss/dinert-table.scss.mjs +5 -0
  12. package/es/packages/assets/scss/dinert-table.scss.mjs.map +1 -0
  13. package/es/packages/assets/scss/dinert-tooltip.scss.mjs +5 -0
  14. package/es/packages/assets/scss/dinert-tooltip.scss.mjs.map +1 -0
  15. package/es/packages/components/form/index.mjs +10 -0
  16. package/es/packages/components/form/index.mjs.map +1 -0
  17. package/es/packages/components/form/src/cascader.mjs +49 -0
  18. package/es/packages/components/form/src/cascader.mjs.map +1 -0
  19. package/es/packages/components/form/src/checkbox.mjs +44 -0
  20. package/es/packages/components/form/src/checkbox.mjs.map +1 -0
  21. package/es/packages/components/form/src/date.mjs +47 -0
  22. package/es/packages/components/form/src/date.mjs.map +1 -0
  23. package/es/packages/components/form/src/index.mjs +229 -0
  24. package/es/packages/components/form/src/index.mjs.map +1 -0
  25. package/es/packages/components/form/src/input-autocomplete.mjs +35 -0
  26. package/es/packages/components/form/src/input-autocomplete.mjs.map +1 -0
  27. package/es/packages/components/form/src/input-number.mjs +39 -0
  28. package/es/packages/components/form/src/input-number.mjs.map +1 -0
  29. package/es/packages/components/form/src/input.mjs +43 -0
  30. package/es/packages/components/form/src/input.mjs.map +1 -0
  31. package/es/packages/components/form/src/radio.mjs +48 -0
  32. package/es/packages/components/form/src/radio.mjs.map +1 -0
  33. package/es/packages/components/form/src/rate.mjs +35 -0
  34. package/es/packages/components/form/src/rate.mjs.map +1 -0
  35. package/es/packages/components/form/src/select.mjs +45 -0
  36. package/es/packages/components/form/src/select.mjs.map +1 -0
  37. package/es/packages/components/form/src/switch.mjs +36 -0
  38. package/es/packages/components/form/src/switch.mjs.map +1 -0
  39. package/es/packages/components/form/src/tree-select.mjs +43 -0
  40. package/es/packages/components/form/src/tree-select.mjs.map +1 -0
  41. package/es/packages/components/form/utils/index.mjs +49 -0
  42. package/es/packages/components/form/utils/index.mjs.map +1 -0
  43. package/es/packages/components/index.mjs +11 -0
  44. package/es/packages/components/index.mjs.map +1 -0
  45. package/es/packages/components/table/hooks/index.mjs +30 -0
  46. package/es/packages/components/table/hooks/index.mjs.map +1 -0
  47. package/es/packages/components/table/index.mjs +10 -0
  48. package/es/packages/components/table/index.mjs.map +1 -0
  49. package/es/packages/components/table/src/index.mjs +177 -0
  50. package/es/packages/components/table/src/index.mjs.map +1 -0
  51. package/es/packages/components/table/src/recuve-table-column.mjs +235 -0
  52. package/es/packages/components/table/src/recuve-table-column.mjs.map +1 -0
  53. package/es/packages/components/table-page/index.mjs +10 -0
  54. package/es/packages/components/table-page/index.mjs.map +1 -0
  55. package/es/packages/components/table-page/src/index.mjs +77 -0
  56. package/es/packages/components/table-page/src/index.mjs.map +1 -0
  57. package/es/packages/components/tooltip/index.mjs +10 -0
  58. package/es/packages/components/tooltip/index.mjs.map +1 -0
  59. package/es/packages/components/tooltip/src/index.mjs +56 -0
  60. package/es/packages/components/tooltip/src/index.mjs.map +1 -0
  61. package/es/packages/hooks/useTablePage/index.mjs +136 -0
  62. package/es/packages/hooks/useTablePage/index.mjs.map +1 -0
  63. package/es/packages/hooks/useWindowResize.mjs +16 -0
  64. package/es/packages/hooks/useWindowResize.mjs.map +1 -0
  65. package/es/packages/index.mjs +21 -0
  66. package/es/packages/index.mjs.map +1 -0
  67. package/es/packages/utils/tools.mjs +54 -0
  68. package/es/packages/utils/tools.mjs.map +1 -0
  69. package/es/src/components/form/index.d.ts +32 -0
  70. package/es/src/components/form/src/checkbox.d.ts +28 -0
  71. package/es/src/components/form/src/date.d.ts +28 -0
  72. package/es/src/components/form/src/index.d.ts +32 -0
  73. package/es/src/components/form/src/input-autocomplete.d.ts +28 -0
  74. package/es/src/components/form/src/input-number.d.ts +28 -0
  75. package/es/src/components/form/src/input.d.ts +28 -0
  76. package/es/src/components/form/src/radio.d.ts +28 -0
  77. package/es/src/components/form/src/rate.d.ts +28 -0
  78. package/es/src/components/form/src/switch.d.ts +28 -0
  79. package/es/src/components/form/src/tree-select.d.ts +39 -0
  80. package/es/src/components/form/types/index.d.ts +41 -0
  81. package/es/src/components/form/utils/index.d.ts +5 -0
  82. package/es/src/components/index.d.ts +7 -0
  83. package/es/src/components/table/hooks/index.d.ts +14 -0
  84. package/es/src/components/table/index.d.ts +608 -0
  85. package/es/src/components/table/src/index.d.ts +609 -0
  86. package/es/src/components/table/src/recuve-table-column.d.ts +43 -0
  87. package/es/src/components/table/types/index.d.ts +82 -0
  88. package/es/src/components/table-page/index.d.ts +1329 -0
  89. package/es/src/components/table-page/src/index.d.ts +1330 -0
  90. package/es/src/components/tooltip/index.d.ts +60 -0
  91. package/es/src/components/tooltip/src/index.d.ts +59 -0
  92. package/es/src/components/tooltip/types/index.d.ts +10 -0
  93. package/es/src/hooks/useTablePage/index.d.ts +49 -0
  94. package/es/src/hooks/useTablePage/types/index.d.ts +29 -0
  95. package/es/src/hooks/useWindowResize.d.ts +2 -0
  96. package/es/src/index.d.ts +7 -0
  97. package/es/src/utils/tools.d.ts +19 -0
  98. package/es/src/views/test-table/data.d.ts +21 -0
  99. package/es/src/views/test-table/tableColumns.d.ts +9 -0
  100. package/es/src/views/test-table-page/data.d.ts +2 -0
  101. package/es/src/views/test-table-page/formItem.d.ts +1 -0
  102. package/es/src/views/test-table-page/types/index.d.ts +23 -0
  103. package/es/style.css +1 -0
  104. package/lib/index.js +2 -0
  105. package/lib/index.js.map +1 -0
  106. package/lib/src/components/form/index.d.ts +32 -0
  107. package/lib/src/components/form/src/checkbox.d.ts +28 -0
  108. package/lib/src/components/form/src/date.d.ts +28 -0
  109. package/lib/src/components/form/src/index.d.ts +32 -0
  110. package/lib/src/components/form/src/input-autocomplete.d.ts +28 -0
  111. package/lib/src/components/form/src/input-number.d.ts +28 -0
  112. package/lib/src/components/form/src/input.d.ts +28 -0
  113. package/lib/src/components/form/src/radio.d.ts +28 -0
  114. package/lib/src/components/form/src/rate.d.ts +28 -0
  115. package/lib/src/components/form/src/switch.d.ts +28 -0
  116. package/lib/src/components/form/src/tree-select.d.ts +39 -0
  117. package/lib/src/components/form/types/index.d.ts +41 -0
  118. package/lib/src/components/form/utils/index.d.ts +5 -0
  119. package/lib/src/components/index.d.ts +7 -0
  120. package/lib/src/components/table/hooks/index.d.ts +14 -0
  121. package/lib/src/components/table/index.d.ts +608 -0
  122. package/lib/src/components/table/src/index.d.ts +609 -0
  123. package/lib/src/components/table/src/recuve-table-column.d.ts +43 -0
  124. package/lib/src/components/table/types/index.d.ts +82 -0
  125. package/lib/src/components/table-page/index.d.ts +1329 -0
  126. package/lib/src/components/table-page/src/index.d.ts +1330 -0
  127. package/lib/src/components/tooltip/index.d.ts +60 -0
  128. package/lib/src/components/tooltip/src/index.d.ts +59 -0
  129. package/lib/src/components/tooltip/types/index.d.ts +10 -0
  130. package/lib/src/hooks/useTablePage/index.d.ts +49 -0
  131. package/lib/src/hooks/useTablePage/types/index.d.ts +29 -0
  132. package/lib/src/hooks/useWindowResize.d.ts +2 -0
  133. package/lib/src/index.d.ts +7 -0
  134. package/lib/src/utils/tools.d.ts +19 -0
  135. package/lib/src/views/test-table/data.d.ts +21 -0
  136. package/lib/src/views/test-table/tableColumns.d.ts +9 -0
  137. package/lib/src/views/test-table-page/data.d.ts +2 -0
  138. package/lib/src/views/test-table-page/formItem.d.ts +1 -0
  139. package/lib/src/views/test-table-page/types/index.d.ts +23 -0
  140. package/lib/style.css +1 -0
  141. package/package.json +92 -86
@@ -0,0 +1,136 @@
1
+ import { ref as r } from "vue";
2
+ import { getUuid as u } from "../../utils/tools.mjs";
3
+ import l from "lodash";
4
+ class c {
5
+ constructor(a) {
6
+ this.selecTableDatas = r([]), this.lastSelectDatas = r([]), this.ids = r([]), this.tablePageRef = r(null), this.defaultOptions = {
7
+ table: {
8
+ rowKey: "id",
9
+ className: "table_page" + u(),
10
+ tableColumns: [],
11
+ data: [],
12
+ key: !0,
13
+ border: !0,
14
+ tableSlot: !0,
15
+ pagination: {
16
+ total: 0,
17
+ currentPage: 1,
18
+ pageSize: 10,
19
+ pageSizes: [10, 20, 30, 50, 100]
20
+ },
21
+ on: {}
22
+ },
23
+ form: {
24
+ model: {},
25
+ formItem: {}
26
+ },
27
+ footer: !1,
28
+ search: !1
29
+ }, this.firstOptions = {
30
+ table: {
31
+ tableColumns: [],
32
+ data: [],
33
+ key: !0,
34
+ pagination: {}
35
+ },
36
+ form: { model: {}, formItem: {} }
37
+ }, this.getTableParams = () => ({}), this.ajaxTableDataAfter = () => ({}), this.lookOperations = () => ({}), this.editOperations = () => ({}), this.addOperations = () => ({}), this.deleteOperations = () => ({}), this.importOperations = () => ({}), this.options = l.defaultsDeep(l.cloneDeep(a), this.defaultOptions), this.firstOptions = l.cloneDeep(this.options), this.table = r(this.options.table), this.form = r(this.options.form), this.footer = r(this.options.footer), this.showSearch = r(this.options.search), this.params = {}, this.oldParams = {}, this.tableSelectEvent();
38
+ }
39
+ // 导入
40
+ sizeChange(a) {
41
+ const e = this.table.value.pagination.pageSize;
42
+ this.table.value.pagination.pageSize = a;
43
+ const t = this.table.value.pagination;
44
+ (e > a || t.currentPage <= Math.ceil(t.total / t.pageSize)) && this.search({ name: "size", pageSize: a });
45
+ }
46
+ currentChange(a) {
47
+ this.table.value.pagination.currentPage = a, this.search({ name: "current", currentPage: a });
48
+ }
49
+ async getTableData(a) {
50
+ const e = await this.ajaxTableData(a);
51
+ return this.changeTableData(e.data), typeof this.ajaxTableDataAfter == "function" && this.ajaxTableDataAfter(e), this.table.value.key = !this.table.value.key, e;
52
+ }
53
+ changeTableData(a) {
54
+ if (a && a.data && a.data.length)
55
+ for (let e = 0; e < a.data.length; e++)
56
+ a.data[e].index = e + 1 + a.pageNum * a.pageSize;
57
+ this.table.value.data = a.data, this.table.value.pagination.total = a.total;
58
+ }
59
+ // 获取请求的所有参数
60
+ getAjaxTableDataParams(a) {
61
+ this.params = this.getTableParams(a);
62
+ const e = l.isEqual(this.params, this.oldParams);
63
+ return a.name === "search" ? (e || (this.table.value.pagination.currentPage = 1, this.params = this.getTableParams(a)), this.oldParams = l.cloneDeep(this.params)) : a.name === "reset" ? (this.resetPagination(), this.params = this.getTableParams(a), this.oldParams = l.cloneDeep(this.params)) : a.name === "delete" ? this.table.value.data && this.table.value.data.length && this.table.value.data.length === 1 && this.table.value.pagination.currentPage > 1 && (this.table.value.pagination.currentPage = 2, this.params = this.getTableParams(a)) : a.name === "current" ? (this.oldParams.data && this.oldParams.data.pageNum ? this.oldParams.data.pageNum = a.currentPage : this.oldParams.data && this.oldParams.data.page ? this.oldParams.data.page = a.currentPage : this.oldParams.params && this.oldParams.params.page ? this.oldParams.params.page = a.currentPage : this.oldParams.params && this.oldParams.params.pageNum && (this.oldParams.params.pageNum = a.currentPage), this.oldParams.data && this.oldParams.data.pageSize ? this.oldParams.data.pageSize = this.table.value.pagination.pageSize : this.oldParams.params && this.oldParams.params.pageSize && (this.oldParams.params.pageSize = this.table.value.pagination.pageSize), this.params = l.cloneDeep(this.oldParams)) : a.name === "size" && (this.oldParams.data && this.oldParams.data.pageSize ? this.oldParams.data.pageSize = a.pageSize : this.oldParams.params && this.oldParams.params.pageSize && (this.oldParams.params.pageSize = a.pageSize), this.params = l.cloneDeep(this.oldParams)), (!["size", "current"].includes(a.name || "") || !this.table.value.rowKey) && (this.selecTableDatas.value = []), this.params;
64
+ }
65
+ // 请求
66
+ ajaxTableData(a) {
67
+ return new Promise((e) => {
68
+ e(this.getAjaxTableDataParams(a));
69
+ });
70
+ }
71
+ // 查询
72
+ search(a = { name: "search" }) {
73
+ var e, t;
74
+ for (const s in (e = this.form.value) == null ? void 0 : e.model)
75
+ [null, void 0, ""].includes(this.form.value.model[s]) && ((t = this.form.value) == null || delete t.model[s]);
76
+ return this.getTableData(a);
77
+ }
78
+ // 重置查询
79
+ resetSearch(a = { name: "reset" }) {
80
+ this.resetParams(), this.search(a);
81
+ }
82
+ // 重置分页参数
83
+ resetPagination() {
84
+ this.table.value.pagination = this.defaultOptions.table.pagination;
85
+ }
86
+ // 重置表格请求参数
87
+ resetParams() {
88
+ var a, e, t, s, h, o, n;
89
+ if (l.isEmpty((a = this.firstOptions.form) == null ? void 0 : a.model))
90
+ for (const i in (e = this.form.value) == null ? void 0 : e.model)
91
+ (t = this.form.value) == null || delete t.model[i];
92
+ else {
93
+ for (const i in (s = this.form.value) == null ? void 0 : s.model)
94
+ (h = this.form.value) == null || delete h.model[i];
95
+ for (const i in (o = this.firstOptions.form) == null ? void 0 : o.model)
96
+ this.form.value.model[i] = (n = this.firstOptions.form) == null ? void 0 : n.model[i];
97
+ }
98
+ }
99
+ // 清空参数
100
+ clearParams() {
101
+ var a;
102
+ for (const e in (a = this.form.value) == null ? void 0 : a.model)
103
+ delete this.form.value.model[e];
104
+ }
105
+ // 根据key获取表格中的数据
106
+ getTableDataKeys(a = "id") {
107
+ return this.ids.value = l.map(this.table.value.data || [], a), this.ids.value;
108
+ }
109
+ // 回显选中
110
+ echoOperations() {
111
+ const a = this.table.value.rowKey, e = (this.selecTableDatas.value || []).map((t) => t[a]);
112
+ this.tablePageRef.value && (this.table.value.data || []).forEach((t) => {
113
+ var s, h, o, n, i, m;
114
+ e.includes(t[a]) ? (o = (h = (s = this.tablePageRef.value) == null ? void 0 : s.tableRef) == null ? void 0 : h.tableRef) == null || o.toggleRowSelection(t, !0) : (m = (i = (n = this.tablePageRef.value) == null ? void 0 : n.tableRef) == null ? void 0 : i.tableRef) == null || m.toggleRowSelection(t, !1);
115
+ });
116
+ }
117
+ // 监听表格选择事件,包括全选和单选
118
+ tableSelectEvent() {
119
+ const a = this.table.value.rowKey;
120
+ this.table.value.on && (this.table.value.on.onSelect || (this.table.value.on.onSelect = (e) => {
121
+ a ? (this.table.value.data.forEach((t) => {
122
+ for (let s = 0; s < this.selecTableDatas.value.length; s++)
123
+ t[a] === this.selecTableDatas.value[s][a] && this.selecTableDatas.value.splice(s, 1);
124
+ }), this.selecTableDatas.value = l.uniqBy(e.concat(this.selecTableDatas.value), a)) : this.selecTableDatas.value = e;
125
+ }), this.table.value.on["onSelect-all"] || (this.table.value.on["onSelect-all"] = (e) => {
126
+ a ? e.length === 0 ? this.table.value.data.forEach((t) => {
127
+ for (let s = 0; s < this.selecTableDatas.value.length; s++)
128
+ t[a] === this.selecTableDatas.value[s][a] && this.selecTableDatas.value.splice(s, 1);
129
+ }) : this.selecTableDatas.value = l.uniqBy(e.concat(this.selecTableDatas.value), a) : this.selecTableDatas.value = e;
130
+ }));
131
+ }
132
+ }
133
+ export {
134
+ c as default
135
+ };
136
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../../packages/hooks/useTablePage/index.ts"],"sourcesContent":["\nimport {Ref, ref} from 'vue'\n\nimport type {RewriteFormProps} from '@packages/components/form/types'\nimport type {RewriteTableProps} from '@packages/components/table/types'\n\nimport type {DinertTablePageProps, AjaxTableProps, ScopeFn} from '@packages/hooks/useTablePage/types'\n\nimport TablePageCom from '@packages/components/table-page/index'\nimport {getUuid} from '@packages/utils/tools'\nimport lodash from 'lodash'\n\n/**\n * T 表格data数据格式\n * D 表单model的数据格式\n * P 发起请求的数据格式\n * R 请求回来的数据格式\n */\n\n\nclass TablePage<T, D = any, P = any, R = any> {\n showSearch: Ref<DinertTablePageProps['search']>\n table: Ref<RewriteTableProps<T>>\n form: Ref<RewriteFormProps<D>>\n footer: Ref<DinertTablePageProps['footer']>\n\n selecTableDatas: Ref<T[]> = ref([])\n lastSelectDatas: Ref<T[]> = ref([])\n\n options: DinertTablePageProps<T, D>\n\n ids: Ref<string[]> = ref([])\n\n params: P | any\n oldParams: P | any\n\n tablePageRef: Ref<InstanceType<typeof TablePageCom> | null> = ref(null)\n\n private readonly defaultOptions: DinertTablePageProps<T, D> = {\n table: {\n rowKey: 'id',\n className: 'table_page' + getUuid(),\n tableColumns: [],\n data: [],\n key: true,\n border: true,\n tableSlot: true,\n pagination: {\n total: 0,\n currentPage: 1,\n pageSize: 10,\n pageSizes: [10, 20, 30, 50, 100],\n },\n on: {\n }\n },\n form: {\n model: {},\n formItem: {}\n },\n footer: false,\n search: false\n }\n\n\n private readonly firstOptions: DinertTablePageProps<T, D> = {\n table: {\n tableColumns: [],\n data: [],\n key: true,\n pagination: {}\n },\n form: {model: {}, formItem: {}}\n }\n\n\n constructor(options: DinertTablePageProps<T, D>) {\n\n this.options = lodash.defaultsDeep(lodash.cloneDeep(options), this.defaultOptions)\n\n this.firstOptions = lodash.cloneDeep(this.options)\n\n this.table = ref<DinertTablePageProps['table'] | any>(this.options.table)\n\n this.form = ref<RewriteFormProps<D | any>>(this.options.form)\n\n this.footer = ref<DinertTablePageProps['footer']>(this.options.footer)\n\n this.showSearch = ref<DinertTablePageProps['search']>(this.options.search)\n\n this.params = {}\n this.oldParams = {}\n\n // 监听表格选择的方法,方便表格数据回显\n this.tableSelectEvent()\n }\n\n // 获取请求参数\n getTableParams: (params: P) => (Partial<P>) = () => ({} as any)\n ajaxTableDataAfter: (res: R) => void = () => ({})\n\n lookOperations: ScopeFn<T> = () => ({}) // 查看\n editOperations: ScopeFn<T> = () => ({}) // 编辑\n addOperations: ScopeFn<T> = () => ({}) // 添加\n deleteOperations: ScopeFn<T> = () => ({}) // 删除\n importOperations: ScopeFn<T> = () => ({}) // 导入\n\n sizeChange(size: number) {\n\n const pageSize = this.table.value.pagination.pageSize\n this.table.value.pagination.pageSize = size\n const pagination = this.table.value.pagination\n if ((pageSize as any) > size\n || (pagination.currentPage as any) <= Math.ceil((pagination.total as any) / (pagination.pageSize as any))) {\n this.search({name: 'size', pageSize: size})\n }\n\n }\n\n currentChange(currentPage: number) {\n this.table.value.pagination.currentPage = currentPage\n this.search({name: 'current', currentPage})\n }\n\n async getTableData(options: (P & AjaxTableProps) | any) {\n const res = await this.ajaxTableData(options)\n this.changeTableData(res.data as R)\n\n typeof this.ajaxTableDataAfter === 'function' && this.ajaxTableDataAfter(res)\n\n this.table.value.key = !this.table.value.key\n return res\n }\n\n changeTableData(res: R | any) {\n if (res && res.data && res.data.length) {\n for (let i = 0; i < res.data.length; i++) {\n res.data[i].index = i + 1 + (res.pageNum as number) * (res.pageSize as number)\n }\n }\n this.table.value.data = res.data\n this.table.value.pagination.total = res.total\n }\n\n // 获取请求的所有参数\n getAjaxTableDataParams(options: (P & AjaxTableProps) | any) {\n this.params = this.getTableParams(options)\n\n const isSame = lodash.isEqual(this.params, this.oldParams) // 判断当前提交的参数和上一次提交的参数是否相同\n\n if (options.name === 'search') {\n if (!isSame) {\n this.table.value.pagination.currentPage = 1\n this.params = this.getTableParams(options)\n }\n\n this.oldParams = lodash.cloneDeep(this.params)\n } else if (options.name === 'reset') {\n this.resetPagination()\n this.params = this.getTableParams(options)\n\n this.oldParams = lodash.cloneDeep(this.params)\n } else if (options.name === 'delete') {\n if (this.table.value.data && this.table.value.data.length) {\n if (this.table.value.data.length === 1 && (this.table.value as any).pagination.currentPage > 1) {\n this.table.value.pagination.currentPage = 2\n\n this.params = this.getTableParams(options)\n }\n }\n } else if (options.name === 'current') {\n if (this.oldParams.data && this.oldParams.data.pageNum) {\n this.oldParams.data.pageNum = options.currentPage\n } else if (this.oldParams.data && this.oldParams.data.page) {\n this.oldParams.data.page = options.currentPage\n } else if (this.oldParams.params && this.oldParams.params.page) {\n this.oldParams.params.page = options.currentPage\n } else if (this.oldParams.params && this.oldParams.params.pageNum) {\n this.oldParams.params.pageNum = options.currentPage\n }\n\n if (this.oldParams.data && this.oldParams.data.pageSize) {\n this.oldParams.data.pageSize = this.table.value.pagination.pageSize\n } else if (this.oldParams.params && this.oldParams.params.pageSize) {\n this.oldParams.params.pageSize = this.table.value.pagination.pageSize\n }\n\n this.params = lodash.cloneDeep(this.oldParams)\n } else if (options.name === 'size') {\n if (this.oldParams.data && this.oldParams.data.pageSize) {\n this.oldParams.data.pageSize = options.pageSize\n } else if (this.oldParams.params && this.oldParams.params.pageSize) {\n this.oldParams.params.pageSize = options.pageSize\n }\n\n this.params = lodash.cloneDeep(this.oldParams)\n }\n if (!['size', 'current'].includes(options.name || '') || !this.table.value.rowKey) {\n this.selecTableDatas.value = []\n }\n\n return this.params\n }\n\n // 请求\n ajaxTableData(options: (P & AjaxTableProps)): Promise<R | any> {\n return new Promise(resolve => {\n resolve(this.getAjaxTableDataParams(options))\n })\n }\n\n\n // 查询\n search(options: (P & AjaxTableProps) | any = {name: 'search'}) {\n\n for (const prop in this.form.value?.model) {\n if ([null, undefined, ''].includes((this.form.value.model as any)[prop])) {\n delete this.form.value?.model[prop]\n }\n }\n return this.getTableData(options)\n }\n\n // 重置查询\n resetSearch(options: (P & AjaxTableProps) | any = {name: 'reset'}) {\n this.resetParams()\n this.search(options)\n }\n\n\n // 重置分页参数\n resetPagination() {\n this.table.value.pagination = this.defaultOptions.table.pagination\n }\n\n // 重置表格请求参数\n resetParams() {\n if (lodash.isEmpty(this.firstOptions.form?.model)) { // 判断查询的默认参数是否为空\n for (const prop in this.form.value?.model) {\n delete this.form.value?.model[prop]\n }\n } else {\n for (const prop in this.form.value?.model) {\n delete this.form.value?.model[prop]\n }\n for (const prop in this.firstOptions.form?.model) {\n this.form.value.model[prop] = this.firstOptions.form?.model[prop]\n }\n }\n }\n\n // 清空参数\n clearParams() {\n for (const prop in this.form.value?.model) {\n delete this.form.value.model[prop]\n }\n }\n\n // 根据key获取表格中的数据\n getTableDataKeys(key: string = 'id') {\n this.ids.value = lodash.map(this.table.value.data || [], key)\n return this.ids.value\n }\n\n // 回显选中\n echoOperations() {\n const rowKey = this.table.value.rowKey as any\n const keys = (this.selecTableDatas.value || []).map((item: any) => item[rowKey])\n if (this.tablePageRef.value) {\n (this.table.value.data || []).forEach((item: any) => {\n if (keys.includes(item[rowKey])) {\n this.tablePageRef.value?.tableRef?.tableRef?.toggleRowSelection(item, true)\n } else {\n this.tablePageRef.value?.tableRef?.tableRef?.toggleRowSelection(item, false)\n }\n })\n }\n\n }\n\n // 监听表格选择事件,包括全选和单选\n tableSelectEvent() {\n const rowKey: any = this.table.value.rowKey\n if (this.table.value.on) {\n if (!this.table.value.on.onSelect) {\n this.table.value.on.onSelect = (selection: T[]) => {\n if (rowKey) {\n this.table.value.data.forEach((item: any) => {\n for (let i = 0; i < this.selecTableDatas.value.length; i++) {\n if (item[rowKey] === (this.selecTableDatas.value[i]as any)[rowKey]) {\n this.selecTableDatas.value.splice(i, 1)\n }\n }\n })\n this.selecTableDatas.value = lodash.uniqBy(selection.concat(this.selecTableDatas.value), rowKey)\n } else {\n this.selecTableDatas.value = selection\n }\n }\n }\n if (!this.table.value.on['onSelect-all']) {\n this.table.value.on['onSelect-all'] = (selection: T[]) => {\n if (rowKey) {\n if (selection.length === 0) {\n this.table.value.data.forEach((item: any) => {\n for (let i = 0; i < this.selecTableDatas.value.length; i++) {\n if (item[rowKey] === (this.selecTableDatas.value[i] as any)[rowKey]) {\n this.selecTableDatas.value.splice(i, 1)\n }\n }\n })\n } else {\n this.selecTableDatas.value = lodash.uniqBy(selection.concat(this.selecTableDatas.value), rowKey)\n }\n\n } else {\n this.selecTableDatas.value = selection\n }\n }\n }\n }\n }\n}\n\n\nexport default TablePage\n"],"names":["TablePage","options","ref","getUuid","lodash","size","pageSize","pagination","currentPage","res","i","isSame","resolve","prop","_a","_b","_c","_d","_e","_f","_g","key","rowKey","keys","item","selection"],"mappings":";;;AAoBA,MAAMA,EAAwC;AAAA,EAwD1C,YAAYC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rB,KAAK,MAAM,MAAM,GAAG,WAAW,CAACG,MAAmB;AAC/C,MAAIH,KACA,KAAK,MAAM,MAAM,KAAK,QAAQ,CAACE,MAAc;AACzC,iBAASd,IAAI,GAAGA,IAAI,KAAK,gBAAgB,MAAM,QAAQA;AAC/C,UAAAc,EAAKF,CAAM,MAAO,KAAK,gBAAgB,MAAMZ,CAAC,EAASY,CAAM,KAC7D,KAAK,gBAAgB,MAAM,OAAOZ,GAAG,CAAC;AAAA,MAE9C,CACH,GACI,KAAA,gBAAgB,QAAQN,EAAO,OAAOqB,EAAU,OAAO,KAAK,gBAAgB,KAAK,GAAGH,CAAM,KAE/F,KAAK,gBAAgB,QAAQG;AAAA,IACjC,IAGH,KAAK,MAAM,MAAM,GAAG,cAAc,MACnC,KAAK,MAAM,MAAM,GAAG,cAAc,IAAI,CAACA,MAAmB;AACtD,MAAIH,IACIG,EAAU,WAAW,IACrB,KAAK,MAAM,MAAM,KAAK,QAAQ,CAACD,MAAc;AACzC,iBAASd,IAAI,GAAGA,IAAI,KAAK,gBAAgB,MAAM,QAAQA;AAC/C,UAAAc,EAAKF,CAAM,MAAO,KAAK,gBAAgB,MAAMZ,CAAC,EAAUY,CAAM,KAC9D,KAAK,gBAAgB,MAAM,OAAOZ,GAAG,CAAC;AAAA,MAE9C,CACH,IAEI,KAAA,gBAAgB,QAAQN,EAAO,OAAOqB,EAAU,OAAO,KAAK,gBAAgB,KAAK,GAAGH,CAAM,IAInG,KAAK,gBAAgB,QAAQG;AAAA,IACjC;AAAA,EAIhB;AACJ;"}
@@ -0,0 +1,16 @@
1
+ import t from "lodash";
2
+ import { onMounted as i, onUnmounted as d } from "vue";
3
+ const f = (e, n = 0, s = !1) => {
4
+ const o = t.debounce(() => {
5
+ e();
6
+ }, n);
7
+ i(() => {
8
+ s && e(), window.addEventListener("resize", o, !1);
9
+ }), d(() => {
10
+ window.removeEventListener("resize", o, !1);
11
+ });
12
+ };
13
+ export {
14
+ f as default
15
+ };
16
+ //# sourceMappingURL=useWindowResize.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWindowResize.mjs","sources":["../../../packages/hooks/useWindowResize.ts"],"sourcesContent":["/**\n * 监听浏览器缩放,使用防抖函数做触发次数太多的处理\n */\nimport lodash from 'lodash'\nimport {onMounted, onUnmounted} from 'vue'\n\nconst useWindowResize = (resize: () => void, delay: number = 0, immediate: boolean = false) => {\n const onResize = lodash.debounce(() => {\n resize()\n }, delay)\n onMounted(() => {\n if (immediate) {\n resize() // 手动触发一次\n }\n window.addEventListener('resize', onResize, false)\n })\n\n onUnmounted(() => {\n window.removeEventListener('resize', onResize, false)\n })\n}\n\nexport default useWindowResize\n"],"names":["useWindowResize","resize","delay","immediate","onResize","lodash","onMounted","onUnmounted"],"mappings":";;AAMA,MAAMA,IAAkB,CAACC,GAAoBC,IAAgB,GAAGC,IAAqB,OAAU;AACrF,QAAAC,IAAWC,EAAO,SAAS,MAAM;AAC5B,IAAAJ;KACRC,CAAK;AACR,EAAAI,EAAU,MAAM;AACZ,IAAIH,KACOF,KAEJ,OAAA,iBAAiB,UAAUG,GAAU,EAAK;AAAA,EAAA,CACpD,GAEDG,EAAY,MAAM;AACP,WAAA,oBAAoB,UAAUH,GAAU,EAAK;AAAA,EAAA,CACvD;AACL;"}
@@ -0,0 +1,21 @@
1
+ import * as o from "./components/index.mjs";
2
+ import t from "./hooks/useTablePage/index.mjs";
3
+ import { Table as p } from "./components/table/index.mjs";
4
+ import { TablePage as i } from "./components/table-page/index.mjs";
5
+ import { Form as T } from "./components/form/index.mjs";
6
+ import { Tooltip as g } from "./components/tooltip/index.mjs";
7
+ const m = t, l = {
8
+ install: (e) => {
9
+ for (const r in o)
10
+ e.use(o[r]);
11
+ }
12
+ };
13
+ export {
14
+ T as Form,
15
+ p as Table,
16
+ i as TablePage,
17
+ g as Tooltip,
18
+ m as UseTablePage,
19
+ l as default
20
+ };
21
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../packages/index.ts"],"sourcesContent":["import {Plugin, App} from 'vue'\nimport * as components from './components/index'\nimport TablePage from './hooks/useTablePage/index'\n\nexport * from './components/index'\nexport const UseTablePage: typeof TablePage = TablePage\nexport * from './hooks/useTablePage/types/index'\n\nconst myPlugin: Plugin = {\n install: (app: App) => {\n for (const name in components) {\n app.use((components as any)[name])\n }\n }\n}\n\nexport default myPlugin\n"],"names":["UseTablePage","TablePage","myPlugin","app","name","components"],"mappings":";;;;;;AAKO,MAAMA,IAAiCC,GAGxCC,IAAmB;AAAA,EACrB,SAAS,CAACC,MAAa;AACnB,eAAWC,KAAQC;AACX,MAAAF,EAAA,IAAKE,EAAmBD,CAAI,CAAC;AAAA,EAEzC;AACJ;"}
@@ -0,0 +1,54 @@
1
+ const c = () => {
2
+ const e = [], n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3
+ for (let t = 0; t < 36; t++)
4
+ e[t] = n.substr(Math.floor(Math.random() * 16), 1);
5
+ return e[14] = "4", e[19] = n.substr(+e[19] & 3 | 8, 1), e[8] = e[13] = e[18] = e[23] = "-", e.join("");
6
+ }, d = (e, n) => {
7
+ let o = e;
8
+ n = n.replace(/\[(\w+)\]/g, ".$1"), n = n.replace(/^\./, "");
9
+ const t = n.split(".");
10
+ let r = 0;
11
+ for (let u = t.length; r < u - 1 && o; ++r) {
12
+ const s = t[r];
13
+ if (s in o)
14
+ o = o[s];
15
+ else
16
+ return null;
17
+ }
18
+ return o ? o[t[r]] : null;
19
+ }, f = (e, n = "-") => [null, void 0, ""].includes(e) ? n : e, g = (e, n, o, t) => {
20
+ const r = [], u = (s) => {
21
+ for (let l = 0; l < s.length; l++)
22
+ o.includes(s[l][n]) && r.push(s[l][t]), s[l].children && s[l].children.length && u(s[l].children);
23
+ };
24
+ return u(e), r;
25
+ };
26
+ function i(e, n = "children", o = null) {
27
+ return e.reduce((t, r) => (t.push({ ...r, parentId: o }), r[n] && r[n].length && (t = t.concat(i(r[n], n, r.id))), t), []);
28
+ }
29
+ const p = (e) => String(e).replace(/[<>& "]/g, (n) => {
30
+ switch (n) {
31
+ case "<":
32
+ return "&lt;";
33
+ case ">":
34
+ return "&gt;";
35
+ case "&":
36
+ return "&amp;";
37
+ case " ":
38
+ return "&nbsp;";
39
+ case '"':
40
+ return "&quot;";
41
+ default:
42
+ return "";
43
+ }
44
+ }), h = (e) => "column_" + e.split(".").join("_");
45
+ export {
46
+ h as columnProp,
47
+ i as convertToFlat,
48
+ f as dataTransformRod,
49
+ p as escapeHTML,
50
+ d as getPropByPath,
51
+ g as getTreeNode,
52
+ c as getUuid
53
+ };
54
+ //# sourceMappingURL=tools.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.mjs","sources":["../../../packages/utils/tools.ts"],"sourcesContent":["\n// 浏览器的各种存储\nexport const storage = (name: 'localStorage' | 'sessionStorage', key: string, value?: any) => {\n if (key === 'remove') {\n return (window as any)[name].removeItem(`dinert-zhdd-${value}`)\n } else if (key === 'clear') {\n return (window as any)[name].clear()\n } else if (value) {\n return (window as any)[name].setItem(`dinert-zhdd-${key}`, JSON.stringify(value))\n } else {\n return JSON.parse((window as any)[name].getItem(`dinert-zhdd-${key}`))\n }\n}\n\n// 首字母大写\nexport const firstUpperCase = (str: string) => {\n str = String(str)\n return str.replace(/^\\S/, s => s.toUpperCase())\n}\n\n// 重写判断类型\nexport const type = (type: any) => {\n return Object.prototype.toString\n .call(type)\n .split(' ')[1]\n .split(']')[0]\n .toLocaleLowerCase()\n}\n\n// 生成唯一ID\nexport const getUuid = (): string => {\n const s = []\n const hexDigits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n for (let i = 0; i < 36; i++) {\n s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)\n }\n s[14] = '4'\n s[19] = hexDigits.substr((+s[19] & 0x3) | 0x8, 1)\n s[8] = s[13] = s[18] = s[23] = '-'\n const uuid = s.join('')\n return uuid\n}\n\n\n/**\n *\n * @param {Object} obj\n * @param {String} path\n * @returns\n */\nexport const getPropByPath = (obj: any, path: string) => {\n let tempObj = obj\n path = path.replace(/\\[(\\w+)\\]/g, '.$1')\n path = path.replace(/^\\./, '')\n\n const keyArr = path.split('.')\n let i = 0\n for (let len = keyArr.length; i < len - 1; ++i) {\n // eslint-disable-next-line max-statements-per-line\n if (!tempObj) {break}\n const key = keyArr[i]\n if (key in tempObj) {\n tempObj = tempObj[key]\n } else {\n return null\n // break;\n }\n }\n return tempObj ? tempObj[keyArr[i]] : null\n}\n\nexport const dataTransformRod = (data: any, errData: any = '-') => {\n return [null, undefined, ''].includes(data) ? errData : data\n}\n\n// 获取树指定的所有节点\nexport const getTreeNode = <T = any>(treeData: any, name: string, value: any, key: string): T[] => {\n const result: T[] = []\n // eslint-disable-next-line consistent-return\n const treeNode = (treeData2: any) => {\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < treeData2.length; i++) {\n if (value.includes(treeData2[i][name])) {\n result.push(treeData2[i][key])\n }\n if (treeData2[i].children && treeData2[i].children.length) {\n treeNode(treeData2[i].children)\n }\n }\n\n }\n treeNode(treeData)\n return result\n}\n\n// 树转扁平\nexport function convertToFlat<T = any>(data: T[], children: string = 'children', parentId: any = null): T[] {\n return data.reduce((acc: any, curr: any) => {\n acc.push({...curr, parentId})\n if (curr[children] && curr[children].length) {\n acc = acc.concat(convertToFlat(curr[children], children, curr.id))\n }\n return acc\n }, [])\n}\n\n// 格式化手机号\nexport function formatPhone(value: string): string {\n if (!/^1[3|4|5|7|8|9][0-9]\\d{4,8}$/.test(value)\n || value.length !== 11) {\n return value\n } else {\n const mobile = value.replace(/^(.{3})(.*)(.{4})/, '$1-$2-$3')\n return mobile\n }\n}\n\n// 下载文件\nexport const downFile = (response: any): any => {\n const content = response.data\n // blob内容是json,不下载\n if (response.headers['content-type'] === 'application/json;charset=UTF-8') {\n return response\n }\n const data = new Blob([content], {\n type: response.headers['content-type']\n })\n const downloadUrl = window.URL.createObjectURL(data)\n\n if (response.config.headers.prohibitDownload) {\n return downloadUrl\n }\n const anchor = document.createElement('a')\n anchor.href = downloadUrl\n let filename = response.headers['content-disposition'].split('=')[1]\n filename = filename.split(';')[0]\n anchor.download = decodeURIComponent(filename)\n anchor.target = '_blank'\n anchor.click()\n window.URL.revokeObjectURL((data as any))\n return true\n}\n\n// 转化数组为字符串\nexport const formatterArray = (cellValue: any) => {\n if (cellValue instanceof Array) {\n const joinValue = cellValue.join(',')\n return joinValue || '-'\n } else if (cellValue) {\n return cellValue\n } else {\n return '-'\n }\n}\n\n\n// 预防xss攻击\nexport const escapeHTML = (str: any) => {\n // eslint-disable-next-line consistent-return\n return String(str).replace(/[<>& \"]/g, (match: any) => {\n switch (match) {\n case '<':\n return '&lt;'\n case '>':\n return '&gt;'\n case '&':\n return '&amp;'\n case ' ':\n return '&nbsp;'\n case '\"':\n return '&quot;'\n default:\n return ''\n }\n })\n}\n\nexport const columnProp = (prop: string) => {\n return 'column_' + prop.split('.').join('_')\n}\n"],"names":["getUuid","s","hexDigits","i","getPropByPath","obj","path","tempObj","keyArr","len","key","dataTransformRod","data","errData","getTreeNode","treeData","name","value","result","treeNode","treeData2","convertToFlat","children","parentId","acc","curr","escapeHTML","str","match","columnProp","prop"],"mappings":"AA8BO,MAAMA,IAAU,MAAc;AACjC,QAAMC,IAAI,CAAA,GACJC,IAAY;AAClB,WAASC,IAAI,GAAGA,IAAI,IAAIA;AAClB,IAAAF,EAAAE,CAAC,IAAID,EAAU,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,EAAI,GAAG,CAAC;AAE/D,SAAAD,EAAE,EAAE,IAAI,KACNA,EAAA,EAAE,IAAIC,EAAU,OAAQ,CAACD,EAAE,EAAE,IAAI,IAAO,GAAK,CAAC,GAC9CA,EAAA,CAAC,IAAIA,EAAE,EAAE,IAAIA,EAAE,EAAE,IAAIA,EAAE,EAAE,IAAI,KAClBA,EAAE,KAAK,EAAE;AAE1B,GASaG,IAAgB,CAACC,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AE,CAAC,IAE9DD,IACR,CAAE,CAAA;AACT;AAqDa,MAAAE,IAAa,CAACC,MAEhB,OAAOA,CAAG,EAAE,QAAQ,YAAY,CAACC,MAAe;AACnD,UAAQA,GAAO;AAAA,IACX,KAAK;AACM,aAAA;AAAA,IACX,KAAK;AACM,aAAA;AAAA,IACX,KAAK;AACM,aAAA;AAAA,IACX,KAAK;AACM,aAAA;AAAA,IACX,KAAK;AACM,aAAA;AAAA,IACX;AACW,aAAA;AAAA,EACf;AAAA,CACH,GAGQC,IAAa,CAACC,MAChB,YAAYA,EAAK,MAAM,GAAG,EAAE,KAAK,GAAG;"}
@@ -0,0 +1,32 @@
1
+ import type { Plugin } from 'vue';
2
+ type SFCWithInstall<T> = T & Plugin;
3
+ export declare const Form: SFCWithInstall<import("vue").DefineComponent<{
4
+ form: {
5
+ type: import("vue").PropType<import("./types").RewriteFormProps<any>>;
6
+ default: () => {};
7
+ };
8
+ search: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ }, {
13
+ formItemMap: import("vue").ComputedRef<any>;
14
+ unfold: () => void;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("UnFold" | "SearchFn" | "ResetFn")[], "UnFold" | "SearchFn" | "ResetFn", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: import("vue").PropType<import("./types").RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ search: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ }>> & {
25
+ onUnFold?: ((...args: any[]) => any) | undefined;
26
+ onSearchFn?: ((...args: any[]) => any) | undefined;
27
+ onResetFn?: ((...args: any[]) => any) | undefined;
28
+ }, {
29
+ form: import("./types").RewriteFormProps<any>;
30
+ search: boolean;
31
+ }, {}>>;
32
+ export default Form;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { PropType } from 'vue';
3
+ import type { CheckboxGroupProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<CheckboxGroupProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<CheckboxGroupProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<CheckboxGroupProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { DatePickerProps } from 'element-plus';
2
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
3
+ import type { PropType } from 'vue';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<DatePickerProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<DatePickerProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<DatePickerProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,32 @@
1
+ import type { PropType } from 'vue';
2
+ import type { RewriteFormProps } from '../types';
3
+ declare const _default: import("vue").DefineComponent<{
4
+ form: {
5
+ type: PropType<RewriteFormProps<any>>;
6
+ default: () => {};
7
+ };
8
+ search: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ }, {
13
+ formItemMap: import("vue").ComputedRef<any>;
14
+ unfold: () => void;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("UnFold" | "SearchFn" | "ResetFn")[], "UnFold" | "SearchFn" | "ResetFn", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ search: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ }>> & {
25
+ onUnFold?: ((...args: any[]) => any) | undefined;
26
+ onSearchFn?: ((...args: any[]) => any) | undefined;
27
+ onResetFn?: ((...args: any[]) => any) | undefined;
28
+ }, {
29
+ form: RewriteFormProps<any>;
30
+ search: boolean;
31
+ }, {}>;
32
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { PropType } from 'vue';
3
+ import type { AutocompleteProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<AutocompleteProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<AutocompleteProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<AutocompleteProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { InputNumberProps } from 'element-plus';
3
+ import type { PropType } from 'vue';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<InputNumberProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<InputNumberProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<InputNumberProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { PropType } from 'vue';
3
+ import type { InputProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<InputProps>, any>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<InputProps>, any>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<InputProps>, any>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { PropType } from 'vue';
3
+ import type { RadioProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<RadioProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<RadioProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<RadioProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { PropType } from 'vue';
2
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
3
+ import type { RateProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<RateProps>, any>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<RateProps>, any>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<RateProps>, any>;
27
+ }, {}>;
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { RewriteFormProps, CustomFormItemProps } from '../types';
2
+ import type { PropType } from 'vue';
3
+ import type { SwitchProps } from 'element-plus';
4
+ declare const _default: import("vue").DefineComponent<{
5
+ form: {
6
+ type: PropType<RewriteFormProps<any>>;
7
+ default: () => {};
8
+ };
9
+ formItem: {
10
+ type: PropType<CustomFormItemProps<Partial<SwitchProps>, any[]>>;
11
+ default: () => {};
12
+ };
13
+ }, {
14
+ options: import("vue").ComputedRef<import('../types').RewriteFormItemProps<any[]>>;
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ form: {
17
+ type: PropType<RewriteFormProps<any>>;
18
+ default: () => {};
19
+ };
20
+ formItem: {
21
+ type: PropType<CustomFormItemProps<Partial<SwitchProps>, any[]>>;
22
+ default: () => {};
23
+ };
24
+ }>>, {
25
+ form: RewriteFormProps<any>;
26
+ formItem: CustomFormItemProps<Partial<SwitchProps>, any[]>;
27
+ }, {}>;
28
+ export default _default;