vue-super-crud 1.7.1 → 1.7.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 (269) hide show
  1. package/README.md +42 -10
  2. package/lib/index.css +1 -1
  3. package/lib/super-crud.min.js +2 -2
  4. package/package.json +21 -16
  5. package/.browserslistrc +0 -3
  6. package/.versionrc.json +0 -36
  7. package/CHANGELOG.md +0 -232
  8. package/babel.config.js +0 -12
  9. package/build/alias.js +0 -10
  10. package/build/build.js +0 -52
  11. package/build/config.js +0 -70
  12. package/deploy.bat +0 -14
  13. package/docs/.vuepress/components/button/base.vue +0 -88
  14. package/docs/.vuepress/components/common/code-format.vue +0 -331
  15. package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +0 -68
  16. package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +0 -73
  17. package/docs/.vuepress/components/commonConfig/renderType/component.vue +0 -160
  18. package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +0 -49
  19. package/docs/.vuepress/components/commonConfig/renderType/render.vue +0 -91
  20. package/docs/.vuepress/components/commonConfig/renderType/slot.vue +0 -63
  21. package/docs/.vuepress/components/crud/baseUse/baseUse.vue +0 -98
  22. package/docs/.vuepress/components/crud/baseUse/columnAction.vue +0 -72
  23. package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +0 -107
  24. package/docs/.vuepress/components/crud/baseUse/handleRow.vue +0 -65
  25. package/docs/.vuepress/components/crud/baseUse/height.vue +0 -82
  26. package/docs/.vuepress/components/crud/baseUse/index.vue +0 -54
  27. package/docs/.vuepress/components/crud/baseUse/loading.vue +0 -70
  28. package/docs/.vuepress/components/crud/baseUse/pagination.vue +0 -108
  29. package/docs/.vuepress/components/crud/baseUse/selection.vue +0 -114
  30. package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +0 -118
  31. package/docs/.vuepress/components/crud/baseUse/title.vue +0 -54
  32. package/docs/.vuepress/components/crud/baseUse/toolbar.vue +0 -69
  33. package/docs/.vuepress/components/crud/buttons/common.vue +0 -115
  34. package/docs/.vuepress/components/crud/buttons/fast.vue +0 -82
  35. package/docs/.vuepress/components/crud/contextMenu/base.vue +0 -72
  36. package/docs/.vuepress/components/crud/copy.vue +0 -52
  37. package/docs/.vuepress/components/crud/crudEvents/api.vue +0 -157
  38. package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +0 -93
  39. package/docs/.vuepress/components/crud/crudEvents/events.vue +0 -188
  40. package/docs/.vuepress/components/crud/dataSort/base.vue +0 -142
  41. package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +0 -53
  42. package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +0 -111
  43. package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +0 -68
  44. package/docs/.vuepress/components/crud/handleBar/handleRow.vue +0 -65
  45. package/docs/.vuepress/components/crud/handleBar/toolbar.vue +0 -69
  46. package/docs/.vuepress/components/crud/renderType/1.vue +0 -57
  47. package/docs/.vuepress/components/crud/renderType/2.vue +0 -63
  48. package/docs/.vuepress/components/crud/renderType/3.vue +0 -105
  49. package/docs/.vuepress/components/crud/renderType/5.vue +0 -91
  50. package/docs/.vuepress/components/crud/search/1.vue +0 -90
  51. package/docs/.vuepress/components/crud/search/2.vue +0 -78
  52. package/docs/.vuepress/components/crud/search/3.vue +0 -107
  53. package/docs/.vuepress/components/crud/search/base.vue +0 -123
  54. package/docs/.vuepress/components/crud/search/localSearch.vue +0 -124
  55. package/docs/.vuepress/components/crud/search/special.vue +0 -148
  56. package/docs/.vuepress/components/crud/selection/events.vue +0 -47
  57. package/docs/.vuepress/components/crud/selection/pagination.vue +0 -94
  58. package/docs/.vuepress/components/crud/selection/singleSelection.vue +0 -64
  59. package/docs/.vuepress/components/crud/span/base.vue +0 -69
  60. package/docs/.vuepress/components/crud/span/special.vue +0 -75
  61. package/docs/.vuepress/components/crud/summary/base.vue +0 -99
  62. package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +0 -174
  63. package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +0 -194
  64. package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +0 -219
  65. package/docs/.vuepress/components/crud/tableEdit/dialog.vue +0 -172
  66. package/docs/.vuepress/components/crud/tableEdit/free.vue +0 -88
  67. package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +0 -82
  68. package/docs/.vuepress/components/crud/tableEdit/methods.vue +0 -154
  69. package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +0 -107
  70. package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +0 -116
  71. package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +0 -98
  72. package/docs/.vuepress/components/crud/validate/base.vue +0 -122
  73. package/docs/.vuepress/components/crud/validate/custom.vue +0 -82
  74. package/docs/.vuepress/components/crud/validate/regulars.vue +0 -88
  75. package/docs/.vuepress/components/crud/validate/relation.vue +0 -91
  76. package/docs/.vuepress/components/crud/validate/tree.vue +0 -82
  77. package/docs/.vuepress/components/dialog/baseUse/base.vue +0 -92
  78. package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +0 -78
  79. package/docs/.vuepress/components/dialog/baseUse/control.vue +0 -79
  80. package/docs/.vuepress/components/dialog/baseUse/drawer.vue +0 -59
  81. package/docs/.vuepress/components/dialog/baseUse/footer.vue +0 -87
  82. package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +0 -79
  83. package/docs/.vuepress/components/dict/DictLinkage.vue +0 -91
  84. package/docs/.vuepress/components/dict/baseUse.vue +0 -72
  85. package/docs/.vuepress/components/dict/component.vue +0 -82
  86. package/docs/.vuepress/components/dict/localDict.vue +0 -68
  87. package/docs/.vuepress/components/form/baseUse/base.vue +0 -48
  88. package/docs/.vuepress/components/form/baseUse/dataFormat.vue +0 -92
  89. package/docs/.vuepress/components/form/baseUse/deep.vue +0 -57
  90. package/docs/.vuepress/components/form/baseUse/gridLayout.vue +0 -47
  91. package/docs/.vuepress/components/form/baseUse/group.vue +0 -66
  92. package/docs/.vuepress/components/form/baseUse/hidden.vue +0 -40
  93. package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +0 -48
  94. package/docs/.vuepress/components/form/baseUse/label.vue +0 -51
  95. package/docs/.vuepress/components/form/baseUse/tooltip.vue +0 -40
  96. package/docs/.vuepress/components/form/baseUse/validate.vue +0 -52
  97. package/docs/.vuepress/components/form/detail/base.vue +0 -78
  98. package/docs/.vuepress/components/form/detail/border.vue +0 -90
  99. package/docs/.vuepress/components/form/detail/singleDetail.vue +0 -72
  100. package/docs/.vuepress/components/formatData/baseUse.vue +0 -131
  101. package/docs/.vuepress/components/mock/index.js +0 -347
  102. package/docs/.vuepress/components/mockData/custom.vue +0 -69
  103. package/docs/.vuepress/components/mockData/example.vue +0 -290
  104. package/docs/.vuepress/components/positionSlot/base.vue +0 -24
  105. package/docs/.vuepress/components/positionSlot/form.vue +0 -71
  106. package/docs/.vuepress/components/positionSlot/table.vue +0 -85
  107. package/docs/.vuepress/components/tabs/base.vue +0 -57
  108. package/docs/.vuepress/components/temp.js +0 -195
  109. package/docs/.vuepress/config.js +0 -146
  110. package/docs/.vuepress/enhanceApp.js +0 -142
  111. package/docs/.vuepress/public/favicon.ico +0 -0
  112. package/docs/.vuepress/public/super.png +0 -0
  113. package/docs/.vuepress/styles/index.styl +0 -25
  114. package/docs/.vuepress/styles/palette.styl +0 -6
  115. package/docs/README.md +0 -14
  116. package/docs/guide/button/base.md +0 -31
  117. package/docs/guide/commonConfig/jsx.md +0 -166
  118. package/docs/guide/commonConfig/presetCodeTemplate.md +0 -68
  119. package/docs/guide/commonConfig/renderType.md +0 -181
  120. package/docs/guide/crud/baseUse.md +0 -120
  121. package/docs/guide/crud/buttons.md +0 -18
  122. package/docs/guide/crud/config.md +0 -217
  123. package/docs/guide/crud/contextMenu.md +0 -18
  124. package/docs/guide/crud/dataSort.md +0 -66
  125. package/docs/guide/crud/genDynamicColumns.md +0 -145
  126. package/docs/guide/crud/handleBar.md +0 -26
  127. package/docs/guide/crud/renderType.md +0 -4
  128. package/docs/guide/crud/search.md +0 -150
  129. package/docs/guide/crud/selection.md +0 -73
  130. package/docs/guide/crud/span.md +0 -98
  131. package/docs/guide/crud/summary.md +0 -167
  132. package/docs/guide/crud/tableEdit.md +0 -377
  133. package/docs/guide/crud/validate.md +0 -158
  134. package/docs/guide/dialog/baseUse.md +0 -81
  135. package/docs/guide/dict/baseUse.md +0 -174
  136. package/docs/guide/dict/component.md +0 -88
  137. package/docs/guide/dict/config.md +0 -44
  138. package/docs/guide/form/baseUse.md +0 -142
  139. package/docs/guide/form/detail.md +0 -38
  140. package/docs/guide/formatData/baseUse.md +0 -98
  141. package/docs/guide/formatData/config.md +0 -142
  142. package/docs/guide/mockData/base.md +0 -26
  143. package/docs/guide/positionSlot/base.md +0 -41
  144. package/docs/guide/question/base.md +0 -44
  145. package/docs/guide/start/base.md +0 -30
  146. package/docs/guide/tabs/base.md +0 -63
  147. package/examples/App.vue +0 -52
  148. package/examples/Layout/components/AppMain.vue +0 -40
  149. package/examples/Layout/components/Item.vue +0 -29
  150. package/examples/Layout/components/Link.vue +0 -44
  151. package/examples/Layout/components/SidebarItem.vue +0 -93
  152. package/examples/Layout/index.vue +0 -69
  153. package/examples/assets/logo.png +0 -0
  154. package/examples/favicon.ico +0 -0
  155. package/examples/index.html +0 -18
  156. package/examples/main.js +0 -54
  157. package/examples/router/index.js +0 -140
  158. package/examples/store/index.js +0 -0
  159. package/examples/styles/index.scss +0 -63
  160. package/examples/styles/sidebar.scss +0 -226
  161. package/examples/styles/transition.scss +0 -48
  162. package/examples/styles/variables.scss +0 -25
  163. package/examples/views/crud/base.vue +0 -68
  164. package/examples/views/crud/handleRow.vue +0 -84
  165. package/examples/views/crud/search.vue +0 -116
  166. package/examples/views/dashboard/index.vue +0 -244
  167. package/examples/views/dashboard/index1.vue +0 -234
  168. package/examples/views/dashboard/test.vue +0 -9
  169. package/examples/views/formTest/index.vue +0 -168
  170. package/examples/views/nested/menu1/index.vue +0 -7
  171. package/examples/views/nested/menu1/menu1-1/index.vue +0 -7
  172. package/examples/views/nested/menu1/menu1-2/index.vue +0 -7
  173. package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +0 -5
  174. package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +0 -5
  175. package/examples/views/nested/menu1/menu1-3/index.vue +0 -5
  176. package/examples/views/nested/menu2/index.vue +0 -5
  177. package/gulpfile.js +0 -84
  178. package/packages/button/index.vue +0 -189
  179. package/packages/core/components/comp.vue +0 -223
  180. package/packages/core/components/position.vue +0 -135
  181. package/packages/core/components/render.vue +0 -460
  182. package/packages/core/configManager.js +0 -302
  183. package/packages/core/create.js +0 -8
  184. package/packages/core/defaultRender.js +0 -64
  185. package/packages/core/dict/global.js +0 -10
  186. package/packages/core/dict/index.js +0 -432
  187. package/packages/core/dict/mixin.js +0 -94
  188. package/packages/core/event.js +0 -60
  189. package/packages/core/index.js +0 -6
  190. package/packages/core/init.js +0 -122
  191. package/packages/core/mock/genConfig.js +0 -228
  192. package/packages/core/mock/genData.js +0 -422
  193. package/packages/core/mock/index.js +0 -4
  194. package/packages/core/rules.js +0 -111
  195. package/packages/crud/column.vue +0 -205
  196. package/packages/crud/columnAction.vue +0 -207
  197. package/packages/crud/columnCell.vue +0 -146
  198. package/packages/crud/defaultColumn.vue +0 -130
  199. package/packages/crud/drawerColumn.vue +0 -225
  200. package/packages/crud/form.vue +0 -69
  201. package/packages/crud/index.vue +0 -564
  202. package/packages/crud/menuBar.vue +0 -298
  203. package/packages/crud/mixins/cacheHandler.js +0 -36
  204. package/packages/crud/mixins/calcColumnWidth.js +0 -79
  205. package/packages/crud/mixins/calcHeight.js +0 -105
  206. package/packages/crud/mixins/columnHandler.js +0 -128
  207. package/packages/crud/mixins/contextMenu.js +0 -98
  208. package/packages/crud/mixins/dataProcessor.js +0 -202
  209. package/packages/crud/mixins/dialog.js +0 -109
  210. package/packages/crud/mixins/excelHandler.js +0 -150
  211. package/packages/crud/mixins/exposeMethods.js +0 -107
  212. package/packages/crud/mixins/generateDynamicColumns.js +0 -250
  213. package/packages/crud/mixins/props.js +0 -38
  214. package/packages/crud/mixins/searchHandler.js +0 -151
  215. package/packages/crud/mixins/select.js +0 -359
  216. package/packages/crud/mixins/spanMethod.js +0 -288
  217. package/packages/crud/mixins/summary.js +0 -177
  218. package/packages/crud/mixins/tableEdit.js +0 -547
  219. package/packages/crud/mixins/validate.js +0 -219
  220. package/packages/crud/pagination.vue +0 -110
  221. package/packages/crud/search.vue +0 -119
  222. package/packages/crud/searchHeader.vue +0 -231
  223. package/packages/crud/selectBanner.vue +0 -138
  224. package/packages/crud/utils/EditState.js +0 -319
  225. package/packages/crud/utils/excelExport.js +0 -112
  226. package/packages/crud/utils/excelImport.js +0 -112
  227. package/packages/crud/utils/index.js +0 -98
  228. package/packages/dialog/dialog.js +0 -233
  229. package/packages/dialog/dialog.vue +0 -15
  230. package/packages/dialog/index.js +0 -22
  231. package/packages/dict/cascadeFormat.vue +0 -179
  232. package/packages/dict/dateFormat.vue +0 -40
  233. package/packages/dict/form/cascade.vue +0 -61
  234. package/packages/dict/form/checkbox.vue +0 -90
  235. package/packages/dict/form/extendMethod.js +0 -22
  236. package/packages/dict/form/input-base.js +0 -31
  237. package/packages/dict/form/input.js +0 -20
  238. package/packages/dict/form/radio.vue +0 -69
  239. package/packages/dict/form/select.vue +0 -118
  240. package/packages/dict/form/switch.vue +0 -75
  241. package/packages/dict/valueFormat.vue +0 -188
  242. package/packages/directive/dialog/drag.js +0 -86
  243. package/packages/directive/dialog/dragSize.js +0 -42
  244. package/packages/directive/index.js +0 -9
  245. package/packages/directive/insertSlot.js +0 -10
  246. package/packages/form/contextMenu.js +0 -192
  247. package/packages/form/draftDrawer.vue +0 -391
  248. package/packages/form/formAction.vue +0 -97
  249. package/packages/form/formItem.vue +0 -259
  250. package/packages/form/index.vue +0 -451
  251. package/packages/form/props.js +0 -15
  252. package/packages/grid/cell.vue +0 -65
  253. package/packages/grid/index.vue +0 -130
  254. package/packages/group/index.vue +0 -96
  255. package/packages/tabs/index.vue +0 -290
  256. package/packages/tooltip/index.js +0 -9
  257. package/packages/tooltip/tooltip.vue +0 -32
  258. package/packages/tooltip/tooltipComponent.js +0 -38
  259. package/packages/verifyInput/index.vue +0 -131
  260. package/styles/button.scss +0 -3
  261. package/styles/crud.scss +0 -425
  262. package/styles/dialog.scss +0 -95
  263. package/styles/form.scss +0 -532
  264. package/styles/group.scss +0 -78
  265. package/styles/index.scss +0 -94
  266. package/styles/tabs.scss +0 -139
  267. package/styles/verifyInput.scss +0 -56
  268. package/vue-jsx-sync.js +0 -90
  269. package/vue.config.js +0 -54
@@ -1,111 +0,0 @@
1
- import { batchMerge, mergeTemp } from "utils/mergeTemp";
2
- import { executeFunctionByObject } from "utils";
3
-
4
- export function generateRules(item, scope) {
5
- // 获取经过scope处理后的配置
6
- const config = executeFunctionByObject(
7
- {
8
- required: item.required,
9
- regular: item.regular,
10
- limit: item.limit,
11
- rules: item.rules,
12
- },
13
- scope
14
- );
15
-
16
- const rules = [];
17
- const rawRules = [];
18
-
19
- // 处理必填规则
20
- if (config.required) {
21
- const requiredRule = generateRequiredRule(config.required, item);
22
- rules.push(requiredRule);
23
- rules.required = true;
24
- }
25
-
26
- // 处理长度限制规则
27
- if (config.limit) {
28
- rules.push(generateLimitRule(config.limit));
29
- }
30
-
31
- // 处理正则校验规则
32
- if (config.regular) {
33
- const regularRules = generateRegularRules(
34
- config.regular,
35
- item,
36
- scope,
37
- rawRules
38
- );
39
- rules.push(...regularRules);
40
- }
41
-
42
- // 处理自定义规则
43
- if (config.rules) {
44
- const customRules = generateCustomRules(
45
- config.rules,
46
- item,
47
- scope,
48
- rawRules
49
- );
50
- rules.push(...customRules);
51
- }
52
-
53
- return {
54
- rules,
55
- rawRules,
56
- };
57
- }
58
- function generateRequiredRule(required, item) {
59
- return mergeTemp("rules", "required", required, { item });
60
- }
61
-
62
- function generateLimitRule([min, max]) {
63
- return {
64
- min,
65
- max,
66
- message:
67
- min === max ? `请输入 ${min} 个字符` : `请输入 ${min} 到 ${max} 个字符`,
68
- trigger: "change",
69
- };
70
- }
71
-
72
- function generateRegularRules(regular, item, scope, rawRules) {
73
- const rules = batchMerge("rules", regular, { item });
74
- rawRules.push(...rules);
75
- return handleRegularRule(rules, scope);
76
- }
77
-
78
- function generateCustomRules(rules, item, scope, rawRules) {
79
- const customRules = batchMerge("rules", rules, { item });
80
- rawRules.push(...customRules);
81
- return handleRegularRule(customRules, scope);
82
- }
83
-
84
- function handleRegularRule(rules, scope) {
85
- return rules.map((item) => {
86
- if (item.regular && item.msg) {
87
- return {
88
- validator: (rule, value, callback) => {
89
- if (!value || item.regular.test(value)) {
90
- callback();
91
- } else {
92
- callback(new Error(item.msg));
93
- }
94
- },
95
- trigger: item.trigger || "change",
96
- message: item.msg,
97
- };
98
- } else {
99
- if (item.validator) {
100
- const validator = item.validator;
101
- return {
102
- ...item,
103
- validator: (...args) => {
104
- validator(...args.slice(0, 3), scope);
105
- },
106
- };
107
- }
108
- return item;
109
- }
110
- });
111
- }
@@ -1,205 +0,0 @@
1
- <script>
2
- import create from "core/create";
3
- import calcColumnWidth from "./mixins/calcColumnWidth";
4
- import columnCell from "./columnCell.vue";
5
- import column from "./column.vue";
6
- import searchHeader from "./searchHeader.vue";
7
- import position from "core/components/position";
8
- import { set, merge, isFunction } from "lodash-es";
9
- import { checkVisibility } from "utils";
10
- // 调试时element-ui导入地址需要改成引入项目下的node_modules地址
11
- import { TableColumn } from "element-ui";
12
- // import { TableColumn } from "C:/Users/Administrator/Desktop/jhfCloud2/ruoyi-ui/lib";
13
-
14
- TableColumn.destroyed = function () {
15
- if (!this.$parent) return;
16
- let parent = this.$parent;
17
- if (parent.$options.name === "sc-crud-column") {
18
- // 解决children动态变化时el-table的columns被错误删除的问题,因为给el-table-column多套了一层,导致饿了么内部parent取错,所以这里需要再往上取一层
19
- parent = parent.$parent;
20
- }
21
- this.owner.store.commit(
22
- "removeColumn",
23
- this.columnConfig,
24
- this.isSubColumn ? parent.columnConfig : null
25
- );
26
- };
27
-
28
- export default create({
29
- name: "crud-column",
30
- props: {
31
- col: Object,
32
- },
33
- inject: ["ctx"],
34
- mixins: [calcColumnWidth],
35
- data() {
36
- return {
37
- isSearch: false,
38
- };
39
- },
40
- components: { TableColumn, columnCell, column, searchHeader, position },
41
- watch: {
42
- col() {
43
- this.bindColumnConfig();
44
- },
45
- },
46
- computed: {
47
- defaultMinWidth() {
48
- // 计算头部默认宽度
49
- const labelSpan = document.createElement("span");
50
- labelSpan.innerText = this.col.label;
51
- document.body.appendChild(labelSpan);
52
- let labelMinWidth = labelSpan.getBoundingClientRect().width + 20;
53
- this.col.search && (labelMinWidth += 20);
54
- this.col.sortable && (labelMinWidth += 25);
55
- document.body.removeChild(labelSpan);
56
- labelMinWidth = Math.round(labelMinWidth);
57
- return Math.max(labelMinWidth, 80);
58
- },
59
- showOverflowTooltip() {
60
- const col = this.col;
61
- if (col.showOverflowTooltip !== undefined) return col.showOverflowTooltip;
62
- return this.ctx.isDefaultColumn(col);
63
- },
64
- calcOpts() {
65
- return { ...this.ctx.crudOptions.calcColumnWidth, ...this.col };
66
- },
67
- colWidth() {
68
- return this.getColumnWidth(
69
- this.col.width,
70
- this.col.prop,
71
- this.ctx.data,
72
- this.calcOpts.widthType,
73
- this.calcOpts.widthFont,
74
- this.calcOpts.calcWidth
75
- );
76
- },
77
- colMinWidth() {
78
- if (!this.col.width) {
79
- return this.defaultMinWidth;
80
- }
81
- return this.getColumnWidth(
82
- this.col.minWidth,
83
- this.col.prop,
84
- this.ctx.data,
85
- this.calcOpts.widthType,
86
- this.calcOpts.widthFont,
87
- this.calcOpts.calcWidth
88
- );
89
- },
90
- isShow() {
91
- // hiddenList 只隐藏列表
92
- if (this.col.hiddenList) return false;
93
- return !this.hidden;
94
- },
95
- hidden() {
96
- if (this.ctx.setOptions.hidden.includes(this.col.prop)) return true;
97
- },
98
- fixed() {
99
- if (this.col.fixed) return this.col.fixed;
100
- const fixed = this.ctx.setOptions.fixed[this.col.prop];
101
- if (fixed) return fixed;
102
- },
103
- showSearchHeader() {
104
- if (this.col.search?.hidden) return false;
105
- if (this.col.searchHeader?.hidden) return false;
106
- const show = checkVisibility(this.ctx.crudOptions.searchHeader);
107
- return (this.col.search && show) || (this.col.searchHeader && show);
108
- },
109
- },
110
- methods: {
111
- bindColumnConfig() {
112
- const columnConfig = this.$refs.column?.columnConfig;
113
- if (columnConfig) {
114
- columnConfig.col = { ...this.col };
115
- columnConfig.options = { ...this.ctx.crudOptions };
116
- }
117
- },
118
- getTopProps() {
119
- return {
120
- size: this.ctx.crudOptions.size,
121
- isTree: this.ctx.isTree,
122
- valueKey: this.ctx.valueKey,
123
- extendsScopedSlots: this.ctx.extendsScopedSlots,
124
- defaultRender: this.ctx.crudOptions.defaultRender,
125
- };
126
- },
127
- },
128
- render(h) {
129
- const {
130
- col,
131
- ctx,
132
- showSearchHeader,
133
- showOverflowTooltip,
134
- isShow,
135
- fixed,
136
- } = this;
137
- const isDefaultColumn = this.ctx.isDefaultColumn(col);
138
- if (!isShow) return null;
139
- const topProps = this.getTopProps();
140
- const cellRender = (scope) => {
141
- return (
142
- <columnCell col={col} scope={scope} ctx={ctx} topProps={topProps} />
143
- );
144
- };
145
- const columnHeader = () => {
146
- return (
147
- <div
148
- class={this.b(["header"])}
149
- style={{ color: this.isSearch ? "var(--color-primary)" : "" }}
150
- >
151
- <position
152
- slotName={`${col.prop}-header`}
153
- render={col.labelRender || col.headerRender}
154
- slots={ctx.$scopedSlots}
155
- >
156
- <span
157
- style="white-space: nowrap;" // 解决动态列因为换行导致el-table中updateElsHeight重新计算有误
158
- domProps={{
159
- innerHTML: col.label,
160
- }}
161
- ></span>
162
- </position>
163
- {showSearchHeader && (
164
- <searchHeader
165
- on={{
166
- "update:isSearch": (val) => {
167
- this.isSearch = val;
168
- },
169
- }}
170
- item={col.searchHeader}
171
- />
172
- )}
173
- </div>
174
- );
175
- };
176
- return (
177
- <TableColumn
178
- ref="column"
179
- props={col}
180
- prop={col.prop}
181
- fixed={fixed}
182
- header-align={col.headerAlign || col.align || "center"}
183
- align={col.align || "center"}
184
- width={col.width}
185
- min-width={col.minWidth}
186
- show-overflow-tooltip={showOverflowTooltip}
187
- scopedSlots={{
188
- default: !isDefaultColumn ? (scope) => cellRender(scope) : null,
189
- header: columnHeader,
190
- }}
191
- on={{
192
- "hook:mounted": () => {
193
- this.bindColumnConfig();
194
- },
195
- }}
196
- >
197
- {col.children &&
198
- col.children.map((sub) => {
199
- return <column key={sub.label + sub.prop} col={sub}></column>;
200
- })}
201
- </TableColumn>
202
- );
203
- },
204
- });
205
- </script>
@@ -1,207 +0,0 @@
1
- <template>
2
- <!-- 操作栏 -->
3
- <el-table-column
4
- ref="column"
5
- v-if="showAction"
6
- v-bind="action"
7
- :width="width"
8
- :fixed="fixed"
9
- @hook:mounted="bindColumnConfig"
10
- >
11
- <template v-slot="scope">
12
- <div :class="b()" ref="actionRef">
13
- <button_
14
- v-for="(btn, index) in handleActionButtons(scope, actionButtons)"
15
- :type="btn.type || 'text'"
16
- :size="ctx.crudOptions.size"
17
- :scope="scope"
18
- v-bind="btn"
19
- :key="index"
20
- />
21
- </div>
22
- </template>
23
- </el-table-column>
24
- </template>
25
-
26
- <script>
27
- import create from "core/create";
28
- import { batchMerge } from "utils/mergeTemp";
29
- import { checkVisibility } from "utils";
30
- import button_ from "pak/button";
31
- import { cloneDeep, debounce } from "lodash-es";
32
-
33
- export default create({
34
- name: "crud-action-column",
35
- components: {
36
- button_,
37
- },
38
- inject: ["ctx"],
39
- data() {
40
- return {
41
- buttonList: [],
42
- actionWidth: "",
43
- };
44
- },
45
- created() {
46
- const calcAutoWidth = this.calcAutoWidth;
47
- this.calcAutoWidth = debounce(calcAutoWidth, 0);
48
- },
49
- watch: {
50
- action() {
51
- this.bindColumnConfig();
52
- },
53
- },
54
- computed: {
55
- width() {
56
- if (this.action.width === "auto")
57
- return Math.max(this.actionWidth, this.action.defaultWidth);
58
- if (this.action.width) return this.action.width;
59
- return this.action.defaultWidth;
60
- },
61
- fixed() {
62
- if (this.action.fixed) return this.action.fixed;
63
- return this.ctx.setOptions.fixed[this.action.prop];
64
- },
65
- action() {
66
- const editConfig = this.ctx.editConfig;
67
- return {
68
- type: "action",
69
- delete: editConfig.delete,
70
- view: editConfig.view,
71
- edit: editConfig.edit,
72
- rowEdit: editConfig.rowEdit,
73
- rowSave: editConfig.rowEdit,
74
- rowCancel: editConfig.rowEdit,
75
- ...cloneDeep(this.ctx.crudOptions.action),
76
- };
77
- },
78
- showAction() {
79
- if (this.ctx.setOptions.hidden.includes(this.action.prop)) return false;
80
- return checkVisibility(this.action, null, this.actionButtons.length > 0);
81
- },
82
- actionButtons() {
83
- let buttons = [];
84
- const merges = batchMerge(
85
- "btn.crud.action",
86
- this.action,
87
- {
88
- ctx: this.ctx,
89
- },
90
- this.actionTemps
91
- );
92
- buttons.push(...merges);
93
- return buttons;
94
- },
95
- actionTemps() {
96
- return {
97
- rowEdit: (item, { ctx }) => ({
98
- icon: "el-icon-edit",
99
- label: "编辑",
100
- order: 9,
101
- disabled: (scope) => {
102
- return this.ctx.disabledRowEdit({
103
- row: scope.row,
104
- $index: scope.$index,
105
- });
106
- },
107
- innerHide: (scope) => this.isRowEditing(scope),
108
- onClick: (scope) => {
109
- this.ctx.handleRowEdit(scope);
110
- },
111
- }),
112
- rowSave: (item, { ctx }) => ({
113
- icon: "el-icon-circle-check",
114
- label: "保存",
115
- order: 10,
116
- innerHide: (scope) => !this.isRowEditing(scope),
117
- onClick: (scope) => {
118
- this.ctx.handleRowSave(scope);
119
- },
120
- }),
121
- rowCancel: (item, { ctx }) => ({
122
- icon: "el-icon-circle-close",
123
- label: "取消",
124
- order: 11,
125
- innerHide: (scope) => !this.isRowEditing(scope),
126
- onClick: (scope) => {
127
- this.ctx.handleRowCancel(scope);
128
- },
129
- }),
130
- view: (item, { ctx }) => ({
131
- icon: "el-icon-view",
132
- label: "查看",
133
- order: 8,
134
- onClick: (scope) => {
135
- this.ctx.handleView(scope);
136
- },
137
- }),
138
- edit: (item, { ctx }) => ({
139
- icon: "el-icon-edit",
140
- label: "编辑",
141
- order: 9,
142
- onClick: (scope) => {
143
- this.ctx.handleEdit(scope);
144
- },
145
- }),
146
- delete: (item, { ctx }) => ({
147
- icon: "el-icon-delete",
148
- label: "删除",
149
- order: 12,
150
- innerHide: (scope) =>
151
- this.ctx.editConfig.mode === "row" && this.isRowEditing(scope),
152
- onClick: (scope) => {
153
- this.ctx.handleDelete(scope);
154
- },
155
- }),
156
- };
157
- },
158
- },
159
- methods: {
160
- bindColumnConfig() {
161
- const columnConfig = this.$refs.column?.columnConfig;
162
- if (columnConfig) {
163
- columnConfig.col = { ...this.action };
164
- columnConfig.options = { ...this.ctx.crudOptions };
165
- }
166
- },
167
- isRowEditing(scope) {
168
- return this.ctx.editState.isRowEditing(scope.row);
169
- },
170
- handleActionButtons(scope, actionButtons) {
171
- let buttons = actionButtons;
172
-
173
- buttons = buttons.filter((btn) => {
174
- if (btn.innerHide && btn.innerHide(scope)) {
175
- return false;
176
- }
177
- return true;
178
- });
179
-
180
- this.ctx.buttonList[scope.$index] = this.buttonList[
181
- scope.$index
182
- ] = buttons;
183
-
184
- this.$nextTick(() => {
185
- this.calcAutoWidth();
186
- });
187
- return buttons;
188
- },
189
- calcAutoWidth() {
190
- if (this.action.width === "auto") {
191
- let width = this.actionWidth;
192
- let list = document.querySelectorAll(".sc-crud-action-column");
193
- list.forEach((ele) => {
194
- let childList = ele.children;
195
- let allWidth = 0;
196
- for (let i = 0; i < childList.length; i++) {
197
- const child = childList[i];
198
- allWidth += child.offsetWidth + this.action.calcWidth;
199
- }
200
- if (allWidth >= width) width = allWidth;
201
- });
202
- this.actionWidth = width;
203
- }
204
- },
205
- },
206
- });
207
- </script>
@@ -1,146 +0,0 @@
1
- <script>
2
- import create from "core/create";
3
- import { generateRules } from "core";
4
- import Render from "core/components/render";
5
- import { bem } from "src/utils/bem";
6
- import { defaultRender } from "core";
7
-
8
- export default create({
9
- functional: true,
10
- name: "crud-cell",
11
- props: {
12
- col: Object,
13
- scope: Object,
14
- ctx: Object,
15
- topProps: Object,
16
- },
17
- render(h, context) {
18
- const { props, data } = context;
19
- const { col, scope, ctx, topProps } = props;
20
-
21
- const b = (...args) => bem("sc-crud-cell", ...args);
22
-
23
- // 辅助函数
24
- const findTreeProp = (tree, targetId, path = "") => {
25
- for (let i = 0; i < tree.length; i++) {
26
- const node = tree[i];
27
- if (node.id === targetId) {
28
- return path + i;
29
- }
30
- if (node.children && node.children.length > 0) {
31
- const childPath = `${path}${i}.children.`;
32
- const result = findTreeProp(node.children, targetId, childPath);
33
- if (result !== null) {
34
- return result;
35
- }
36
- }
37
- }
38
- return null;
39
- };
40
-
41
- // 获取表单属性
42
- const getFormProp = (item) => {
43
- if (!item.prop) return;
44
- if (topProps.isTree) {
45
- return (
46
- "list." +
47
- findTreeProp(ctx.list, scope.row[topProps.valueKey]) +
48
- "." +
49
- item.prop
50
- );
51
- }
52
- return "list." + scope.$index + "." + (item.validateProp || item.prop);
53
- };
54
-
55
- // 获取渲染项
56
- const getItem = (editMode) => {
57
- const props = { ...col };
58
- return (editMode && props[editMode]) || props;
59
- };
60
-
61
- // 单元格渲染
62
- const cellRender = (item, editMode, rawRules, formProp) => {
63
- return (
64
- <Render
65
- props={item}
66
- item={item}
67
- slots={topProps.extendsScopedSlots}
68
- mode={editMode}
69
- scope={scope}
70
- size={topProps.size}
71
- rawRules={rawRules}
72
- defaultRender={topProps.defaultRender}
73
- controlDefault={(defaultRender, scope) => {
74
- if (editMode === "add" || editMode === "edit") {
75
- return defaultRender.input;
76
- }
77
- }}
78
- data-row-key={scope.row[topProps.valueKey]}
79
- data-full-prop={formProp}
80
- data-prop={item.prop}
81
- ></Render>
82
- );
83
- };
84
-
85
- const cellDefaultRender = (item) => {
86
- const _scope = {
87
- ...scope,
88
- item,
89
- $value: {
90
- get: scope.row[item.prop],
91
- },
92
- };
93
- return defaultRender.formatter(h, _scope);
94
- };
95
-
96
- const isDefaultRender = (item) => {
97
- if (
98
- item.comp ||
99
- item.render ||
100
- ctx.extendsScopedSlots[item.prop] ||
101
- item.position ||
102
- item.formatData
103
- ) {
104
- return false;
105
- }
106
- return true;
107
- };
108
-
109
- // 主渲染逻辑
110
- const editMode = ctx.validateEdit(col, scope);
111
- const item = getItem(editMode);
112
- const formProp = getFormProp(item);
113
- const { rules, rawRules } = generateRules(item, scope);
114
- const isValidate = editMode && rules.length;
115
- const CompName = editMode && isValidate ? "el-form-item" : "div";
116
- let VNode;
117
-
118
- if (isDefaultRender(item) && !editMode) {
119
- VNode = cellDefaultRender(item);
120
- } else {
121
- VNode = cellRender(item, editMode, rawRules, formProp);
122
- }
123
- return (
124
- <CompName
125
- class={[
126
- rules.required && editMode ? "is-required" : "",
127
- b([col.align || "center"]),
128
- col.showOverflowTooltip && "sc-over-ellipsis",
129
- ]}
130
- label-width={item.labelWidth}
131
- size={topProps.size}
132
- prop={formProp}
133
- rules={rules}
134
- style="width:100%"
135
- on={{
136
- "hook:destroyed": () => {
137
- ctx.clearErrorMsg(scope.row, item.prop);
138
- },
139
- }}
140
- >
141
- {VNode}
142
- </CompName>
143
- );
144
- },
145
- });
146
- </script>