vue-super-crud 1.7.1

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 (291) hide show
  1. package/.browserslistrc +3 -0
  2. package/.versionrc.json +36 -0
  3. package/CHANGELOG.md +232 -0
  4. package/LICENSE +201 -0
  5. package/README.md +46 -0
  6. package/babel.config.js +12 -0
  7. package/build/alias.js +10 -0
  8. package/build/build.js +52 -0
  9. package/build/config.js +70 -0
  10. package/deploy.bat +14 -0
  11. package/docs/.vuepress/components/button/base.vue +88 -0
  12. package/docs/.vuepress/components/common/code-format.vue +331 -0
  13. package/docs/.vuepress/components/commonConfig/presetCodeTemplate/base.vue +68 -0
  14. package/docs/.vuepress/components/commonConfig/presetCodeTemplate/customParams.vue +73 -0
  15. package/docs/.vuepress/components/commonConfig/renderType/component.vue +160 -0
  16. package/docs/.vuepress/components/commonConfig/renderType/formatter.vue +49 -0
  17. package/docs/.vuepress/components/commonConfig/renderType/render.vue +91 -0
  18. package/docs/.vuepress/components/commonConfig/renderType/slot.vue +63 -0
  19. package/docs/.vuepress/components/crud/baseUse/baseUse.vue +98 -0
  20. package/docs/.vuepress/components/crud/baseUse/columnAction.vue +72 -0
  21. package/docs/.vuepress/components/crud/baseUse/columnWidth.vue +107 -0
  22. package/docs/.vuepress/components/crud/baseUse/handleRow.vue +65 -0
  23. package/docs/.vuepress/components/crud/baseUse/height.vue +82 -0
  24. package/docs/.vuepress/components/crud/baseUse/index.vue +54 -0
  25. package/docs/.vuepress/components/crud/baseUse/loading.vue +70 -0
  26. package/docs/.vuepress/components/crud/baseUse/pagination.vue +108 -0
  27. package/docs/.vuepress/components/crud/baseUse/selection.vue +114 -0
  28. package/docs/.vuepress/components/crud/baseUse/summaryMethod.vue +118 -0
  29. package/docs/.vuepress/components/crud/baseUse/title.vue +54 -0
  30. package/docs/.vuepress/components/crud/baseUse/toolbar.vue +69 -0
  31. package/docs/.vuepress/components/crud/buttons/common.vue +115 -0
  32. package/docs/.vuepress/components/crud/buttons/fast.vue +82 -0
  33. package/docs/.vuepress/components/crud/contextMenu/base.vue +72 -0
  34. package/docs/.vuepress/components/crud/copy.vue +52 -0
  35. package/docs/.vuepress/components/crud/crudEvents/api.vue +157 -0
  36. package/docs/.vuepress/components/crud/crudEvents/deleteTip.vue +93 -0
  37. package/docs/.vuepress/components/crud/crudEvents/events.vue +188 -0
  38. package/docs/.vuepress/components/crud/dataSort/base.vue +142 -0
  39. package/docs/.vuepress/components/crud/genDynamicColumns/base.vue +53 -0
  40. package/docs/.vuepress/components/crud/genDynamicColumns/dynamicAndFixed.vue +111 -0
  41. package/docs/.vuepress/components/crud/genDynamicColumns/treeDynamic.vue +68 -0
  42. package/docs/.vuepress/components/crud/handleBar/handleRow.vue +65 -0
  43. package/docs/.vuepress/components/crud/handleBar/toolbar.vue +69 -0
  44. package/docs/.vuepress/components/crud/renderType/1.vue +57 -0
  45. package/docs/.vuepress/components/crud/renderType/2.vue +63 -0
  46. package/docs/.vuepress/components/crud/renderType/3.vue +105 -0
  47. package/docs/.vuepress/components/crud/renderType/5.vue +91 -0
  48. package/docs/.vuepress/components/crud/search/1.vue +90 -0
  49. package/docs/.vuepress/components/crud/search/2.vue +78 -0
  50. package/docs/.vuepress/components/crud/search/3.vue +107 -0
  51. package/docs/.vuepress/components/crud/search/base.vue +123 -0
  52. package/docs/.vuepress/components/crud/search/localSearch.vue +124 -0
  53. package/docs/.vuepress/components/crud/search/special.vue +148 -0
  54. package/docs/.vuepress/components/crud/selection/events.vue +47 -0
  55. package/docs/.vuepress/components/crud/selection/pagination.vue +94 -0
  56. package/docs/.vuepress/components/crud/selection/singleSelection.vue +64 -0
  57. package/docs/.vuepress/components/crud/span/base.vue +69 -0
  58. package/docs/.vuepress/components/crud/span/special.vue +75 -0
  59. package/docs/.vuepress/components/crud/summary/base.vue +99 -0
  60. package/docs/.vuepress/components/crud/tableEdit/addDeleteBtn.vue +174 -0
  61. package/docs/.vuepress/components/crud/tableEdit/cellEdit.vue +194 -0
  62. package/docs/.vuepress/components/crud/tableEdit/controlEdit.vue +219 -0
  63. package/docs/.vuepress/components/crud/tableEdit/dialog.vue +172 -0
  64. package/docs/.vuepress/components/crud/tableEdit/free.vue +88 -0
  65. package/docs/.vuepress/components/crud/tableEdit/freeColumn.vue +82 -0
  66. package/docs/.vuepress/components/crud/tableEdit/methods.vue +154 -0
  67. package/docs/.vuepress/components/crud/tableEdit/rowAction.vue +107 -0
  68. package/docs/.vuepress/components/crud/tableEdit/rowBatch.vue +116 -0
  69. package/docs/.vuepress/components/crud/tableEdit/rowClick.vue +98 -0
  70. package/docs/.vuepress/components/crud/validate/base.vue +122 -0
  71. package/docs/.vuepress/components/crud/validate/custom.vue +82 -0
  72. package/docs/.vuepress/components/crud/validate/regulars.vue +88 -0
  73. package/docs/.vuepress/components/crud/validate/relation.vue +91 -0
  74. package/docs/.vuepress/components/crud/validate/tree.vue +82 -0
  75. package/docs/.vuepress/components/dialog/baseUse/base.vue +92 -0
  76. package/docs/.vuepress/components/dialog/baseUse/beforeConfirm.vue +78 -0
  77. package/docs/.vuepress/components/dialog/baseUse/control.vue +79 -0
  78. package/docs/.vuepress/components/dialog/baseUse/drawer.vue +59 -0
  79. package/docs/.vuepress/components/dialog/baseUse/footer.vue +87 -0
  80. package/docs/.vuepress/components/dialog/baseUse/insertSlot.vue +79 -0
  81. package/docs/.vuepress/components/dict/DictLinkage.vue +91 -0
  82. package/docs/.vuepress/components/dict/baseUse.vue +72 -0
  83. package/docs/.vuepress/components/dict/component.vue +82 -0
  84. package/docs/.vuepress/components/dict/localDict.vue +68 -0
  85. package/docs/.vuepress/components/form/baseUse/base.vue +48 -0
  86. package/docs/.vuepress/components/form/baseUse/dataFormat.vue +92 -0
  87. package/docs/.vuepress/components/form/baseUse/deep.vue +57 -0
  88. package/docs/.vuepress/components/form/baseUse/gridLayout.vue +47 -0
  89. package/docs/.vuepress/components/form/baseUse/group.vue +66 -0
  90. package/docs/.vuepress/components/form/baseUse/hidden.vue +40 -0
  91. package/docs/.vuepress/components/form/baseUse/inlineLayout.vue +48 -0
  92. package/docs/.vuepress/components/form/baseUse/label.vue +51 -0
  93. package/docs/.vuepress/components/form/baseUse/tooltip.vue +40 -0
  94. package/docs/.vuepress/components/form/baseUse/validate.vue +52 -0
  95. package/docs/.vuepress/components/form/detail/base.vue +78 -0
  96. package/docs/.vuepress/components/form/detail/border.vue +90 -0
  97. package/docs/.vuepress/components/form/detail/singleDetail.vue +72 -0
  98. package/docs/.vuepress/components/formatData/baseUse.vue +131 -0
  99. package/docs/.vuepress/components/mock/index.js +347 -0
  100. package/docs/.vuepress/components/mockData/custom.vue +69 -0
  101. package/docs/.vuepress/components/mockData/example.vue +290 -0
  102. package/docs/.vuepress/components/positionSlot/base.vue +24 -0
  103. package/docs/.vuepress/components/positionSlot/form.vue +71 -0
  104. package/docs/.vuepress/components/positionSlot/table.vue +85 -0
  105. package/docs/.vuepress/components/tabs/base.vue +57 -0
  106. package/docs/.vuepress/components/temp.js +195 -0
  107. package/docs/.vuepress/config.js +146 -0
  108. package/docs/.vuepress/enhanceApp.js +142 -0
  109. package/docs/.vuepress/public/favicon.ico +0 -0
  110. package/docs/.vuepress/public/super.png +0 -0
  111. package/docs/.vuepress/styles/index.styl +25 -0
  112. package/docs/.vuepress/styles/palette.styl +6 -0
  113. package/docs/README.md +14 -0
  114. package/docs/guide/button/base.md +31 -0
  115. package/docs/guide/commonConfig/jsx.md +166 -0
  116. package/docs/guide/commonConfig/presetCodeTemplate.md +68 -0
  117. package/docs/guide/commonConfig/renderType.md +181 -0
  118. package/docs/guide/crud/baseUse.md +120 -0
  119. package/docs/guide/crud/buttons.md +18 -0
  120. package/docs/guide/crud/config.md +217 -0
  121. package/docs/guide/crud/contextMenu.md +18 -0
  122. package/docs/guide/crud/dataSort.md +66 -0
  123. package/docs/guide/crud/genDynamicColumns.md +145 -0
  124. package/docs/guide/crud/handleBar.md +26 -0
  125. package/docs/guide/crud/renderType.md +4 -0
  126. package/docs/guide/crud/search.md +150 -0
  127. package/docs/guide/crud/selection.md +73 -0
  128. package/docs/guide/crud/span.md +98 -0
  129. package/docs/guide/crud/summary.md +167 -0
  130. package/docs/guide/crud/tableEdit.md +377 -0
  131. package/docs/guide/crud/validate.md +158 -0
  132. package/docs/guide/dialog/baseUse.md +81 -0
  133. package/docs/guide/dict/baseUse.md +174 -0
  134. package/docs/guide/dict/component.md +88 -0
  135. package/docs/guide/dict/config.md +44 -0
  136. package/docs/guide/form/baseUse.md +142 -0
  137. package/docs/guide/form/detail.md +38 -0
  138. package/docs/guide/formatData/baseUse.md +98 -0
  139. package/docs/guide/formatData/config.md +142 -0
  140. package/docs/guide/mockData/base.md +26 -0
  141. package/docs/guide/positionSlot/base.md +41 -0
  142. package/docs/guide/question/base.md +44 -0
  143. package/docs/guide/start/base.md +30 -0
  144. package/docs/guide/tabs/base.md +63 -0
  145. package/examples/App.vue +52 -0
  146. package/examples/Layout/components/AppMain.vue +40 -0
  147. package/examples/Layout/components/Item.vue +29 -0
  148. package/examples/Layout/components/Link.vue +44 -0
  149. package/examples/Layout/components/SidebarItem.vue +93 -0
  150. package/examples/Layout/index.vue +69 -0
  151. package/examples/assets/logo.png +0 -0
  152. package/examples/favicon.ico +0 -0
  153. package/examples/index.html +18 -0
  154. package/examples/main.js +54 -0
  155. package/examples/router/index.js +140 -0
  156. package/examples/store/index.js +0 -0
  157. package/examples/styles/index.scss +63 -0
  158. package/examples/styles/sidebar.scss +226 -0
  159. package/examples/styles/transition.scss +48 -0
  160. package/examples/styles/variables.scss +25 -0
  161. package/examples/views/crud/base.vue +68 -0
  162. package/examples/views/crud/handleRow.vue +84 -0
  163. package/examples/views/crud/search.vue +116 -0
  164. package/examples/views/dashboard/index.vue +244 -0
  165. package/examples/views/dashboard/index1.vue +234 -0
  166. package/examples/views/dashboard/test.vue +9 -0
  167. package/examples/views/formTest/index.vue +168 -0
  168. package/examples/views/nested/menu1/index.vue +7 -0
  169. package/examples/views/nested/menu1/menu1-1/index.vue +7 -0
  170. package/examples/views/nested/menu1/menu1-2/index.vue +7 -0
  171. package/examples/views/nested/menu1/menu1-2/menu1-2-1/index.vue +5 -0
  172. package/examples/views/nested/menu1/menu1-2/menu1-2-2/index.vue +5 -0
  173. package/examples/views/nested/menu1/menu1-3/index.vue +5 -0
  174. package/examples/views/nested/menu2/index.vue +5 -0
  175. package/gulpfile.js +84 -0
  176. package/lib/index.css +1 -0
  177. package/lib/super-crud.min.js +15 -0
  178. package/package.json +66 -0
  179. package/packages/button/index.vue +189 -0
  180. package/packages/core/components/comp.vue +223 -0
  181. package/packages/core/components/position.vue +135 -0
  182. package/packages/core/components/render.vue +460 -0
  183. package/packages/core/configManager.js +302 -0
  184. package/packages/core/create.js +8 -0
  185. package/packages/core/defaultRender.js +64 -0
  186. package/packages/core/dict/global.js +10 -0
  187. package/packages/core/dict/index.js +432 -0
  188. package/packages/core/dict/mixin.js +94 -0
  189. package/packages/core/event.js +60 -0
  190. package/packages/core/index.js +6 -0
  191. package/packages/core/init.js +122 -0
  192. package/packages/core/mock/genConfig.js +228 -0
  193. package/packages/core/mock/genData.js +422 -0
  194. package/packages/core/mock/index.js +4 -0
  195. package/packages/core/rules.js +111 -0
  196. package/packages/crud/column.vue +205 -0
  197. package/packages/crud/columnAction.vue +207 -0
  198. package/packages/crud/columnCell.vue +146 -0
  199. package/packages/crud/defaultColumn.vue +130 -0
  200. package/packages/crud/drawerColumn.vue +225 -0
  201. package/packages/crud/form.vue +69 -0
  202. package/packages/crud/index.vue +564 -0
  203. package/packages/crud/menuBar.vue +298 -0
  204. package/packages/crud/mixins/cacheHandler.js +36 -0
  205. package/packages/crud/mixins/calcColumnWidth.js +79 -0
  206. package/packages/crud/mixins/calcHeight.js +105 -0
  207. package/packages/crud/mixins/columnHandler.js +128 -0
  208. package/packages/crud/mixins/contextMenu.js +98 -0
  209. package/packages/crud/mixins/dataProcessor.js +202 -0
  210. package/packages/crud/mixins/dialog.js +109 -0
  211. package/packages/crud/mixins/excelHandler.js +150 -0
  212. package/packages/crud/mixins/exposeMethods.js +107 -0
  213. package/packages/crud/mixins/generateDynamicColumns.js +250 -0
  214. package/packages/crud/mixins/props.js +38 -0
  215. package/packages/crud/mixins/searchHandler.js +151 -0
  216. package/packages/crud/mixins/select.js +359 -0
  217. package/packages/crud/mixins/spanMethod.js +288 -0
  218. package/packages/crud/mixins/summary.js +177 -0
  219. package/packages/crud/mixins/tableEdit.js +547 -0
  220. package/packages/crud/mixins/validate.js +219 -0
  221. package/packages/crud/pagination.vue +110 -0
  222. package/packages/crud/search.vue +119 -0
  223. package/packages/crud/searchHeader.vue +231 -0
  224. package/packages/crud/selectBanner.vue +138 -0
  225. package/packages/crud/utils/EditState.js +319 -0
  226. package/packages/crud/utils/excelExport.js +112 -0
  227. package/packages/crud/utils/excelImport.js +112 -0
  228. package/packages/crud/utils/index.js +98 -0
  229. package/packages/dialog/dialog.js +233 -0
  230. package/packages/dialog/dialog.vue +15 -0
  231. package/packages/dialog/index.js +22 -0
  232. package/packages/dict/cascadeFormat.vue +179 -0
  233. package/packages/dict/dateFormat.vue +40 -0
  234. package/packages/dict/form/cascade.vue +61 -0
  235. package/packages/dict/form/checkbox.vue +90 -0
  236. package/packages/dict/form/extendMethod.js +22 -0
  237. package/packages/dict/form/input-base.js +31 -0
  238. package/packages/dict/form/input.js +20 -0
  239. package/packages/dict/form/radio.vue +69 -0
  240. package/packages/dict/form/select.vue +118 -0
  241. package/packages/dict/form/switch.vue +75 -0
  242. package/packages/dict/valueFormat.vue +188 -0
  243. package/packages/directive/dialog/drag.js +86 -0
  244. package/packages/directive/dialog/dragSize.js +42 -0
  245. package/packages/directive/index.js +9 -0
  246. package/packages/directive/insertSlot.js +10 -0
  247. package/packages/form/contextMenu.js +192 -0
  248. package/packages/form/draftDrawer.vue +391 -0
  249. package/packages/form/formAction.vue +97 -0
  250. package/packages/form/formItem.vue +259 -0
  251. package/packages/form/index.vue +451 -0
  252. package/packages/form/props.js +15 -0
  253. package/packages/grid/cell.vue +65 -0
  254. package/packages/grid/index.vue +130 -0
  255. package/packages/group/index.vue +96 -0
  256. package/packages/tabs/index.vue +290 -0
  257. package/packages/tooltip/index.js +9 -0
  258. package/packages/tooltip/tooltip.vue +32 -0
  259. package/packages/tooltip/tooltipComponent.js +38 -0
  260. package/packages/verifyInput/index.vue +131 -0
  261. package/src/config/common.js +88 -0
  262. package/src/config/crud.js +567 -0
  263. package/src/config/dialog.js +87 -0
  264. package/src/config/form.js +215 -0
  265. package/src/config/index.js +9 -0
  266. package/src/constants/index.js +72 -0
  267. package/src/index.js +67 -0
  268. package/src/template/btn/crud.js +6 -0
  269. package/src/template/btn/dialog.js +1 -0
  270. package/src/template/btn/form.js +3 -0
  271. package/src/template/btn/index.js +9 -0
  272. package/src/template/dicts.js +1 -0
  273. package/src/template/formatData.js +507 -0
  274. package/src/template/index.js +19 -0
  275. package/src/template/render.js +124 -0
  276. package/src/template/rules.js +53 -0
  277. package/src/utils/bem.js +49 -0
  278. package/src/utils/cache.js +77 -0
  279. package/src/utils/getType.js +34 -0
  280. package/src/utils/index.js +212 -0
  281. package/src/utils/mergeTemp.js +124 -0
  282. package/styles/button.scss +3 -0
  283. package/styles/crud.scss +425 -0
  284. package/styles/dialog.scss +95 -0
  285. package/styles/form.scss +532 -0
  286. package/styles/group.scss +78 -0
  287. package/styles/index.scss +94 -0
  288. package/styles/tabs.scss +139 -0
  289. package/styles/verifyInput.scss +56 -0
  290. package/vue-jsx-sync.js +90 -0
  291. package/vue.config.js +54 -0
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "vue-super-crud",
3
+ "version": "1.7.1",
4
+ "main": "lib/super-crud.min.js",
5
+ "private": false,
6
+ "scripts": {
7
+ "serve": "vue-cli-service serve",
8
+ "docs:dev": "vuepress dev docs",
9
+ "docs:build": "vuepress build docs",
10
+ "lib": "vue-cli-service build --target lib --dest lib src/index.js",
11
+ "dev": "cross-env TARGET=dev gulp watch",
12
+ "build": "cross-env TARGET=prod gulp build",
13
+ "deploy": "deploy.bat",
14
+ "release": "standard-version",
15
+ "test": "jest",
16
+ "test:watch": "jest --watch",
17
+ "test:coverage": "jest --coverage"
18
+ },
19
+ "dependencies": {
20
+ "dayjs": "^1.11.13",
21
+ "el-table-virtual-scroll": "^1.4.6",
22
+ "element-ui": "^2.15.14",
23
+ "lodash-es": "^4.17.21",
24
+ "mockjs": "^1.1.0",
25
+ "vue": "^2.6.11",
26
+ "vue-contextmenujs": "^1.4.11",
27
+ "vue-highlight.js": "^3.1.0",
28
+ "vue-router": "^3.2.0",
29
+ "vuedraggable": "^2.24.3",
30
+ "vuepress": "^1.9.10",
31
+ "vuepress-plugin-code-copy": "^1.0.6",
32
+ "xe-utils": "^3.5.28",
33
+ "xlsx": "^0.18.5"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/core": "^7.13.14",
37
+ "@babel/preset-env": "^7.13.12",
38
+ "@vue/babel-helper-vue-jsx-merge-props": "^1.4.0",
39
+ "@vue/babel-preset-jsx": "^1.4.0",
40
+ "@vue/cli-plugin-babel": "~4.5.19",
41
+ "@vue/cli-plugin-router": "~4.5.19",
42
+ "@vue/cli-plugin-vuex": "~4.5.19",
43
+ "@vue/cli-service": "~4.5.19",
44
+ "babel-loader": "^8.2.2",
45
+ "babel-plugin-jsx-v-model": "^2.0.3",
46
+ "cache-loader": "^4.1.0",
47
+ "cross-env": "^7.0.3",
48
+ "css-loader": "^5.2.0",
49
+ "gulp": "^4.0.0",
50
+ "gulp-autoprefixer": "^4.0.0",
51
+ "gulp-cssmin": "^0.1.7",
52
+ "gulp-postcss": "^6.1.1",
53
+ "gulp-sass": "^5.1.0",
54
+ "jest": "^29.7.0",
55
+ "progress-bar-webpack-plugin": "^2.1.0",
56
+ "sass": "^1.26.5",
57
+ "sass-loader": "^8.0.2",
58
+ "standard-version": "^9.5.0",
59
+ "vue-loader": "^15.9.6",
60
+ "vue-template-compiler": "^2.6.11",
61
+ "vuepress-plugin-fulltext-search": "^2.2.1",
62
+ "vuepress-theme-reco": "^1.6.17",
63
+ "webpack": "^4.27.0",
64
+ "webpack-merge": "^4.1.4"
65
+ }
66
+ }
@@ -0,0 +1,189 @@
1
+ <template>
2
+ <el-button
3
+ v-if="getIsShow() && !attrs.children"
4
+ :disabled="isDebounce || attrs.disabled"
5
+ v-bind="attrs"
6
+ :size="size"
7
+ :class="b()"
8
+ @click="handleClick()"
9
+ >
10
+ <span v-if="attrs.label">{{ attrs.label }}</span>
11
+ <slot v-if="$slots.default"></slot>
12
+ </el-button>
13
+ <el-dropdown
14
+ v-else-if="getIsShow()"
15
+ v-bind="attrs"
16
+ trigger="click"
17
+ :size="size"
18
+ :disabled="isDebounce || attrs.disabled"
19
+ >
20
+ <el-button
21
+ :class="b()"
22
+ :size="size"
23
+ :disabled="isDebounce || attrs.disabled"
24
+ v-bind="attrs"
25
+ ><span v-if="attrs.label">{{ attrs.label }}</span
26
+ ><slot v-if="$slots.default"></slot
27
+ ><i class="el-icon-arrow-down el-icon--right"></i
28
+ ></el-button>
29
+ <el-dropdown-menu slot="dropdown">
30
+ <el-dropdown-item
31
+ v-for="(child, idx) in attrs.children"
32
+ @click.native="handleClick(child)"
33
+ :key="idx"
34
+ v-bind="child"
35
+ >{{ child.label }}</el-dropdown-item
36
+ >
37
+ </el-dropdown-menu>
38
+ </el-dropdown>
39
+ </template>
40
+ <script>
41
+ import { create } from "core";
42
+ import { isFunction } from "lodash-es";
43
+ export default create({
44
+ inheritAttrs: false,
45
+ name: "button",
46
+ props: {
47
+ time: {
48
+ type: Number,
49
+ default: 300,
50
+ },
51
+ size: String,
52
+ scope: {},
53
+ onClick: {},
54
+ confirm: {},
55
+ customConfirm: {},
56
+ successBack: {},
57
+ textSubmit: {},
58
+ batchConfirm: {},
59
+ },
60
+ data() {
61
+ return {
62
+ isDebounce: false,
63
+ attrs: {},
64
+ };
65
+ },
66
+ watch: {
67
+ $attrs() {
68
+ this.attrs = this.getBindAttrs();
69
+ },
70
+ },
71
+ created() {
72
+ this.attrs = this.getBindAttrs();
73
+ },
74
+ methods: {
75
+ getBindAttrs() {
76
+ const attrs = {};
77
+ Object.keys(this.$attrs).forEach((key) => {
78
+ if (isFunction(this.$attrs[key])) {
79
+ attrs[key] = this.$attrs[key](this.scope);
80
+ } else {
81
+ attrs[key] = this.$attrs[key];
82
+ }
83
+ });
84
+ return attrs;
85
+ },
86
+ getIsShow() {
87
+ const bindAttrs = this.attrs;
88
+ if (bindAttrs.hidden) return false;
89
+ if (bindAttrs.show === false) return false;
90
+ return true;
91
+ },
92
+ handleClick(item = this) {
93
+ this.beforeClick((...args) => {
94
+ if (item.onClick) {
95
+ item.onClick(this.scope, ...args);
96
+ } else {
97
+ this.$emit("click", ...args);
98
+ }
99
+ this.isDebounce = true;
100
+ setTimeout(() => {
101
+ this.isDebounce = false;
102
+ }, this.time);
103
+ }, item);
104
+ },
105
+ beforeClick(cb, item) {
106
+ if (item.confirm) {
107
+ this.handleConfirm(item.confirm, cb);
108
+ } else if (item.customConfirm) {
109
+ this.handleCustomConfirm(item.customConfirm, cb);
110
+ } else if (item.successBack) {
111
+ this.handleSuccessBack(item.successBack, cb);
112
+ } else if (item.textSubmit) {
113
+ this.handleFormSubmit(item.textSubmit, cb);
114
+ } else if (item.batchConfirm) {
115
+ this.$scDialog({
116
+ presetType: "batchConfirm",
117
+ ...item.batchConfirm,
118
+ }).show(cb);
119
+ } else {
120
+ cb();
121
+ }
122
+ },
123
+ handleConfirm(confirm, cb) {
124
+ if (isFunction(confirm)) confirm = confirm(this.scope);
125
+ // 处理字符串和布尔值配置
126
+ if (confirm === true || typeof confirm === "string") {
127
+ const message = confirm === true ? "确定要执行此操作吗?" : confirm;
128
+ this.$confirm(message, "提示", {
129
+ confirmButtonText: "确定",
130
+ cancelButtonText: "取消",
131
+ type: "warning",
132
+ }).then(() => {
133
+ cb();
134
+ });
135
+ return;
136
+ }
137
+ // 处理对象配置
138
+ const {
139
+ label,
140
+ title = "提示",
141
+ confirmButtonText = "确定",
142
+ cancelButtonText = "取消",
143
+ type = "warning",
144
+ } = confirm;
145
+ this.$confirm(label || "确定要执行此操作吗?", title, {
146
+ confirmButtonText,
147
+ cancelButtonText,
148
+ type,
149
+ }).then(() => {
150
+ cb();
151
+ });
152
+ },
153
+ handleCustomConfirm(customConfirm, cb) {
154
+ if (isFunction(customConfirm)) customConfirm = customConfirm(this.scope);
155
+ this.$scDialog({
156
+ presetType: "confirmTip",
157
+ label: customConfirm.label,
158
+ content: customConfirm.content,
159
+ title: customConfirm.title,
160
+ }).show(cb);
161
+ },
162
+ handleSuccessBack(successBack, cb) {
163
+ const vm = this.$scDialog({
164
+ presetType: "successBack",
165
+ onClick: () => {
166
+ if (isFunction(successBack)) {
167
+ successBack(this.scope);
168
+ vm.hide();
169
+ } else {
170
+ setTimeout(() => {
171
+ this.$router.go(-1);
172
+ vm.hide();
173
+ }, 50);
174
+ }
175
+ },
176
+ });
177
+ cb(() => vm.show());
178
+ },
179
+ handleFormSubmit(textSubmit, clickCb) {
180
+ if (isFunction(textSubmit)) textSubmit = textSubmit(this.scope);
181
+ this.$scDialog({
182
+ presetType: "textSubmit",
183
+ ...textSubmit,
184
+ submit: clickCb,
185
+ }).show();
186
+ },
187
+ },
188
+ });
189
+ </script>
@@ -0,0 +1,223 @@
1
+ <script>
2
+ import { set, omit, isArray, isFunction, isPlainObject } from "lodash-es";
3
+ import { isVNode } from "utils";
4
+ import Comp from "./comp.vue";
5
+
6
+ // 获取组件名称
7
+ function getCompName(name, isChildren, children, comp) {
8
+ if (isChildren || children) return name;
9
+ const nameMap = {
10
+ "el-select": "sc-select",
11
+ "el-checkbox-group": "sc-checkbox",
12
+ "el-radio-group": "sc-radio",
13
+ "el-switch": "sc-switch",
14
+ "el-cascader": "sc-cascader",
15
+ };
16
+ if (comp.options && name === "el-input") {
17
+ return "sc-select";
18
+ }
19
+ return nameMap[name] || name;
20
+ }
21
+
22
+ // 获取事件处理函数
23
+ function getOn(on, comp, scope, parent, props) {
24
+ const events = {};
25
+ if (on) {
26
+ Object.entries(on).forEach(([key, handler]) => {
27
+ events[key] = (...args) => handler?.(...args, scope);
28
+ });
29
+ }
30
+
31
+ // 处理以 on 开头的事件配置
32
+ Object.entries(comp)
33
+ .filter(([key, value]) => /^on[A-Z]/.test(key) && isFunction(value))
34
+ .forEach(([key, handler]) => {
35
+ const eventName = key.slice(2).toLowerCase();
36
+ events[eventName] = (...args) => handler?.(...args, scope);
37
+ });
38
+
39
+ return {
40
+ ...events,
41
+ input: (event) => {
42
+ parent.$value = event;
43
+ events.input && events.input(event);
44
+ },
45
+ change: (event) => {
46
+ parent.$value = event;
47
+ events.change && events.change(event);
48
+ },
49
+ "hook:mounted": () => {
50
+ const instance = parent.$vnode.componentInstance.$children[0];
51
+ if (props.mounted) {
52
+ props.mounted(scope, instance);
53
+ }
54
+ if (props.ref) {
55
+ props.ref(scope, instance);
56
+ }
57
+ },
58
+ };
59
+ }
60
+
61
+ // 获取插槽
62
+ function getScopedSlots(scopedSlots, slots, h, scope) {
63
+ const result = {};
64
+ const allSlots = { ...scopedSlots, ...slots };
65
+
66
+ for (const key in allSlots) {
67
+ result[key] = () => allSlots[key](h, scope);
68
+ }
69
+
70
+ return result;
71
+ }
72
+
73
+ // 获取placeholder
74
+ function getPlaceholder(comp, name, scope) {
75
+ if (comp.placeholder) {
76
+ return comp.placeholder;
77
+ }
78
+ if (name === "el-input") {
79
+ return "请输入" + scope.item.label;
80
+ }
81
+ return "请选择" + scope.item.label;
82
+ }
83
+
84
+ // 获取clearable
85
+ function getClearable(comp) {
86
+ if (comp.clearable !== undefined) {
87
+ return comp.clearable;
88
+ }
89
+ return true;
90
+ }
91
+
92
+ // 获取组件尺寸
93
+ function getCompSize(comp, size, ELEMENT) {
94
+ return comp.size || size || (ELEMENT || {}).size;
95
+ }
96
+
97
+ // 渲染子元素
98
+ function renderChildren(children, h, scope) {
99
+ if (!children) return null;
100
+
101
+ if (isFunction(children)) {
102
+ if (children.length === 2) {
103
+ children = children(h, scope);
104
+ if (isVNode(children)) return children;
105
+ } else {
106
+ children = children(scope);
107
+ }
108
+ }
109
+
110
+ if (isArray(children)) {
111
+ return children.map((child) => {
112
+ if (isPlainObject(child)) {
113
+ return h(Comp, {
114
+ props: { ...child, comp: child, scope, isChildren: true },
115
+ });
116
+ }
117
+ return child;
118
+ });
119
+ }
120
+
121
+ return children;
122
+ }
123
+
124
+ // 生成假插槽
125
+ function fakeSlot(h, scopedSlots, slots) {
126
+ const allSlots = { ...scopedSlots, ...slots };
127
+ return Object.keys(allSlots).map((slot) => h("i", { slot }));
128
+ }
129
+
130
+ export default {
131
+ name: "comp",
132
+ functional: true,
133
+ props: {
134
+ value: {},
135
+ prop: {},
136
+ name: {
137
+ default: "el-input",
138
+ },
139
+ comp: Object,
140
+ bind: [Object, Function],
141
+ on: Object,
142
+ scopedSlots: Object,
143
+ slots: Object,
144
+ children: {},
145
+ scope: Object,
146
+ size: {},
147
+ isChildren: Boolean,
148
+ nativeOn: Object,
149
+ directives: {
150
+ type: Object,
151
+ default: () => ({}),
152
+ },
153
+ created: Function,
154
+ mounted: Function,
155
+ },
156
+ render(h, context) {
157
+ const { props, data, parent } = context;
158
+ const { name, comp, scope, isChildren, children, bind } = props;
159
+
160
+ // 获取组件props
161
+ const getComponentProps = (compName) => {
162
+ const component = parent.$options.components[compName];
163
+ return component?.options?.props || {};
164
+ };
165
+
166
+ // 处理bind属性
167
+ let processedComp = comp;
168
+ if (isFunction(bind)) {
169
+ processedComp = { ...comp, ...bind(scope) };
170
+ } else if (bind) {
171
+ processedComp = { ...comp, ...bind };
172
+ }
173
+
174
+ // 获取组件名称
175
+ const compName = getCompName(name, isChildren, children, processedComp);
176
+
177
+ // 获取组件声明的props
178
+ const componentProps = getComponentProps(compName);
179
+
180
+ // 分离props和attrs
181
+ const propsToPass = {};
182
+ const attrsToPass = {};
183
+
184
+ Object.entries(processedComp).forEach(([key, value]) => {
185
+ if (componentProps[key]) {
186
+ propsToPass[key] = value;
187
+ } else if (!(key in props)) {
188
+ attrsToPass[key] = value;
189
+ }
190
+ });
191
+
192
+ // 生命周期钩子
193
+ if (props.created) {
194
+ props.created(scope);
195
+ }
196
+ return h(
197
+ compName,
198
+ {
199
+ props: {
200
+ ...propsToPass,
201
+ value: props.value || parent.$value,
202
+ scope,
203
+ },
204
+ attrs: {
205
+ ...attrsToPass,
206
+ size: getCompSize(processedComp, props.size, parent.$ELEMENT),
207
+ placeholder: getPlaceholder(processedComp, compName, scope),
208
+ clearable: getClearable(processedComp),
209
+ disabled: processedComp.disabled ? true : false,
210
+ },
211
+ on: getOn(props.on, processedComp, scope, parent, props),
212
+ nativeOn: props.nativeOn,
213
+ scopedSlots: getScopedSlots(props.scopedSlots, props.slots, h, scope),
214
+ directives: props.directives,
215
+ },
216
+ [
217
+ renderChildren(children, h, scope),
218
+ ...fakeSlot(h, props.scopedSlots, props.slots),
219
+ ]
220
+ );
221
+ },
222
+ };
223
+ </script>
@@ -0,0 +1,135 @@
1
+ <script>
2
+ import create from "core/create";
3
+ import { resolveRender } from "utils";
4
+ export default create({
5
+ name: "position",
6
+ props: {
7
+ inline: {
8
+ type: Boolean,
9
+ default: true,
10
+ },
11
+ slotName: String,
12
+ slotSuffixes: {
13
+ type: Array,
14
+ default: () => [],
15
+ },
16
+ render: Function,
17
+ slots: {
18
+ type: Object,
19
+ default() {
20
+ return {};
21
+ },
22
+ },
23
+ scope: {},
24
+ ellipsis: Boolean,
25
+ },
26
+ computed: {
27
+ slotNames() {
28
+ if (!this.slotName) return;
29
+ // 如果没有后缀,直接返回原始slotName
30
+ if (!this.slotSuffixes.length) return this.slotName;
31
+
32
+ // 将所有后缀用'-'连接
33
+ const suffix = this.slotSuffixes
34
+ .filter(Boolean) // 过滤掉空值
35
+ .join("-");
36
+
37
+ // 如果有后缀,返回 slotName-suffix 格式
38
+ return suffix ? `${this.slotName}-${suffix}` : this.slotName;
39
+ },
40
+ leftSlot() {
41
+ return this.slots[`${this.slotNames}-left`] || this.$scopedSlots.left;
42
+ },
43
+ rightSlot() {
44
+ return this.slots[`${this.slotNames}-right`] || this.$scopedSlots.right;
45
+ },
46
+ topSlot() {
47
+ return this.slots[`${this.slotNames}-top`] || this.$scopedSlots.top;
48
+ },
49
+ bottomSlot() {
50
+ return this.slots[`${this.slotNames}-bottom`] || this.$scopedSlots.bottom;
51
+ },
52
+ hasPosition() {
53
+ return this.topSlot || this.bottomSlot || this.leftSlot || this.rightSlot;
54
+ },
55
+ contentStyle() {
56
+ if (!this.ellipsis) return {};
57
+ return {
58
+ "white-space": "nowrap",
59
+ overflow: "hidden",
60
+ "text-overflow": "ellipsis",
61
+ };
62
+ },
63
+ // 动态计算grid布局样式
64
+ gridStyle() {
65
+ const areas = [];
66
+ if (this.topSlot) {
67
+ areas.push('"top top top"');
68
+ }
69
+ const middleRow = [
70
+ this.leftSlot ? "left" : ".",
71
+ "content",
72
+ this.rightSlot ? "right" : ".",
73
+ ].join(" ");
74
+ areas.push(`"${middleRow}"`);
75
+
76
+ if (this.bottomSlot) {
77
+ areas.push('"bottom bottom bottom"');
78
+ }
79
+ const columns = [
80
+ this.leftSlot ? "auto" : "0",
81
+ "1fr",
82
+ this.rightSlot ? "auto" : "0",
83
+ ].join(" ");
84
+ return {
85
+ display: this.inline ? "inline-grid" : "grid",
86
+ "grid-template-areas": areas.join("\n"),
87
+ "grid-template-columns": columns,
88
+ "align-items": "center",
89
+ };
90
+ },
91
+ },
92
+ render(h) {
93
+ const renderContent = () => {
94
+ if (this.slots[`${this.slotNames}`]) {
95
+ return this.slots[`${this.slotNames}`](this.scope);
96
+ }
97
+ if (this.render) {
98
+ return resolveRender(this.render, h, this.scope);
99
+ }
100
+ if (this.$scopedSlots.default) {
101
+ return this.$scopedSlots.default(this.scope);
102
+ }
103
+ };
104
+ const content = renderContent();
105
+ if (
106
+ !content &&
107
+ !this.topSlot &&
108
+ !this.leftSlot &&
109
+ !this.rightSlot &&
110
+ !this.bottomSlot
111
+ )
112
+ return null;
113
+ return (
114
+ <div
115
+ class={[this.b([this.slotNames || "position"])]}
116
+ style={this.gridStyle}
117
+ >
118
+ {this.topSlot && <div class="top">{this.topSlot(this.scope)}</div>}
119
+ {this.leftSlot && <div class="left">{this.leftSlot(this.scope)}</div>}
120
+ {content && (
121
+ <div class="content" style={this.contentStyle}>
122
+ {content}
123
+ </div>
124
+ )}
125
+ {this.rightSlot && (
126
+ <div class="right">{this.rightSlot(this.scope)}</div>
127
+ )}
128
+ {this.bottomSlot && (
129
+ <div class="bottom">{this.bottomSlot(this.scope)}</div>
130
+ )}
131
+ </div>
132
+ );
133
+ },
134
+ });
135
+ </script>