el-crud-page 1.0.1 → 1.0.3

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/dist/index.esm.js CHANGED
@@ -21,9 +21,6 @@ function _arrayLikeToArray(r, a) {
21
21
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
22
22
  return n;
23
23
  }
24
- function _arrayWithHoles(r) {
25
- if (Array.isArray(r)) return r;
26
- }
27
24
  function _arrayWithoutHoles(r) {
28
25
  if (Array.isArray(r)) return _arrayLikeToArray(r);
29
26
  }
@@ -63,36 +60,6 @@ function _defineProperty(e, r, t) {
63
60
  function _iterableToArray(r) {
64
61
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
65
62
  }
66
- function _iterableToArrayLimit(r, l) {
67
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
68
- if (null != t) {
69
- var e,
70
- n,
71
- i,
72
- u,
73
- a = [],
74
- f = !0,
75
- o = !1;
76
- try {
77
- if (i = (t = t.call(r)).next, 0 === l) {
78
- if (Object(t) !== t) return;
79
- f = !1;
80
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
81
- } catch (r) {
82
- o = !0, n = r;
83
- } finally {
84
- try {
85
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
86
- } finally {
87
- if (o) throw n;
88
- }
89
- }
90
- return a;
91
- }
92
- }
93
- function _nonIterableRest() {
94
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95
- }
96
63
  function _nonIterableSpread() {
97
64
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
98
65
  }
@@ -225,9 +192,6 @@ function _regeneratorDefine(e, r, n, t) {
225
192
  }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
226
193
  }, _regeneratorDefine(e, r, n, t);
227
194
  }
228
- function _slicedToArray(r, e) {
229
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
230
- }
231
195
  function _toConsumableArray(r) {
232
196
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
233
197
  }
@@ -1145,7 +1109,7 @@ TableColumn.components = {
1145
1109
  //
1146
1110
  //
1147
1111
 
1148
- var script$5 = {
1112
+ var script$4 = {
1149
1113
  name: "CrudTable",
1150
1114
  components: {
1151
1115
  CrudTableColumn: TableColumn
@@ -1379,7 +1343,7 @@ function addStyle(id, css) {
1379
1343
  }
1380
1344
 
1381
1345
  /* script */
1382
- var __vue_script__$5 = script$5;
1346
+ var __vue_script__$4 = script$4;
1383
1347
 
1384
1348
  /* template */
1385
1349
  var __vue_render__$4 = function __vue_render__() {
@@ -1392,8 +1356,9 @@ var __vue_render__$4 = function __vue_render__() {
1392
1356
  attrs: {
1393
1357
  data: _vm.data
1394
1358
  }
1395
- }, "el-table", _vm.combinedProps, false), _vm.combinedEvents), _vm._l(_vm.columns, function (column) {
1359
+ }, "el-table", _vm.combinedProps, false), _vm.combinedEvents), _vm._l(_vm.columns, function (column, index) {
1396
1360
  return !column["v-hasPermi"] || !column["v-hasPermi"].length || _vm.$auth.hasPermiOr(column["v-hasPermi"] || []) ? _c("crud-table-column", {
1361
+ key: "" + (column.key || "column_" + index),
1397
1362
  attrs: {
1398
1363
  indexMethod: function indexMethod(index) {
1399
1364
  return _vm.baseIndex + 1 + index;
@@ -1410,35 +1375,35 @@ var __vue_staticRenderFns__$4 = [];
1410
1375
  __vue_render__$4._withStripped = true;
1411
1376
 
1412
1377
  /* style */
1413
- var __vue_inject_styles__$5 = function __vue_inject_styles__(inject) {
1378
+ var __vue_inject_styles__$4 = function __vue_inject_styles__(inject) {
1414
1379
  if (!inject) return;
1415
- inject("data-v-eea78022_0", {
1416
- source: ".crud-table[data-v-eea78022] .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */",
1380
+ inject("data-v-8bcd2094_0", {
1381
+ source: ".crud-table[data-v-8bcd2094] .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */",
1417
1382
  map: {
1418
1383
  "version": 3,
1419
1384
  "sources": ["/Users/tonwe/git/el-crud-page/src/table.vue", "table.vue"],
1420
1385
  "names": [],
1421
1386
  "mappings": "AAsJA;EACA,YAAA;EACA,cAAA;ACrJA;;AAEA,oCAAoC",
1422
1387
  "file": "table.vue",
1423
- "sourcesContent": ["<!-- crud table 组件 -->\n<template>\n <el-table :data=\"data\" class=\"crud-table\" ref=\"table\" v-bind=\"combinedProps\" v-on=\"combinedEvents\">\n <crud-table-column v-for=\"column in columns\" :indexMethod=\"(index)=>( baseIndex + 1 + index )\"\n v-if=\"!column[`v-hasPermi`] || !column[`v-hasPermi`].length || $auth.hasPermiOr(column[`v-hasPermi`] || [])\"\n :column=\"column\" @action=\"onRowAction\">\n </crud-table-column>\n </el-table>\n</template>\n<script>\n\n\n/**\n * CRUD table组件\n */\n\nimport CrudTableColumn from \"./tableColumn.js\";\n\nexport default {\n name: \"CrudTable\",\n components: {\n CrudTableColumn\n },\n inject: [\"crud\"],\n props: {\n columns: {\n type: Array,\n default: () => []\n },\n on: {\n type: Object,\n default: () => {\n return {};\n }\n },\n data: {\n type: Array,\n default: () => {\n return [];\n }\n }\n },\n data() {\n return {\n emit: {},\n defaultProps: {\n stripe: true,\n size: \"mini\",\n }\n };\n },\n computed: {\n // 将外部传入的 props 与 crud 内部样式合并\n combinedProps() {\n return Object.assign({}, this.defaultProps, this.$attrs);\n },\n // 将各事件处理函数合并,包括 emit 与 on 上的回调\n combinedEvents() {\n return Object.assign(\n {},\n {\n \"selection-change\": this.onSelectionChange,\n \"sort-change\": this.onSortChange,\n \"row-contextmenu\": this.onRowContextMenu\n },\n this.emit,\n this.on\n );\n },\n baseIndex(){\n if( this.crud?.pagination ){\n return (this.crud?.pagination?.pageNum-1) * this.crud?.pagination?.pageSize;\n }else{\n return 0;\n }\n }\n },\n mounted() {\n this.bindEmits();\n this.bindMethods();\n },\n methods: {\n // 绑定 el-table 回调\n bindEmits() {\n const emits = [\n \"select\",\n \"select-all\",\n \"cell-mouse-enter\",\n \"cell-mouse-leave\",\n \"cell-click\",\n \"cell-dblclick\",\n \"row-click\",\n \"row-contextmenu\",\n \"row-dblclick\",\n \"header-click\",\n \"header-contextmenu\",\n \"filter-change\",\n \"current-change\",\n \"header-dragend\",\n \"expand-change\"\n ];\n\n emits.forEach((name) => {\n this.emit[name] = (...args) => {\n this.$emit(name, ...args);\n };\n });\n },\n\n // 绑定 el-table 事件\n bindMethods() {\n const methods = [\n \"clearSelection\",\n \"toggleRowSelection\",\n \"toggleAllSelection\",\n \"toggleRowExpansion\",\n \"setCurrentRow\",\n \"clearSort\",\n \"clearFilter\",\n \"doLayout\",\n \"sort\"\n ];\n\n methods.forEach((n) => {\n this[n] = this.$refs[\"table\"][n];\n });\n },\n onSelectionChange(selection) {\n this.$emit(\"selection-change\", selection);\n },\n onSortChange({ prop, order }) {\n this.$emit(\"sort-change\", { prop, order });\n },\n onRowContextMenu(row, column, event) {\n this.$emit(\"row-contextmenu\", row, column, event);\n },\n onRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n this.$emit(`row-${action}`, scope);\n }\n }\n\n}\n</script>\n\n<style scoped lang=\"scss\">\n.crud-table {\n &::v-deep {\n .el-table__body-wrapper {\n .el-table__cell {\n .cell:empty::after {\n content: '/';\n color: #c0c4cc;\n }\n }\n }\n }\n}\n</style>\n", ".crud-table::v-deep .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */"]
1388
+ "sourcesContent": ["<!-- crud table 组件 -->\n<template>\n <el-table :data=\"data\" class=\"crud-table\" ref=\"table\" v-bind=\"combinedProps\" v-on=\"combinedEvents\">\n <crud-table-column v-for=\"(column,index) in columns\" :key=\"`${ column.key || ('column_'+index) }`\" :indexMethod=\"(index)=>( baseIndex + 1 + index )\"\n v-if=\"!column[`v-hasPermi`] || !column[`v-hasPermi`].length || $auth.hasPermiOr(column[`v-hasPermi`] || [])\"\n :column=\"column\" @action=\"onRowAction\">\n </crud-table-column>\n </el-table>\n</template>\n<script>\n\n\n/**\n * CRUD table组件\n */\n\nimport CrudTableColumn from \"./tableColumn.js\";\n\nexport default {\n name: \"CrudTable\",\n components: {\n CrudTableColumn\n },\n inject: [\"crud\"],\n props: {\n columns: {\n type: Array,\n default: () => []\n },\n on: {\n type: Object,\n default: () => {\n return {};\n }\n },\n data: {\n type: Array,\n default: () => {\n return [];\n }\n }\n },\n data() {\n return {\n emit: {},\n defaultProps: {\n stripe: true,\n size: \"mini\",\n }\n };\n },\n computed: {\n // 将外部传入的 props 与 crud 内部样式合并\n combinedProps() {\n return Object.assign({}, this.defaultProps, this.$attrs);\n },\n // 将各事件处理函数合并,包括 emit 与 on 上的回调\n combinedEvents() {\n return Object.assign(\n {},\n {\n \"selection-change\": this.onSelectionChange,\n \"sort-change\": this.onSortChange,\n \"row-contextmenu\": this.onRowContextMenu\n },\n this.emit,\n this.on\n );\n },\n baseIndex(){\n if( this.crud?.pagination ){\n return (this.crud?.pagination?.pageNum-1) * this.crud?.pagination?.pageSize;\n }else{\n return 0;\n }\n }\n },\n mounted() {\n this.bindEmits();\n this.bindMethods();\n },\n methods: {\n // 绑定 el-table 回调\n bindEmits() {\n const emits = [\n \"select\",\n \"select-all\",\n \"cell-mouse-enter\",\n \"cell-mouse-leave\",\n \"cell-click\",\n \"cell-dblclick\",\n \"row-click\",\n \"row-contextmenu\",\n \"row-dblclick\",\n \"header-click\",\n \"header-contextmenu\",\n \"filter-change\",\n \"current-change\",\n \"header-dragend\",\n \"expand-change\"\n ];\n\n emits.forEach((name) => {\n this.emit[name] = (...args) => {\n this.$emit(name, ...args);\n };\n });\n },\n\n // 绑定 el-table 事件\n bindMethods() {\n const methods = [\n \"clearSelection\",\n \"toggleRowSelection\",\n \"toggleAllSelection\",\n \"toggleRowExpansion\",\n \"setCurrentRow\",\n \"clearSort\",\n \"clearFilter\",\n \"doLayout\",\n \"sort\"\n ];\n\n methods.forEach((n) => {\n this[n] = this.$refs[\"table\"][n];\n });\n },\n onSelectionChange(selection) {\n this.$emit(\"selection-change\", selection);\n },\n onSortChange({ prop, order }) {\n this.$emit(\"sort-change\", { prop, order });\n },\n onRowContextMenu(row, column, event) {\n this.$emit(\"row-contextmenu\", row, column, event);\n },\n onRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n this.$emit(`row-${action}`, scope);\n }\n }\n\n}\n</script>\n\n<style scoped lang=\"scss\">\n.crud-table {\n &::v-deep {\n .el-table__body-wrapper {\n .el-table__cell {\n .cell:empty::after {\n content: '/';\n color: #c0c4cc;\n }\n }\n }\n }\n}\n</style>\n", ".crud-table::v-deep .el-table__body-wrapper .el-table__cell .cell:empty::after {\n content: \"/\";\n color: #c0c4cc;\n}\n\n/*# sourceMappingURL=table.vue.map */"]
1424
1389
  },
1425
1390
  media: undefined
1426
1391
  });
1427
1392
  };
1428
1393
  /* scoped */
1429
- var __vue_scope_id__$5 = "data-v-eea78022";
1394
+ var __vue_scope_id__$4 = "data-v-8bcd2094";
1430
1395
  /* module identifier */
1431
- var __vue_module_identifier__$5 = undefined;
1396
+ var __vue_module_identifier__$4 = undefined;
1432
1397
  /* functional template */
1433
- var __vue_is_functional_template__$5 = false;
1398
+ var __vue_is_functional_template__$4 = false;
1434
1399
  /* style inject SSR */
1435
1400
 
1436
1401
  /* style inject shadow dom */
1437
1402
 
1438
- var __vue_component__$5 = /*#__PURE__*/normalizeComponent({
1403
+ var __vue_component__$4 = /*#__PURE__*/normalizeComponent({
1439
1404
  render: __vue_render__$4,
1440
1405
  staticRenderFns: __vue_staticRenderFns__$4
1441
- }, __vue_inject_styles__$5, __vue_script__$5, __vue_scope_id__$5, __vue_is_functional_template__$5, __vue_module_identifier__$5, false, createInjector, undefined, undefined);
1406
+ }, __vue_inject_styles__$4, __vue_script__$4, __vue_scope_id__$4, __vue_is_functional_template__$4, __vue_module_identifier__$4, false, createInjector, undefined, undefined);
1442
1407
 
1443
1408
  //
1444
1409
  //
@@ -1474,7 +1439,7 @@ var __vue_component__$5 = /*#__PURE__*/normalizeComponent({
1474
1439
  //
1475
1440
  //
1476
1441
 
1477
- var script$4 = {
1442
+ var script$3 = {
1478
1443
  name: "RightToolbar",
1479
1444
  inject: ["crud"],
1480
1445
  data: function data() {
@@ -1580,7 +1545,7 @@ var script$4 = {
1580
1545
  };
1581
1546
 
1582
1547
  /* script */
1583
- var __vue_script__$4 = script$4;
1548
+ var __vue_script__$3 = script$3;
1584
1549
 
1585
1550
  /* template */
1586
1551
  var __vue_render__$3 = function __vue_render__() {
@@ -1711,7 +1676,7 @@ var __vue_staticRenderFns__$3 = [];
1711
1676
  __vue_render__$3._withStripped = true;
1712
1677
 
1713
1678
  /* style */
1714
- var __vue_inject_styles__$4 = function __vue_inject_styles__(inject) {
1679
+ var __vue_inject_styles__$3 = function __vue_inject_styles__(inject) {
1715
1680
  if (!inject) return;
1716
1681
  inject("data-v-d5778a5c_0", {
1717
1682
  source: "[data-v-d5778a5c] .el-transfer__button {\n border-radius: 50%;\n padding: 12px;\n display: block;\n margin-left: 0px;\n}\n[data-v-d5778a5c] .el-transfer__button:first-child {\n margin-bottom: 10px;\n}\n.drag-item[data-v-d5778a5c] {\n padding: 8px;\n cursor: move;\n border-bottom: 1px solid #ebeef5;\n display: flex;\n align-items: center;\n}\n.drag-item[data-v-d5778a5c]:hover {\n background-color: #f5f7fa;\n}\n.drag-handle[data-v-d5778a5c] {\n color: #909399;\n}\n.drag-handle[data-v-d5778a5c]:hover {\n color: #409eff;\n}\n\n/*# sourceMappingURL=rightToolbar.vue.map */",
@@ -1727,21 +1692,21 @@ var __vue_inject_styles__$4 = function __vue_inject_styles__(inject) {
1727
1692
  });
1728
1693
  };
1729
1694
  /* scoped */
1730
- var __vue_scope_id__$4 = "data-v-d5778a5c";
1695
+ var __vue_scope_id__$3 = "data-v-d5778a5c";
1731
1696
  /* module identifier */
1732
- var __vue_module_identifier__$4 = undefined;
1697
+ var __vue_module_identifier__$3 = undefined;
1733
1698
  /* functional template */
1734
- var __vue_is_functional_template__$4 = false;
1699
+ var __vue_is_functional_template__$3 = false;
1735
1700
  /* style inject SSR */
1736
1701
 
1737
1702
  /* style inject shadow dom */
1738
1703
 
1739
- var __vue_component__$4 = /*#__PURE__*/normalizeComponent({
1704
+ var __vue_component__$3 = /*#__PURE__*/normalizeComponent({
1740
1705
  render: __vue_render__$3,
1741
1706
  staticRenderFns: __vue_staticRenderFns__$3
1742
- }, __vue_inject_styles__$4, __vue_script__$4, __vue_scope_id__$4, __vue_is_functional_template__$4, __vue_module_identifier__$4, false, createInjector, undefined, undefined);
1707
+ }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, false, createInjector, undefined, undefined);
1743
1708
 
1744
- var script$3 = {
1709
+ var script$2 = {
1745
1710
  props: {
1746
1711
  // queryParams: {
1747
1712
  // type: Object,
@@ -1957,7 +1922,7 @@ var script$3 = {
1957
1922
  };
1958
1923
 
1959
1924
  /* script */
1960
- var __vue_script__$3 = script$3;
1925
+ var __vue_script__$2 = script$2;
1961
1926
 
1962
1927
  /* template */
1963
1928
  var __vue_render__$2 = function __vue_render__() {
@@ -2007,7 +1972,7 @@ var __vue_render__$2 = function __vue_render__() {
2007
1972
  if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
2008
1973
  return null;
2009
1974
  }
2010
- return _vm.handleQuery.apply(null, arguments);
1975
+ return _vm.handleQuery($event);
2011
1976
  }
2012
1977
  },
2013
1978
  model: {
@@ -2124,7 +2089,7 @@ var __vue_staticRenderFns__$2 = [];
2124
2089
  __vue_render__$2._withStripped = true;
2125
2090
 
2126
2091
  /* style */
2127
- var __vue_inject_styles__$3 = function __vue_inject_styles__(inject) {
2092
+ var __vue_inject_styles__$2 = function __vue_inject_styles__(inject) {
2128
2093
  if (!inject) return;
2129
2094
  inject("data-v-ba1b80d0_0", {
2130
2095
  source: ".container-main[data-v-ba1b80d0] {\n background-color: #fff;\n}\n.el-crud-query[data-v-ba1b80d0] {\n overflow: hidden;\n padding: 10px;\n}\n.el-crud-query .el-crud-query-form[data-v-ba1b80d0] {\n margin-bottom: -10px;\n}\n.el-crud-query .el-crud-query-form[data-v-ba1b80d0] .el-form-item--mini.el-form-item, .el-crud-query .el-crud-query-form[data-v-ba1b80d0] .el-form-item--small.el-form-item {\n margin-bottom: 10px;\n}\n\n/*# sourceMappingURL=queryForm.vue.map */",
@@ -2140,19 +2105,19 @@ var __vue_inject_styles__$3 = function __vue_inject_styles__(inject) {
2140
2105
  });
2141
2106
  };
2142
2107
  /* scoped */
2143
- var __vue_scope_id__$3 = "data-v-ba1b80d0";
2108
+ var __vue_scope_id__$2 = "data-v-ba1b80d0";
2144
2109
  /* module identifier */
2145
- var __vue_module_identifier__$3 = undefined;
2110
+ var __vue_module_identifier__$2 = undefined;
2146
2111
  /* functional template */
2147
- var __vue_is_functional_template__$3 = false;
2112
+ var __vue_is_functional_template__$2 = false;
2148
2113
  /* style inject SSR */
2149
2114
 
2150
2115
  /* style inject shadow dom */
2151
2116
 
2152
- var __vue_component__$3 = /*#__PURE__*/normalizeComponent({
2117
+ var __vue_component__$2 = /*#__PURE__*/normalizeComponent({
2153
2118
  render: __vue_render__$2,
2154
2119
  staticRenderFns: __vue_staticRenderFns__$2
2155
- }, __vue_inject_styles__$3, __vue_script__$3, __vue_scope_id__$3, __vue_is_functional_template__$3, __vue_module_identifier__$3, false, createInjector, undefined, undefined);
2120
+ }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, false, createInjector, undefined, undefined);
2156
2121
 
2157
2122
  //
2158
2123
  //
@@ -2172,7 +2137,7 @@ var __vue_component__$3 = /*#__PURE__*/normalizeComponent({
2172
2137
  //
2173
2138
  //
2174
2139
 
2175
- var script$2 = {
2140
+ var script$1 = {
2176
2141
  name: 'Pagination',
2177
2142
  props: {
2178
2143
  total: {
@@ -2262,7 +2227,7 @@ var script$2 = {
2262
2227
  };
2263
2228
 
2264
2229
  /* script */
2265
- var __vue_script__$2 = script$2;
2230
+ var __vue_script__$1 = script$1;
2266
2231
 
2267
2232
  /* template */
2268
2233
  var __vue_render__$1 = function __vue_render__() {
@@ -2306,7 +2271,7 @@ var __vue_staticRenderFns__$1 = [];
2306
2271
  __vue_render__$1._withStripped = true;
2307
2272
 
2308
2273
  /* style */
2309
- var __vue_inject_styles__$2 = function __vue_inject_styles__(inject) {
2274
+ var __vue_inject_styles__$1 = function __vue_inject_styles__(inject) {
2310
2275
  if (!inject) return;
2311
2276
  inject("data-v-7ec7699b_0", {
2312
2277
  source: "\n.pagination-container[data-v-7ec7699b] {\n background: #fff;\n padding: 32px 16px;\n}\n.pagination-container.hidden[data-v-7ec7699b] {\n display: none;\n}\n",
@@ -2322,26 +2287,26 @@ var __vue_inject_styles__$2 = function __vue_inject_styles__(inject) {
2322
2287
  });
2323
2288
  };
2324
2289
  /* scoped */
2325
- var __vue_scope_id__$2 = "data-v-7ec7699b";
2290
+ var __vue_scope_id__$1 = "data-v-7ec7699b";
2326
2291
  /* module identifier */
2327
- var __vue_module_identifier__$2 = undefined;
2292
+ var __vue_module_identifier__$1 = undefined;
2328
2293
  /* functional template */
2329
- var __vue_is_functional_template__$2 = false;
2294
+ var __vue_is_functional_template__$1 = false;
2330
2295
  /* style inject SSR */
2331
2296
 
2332
2297
  /* style inject shadow dom */
2333
2298
 
2334
- var __vue_component__$2 = /*#__PURE__*/normalizeComponent({
2299
+ var __vue_component__$1 = /*#__PURE__*/normalizeComponent({
2335
2300
  render: __vue_render__$1,
2336
2301
  staticRenderFns: __vue_staticRenderFns__$1
2337
- }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2, __vue_module_identifier__$2, false, createInjector, undefined, undefined);
2302
+ }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, createInjector, undefined, undefined);
2338
2303
 
2339
- var script$1 = {
2304
+ var script = {
2340
2305
  components: {
2341
- CrudTable: __vue_component__$5,
2342
- RightToolbar: __vue_component__$4,
2343
- QueryForm: __vue_component__$3,
2344
- Pagination: __vue_component__$2
2306
+ CrudTable: __vue_component__$4,
2307
+ RightToolbar: __vue_component__$3,
2308
+ QueryForm: __vue_component__$2,
2309
+ Pagination: __vue_component__$1
2345
2310
  },
2346
2311
  name: 'Crud',
2347
2312
  provide: function provide() {
@@ -2652,7 +2617,7 @@ var script$1 = {
2652
2617
  };
2653
2618
 
2654
2619
  /* script */
2655
- var __vue_script__$1 = script$1;
2620
+ var __vue_script__ = script;
2656
2621
 
2657
2622
  /* template */
2658
2623
  var __vue_render__ = function __vue_render__() {
@@ -2661,26 +2626,24 @@ var __vue_render__ = function __vue_render__() {
2661
2626
  var _c = _vm._self._c || _h;
2662
2627
  return _c("div", {
2663
2628
  staticClass: "el-crud"
2664
- }, [_vm._t("query", function () {
2665
- return [_vm.queryItems && _vm.queryItems.length ? _c("query-form", {
2666
- directives: [{
2667
- name: "show",
2668
- rawName: "v-show",
2669
- value: _vm.showSearch,
2670
- expression: "showSearch"
2671
- }],
2672
- attrs: {
2673
- queryItems: _vm.queryItems,
2674
- lineClamp: _vm.queryLineClamp,
2675
- "label-width": _vm.queryLabelWidth,
2676
- "input-width": _vm.queryInputWidth,
2677
- inline: _vm.queryInline
2678
- },
2679
- on: {
2680
- queryTable: _vm.handleQuery
2681
- }
2682
- }) : _vm._e()];
2683
- }, {
2629
+ }, [_vm._t("query", [_vm.queryItems && _vm.queryItems.length ? _c("query-form", {
2630
+ directives: [{
2631
+ name: "show",
2632
+ rawName: "v-show",
2633
+ value: _vm.showSearch,
2634
+ expression: "showSearch"
2635
+ }],
2636
+ attrs: {
2637
+ queryItems: _vm.queryItems,
2638
+ lineClamp: _vm.queryLineClamp,
2639
+ "label-width": _vm.queryLabelWidth,
2640
+ "input-width": _vm.queryInputWidth,
2641
+ inline: _vm.queryInline
2642
+ },
2643
+ on: {
2644
+ queryTable: _vm.handleQuery
2645
+ }
2646
+ }) : _vm._e()], {
2684
2647
  queryItems: _vm.queryItems,
2685
2648
  lineClamp: _vm.queryLineClamp,
2686
2649
  labelWidth: _vm.queryLabelWidth,
@@ -2691,114 +2654,105 @@ var __vue_render__ = function __vue_render__() {
2691
2654
  "class": {
2692
2655
  pt5: _vm.tabPanes.length > 0
2693
2656
  }
2694
- }, [_vm._t("tabQuery", function () {
2695
- return [_vm.tabPanes.length > 0 ? _c("el-tabs", {
2696
- staticClass: "top-tab-query",
2657
+ }, [_vm._t("tabQuery", [_vm.tabPanes.length > 0 ? _c("el-tabs", {
2658
+ staticClass: "top-tab-query",
2659
+ attrs: {
2660
+ value: _vm.tabQuery.tabKey
2661
+ },
2662
+ on: {
2663
+ "tab-click": _vm.handleTabClick
2664
+ }
2665
+ }, _vm._l(_vm.tabPanes, function (item) {
2666
+ return _c("el-tab-pane", {
2667
+ key: item.name,
2697
2668
  attrs: {
2698
- value: _vm.tabQuery.tabKey
2699
- },
2700
- on: {
2701
- "tab-click": _vm.handleTabClick
2669
+ label: item.label,
2670
+ name: item.name
2702
2671
  }
2703
- }, _vm._l(_vm.tabPanes, function (item) {
2704
- return _c("el-tab-pane", {
2705
- key: item.name,
2706
- attrs: {
2707
- label: item.label,
2708
- name: item.name
2709
- }
2710
- });
2711
- }), 1) : _vm._e()];
2712
- }), _vm._v(" "), _c("div", {
2672
+ });
2673
+ }), 1) : _vm._e()]), _vm._v(" "), _c("div", {
2713
2674
  staticClass: "flex justify-between el-crud-toolbar"
2714
- }, [_vm._t("buttons", function () {
2715
- return [_c("div", _vm._l(_vm.actionButtons, function (item) {
2716
- return _c("el-button", {
2717
- attrs: {
2718
- size: item.size,
2719
- plain: item.plain,
2720
- disabled: item.disabled,
2721
- type: item.type,
2722
- icon: item.icon
2723
- },
2724
- on: {
2725
- click: function click($event) {
2726
- return _vm.handleButtonClick(item);
2727
- }
2728
- }
2729
- }, [_vm._v(_vm._s(item.text))]);
2730
- }), 1)];
2731
- }, {
2732
- selections: _vm.selections
2733
- }), _vm._v(" "), _vm._t("toolbar", function () {
2734
- return [_c("right-toolbar", {
2675
+ }, [_vm._t("buttons", [_c("div", _vm._l(_vm.actionButtons, function (item, index) {
2676
+ return _c("el-button", {
2677
+ key: "" + (item.key || "action-btn-" + index),
2735
2678
  attrs: {
2736
- showSearch: _vm.showSearch,
2737
- columns: _vm.columns,
2738
- search: !!(_vm.queryItems && _vm.queryItems.length)
2679
+ size: item.size,
2680
+ plain: item.plain,
2681
+ disabled: item.disabled,
2682
+ type: item.type,
2683
+ icon: item.icon
2739
2684
  },
2740
2685
  on: {
2741
- "update:showSearch": function updateShowSearch($event) {
2742
- _vm.showSearch = $event;
2743
- },
2744
- "update:show-search": function updateShowSearch($event) {
2745
- _vm.showSearch = $event;
2746
- },
2747
- queryTable: _vm.refresh
2686
+ click: function click($event) {
2687
+ return _vm.handleButtonClick(item);
2688
+ }
2748
2689
  }
2749
- })];
2750
- }, {
2690
+ }, [_vm._v(_vm._s(item.text))]);
2691
+ }), 1)], {
2692
+ selections: _vm.selections
2693
+ }), _vm._v(" "), _vm._t("toolbar", [_c("right-toolbar", {
2694
+ attrs: {
2695
+ showSearch: _vm.showSearch,
2696
+ columns: _vm.columns,
2697
+ search: !!(_vm.queryItems && _vm.queryItems.length)
2698
+ },
2699
+ on: {
2700
+ "update:showSearch": function updateShowSearch($event) {
2701
+ _vm.showSearch = $event;
2702
+ },
2703
+ "update:show-search": function updateShowSearch($event) {
2704
+ _vm.showSearch = $event;
2705
+ },
2706
+ queryTable: _vm.refresh
2707
+ }
2708
+ })], {
2751
2709
  columns: _vm.columns,
2752
2710
  showSearch: _vm.showSearch
2753
- })], 2), _vm._v(" "), _vm._t("default", function () {
2754
- return [_c("crud-table", {
2755
- directives: [{
2756
- name: "loading",
2757
- rawName: "v-loading",
2758
- value: _vm.listLoading,
2759
- expression: "listLoading"
2760
- }],
2761
- attrs: {
2762
- size: "mini",
2763
- highlightCol: _vm.highlightCol,
2764
- resizable: _vm.resizable,
2765
- border: _vm.border,
2766
- columns: _vm.columns,
2767
- data: _vm.data,
2768
- "default-sort": _vm.defaultSort
2769
- },
2770
- on: {
2771
- "selection-change": _vm.handleSelectionChange,
2772
- "row-action": _vm.handleRowAction,
2773
- "sort-change": _vm.handleSortChange
2774
- }
2775
- })];
2776
- }, {
2711
+ })], 2), _vm._v(" "), _vm._t("default", [_c("crud-table", {
2712
+ directives: [{
2713
+ name: "loading",
2714
+ rawName: "v-loading",
2715
+ value: _vm.listLoading,
2716
+ expression: "listLoading"
2717
+ }],
2718
+ attrs: {
2719
+ size: "mini",
2720
+ highlightCol: _vm.highlightCol,
2721
+ resizable: _vm.resizable,
2722
+ border: _vm.border,
2723
+ columns: _vm.columns,
2724
+ data: _vm.data,
2725
+ "default-sort": _vm.defaultSort
2726
+ },
2727
+ on: {
2728
+ "selection-change": _vm.handleSelectionChange,
2729
+ "row-action": _vm.handleRowAction,
2730
+ "sort-change": _vm.handleSortChange
2731
+ }
2732
+ })], {
2777
2733
  data: _vm.data
2778
- }), _vm._v(" "), _vm._t("pagination", function () {
2779
- return [_c("pagination", {
2780
- directives: [{
2781
- name: "show",
2782
- rawName: "v-show",
2783
- value: _vm.total > 0,
2784
- expression: "total > 0"
2785
- }],
2786
- attrs: {
2787
- total: _vm.total,
2788
- page: _vm.pagination.pageNum,
2789
- limit: _vm.pagination.pageSize
2734
+ }), _vm._v(" "), _vm._t("pagination", [_c("pagination", {
2735
+ directives: [{
2736
+ name: "show",
2737
+ rawName: "v-show",
2738
+ value: _vm.total > 0,
2739
+ expression: "total > 0"
2740
+ }],
2741
+ attrs: {
2742
+ total: _vm.total,
2743
+ page: _vm.pagination.pageNum,
2744
+ limit: _vm.pagination.pageSize
2745
+ },
2746
+ on: {
2747
+ "update:page": function updatePage($event) {
2748
+ return _vm.$set(_vm.pagination, "pageNum", $event);
2790
2749
  },
2791
- on: {
2792
- "update:page": function updatePage($event) {
2793
- return _vm.$set(_vm.pagination, "pageNum", $event);
2794
- },
2795
- "update:limit": function updateLimit($event) {
2796
- return _vm.$set(_vm.pagination, "pageSize", $event);
2797
- },
2798
- pagination: _vm.refresh
2799
- }
2800
- })];
2801
- }, {
2750
+ "update:limit": function updateLimit($event) {
2751
+ return _vm.$set(_vm.pagination, "pageSize", $event);
2752
+ },
2753
+ pagination: _vm.refresh
2754
+ }
2755
+ })], {
2802
2756
  total: _vm.total,
2803
2757
  pagination: _vm.pagination
2804
2758
  })], 2)], 2);
@@ -2807,800 +2761,37 @@ var __vue_staticRenderFns__ = [];
2807
2761
  __vue_render__._withStripped = true;
2808
2762
 
2809
2763
  /* style */
2810
- var __vue_inject_styles__$1 = function __vue_inject_styles__(inject) {
2764
+ var __vue_inject_styles__ = function __vue_inject_styles__(inject) {
2811
2765
  if (!inject) return;
2812
- inject("data-v-7449f835_0", {
2813
- source: ".top-tab-query[data-v-7449f835] {\n margin-bottom: 10px;\n}\n.top-tab-query[data-v-7449f835] .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */",
2766
+ inject("data-v-35906918_0", {
2767
+ source: ".top-tab-query[data-v-35906918] {\n margin-bottom: 10px;\n}\n.top-tab-query[data-v-35906918] .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */",
2814
2768
  map: {
2815
2769
  "version": 3,
2816
2770
  "sources": ["/Users/tonwe/git/el-crud-page/src/index.vue", "index.vue"],
2817
2771
  "names": [],
2818
2772
  "mappings": "AA2UA;EACA,mBAAA;AC1UA;AD6UA;EACA,SAAA;AC3UA;;AAEA,oCAAoC",
2819
2773
  "file": "index.vue",
2820
- "sourcesContent": ["<!-- crud组件 主要用于子组件的上下文传递 -->\n<!-- \n 搜索组件配置 queryItems 可配置\n 搜索及重置事件 queryTable \n \n 切换组件配置 tabPanes 可配置\n 切换参数 tabQuery \n \n 按钮组件配置 buttons 可配置\n 右侧工具条\n 表格列配置 columns 可配置\n 表格数据\n 分页数据\n -->\n<template>\n\n <div class=\"el-crud\">\n <!-- 搜索过滤插槽 -->\n <slot name=\"query\" :queryItems=\"queryItems\" :lineClamp=\"queryLineClamp\" :labelWidth=\"queryLabelWidth\"\n :inputWidth=\"queryInputWidth\" :inline=\"queryInline\">\n <query-form v-show=\"showSearch\" v-if=\"queryItems && queryItems.length\" :queryItems=\"queryItems\"\n :lineClamp=\"queryLineClamp\" :label-width=\"queryLabelWidth\" :input-width=\"queryInputWidth\" :inline=\"queryInline\"\n @queryTable=\"handleQuery\" />\n </slot>\n <div class=\"container-main\" :class=\"{ pt5: tabPanes.length > 0 }\">\n <slot name=\"tabQuery\">\n <el-tabs class=\"top-tab-query\" v-if=\"tabPanes.length > 0\" :value=\"tabQuery.tabKey\"\n @tab-click=\"handleTabClick\">\n <el-tab-pane :label=\"item.label\" :name=\"item.name\" v-for=\"item in tabPanes\"\n :key=\"item.name\"></el-tab-pane>\n </el-tabs>\n </slot>\n <!-- 工具条插槽 -->\n <div class=\"flex justify-between el-crud-toolbar\">\n <slot name=\"buttons\" :selections=\"selections\">\n <div>\n <el-button :size=\"item.size\" @click=\"handleButtonClick(item)\" v-for=\"item in actionButtons\"\n :plain=\"item.plain\" :disabled=\"item.disabled\" :type=\"item.type\" :icon=\"item.icon\">{{\n item.text\n }}</el-button>\n </div>\n </slot>\n <slot name=\"toolbar\" :columns=\"columns\" :showSearch=\"showSearch\">\n <right-toolbar :showSearch.sync=\"showSearch\" @queryTable=\"refresh\" :columns=\"columns\"\n :search=\"!!(queryItems && queryItems.length)\"></right-toolbar>\n </slot>\n </div>\n <!-- 默认插槽 并传 data -->\n <slot :data=\"data\">\n <crud-table v-loading=\"listLoading\" size=\"mini\" @selection-change=\"handleSelectionChange\"\n :highlightCol=\"highlightCol\" :resizable=\"resizable\" :border=\"border\" :columns=\"columns\" :data=\"data\"\n @row-action=\"handleRowAction\" @sort-change=\"handleSortChange\"\n :default-sort=\"defaultSort\"></crud-table>\n </slot>\n <!-- 分页插槽 并传 total queryParams -->\n <slot name=\"pagination\" :total=\"total\" :pagination=\"pagination\">\n <pagination v-show=\"total > 0\" :total=\"total\" :page.sync=\"pagination.pageNum\"\n :limit.sync=\"pagination.pageSize\" @pagination=\"refresh\" />\n </slot>\n </div>\n\n </div>\n\n</template>\n\n\n<script>\nimport CrudTable from \"./table.vue\";\nimport RightToolbar from \"./rightToolbar.vue\";\nimport QueryForm from \"./queryForm.vue\";\nimport Pagination from \"./pagination.vue\"\nimport { toLine } from \"./utils\";\n\nexport default {\n components: {\n CrudTable, RightToolbar, QueryForm, Pagination\n },\n name: 'Crud',\n provide() {\n return {\n crud: this\n };\n },\n props: {\n queryParamsMethod: {\n type: Function\n },\n columns: {\n type: Array,\n default: () => []\n },\n queryItems: {\n type: Array,\n default: () => []\n },\n queryLineClamp: {\n type: Number,\n default: 1\n },\n queryLabelWidth: {\n type: Number,\n default: 80\n },\n queryInputWidth: {\n type: Number,\n default: 210\n },\n queryInline: {\n type: Boolean,\n default: true\n },\n buttons: {\n type: Array | Function,\n default: () => []\n },\n tabPanes: {\n type: Array,\n default: () => []\n },\n defaultSort: {\n type: Object,\n default: () => {\n return {\n prop: undefined,\n order: undefined\n }\n }\n },\n highlightCol: {\n type: Boolean,\n default: false\n },\n resizable: {\n type: Boolean,\n default: false\n },\n border: {\n type: Boolean,\n default: false\n }\n },\n watch: {\n tabPanes: {\n handler(val) {\n if (val.length) {\n\n this.tabQuery.tabKey = val[0].name\n }\n },\n deep: true,\n immediate: true\n },\n \"tabQuery.tabKey\": {\n handler(val) {\n this.$emit(\"tabChange\", val);\n },\n\n }\n },\n computed: {\n actionButtons() {\n let buts = this.buttons;\n if (typeof buts === 'function') {\n return buts(this.selections);\n } else if (buts?.length) {\n return buts\n }\n return []\n }\n },\n data() {\n return {\n listLoading: false,\n showSearch: true,\n selections: [],\n data: [],\n service: { // 增删改查导出\n add: null,\n update: null,\n delete: null,\n page: null,\n info: null,\n list: null,\n export: null,\n }, // 服务\n queryParams: {\n // pageNum: 1,\n // pageSize: 10\n }, // 查询参数\n\n tabQuery: {\n tabKey: undefined\n }, // 参数\n filterParams: {}, // 过滤参数\n pagination: {\n pageNum: 1,\n pageSize: 10\n },\n orderParams: {\n orderByRowName: undefined,\n orderByRule: undefined\n },\n total: 0,\n\n }\n },\n created() {\n },\n methods: {\n handleTabClick(tab) {\n this.tabQuery.tabKey = tab.name\n this.refresh()\n },\n handleSelectionChange(e) {\n this.selections = e\n },\n handleQuery(query) {\n this.queryParams = query;\n this.refresh()\n },\n handleButtonClick(item) {\n this.$emit(\"action\", item.action, this.selections);\n },\n handleRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n if (action === 'delete' && this.service.delete) {\n this.delete(scope)\n }\n },\n handleSortChange(column) {\n this.orderParams.orderByRowName = toLine(column.prop);\n if (column.order == \"descending\") {\n this.orderParams.orderByRule = \"desc\";\n } else if (column.order == \"ascending\") {\n this.orderParams.orderByRule = \"asc\";\n } else {\n this.orderParams.orderByRule = undefined;\n this.orderParams.orderByRowName = undefined;\n }\n this.refresh();\n },\n // 服务\n setService(service) {\n this.service = Object.assign(this.service, service);\n },\n // 设置列\n setColumns(columns) {\n this.columns = columns;\n },\n // 设置数据\n setData(data) {\n // this.crud.data = data;\n },\n // 获得查询参数\n async getParams() {\n const defaultSort = this.defaultSort;\n let orderParams = this.orderParams;\n\n if (!orderParams?.orderByRowName && defaultSort?.prop) {\n const orderByRowName = toLine(defaultSort.prop);\n let orderByRule = defaultSort.order;\n\n if (defaultSort.order == \"descending\") {\n orderByRule = \"desc\";\n } else if (defaultSort.order == \"ascending\") {\n orderByRule = \"asc\";\n }\n\n orderParams = {\n orderByRowName,\n orderByRule\n }\n }\n\n let params = { ...this.queryParams, ...this.pagination, ...this.tabQuery, ...orderParams }\n\n\n\n if (this.queryParamsMethod) {\n return await this.queryParamsMethod(params);\n }\n return params;\n },\n // 刷新列表数据\n async refresh() {\n this.listLoading = true;\n try {\n const queryParams = await this.getParams();\n const { code, rows, total } = await this.service.page(queryParams);\n if (code === 200) {\n this.data = rows;\n this.total = total;\n }\n\n } catch (error) {\n console.log(error);\n }\n this.listLoading = false;\n },\n // 删除\n async delete({ row }) {\n try {\n let id = row?.id;\n await this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {\n confirmButtonText: '确定',\n cancelButtonText: '取消',\n type: 'warning'\n })\n const { code } = await this.service.delete(id);\n if (code === 200) {\n this.refresh();\n this.$message({\n type: 'success',\n message: '操作成功!'\n });\n }\n } catch (error) {\n console.log(error);\n\n }\n\n\n }\n\n }\n\n}\n\n</script>\n\n<style scoped lang=\"scss\">\n.top-tab-query {\n margin-bottom: 10px;\n\n &::v-deep {\n .el-tabs__header {\n margin: 0;\n }\n }\n}\n</style>", ".top-tab-query {\n margin-bottom: 10px;\n}\n.top-tab-query::v-deep .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */"]
2774
+ "sourcesContent": ["<!-- crud组件 主要用于子组件的上下文传递 -->\n<!-- \n 搜索组件配置 queryItems 可配置\n 搜索及重置事件 queryTable \n \n 切换组件配置 tabPanes 可配置\n 切换参数 tabQuery \n \n 按钮组件配置 buttons 可配置\n 右侧工具条\n 表格列配置 columns 可配置\n 表格数据\n 分页数据\n -->\n<template>\n\n <div class=\"el-crud\">\n <!-- 搜索过滤插槽 -->\n <slot name=\"query\" :queryItems=\"queryItems\" :lineClamp=\"queryLineClamp\" :labelWidth=\"queryLabelWidth\"\n :inputWidth=\"queryInputWidth\" :inline=\"queryInline\">\n <query-form v-show=\"showSearch\" v-if=\"queryItems && queryItems.length\" :queryItems=\"queryItems\"\n :lineClamp=\"queryLineClamp\" :label-width=\"queryLabelWidth\" :input-width=\"queryInputWidth\" :inline=\"queryInline\"\n @queryTable=\"handleQuery\" />\n </slot>\n <div class=\"container-main\" :class=\"{ pt5: tabPanes.length > 0 }\">\n <slot name=\"tabQuery\">\n <el-tabs class=\"top-tab-query\" v-if=\"tabPanes.length > 0\" :value=\"tabQuery.tabKey\"\n @tab-click=\"handleTabClick\">\n <el-tab-pane :label=\"item.label\" :name=\"item.name\" v-for=\"item in tabPanes\"\n :key=\"item.name\"></el-tab-pane>\n </el-tabs>\n </slot>\n <!-- 工具条插槽 -->\n <div class=\"flex justify-between el-crud-toolbar\">\n <slot name=\"buttons\" :selections=\"selections\">\n <div>\n <el-button :size=\"item.size\" @click=\"handleButtonClick(item)\" v-for=\"(item,index) in actionButtons\" :key=\"`${item.key || ('action-btn-'+index)}`\"\n :plain=\"item.plain\" :disabled=\"item.disabled\" :type=\"item.type\" :icon=\"item.icon\">{{\n item.text\n }}</el-button>\n </div>\n </slot>\n <slot name=\"toolbar\" :columns=\"columns\" :showSearch=\"showSearch\">\n <right-toolbar :showSearch.sync=\"showSearch\" @queryTable=\"refresh\" :columns=\"columns\"\n :search=\"!!(queryItems && queryItems.length)\"></right-toolbar>\n </slot>\n </div>\n <!-- 默认插槽 并传 data -->\n <slot :data=\"data\">\n <crud-table v-loading=\"listLoading\" size=\"mini\" @selection-change=\"handleSelectionChange\"\n :highlightCol=\"highlightCol\" :resizable=\"resizable\" :border=\"border\" :columns=\"columns\" :data=\"data\"\n @row-action=\"handleRowAction\" @sort-change=\"handleSortChange\"\n :default-sort=\"defaultSort\"></crud-table>\n </slot>\n <!-- 分页插槽 并传 total queryParams -->\n <slot name=\"pagination\" :total=\"total\" :pagination=\"pagination\">\n <pagination v-show=\"total > 0\" :total=\"total\" :page.sync=\"pagination.pageNum\"\n :limit.sync=\"pagination.pageSize\" @pagination=\"refresh\" />\n </slot>\n </div>\n\n </div>\n\n</template>\n\n\n<script>\nimport CrudTable from \"./table.vue\";\nimport RightToolbar from \"./rightToolbar.vue\";\nimport QueryForm from \"./queryForm.vue\";\nimport Pagination from \"./pagination.vue\"\nimport { toLine } from \"./utils\";\n\nexport default {\n components: {\n CrudTable, RightToolbar, QueryForm, Pagination\n },\n name: 'Crud',\n provide() {\n return {\n crud: this\n };\n },\n props: {\n queryParamsMethod: {\n type: Function\n },\n columns: {\n type: Array,\n default: () => []\n },\n queryItems: {\n type: Array,\n default: () => []\n },\n queryLineClamp: {\n type: Number,\n default: 1\n },\n queryLabelWidth: {\n type: Number,\n default: 80\n },\n queryInputWidth: {\n type: Number,\n default: 210\n },\n queryInline: {\n type: Boolean,\n default: true\n },\n buttons: {\n type: Array | Function,\n default: () => []\n },\n tabPanes: {\n type: Array,\n default: () => []\n },\n defaultSort: {\n type: Object,\n default: () => {\n return {\n prop: undefined,\n order: undefined\n }\n }\n },\n highlightCol: {\n type: Boolean,\n default: false\n },\n resizable: {\n type: Boolean,\n default: false\n },\n border: {\n type: Boolean,\n default: false\n }\n },\n watch: {\n tabPanes: {\n handler(val) {\n if (val.length) {\n\n this.tabQuery.tabKey = val[0].name\n }\n },\n deep: true,\n immediate: true\n },\n \"tabQuery.tabKey\": {\n handler(val) {\n this.$emit(\"tabChange\", val);\n },\n\n }\n },\n computed: {\n actionButtons() {\n let buts = this.buttons;\n if (typeof buts === 'function') {\n return buts(this.selections);\n } else if (buts?.length) {\n return buts\n }\n return []\n }\n },\n data() {\n return {\n listLoading: false,\n showSearch: true,\n selections: [],\n data: [],\n service: { // 增删改查导出\n add: null,\n update: null,\n delete: null,\n page: null,\n info: null,\n list: null,\n export: null,\n }, // 服务\n queryParams: {\n // pageNum: 1,\n // pageSize: 10\n }, // 查询参数\n\n tabQuery: {\n tabKey: undefined\n }, // 参数\n filterParams: {}, // 过滤参数\n pagination: {\n pageNum: 1,\n pageSize: 10\n },\n orderParams: {\n orderByRowName: undefined,\n orderByRule: undefined\n },\n total: 0,\n\n }\n },\n created() {\n },\n methods: {\n handleTabClick(tab) {\n this.tabQuery.tabKey = tab.name\n this.refresh()\n },\n handleSelectionChange(e) {\n this.selections = e\n },\n handleQuery(query) {\n this.queryParams = query;\n this.refresh()\n },\n handleButtonClick(item) {\n this.$emit(\"action\", item.action, this.selections);\n },\n handleRowAction(action, scope) {\n this.$emit(\"row-action\", action, scope);\n if (action === 'delete' && this.service.delete) {\n this.delete(scope)\n }\n },\n handleSortChange(column) {\n this.orderParams.orderByRowName = toLine(column.prop);\n if (column.order == \"descending\") {\n this.orderParams.orderByRule = \"desc\";\n } else if (column.order == \"ascending\") {\n this.orderParams.orderByRule = \"asc\";\n } else {\n this.orderParams.orderByRule = undefined;\n this.orderParams.orderByRowName = undefined;\n }\n this.refresh();\n },\n // 服务\n setService(service) {\n this.service = Object.assign(this.service, service);\n },\n // 设置列\n setColumns(columns) {\n this.columns = columns;\n },\n // 设置数据\n setData(data) {\n // this.crud.data = data;\n },\n // 获得查询参数\n async getParams() {\n const defaultSort = this.defaultSort;\n let orderParams = this.orderParams;\n\n if (!orderParams?.orderByRowName && defaultSort?.prop) {\n const orderByRowName = toLine(defaultSort.prop);\n let orderByRule = defaultSort.order;\n\n if (defaultSort.order == \"descending\") {\n orderByRule = \"desc\";\n } else if (defaultSort.order == \"ascending\") {\n orderByRule = \"asc\";\n }\n\n orderParams = {\n orderByRowName,\n orderByRule\n }\n }\n\n let params = { ...this.queryParams, ...this.pagination, ...this.tabQuery, ...orderParams }\n\n\n\n if (this.queryParamsMethod) {\n return await this.queryParamsMethod(params);\n }\n return params;\n },\n // 刷新列表数据\n async refresh() {\n this.listLoading = true;\n try {\n const queryParams = await this.getParams();\n const { code, rows, total } = await this.service.page(queryParams);\n if (code === 200) {\n this.data = rows;\n this.total = total;\n }\n\n } catch (error) {\n console.log(error);\n }\n this.listLoading = false;\n },\n // 删除\n async delete({ row }) {\n try {\n let id = row?.id;\n await this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {\n confirmButtonText: '确定',\n cancelButtonText: '取消',\n type: 'warning'\n })\n const { code } = await this.service.delete(id);\n if (code === 200) {\n this.refresh();\n this.$message({\n type: 'success',\n message: '操作成功!'\n });\n }\n } catch (error) {\n console.log(error);\n\n }\n\n\n }\n\n }\n\n}\n\n</script>\n\n<style scoped lang=\"scss\">\n.top-tab-query {\n margin-bottom: 10px;\n\n &::v-deep {\n .el-tabs__header {\n margin: 0;\n }\n }\n}\n</style>", ".top-tab-query {\n margin-bottom: 10px;\n}\n.top-tab-query::v-deep .el-tabs__header {\n margin: 0;\n}\n\n/*# sourceMappingURL=index.vue.map */"]
2821
2775
  },
2822
2776
  media: undefined
2823
2777
  });
2824
2778
  };
2825
2779
  /* scoped */
2826
- var __vue_scope_id__$1 = "data-v-7449f835";
2780
+ var __vue_scope_id__ = "data-v-35906918";
2827
2781
  /* module identifier */
2828
- var __vue_module_identifier__$1 = undefined;
2782
+ var __vue_module_identifier__ = undefined;
2829
2783
  /* functional template */
2830
- var __vue_is_functional_template__$1 = false;
2784
+ var __vue_is_functional_template__ = false;
2831
2785
  /* style inject SSR */
2832
2786
 
2833
2787
  /* style inject shadow dom */
2834
2788
 
2835
- var __vue_component__$1 = /*#__PURE__*/normalizeComponent({
2789
+ var __vue_component__ = /*#__PURE__*/normalizeComponent({
2836
2790
  render: __vue_render__,
2837
2791
  staticRenderFns: __vue_staticRenderFns__
2838
- }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, createInjector, undefined, undefined);
2839
-
2840
- function getDefaultExportFromCjs (x) {
2841
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2842
- }
2843
-
2844
- function _extends(){return _extends=Object.assign?Object.assign.bind():function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}var normalMerge=["attrs","props","domProps"],toArrayMerge=["class","style","directives"],functionalMerge=["on","nativeOn"],mergeJsxProps=function(a){return a.reduce(function(c,a){for(var b in a)if(!c[b])c[b]=a[b];else if(-1!==normalMerge.indexOf(b))c[b]=_extends({},c[b],a[b]);else if(-1!==toArrayMerge.indexOf(b)){var d=c[b]instanceof Array?c[b]:[c[b]],e=a[b]instanceof Array?a[b]:[a[b]];c[b]=[].concat(d,e);}else if(-1!==functionalMerge.indexOf(b)){for(var f in a[b])if(c[b][f]){var g=c[b][f]instanceof Array?c[b][f]:[c[b][f]],h=a[b][f]instanceof Array?a[b][f]:[a[b][f]];c[b][f]=[].concat(g,h);}else c[b][f]=a[b][f];}else if("hook"===b)for(var i in a[b])c[b][i]=c[b][i]?mergeFn(c[b][i],a[b][i]):a[b][i];else c[b]=a[b];return c},{})},mergeFn=function(a,b){return function(){a&&a.apply(this,arguments),b&&b.apply(this,arguments);}};var helper=mergeJsxProps;
2845
-
2846
- var _mergeJSXProps7 = /*@__PURE__*/getDefaultExportFromCjs(helper);
2847
-
2848
- var format = {
2849
- number: function number(value) {
2850
- var result;
2851
- if (isArray(value)) {
2852
- result = value.map(Number).map(function (item) {
2853
- return isNaN(item) ? undefined : item;
2854
- });
2855
- } else {
2856
- result = Number(value);
2857
- if (isNaN(result)) {
2858
- result = undefined;
2859
- }
2860
- }
2861
- return result;
2862
- },
2863
- string: function string(value) {
2864
- return isArray(value) ? value.map(String) : String(value);
2865
- },
2866
- split: function split(value) {
2867
- return isString(value) ? value.split(",").filter(Boolean) : value;
2868
- },
2869
- join: function join(value) {
2870
- return isArray(value) ? value.join(",") : value;
2871
- },
2872
- "boolean": function boolean(value) {
2873
- return Boolean(value);
2874
- },
2875
- booleanNumber: function booleanNumber(value) {
2876
- return Boolean(value) ? 1 : 0;
2877
- },
2878
- datetimerange: function datetimerange(value, form, method) {
2879
- if (method == "bind") {
2880
- return [form.startTime, form.endTime];
2881
- } else {
2882
- var _ref = value || [],
2883
- _ref2 = _slicedToArray(_ref, 2),
2884
- startTime = _ref2[0],
2885
- endTime = _ref2[1];
2886
- form.startTime = startTime;
2887
- form.endTime = endTime;
2888
- return undefined;
2889
- }
2890
- },
2891
- splitJoin: function splitJoin(value, _, method) {
2892
- if (method == "bind") {
2893
- return isString(value) ? value.split(",").filter(Boolean) : value;
2894
- } else {
2895
- return isArray(value) ? value.join(",") : value;
2896
- }
2897
- }
2898
- };
2899
- function parse(method, _ref3) {
2900
- var value = _ref3.value,
2901
- pipe = _ref3.pipe,
2902
- form = _ref3.form;
2903
- if (!pipe) {
2904
- return value;
2905
- }
2906
- var pipes = [];
2907
- if (isString(pipe)) {
2908
- if (format[pipe]) {
2909
- pipes = [pipe];
2910
- } else {
2911
- console.error("".concat(pipe, " is not found."));
2912
- return value;
2913
- }
2914
- } else if (isArray(pipe)) {
2915
- pipes = pipe;
2916
- } else if (isObject(pipe)) {
2917
- pipes = isArray(pipe[method]) ? pipe[method] : [pipe[method]];
2918
- } else if (isFunction(pipe)) {
2919
- pipes = [pipe];
2920
- } else {
2921
- console.error("Hook data error!");
2922
- return value;
2923
- }
2924
- var d = value;
2925
- pipes.forEach(function (e) {
2926
- if (isString(e)) {
2927
- d = format[e](d, form, method);
2928
- } else if (isFunction(e)) {
2929
- d = e(d, form);
2930
- }
2931
- });
2932
- return d;
2933
- }
2934
- var valueHook = {
2935
- bind: function bind(value, pipe, form) {
2936
- return parse("bind", {
2937
- value: value,
2938
- pipe: pipe,
2939
- form: form
2940
- });
2941
- },
2942
- submit: function submit(value, pipe, form) {
2943
- return parse("submit", {
2944
- value: value,
2945
- pipe: pipe,
2946
- form: form
2947
- });
2948
- }
2949
- };
2950
-
2951
- // type FormItems = { // 表单项配置
2952
- // label: string; // 标签
2953
- // prop: string; // 字段名
2954
-
2955
- // options?: { value: string; label: string; disabled?: boolean }[] || ()=>[]; // 字典数据
2956
- // rules?: any[]; // 验证规则
2957
-
2958
- // children?: FormItems[];
2959
- // hidden?: boolean; // 是否隐藏
2960
- // help?: string; // 帮助信息
2961
-
2962
- // span?: number; // 栅格占据的列数
2963
- // labelWidth?: string; // formitem 标签宽度
2964
-
2965
- // component?: VNode;
2966
- // };
2967
- // type VNodeFunction = ({ scope,h }) => VNode | ({ scope,h }) =><div>{ scope }</div> | <div />;
2968
-
2969
- // type VNodeObject = {
2970
- // name?: string | Component; // 组件名 | 组件引用
2971
- // options?: any[]; // 选项
2972
- // attrs?: any; // 属性
2973
- // on?: any; // 事件
2974
- // props?: any; // 属性
2975
- // [key: string]: any;
2976
- // };
2977
- // type VNode = string | VNodeFunction | VNodeObject;
2978
-
2979
- var script = {
2980
- props: {
2981
- // 表单配置项,可以从外部传入
2982
- formItems: {
2983
- type: Array,
2984
- "default": function _default() {
2985
- return [];
2986
- }
2987
- },
2988
- // 初始表单数据
2989
- initialFormData: {
2990
- type: Object,
2991
- "default": function _default() {
2992
- return {};
2993
- }
2994
- },
2995
- // 按钮配置
2996
- buttons: {
2997
- type: Object,
2998
- "default": function _default() {
2999
- return {
3000
- submit: {
3001
- show: true,
3002
- text: '提交',
3003
- type: 'primary',
3004
- loading: false
3005
- },
3006
- cancel: {
3007
- show: true,
3008
- text: '取消',
3009
- type: 'default'
3010
- }
3011
- };
3012
- }
3013
- },
3014
- // 按钮位置
3015
- buttonPosition: {
3016
- type: String,
3017
- "default": 'right',
3018
- // center, left, right
3019
- validator: function validator(value) {
3020
- return ['center', 'left', 'right'].includes(value);
3021
- }
3022
- },
3023
- // 是否显示按钮区域
3024
- showButtons: {
3025
- type: Boolean,
3026
- "default": true
3027
- },
3028
- readonly: {
3029
- type: Boolean
3030
- },
3031
- labelWidth: {
3032
- type: String,
3033
- "default": '80px'
3034
- },
3035
- column: {
3036
- type: Number,
3037
- "default": 2
3038
- },
3039
- gutter: {
3040
- type: Number,
3041
- "default": 10
3042
- },
3043
- size: {
3044
- type: String,
3045
- "default": 'small'
3046
- }
3047
- // value: {
3048
- // type: Object,
3049
- // default: () => ({})
3050
- // },
3051
- },
3052
- data: function data() {
3053
- return {
3054
- form: {},
3055
- // 如果没有传入formItems,则使用默认配置
3056
- items: [],
3057
- activeName: 'first',
3058
- submitLoading: false
3059
- };
3060
- },
3061
- computed: {
3062
- // 从items中提取所有字段的规则
3063
- formRules: function formRules() {
3064
- var rules = {};
3065
-
3066
- // 递归提取规则函数
3067
- var _extractRules = function extractRules(nodes) {
3068
- if (!nodes || !nodes.length) return;
3069
- nodes.forEach(function (node) {
3070
- // 如果节点有children,递归处理
3071
- if (node.children && node.children.length) {
3072
- _extractRules(node.children);
3073
- }
3074
-
3075
- // 如果是表单字段且有规则,添加到规则对象
3076
- if (node.prop && node.rules) {
3077
- rules[node.prop] = node.rules;
3078
- }
3079
- });
3080
- };
3081
-
3082
- // 对所有配置项提取规则
3083
- _extractRules(this.items);
3084
- return rules;
3085
- },
3086
- // 按钮区域样式
3087
- buttonAreaStyle: function buttonAreaStyle() {
3088
- return {
3089
- textAlign: this.buttonPosition,
3090
- marginTop: '20px'
3091
- };
3092
- },
3093
- // label宽度
3094
- labelStyle: function labelStyle() {
3095
- return {
3096
- width: this.labelWidth,
3097
- textAlign: 'center'
3098
- };
3099
- }
3100
- },
3101
- watch: {
3102
- // 监听外部传入的表单数据变化
3103
- initialFormData: {
3104
- handler: function handler(val) {
3105
- this.form = JSON.parse(JSON.stringify(val));
3106
- },
3107
- immediate: true,
3108
- deep: true
3109
- },
3110
- // 监听外部传入的表单配置变化
3111
- formItems: {
3112
- handler: function handler(val) {
3113
- if (val && val.length) {
3114
- this.items = val;
3115
- }
3116
- },
3117
- immediate: true,
3118
- deep: true
3119
- },
3120
- // 监听外部传入的value变化
3121
- // value: {
3122
- // handler(val) {
3123
- // this.form = JSON.parse(JSON.stringify(val)) || {};
3124
- // },
3125
- // immediate: true,
3126
- // deep: true
3127
- // },
3128
- // v-model绑定的值变化时,更新表单数据
3129
- form: {
3130
- handler: function handler(val) {
3131
- this.$emit('input', val);
3132
- },
3133
- deep: true
3134
- }
3135
- },
3136
- methods: {
3137
- // 处理表单输入事件
3138
- handleInput: function handleInput(prop, value) {
3139
- this.$set(this.form, prop, value);
3140
- // 触发change事件,将变更通知给父组件
3141
- this.$emit('field-change', {
3142
- prop: prop,
3143
- value: value,
3144
- form: this.form
3145
- });
3146
- },
3147
- // 递归渲染函数 - 根据节点类型渲染不同内容
3148
- renderNode: function renderNode(node, index) {
3149
- // 如果是只读模式,使用只读渲染函数
3150
- if (this.readonly) {
3151
- return this.renderReadOnlyNode(node, index);
3152
- }
3153
-
3154
- // 如果是输入字段(没有type或没有children,则视为字段)
3155
- if (!node.type || !node.children && node.prop) {
3156
- return this.renderField(node, index);
3157
- }
3158
-
3159
- // 根据节点类型渲染
3160
- switch (node.type) {
3161
- case 'tab':
3162
- return this.renderTab(node, index);
3163
- case 'group':
3164
- return this.renderGroup(node, index);
3165
- default:
3166
- // 默认当作字段渲染
3167
- return this.renderField(node, index);
3168
- }
3169
- },
3170
- // 只读模式 - 递归渲染函数
3171
- renderReadOnlyNode: function renderReadOnlyNode(node, index) {
3172
- if (!node.type || !node.children && node.prop) {
3173
- return this.renderReadOnlyField(node, index);
3174
- }
3175
- switch (node.type) {
3176
- case 'tab':
3177
- return this.renderReadOnlyTab(node, index);
3178
- case 'group':
3179
- return this.renderReadOnlyGroup(node, index);
3180
- default:
3181
- return this.renderReadOnlyField(node, index);
3182
- }
3183
- },
3184
- // 只读模式 - 渲染标签页
3185
- renderReadOnlyTab: function renderReadOnlyTab(tab, index) {
3186
- var h = this.$createElement;
3187
- return h("el-tab-pane", _mergeJSXProps7([{
3188
- "key": tab.name || index,
3189
- "attrs": {
3190
- "label": tab.label,
3191
- "name": tab.name || index
3192
- }
3193
- }, tab.props]), [this.renderReadOnlyChildren(tab.children)]);
3194
- },
3195
- // 只读模式 - 渲染分组
3196
- renderReadOnlyGroup: function renderReadOnlyGroup(group, index) {
3197
- var h = this.$createElement;
3198
- return h("div", _mergeJSXProps7([{
3199
- "class": ['el-form-group', group.className],
3200
- "key": index
3201
- }, group.props]), [h("el-descriptions", {
3202
- "attrs": {
3203
- "title": group.title,
3204
- "border": true,
3205
- "column": this.column,
3206
- "size": this.size,
3207
- "labelStyle": this.labelStyle
3208
- }
3209
- }, [this.renderReadOnlyDescriptionItems(group.children)])]);
3210
- },
3211
- // 只读模式 - 渲染字段
3212
- renderReadOnlyField: function renderReadOnlyField(field, index) {
3213
- var h = this.$createElement;
3214
- // 如果字段被配置为隐藏,则不渲染
3215
- if (field.hidden) {
3216
- return null;
3217
- }
3218
-
3219
- // 获取字段值
3220
- var value = this.form[field.prop];
3221
-
3222
- // 处理显示值
3223
- var displayValue = value;
3224
-
3225
- // 处理不同类型的字段显示值
3226
- if (field.options && Array.isArray(field.options)) {
3227
- var option = field.options.find(function (opt) {
3228
- return opt.value === value;
3229
- });
3230
- if (option) {
3231
- displayValue = option.label;
3232
- }
3233
- }
3234
-
3235
- // 如果处于顶层(不在group内),则需要包装在el-descriptions中
3236
- if (!field._inGroup) {
3237
- return h("el-col", {
3238
- "attrs": {
3239
- "span": 24 / this.column || field.span || 12
3240
- },
3241
- "key": field.prop || index
3242
- }, [h("el-descriptions", {
3243
- "attrs": {
3244
- "labelStyle": this.labelStyle,
3245
- "border": true,
3246
- "column": this.column,
3247
- "size": this.size
3248
- }
3249
- }, [h("el-descriptions-item", {
3250
- "attrs": {
3251
- "label": field.label || ''
3252
- }
3253
- }, [displayValue || '-'])])]);
3254
- }
3255
- // 在group内部的字段直接返回
3256
- return h("el-descriptions-item", {
3257
- "attrs": {
3258
- "label": field.label || ''
3259
- }
3260
- }, [displayValue || '-']);
3261
- },
3262
- // 只读模式 - 渲染描述项
3263
- renderReadOnlyDescriptionItems: function renderReadOnlyDescriptionItems(children) {
3264
- var _this = this;
3265
- if (!children || !children.length) {
3266
- return null;
3267
- }
3268
- return children.map(function (child) {
3269
- // 标记字段在group内部
3270
- child._inGroup = true;
3271
- return _this.renderReadOnlyField(child);
3272
- });
3273
- },
3274
- // 只读模式 - 渲染子节点
3275
- renderReadOnlyChildren: function renderReadOnlyChildren(children) {
3276
- var _this2 = this;
3277
- var h = this.$createElement;
3278
- // 如果没有子节点,返回空
3279
- if (!children || !children.length) {
3280
- return null;
3281
- }
3282
-
3283
- // 检查第一个子节点类型,判断是否需要包装
3284
- var firstChild = children[0];
3285
-
3286
- // 如果第一个子节点是group,不需要额外包装
3287
- if (firstChild.type === 'group') {
3288
- return children.map(function (child, index) {
3289
- return _this2.renderReadOnlyNode(child, index);
3290
- });
3291
- }
3292
-
3293
- // 如果子节点不是输入字段,也不是分组,则直接渲染
3294
- if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {
3295
- return children.map(function (child, index) {
3296
- return _this2.renderReadOnlyNode(child, index);
3297
- });
3298
- }
3299
-
3300
- // 如果是普通字段(非group),则包装在el-descriptions中
3301
- return h("el-descriptions", {
3302
- "attrs": {
3303
- "border": true,
3304
- "column": this.column,
3305
- "size": this.size,
3306
- "labelStyle": this.labelStyle
3307
- }
3308
- }, [children.map(function (child, index) {
3309
- child._inGroup = true;
3310
- return _this2.renderReadOnlyNode(child, index);
3311
- })]);
3312
- },
3313
- // 渲染标签页
3314
- renderTab: function renderTab(tab, index) {
3315
- var h = this.$createElement;
3316
- return h("el-tab-pane", _mergeJSXProps7([{
3317
- "key": tab.name || index,
3318
- "attrs": {
3319
- "label": tab.label,
3320
- "name": tab.name || index
3321
- }
3322
- }, tab.props]), [this.renderChildren(tab.children)]);
3323
- },
3324
- // 渲染分组
3325
- renderGroup: function renderGroup(group, index) {
3326
- var h = this.$createElement;
3327
- return h("div", _mergeJSXProps7([{
3328
- "class": ['el-form-group', group.className],
3329
- "key": index
3330
- }, group.props]), [group.title && h("div", {
3331
- "class": "el-form-group__title"
3332
- }, [group.title]), h("div", [this.renderChildren(group.children)])]);
3333
- },
3334
- // 渲染各种表单控件
3335
- renderFormControl: function renderFormControl(field) {
3336
- var _field$hook;
3337
- var component = field.component;
3338
- if (isString(field.component)) {
3339
- component = {
3340
- name: field.component,
3341
- attrs: {
3342
- placeholder: field.placeholder || "\u8BF7\u8F93\u5165".concat(field.label),
3343
- clearable: typeof field.clearable !== 'undefined' ? field.clearable : true
3344
- }
3345
- };
3346
- }
3347
- if (!isFunction(field.component)) {
3348
- if (field.component === 'el-select') {
3349
- component.attrs = _objectSpread2(_objectSpread2({}, component.attrs), {}, {
3350
- placeholder: field.placeholder || "\u8BF7\u9009\u62E9".concat(field.label),
3351
- filterable: true
3352
- });
3353
- }
3354
- }
3355
- if ((_field$hook = field.hook) !== null && _field$hook !== void 0 && (_field$hook = _field$hook.bind) !== null && _field$hook !== void 0 && _field$hook.length) {
3356
- var _field$hook2;
3357
- var value = valueHook.bind(this.form[field.prop], (_field$hook2 = field.hook) === null || _field$hook2 === void 0 ? void 0 : _field$hook2.bind, this.form);
3358
- this.$set(this.form, field.prop, value);
3359
- }
3360
- // component 渲染 { prop: this.column.prop, scope: scope }
3361
- return renderNode.call(this, component, {
3362
- prop: field.prop,
3363
- scope: this.form
3364
- });
3365
- },
3366
- // 渲染字段
3367
- renderField: function renderField(field, index) {
3368
- var h = this.$createElement;
3369
- // 如果字段被配置为隐藏,则不渲染
3370
- if (field.hidden) {
3371
- return null;
3372
- }
3373
- return h("el-col", {
3374
- "attrs": {
3375
- "span": 24 / this.column || field.span || 12
3376
- },
3377
- "key": field.prop || index
3378
- }, [h("el-form-item", _mergeJSXProps7([{
3379
- "attrs": {
3380
- "label": field.label,
3381
- "prop": field.prop,
3382
- "rules": field.rules,
3383
- "labelWidth": field.labelWidth || this.labelWidth
3384
- }
3385
- }, field.formItemProps]), [this.renderFormControl(field), field.help && h("div", {
3386
- "class": "form-item-help"
3387
- }, [field.help])])]);
3388
- },
3389
- // 渲染子节点
3390
- renderChildren: function renderChildren(children) {
3391
- var h = this.$createElement;
3392
- // 如果没有子节点,返回空
3393
- if (!children || !children.length) {
3394
- return null;
3395
- }
3396
-
3397
- // 检查第一个子节点类型,判断是否需要包装
3398
- var firstChild = children[0];
3399
-
3400
- // 如果第一个子节点是group,不需要额外包装
3401
- if (firstChild.type === 'group') {
3402
- return children.map(this.renderNode);
3403
- }
3404
-
3405
- // 如果子节点不是输入字段,也不是分组,则直接渲染
3406
- if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {
3407
- return children.map(this.renderNode);
3408
- }
3409
-
3410
- // 其他情况(子节点是输入字段)包装在row中
3411
- return h("el-row", {
3412
- "attrs": {
3413
- "gutter": this.gutter
3414
- }
3415
- }, [children.map(this.renderNode)]);
3416
- },
3417
- // 判断是否有标签页
3418
- hasTabs: function hasTabs() {
3419
- return this.items && this.items.some(function (item) {
3420
- return item.type === 'tab';
3421
- });
3422
- },
3423
- // 渲染按钮区域
3424
- renderButtons: function renderButtons() {
3425
- var h = this.$createElement;
3426
- if (!this.showButtons || this.readonly) return null;
3427
- return h("div", {
3428
- "class": "form-button-area",
3429
- "style": this.buttonAreaStyle
3430
- }, [this.buttons.cancel && this.buttons.cancel.show && h("el-button", _mergeJSXProps7([{
3431
- "on": {
3432
- "click": this.handleCancel
3433
- },
3434
- "attrs": {
3435
- "type": this.buttons.cancel.type
3436
- }
3437
- }, this.buttons.cancel.props]), [this.buttons.cancel.text]), this.buttons.submit && this.buttons.submit.show && h("el-button", _mergeJSXProps7([{
3438
- "on": {
3439
- "click": this.handleSubmit
3440
- },
3441
- "attrs": {
3442
- "type": this.buttons.submit.type,
3443
- "loading": this.submitLoading || this.buttons.submit.loading
3444
- }
3445
- }, this.buttons.submit.props]), [this.buttons.submit.text])]);
3446
- },
3447
- // 处理提交
3448
- handleSubmit: function handleSubmit() {
3449
- var _this3 = this;
3450
- return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3451
- var formData, _t;
3452
- return _regenerator().w(function (_context) {
3453
- while (1) switch (_context.p = _context.n) {
3454
- case 0:
3455
- _context.p = 0;
3456
- _this3.submitLoading = true;
3457
- // 表单验证
3458
- _context.n = 1;
3459
- return _this3.validate();
3460
- case 1:
3461
- formData = _context.v;
3462
- // 发出提交事件
3463
- _this3.$emit('submit', formData);
3464
-
3465
- // return formData;
3466
- _context.n = 3;
3467
- break;
3468
- case 2:
3469
- _context.p = 2;
3470
- _t = _context.v;
3471
- _this3.$emit('submit-error', _t);
3472
- return _context.a(2, Promise.reject(_t));
3473
- case 3:
3474
- _this3.submitLoading = false;
3475
- case 4:
3476
- return _context.a(2);
3477
- }
3478
- }, _callee, null, [[0, 2]]);
3479
- }))();
3480
- },
3481
- // 处理取消
3482
- handleCancel: function handleCancel() {
3483
- this.$emit('cancel');
3484
- },
3485
- // 表单验证方法
3486
- validate: function validate() {
3487
- var _this4 = this;
3488
- return new Promise(function (resolve, reject) {
3489
- _this4.$refs.form.validate(function (valid) {
3490
- if (valid) {
3491
- resolve(_this4.form);
3492
- } else {
3493
- reject(new Error('表单验证失败'));
3494
- }
3495
- });
3496
- });
3497
- },
3498
- // 重置表单
3499
- resetForm: function resetForm() {
3500
- this.form = JSON.parse(JSON.stringify(this.initialFormData)) || {};
3501
- this.$refs.form.resetFields();
3502
- this.$emit('form-reset', this.form);
3503
- },
3504
- // 获取表单数据
3505
- getFormData: function getFormData() {
3506
- return this.form;
3507
- }
3508
- },
3509
- render: function render() {
3510
- var _this5 = this;
3511
- var h = arguments[0];
3512
- if (this.readonly) {
3513
- // 只读模式渲染
3514
- return h("div", {
3515
- "class": "dynamic-form-container readonly"
3516
- }, [this.hasTabs() ? // 渲染标签页结构
3517
- h("el-tabs", {
3518
- "directives": [{
3519
- name: "on",
3520
- value: this.$listeners
3521
- }],
3522
- "model": {
3523
- value: _this5.activeName,
3524
- callback: function callback($$v) {
3525
- _this5.activeName = $$v;
3526
- }
3527
- }
3528
- }, [this.items.map(function (item, index) {
3529
- return _this5.renderReadOnlyNode(item, index);
3530
- })]) :
3531
- // 非标签页结构,直接渲染
3532
- this.renderReadOnlyChildren(this.items)]);
3533
- }
3534
- var formProps = _objectSpread2({
3535
- model: this.form,
3536
- rules: this.formRules
3537
- }, this.$attrs);
3538
- // 如果没有配置项,渲染空表单
3539
- if (!this.items || !this.items.length) {
3540
- return h("div", {
3541
- "class": "dynamic-form-container"
3542
- }, [h("el-form", {
3543
- "ref": "form",
3544
- "props": _objectSpread2({}, formProps)
3545
- })]);
3546
- }
3547
- return h("div", {
3548
- "class": "dynamic-form-container"
3549
- }, [h("el-form", {
3550
- "ref": "form",
3551
- "props": _objectSpread2({}, formProps)
3552
- }, [this.hasTabs() ? // 渲染标签页结构
3553
- h("el-tabs", {
3554
- "directives": [{
3555
- name: "on",
3556
- value: this.$listeners
3557
- }],
3558
- "model": {
3559
- value: _this5.activeName,
3560
- callback: function callback($$v) {
3561
- _this5.activeName = $$v;
3562
- }
3563
- }
3564
- }, [this.items.map(this.renderNode)]) :
3565
- // 非标签页结构,直接渲染
3566
- this.renderChildren(this.items), this.renderButtons()])]);
3567
- }
3568
- };
3569
-
3570
- /* script */
3571
- var __vue_script__ = script;
3572
-
3573
- /* template */
3574
-
3575
- /* style */
3576
- var __vue_inject_styles__ = function __vue_inject_styles__(inject) {
3577
- if (!inject) return;
3578
- inject("data-v-ef86d32c_0", {
3579
- source: "@charset \"UTF-8\";\n.dynamic-form-container[data-v-ef86d32c] {\n padding: 20px;\n}\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-input,\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-select {\n width: 100%;\n}\n.dynamic-form-container .el-form .el-form-item[data-v-ef86d32c] .el-input__inner {\n width: 100%;\n}\n.el-form-group[data-v-ef86d32c] {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n.el-form-group__title[data-v-ef86d32c] {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n.form-button-area[data-v-ef86d32c] {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n.form-button-area .el-button + .el-button[data-v-ef86d32c] {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly .el-descriptions__body[data-v-ef86d32c] {\n background-color: #fafafa;\n}\n.dynamic-form-container.readonly .el-descriptions-item__label[data-v-ef86d32c] {\n font-weight: bold;\n}\n.dynamic-form-container.readonly .el-descriptions-item__content[data-v-ef86d32c] {\n word-break: break-all;\n}\n\n/*# sourceMappingURL=form.vue.map */",
3580
- map: {
3581
- "version": 3,
3582
- "sources": ["form.vue", "/Users/tonwe/git/el-crud-page/src/form.vue"],
3583
- "names": [],
3584
- "mappings": "AAAA,gBAAgB;ACqlBhB;EACA,aAAA;ADnlBA;AC2lBA;;EAEA,WAAA;ADzlBA;AC2lBA;EACA,WAAA;ADzlBA;AComBA;EACA,mBAAA;EACA,mBAAA;EACA,gCAAA;ADjmBA;AComBA;EACA,iBAAA;EACA,mBAAA;EACA,eAAA;EACA,cAAA;ADjmBA;AComBA;EACA,iBAAA;EACA,6BAAA;ADjmBA;AComBA;EACA,iBAAA;ADjmBA;;AComBA,WAAA;AAEA;EACA,yBAAA;ADlmBA;ACqmBA;EACA,iBAAA;ADnmBA;ACsmBA;EACA,qBAAA;ADpmBA;;AAEA,mCAAmC",
3585
- "file": "form.vue",
3586
- "sourcesContent": ["@charset \"UTF-8\";\n.dynamic-form-container {\n padding: 20px;\n}\n.dynamic-form-container .el-form .el-form-item::v-deep .el-input,\n.dynamic-form-container .el-form .el-form-item::v-deep .el-select {\n width: 100%;\n}\n.dynamic-form-container .el-form .el-form-item::v-deep .el-input__inner {\n width: 100%;\n}\n\n.el-form-group {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n\n.el-form-group__title {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n\n.form-button-area {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n\n.form-button-area .el-button + .el-button {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly .el-descriptions__body {\n background-color: #fafafa;\n}\n.dynamic-form-container.readonly .el-descriptions-item__label {\n font-weight: bold;\n}\n.dynamic-form-container.readonly .el-descriptions-item__content {\n word-break: break-all;\n}\n\n/*# sourceMappingURL=form.vue.map */", "<script lang=\"jsx\">\nimport { renderNode } from \"./utils/vnode\"\nimport { isObject, isString ,isFunction} from \"./utils/index\"\nimport valueHook from \"./utils/value-hook\"\n\n// type FormItems = { // 表单项配置\n// label: string; // 标签\n// prop: string; // 字段名\n\n// options?: { value: string; label: string; disabled?: boolean }[] || ()=>[]; // 字典数据\n// rules?: any[]; // 验证规则\n\n// children?: FormItems[];\n// hidden?: boolean; // 是否隐藏\n// help?: string; // 帮助信息\n\n// span?: number; // 栅格占据的列数\n// labelWidth?: string; // formitem 标签宽度 \n\n// component?: VNode;\n// };\n// type VNodeFunction = ({ scope,h }) => VNode | ({ scope,h }) =><div>{ scope }</div> | <div />;\n\n// type VNodeObject = { \n// name?: string | Component; // 组件名 | 组件引用\n// options?: any[]; // 选项\n// attrs?: any; // 属性\n// on?: any; // 事件\n// props?: any; // 属性\n// [key: string]: any;\n// };\n// type VNode = string | VNodeFunction | VNodeObject;\n\n\nexport default {\n props: {\n // 表单配置项,可以从外部传入\n formItems: {\n type: Array,\n default: () => []\n },\n // 初始表单数据\n initialFormData: {\n type: Object,\n default: () => ({})\n },\n // 按钮配置\n buttons: {\n type: Object,\n default: () => ({\n submit: {\n show: true,\n text: '提交',\n type: 'primary',\n loading: false\n },\n cancel: {\n show: true,\n text: '取消',\n type: 'default'\n }\n })\n },\n // 按钮位置\n buttonPosition: {\n type: String,\n default: 'right', // center, left, right\n validator: value => ['center', 'left', 'right'].includes(value)\n },\n // 是否显示按钮区域\n showButtons: {\n type: Boolean,\n default: true\n },\n readonly: {\n type: Boolean\n },\n labelWidth: {\n type: String,\n default: '80px'\n },\n column: {\n type: Number,\n default: 2\n },\n gutter: {\n type: Number,\n default: 10\n },\n size: {\n type: String,\n default: 'small'\n },\n // value: {\n // type: Object,\n // default: () => ({})\n // },\n\n\n },\n\n data() {\n return {\n form: {},\n // 如果没有传入formItems,则使用默认配置\n items: [],\n activeName: 'first',\n submitLoading: false\n\n }\n },\n\n computed: {\n // 从items中提取所有字段的规则\n formRules() {\n const rules = {};\n\n // 递归提取规则函数\n const extractRules = (nodes) => {\n if (!nodes || !nodes.length) return;\n\n nodes.forEach(node => {\n // 如果节点有children,递归处理\n if (node.children && node.children.length) {\n extractRules(node.children);\n }\n\n // 如果是表单字段且有规则,添加到规则对象\n if (node.prop && node.rules) {\n rules[node.prop] = node.rules;\n }\n });\n };\n\n // 对所有配置项提取规则\n extractRules(this.items);\n\n return rules;\n },\n // 按钮区域样式\n buttonAreaStyle() {\n return {\n textAlign: this.buttonPosition,\n marginTop: '20px'\n };\n },\n // label宽度\n labelStyle() {\n return {\n width: this.labelWidth,\n textAlign: 'center'\n };\n },\n\n\n },\n\n watch: {\n // 监听外部传入的表单数据变化\n initialFormData: {\n handler(val) {\n this.form = JSON.parse(JSON.stringify(val));\n },\n immediate: true,\n deep: true\n },\n // 监听外部传入的表单配置变化\n formItems: {\n handler(val) {\n if (val && val.length) {\n this.items = val;\n }\n },\n immediate: true,\n deep: true\n },\n // 监听外部传入的value变化\n // value: {\n // handler(val) {\n // this.form = JSON.parse(JSON.stringify(val)) || {};\n // },\n // immediate: true,\n // deep: true\n // },\n // v-model绑定的值变化时,更新表单数据\n form: {\n handler(val) {\n this.$emit('input', val);\n },\n deep: true\n }\n },\n\n methods: {\n // 处理表单输入事件\n handleInput(prop, value) {\n this.$set(this.form, prop, value);\n // 触发change事件,将变更通知给父组件\n this.$emit('field-change', { prop, value, form: this.form });\n },\n\n // 递归渲染函数 - 根据节点类型渲染不同内容\n renderNode(node, index) {\n // 如果是只读模式,使用只读渲染函数\n if (this.readonly) {\n return this.renderReadOnlyNode(node, index);\n }\n\n // 如果是输入字段(没有type或没有children,则视为字段)\n if (!node.type || (!node.children && node.prop)) {\n return this.renderField(node, index);\n }\n\n // 根据节点类型渲染\n switch (node.type) {\n case 'tab':\n return this.renderTab(node, index);\n case 'group':\n return this.renderGroup(node, index);\n default:\n // 默认当作字段渲染\n return this.renderField(node, index);\n }\n },\n\n // 只读模式 - 递归渲染函数\n renderReadOnlyNode(node, index) {\n if (!node.type || (!node.children && node.prop)) {\n return this.renderReadOnlyField(node, index);\n }\n switch (node.type) {\n case 'tab':\n return this.renderReadOnlyTab(node, index);\n case 'group':\n return this.renderReadOnlyGroup(node, index);\n default:\n return this.renderReadOnlyField(node, index);\n }\n },\n\n // 只读模式 - 渲染标签页\n renderReadOnlyTab(tab, index) {\n return (\n <el-tab-pane\n key={tab.name || index}\n label={tab.label}\n name={tab.name || index}\n {...tab.props}\n >\n {this.renderReadOnlyChildren(tab.children)}\n </el-tab-pane>\n );\n },\n\n // 只读模式 - 渲染分组\n renderReadOnlyGroup(group, index) {\n return (\n <div class={['el-form-group', group.className]} key={index} {...group.props}>\n <el-descriptions\n title={group.title}\n border\n column={this.column}\n size={this.size}\n labelStyle={this.labelStyle}\n >\n {this.renderReadOnlyDescriptionItems(group.children)}\n </el-descriptions>\n </div>\n );\n },\n\n // 只读模式 - 渲染字段\n renderReadOnlyField(field, index) {\n // 如果字段被配置为隐藏,则不渲染\n if (field.hidden) {\n return null;\n }\n\n // 获取字段值\n const value = this.form[field.prop];\n\n // 处理显示值\n let displayValue = value;\n\n // 处理不同类型的字段显示值\n if (field.options && Array.isArray(field.options)) {\n const option = field.options.find(opt => opt.value === value);\n if (option) {\n displayValue = option.label;\n }\n }\n\n // 如果处于顶层(不在group内),则需要包装在el-descriptions中\n if (!field._inGroup) {\n return (\n <el-col span={24 / this.column || field.span || 12} key={field.prop || index}>\n <el-descriptions labelStyle={this.labelStyle} border column={this.column} size={this.size}>\n <el-descriptions-item label={field.label || ''}>\n {displayValue || '-'}\n </el-descriptions-item>\n </el-descriptions>\n </el-col>\n );\n }\n // 在group内部的字段直接返回\n return (\n <el-descriptions-item label={field.label || ''}>\n {displayValue || '-'}\n </el-descriptions-item>\n );\n },\n\n // 只读模式 - 渲染描述项\n renderReadOnlyDescriptionItems(children) {\n if (!children || !children.length) {\n return null;\n }\n\n return children.map(child => {\n // 标记字段在group内部\n child._inGroup = true;\n return this.renderReadOnlyField(child);\n });\n },\n\n // 只读模式 - 渲染子节点\n renderReadOnlyChildren(children) {\n // 如果没有子节点,返回空\n if (!children || !children.length) {\n return null;\n }\n\n // 检查第一个子节点类型,判断是否需要包装\n const firstChild = children[0];\n\n // 如果第一个子节点是group,不需要额外包装\n if (firstChild.type === 'group') {\n return children.map((child, index) => this.renderReadOnlyNode(child, index));\n }\n\n // 如果子节点不是输入字段,也不是分组,则直接渲染\n if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {\n return children.map((child, index) => this.renderReadOnlyNode(child, index));\n }\n\n // 如果是普通字段(非group),则包装在el-descriptions中\n return (\n <el-descriptions border column={this.column} size={this.size} labelStyle={this.labelStyle}>\n {children.map((child, index) => {\n child._inGroup = true;\n return this.renderReadOnlyNode(child, index);\n })}\n </el-descriptions>\n );\n },\n\n // 渲染标签页\n renderTab(tab, index) {\n return (\n <el-tab-pane\n key={tab.name || index}\n label={tab.label}\n name={tab.name || index}\n {...tab.props}\n >\n {this.renderChildren(tab.children)}\n </el-tab-pane>\n );\n },\n\n // 渲染分组\n renderGroup(group, index) {\n return (\n <div class={['el-form-group', group.className]} key={index} {...group.props}>\n {group.title && <div class=\"el-form-group__title\">{group.title}</div>}\n <div>\n {this.renderChildren(group.children)}\n </div>\n </div>\n );\n },\n\n // 渲染各种表单控件\n renderFormControl(field) {\n let component = field.component;\n if (isString(field.component)) {\n component = {\n name: field.component,\n attrs: {\n placeholder: field.placeholder || `请输入${field.label}`,\n clearable: typeof field.clearable !== 'undefined' ? field.clearable : true,\n }\n }\n }\n if ( !isFunction(field.component)) {\n if (field.component === 'el-select') {\n component.attrs = {\n ...component.attrs,\n placeholder: field.placeholder || `请选择${field.label}`,\n filterable: true,\n\n }\n } \n }\n\n if( field.hook?.bind?.length ){\n let value = valueHook.bind(this.form[ field.prop ], field.hook?.bind , this.form)\n this.$set(this.form, field.prop, value)\n }\n // component 渲染 { prop: this.column.prop, scope: scope }\n return renderNode.call(this, component, {\n prop: field.prop,\n scope: this.form\n });\n\n },\n\n // 渲染字段\n renderField(field, index) {\n // 如果字段被配置为隐藏,则不渲染\n if (field.hidden) {\n return null;\n }\n return (\n <el-col span={24 / this.column || field.span || 12} key={field.prop || index}>\n <el-form-item\n label={field.label}\n prop={field.prop}\n rules={field.rules} // 直接使用字段自身的规则\n labelWidth={field.labelWidth || this.labelWidth}\n {...field.formItemProps}\n >\n {this.renderFormControl(field)}\n {field.help && <div class=\"form-item-help\">{field.help}</div>}\n </el-form-item>\n </el-col>\n );\n },\n\n // 渲染子节点\n renderChildren(children) {\n // 如果没有子节点,返回空\n if (!children || !children.length) {\n return null;\n }\n\n // 检查第一个子节点类型,判断是否需要包装\n const firstChild = children[0];\n\n // 如果第一个子节点是group,不需要额外包装\n if (firstChild.type === 'group') {\n return children.map(this.renderNode);\n }\n\n // 如果子节点不是输入字段,也不是分组,则直接渲染\n if (firstChild.type && firstChild.type !== 'group' && !firstChild.prop) {\n return children.map(this.renderNode);\n }\n\n // 其他情况(子节点是输入字段)包装在row中\n return <el-row gutter={this.gutter}>{children.map(this.renderNode)}</el-row>;\n },\n\n // 判断是否有标签页\n hasTabs() {\n return this.items && this.items.some(item => item.type === 'tab');\n },\n\n // 渲染按钮区域\n renderButtons() {\n if (!this.showButtons || this.readonly) return null;\n\n return (\n <div class=\"form-button-area\" style={this.buttonAreaStyle}>\n {this.buttons.cancel && this.buttons.cancel.show && (\n <el-button\n onClick={this.handleCancel}\n type={this.buttons.cancel.type}\n {...this.buttons.cancel.props}\n >\n {this.buttons.cancel.text}\n </el-button>\n )}\n {this.buttons.submit && this.buttons.submit.show && (\n <el-button\n onClick={this.handleSubmit}\n type={this.buttons.submit.type}\n loading={this.submitLoading || (this.buttons.submit.loading)}\n {...this.buttons.submit.props}\n >\n {this.buttons.submit.text}\n </el-button>\n )}\n </div>\n );\n },\n\n // 处理提交\n async handleSubmit() {\n try {\n this.submitLoading = true;\n // 表单验证\n const formData = await this.validate();\n // 发出提交事件\n this.$emit('submit', formData);\n\n // return formData;\n } catch (error) {\n this.$emit('submit-error', error);\n return Promise.reject(error);\n }\n this.submitLoading = false;\n },\n\n // 处理取消\n handleCancel() {\n this.$emit('cancel');\n },\n\n // 表单验证方法\n validate() {\n return new Promise((resolve, reject) => {\n this.$refs.form.validate(valid => {\n if (valid) {\n resolve(this.form);\n } else {\n reject(new Error('表单验证失败'));\n }\n });\n });\n },\n\n // 重置表单\n resetForm() {\n this.form = JSON.parse(JSON.stringify(this.initialFormData)) || {};\n this.$refs.form.resetFields();\n this.$emit('form-reset', this.form);\n },\n\n // 获取表单数据\n getFormData() {\n return this.form;\n }\n },\n\n render() {\n\n if (this.readonly) {\n // 只读模式渲染\n return (\n <div class=\"dynamic-form-container readonly\">\n {this.hasTabs() ? (\n // 渲染标签页结构\n <el-tabs v-on={this.$listeners} v-model={this.activeName}>\n {this.items.map((item, index) => this.renderReadOnlyNode(item, index))}\n </el-tabs>\n ) : (\n // 非标签页结构,直接渲染\n this.renderReadOnlyChildren(this.items)\n )}\n </div>\n );\n }\n\n const formProps = {\n model: this.form,\n rules: this.formRules,\n ...this.$attrs\n };\n // 如果没有配置项,渲染空表单\n if (!this.items || !this.items.length) {\n return <div class=\"dynamic-form-container\"><el-form ref=\"form\" {...{ props: formProps }}></el-form></div>;\n }\n\n return (\n <div class=\"dynamic-form-container\">\n <el-form ref=\"form\" {...{ props: formProps }}>\n {this.hasTabs() ? (\n // 渲染标签页结构\n <el-tabs v-on={this.$listeners} v-model={this.activeName}>\n {this.items.map(this.renderNode)}\n </el-tabs>\n ) : (\n // 非标签页结构,直接渲染\n this.renderChildren(this.items)\n )}\n\n {/* 渲染按钮区域 */}\n {this.renderButtons()}\n </el-form>\n </div>\n );\n }\n}\n</script>\n\n<style scoped lang=\"scss\">\n.dynamic-form-container {\n padding: 20px;\n\n .el-form{\n \n\n .el-form-item {\n \n &::v-deep{\n .el-input,\n .el-select{\n width: 100%;\n }\n .el-input__inner {\n width: 100%;\n }\n }\n\n }\n\n \n\n }\n}\n\n.el-form-group {\n margin-bottom: 20px;\n /* padding: 15px; */\n border-bottom: 1px solid #ebeef5;\n}\n\n.el-form-group__title {\n font-weight: bold;\n margin-bottom: 15px;\n font-size: 14px;\n color: #606266;\n}\n\n.form-button-area {\n padding-top: 10px;\n border-top: 1px solid #ebeef5;\n}\n\n.form-button-area .el-button+.el-button {\n margin-left: 10px;\n}\n\n/* 只读模式样式 */\n.dynamic-form-container.readonly {\n .el-descriptions__body {\n background-color: #fafafa;\n }\n\n .el-descriptions-item__label {\n font-weight: bold;\n }\n\n .el-descriptions-item__content {\n word-break: break-all;\n }\n}\n</style>\n"]
3587
- },
3588
- media: undefined
3589
- });
3590
- };
3591
- /* scoped */
3592
- var __vue_scope_id__ = "data-v-ef86d32c";
3593
- /* module identifier */
3594
- var __vue_module_identifier__ = undefined;
3595
- /* functional template */
3596
- var __vue_is_functional_template__ = undefined;
3597
- /* style inject SSR */
3598
-
3599
- /* style inject shadow dom */
3600
-
3601
- var __vue_component__ = /*#__PURE__*/normalizeComponent({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, createInjector, undefined, undefined);
2792
+ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, createInjector, undefined, undefined);
3602
2793
 
3603
- ___$insertStylesToHeader(".el-crud .flex {\n display: flex;\n}\n.el-crud .inline-flex {\n display: inline-flex;\n}\n.el-crud .hidden {\n display: none;\n}\n.el-crud .block {\n display: block;\n}\n.el-crud .inline-block {\n display: inline-block;\n}\n.el-crud .flex-row {\n flex-direction: row;\n}\n.el-crud .flex-row-reverse {\n flex-direction: row-reverse;\n}\n.el-crud .flex-col {\n flex-direction: column;\n}\n.el-crud .flex-col-reverse {\n flex-direction: column-reverse;\n}\n.el-crud .flex-wrap {\n flex-wrap: wrap;\n}\n.el-crud .flex-nowrap {\n flex-wrap: nowrap;\n}\n.el-crud .flex-wrap-reverse {\n flex-wrap: wrap-reverse;\n}\n.el-crud .justify-start {\n justify-content: flex-start;\n}\n.el-crud .justify-end {\n justify-content: flex-end;\n}\n.el-crud .justify-center {\n justify-content: center;\n}\n.el-crud .justify-between {\n justify-content: space-between;\n}\n.el-crud .justify-around {\n justify-content: space-around;\n}\n.el-crud .justify-evenly {\n justify-content: space-evenly;\n}\n.el-crud .items-start {\n align-items: flex-start;\n}\n.el-crud .items-end {\n align-items: flex-end;\n}\n.el-crud .items-center {\n align-items: center;\n}\n.el-crud .items-baseline {\n align-items: baseline;\n}\n.el-crud .items-stretch {\n align-items: stretch;\n}\n.el-crud .content-start {\n align-content: flex-start;\n}\n.el-crud .content-end {\n align-content: flex-end;\n}\n.el-crud .content-center {\n align-content: center;\n}\n.el-crud .content-between {\n align-content: space-between;\n}\n.el-crud .content-around {\n align-content: space-around;\n}\n.el-crud .content-evenly {\n align-content: space-evenly;\n}\n.el-crud .self-auto {\n align-self: auto;\n}\n.el-crud .self-start {\n align-self: flex-start;\n}\n.el-crud .self-end {\n align-self: flex-end;\n}\n.el-crud .self-center {\n align-self: center;\n}\n.el-crud .self-stretch {\n align-self: stretch;\n}\n.el-crud .flex-1 {\n flex: 1 1 0%;\n}\n.el-crud .flex-auto {\n flex: 1 1 auto;\n}\n.el-crud .flex-initial {\n flex: 0 1 auto;\n}\n.el-crud .flex-none {\n flex: none;\n}\n.el-crud .grow {\n flex-grow: 1;\n}\n.el-crud .grow-0 {\n flex-grow: 0;\n}\n.el-crud .shrink {\n flex-shrink: 1;\n}\n.el-crud .shrink-0 {\n flex-shrink: 0;\n}\n.el-crud .w-full {\n width: 100%;\n}\n.el-crud .w-auto {\n width: auto;\n}\n.el-crud .h-full {\n height: 100%;\n}\n.el-crud .h-auto {\n height: auto;\n}\n.el-crud .h-screen {\n height: 100vh;\n}\n.el-crud .m-0 {\n margin: 0;\n}\n.el-crud .m-auto {\n margin: auto;\n}\n.el-crud .mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n.el-crud .my-auto {\n margin-top: auto;\n margin-bottom: auto;\n}\n.el-crud .text-left {\n text-align: left;\n}\n.el-crud .text-center {\n text-align: center;\n}\n.el-crud .text-right {\n text-align: right;\n}\n.el-crud .text-justify {\n text-align: justify;\n}\n.el-crud .font-normal {\n font-weight: 400;\n}\n.el-crud .font-medium {\n font-weight: 500;\n}\n.el-crud .font-semibold {\n font-weight: 600;\n}\n.el-crud .font-bold {\n font-weight: 700;\n}\n.el-crud .overflow-hidden {\n overflow: hidden;\n}\n.el-crud .overflow-auto {\n overflow: auto;\n}\n.el-crud .overflow-scroll {\n overflow: scroll;\n}\n.el-crud .overflow-x-auto {\n overflow-x: auto;\n}\n.el-crud .overflow-y-auto {\n overflow-y: auto;\n}\n.el-crud .relative {\n position: relative;\n}\n.el-crud .absolute {\n position: absolute;\n}\n.el-crud .fixed {\n position: fixed;\n}\n.el-crud .sticky {\n position: sticky;\n}\n.el-crud .cursor-pointer {\n cursor: pointer;\n}\n.el-crud .cursor-not-allowed {\n cursor: not-allowed;\n}\n.el-crud-toolbar {\n margin-top: 10px;\n}\n.el-crud .crud-table {\n margin-top: 10px;\n}\n\n/*# sourceMappingURL=output.css.map */");
2794
+ ___$insertStylesToHeader(".el-crud .flex {\n display: flex;\n}\n.el-crud .inline-flex {\n display: inline-flex;\n}\n.el-crud .hidden {\n display: none;\n}\n.el-crud .block {\n display: block;\n}\n.el-crud .inline-block {\n display: inline-block;\n}\n.el-crud .flex-row {\n flex-direction: row;\n}\n.el-crud .flex-row-reverse {\n flex-direction: row-reverse;\n}\n.el-crud .flex-col {\n flex-direction: column;\n}\n.el-crud .flex-col-reverse {\n flex-direction: column-reverse;\n}\n.el-crud .flex-wrap {\n flex-wrap: wrap;\n}\n.el-crud .flex-nowrap {\n flex-wrap: nowrap;\n}\n.el-crud .flex-wrap-reverse {\n flex-wrap: wrap-reverse;\n}\n.el-crud .justify-start {\n justify-content: flex-start;\n}\n.el-crud .justify-end {\n justify-content: flex-end;\n}\n.el-crud .justify-center {\n justify-content: center;\n}\n.el-crud .justify-between {\n justify-content: space-between;\n}\n.el-crud .justify-around {\n justify-content: space-around;\n}\n.el-crud .justify-evenly {\n justify-content: space-evenly;\n}\n.el-crud .items-start {\n align-items: flex-start;\n}\n.el-crud .items-end {\n align-items: flex-end;\n}\n.el-crud .items-center {\n align-items: center;\n}\n.el-crud .items-baseline {\n align-items: baseline;\n}\n.el-crud .items-stretch {\n align-items: stretch;\n}\n.el-crud .content-start {\n align-content: flex-start;\n}\n.el-crud .content-end {\n align-content: flex-end;\n}\n.el-crud .content-center {\n align-content: center;\n}\n.el-crud .content-between {\n align-content: space-between;\n}\n.el-crud .content-around {\n align-content: space-around;\n}\n.el-crud .content-evenly {\n align-content: space-evenly;\n}\n.el-crud .self-auto {\n align-self: auto;\n}\n.el-crud .self-start {\n align-self: flex-start;\n}\n.el-crud .self-end {\n align-self: flex-end;\n}\n.el-crud .self-center {\n align-self: center;\n}\n.el-crud .self-stretch {\n align-self: stretch;\n}\n.el-crud .flex-1 {\n flex: 1 1 0%;\n}\n.el-crud .flex-auto {\n flex: 1 1 auto;\n}\n.el-crud .flex-initial {\n flex: 0 1 auto;\n}\n.el-crud .flex-none {\n flex: none;\n}\n.el-crud .grow {\n flex-grow: 1;\n}\n.el-crud .grow-0 {\n flex-grow: 0;\n}\n.el-crud .shrink {\n flex-shrink: 1;\n}\n.el-crud .shrink-0 {\n flex-shrink: 0;\n}\n.el-crud .w-full {\n width: 100%;\n}\n.el-crud .w-auto {\n width: auto;\n}\n.el-crud .h-full {\n height: 100%;\n}\n.el-crud .h-auto {\n height: auto;\n}\n.el-crud .h-screen {\n height: 100vh;\n}\n.el-crud .m-0 {\n margin: 0;\n}\n.el-crud .m-auto {\n margin: auto;\n}\n.el-crud .mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n.el-crud .my-auto {\n margin-top: auto;\n margin-bottom: auto;\n}\n.el-crud .text-left {\n text-align: left;\n}\n.el-crud .text-center {\n text-align: center;\n}\n.el-crud .text-right {\n text-align: right;\n}\n.el-crud .text-justify {\n text-align: justify;\n}\n.el-crud .font-normal {\n font-weight: 400;\n}\n.el-crud .font-medium {\n font-weight: 500;\n}\n.el-crud .font-semibold {\n font-weight: 600;\n}\n.el-crud .font-bold {\n font-weight: 700;\n}\n.el-crud .overflow-hidden {\n overflow: hidden;\n}\n.el-crud .overflow-auto {\n overflow: auto;\n}\n.el-crud .overflow-scroll {\n overflow: scroll;\n}\n.el-crud .overflow-x-auto {\n overflow-x: auto;\n}\n.el-crud .overflow-y-auto {\n overflow-y: auto;\n}\n.el-crud .relative {\n position: relative;\n}\n.el-crud .absolute {\n position: absolute;\n}\n.el-crud .fixed {\n position: fixed;\n}\n.el-crud .sticky {\n position: sticky;\n}\n.el-crud .cursor-pointer {\n cursor: pointer;\n}\n.el-crud .cursor-not-allowed {\n cursor: not-allowed;\n}\n.el-crud .crud-table {\n margin-top: 10px;\n}\n\n/*# sourceMappingURL=output.css.map */");
3604
2795
 
3605
- export { __vue_component__$1 as Crud, __vue_component__ as CrudForm, __vue_component__$5 as CrudTable, __vue_component__$3 as QueryForm };
2796
+ export { __vue_component__ as Crud, __vue_component__$4 as CrudTable, __vue_component__$2 as QueryForm };
3606
2797
  //# sourceMappingURL=index.esm.js.map