skhj-variant 2.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (346) hide show
  1. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/package.iml +12 -0
  4. package/README.md +180 -0
  5. package/babel.config.js +5 -0
  6. package/dist/build/css/app.9b74af27.css +1 -0
  7. package/dist/build/css/chunk-vendors.a16c4353.css +1 -0
  8. package/dist/build/favicon.ico +0 -0
  9. package/dist/build/fonts/element-icons.535877f5.woff +0 -0
  10. package/dist/build/fonts/element-icons.732389de.ttf +0 -0
  11. package/dist/build/img/t1.21b2c158.png +0 -0
  12. package/dist/build/img/t2.6991670f.png +0 -0
  13. package/dist/build/img/t3.49724600.png +0 -0
  14. package/dist/build/img/t4.4acb1808.png +0 -0
  15. package/dist/build/img/t5.e5e1948c.png +0 -0
  16. package/dist/build/img/t6.40836551.png +0 -0
  17. package/dist/build/img/t7.94cf1cc9.png +0 -0
  18. package/dist/build/img/t8.9291e9c1.png +0 -0
  19. package/dist/build/index.html +1 -0
  20. package/dist/build/js/app.dbcf7751.js +1 -0
  21. package/dist/build/js/chunk-1d66e3dd.7d669272.js +23 -0
  22. package/dist/build/js/chunk-vendors.be32fc27.js +24 -0
  23. package/dist/build/report.html +53 -0
  24. package/dist/lib/VFormDesigner.common-report.html +53 -0
  25. package/dist/lib/VFormDesigner.common.1.js +14583 -0
  26. package/dist/lib/VFormDesigner.common.1.js.map +1 -0
  27. package/dist/lib/VFormDesigner.common.js +71232 -0
  28. package/dist/lib/VFormDesigner.common.js.map +1 -0
  29. package/dist/lib/VFormDesigner.css +1 -0
  30. package/dist/lib/VFormDesigner.umd-report.html +53 -0
  31. package/dist/lib/VFormDesigner.umd.1.js +14583 -0
  32. package/dist/lib/VFormDesigner.umd.1.js.map +1 -0
  33. package/dist/lib/VFormDesigner.umd.js +71242 -0
  34. package/dist/lib/VFormDesigner.umd.js.map +1 -0
  35. package/dist/lib/VFormDesigner.umd.min-report.html +53 -0
  36. package/dist/lib/VFormDesigner.umd.min.1.js +23 -0
  37. package/dist/lib/VFormDesigner.umd.min.js +19 -0
  38. package/dist/lib/demo.html +10 -0
  39. package/dist/lib/img/t1.21b2c158.png +0 -0
  40. package/dist/lib/img/t2.6991670f.png +0 -0
  41. package/dist/lib/img/t3.49724600.png +0 -0
  42. package/dist/lib/img/t4.4acb1808.png +0 -0
  43. package/dist/lib/img/t5.e5e1948c.png +0 -0
  44. package/dist/lib/img/t6.40836551.png +0 -0
  45. package/dist/lib/img/t7.94cf1cc9.png +0 -0
  46. package/dist/lib/img/t8.9291e9c1.png +0 -0
  47. package/dist/lib-render/VFormRender.common-report.html +53 -0
  48. package/dist/lib-render/VFormRender.common.1.js +14583 -0
  49. package/dist/lib-render/VFormRender.common.1.js.map +1 -0
  50. package/dist/lib-render/VFormRender.common.js +32421 -0
  51. package/dist/lib-render/VFormRender.common.js.map +1 -0
  52. package/dist/lib-render/VFormRender.css +1 -0
  53. package/dist/lib-render/VFormRender.umd-report.html +53 -0
  54. package/dist/lib-render/VFormRender.umd.1.js +14583 -0
  55. package/dist/lib-render/VFormRender.umd.1.js.map +1 -0
  56. package/dist/lib-render/VFormRender.umd.js +32431 -0
  57. package/dist/lib-render/VFormRender.umd.js.map +1 -0
  58. package/dist/lib-render/VFormRender.umd.min-report.html +53 -0
  59. package/dist/lib-render/VFormRender.umd.min.1.js +23 -0
  60. package/dist/lib-render/VFormRender.umd.min.js +15 -0
  61. package/dist/lib-render/demo.html +10 -0
  62. package/index_template/index_dev.html +19 -0
  63. package/index_template/index_prod.html +28 -0
  64. package/index_template/vform_demo.gif +0 -0
  65. package/install-render.js +29 -0
  66. package/install.js +41 -0
  67. package/jsconfig.json +10 -0
  68. package/license.txt +8 -0
  69. package/package.json +58 -0
  70. package/public/favicon.ico +0 -0
  71. package/public/index.html +28 -0
  72. package/src/App.vue +22 -0
  73. package/src/assets/ft-images/t1.png +0 -0
  74. package/src/assets/ft-images/t2.png +0 -0
  75. package/src/assets/ft-images/t3.png +0 -0
  76. package/src/assets/ft-images/t4.png +0 -0
  77. package/src/assets/ft-images/t5.png +0 -0
  78. package/src/assets/ft-images/t6.png +0 -0
  79. package/src/assets/ft-images/t7.png +0 -0
  80. package/src/assets/ft-images/t8.png +0 -0
  81. package/src/assets/style.scss +92 -0
  82. package/src/assets/vform-logo.png +0 -0
  83. package/src/components/code-editor/index.vue +130 -0
  84. package/src/components/form-designer/designer.js +926 -0
  85. package/src/components/form-designer/form-widget/container-widget/container-wrapper.vue +107 -0
  86. package/src/components/form-designer/form-widget/container-widget/containerMixin.js +85 -0
  87. package/src/components/form-designer/form-widget/container-widget/grid-col-widget.vue +310 -0
  88. package/src/components/form-designer/form-widget/container-widget/grid-widget.vue +89 -0
  89. package/src/components/form-designer/form-widget/container-widget/index.js +24 -0
  90. package/src/components/form-designer/form-widget/container-widget/tab-widget.vue +119 -0
  91. package/src/components/form-designer/form-widget/container-widget/table-cell-widget.vue +341 -0
  92. package/src/components/form-designer/form-widget/container-widget/table-widget.vue +111 -0
  93. package/src/components/form-designer/form-widget/field-widget/button-widget.vue +87 -0
  94. package/src/components/form-designer/form-widget/field-widget/cascader-widget.vue +104 -0
  95. package/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue +105 -0
  96. package/src/components/form-designer/form-widget/field-widget/color-widget.vue +99 -0
  97. package/src/components/form-designer/form-widget/field-widget/date-range-widget.vue +104 -0
  98. package/src/components/form-designer/form-widget/field-widget/date-widget.vue +103 -0
  99. package/src/components/form-designer/form-widget/field-widget/divider-widget.vue +83 -0
  100. package/src/components/form-designer/form-widget/field-widget/fieldMixin.js +535 -0
  101. package/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue +271 -0
  102. package/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue +331 -0
  103. package/src/components/form-designer/form-widget/field-widget/html-text-widget.vue +82 -0
  104. package/src/components/form-designer/form-widget/field-widget/index.js +10 -0
  105. package/src/components/form-designer/form-widget/field-widget/input-widget.vue +112 -0
  106. package/src/components/form-designer/form-widget/field-widget/number-widget.vue +103 -0
  107. package/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue +226 -0
  108. package/src/components/form-designer/form-widget/field-widget/radio-widget.vue +105 -0
  109. package/src/components/form-designer/form-widget/field-widget/rate-widget.vue +102 -0
  110. package/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue +122 -0
  111. package/src/components/form-designer/form-widget/field-widget/select-widget.vue +115 -0
  112. package/src/components/form-designer/form-widget/field-widget/slider-widget.vue +100 -0
  113. package/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue +189 -0
  114. package/src/components/form-designer/form-widget/field-widget/static-text-widget.vue +82 -0
  115. package/src/components/form-designer/form-widget/field-widget/switch-widget.vue +101 -0
  116. package/src/components/form-designer/form-widget/field-widget/textarea-widget.vue +99 -0
  117. package/src/components/form-designer/form-widget/field-widget/time-range-widget.vue +104 -0
  118. package/src/components/form-designer/form-widget/field-widget/time-widget.vue +103 -0
  119. package/src/components/form-designer/form-widget/index.vue +260 -0
  120. package/src/components/form-designer/index.vue +448 -0
  121. package/src/components/form-designer/setting-panel/form-setting.vue +324 -0
  122. package/src/components/form-designer/setting-panel/index.vue +328 -0
  123. package/src/components/form-designer/setting-panel/option-items-setting.vue +234 -0
  124. package/src/components/form-designer/setting-panel/property-editor/allowCreate-editor.vue +24 -0
  125. package/src/components/form-designer/setting-panel/property-editor/appendButton-editor.vue +28 -0
  126. package/src/components/form-designer/setting-panel/property-editor/appendButtonDisabled-editor.vue +23 -0
  127. package/src/components/form-designer/setting-panel/property-editor/automaticDropdown-editor.vue +23 -0
  128. package/src/components/form-designer/setting-panel/property-editor/border-editor.vue +23 -0
  129. package/src/components/form-designer/setting-panel/property-editor/buttonIcon-editor.vue +23 -0
  130. package/src/components/form-designer/setting-panel/property-editor/buttonStyle-editor.vue +23 -0
  131. package/src/components/form-designer/setting-panel/property-editor/clearable-editor.vue +23 -0
  132. package/src/components/form-designer/setting-panel/property-editor/columnWidth-editor.vue +40 -0
  133. package/src/components/form-designer/setting-panel/property-editor/container-grid/colHeight-editor.vue +28 -0
  134. package/src/components/form-designer/setting-panel/property-editor/container-grid/gutter-editor.vue +81 -0
  135. package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-offset-editor.vue +24 -0
  136. package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-pull-editor.vue +24 -0
  137. package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-push-editor.vue +24 -0
  138. package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-responsive-editor.vue +23 -0
  139. package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-span-editor.vue +48 -0
  140. package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showBlankRow-editor.vue +23 -0
  141. package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showRowNumber-editor.vue +23 -0
  142. package/src/components/form-designer/setting-panel/property-editor/container-sub-form/sub-form-labelAlign-editor.vue +36 -0
  143. package/src/components/form-designer/setting-panel/property-editor/container-tab/tab-customClass-editor.vue +119 -0
  144. package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellHeight-editor.vue +23 -0
  145. package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellWidth-editor.vue +23 -0
  146. package/src/components/form-designer/setting-panel/property-editor/customClass-editor.vue +40 -0
  147. package/src/components/form-designer/setting-panel/property-editor/defaultValue-editor.vue +25 -0
  148. package/src/components/form-designer/setting-panel/property-editor/disabled-editor.vue +23 -0
  149. package/src/components/form-designer/setting-panel/property-editor/displayStyle-editor.vue +26 -0
  150. package/src/components/form-designer/setting-panel/property-editor/editable-editor.vue +24 -0
  151. package/src/components/form-designer/setting-panel/property-editor/endPlaceholder-editor.vue +23 -0
  152. package/src/components/form-designer/setting-panel/property-editor/event-handler/eventMixin.js +12 -0
  153. package/src/components/form-designer/setting-panel/property-editor/event-handler/onBeforeUpload-editor.vue +30 -0
  154. package/src/components/form-designer/setting-panel/property-editor/event-handler/onBlur-editor.vue +30 -0
  155. package/src/components/form-designer/setting-panel/property-editor/event-handler/onChange-editor.vue +30 -0
  156. package/src/components/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +30 -0
  157. package/src/components/form-designer/setting-panel/property-editor/event-handler/onCreated-editor.vue +31 -0
  158. package/src/components/form-designer/setting-panel/property-editor/event-handler/onFocus-editor.vue +30 -0
  159. package/src/components/form-designer/setting-panel/property-editor/event-handler/onInput-editor.vue +30 -0
  160. package/src/components/form-designer/setting-panel/property-editor/event-handler/onMounted-editor.vue +30 -0
  161. package/src/components/form-designer/setting-panel/property-editor/event-handler/onRemoteQuery-editor.vue +30 -0
  162. package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowAdd-editor.vue +30 -0
  163. package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowChange-editor.vue +30 -0
  164. package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowDelete-editor.vue +30 -0
  165. package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowInsert-editor.vue +30 -0
  166. package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadError-editor.vue +30 -0
  167. package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadSuccess-editor.vue +30 -0
  168. package/src/components/form-designer/setting-panel/property-editor/event-handler/onValidate-editor.vue +30 -0
  169. package/src/components/form-designer/setting-panel/property-editor/field-button/button-type-editor.vue +32 -0
  170. package/src/components/form-designer/setting-panel/property-editor/field-button/circle-editor.vue +23 -0
  171. package/src/components/form-designer/setting-panel/property-editor/field-button/icon-editor.vue +23 -0
  172. package/src/components/form-designer/setting-panel/property-editor/field-button/plain-editor.vue +24 -0
  173. package/src/components/form-designer/setting-panel/property-editor/field-button/round-editor.vue +23 -0
  174. package/src/components/form-designer/setting-panel/property-editor/field-color/color-defaultValue-editor.vue +23 -0
  175. package/src/components/form-designer/setting-panel/property-editor/field-date/date-defaultValue-editor.vue +24 -0
  176. package/src/components/form-designer/setting-panel/property-editor/field-date/date-format-editor.vue +30 -0
  177. package/src/components/form-designer/setting-panel/property-editor/field-date/date-type-editor.vue +30 -0
  178. package/src/components/form-designer/setting-panel/property-editor/field-date/date-valueFormat-editor.vue +26 -0
  179. package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultValue-editor.vue +24 -0
  180. package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-format-editor.vue +30 -0
  181. package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-type-editor.vue +27 -0
  182. package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-valueFormat-editor.vue +26 -0
  183. package/src/components/form-designer/setting-panel/property-editor/field-divider/contentPosition-editor.vue +27 -0
  184. package/src/components/form-designer/setting-panel/property-editor/field-file-upload/file-upload-fileTypes-editor.vue +44 -0
  185. package/src/components/form-designer/setting-panel/property-editor/field-html-text/htmlContent-editor.vue +23 -0
  186. package/src/components/form-designer/setting-panel/property-editor/field-number/controlsPosition-editor.vue +27 -0
  187. package/src/components/form-designer/setting-panel/property-editor/field-picture-upload/picture-upload-fileTypes-editor.vue +43 -0
  188. package/src/components/form-designer/setting-panel/property-editor/field-rate/allowHalf-editor.vue +23 -0
  189. package/src/components/form-designer/setting-panel/property-editor/field-rate/highThreshold-editor.vue +24 -0
  190. package/src/components/form-designer/setting-panel/property-editor/field-rate/lowThreshold-editor.vue +24 -0
  191. package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-defaultValue-editor.vue +26 -0
  192. package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-max-editor.vue +25 -0
  193. package/src/components/form-designer/setting-panel/property-editor/field-rate/showScore-editor.vue +23 -0
  194. package/src/components/form-designer/setting-panel/property-editor/field-rate/showText-editor.vue +23 -0
  195. package/src/components/form-designer/setting-panel/property-editor/field-slider/range-editor.vue +23 -0
  196. package/src/components/form-designer/setting-panel/property-editor/field-slider/showStops-editor.vue +23 -0
  197. package/src/components/form-designer/setting-panel/property-editor/field-slider/vertical-editor.vue +23 -0
  198. package/src/components/form-designer/setting-panel/property-editor/field-static-text/textContent-editor.vue +23 -0
  199. package/src/components/form-designer/setting-panel/property-editor/field-switch/activeColor-editor.vue +23 -0
  200. package/src/components/form-designer/setting-panel/property-editor/field-switch/activeText-editor.vue +23 -0
  201. package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveColor-editor.vue +23 -0
  202. package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveText-editor.vue +23 -0
  203. package/src/components/form-designer/setting-panel/property-editor/field-switch/switch-defaultValue-editor.vue +25 -0
  204. package/src/components/form-designer/setting-panel/property-editor/field-switch/switchWidth-editor.vue +23 -0
  205. package/src/components/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +24 -0
  206. package/src/components/form-designer/setting-panel/property-editor/field-time/time-format-editor.vue +27 -0
  207. package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-defaultValue-editor.vue +24 -0
  208. package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-format-editor.vue +27 -0
  209. package/src/components/form-designer/setting-panel/property-editor/fileMaxSize-editor.vue +23 -0
  210. package/src/components/form-designer/setting-panel/property-editor/filterable-editor.vue +23 -0
  211. package/src/components/form-designer/setting-panel/property-editor/hidden-editor.vue +23 -0
  212. package/src/components/form-designer/setting-panel/property-editor/index.js +10 -0
  213. package/src/components/form-designer/setting-panel/property-editor/label-editor.vue +30 -0
  214. package/src/components/form-designer/setting-panel/property-editor/labelAlign-editor.vue +42 -0
  215. package/src/components/form-designer/setting-panel/property-editor/labelHidden-editor.vue +23 -0
  216. package/src/components/form-designer/setting-panel/property-editor/labelIconClass-editor.vue +28 -0
  217. package/src/components/form-designer/setting-panel/property-editor/labelIconPosition-editor.vue +37 -0
  218. package/src/components/form-designer/setting-panel/property-editor/labelTooltip-editor.vue +23 -0
  219. package/src/components/form-designer/setting-panel/property-editor/labelWidth-editor.vue +25 -0
  220. package/src/components/form-designer/setting-panel/property-editor/limit-editor.vue +24 -0
  221. package/src/components/form-designer/setting-panel/property-editor/max-editor.vue +39 -0
  222. package/src/components/form-designer/setting-panel/property-editor/maxLength-editor.vue +40 -0
  223. package/src/components/form-designer/setting-panel/property-editor/min-editor.vue +40 -0
  224. package/src/components/form-designer/setting-panel/property-editor/minLength-editor.vue +41 -0
  225. package/src/components/form-designer/setting-panel/property-editor/multiple-editor.vue +24 -0
  226. package/src/components/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +24 -0
  227. package/src/components/form-designer/setting-panel/property-editor/multipleSelect-editor.vue +24 -0
  228. package/src/components/form-designer/setting-panel/property-editor/name-editor.vue +80 -0
  229. package/src/components/form-designer/setting-panel/property-editor/optionItems-editor.vue +28 -0
  230. package/src/components/form-designer/setting-panel/property-editor/placeholder-editor.vue +24 -0
  231. package/src/components/form-designer/setting-panel/property-editor/precision-editor.vue +23 -0
  232. package/src/components/form-designer/setting-panel/property-editor/prefixIcon-editor.vue +23 -0
  233. package/src/components/form-designer/setting-panel/property-editor/propertyMixin.js +47 -0
  234. package/src/components/form-designer/setting-panel/property-editor/readonly-editor.vue +23 -0
  235. package/src/components/form-designer/setting-panel/property-editor/remote-editor.vue +25 -0
  236. package/src/components/form-designer/setting-panel/property-editor/required-editor.vue +23 -0
  237. package/src/components/form-designer/setting-panel/property-editor/rows-editor.vue +24 -0
  238. package/src/components/form-designer/setting-panel/property-editor/showFileList-editor.vue +23 -0
  239. package/src/components/form-designer/setting-panel/property-editor/showPassword-editor.vue +24 -0
  240. package/src/components/form-designer/setting-panel/property-editor/showWordLimit-editor.vue +23 -0
  241. package/src/components/form-designer/setting-panel/property-editor/size-editor.vue +38 -0
  242. package/src/components/form-designer/setting-panel/property-editor/startPlaceholder-editor.vue +23 -0
  243. package/src/components/form-designer/setting-panel/property-editor/step-editor.vue +23 -0
  244. package/src/components/form-designer/setting-panel/property-editor/suffixIcon-editor.vue +23 -0
  245. package/src/components/form-designer/setting-panel/property-editor/type-editor.vue +33 -0
  246. package/src/components/form-designer/setting-panel/property-editor/uploadTip-editor.vue +24 -0
  247. package/src/components/form-designer/setting-panel/property-editor/uploadURL-editor.vue +28 -0
  248. package/src/components/form-designer/setting-panel/property-editor/validation-editor.vue +48 -0
  249. package/src/components/form-designer/setting-panel/property-editor/validationHint-editor.vue +23 -0
  250. package/src/components/form-designer/setting-panel/property-editor/withCredentials-editor.vue +23 -0
  251. package/src/components/form-designer/setting-panel/property-editor-factory.js +173 -0
  252. package/src/components/form-designer/setting-panel/propertyRegister.js +198 -0
  253. package/src/components/form-designer/toolbar-panel/index.vue +1070 -0
  254. package/src/components/form-designer/widget-panel/index.vue +530 -0
  255. package/src/components/form-designer/widget-panel/templatesConfig.js +58 -0
  256. package/src/components/form-designer/widget-panel/widgetsConfig.js +966 -0
  257. package/src/components/form-render/container-item/container-item-wrapper.vue +34 -0
  258. package/src/components/form-render/container-item/containerItemMixin.js +136 -0
  259. package/src/components/form-render/container-item/grid-col-item.vue +115 -0
  260. package/src/components/form-render/container-item/grid-item.vue +54 -0
  261. package/src/components/form-render/container-item/index.js +24 -0
  262. package/src/components/form-render/container-item/sub-form-item.vue +405 -0
  263. package/src/components/form-render/container-item/tab-item.vue +89 -0
  264. package/src/components/form-render/container-item/table-cell-item.vue +61 -0
  265. package/src/components/form-render/container-item/table-item.vue +65 -0
  266. package/src/components/form-render/index.vue +712 -0
  267. package/src/components/form-render/refMixin.js +22 -0
  268. package/src/components/svg-icon/index.vue +49 -0
  269. package/src/components/v-table/index.vue +106 -0
  270. package/src/extension/extension-helper.js +23 -0
  271. package/src/extension/extension-loader.js +112 -0
  272. package/src/extension/samples/alert/alert-widget.vue +72 -0
  273. package/src/extension/samples/card/card-item.vue +90 -0
  274. package/src/extension/samples/card/card-widget.vue +119 -0
  275. package/src/extension/samples/extension-schema.js +36 -0
  276. package/src/extension/samples/extension-sfc-generator.js +50 -0
  277. package/src/iconfont/iconfont.css +29 -0
  278. package/src/iconfont/iconfont.eot +0 -0
  279. package/src/iconfont/iconfont.js +1 -0
  280. package/src/iconfont/iconfont.json +37 -0
  281. package/src/iconfont/iconfont.svg +35 -0
  282. package/src/iconfont/iconfont.ttf +0 -0
  283. package/src/iconfont/iconfont.woff +0 -0
  284. package/src/iconfont/iconfont.woff2 +0 -0
  285. package/src/icons/index.js +9 -0
  286. package/src/icons/svg/alert.svg +1 -0
  287. package/src/icons/svg/button.svg +1 -0
  288. package/src/icons/svg/card.svg +1 -0
  289. package/src/icons/svg/cascader-field.svg +1 -0
  290. package/src/icons/svg/checkbox-field.svg +1 -0
  291. package/src/icons/svg/color-field.svg +1 -0
  292. package/src/icons/svg/custom-component.svg +1 -0
  293. package/src/icons/svg/data-table.svg +1 -0
  294. package/src/icons/svg/date-field.svg +1 -0
  295. package/src/icons/svg/date-range-field.svg +1 -0
  296. package/src/icons/svg/divider.svg +1 -0
  297. package/src/icons/svg/document.svg +1 -0
  298. package/src/icons/svg/drag.svg +1 -0
  299. package/src/icons/svg/file-upload-field.svg +1 -0
  300. package/src/icons/svg/github.svg +1 -0
  301. package/src/icons/svg/grid.svg +1 -0
  302. package/src/icons/svg/html-text.svg +1 -0
  303. package/src/icons/svg/node-tree.svg +1 -0
  304. package/src/icons/svg/number-field.svg +1 -0
  305. package/src/icons/svg/picture-upload-field.svg +1 -0
  306. package/src/icons/svg/radio-field.svg +1 -0
  307. package/src/icons/svg/rate-field.svg +1 -0
  308. package/src/icons/svg/redo.svg +1 -0
  309. package/src/icons/svg/rich-editor-field.svg +1 -0
  310. package/src/icons/svg/section.svg +1 -0
  311. package/src/icons/svg/select-field.svg +1 -0
  312. package/src/icons/svg/slider-field.svg +1 -0
  313. package/src/icons/svg/slot-component.svg +1 -0
  314. package/src/icons/svg/static-text.svg +1 -0
  315. package/src/icons/svg/sub-form.svg +1 -0
  316. package/src/icons/svg/switch-field.svg +1 -0
  317. package/src/icons/svg/tab.svg +1 -0
  318. package/src/icons/svg/table.svg +1 -0
  319. package/src/icons/svg/text-field.svg +1 -0
  320. package/src/icons/svg/textarea-field.svg +1 -0
  321. package/src/icons/svg/time-field.svg +1 -0
  322. package/src/icons/svg/time-range-field.svg +1 -0
  323. package/src/icons/svg/undo.svg +1 -0
  324. package/src/icons/svg/vue-sfc.svg +1 -0
  325. package/src/index.js +41 -0
  326. package/src/lang/en-US.js +321 -0
  327. package/src/lang/en-US_extension.js +26 -0
  328. package/src/lang/en-US_render.js +38 -0
  329. package/src/lang/zh-CN.js +321 -0
  330. package/src/lang/zh-CN_extension.js +26 -0
  331. package/src/lang/zh-CN_render.js +38 -0
  332. package/src/main.js +29 -0
  333. package/src/styles/global.scss +103 -0
  334. package/src/styles/index.scss +15 -0
  335. package/src/utils/beautifierLoader.js +77 -0
  336. package/src/utils/code-generator.js +91 -0
  337. package/src/utils/config.js +19 -0
  338. package/src/utils/debug-console.js +7 -0
  339. package/src/utils/directive.js +74 -0
  340. package/src/utils/i18n.js +70 -0
  341. package/src/utils/sfc-generator.js +583 -0
  342. package/src/utils/util.js +232 -0
  343. package/src/utils/validators.js +127 -0
  344. package/src/utils/vue2js-generator.js +144 -0
  345. package/src/utils/vue3js-generator.js +70 -0
  346. package/vue.config.js +92 -0
@@ -0,0 +1,926 @@
1
+ /**
2
+ * author: vformAdmin
3
+ * email: vdpadmin@163.com
4
+ * website: https://www.vform666.com
5
+ * date: 2021.08.18
6
+ * remark: 如果要分发VForm源码,需在本文件顶部保留此文件头信息!!
7
+ */
8
+
9
+ import {deepClone, generateId, overwriteObj} from "@/utils/util"
10
+ import {containers, advancedFields, basicFields, customFields} from "@/components/form-designer/widget-panel/widgetsConfig.js"
11
+ import {VARIANT_FORM_VERSION} from "@/utils/config"
12
+
13
+ export function createDesigner(vueInstance) {
14
+ let defaultFormConfig = {
15
+ modelName: 'formData',
16
+ refName: 'vForm',
17
+ rulesName: 'rules',
18
+ labelWidth: 80,
19
+ labelPosition: 'left',
20
+ size: '',
21
+ labelAlign: 'label-left-align',
22
+ cssCode: '',
23
+ customClass: '',
24
+ functions: '',
25
+ layoutType: 'PC',
26
+
27
+ onFormCreated: '',
28
+ onFormMounted: '',
29
+ onFormDataChange: '',
30
+ }
31
+
32
+ return {
33
+ widgetList: [],
34
+ formConfig: {cssCode: ''},
35
+
36
+ selectedId: null,
37
+ selectedWidget: null,
38
+ selectedWidgetName: null, //选中组件名称(唯一)
39
+ vueInstance: vueInstance,
40
+
41
+ formWidget: null, //表单设计容器
42
+
43
+ cssClassList: [], //自定义样式列表
44
+
45
+ historyData: {
46
+ index: -1, //index: 0,
47
+ maxStep: 20,
48
+ steps: [],
49
+ },
50
+
51
+ initDesigner() {
52
+ this.widgetList = []
53
+ this.formConfig = deepClone(defaultFormConfig)
54
+
55
+ //输出版本信息和语雀链接
56
+ console.info(`%cVariantForm %cVer${VARIANT_FORM_VERSION} %chttps://www.yuque.com/variantdev/vform`,
57
+ "color:#409EFF;font-size: 22px;font-weight:bolder",
58
+ "color:#999;font-size: 12px",
59
+ "color:#333"
60
+ )
61
+
62
+ this.initHistoryData()
63
+ },
64
+
65
+ clearDesigner(skipHistoryChange) {
66
+ let emptyWidgetListFlag = (this.widgetList.length === 0)
67
+ this.widgetList = []
68
+ this.selectedId = null
69
+ this.selectedWidgetName = null
70
+ this.selectedWidget = {} //this.selectedWidget = null
71
+ overwriteObj(this.formConfig, defaultFormConfig) //
72
+
73
+ if (!!skipHistoryChange) {
74
+ //什么也不做!!
75
+ } else if (!emptyWidgetListFlag) {
76
+ this.emitHistoryChange()
77
+ } else {
78
+ this.saveCurrentHistoryStep()
79
+ }
80
+ },
81
+
82
+ loadPresetCssCode(preCssCode) {
83
+ if ((this.formConfig.cssCode === '') && !!preCssCode) {
84
+ this.formConfig.cssCode = preCssCode
85
+ }
86
+ },
87
+
88
+ getLayoutType() {
89
+ return this.formConfig.layoutType || 'PC'
90
+ },
91
+
92
+ changeLayoutType(newType) {
93
+ this.formConfig.layoutType = newType
94
+ },
95
+
96
+ getImportTemplate() {
97
+ return {
98
+ widgetList: [],
99
+ formConfig: deepClone(this.formConfig)
100
+ }
101
+ },
102
+
103
+ loadFormJson(formJson) {
104
+ let modifiedFlag = false
105
+
106
+ if (!!formJson && !!formJson.widgetList) {
107
+ this.widgetList = formJson.widgetList
108
+ modifiedFlag = true
109
+ }
110
+ if (!!formJson && !!formJson.formConfig) {
111
+ //this.formConfig = importObj.formConfig
112
+ overwriteObj(this.formConfig, formJson.formConfig) /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
113
+ modifiedFlag = true
114
+ }
115
+
116
+ return modifiedFlag
117
+ },
118
+
119
+ setSelected(selected) {
120
+ if (!selected) {
121
+ this.clearSelected()
122
+ return
123
+ }
124
+
125
+ this.selectedWidget = selected
126
+ if (!!selected.id) {
127
+ this.selectedId = selected.id
128
+ this.selectedWidgetName = selected.options.name
129
+ }
130
+ },
131
+
132
+ updateSelectedWidgetNameAndRef(selectedWidget, newName, newLabel) {
133
+ this.selectedWidgetName = newName
134
+ //selectedWidget.options.name = newName //此行多余
135
+ if (!!newLabel && (Object.keys(selectedWidget.options).indexOf('label') > -1)) {
136
+ selectedWidget.options.label = newLabel
137
+ }
138
+ },
139
+
140
+ clearSelected() {
141
+ this.selectedId = null
142
+ this.selectedWidgetName = null
143
+ this.selectedWidget = {} //this.selectedWidget = null
144
+ },
145
+
146
+ checkWidgetMove(evt) { /* Only field widget can be dragged into sub-form */
147
+ if (!!evt.draggedContext && !!evt.draggedContext.element) {
148
+ let wgCategory = evt.draggedContext.element.category
149
+ if (!!evt.to) {
150
+ if ((evt.to.className === 'sub-form-table') && (wgCategory === 'container')) {
151
+ //this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
152
+ return false
153
+ }
154
+ }
155
+ }
156
+
157
+ return true
158
+ },
159
+
160
+ /**
161
+ * 追加表格新行
162
+ * @param widget
163
+ */
164
+ appendTableRow(widget) {
165
+ let rowIdx = widget.rows.length//确定插入行位置
166
+ let newRow = deepClone(widget.rows[widget.rows.length - 1])
167
+ newRow.id = 'table-row-' + generateId()
168
+ newRow.merged = false
169
+ newRow.cols.forEach(col => {
170
+ col.id = 'table-cell-' + generateId()
171
+ col.options.name = col.id
172
+ col.merged = false
173
+ col.options.colspan = 1
174
+ col.options.rowspan = 1
175
+ col.widgetList.length = 0
176
+ })
177
+ widget.rows.splice(rowIdx, 0, newRow)
178
+
179
+ this.emitHistoryChange()
180
+ },
181
+
182
+ /**
183
+ * 追加表格新列
184
+ * @param widget
185
+ */
186
+ appendTableCol(widget) {
187
+ let colIdx = widget.rows[0].cols.length //确定插入列位置
188
+ widget.rows.forEach(row => {
189
+ let newCol = deepClone(this.getContainerByType('table-cell'))
190
+ newCol.id = 'table-cell-' + generateId()
191
+ newCol.options.name = newCol.id
192
+ newCol.merged = false
193
+ newCol.options.colspan = 1
194
+ newCol.options.rowspan = 1
195
+ newCol.widgetList.length = 0
196
+ row.cols.splice(colIdx, 0, newCol)
197
+ })
198
+
199
+ this.emitHistoryChange()
200
+ },
201
+
202
+ insertTableRow(widget, insertPos, cloneRowIdx, curCol, aboveFlag) {
203
+ let newRowIdx = !!aboveFlag ? insertPos : (insertPos + 1) //初步确定插入行位置
204
+ if (!aboveFlag) { //继续向下寻找同列第一个未被合并的单元格
205
+ let tmpRowIdx = newRowIdx
206
+ let rowFoundFlag = false
207
+ while (tmpRowIdx < widget.rows.length) {
208
+ if (!widget.rows[tmpRowIdx].cols[curCol].merged) {
209
+ newRowIdx = tmpRowIdx
210
+ rowFoundFlag = true
211
+ break
212
+ } else {
213
+ tmpRowIdx++
214
+ }
215
+ }
216
+
217
+ if (!rowFoundFlag) {
218
+ newRowIdx = widget.rows.length
219
+ }
220
+ }
221
+
222
+ let newRow = deepClone( widget.rows[cloneRowIdx] )
223
+ newRow.id = 'table-row-' + generateId()
224
+ newRow.merged = false
225
+ newRow.cols.forEach(col => {
226
+ col.id = 'table-cell-' + generateId()
227
+ col.options.name = col.id
228
+ col.merged = false
229
+ col.options.colspan = 1
230
+ col.options.rowspan = 1
231
+ col.widgetList.length = 0
232
+ })
233
+ widget.rows.splice(newRowIdx, 0, newRow)
234
+
235
+ let colNo = 0
236
+ while ((newRowIdx < widget.rows.length - 1) && (colNo < widget.rows[0].cols.length)) { //越界判断
237
+ const cellOfNextRow = widget.rows[newRowIdx + 1].cols[colNo]
238
+ const rowMerged = cellOfNextRow.merged //确定插入位置下一行的单元格是否为合并单元格
239
+ if (!!rowMerged) {
240
+ let rowArray = widget.rows
241
+ let unMergedCell = {}
242
+ let startRowIndex = null
243
+ for (let i = newRowIdx; i >= 0; i--) { //查找该行已合并的主单元格
244
+ if (!rowArray[i].cols[colNo].merged && (rowArray[i].cols[colNo].options.rowspan > 1)) {
245
+ startRowIndex = i
246
+ unMergedCell = rowArray[i].cols[colNo]
247
+ break
248
+ }
249
+ }
250
+
251
+ if (!!unMergedCell.options) { //如果有符合条件的unMergedCell
252
+ let newRowspan = unMergedCell.options.rowspan + 1
253
+ this.setPropsOfMergedRows(widget.rows, startRowIndex, colNo, unMergedCell.options.colspan, newRowspan)
254
+ colNo += unMergedCell.options.colspan
255
+ } else {
256
+ colNo += 1
257
+ }
258
+ } else {
259
+ //colNo += 1
260
+ colNo += cellOfNextRow.options.colspan || 1
261
+ }
262
+ }
263
+
264
+ this.emitHistoryChange()
265
+ },
266
+
267
+ insertTableCol(widget, insertPos, curRow, leftFlag) {
268
+ let newColIdx = !!leftFlag ? insertPos : (insertPos + 1) //初步确定插入列位置
269
+ if (!leftFlag) { //继续向右寻找同行第一个未被合并的单元格
270
+ let tmpColIdx = newColIdx
271
+ let colFoundFlag = false
272
+ while (tmpColIdx < widget.rows[curRow].cols.length) {
273
+ if (!widget.rows[curRow].cols[tmpColIdx].merged) {
274
+ newColIdx = tmpColIdx
275
+ colFoundFlag = true
276
+ break
277
+ } else {
278
+ tmpColIdx++
279
+ }
280
+
281
+ if (!colFoundFlag) {
282
+ newColIdx = widget.rows[curRow].cols.length
283
+ }
284
+ }
285
+ }
286
+
287
+ widget.rows.forEach(row => {
288
+ let newCol = deepClone(this.getContainerByType('table-cell'))
289
+ newCol.id = 'table-cell-' + generateId()
290
+ newCol.options.name = newCol.id
291
+ newCol.merged = false
292
+ newCol.options.colspan = 1
293
+ newCol.options.rowspan = 1
294
+ newCol.widgetList.length = 0
295
+ row.cols.splice(newColIdx, 0, newCol)
296
+ })
297
+
298
+ let rowNo = 0
299
+ while((newColIdx < widget.rows[0].cols.length - 1) && (rowNo < widget.rows.length)) { //越界判断
300
+ const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1]
301
+ const colMerged = cellOfNextCol.merged //确定插入位置右侧列的单元格是否为合并单元格
302
+ if (!!colMerged) {
303
+ let colArray = widget.rows[rowNo].cols
304
+ let unMergedCell = {}
305
+ let startColIndex = null
306
+ for (let i = newColIdx; i >= 0; i--) { //查找该行已合并的主单元格
307
+ if (!colArray[i].merged && (colArray[i].options.colspan > 1)) {
308
+ startColIndex = i
309
+ unMergedCell = colArray[i]
310
+ break
311
+ }
312
+ }
313
+
314
+ if (!!unMergedCell.options) { //如果有符合条件的unMergedCell
315
+ let newColspan = unMergedCell.options.colspan + 1
316
+ this.setPropsOfMergedCols(widget.rows, rowNo, startColIndex, newColspan, unMergedCell.options.rowspan)
317
+ rowNo += unMergedCell.options.rowspan
318
+ } else {
319
+ rowNo += 1
320
+ }
321
+ } else {
322
+ //rowNo += 1
323
+ rowNo += cellOfNextCol.options.rowspan || 1
324
+ }
325
+ }
326
+
327
+ this.emitHistoryChange()
328
+ },
329
+
330
+ setPropsOfMergedCols(rowArray, startRowIndex, startColIndex, newColspan, rowspan) {
331
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
332
+ for (let j = startColIndex; j < startColIndex + newColspan; j++) {
333
+ if ((i === startRowIndex) && (j === startColIndex)) {
334
+ rowArray[i].cols[j].options.colspan = newColspan //合并后的主单元格
335
+ continue
336
+ }
337
+
338
+ rowArray[i].cols[j].merged = true
339
+ rowArray[i].cols[j].options.colspan = newColspan
340
+ rowArray[i].cols[j].widgetList = []
341
+ }
342
+ }
343
+ },
344
+
345
+ setPropsOfMergedRows(rowArray, startRowIndex, startColIndex, colspan, newRowspan) {
346
+ for (let i = startRowIndex; i < startRowIndex + newRowspan; i++) {
347
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
348
+ if ((i === startRowIndex) && (j === startColIndex)) {
349
+ rowArray[i].cols[j].options.rowspan = newRowspan
350
+ continue
351
+ }
352
+
353
+ rowArray[i].cols[j].merged = true
354
+ rowArray[i].cols[j].options.rowspan = newRowspan
355
+ rowArray[i].cols[j].widgetList = []
356
+ }
357
+ }
358
+ },
359
+
360
+ setPropsOfSplitCol(rowArray, startRowIndex, startColIndex, colspan, rowspan) {
361
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
362
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
363
+ rowArray[i].cols[j].merged = false;
364
+ rowArray[i].cols[j].options.rowspan = 1
365
+ rowArray[i].cols[j].options.colspan = 1
366
+ }
367
+ }
368
+ },
369
+
370
+ setPropsOfSplitRow(rowArray, startRowIndex, startColIndex, colspan, rowspan) {
371
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
372
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
373
+ rowArray[i].cols[j].merged = false;
374
+ rowArray[i].cols[j].options.rowspan = 1
375
+ rowArray[i].cols[j].options.colspan = 1
376
+ }
377
+ }
378
+ },
379
+
380
+ mergeTableCol(rowArray, colArray, curRow, curCol, leftFlag, cellWidget) {
381
+ let mergedColIdx = !!leftFlag ? curCol : curCol + colArray[curCol].options.colspan
382
+
383
+ // let remainedColIdx = !!leftFlag ? curCol - colArray[curCol - 1].options.colspan : curCol
384
+ let remainedColIdx = !!leftFlag ? curCol - 1 : curCol
385
+ if (!!leftFlag) { //继续向左寻找同行未被合并的第一个单元格
386
+ let tmpColIdx = remainedColIdx
387
+ while (tmpColIdx >= 0) {
388
+ if (!rowArray[curRow].cols[tmpColIdx].merged) {
389
+ remainedColIdx = tmpColIdx
390
+ break;
391
+ } else {
392
+ tmpColIdx--
393
+ }
394
+ }
395
+ }
396
+
397
+ if (!!colArray[mergedColIdx].widgetList && (colArray[mergedColIdx].widgetList.length > 0)) { //保留widgetList
398
+ if (!colArray[remainedColIdx].widgetList || (colArray[remainedColIdx].widgetList.length === 0)) {
399
+ colArray[remainedColIdx].widgetList = deepClone(colArray[mergedColIdx].widgetList)
400
+ }
401
+ }
402
+
403
+ let newColspan = colArray[mergedColIdx].options.colspan * 1 + colArray[remainedColIdx].options.colspan * 1
404
+ this.setPropsOfMergedCols(rowArray, curRow, remainedColIdx, newColspan, cellWidget.options.rowspan)
405
+
406
+ this.emitHistoryChange()
407
+ },
408
+
409
+ mergeTableWholeRow(rowArray, colArray, rowIndex, colIndex) { //需要考虑操作的行存在已合并的单元格!!
410
+ //整行所有单元格行高不一致不可合并!!
411
+ let startRowspan = rowArray[rowIndex].cols[0].options.rowspan
412
+ let unmatchedFlag = false
413
+ for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
414
+ if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
415
+ unmatchedFlag = true
416
+ break;
417
+ }
418
+ }
419
+ if (unmatchedFlag) {
420
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.rowspanNotConsistentForMergeEntireRow'))
421
+ return
422
+ }
423
+
424
+ let widgetListCols = colArray.filter((colItem) => {
425
+ return !colItem.merged && !!colItem.widgetList && (colItem.widgetList.length > 0)
426
+ })
427
+ if (!!widgetListCols && (widgetListCols.length > 0)) { //保留widgetList
428
+ if ((widgetListCols[0].id !== colArray[0].id) && (!colArray[0].widgetList ||
429
+ colArray[0].widgetList.length <= 0)) {
430
+ colArray[0].widgetList = deepClone( widgetListCols[0].widgetList )
431
+ }
432
+ }
433
+
434
+ this.setPropsOfMergedCols(rowArray, rowIndex, 0, colArray.length, colArray[colIndex].options.rowspan)
435
+
436
+ this.emitHistoryChange()
437
+ },
438
+
439
+ mergeTableRow(rowArray, curRow, curCol, aboveFlag, cellWidget) {
440
+ let mergedRowIdx = !!aboveFlag ? curRow : curRow + cellWidget.options.rowspan
441
+
442
+ //let remainedRowIdx = !!aboveFlag ? curRow - cellWidget.options.rowspan : curRow
443
+ let remainedRowIdx = !!aboveFlag ? curRow - 1 : curRow
444
+ if (!!aboveFlag) { //继续向上寻找同列未被合并的第一个单元格
445
+ let tmpRowIdx = remainedRowIdx
446
+ while (tmpRowIdx >= 0) {
447
+ if (!rowArray[tmpRowIdx].cols[curCol].merged) {
448
+ remainedRowIdx = tmpRowIdx
449
+ break;
450
+ } else {
451
+ tmpRowIdx--
452
+ }
453
+ }
454
+ }
455
+
456
+ if (!!rowArray[mergedRowIdx].cols[curCol].widgetList && (rowArray[mergedRowIdx].cols[curCol].widgetList.length > 0)) { //保留widgetList
457
+ if (!rowArray[remainedRowIdx].cols[curCol].widgetList || (rowArray[remainedRowIdx].cols[curCol].widgetList.length === 0)) {
458
+ rowArray[remainedRowIdx].cols[curCol].widgetList = deepClone(rowArray[mergedRowIdx].cols[curCol].widgetList)
459
+ }
460
+ }
461
+
462
+ let newRowspan = rowArray[mergedRowIdx].cols[curCol].options.rowspan * 1 + rowArray[remainedRowIdx].cols[curCol].options.rowspan * 1
463
+ this.setPropsOfMergedRows(rowArray, remainedRowIdx, curCol, cellWidget.options.colspan, newRowspan)
464
+
465
+ this.emitHistoryChange()
466
+ },
467
+
468
+ mergeTableWholeCol(rowArray, colArray, rowIndex, colIndex) { //需要考虑操作的列存在已合并的单元格!!
469
+ //整列所有单元格列宽不一致不可合并!!
470
+ let startColspan = rowArray[0].cols[colIndex].options.colspan
471
+ let unmatchedFlag = false
472
+ for (let i = 1; i < rowArray.length; i++) {
473
+ if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
474
+ unmatchedFlag = true
475
+ break;
476
+ }
477
+ }
478
+ if (unmatchedFlag) {
479
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.colspanNotConsistentForMergeEntireColumn'))
480
+ return
481
+ }
482
+
483
+ let widgetListCols = []
484
+ rowArray.forEach(rowItem => {
485
+ let tempCell = rowItem.cols[colIndex]
486
+ if (!tempCell.merged && !!tempCell.widgetList && (tempCell.widgetList.length > 0)) {
487
+ widgetListCols.push(tempCell)
488
+ }
489
+ })
490
+
491
+ let firstCellOfCol = rowArray[0].cols[colIndex]
492
+ if (!!widgetListCols && (widgetListCols.length > 0)) { //保留widgetList
493
+ if ((widgetListCols[0].id !== firstCellOfCol.id) && (!firstCellOfCol.widgetList ||
494
+ firstCellOfCol.widgetList.length <= 0)) {
495
+ firstCellOfCol.widgetList = deepClone( widgetListCols[0].widgetList )
496
+ }
497
+ }
498
+
499
+ this.setPropsOfMergedRows(rowArray, 0, colIndex, firstCellOfCol.options.colspan, rowArray.length)
500
+
501
+ this.emitHistoryChange()
502
+ },
503
+
504
+ undoMergeTableCol(rowArray, rowIndex, colIndex, colspan, rowspan) {
505
+ this.setPropsOfSplitCol(rowArray, rowIndex, colIndex, colspan, rowspan)
506
+
507
+ this.emitHistoryChange()
508
+ },
509
+
510
+ undoMergeTableRow(rowArray, rowIndex, colIndex, colspan, rowspan) {
511
+ this.setPropsOfSplitRow(rowArray, rowIndex, colIndex, colspan, rowspan)
512
+
513
+ this.emitHistoryChange()
514
+ },
515
+
516
+ deleteTableWholeCol(rowArray, colIndex) { //需考虑删除的是合并列!!
517
+ let onlyOneColFlag = true
518
+ rowArray.forEach(ri => {
519
+ if (ri.cols[0].options.colspan !== rowArray[0].cols.length) {
520
+ onlyOneColFlag = false
521
+ }
522
+ })
523
+ //仅剩一列则不可删除!!
524
+ if (onlyOneColFlag) {
525
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.lastColCannotBeDeleted'))
526
+ return
527
+ }
528
+
529
+ //整列所有单元格列宽不一致不可删除!!
530
+ let startColspan = rowArray[0].cols[colIndex].options.colspan
531
+ let unmatchedFlag = false
532
+ for (let i = 1; i < rowArray.length; i++) {
533
+ if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
534
+ unmatchedFlag = true
535
+ break;
536
+ }
537
+ }
538
+ if (unmatchedFlag) {
539
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.colspanNotConsistentForDeleteEntireColumn'))
540
+ return
541
+ }
542
+
543
+ rowArray.forEach((rItem) => {
544
+ rItem.cols.splice(colIndex, startColspan)
545
+ })
546
+
547
+ this.emitHistoryChange()
548
+ },
549
+
550
+ deleteTableWholeRow(rowArray, rowIndex) { //需考虑删除的是合并行!!
551
+ let onlyOneRowFlag = true
552
+ rowArray[0].cols.forEach(ci => {
553
+ if (ci.options.rowspan !== rowArray.length) {
554
+ onlyOneRowFlag = false
555
+ }
556
+ })
557
+ //仅剩一行则不可删除!!
558
+ if (onlyOneRowFlag) {
559
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.lastRowCannotBeDeleted'))
560
+ return
561
+ }
562
+
563
+ //整行所有单元格行高不一致不可删除!!
564
+ let startRowspan = rowArray[rowIndex].cols[0].options.rowspan
565
+ let unmatchedFlag = false
566
+ for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
567
+ if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
568
+ unmatchedFlag = true
569
+ break;
570
+ }
571
+ }
572
+ if (unmatchedFlag) {
573
+ this.vueInstance.$message.info(this.vueInstance.i18nt('designer.hint.rowspanNotConsistentForDeleteEntireRow'))
574
+ return
575
+ }
576
+
577
+ rowArray.splice(rowIndex, startRowspan)
578
+
579
+ this.emitHistoryChange()
580
+ },
581
+
582
+ getContainerByType(typeName) {
583
+ let allWidgets = [...containers, ...basicFields, ...advancedFields, ...customFields]
584
+ let foundCon = null
585
+ allWidgets.forEach(con => {
586
+ if (!!con.category && !!con.type && (con.type === typeName)) {
587
+ foundCon = con
588
+ }
589
+ })
590
+
591
+ return foundCon
592
+ },
593
+
594
+ getFieldWidgetByType(typeName) {
595
+ let allWidgets = [...containers, ...basicFields, ...advancedFields, ...customFields]
596
+ let foundWidget = null
597
+ allWidgets.forEach(widget => {
598
+ if (!!!widget.category && !!widget.type && (widget.type === typeName)) {
599
+ foundWidget = widget
600
+ }
601
+ })
602
+
603
+ return foundWidget
604
+ },
605
+
606
+ hasConfig(widget, configName) {
607
+ let originalWidget = null
608
+ if (!!widget.category) {
609
+ originalWidget = this.getContainerByType(widget.type)
610
+ } else {
611
+ originalWidget = this.getFieldWidgetByType(widget.type)
612
+ }
613
+
614
+ if (!originalWidget || !originalWidget.options) {
615
+ return false
616
+ }
617
+
618
+ return Object.keys(originalWidget.options).indexOf(configName) > -1
619
+ },
620
+
621
+ cloneGridCol(widget, parentWidget) {
622
+ let newGridCol = deepClone(this.getContainerByType('grid-col'))
623
+ newGridCol.options.span = widget.options.span
624
+ let tmpId = generateId()
625
+ newGridCol.id = 'grid-col-' + tmpId
626
+ newGridCol.options.name = 'gridCol' + tmpId
627
+
628
+ parentWidget.cols.push(newGridCol)
629
+ },
630
+
631
+ cloneContainer(containWidget) {
632
+ if (containWidget.type === 'grid') {
633
+ let newGrid = deepClone(this.getContainerByType('grid'))
634
+ newGrid.id = newGrid.type + generateId()
635
+ newGrid.options.name = newGrid.id
636
+ containWidget.cols.forEach(gridCol => {
637
+ let newGridCol = deepClone(this.getContainerByType('grid-col'))
638
+ let tmpId = generateId()
639
+ newGridCol.id = 'grid-col-' + tmpId
640
+ newGridCol.options.name = 'gridCol' + tmpId
641
+ newGridCol.options.span = gridCol.options.span
642
+ newGrid.cols.push(newGridCol)
643
+ })
644
+
645
+ return newGrid
646
+ } else if (containWidget.type === 'table') {
647
+ let newTable = deepClone(this.getContainerByType('table'))
648
+ newTable.id = newTable.type + generateId()
649
+ newTable.options.name = newTable.id
650
+ containWidget.rows.forEach(tRow => {
651
+ let newRow = deepClone(tRow)
652
+ newRow.id = 'table-row-' + generateId()
653
+ newRow.cols.forEach(col => {
654
+ col.id = 'table-cell-' + generateId()
655
+ col.options.name = col.id
656
+ col.widgetList = [] //清空组件列表
657
+ })
658
+ newTable.rows.push(newRow)
659
+ })
660
+
661
+ return newTable
662
+ } else { //其他容器组件不支持clone操作
663
+ return null
664
+ }
665
+ },
666
+
667
+ moveUpWidget(parentList, indexOfParentList) {
668
+ if (!!parentList) {
669
+ if (indexOfParentList === 0) {
670
+ this.vueInstance.$message(this.vueInstance.i18nt('designer.hint.moveUpFirstChildHint'))
671
+ return
672
+ }
673
+
674
+ let tempWidget = parentList[indexOfParentList]
675
+ parentList.splice(indexOfParentList, 1)
676
+ parentList.splice(indexOfParentList - 1, 0, tempWidget)
677
+ }
678
+ },
679
+
680
+ moveDownWidget(parentList, indexOfParentList) {
681
+ if (!!parentList) {
682
+ if (indexOfParentList === parentList.length - 1) {
683
+ this.vueInstance.$message(this.vueInstance.i18nt('designer.hint.moveDownLastChildHint'))
684
+ return
685
+ }
686
+
687
+ let tempWidget = parentList[indexOfParentList]
688
+ parentList.splice(indexOfParentList, 1)
689
+ parentList.splice(indexOfParentList + 1, 0, tempWidget)
690
+ }
691
+ },
692
+
693
+ copyNewFieldWidget(origin) {
694
+ let newWidget = deepClone(origin)
695
+ let tempId = generateId()
696
+ newWidget.id = newWidget.type.replace(/-/g, '') + tempId
697
+ newWidget.options.name = newWidget.id
698
+ newWidget.options.label = newWidget.type.toLowerCase()
699
+
700
+ delete newWidget.displayName
701
+ return newWidget
702
+ },
703
+
704
+ copyNewContainerWidget(origin) {
705
+ let newCon = deepClone(origin)
706
+ newCon.id = newCon.type.replace(/-/g, '') + generateId()
707
+ newCon.options.name = newCon.id
708
+ if (newCon.type === 'grid') {
709
+ let newCol = deepClone( this.getContainerByType('grid-col') )
710
+ let tmpId = generateId()
711
+ newCol.id = 'grid-col-' + tmpId
712
+ newCol.options.name = 'gridCol' + tmpId
713
+ newCon.cols.push(newCol)
714
+ //
715
+ newCol = deepClone(newCol)
716
+ tmpId = generateId()
717
+ newCol.id = 'grid-col-' + tmpId
718
+ newCol.options.name = 'gridCol' + tmpId
719
+ newCon.cols.push(newCol)
720
+ } else if (newCon.type === 'table') {
721
+ let newRow = {cols: []}
722
+ newRow.id = 'table-row-' + generateId()
723
+ newRow.merged = false
724
+ let newCell = deepClone( this.getContainerByType('table-cell') )
725
+ newCell.id = 'table-cell-' + generateId()
726
+ newCell.options.name = newCell.id
727
+ newCell.merged = false
728
+ newCell.options.colspan = 1
729
+ newCell.options.rowspan = 1
730
+ newRow.cols.push(newCell)
731
+ newCon.rows.push(newRow)
732
+ } else if (newCon.type === 'tab') {
733
+ let newTabPane = deepClone( this.getContainerByType('tab-pane') )
734
+ newTabPane.id = 'tab-pane-' + generateId()
735
+ newTabPane.options.name = 'tab1'
736
+ newTabPane.options.label = 'tab 1'
737
+ newCon.tabs.push(newTabPane)
738
+ }
739
+ //newCon.options.customClass = []
740
+
741
+ delete newCon.displayName
742
+ return newCon
743
+ },
744
+
745
+ addContainerByDbClick(container) {
746
+ let newCon = this.copyNewContainerWidget(container)
747
+ this.widgetList.push(newCon)
748
+ this.setSelected(newCon)
749
+ },
750
+
751
+ addFieldByDbClick(widget) {
752
+ let newWidget = this.copyNewFieldWidget(widget)
753
+ if (!!this.selectedWidget && this.selectedWidget.type === 'tab') {
754
+ //获取当前激活的tabPane
755
+ let activeTab = this.selectedWidget.tabs[0]
756
+ this.selectedWidget.tabs.forEach(tabPane => {
757
+ if (!!tabPane.options.active) {
758
+ activeTab = tabPane
759
+ }
760
+ })
761
+
762
+ !!activeTab && activeTab.widgetList.push(newWidget)
763
+ } else if (!!this.selectedWidget && !!this.selectedWidget.widgetList) {
764
+ this.selectedWidget.widgetList.push(newWidget)
765
+ } else {
766
+ this.widgetList.push(newWidget)
767
+ }
768
+
769
+ this.setSelected(newWidget)
770
+ this.emitHistoryChange()
771
+ },
772
+
773
+ deleteColOfGrid(gridWidget, colIdx) {
774
+ if (!!gridWidget && !!gridWidget.cols) {
775
+ gridWidget.cols.splice(colIdx, 1)
776
+ }
777
+ },
778
+
779
+ addNewColOfGrid(gridWidget) {
780
+ const cols = gridWidget.cols
781
+ let newGridCol = deepClone(this.getContainerByType('grid-col'))
782
+ let tmpId = generateId()
783
+ newGridCol.id = 'grid-col-' + tmpId
784
+ newGridCol.options.name = 'gridCol' + tmpId
785
+ if ((!!cols) && (cols.length > 0)) {
786
+ let spanSum = 0
787
+ cols.forEach((col) => {
788
+ spanSum += col.options.span
789
+ })
790
+
791
+ if (spanSum >= 24) {
792
+ //this.$message.info('列栅格之和超出24')
793
+ console.log('列栅格之和超出24')
794
+ gridWidget.cols.push(newGridCol)
795
+ } else {
796
+ newGridCol.options.span = (24 - spanSum) > 12 ? 12 : (24 - spanSum)
797
+ gridWidget.cols.push(newGridCol)
798
+ }
799
+ } else {
800
+ gridWidget.cols = [newGridCol]
801
+ }
802
+ },
803
+
804
+ addTabPaneOfTabs(tabsWidget) {
805
+ const tabPanes = tabsWidget.tabs
806
+ let newTabPane = deepClone( this.getContainerByType('tab-pane') )
807
+ newTabPane.id = 'tab-pane-' + generateId()
808
+ newTabPane.options.name = newTabPane.id
809
+ newTabPane.options.label = 'tab ' + (tabPanes.length + 1)
810
+ tabPanes.push(newTabPane)
811
+ },
812
+
813
+ deleteTabPaneOfTabs(tabsWidget, tpIdx) {
814
+ tabsWidget.tabs.splice(tpIdx, 1)
815
+ },
816
+
817
+ emitEvent(evtName, evtData) { //用于兄弟组件发射事件
818
+ this.vueInstance.$emit(evtName, evtData)
819
+ },
820
+
821
+ handleEvent(evtName, callback) { //用于兄弟组件接收事件
822
+ this.vueInstance.$on(evtName, (data) => callback(data))
823
+ },
824
+
825
+ setCssClassList(cssClassList) {
826
+ this.cssClassList = cssClassList
827
+ },
828
+
829
+ getCssClassList() {
830
+ return this.cssClassList
831
+ },
832
+
833
+ registerFormWidget(formWidget) {
834
+ this.formWidget = formWidget
835
+ },
836
+
837
+ initHistoryData() {
838
+ this.loadFormContentFromStorage()
839
+ this.historyData.index++
840
+ this.historyData.steps[this.historyData.index] = ({
841
+ widgetList: deepClone(this.widgetList),
842
+ formConfig: deepClone(this.formConfig)
843
+ })
844
+ },
845
+
846
+ emitHistoryChange() {
847
+ //console.log('------------', 'Form history changed!')
848
+
849
+ if (this.historyData.index === this.historyData.maxStep - 1) {
850
+ this.historyData.steps.shift()
851
+ } else {
852
+ this.historyData.index++
853
+ }
854
+
855
+ this.historyData.steps[this.historyData.index] = ({
856
+ widgetList: deepClone(this.widgetList),
857
+ formConfig: deepClone(this.formConfig)
858
+ })
859
+
860
+ this.saveFormContentToStorage()
861
+
862
+ if (this.historyData.index < this.historyData.steps.length - 1) {
863
+ this.historyData.steps = this.historyData.steps.slice(0, this.historyData.index + 1)
864
+ }
865
+
866
+ console.log('history', this.historyData.index)
867
+ },
868
+
869
+ saveCurrentHistoryStep() {
870
+ this.historyData.steps[this.historyData.index] = deepClone({
871
+ widgetList: this.widgetList,
872
+ formConfig: this.formConfig
873
+ })
874
+
875
+ this.saveFormContentToStorage()
876
+ },
877
+
878
+ undoHistoryStep() {
879
+ if (this.historyData.index !== 0) {
880
+ this.historyData.index--
881
+ }
882
+ console.log('undo', this.historyData.index)
883
+
884
+ this.widgetList = deepClone(this.historyData.steps[this.historyData.index].widgetList)
885
+ this.formConfig = deepClone(this.historyData.steps[this.historyData.index].formConfig)
886
+ },
887
+
888
+ redoHistoryStep() {
889
+ if (this.historyData.index !== (this.historyData.steps.length - 1)) {
890
+ this.historyData.index++
891
+ }
892
+ console.log('redo', this.historyData.index)
893
+
894
+ this.widgetList = deepClone(this.historyData.steps[this.historyData.index].widgetList)
895
+ this.formConfig = deepClone(this.historyData.steps[this.historyData.index].formConfig)
896
+ },
897
+
898
+ undoEnabled() {
899
+ return (this.historyData.index > 0) && (this.historyData.steps.length > 0)
900
+ },
901
+
902
+ redoEnabled() {
903
+ return this.historyData.index < (this.historyData.steps.length - 1)
904
+ },
905
+
906
+ saveFormContentToStorage() {
907
+ window.localStorage.setItem('widget__list__backup', JSON.stringify(this.widgetList))
908
+ window.localStorage.setItem('form__config__backup', JSON.stringify(this.formConfig))
909
+ },
910
+
911
+ loadFormContentFromStorage() {
912
+ let widgetListBackup = window.localStorage.getItem('widget__list__backup')
913
+ if (!!widgetListBackup) {
914
+ this.widgetList = JSON.parse(widgetListBackup)
915
+ }
916
+
917
+ let formConfigBackup = window.localStorage.getItem('form__config__backup')
918
+ if (!!formConfigBackup) {
919
+ //this.formConfig = JSON.parse(formConfigBackup)
920
+ overwriteObj(this.formConfig, JSON.parse(formConfigBackup)) /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
921
+ }
922
+ },
923
+
924
+
925
+ }
926
+ }