cloud-web-corejs 1.1.0-dev.6 → 1.1.0-dev.60

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 (498) hide show
  1. package/README.md +38 -0
  2. package/bin/core-resources.js +16 -0
  3. package/bin/create-child-app.js +34 -0
  4. package/docs/child-app/README.md +95 -0
  5. package/docs/child-app/activiti-resources.md +63 -0
  6. package/docs/child-app/generate-prompt.md +55 -0
  7. package/docs/child-app/luckysheet-resources.md +80 -0
  8. package/docs/child-app/public-resources-plan.md +288 -0
  9. package/docs/child-app/resources-implementation.md +101 -0
  10. package/docs/child-app/tinymce-resources.md +88 -0
  11. package/docs/child-app/validation.md +34 -0
  12. package/docs/qiankun/346/216/245/345/205/245/345/215/217/350/256/256.md +298 -0
  13. package/docs/qiankun/350/257/246/346/203/205/346/211/277/350/275/275/345/255/220/345/272/224/347/224/250/345/257/271/346/216/245/346/270/205/345/215/225.md +111 -0
  14. package/package.json +29 -4
  15. package/resource-tools/index.js +126 -0
  16. package/src/app-bootstrap.js +531 -0
  17. package/src/app-bootstrap.sync.js +502 -0
  18. package/src/boot-assets.legacy.js +13 -0
  19. package/src/boot-assets.next.js +7 -0
  20. package/src/components/Qrcode/fileParse.vue +11 -0
  21. package/src/components/Tinymce/dynamicLoadScript.js +51 -59
  22. package/src/components/Tinymce/index.vue +382 -336
  23. package/src/components/Tinymce/mce-chrome.scss +150 -0
  24. package/src/components/VabUpload/image-viewer.vue +18 -10
  25. package/src/components/VabUpload/index.js +11 -4
  26. package/src/components/VabUpload/index.vue +1 -1
  27. package/src/components/VabUpload/mixins/fileLibraryDialog.js +2 -0
  28. package/src/components/VabUpload/mixins.js +72 -40
  29. package/src/components/VabUpload/partUploadConfig.js +95 -0
  30. package/src/components/VabUpload/privateProfileDialogMixins.js +2 -0
  31. package/src/components/VabUpload/style.scss +282 -0
  32. package/src/components/VabUpload/view.vue +19 -18
  33. package/src/components/baseArea/index.vue +2 -2
  34. package/src/components/baseInputExport/mixins.js +1 -6
  35. package/src/components/bizTab/BizTabListPage.vue +66 -33
  36. package/src/components/bizTab/README.md +3 -1
  37. package/src/components/bizTab/bizBillDetailMixin.js +2 -0
  38. package/src/components/code-editor/ace-chrome.scss +17 -0
  39. package/src/components/code-editor/index.vue +361 -340
  40. package/src/components/errorMsg/index.vue +142 -13
  41. package/src/components/errorMsg/mixins.js +53 -0
  42. package/src/components/excelExport/conditionExportConfig.js +112 -0
  43. package/src/components/excelExport/exportColumnMemory.js +118 -0
  44. package/src/components/excelExport/exportFieldDialog.vue +50 -38
  45. package/src/components/excelExport/exportType.js +8 -0
  46. package/src/components/excelExport/index.js +30 -13
  47. package/src/components/excelExport/index.vue +7 -1
  48. package/src/components/excelExport/mixins.js +782 -293
  49. package/src/components/excelImport/index.vue +156 -156
  50. package/src/components/excelImport/mixins.js +888 -834
  51. package/src/components/fileLibrary/mixins/indexMixins.js +2 -0
  52. package/src/components/fileLibrary/style.scss +579 -0
  53. package/src/components/formDialog/index.vue +11 -8
  54. package/src/components/hiprint/style.scss +188 -0
  55. package/src/components/hiprint/view/json-view.vue +4 -4
  56. package/src/components/jdPrint/mixins.js +2 -0
  57. package/src/components/jsonImport/index.vue +1 -1
  58. package/src/components/jsonImport/mixins.js +6 -10
  59. package/src/components/langImport/index.vue +1 -1
  60. package/src/components/langImport/mixins.js +6 -10
  61. package/src/components/luckysheet/loadResources.js +64 -0
  62. package/src/components/luckysheet/view.vue +239 -210
  63. package/src/components/mobile/buttonGroup/index.vue +1 -1
  64. package/src/components/mobile/wf/addTaskUserdialog.vue +100 -80
  65. package/src/components/mobile/wf/content.vue +1734 -1662
  66. package/src/components/mobile/wf/deleteTaskUserDialog.vue +73 -54
  67. package/src/components/mobile/wf/selectUserDialog.vue +118 -0
  68. package/src/components/mobile/wf/setCandidateDialog.vue +69 -48
  69. package/src/components/mobile/wf/urgingDialog.vue +75 -52
  70. package/src/components/mobile/wf/wfModifyDialog.vue +4 -0
  71. package/src/components/obsUpload/index.js +4 -1
  72. package/src/components/obsUpload/index.vue +1 -1
  73. package/src/components/obsUpload/mixins.js +45 -15
  74. package/src/components/onlineTalk/index.vue +4 -4
  75. package/src/components/onlineTalk/mixins.js +21 -7
  76. package/src/components/table/index.js +96 -81
  77. package/src/components/table/plugins/cell-area/index.js +10 -3
  78. package/src/components/table/style.scss +1399 -0
  79. package/src/components/table/vxeFilter/mixin.js +28 -18
  80. package/src/components/wf/content.vue +3 -2
  81. package/src/components/wf/content2.vue +1 -1
  82. package/src/components/wf/style.scss +265 -0
  83. package/src/components/wf/wf.js +7 -0
  84. package/src/components/wf/wfActionItems.js +3 -0
  85. package/src/components/wf/wfStartDialog.vue +1 -0
  86. package/src/components/wf/wfTransferEnabled.js +54 -0
  87. package/src/components/wf/wfUtil.js +47 -29
  88. package/src/components/wf/wfVisibility.js +6 -0
  89. package/src/components/xform/docs/2026-07 table/344/270/216excelExport/344/277/256/345/244/215/345/217/212/345/257/274/345/207/272/344/274/230/345/214/226.md" +64 -57
  90. package/src/components/xform/docs/2026-08 xform H5 P0 /345/256/236/347/216/260/350/247/204/346/240/274.md" +1 -1
  91. package/src/components/xform/docs/2026-08 xform /347/247/273/345/212/250/347/253/257/345/270/203/345/261/200/345/257/271/351/275/220 bill_setting /346/226/271/346/241/210.md" +1 -1
  92. package/src/components/xform/docs/2026-09 /345/212/250/346/200/201/345/255/227/346/256/265/350/247/204/345/210/231/344/270/216/346/265/201/347/250/213/346/216/247/345/210/266/346/211/247/350/241/214/351/241/272/345/272/217/350/220/275/345/234/260/346/226/271/346/241/210.md" +409 -0
  93. package/src/components/xform/docs/2026-09 /346/235/241/344/273/266/345/257/274/345/207/272/345/244/247/346/225/260/346/215/256/351/207/217/345/264/251/346/272/203/346/216/222/346/237/245.md" +389 -0
  94. package/src/components/xform/docs/2026-09 /346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206P0/344/273/243/347/240/201/350/257/204/345/256/241.md" +255 -0
  95. package/src/components/xform/docs/2026-09 /346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206P0/346/265/213/350/257/225/351/252/214/350/257/201/345/256/236/346/226/275/346/226/207/346/241/243.md" +595 -0
  96. package/src/components/xform/docs/2026-09 /347/274/226/350/276/221/350/241/250/350/241/214/345/206/205/344/277/235/345/255/230/346/240/241/351/252/214/350/214/203/345/233/264/344/270/216/345/210/227/345/277/205/345/241/253/350/247/243/346/236/220/344/277/256/345/244/215.md" +233 -0
  97. package/src/components/xform/docs/2026-09 /350/241/250/345/215/225/345/257/274/345/205/245/351/200/232/351/201/223/346/242/263/347/220/206/344/270/216/350/220/275/345/234/260/346/226/271/346/241/210.md" +745 -0
  98. package/src/components/xform/docs//346/265/217/350/247/210/345/231/250/345/264/251/346/272/203/346/262/273/347/220/206/344/270/216/344/277/256/345/244/215/350/220/275/345/234/260/346/226/271/346/241/210.md +324 -0
  99. package/src/components/xform/form-designer/designer.js +2133 -2100
  100. package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +7 -0
  101. package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +4 -2
  102. package/src/components/xform/form-designer/form-widget/container-widget/detail-h5-widget.vue +243 -227
  103. package/src/components/xform/form-designer/form-widget/container-widget/h5-card-pane-widget.vue +228 -207
  104. package/src/components/xform/form-designer/form-widget/container-widget/h5-card-widget.vue +165 -136
  105. package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +30 -4
  106. package/src/components/xform/form-designer/form-widget/dialog/importDialog.vue +190 -185
  107. package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +2657 -1774
  108. package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +27 -4
  109. package/src/components/xform/form-designer/form-widget/field-widget/a-link-widget.vue +1 -1
  110. package/src/components/xform/form-designer/form-widget/field-widget/a-text-widget.vue +1 -1
  111. package/src/components/xform/form-designer/form-widget/field-widget/area-select-widget.vue +1 -1
  112. package/src/components/xform/form-designer/form-widget/field-widget/autocomplete-widget.vue +1 -1
  113. package/src/components/xform/form-designer/form-widget/field-widget/baseAttachment-widget.vue +1 -1
  114. package/src/components/xform/form-designer/form-widget/field-widget/button-widget.vue +1 -1
  115. package/src/components/xform/form-designer/form-widget/field-widget/cascader-widget.vue +1 -1
  116. package/src/components/xform/form-designer/form-widget/field-widget/census-widget.vue +1 -1
  117. package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +1 -1
  118. package/src/components/xform/form-designer/form-widget/field-widget/color-widget.vue +1 -1
  119. package/src/components/xform/form-designer/form-widget/field-widget/copy_button-widget.vue +1 -1
  120. package/src/components/xform/form-designer/form-widget/field-widget/date-range-widget.vue +1 -1
  121. package/src/components/xform/form-designer/form-widget/field-widget/date-widget.vue +1 -1
  122. package/src/components/xform/form-designer/form-widget/field-widget/descriptions-widget.vue +1 -1
  123. package/src/components/xform/form-designer/form-widget/field-widget/divider-widget.vue +1 -1
  124. package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue +1 -1
  125. package/src/components/xform/form-designer/form-widget/field-widget/dropdown-item-widget.vue +1 -1
  126. package/src/components/xform/form-designer/form-widget/field-widget/dropdown-widget.vue +35 -4
  127. package/src/components/xform/form-designer/form-widget/field-widget/echart-bar-widget.vue +1 -1
  128. package/src/components/xform/form-designer/form-widget/field-widget/echart-category-widget.vue +1 -1
  129. package/src/components/xform/form-designer/form-widget/field-widget/echart-pie-widget.vue +1 -1
  130. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +64 -10
  131. package/src/components/xform/form-designer/form-widget/field-widget/file-upload-widget.vue +1 -1
  132. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +14 -4
  133. package/src/components/xform/form-designer/form-widget/field-widget/html-text-widget.vue +1 -1
  134. package/src/components/xform/form-designer/form-widget/field-widget/import-button-widget.vue +19 -6
  135. package/src/components/xform/form-designer/form-widget/field-widget/import2-button-widget.vue +1 -1
  136. package/src/components/xform/form-designer/form-widget/field-widget/index.js +10 -1
  137. package/src/components/xform/form-designer/form-widget/field-widget/input-batch-widget.vue +1 -1
  138. package/src/components/xform/form-designer/form-widget/field-widget/input-widget.vue +29 -3
  139. package/src/components/xform/form-designer/form-widget/field-widget/multiSearch-widget.vue +1 -1
  140. package/src/components/xform/form-designer/form-widget/field-widget/news-list-widget.vue +1 -1
  141. package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +1 -1
  142. package/src/components/xform/form-designer/form-widget/field-widget/oplog-widget.vue +1 -1
  143. package/src/components/xform/form-designer/form-widget/field-widget/picture-upload-widget.vue +1 -1
  144. package/src/components/xform/form-designer/form-widget/field-widget/print-button-widget.vue +1 -1
  145. package/src/components/xform/form-designer/form-widget/field-widget/print-detail-button-widget.vue +1 -1
  146. package/src/components/xform/form-designer/form-widget/field-widget/project-tag-widget.vue +1 -1
  147. package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +1 -1
  148. package/src/components/xform/form-designer/form-widget/field-widget/rate-widget.vue +1 -1
  149. package/src/components/xform/form-designer/form-widget/field-widget/rich-editor-widget.vue +1 -1
  150. package/src/components/xform/form-designer/form-widget/field-widget/row-col-select-widget.vue +64 -0
  151. package/src/components/xform/form-designer/form-widget/field-widget/save_submit_wf_button-widget.vue +1 -1
  152. package/src/components/xform/form-designer/form-widget/field-widget/script-input-widget.vue +1 -1
  153. package/src/components/xform/form-designer/form-widget/field-widget/search_button-widget.vue +1 -1
  154. package/src/components/xform/form-designer/form-widget/field-widget/select-export-button-widget.vue +1 -1
  155. package/src/components/xform/form-designer/form-widget/field-widget/select-export-item-button-widget.vue +6 -2
  156. package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +1 -1
  157. package/src/components/xform/form-designer/form-widget/field-widget/singerSearch-widget.vue +1 -1
  158. package/src/components/xform/form-designer/form-widget/field-widget/singleUpload-widget.vue +145 -145
  159. package/src/components/xform/form-designer/form-widget/field-widget/slider-widget.vue +1 -1
  160. package/src/components/xform/form-designer/form-widget/field-widget/static-content-wrapper.vue +1 -1
  161. package/src/components/xform/form-designer/form-widget/field-widget/static-text-widget.vue +1 -1
  162. package/src/components/xform/form-designer/form-widget/field-widget/status-widget.vue +1 -1
  163. package/src/components/xform/form-designer/form-widget/field-widget/switch-widget.vue +1 -1
  164. package/src/components/xform/form-designer/form-widget/field-widget/table-export-button-widget.vue +3 -2
  165. package/src/components/xform/form-designer/form-widget/field-widget/tempStorage-widget.vue +1 -1
  166. package/src/components/xform/form-designer/form-widget/field-widget/text-widget.vue +1 -1
  167. package/src/components/xform/form-designer/form-widget/field-widget/textarea-widget.vue +1 -1
  168. package/src/components/xform/form-designer/form-widget/field-widget/time-range-widget.vue +1 -1
  169. package/src/components/xform/form-designer/form-widget/field-widget/time-widget.vue +1 -1
  170. package/src/components/xform/form-designer/form-widget/field-widget/title-head-widget.vue +1 -1
  171. package/src/components/xform/form-designer/form-widget/field-widget/vabSearch-widget.vue +1 -1
  172. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +3 -3
  173. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +25 -1
  174. package/src/components/xform/form-designer/form-widget/field-widget/vue-page-widget.vue +1 -1
  175. package/src/components/xform/form-designer/indexMixin.js +27 -0
  176. package/src/components/xform/form-designer/setting-panel/form-dynamicField-setting.vue +687 -602
  177. package/src/components/xform/form-designer/setting-panel/form-setting.vue +269 -36
  178. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +335 -12
  179. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +23 -7
  180. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail/detail-temp-edito.vue +13 -1
  181. package/src/components/xform/form-designer/setting-panel/property-editor/container-list-h5/list-h5-editor.vue +846 -860
  182. package/src/components/xform/form-designer/setting-panel/property-editor/container-tab/tab-lazyRender-editor.vue +27 -0
  183. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onTabChange-editor.vue +28 -0
  184. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onTabClick-editor.vue +28 -0
  185. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import-button-editor.vue +62 -1
  186. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import2-button-editor.vue +142 -2
  187. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/empty-number-input.vue +51 -0
  188. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-item-button-editor.vue +27 -2
  189. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/table-export-button-editor.vue +33 -3
  190. package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +2 -4
  191. package/src/components/xform/form-designer/setting-panel/property-editor/suffixIconClickable-editor.vue +23 -0
  192. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +18 -4
  193. package/src/components/xform/form-designer/toolbar-panel/index.vue +884 -874
  194. package/src/components/xform/form-designer/toolbar-panel/indexMixin.js +13 -0
  195. package/src/components/xform/form-designer/widget-panel/index.vue +11 -7
  196. package/src/components/xform/form-designer/widget-panel/indexMixin.js +15 -2
  197. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +152 -9
  198. package/src/components/xform/form-render/container-item/containerItemMixin.js +93 -8
  199. package/src/components/xform/form-render/container-item/data-table-item.vue +352 -347
  200. package/src/components/xform/form-render/container-item/data-table-mixin.js +7261 -5985
  201. package/src/components/xform/form-render/container-item/detail-h5-item.vue +48 -19
  202. package/src/components/xform/form-render/container-item/detail-item.vue +350 -446
  203. package/src/components/xform/form-render/container-item/dynamicFieldMixin.js +55 -1
  204. package/src/components/xform/form-render/container-item/list-h5-item.vue +261 -178
  205. package/src/components/xform/form-render/container-item/panel-item.vue +1 -1
  206. package/src/components/xform/form-render/container-item/tab-item.vue +177 -129
  207. package/src/components/xform/form-render/fieldControlEngine.js +218 -0
  208. package/src/components/xform/form-render/fieldControlMixin.js +536 -0
  209. package/src/components/xform/form-render/index.vue +164 -153
  210. package/src/components/xform/form-render/indexMixin.js +5443 -5311
  211. package/src/components/xform/form-render/pageDialogScope.js +54 -0
  212. package/src/components/xform/icon-picker/index.vue +1 -1
  213. package/src/components/xform/lang/en-US.js +8 -0
  214. package/src/components/xform/lang/zh-CN.js +9 -0
  215. package/src/components/xform/mixins/businessLock.js +59 -0
  216. package/src/components/xform/mixins/defaultHandle.js +713 -707
  217. package/src/components/xform/mixins/scriptHttp.js +42 -21
  218. package/src/components/xform/mixins/wfStart.js +105 -0
  219. package/src/components/xform/mixins/wfVisibility.js +33 -0
  220. package/src/components/xform/styles/census.scss +288 -0
  221. package/src/components/xform/styles/containers.scss +215 -0
  222. package/src/components/xform/styles/designer.scss +904 -0
  223. package/src/components/xform/styles/detail-temp.scss +71 -0
  224. package/src/components/xform/styles/h5-designer.scss +191 -0
  225. package/src/components/xform/styles/h5-runtime.scss +520 -0
  226. package/src/components/xform/styles/h5.scss +836 -516
  227. package/src/components/xform/styles/skins.scss +398 -0
  228. package/src/components/xform/styles/table-layout.scss +91 -0
  229. package/src/components/xform/styles/titles.scss +255 -0
  230. package/src/components/xform/utils/dynamicSchemaUtil.js +385 -361
  231. package/src/components/xform/utils/fixedQueryUtil.js +29 -4
  232. package/src/components/xform/utils/serviceNameCache.js +69 -0
  233. package/src/components/xform/utils/tableColumnHelper.js +46 -4
  234. package/src/components/xform/utils/util.js +1776 -1708
  235. package/src/core-resources/css/h5.scss +548 -0
  236. package/src/core-resources/css/iconfont.css +1447 -0
  237. package/src/core-resources/font/iconfont.ttf +0 -0
  238. package/src/core-resources/font/iconfont.woff +0 -0
  239. package/src/core-resources/font/iconfont.woff2 +0 -0
  240. package/src/core-resources/images/default-header.png +0 -0
  241. package/src/core-resources/images/ico-default_wenjian.svg +1 -0
  242. package/src/core-resources/images/ico-excel.svg +1 -0
  243. package/src/core-resources/images/ico-ftl.svg +7 -0
  244. package/src/core-resources/images/ico-html.svg +1 -0
  245. package/src/core-resources/images/ico-java.svg +1 -0
  246. package/src/core-resources/images/ico-music.svg +1 -0
  247. package/src/core-resources/images/ico-pdf.svg +1 -0
  248. package/src/core-resources/images/ico-photo.svg +1 -0
  249. package/src/core-resources/images/ico-ppt.svg +1 -0
  250. package/src/core-resources/images/ico-psd.svg +1 -0
  251. package/src/core-resources/images/ico-service.png +0 -0
  252. package/src/core-resources/images/ico-txt.svg +1 -0
  253. package/src/core-resources/images/ico-video.svg +1 -0
  254. package/src/core-resources/images/ico-vue.svg +8 -0
  255. package/src/core-resources/images/ico-wenjianjia.svg +1 -0
  256. package/src/core-resources/images/ico-wrod.svg +1 -0
  257. package/src/core-resources/images/ico-xml.svg +1 -0
  258. package/src/core-resources/images/ico-yasuobao.svg +1 -0
  259. package/src/core-resources/images/icon-error.png +0 -0
  260. package/src/core-resources/images/icon-tips.png +0 -0
  261. package/src/core-resources/images/nodata.png +0 -0
  262. package/src/core-resources/images/nodata2.png +0 -0
  263. package/src/directive/append-to-body/index.js +48 -0
  264. package/src/directive/el-dialog-center/index.js +3 -2
  265. package/src/directive/el-drag-dialog/drag.js +33 -4
  266. package/src/icons/index.js +9 -0
  267. package/src/icons/svg/404.svg +1 -0
  268. package/src/icons/svg/alert.svg +1 -0
  269. package/src/icons/svg/bug.svg +1 -0
  270. package/src/icons/svg/button.svg +1 -0
  271. package/src/icons/svg/card.svg +1 -0
  272. package/src/icons/svg/cascader-field.svg +1 -0
  273. package/src/icons/svg/census.svg +1 -0
  274. package/src/icons/svg/chart.svg +1 -0
  275. package/src/icons/svg/checkbox-field.svg +1 -0
  276. package/src/icons/svg/clipboard.svg +1 -0
  277. package/src/icons/svg/color-field.svg +1 -0
  278. package/src/icons/svg/component.svg +1 -0
  279. package/src/icons/svg/custom-component.svg +1 -0
  280. package/src/icons/svg/dashboard.svg +1 -0
  281. package/src/icons/svg/data-table.svg +1 -0
  282. package/src/icons/svg/date-field.svg +1 -0
  283. package/src/icons/svg/date-range-field.svg +1 -0
  284. package/src/icons/svg/descriptions.svg +1 -0
  285. package/src/icons/svg/divider.svg +1 -0
  286. package/src/icons/svg/document.svg +1 -0
  287. package/src/icons/svg/documentation.svg +1 -0
  288. package/src/icons/svg/drag.svg +1 -0
  289. package/src/icons/svg/echart-category.svg +1 -0
  290. package/src/icons/svg/echart-pie.svg +1 -0
  291. package/src/icons/svg/echart.svg +1 -0
  292. package/src/icons/svg/edit.svg +1 -0
  293. package/src/icons/svg/education.svg +1 -0
  294. package/src/icons/svg/email.svg +1 -0
  295. package/src/icons/svg/example.svg +1 -0
  296. package/src/icons/svg/excel.svg +1 -0
  297. package/src/icons/svg/exit-fullscreen.svg +1 -0
  298. package/src/icons/svg/eye-open.svg +1 -0
  299. package/src/icons/svg/eye.svg +1 -0
  300. package/src/icons/svg/file-upload-field.svg +1 -0
  301. package/src/icons/svg/form.svg +1 -0
  302. package/src/icons/svg/fullscreen.svg +1 -0
  303. package/src/icons/svg/github.svg +1 -0
  304. package/src/icons/svg/grid.svg +1 -0
  305. package/src/icons/svg/guide.svg +1 -0
  306. package/src/icons/svg/html-text.svg +1 -0
  307. package/src/icons/svg/ico-more.svg +1 -0
  308. package/src/icons/svg/ico-wenjianjia.svg +1 -0
  309. package/src/icons/svg/icon.svg +1 -0
  310. package/src/icons/svg/input-batch.svg +1 -0
  311. package/src/icons/svg/international.svg +1 -0
  312. package/src/icons/svg/language.svg +1 -0
  313. package/src/icons/svg/link.svg +1 -0
  314. package/src/icons/svg/list-export.svg +1 -0
  315. package/src/icons/svg/list.svg +1 -0
  316. package/src/icons/svg/lock.svg +1 -0
  317. package/src/icons/svg/message.svg +1 -0
  318. package/src/icons/svg/money.svg +1 -0
  319. package/src/icons/svg/nested.svg +1 -0
  320. package/src/icons/svg/news-list.svg +1 -0
  321. package/src/icons/svg/node-tree.svg +1 -0
  322. package/src/icons/svg/number-field.svg +1 -0
  323. package/src/icons/svg/password.svg +1 -0
  324. package/src/icons/svg/pdf.svg +1 -0
  325. package/src/icons/svg/people.svg +1 -0
  326. package/src/icons/svg/peoples.svg +1 -0
  327. package/src/icons/svg/picture-upload-field.svg +1 -0
  328. package/src/icons/svg/qq.svg +1 -0
  329. package/src/icons/svg/query.svg +1 -0
  330. package/src/icons/svg/radio-field.svg +1 -0
  331. package/src/icons/svg/rate-field.svg +1 -0
  332. package/src/icons/svg/redo.svg +1 -0
  333. package/src/icons/svg/rich-editor-field.svg +1 -0
  334. package/src/icons/svg/search.svg +1 -0
  335. package/src/icons/svg/searchbox.svg +1 -0
  336. package/src/icons/svg/section.svg +1 -0
  337. package/src/icons/svg/select-field.svg +1 -0
  338. package/src/icons/svg/shopping.svg +1 -0
  339. package/src/icons/svg/size.svg +1 -0
  340. package/src/icons/svg/skill.svg +1 -0
  341. package/src/icons/svg/slider-field.svg +1 -0
  342. package/src/icons/svg/slot-component.svg +1 -0
  343. package/src/icons/svg/slot-field.svg +1 -0
  344. package/src/icons/svg/star.svg +1 -0
  345. package/src/icons/svg/static-text.svg +1 -0
  346. package/src/icons/svg/status.svg +1 -0
  347. package/src/icons/svg/sub-form.svg +1 -0
  348. package/src/icons/svg/switch-field.svg +1 -0
  349. package/src/icons/svg/tab.svg +1 -0
  350. package/src/icons/svg/table.svg +1 -0
  351. package/src/icons/svg/text-field.svg +1 -0
  352. package/src/icons/svg/text.svg +1 -0
  353. package/src/icons/svg/textarea-field.svg +1 -0
  354. package/src/icons/svg/theme.svg +1 -0
  355. package/src/icons/svg/time-field.svg +1 -0
  356. package/src/icons/svg/time-range-field.svg +1 -0
  357. package/src/icons/svg/tips-text.svg +1 -0
  358. package/src/icons/svg/title-head.svg +1 -0
  359. package/src/icons/svg/tree-pane.svg +1 -0
  360. package/src/icons/svg/tree-table.svg +1 -0
  361. package/src/icons/svg/tree.svg +1 -0
  362. package/src/icons/svg/undo.svg +1 -0
  363. package/src/icons/svg/uploadbox.svg +1 -0
  364. package/src/icons/svg/user.svg +1 -0
  365. package/src/icons/svg/vf-box.svg +1 -0
  366. package/src/icons/svg/vf-dialog.svg +1 -0
  367. package/src/icons/svg/vf-drawer.svg +1 -0
  368. package/src/icons/svg/vue-sfc.svg +1 -0
  369. package/src/icons/svg/wechat.svg +1 -0
  370. package/src/icons/svg/zip.svg +1 -0
  371. package/src/index.js +2 -510
  372. package/src/index.next.js +5 -0
  373. package/src/index.sync.js +5 -0
  374. package/src/layout/components/Sidebar/default.vue +1656 -1655
  375. package/src/layout/components/TagsView/index.vue +330 -323
  376. package/src/layout/components/TagsView/style.scss +92 -0
  377. package/src/layout/defaultLayout.vue +2 -2
  378. package/src/router/index.js +43 -48
  379. package/src/router/modules/customer.js +12 -0
  380. package/src/store/modules/settings.js +1 -1
  381. package/src/store/modules/tagsView.js +241 -217
  382. package/src/store/modules/user.js +16 -12
  383. package/src/styles/btn.scss +315 -0
  384. package/src/styles/dialog.scss +1710 -0
  385. package/src/styles/element-ui.scss +1076 -0
  386. package/src/styles/element-variables.scss +31 -0
  387. package/src/styles/global.scss +115 -0
  388. package/src/styles/index.scss +245 -0
  389. package/src/styles/layout-skins.scss +840 -0
  390. package/src/styles/legacy-base.scss +19 -0
  391. package/src/styles/menu-icons.scss +75 -0
  392. package/src/styles/mixin.scss +80 -0
  393. package/src/styles/nprogress.scss +14 -0
  394. package/src/styles/page-shell.scss +723 -0
  395. package/src/styles/sidebar.scss +296 -0
  396. package/src/styles/split-handle.scss +52 -0
  397. package/src/styles/theme-variables.scss +7 -0
  398. package/src/styles/transition.scss +48 -0
  399. package/src/styles/utilities.scss +253 -0
  400. package/src/styles/variables.scss +72 -0
  401. package/src/utils/baseDictsCache.js +197 -0
  402. package/src/utils/chunkLoadError.js +24 -0
  403. package/src/utils/featureResources.js +57 -0
  404. package/src/utils/importLimit.js +72 -0
  405. package/src/utils/pdfUtil.js +6 -1
  406. package/src/utils/request.js +142 -7
  407. package/src/utils/resolveViewComponent.js +45 -90
  408. package/src/utils/runtimeRecovery.js +105 -0
  409. package/src/utils/swiperLoader.js +20 -0
  410. package/src/utils/vab.js +1334 -1283
  411. package/src/utils/xlsxLoader.js +29 -0
  412. package/src/views/bd/setting/formVersion/compareContMixin.scss +1 -1
  413. package/src/views/bd/setting/form_template/edit.vue +378 -356
  414. package/src/views/bd/setting/form_template/formDesignerDialog.vue +6 -0
  415. package/src/views/bd/setting/form_template/formTemplateType.js +43 -0
  416. package/src/views/bd/setting/form_template/list.vue +304 -303
  417. package/src/views/bd/setting/form_template/mixins/edit.js +344 -280
  418. package/src/views/bd/setting/form_template/mixins/list.js +749 -721
  419. package/src/views/bd/setting/form_template/mixins/list2.js +412 -411
  420. package/src/views/bd/setting/form_template/mixins/wf_list.js +431 -430
  421. package/src/views/mobile/user/area/dialog.vue +1 -1
  422. package/src/views/mobile/user/user/dialog.vue +1 -1
  423. package/src/views/user/bill_setting/mixins/wf.js +8 -0
  424. package/src/views/user/bill_setting/render.vue +1 -1
  425. package/src/views/user/commMenu/index.vue +3 -1
  426. package/src/views/user/commMenu/style.scss +123 -0
  427. package/src/views/user/common_attribute/edit.vue +2 -0
  428. package/src/views/user/common_attribute/itemEdit.vue +2 -0
  429. package/src/views/user/file_view_ins/list.vue +970 -970
  430. package/src/views/user/form/form_template/list.vue +527 -506
  431. package/src/views/user/form/vform/designer.vue +823 -821
  432. package/src/views/user/form/view/list.vue +24 -1
  433. package/src/views/user/home/default.vue +1124 -1117
  434. package/src/views/user/home/default2.vue +12 -8
  435. package/src/views/user/home/index.vue +102 -102
  436. package/src/views/user/home/wjl/content.vue +1581 -1569
  437. package/src/views/user/intf_permission/edit.vue +230 -0
  438. package/src/views/user/intf_permission/list.vue +196 -0
  439. package/src/views/user/menuFallback/index.vue +23 -0
  440. package/src/views/user/notify_message/dialog.vue +139 -139
  441. package/src/views/user/outLink/form_view.vue +202 -202
  442. package/src/views/user/outLink/index.vue +110 -110
  443. package/src/views/user/role/edit.vue +4 -0
  444. package/src/views/user/role/role-box.scss +83 -0
  445. package/src/views/user/role/voc_edit.vue +4 -0
  446. package/src/views/user/user/list.vue +28 -6
  447. package/src/views/user/wf/iframe/index.vue +51 -51
  448. package/src/views/user/wf/iframe/index2.vue +64 -64
  449. package/src/views/user/wf/wf_diy_attribute/edit.vue +1 -1
  450. package/src/views/user/wf/wf_manage/list2.vue +871 -871
  451. package/src/views/user/wf/wf_manage/wfContentDialog.vue +177 -126
  452. package/src/views/user/wf/wf_obj_config/activiti_wf.vue +134 -133
  453. package/src/views/user/wf/wf_obj_config/importItemDialog.vue +1 -1
  454. package/src/views/user/wf/wf_obj_config/list.vue +747 -746
  455. package/src/views/user/wf/wf_obj_config/list_form.vue +374 -373
  456. package/templates/child-app/.env +3 -0
  457. package/templates/child-app/README.md +49 -0
  458. package/templates/child-app/app.config.js +6 -0
  459. package/templates/child-app/babel.config.js +1 -0
  460. package/templates/child-app/core-resources.config.js +15 -0
  461. package/templates/child-app/gitignore +7 -0
  462. package/templates/child-app/package.json +34 -0
  463. package/templates/child-app/public/index.html +12 -0
  464. package/templates/child-app/src/assets/401_images/401.gif +0 -0
  465. package/templates/child-app/src/assets/404_images/404.png +0 -0
  466. package/templates/child-app/src/assets/404_images/404_cloud.png +0 -0
  467. package/templates/child-app/src/assets/logo.png +0 -0
  468. package/templates/child-app/src/corejsConfig.js +2 -0
  469. package/templates/child-app/src/icons/index.js +2 -0
  470. package/templates/child-app/src/icons/svg/child-demo.svg +1 -0
  471. package/templates/child-app/src/layout/index.vue +4 -0
  472. package/templates/child-app/src/main.js +5 -0
  473. package/templates/child-app/src/prefixConfig.js +13 -0
  474. package/templates/child-app/src/resources/css/login.scss +29 -0
  475. package/templates/child-app/src/resources/images/bg-login5.jpg +0 -0
  476. package/templates/child-app/src/resources/images/home-img.png +0 -0
  477. package/templates/child-app/src/router/modules/customer.js +3 -0
  478. package/templates/child-app/src/settings.js +24 -0
  479. package/templates/child-app/src/styles/app.scss +2 -0
  480. package/templates/child-app/src/views/demo/detail.vue +19 -0
  481. package/templates/child-app/src/views/demo/list.vue +38 -0
  482. package/templates/child-app/src/views/user/login/index.vue +18 -0
  483. package/templates/child-app/vue.config.js +107 -0
  484. package/src/components/xform/form-render/container-item/dynamicFieldEngine.js +0 -285
  485. package/src/components/xform/form-render/formDynamicFieldMixin.js +0 -131
  486. package/src/views/demo/bizTab/bill/billConfig.js +0 -41
  487. package/src/views/demo/bizTab/bill/detail.vue +0 -436
  488. package/src/views/demo/bizTab/bill/list.vue +0 -288
  489. package/src/views/demo/bizTab/bill/productDialog.vue +0 -176
  490. package/src/views/demo/bizTab/simple/billApi.js +0 -123
  491. package/src/views/demo/bizTab/simple/detail.vue +0 -407
  492. package/src/views/demo/bizTab/simple/list.vue +0 -217
  493. package/src/views/demo/bizTab/standalone/index.vue +0 -121
  494. package/src/views/demo/bizTab/wf/billConfig.js +0 -44
  495. package/src/views/demo/bizTab/wf/detail.vue +0 -661
  496. package/src/views/demo/bizTab/wf/list.vue +0 -242
  497. package/src/views/user/outLink/cc_form_view.vue +0 -188
  498. /package/src/{resources → core-resources}/js/base/common.js +0 -0
@@ -1,2100 +1,2133 @@
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 {
10
- deepClone,
11
- generateId,
12
- getDefaultFormConfig,
13
- overwriteObj,
14
- createUUID,
15
- columnFormatMap,
16
- } from "../../../components/xform/utils/util";
17
- import { CLICK_BIND } from "./setting-panel/property-editor/field-button/clickBindActions";
18
- import {
19
- containers,
20
- advancedFields,
21
- basicFields,
22
- customFields,
23
- businessFields,
24
- } from "../../../components/xform/form-designer/widget-panel/widgetsConfig.js";
25
- import { VARIANT_FORM_VERSION } from "../../../components/xform/utils/config";
26
- import { keyNamePrefixMap } from "../../../components/xform/form-designer/widget-panel/widgetsConfig";
27
-
28
- let createDesigner0;
29
- const baseRefUtil = {
30
- deepClone,
31
- generateId,
32
- getDefaultFormConfig,
33
- overwriteObj,
34
- containers,
35
- advancedFields,
36
- basicFields,
37
- customFields,
38
- VARIANT_FORM_VERSION,
39
- };
40
-
41
- let chartContainers = [],
42
- chartWidgets = [];
43
-
44
- (function () {
45
- createDesigner0 = function (vueInstance) {
46
- let defaultFormConfig = baseRefUtil.deepClone(
47
- baseRefUtil.getDefaultFormConfig()
48
- );
49
-
50
- return {
51
- widgetList: [],
52
- formConfig: {
53
- cssCode: "",
54
- gridConfig: {
55
- accessReturnType: 1,
56
- isLoadDataByAccess: false,
57
- },
58
- scriptList: [],
59
- formType: 0,
60
- getConfig: {
61
- accessType: "1",
62
- accessUrl: null,
63
- accessParam: null,
64
- accessCallback: null,
65
- scriptName: null,
66
- scriptCode: null,
67
- },
68
- saveConfig: {
69
- accessType: "1",
70
- accessUrl: null,
71
- accessParam: null,
72
- accessCallback: null,
73
- scriptName: null,
74
- scriptCode: null,
75
- },
76
- editFormCode: null,
77
- editFormName: null,
78
- searchDialogNameField: null,
79
- searchDialogUniqueField: null,
80
- entity: null,
81
- wfEnabled: false,
82
- isLoadEntity: false,
83
- formScriptCode: "getOne",
84
- formScriptParam: null,
85
- formScriptSuccess: null,
86
- saveScriptCode: "saveUpdate",
87
- wfConfig: null,
88
- wfStartBindSave: false,
89
- wfStartConfirmText: null,
90
- wfAgreenBindSave: false,
91
- wfAgreeConfigData: [],
92
- wfConfigDataEnabled: false,
93
- wfConfigData: [],
94
- multiTabEnabled: false,
95
- multiTabLabelField: null,
96
- addTabEnabled: false, // 新增打开独立页签(不走「常规」页签)
97
- submitBehavior: "refreshCurrent", // 提交后行为: refreshCurrent(默认,留在详情页) | closeToList
98
- billNavEnabled: false, // 详情页签显示「上一单/下一单」翻单按钮
99
- addFormCode: null,
100
- addFormName: null,
101
- wfTheme: null,
102
- otherTabEnabled: false,
103
- otherTabList: [],
104
- hideNormalTab: false,
105
- customListTabLabel: null,
106
- globalConfig: null,
107
- // 表单级动态字段规则
108
- dynamicFieldEnabled: false,
109
- dynamicFieldSourceType: "local",
110
- dynamicFieldRules: [],
111
- dynamicFieldScriptCode: null,
112
- dynamicFieldScriptParam: null,
113
- dynamicFieldTriggerFields: [],
114
- },
115
- dataSources: [], //数据源
116
-
117
- selectedId: null,
118
- selectedWidget: null,
119
- selectedWidgetName: null, //选中组件名称(唯一)
120
- vueInstance: vueInstance,
121
-
122
- formWidget: null, //表单设计容器
123
-
124
- cssClassList: [], //自定义样式列表
125
-
126
- historyData: {
127
- index: -1, //index: 0,
128
- maxStep: 20,
129
- steps: [],
130
- },
131
-
132
- initDesigner(resetFormJson) {
133
- this.widgetList = [];
134
- this.formConfig = baseRefUtil.deepClone(defaultFormConfig);
135
- this.dataSources = [];
136
-
137
- //输出版本信息和语雀链接
138
- /* console.info(`%cVariantForm %cVer${baseRefUtil.VARIANT_FORM_VERSION} %chttps://www.yuque.com/visualdev/vform`,
139
- "color:#409EFF;font-size: 22px;font-weight:bolder",
140
- "color:#999;font-size: 12px",
141
- "color:#333"
142
- ); */
143
-
144
- /*if (!resetFormJson) {
145
- this.initHistoryData();
146
- }*/
147
- },
148
-
149
- clearDesigner(skipHistoryChange) {
150
- let emptyWidgetListFlag = this.widgetList.length === 0;
151
- this.widgetList = [];
152
- this.selectedId = null;
153
- this.selectedWidgetName = null;
154
- this.selectedWidget = {}; //this.selectedWidget = null
155
- baseRefUtil.overwriteObj(this.formConfig, defaultFormConfig); //
156
- this.formConfig.gridConfig = defaultFormConfig.gridConfig;
157
-
158
- if (!!skipHistoryChange) {
159
- //什么也不做!!
160
- } else if (!emptyWidgetListFlag) {
161
- this.emitHistoryChange();
162
- } else {
163
- this.saveCurrentHistoryStep();
164
- }
165
- },
166
-
167
- loadPresetCssCode(preCssCode) {
168
- if (this.formConfig.cssCode === "" && !!preCssCode) {
169
- this.formConfig.cssCode = preCssCode;
170
- }
171
- },
172
-
173
- getLayoutType() {
174
- return this.formConfig.layoutType || "PC";
175
- },
176
-
177
- changeLayoutType(newType) {
178
- this.formConfig.layoutType = newType;
179
- },
180
-
181
- getImportTemplate() {
182
- return {
183
- widgetList: [],
184
- // formConfig: baseRefUtil.deepClone(this.formConfig)
185
- formConfig: baseRefUtil.deepClone(defaultFormConfig),
186
- };
187
- },
188
-
189
- handleImportJson(formJson) {
190
- let formConfig = formJson.formConfig;
191
- if (formConfig.formCode === vueInstance?.reportTemplate?.formCode) {
192
- return;
193
- }
194
- let widgetArr = formJson.widgetList;
195
- let itemFieldMap = {
196
- grid: "cols",
197
- table: "rows",
198
- "table-cell": "widgetList",
199
- "h5-table": "rows",
200
- "h5-table-cell": "widgetList",
201
- tab: "tabs",
202
- "tab-pane": "widgetList",
203
- "grid-col": "widgetList",
204
- "vf-box": "widgetList",
205
- card: "widgetList",
206
- detail: "panes",
207
- "detail-plain": "panes",
208
- "detail-pane": "widgetList",
209
- "detail-h5": "panes",
210
- "h5-card": "panes",
211
- "h5-card-pane": "widgetList",
212
- };
213
- let loopDo = (widgetList) => {
214
- if (!widgetList) return;
215
- widgetList.forEach((widget) => {
216
- if (widget.type === "data-table" || widget.type === "list-h5") {
217
- let vailColumns = widget.options.tableColumns.filter(
218
- (item) => item.prop && item.label
219
- );
220
- vailColumns.forEach((item) => {
221
- if (item.formatS === "editAttachment") {
222
- let prop = item.prop;
223
- let columnOption = item.columnOption;
224
- let editColumnOption = item.editColumnOption;
225
-
226
- let suffix = this.createAttachmentSuffix();
227
- let keyName = this.createAttachmentKeyName(suffix);
228
- if (columnOption) {
229
- columnOption.keyName = keyName;
230
- columnOption.keyNameSuffix = suffix;
231
- }
232
- if (editColumnOption) {
233
- editColumnOption.keyName = keyName;
234
- editColumnOption.keyNameSuffix = suffix;
235
- }
236
- item.prop = keyName;
237
- }
238
- });
239
- } else if (
240
- widget.type === "vabUpload" ||
241
- widget.type === "baseAttachment"
242
- ) {
243
- let suffix = this.createAttachmentSuffix();
244
- let keyName = this.createAttachmentKeyName(suffix);
245
- widget.options.keyName = keyName;
246
- widget.options.keyNameSuffix = suffix;
247
- } else {
248
- if (widget.category === "container") {
249
- let itemField = itemFieldMap[widget.type];
250
- if (itemField) {
251
- if ("table" === widget.type) {
252
- widget[itemField].forEach((item) => {
253
- loopDo(item.cols);
254
- });
255
- } else if ("h5-table" === widget.type) {
256
- widget[itemField].forEach((item) => {
257
- loopDo(item.cols);
258
- });
259
- } else {
260
- loopDo(widget[itemField]);
261
- }
262
- }
263
- }
264
- }
265
- });
266
- };
267
- loopDo(widgetArr);
268
- },
269
- loadFormJson(formJson) {
270
- let modifiedFlag = false;
271
-
272
- if (!!formJson && !!formJson.widgetList) {
273
- this.widgetList = formJson.widgetList;
274
- modifiedFlag = true;
275
- }
276
- if (!!formJson && !!formJson.formConfig) {
277
- //this.formConfig = importObj.formConfig
278
- baseRefUtil.overwriteObj(
279
- this.formConfig,
280
- formJson.formConfig
281
- ); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
282
- modifiedFlag = true;
283
- }
284
-
285
- if (modifiedFlag) {
286
- this.emitEvent("form-json-imported", []); // 通知其他组件
287
- }
288
- this.setSelected();
289
- return modifiedFlag;
290
- },
291
- handleSelectedWidget(selected) {
292
- //处理历史未定义的属性
293
- if (selected.formItemFlag || selected.type === "data-table") {
294
- if (selected.options.submitFlag === void 0) {
295
- // selected.options.submitFlag = true;
296
- this.vueInstance.$set(selected.options, "submitFlag", true);
297
- }
298
- }
299
- this.handleKeyNameSuffix(selected);
300
- },
301
- handleKeyNameSuffix(selected) {
302
- if (!selected) return;
303
- let optionModel = selected.options;
304
- let prefix = this.getKeyNamePrefix(selected.type, optionModel);
305
- if (
306
- optionModel.keyNameEnabled &&
307
- !!prefix &&
308
- !optionModel.keyNameSuffix
309
- ) {
310
- let keyName = optionModel.keyName;
311
- if (keyName.startsWith(prefix)) {
312
- this.vueInstance.$set(
313
- optionModel,
314
- "keyNameSuffix",
315
- keyName.substring(prefix.length)
316
- );
317
- }
318
- }
319
- },
320
- setSelected(selected) {
321
- if (!selected) {
322
- this.clearSelected();
323
- return;
324
- }
325
-
326
- //处理历史未定义的属性
327
- this.handleSelectedWidget(selected);
328
-
329
- this.selectedWidget = selected;
330
- if (!!selected.id) {
331
- this.selectedId = selected.id;
332
- this.selectedWidgetName = selected.options.name;
333
- if (!selected.category) {
334
- this.emitEvent("canvas-select-field", selected.options.name);
335
- } else {
336
- this.emitEvent("canvas-select-container", selected.options.name);
337
- }
338
- }
339
- },
340
-
341
- updateSelectedWidgetNameAndLabel(selectedWidget, newName, newLabel) {
342
- this.selectedWidgetName = newName;
343
- //selectedWidget.options.name = newName //此行多余
344
- if (
345
- !!newLabel &&
346
- Object.keys(selectedWidget.options).indexOf("label") > -1
347
- ) {
348
- selectedWidget.options.label = newLabel;
349
- }
350
- },
351
-
352
- clearSelected() {
353
- this.selectedId = null;
354
- this.selectedWidgetName = null;
355
- this.selectedWidget = {}; //this.selectedWidget = null
356
- },
357
-
358
- checkWidgetMove(evt) {
359
- /* Only field widget can be dragged into sub-form */
360
- if (!!evt.draggedContext && !!evt.draggedContext.element) {
361
- let wgCategory = evt.draggedContext.element.category;
362
- let wgType = evt.draggedContext.element.type;
363
- if (!!evt.to) {
364
- if (
365
- evt.to.className === "sub-form-table" &&
366
- wgCategory === "container"
367
- ) {
368
- //this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
369
- return false;
370
- }
371
- }
372
- }
373
-
374
- return true;
375
- },
376
-
377
- checkFieldMove(evt) {
378
- if (!!evt.draggedContext && !!evt.draggedContext.element) {
379
- let wgCategory = evt.draggedContext.element.category;
380
- let wgType = evt.draggedContext.element.type + "";
381
- //console.log('wgType======', wgType)
382
- if (!!evt.to) {
383
- if (evt.to.className === "sub-form-table" && wgType === "slot") {
384
- //this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
385
- return false;
386
- }
387
- }
388
- }
389
-
390
- return true;
391
- },
392
-
393
- /**
394
- * 追加表格新行
395
- * @param widget
396
- */
397
- appendTableRow(widget) {
398
- let rowIdx = widget.rows.length; //确定插入行位置
399
- let newRow = baseRefUtil.deepClone(widget.rows[widget.rows.length - 1]);
400
- newRow.id = "table-row-" + baseRefUtil.generateId();
401
- newRow.merged = false;
402
- newRow.cols.forEach((col) => {
403
- col.id = "table-cell-" + baseRefUtil.generateId();
404
- col.options.name = col.id;
405
- col.merged = false;
406
- col.options.colspan = 1;
407
- col.options.rowspan = 1;
408
- col.widgetList.length = 0;
409
- });
410
- widget.rows.splice(rowIdx, 0, newRow);
411
-
412
- this.emitHistoryChange();
413
- },
414
-
415
- /**
416
- * 追加表格新列
417
- * @param widget
418
- */
419
- appendTableCol(widget) {
420
- let colIdx = widget.rows[0].cols.length; //确定插入列位置
421
- widget.rows.forEach((row) => {
422
- let newCol = baseRefUtil.deepClone(
423
- this.getContainerByType("table-cell")
424
- );
425
- newCol.id = "table-cell-" + baseRefUtil.generateId();
426
- newCol.options.name = newCol.id;
427
- newCol.merged = false;
428
- newCol.options.colspan = 1;
429
- newCol.options.rowspan = 1;
430
- newCol.widgetList.length = 0;
431
- row.cols.splice(colIdx, 0, newCol);
432
- });
433
-
434
- this.emitHistoryChange();
435
- },
436
-
437
- insertTableRow(widget, insertPos, cloneRowIdx, curCol, aboveFlag) {
438
- let newRowIdx = !!aboveFlag ? insertPos : insertPos + 1; //初步确定插入行位置
439
- if (!aboveFlag) {
440
- //继续向下寻找同列第一个未被合并的单元格
441
- let tmpRowIdx = newRowIdx;
442
- let rowFoundFlag = false;
443
- while (tmpRowIdx < widget.rows.length) {
444
- if (!widget.rows[tmpRowIdx].cols[curCol].merged) {
445
- newRowIdx = tmpRowIdx;
446
- rowFoundFlag = true;
447
- break;
448
- } else {
449
- tmpRowIdx++;
450
- }
451
- }
452
-
453
- if (!rowFoundFlag) {
454
- newRowIdx = widget.rows.length;
455
- }
456
- }
457
-
458
- let newRow = baseRefUtil.deepClone(widget.rows[cloneRowIdx]);
459
- newRow.id = "table-row-" + baseRefUtil.generateId();
460
- newRow.merged = false;
461
- newRow.cols.forEach((col) => {
462
- col.id = "table-cell-" + baseRefUtil.generateId();
463
- col.options.name = col.id;
464
- col.merged = false;
465
- col.options.colspan = 1;
466
- col.options.rowspan = 1;
467
- col.widgetList.length = 0;
468
- });
469
- widget.rows.splice(newRowIdx, 0, newRow);
470
-
471
- let colNo = 0;
472
- while (
473
- newRowIdx < widget.rows.length - 1 &&
474
- colNo < widget.rows[0].cols.length
475
- ) {
476
- //越界判断
477
- const cellOfNextRow = widget.rows[newRowIdx + 1].cols[colNo];
478
- const rowMerged = cellOfNextRow.merged; //确定插入位置下一行的单元格是否为合并单元格
479
- if (!!rowMerged) {
480
- let rowArray = widget.rows;
481
- let unMergedCell = {};
482
- let startRowIndex = null;
483
- for (let i = newRowIdx; i >= 0; i--) {
484
- //查找该行已合并的主单元格
485
- if (
486
- !rowArray[i].cols[colNo].merged &&
487
- rowArray[i].cols[colNo].options.rowspan > 1
488
- ) {
489
- startRowIndex = i;
490
- unMergedCell = rowArray[i].cols[colNo];
491
- break;
492
- }
493
- }
494
-
495
- if (!!unMergedCell.options) {
496
- //如果有符合条件的unMergedCell
497
- let newRowspan = unMergedCell.options.rowspan + 1;
498
- this.setPropsOfMergedRows(
499
- widget.rows,
500
- startRowIndex,
501
- colNo,
502
- unMergedCell.options.colspan,
503
- newRowspan
504
- );
505
- colNo += unMergedCell.options.colspan;
506
- } else {
507
- colNo += 1;
508
- }
509
- } else {
510
- //colNo += 1
511
- colNo += cellOfNextRow.options.colspan || 1;
512
- }
513
- }
514
-
515
- this.emitHistoryChange();
516
- },
517
-
518
- insertTableCol(widget, insertPos, curRow, leftFlag) {
519
- let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
520
- if (!leftFlag) {
521
- //继续向右寻找同行第一个未被合并的单元格
522
- let tmpColIdx = newColIdx;
523
- let colFoundFlag = false;
524
- while (tmpColIdx < widget.rows[curRow].cols.length) {
525
- if (!widget.rows[curRow].cols[tmpColIdx].merged) {
526
- newColIdx = tmpColIdx;
527
- colFoundFlag = true;
528
- break;
529
- } else {
530
- tmpColIdx++;
531
- }
532
-
533
- if (!colFoundFlag) {
534
- newColIdx = widget.rows[curRow].cols.length;
535
- }
536
- }
537
- }
538
-
539
- widget.rows.forEach((row) => {
540
- let newCol = baseRefUtil.deepClone(
541
- this.getContainerByType("table-cell")
542
- );
543
- newCol.id = "table-cell-" + baseRefUtil.generateId();
544
- newCol.options.name = newCol.id;
545
- newCol.merged = false;
546
- newCol.options.colspan = 1;
547
- newCol.options.rowspan = 1;
548
- newCol.widgetList.length = 0;
549
- row.cols.splice(newColIdx, 0, newCol);
550
- });
551
-
552
- let rowNo = 0;
553
- while (
554
- newColIdx < widget.rows[0].cols.length - 1 &&
555
- rowNo < widget.rows.length
556
- ) {
557
- //越界判断
558
- const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
559
- const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
560
- if (!!colMerged) {
561
- let colArray = widget.rows[rowNo].cols;
562
- let unMergedCell = {};
563
- let startColIndex = null;
564
- for (let i = newColIdx; i >= 0; i--) {
565
- //查找该行已合并的主单元格
566
- if (!colArray[i].merged && colArray[i].options.colspan > 1) {
567
- startColIndex = i;
568
- unMergedCell = colArray[i];
569
- break;
570
- }
571
- }
572
-
573
- if (!!unMergedCell.options) {
574
- //如果有符合条件的unMergedCell
575
- let newColspan = unMergedCell.options.colspan + 1;
576
- this.setPropsOfMergedCols(
577
- widget.rows,
578
- rowNo,
579
- startColIndex,
580
- newColspan,
581
- unMergedCell.options.rowspan
582
- );
583
- rowNo += unMergedCell.options.rowspan;
584
- } else {
585
- rowNo += 1;
586
- }
587
- } else {
588
- //rowNo += 1
589
- rowNo += cellOfNextCol.options.rowspan || 1;
590
- }
591
- }
592
-
593
- this.emitHistoryChange();
594
- },
595
- insertH5TableCol(widget, insertPos, curRow, leftFlag) {
596
- let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
597
- if (!leftFlag) {
598
- //继续向右寻找同行第一个未被合并的单元格
599
- let tmpColIdx = newColIdx;
600
- let colFoundFlag = false;
601
- while (tmpColIdx < widget.rows[curRow].cols.length) {
602
- if (!widget.rows[curRow].cols[tmpColIdx].merged) {
603
- newColIdx = tmpColIdx;
604
- colFoundFlag = true;
605
- break;
606
- } else {
607
- tmpColIdx++;
608
- }
609
-
610
- if (!colFoundFlag) {
611
- newColIdx = widget.rows[curRow].cols.length;
612
- }
613
- }
614
- }
615
-
616
- widget.rows.forEach((row) => {
617
- let newCol = baseRefUtil.deepClone(
618
- this.getContainerByType("h5-table-cell")
619
- );
620
- newCol.id = "table-cell-" + baseRefUtil.generateId();
621
- newCol.options.name = newCol.id;
622
- newCol.merged = false;
623
- newCol.options.colspan = 1;
624
- newCol.options.rowspan = 1;
625
- newCol.widgetList.length = 0;
626
- row.cols.splice(newColIdx, 0, newCol);
627
- });
628
-
629
- let rowNo = 0;
630
- while (
631
- newColIdx < widget.rows[0].cols.length - 1 &&
632
- rowNo < widget.rows.length
633
- ) {
634
- //越界判断
635
- const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
636
- const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
637
- if (!!colMerged) {
638
- let colArray = widget.rows[rowNo].cols;
639
- let unMergedCell = {};
640
- let startColIndex = null;
641
- for (let i = newColIdx; i >= 0; i--) {
642
- //查找该行已合并的主单元格
643
- if (!colArray[i].merged && colArray[i].options.colspan > 1) {
644
- startColIndex = i;
645
- unMergedCell = colArray[i];
646
- break;
647
- }
648
- }
649
-
650
- if (!!unMergedCell.options) {
651
- //如果有符合条件的unMergedCell
652
- let newColspan = unMergedCell.options.colspan + 1;
653
- this.setPropsOfMergedCols(
654
- widget.rows,
655
- rowNo,
656
- startColIndex,
657
- newColspan,
658
- unMergedCell.options.rowspan
659
- );
660
- rowNo += unMergedCell.options.rowspan;
661
- } else {
662
- rowNo += 1;
663
- }
664
- } else {
665
- //rowNo += 1
666
- rowNo += cellOfNextCol.options.rowspan || 1;
667
- }
668
- }
669
-
670
- this.emitHistoryChange();
671
- },
672
- setPropsOfMergedCols(
673
- rowArray,
674
- startRowIndex,
675
- startColIndex,
676
- newColspan,
677
- rowspan
678
- ) {
679
- for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
680
- for (let j = startColIndex; j < startColIndex + newColspan; j++) {
681
- if (i === startRowIndex && j === startColIndex) {
682
- rowArray[i].cols[j].options.colspan = newColspan; //合并后的主单元格
683
- continue;
684
- }
685
-
686
- rowArray[i].cols[j].merged = true;
687
- rowArray[i].cols[j].options.colspan = newColspan;
688
- rowArray[i].cols[j].widgetList = [];
689
- }
690
- }
691
- },
692
-
693
- setPropsOfMergedRows(
694
- rowArray,
695
- startRowIndex,
696
- startColIndex,
697
- colspan,
698
- newRowspan
699
- ) {
700
- for (let i = startRowIndex; i < startRowIndex + newRowspan; i++) {
701
- for (let j = startColIndex; j < startColIndex + colspan; j++) {
702
- if (i === startRowIndex && j === startColIndex) {
703
- rowArray[i].cols[j].options.rowspan = newRowspan;
704
- continue;
705
- }
706
-
707
- rowArray[i].cols[j].merged = true;
708
- rowArray[i].cols[j].options.rowspan = newRowspan;
709
- rowArray[i].cols[j].widgetList = [];
710
- }
711
- }
712
- },
713
-
714
- setPropsOfSplitCol(
715
- rowArray,
716
- startRowIndex,
717
- startColIndex,
718
- colspan,
719
- rowspan
720
- ) {
721
- for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
722
- for (let j = startColIndex; j < startColIndex + colspan; j++) {
723
- rowArray[i].cols[j].merged = false;
724
- rowArray[i].cols[j].options.rowspan = 1;
725
- rowArray[i].cols[j].options.colspan = 1;
726
- }
727
- }
728
- },
729
-
730
- setPropsOfSplitRow(
731
- rowArray,
732
- startRowIndex,
733
- startColIndex,
734
- colspan,
735
- rowspan
736
- ) {
737
- for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
738
- for (let j = startColIndex; j < startColIndex + colspan; j++) {
739
- rowArray[i].cols[j].merged = false;
740
- rowArray[i].cols[j].options.rowspan = 1;
741
- rowArray[i].cols[j].options.colspan = 1;
742
- }
743
- }
744
- },
745
-
746
- mergeTableCol(rowArray, colArray, curRow, curCol, leftFlag, cellWidget) {
747
- let mergedColIdx = !!leftFlag
748
- ? curCol
749
- : curCol + colArray[curCol].options.colspan;
750
-
751
- // let remainedColIdx = !!leftFlag ? curCol - colArray[curCol - 1].options.colspan : curCol
752
- let remainedColIdx = !!leftFlag ? curCol - 1 : curCol;
753
- if (!!leftFlag) {
754
- //继续向左寻找同行未被合并的第一个单元格
755
- let tmpColIdx = remainedColIdx;
756
- while (tmpColIdx >= 0) {
757
- if (!rowArray[curRow].cols[tmpColIdx].merged) {
758
- remainedColIdx = tmpColIdx;
759
- break;
760
- } else {
761
- tmpColIdx--;
762
- }
763
- }
764
- }
765
-
766
- if (
767
- !!colArray[mergedColIdx].widgetList &&
768
- colArray[mergedColIdx].widgetList.length > 0
769
- ) {
770
- //保留widgetList
771
- if (
772
- !colArray[remainedColIdx].widgetList ||
773
- colArray[remainedColIdx].widgetList.length === 0
774
- ) {
775
- colArray[remainedColIdx].widgetList = baseRefUtil.deepClone(
776
- colArray[mergedColIdx].widgetList
777
- );
778
- }
779
- }
780
-
781
- let newColspan =
782
- colArray[mergedColIdx].options.colspan * 1 +
783
- colArray[remainedColIdx].options.colspan * 1;
784
- this.setPropsOfMergedCols(
785
- rowArray,
786
- curRow,
787
- remainedColIdx,
788
- newColspan,
789
- cellWidget.options.rowspan
790
- );
791
-
792
- this.emitHistoryChange();
793
- },
794
-
795
- mergeTableWholeRow(rowArray, colArray, rowIndex, colIndex) {
796
- //需要考虑操作的行存在已合并的单元格!!
797
- //整行所有单元格行高不一致不可合并!!
798
- let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
799
- let unmatchedFlag = false;
800
- for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
801
- if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
802
- unmatchedFlag = true;
803
- break;
804
- }
805
- }
806
- if (unmatchedFlag) {
807
- this.vueInstance.$message.info(
808
- this.vueInstance.i18nt(
809
- "designer.hint.rowspanNotConsistentForMergeEntireRow"
810
- )
811
- );
812
- return;
813
- }
814
-
815
- let widgetListCols = colArray.filter((colItem) => {
816
- return (
817
- !colItem.merged &&
818
- !!colItem.widgetList &&
819
- colItem.widgetList.length > 0
820
- );
821
- });
822
- if (!!widgetListCols && widgetListCols.length > 0) {
823
- //保留widgetList
824
- if (
825
- widgetListCols[0].id !== colArray[0].id &&
826
- (!colArray[0].widgetList || colArray[0].widgetList.length <= 0)
827
- ) {
828
- colArray[0].widgetList = baseRefUtil.deepClone(
829
- widgetListCols[0].widgetList
830
- );
831
- }
832
- }
833
-
834
- this.setPropsOfMergedCols(
835
- rowArray,
836
- rowIndex,
837
- 0,
838
- colArray.length,
839
- colArray[colIndex].options.rowspan
840
- );
841
-
842
- this.emitHistoryChange();
843
- },
844
-
845
- mergeTableRow(rowArray, curRow, curCol, aboveFlag, cellWidget) {
846
- let mergedRowIdx = !!aboveFlag
847
- ? curRow
848
- : curRow + cellWidget.options.rowspan;
849
-
850
- //let remainedRowIdx = !!aboveFlag ? curRow - cellWidget.options.rowspan : curRow
851
- let remainedRowIdx = !!aboveFlag ? curRow - 1 : curRow;
852
- if (!!aboveFlag) {
853
- //继续向上寻找同列未被合并的第一个单元格
854
- let tmpRowIdx = remainedRowIdx;
855
- while (tmpRowIdx >= 0) {
856
- if (!rowArray[tmpRowIdx].cols[curCol].merged) {
857
- remainedRowIdx = tmpRowIdx;
858
- break;
859
- } else {
860
- tmpRowIdx--;
861
- }
862
- }
863
- }
864
-
865
- if (
866
- !!rowArray[mergedRowIdx].cols[curCol].widgetList &&
867
- rowArray[mergedRowIdx].cols[curCol].widgetList.length > 0
868
- ) {
869
- //保留widgetList
870
- if (
871
- !rowArray[remainedRowIdx].cols[curCol].widgetList ||
872
- rowArray[remainedRowIdx].cols[curCol].widgetList.length === 0
873
- ) {
874
- rowArray[remainedRowIdx].cols[curCol].widgetList =
875
- baseRefUtil.deepClone(
876
- rowArray[mergedRowIdx].cols[curCol].widgetList
877
- );
878
- }
879
- }
880
-
881
- let newRowspan =
882
- rowArray[mergedRowIdx].cols[curCol].options.rowspan * 1 +
883
- rowArray[remainedRowIdx].cols[curCol].options.rowspan * 1;
884
- this.setPropsOfMergedRows(
885
- rowArray,
886
- remainedRowIdx,
887
- curCol,
888
- cellWidget.options.colspan,
889
- newRowspan
890
- );
891
-
892
- this.emitHistoryChange();
893
- },
894
-
895
- mergeTableWholeCol(rowArray, colArray, rowIndex, colIndex) {
896
- //需要考虑操作的列存在已合并的单元格!!
897
- //整列所有单元格列宽不一致不可合并!!
898
- let startColspan = rowArray[0].cols[colIndex].options.colspan;
899
- let unmatchedFlag = false;
900
- for (let i = 1; i < rowArray.length; i++) {
901
- if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
902
- unmatchedFlag = true;
903
- break;
904
- }
905
- }
906
- if (unmatchedFlag) {
907
- this.vueInstance.$message.info(
908
- this.vueInstance.i18nt(
909
- "designer.hint.colspanNotConsistentForMergeEntireColumn"
910
- )
911
- );
912
- return;
913
- }
914
-
915
- let widgetListCols = [];
916
- rowArray.forEach((rowItem) => {
917
- let tempCell = rowItem.cols[colIndex];
918
- if (
919
- !tempCell.merged &&
920
- !!tempCell.widgetList &&
921
- tempCell.widgetList.length > 0
922
- ) {
923
- widgetListCols.push(tempCell);
924
- }
925
- });
926
-
927
- let firstCellOfCol = rowArray[0].cols[colIndex];
928
- if (!!widgetListCols && widgetListCols.length > 0) {
929
- //保留widgetList
930
- if (
931
- widgetListCols[0].id !== firstCellOfCol.id &&
932
- (!firstCellOfCol.widgetList ||
933
- firstCellOfCol.widgetList.length <= 0)
934
- ) {
935
- firstCellOfCol.widgetList = baseRefUtil.deepClone(
936
- widgetListCols[0].widgetList
937
- );
938
- }
939
- }
940
-
941
- this.setPropsOfMergedRows(
942
- rowArray,
943
- 0,
944
- colIndex,
945
- firstCellOfCol.options.colspan,
946
- rowArray.length
947
- );
948
-
949
- this.emitHistoryChange();
950
- },
951
-
952
- undoMergeTableCol(rowArray, rowIndex, colIndex, colspan, rowspan) {
953
- this.setPropsOfSplitCol(rowArray, rowIndex, colIndex, colspan, rowspan);
954
-
955
- this.emitHistoryChange();
956
- },
957
-
958
- undoMergeTableRow(rowArray, rowIndex, colIndex, colspan, rowspan) {
959
- this.setPropsOfSplitRow(rowArray, rowIndex, colIndex, colspan, rowspan);
960
-
961
- this.emitHistoryChange();
962
- },
963
-
964
- deleteTableWholeCol(rowArray, colIndex) {
965
- //需考虑删除的是合并列!!
966
- let onlyOneColFlag = true;
967
- rowArray.forEach((ri) => {
968
- if (ri.cols[0].options.colspan !== rowArray[0].cols.length) {
969
- onlyOneColFlag = false;
970
- }
971
- });
972
- //仅剩一列则不可删除!!
973
- if (onlyOneColFlag) {
974
- this.vueInstance.$message.info(
975
- this.vueInstance.i18nt("designer.hint.lastColCannotBeDeleted")
976
- );
977
- return;
978
- }
979
-
980
- //整列所有单元格列宽不一致不可删除!!
981
- let startColspan = rowArray[0].cols[colIndex].options.colspan;
982
- let unmatchedFlag = false;
983
- for (let i = 1; i < rowArray.length; i++) {
984
- if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
985
- unmatchedFlag = true;
986
- break;
987
- }
988
- }
989
- if (unmatchedFlag) {
990
- this.vueInstance.$message.info(
991
- this.vueInstance.i18nt(
992
- "designer.hint.colspanNotConsistentForDeleteEntireColumn"
993
- )
994
- );
995
- return;
996
- }
997
-
998
- rowArray.forEach((rItem) => {
999
- rItem.cols.splice(colIndex, startColspan);
1000
- });
1001
-
1002
- this.emitHistoryChange();
1003
- },
1004
-
1005
- deleteTableWholeRow(rowArray, rowIndex) {
1006
- //需考虑删除的是合并行!!
1007
- let onlyOneRowFlag = true;
1008
- rowArray[0].cols.forEach((ci) => {
1009
- if (ci.options.rowspan !== rowArray.length) {
1010
- onlyOneRowFlag = false;
1011
- }
1012
- });
1013
- //仅剩一行则不可删除!!
1014
- if (onlyOneRowFlag) {
1015
- this.vueInstance.$message.info(
1016
- this.vueInstance.i18nt("designer.hint.lastRowCannotBeDeleted")
1017
- );
1018
- return;
1019
- }
1020
-
1021
- //整行所有单元格行高不一致不可删除!!
1022
- let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
1023
- let unmatchedFlag = false;
1024
- for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
1025
- if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
1026
- unmatchedFlag = true;
1027
- break;
1028
- }
1029
- }
1030
- if (unmatchedFlag) {
1031
- this.vueInstance.$message.info(
1032
- this.vueInstance.i18nt(
1033
- "designer.hint.rowspanNotConsistentForDeleteEntireRow"
1034
- )
1035
- );
1036
- return;
1037
- }
1038
-
1039
- rowArray.splice(rowIndex, startRowspan);
1040
-
1041
- this.emitHistoryChange();
1042
- },
1043
-
1044
- getContainerByType(typeName) {
1045
- let allWidgets = [
1046
- ...baseRefUtil.containers,
1047
- ...baseRefUtil.basicFields,
1048
- ...baseRefUtil.advancedFields,
1049
- ...baseRefUtil.customFields,
1050
- ...businessFields,
1051
- ];
1052
- let foundCon = null;
1053
- allWidgets.forEach((con) => {
1054
- if (!!con.category && !!con.type && con.type === typeName) {
1055
- foundCon = con;
1056
- }
1057
- });
1058
-
1059
- return foundCon;
1060
- },
1061
-
1062
- getFieldWidgetByType(typeName) {
1063
- let allWidgets = [
1064
- ...baseRefUtil.containers,
1065
- ...baseRefUtil.basicFields,
1066
- ...baseRefUtil.advancedFields,
1067
- ...baseRefUtil.customFields,
1068
- ...chartContainers,
1069
- ...chartWidgets,
1070
- ...businessFields,
1071
- ];
1072
- let foundWidget = null;
1073
- allWidgets.forEach((widget) => {
1074
- if (!!!widget.category && !!widget.type && widget.type === typeName) {
1075
- foundWidget = widget;
1076
- }
1077
- });
1078
-
1079
- return foundWidget;
1080
- },
1081
-
1082
- hasConfig(widget, configName) {
1083
- let originalWidget = null;
1084
- if (!!widget.category) {
1085
- originalWidget = this.getContainerByType(widget.type);
1086
- } else {
1087
- originalWidget = this.getFieldWidgetByType(widget.type);
1088
- }
1089
-
1090
- if (!originalWidget || !originalWidget.options) {
1091
- return false;
1092
- }
1093
-
1094
- return Object.keys(originalWidget.options).indexOf(configName) > -1;
1095
- },
1096
- /*upgradeWidgetConfig(oldWidget) {
1097
- let newWidget = null;
1098
- if (!!oldWidget.category) {
1099
- newWidget = this.getContainerByType(oldWidget.type);
1100
- } else {
1101
- newWidget = this.getFieldWidgetByType(oldWidget.type);
1102
- }
1103
-
1104
- if (!newWidget || !newWidget.options) {
1105
- return;
1106
- }
1107
-
1108
- Object.keys(newWidget.options).forEach(ck => {
1109
- if (!oldWidget.options.hasOwnProperty(ck)) {
1110
- oldWidget.options[ck] = baseRefUtil.deepClone(newWidget.options[ck]);
1111
- }
1112
- });
1113
- },*/
1114
- upgradeWidgetConfig(oldWidget) {
1115
- let newWidget = null;
1116
- if (!!oldWidget.category) {
1117
- newWidget = this.getContainerByType(oldWidget.type);
1118
- } else {
1119
- newWidget = this.getFieldWidgetByType(oldWidget.type);
1120
- }
1121
-
1122
- if (!newWidget || !newWidget.options) {
1123
- return;
1124
- }
1125
-
1126
- Object.keys(newWidget.options).forEach((ck) => {
1127
- if (!oldWidget.options.hasOwnProperty(ck)) {
1128
- let value = newWidget.options[ck];
1129
- let nullValue = Array.isArray(value) ? [] : null;
1130
- oldWidget.options[ck] = nullValue;
1131
- }
1132
- });
1133
- },
1134
-
1135
- upgradeFormConfig(oldFormConfig) {
1136
- Object.keys(this.formConfig).forEach((fc) => {
1137
- if (!oldFormConfig.hasOwnProperty(fc)) {
1138
- let value = this.formConfig[fc];
1139
- let nullValue = Array.isArray(value) ? [] : null;
1140
- oldFormConfig[fc] = baseRefUtil.deepClone(nullValue);
1141
- }
1142
- });
1143
- },
1144
-
1145
- cloneGridCol(widget, parentWidget) {
1146
- let newGridCol = baseRefUtil.deepClone(
1147
- this.getContainerByType("grid-col")
1148
- );
1149
- newGridCol.options.span = widget.options.span;
1150
- let tmpId = baseRefUtil.generateId();
1151
- newGridCol.id = "grid-col-" + tmpId;
1152
- newGridCol.options.name = "gridCol" + tmpId;
1153
-
1154
- parentWidget.cols.push(newGridCol);
1155
- },
1156
-
1157
- cloneContainer(containWidget) {
1158
- if (containWidget.type === "grid") {
1159
- let newGrid = baseRefUtil.deepClone(this.getContainerByType("grid"));
1160
- newGrid.id = newGrid.type + baseRefUtil.generateId();
1161
- newGrid.options.name = newGrid.id;
1162
- containWidget.cols.forEach((gridCol) => {
1163
- let newGridCol = baseRefUtil.deepClone(
1164
- this.getContainerByType("grid-col")
1165
- );
1166
- let tmpId = baseRefUtil.generateId();
1167
- newGridCol.id = "grid-col-" + tmpId;
1168
- newGridCol.options.name = "gridCol" + tmpId;
1169
- newGridCol.options.span = gridCol.options.span;
1170
- newGrid.cols.push(newGridCol);
1171
- });
1172
-
1173
- return newGrid;
1174
- } else if (containWidget.type === "table") {
1175
- let newTable = baseRefUtil.deepClone(
1176
- this.getContainerByType("table")
1177
- );
1178
- newTable.id = newTable.type + baseRefUtil.generateId();
1179
- newTable.options.name = newTable.id;
1180
- containWidget.rows.forEach((tRow) => {
1181
- let newRow = baseRefUtil.deepClone(tRow);
1182
- newRow.id = "table-row-" + baseRefUtil.generateId();
1183
- newRow.cols.forEach((col) => {
1184
- col.id = "table-cell-" + baseRefUtil.generateId();
1185
- col.options.name = col.id;
1186
- col.widgetList = []; //清空组件列表
1187
- });
1188
- newTable.rows.push(newRow);
1189
- });
1190
-
1191
- return newTable;
1192
- } else if (containWidget.type === "h5-table") {
1193
- let newTable = baseRefUtil.deepClone(
1194
- this.getContainerByType("h5-table")
1195
- );
1196
- newTable.id = newTable.type + baseRefUtil.generateId();
1197
- newTable.options.name = newTable.id;
1198
- containWidget.rows.forEach((tRow) => {
1199
- let newRow = baseRefUtil.deepClone(tRow);
1200
- newRow.id = "table-row-" + baseRefUtil.generateId();
1201
- newRow.cols.forEach((col) => {
1202
- col.id = "table-cell-" + baseRefUtil.generateId();
1203
- col.options.name = col.id;
1204
- col.widgetList = []; //清空组件列表
1205
- });
1206
- newTable.rows.push(newRow);
1207
- });
1208
-
1209
- return newTable;
1210
- } else {
1211
- //其他容器组件不支持clone操作
1212
- return null;
1213
- }
1214
- },
1215
-
1216
- moveUpWidget(parentList, indexOfParentList) {
1217
- if (!!parentList) {
1218
- if (indexOfParentList === 0) {
1219
- this.vueInstance.$message(
1220
- this.vueInstance.i18nt("designer.hint.moveUpFirstChildHint")
1221
- );
1222
- return;
1223
- }
1224
-
1225
- let tempWidget = parentList[indexOfParentList];
1226
- parentList.splice(indexOfParentList, 1);
1227
- parentList.splice(indexOfParentList - 1, 0, tempWidget);
1228
- }
1229
- },
1230
-
1231
- moveDownWidget(parentList, indexOfParentList) {
1232
- if (!!parentList) {
1233
- if (indexOfParentList === parentList.length - 1) {
1234
- this.vueInstance.$message(
1235
- this.vueInstance.i18nt("designer.hint.moveDownLastChildHint")
1236
- );
1237
- return;
1238
- }
1239
-
1240
- let tempWidget = parentList[indexOfParentList];
1241
- parentList.splice(indexOfParentList, 1);
1242
- parentList.splice(indexOfParentList + 1, 0, tempWidget);
1243
- }
1244
- },
1245
- copyNewFieldWidget(origin) {
1246
- let newWidget = baseRefUtil.deepClone(origin);
1247
- let sourceType = newWidget.type;
1248
- newWidget.type = newWidget.targetType || newWidget.type;
1249
- newWidget.sourceType = sourceType;
1250
- let tempId = baseRefUtil.generateId();
1251
- newWidget.id = newWidget.type.replace(/-/g, "") + tempId;
1252
- if (newWidget.hasOwnProperty("tableField")) {
1253
- newWidget.tableField = newWidget.id; //表字段
1254
- }
1255
-
1256
- // newWidget.options.name = newWidget.id;
1257
- // newWidget.options.label = newWidget.options.label || newWidget.type.toLowerCase();
1258
-
1259
- newWidget.nameReadonly
1260
- ? newWidget.options.label &&
1261
- newWidget.options.label.indexOf(".") > -1 &&
1262
- (newWidget.options.label = newWidget.options.label.substring(
1263
- newWidget.options.label.indexOf(".") + 1
1264
- ))
1265
- : ((newWidget.options.name = newWidget.id),
1266
- (newWidget.options.label =
1267
- newWidget.options.label || newWidget.type.toLowerCase()));
1268
- delete newWidget.displayName;
1269
- if (!newWidget.nameReadonly) {
1270
- newWidget.options.keyNameEnabled = true;
1271
- if (!newWidget.options.keyName)
1272
- newWidget.options.keyName = newWidget.id;
1273
- if (
1274
- newWidget.type === "vabUpload" ||
1275
- newWidget.type === "baseAttachment"
1276
- ) {
1277
- let keyNameSuffix = this.createKeyNameSuffix(newWidget.type);
1278
- // this.createKeyNameSuffix()
1279
- newWidget.options.keyName = this.createKeyName(
1280
- newWidget.type,
1281
- keyNameSuffix
1282
- );
1283
- newWidget.options.keyNameSuffix = keyNameSuffix;
1284
- }
1285
- }
1286
- if (newWidget.type === "dropdown") {
1287
- let dropdownItem1 = this.copyNewFieldWidget(
1288
- this.getFieldWidgetByType("dropdown-item")
1289
- );
1290
- dropdownItem1.options.label = "下拉按钮1";
1291
- let dropdownItem2 = this.copyNewFieldWidget(
1292
- this.getFieldWidgetByType("dropdown-item")
1293
- );
1294
- dropdownItem2.options.label = "下拉按钮2";
1295
- newWidget.widgetList.push(dropdownItem1);
1296
- newWidget.widgetList.push(dropdownItem2);
1297
- }
1298
- this.emitEvent("canvas-add-field", newWidget.options.name);
1299
- return newWidget;
1300
- },
1301
- createKeyName(type, suffix, options) {
1302
- let keyNameSuffix = suffix ? suffix : this.createKeyNameSuffix(type);
1303
- let keyNamePrefix = this.getKeyNamePrefix(type, options);
1304
- let keyName = null;
1305
- if (keyNamePrefix) {
1306
- keyName = keyNamePrefix + keyNameSuffix;
1307
- } else {
1308
- keyName = keyNameSuffix;
1309
- }
1310
- return keyName;
1311
- },
1312
- createKeyNameSuffix(type) {
1313
- let suffix = createUUID();
1314
- /*if (type === "vabUpload" || type === "baseAttachment") {
1315
- let formCode = vueInstance.reportTemplate.formCode;
1316
- suffix = formCode + "_" + suffix;
1317
- }*/
1318
- return suffix;
1319
- },
1320
- /* 开了「值存为URL」的附件字段存的是主表普通列(值是 URL 字符串),不再走
1321
- attachments_ 独立附件通道,keyName 不能带前缀——否则保存时会被
1322
- data-table-mixin 的 attachments_ 提取逻辑当附件包发走,主表列存不到 */
1323
- getKeyNamePrefix(type, options) {
1324
- if (options && options.urlValueEnabled) {
1325
- return null;
1326
- }
1327
- return keyNamePrefixMap[type] ?? null;
1328
- },
1329
- getFormCodePrefix(type) {
1330
- let prefix = this.getKeyNamePrefix(type) || "";
1331
- let attachmentPrefix =
1332
- prefix + vueInstance.reportTemplate.formCode + "_";
1333
- return attachmentPrefix;
1334
- },
1335
- createAttachmentSuffix() {
1336
- let type = "vabUpload";
1337
- return this.createKeyNameSuffix(type);
1338
- },
1339
- getAttachmentPrefix() {
1340
- let type = "vabUpload";
1341
- return this.getKeyNamePrefix(type);
1342
- },
1343
- getAttachmentFormCodePrefix() {
1344
- let type = "vabUpload";
1345
- let attachmentPrefix = this.getFormCodePrefix(type);
1346
- return attachmentPrefix;
1347
- },
1348
- createAttachmentKeyName(suffix) {
1349
- let type = "vabUpload";
1350
- let keyName = this.createKeyName(type, suffix);
1351
- return keyName;
1352
- },
1353
- copyNewContainerWidget(origin) {
1354
- let newCon = baseRefUtil.deepClone(origin);
1355
- let sourceType = newCon.type;
1356
- newCon.type = newCon.targetType || newCon.type;
1357
- newCon.sourceType = sourceType;
1358
- newCon.id = newCon.type.replace(/-/g, "") + baseRefUtil.generateId();
1359
- newCon.options.name = newCon.id;
1360
- if ((newCon.options.keyNameEnabled = true)) {
1361
- newCon.options.keyName = newCon.id;
1362
- }
1363
- if (newCon.hasOwnProperty("tableField")) {
1364
- newCon.tableField = newCon.id; //表字段
1365
- }
1366
- if (newCon.type === "grid") {
1367
- let newCol = baseRefUtil.deepClone(
1368
- this.getContainerByType("grid-col")
1369
- );
1370
- let tmpId = baseRefUtil.generateId();
1371
- newCol.id = "grid-col-" + tmpId;
1372
- newCol.options.name = "gridCol" + tmpId;
1373
- newCon.cols.push(newCol);
1374
- //
1375
- newCol = baseRefUtil.deepClone(newCol);
1376
- tmpId = baseRefUtil.generateId();
1377
- newCol.id = "grid-col-" + tmpId;
1378
- newCol.options.name = "gridCol" + tmpId;
1379
- newCon.cols.push(newCol);
1380
- } else if (newCon.type === "table") {
1381
- let newRow = {
1382
- cols: [],
1383
- };
1384
- newRow.id = "table-row-" + baseRefUtil.generateId();
1385
- newRow.merged = false;
1386
- for (let i = 0; i < 4; i++) {
1387
- let newCell = baseRefUtil.deepClone(
1388
- this.getContainerByType("table-cell")
1389
- );
1390
- newCell.id = "table-cell-" + baseRefUtil.generateId();
1391
- newCell.options.name = newCell.id;
1392
- newCell.merged = false;
1393
- newCell.options.colspan = 1;
1394
- newCell.options.rowspan = 1;
1395
- newRow.cols.push(newCell);
1396
- }
1397
- newCon.rows.push(newRow);
1398
- } else if (newCon.type === "tab") {
1399
- let newTabPane = baseRefUtil.deepClone(
1400
- this.getContainerByType("tab-pane")
1401
- );
1402
- newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
1403
- newTabPane.options.name = "tab1";
1404
- newTabPane.options.label = "tab 1";
1405
- newCon.tabs.push(newTabPane);
1406
- } else if (newCon.type === "data-table") {
1407
- let add_button = this.copyNewFieldWidget(
1408
- this.getFieldWidgetByType("add_button")
1409
- );
1410
- add_button.options.onClick =
1411
- "this.getWidgetRef('" +
1412
- newCon.options.name +
1413
- "').openEditDialog();";
1414
- newCon.buttons.push(add_button);
1415
- } else if (newCon.type === "detail" || newCon.type === "detail-plain") {
1416
- /* detail-plain 无标题栏,不预置标题栏按钮;其余 panes 结构与 detail 一致 */
1417
- if (newCon.type === "detail") {
1418
- let buttonCon1 = this.copyNewFieldWidget(
1419
- this.getFieldWidgetByType("reset_button")
1420
- );
1421
- // buttonCon1.options.label = "重置";
1422
-
1423
- let buttonCon2 = this.copyNewFieldWidget(
1424
- this.getFieldWidgetByType("save_button")
1425
- );
1426
- buttonCon2.options.label = "保存";
1427
-
1428
- newCon.widgetList.push(buttonCon1);
1429
- newCon.widgetList.push(buttonCon2);
1430
- }
1431
-
1432
- let newCol = baseRefUtil.deepClone(
1433
- this.getContainerByType("detail-pane")
1434
- );
1435
- let tmpId = baseRefUtil.generateId();
1436
- newCol.id = "detail-pane-" + tmpId;
1437
- newCol.options.name = "detailPane" + tmpId;
1438
- newCol.options.label = "隐藏信息";
1439
- newCol.options.hidden = true;
1440
-
1441
- let tableCon = this.copyNewContainerWidget(
1442
- this.getContainerByType("table")
1443
- );
1444
- newCol.widgetList.push(tableCon);
1445
- newCon.panes.push(newCol);
1446
-
1447
- newCol = baseRefUtil.deepClone(
1448
- this.getContainerByType("detail-pane")
1449
- );
1450
- tmpId = baseRefUtil.generateId();
1451
- newCol.id = "detail-pane-" + tmpId;
1452
- newCol.options.name = "detailPane" + tmpId;
1453
- newCol.options.label = "基础信息";
1454
-
1455
- tableCon = this.copyNewContainerWidget(
1456
- this.getContainerByType("table")
1457
- );
1458
- newCol.widgetList.push(tableCon);
1459
- newCon.panes.push(newCol);
1460
- //
1461
- newCol = baseRefUtil.deepClone(
1462
- this.getContainerByType("detail-pane")
1463
- );
1464
- tmpId = baseRefUtil.generateId();
1465
- newCol.id = "detail-pane-" + tmpId;
1466
- newCol.options.name = "detailPane" + tmpId;
1467
- newCol.options.label = "明细信息";
1468
- newCol.options.tableRef = tableCon.id;
1469
- let dataTableCon = this.copyNewContainerWidget(
1470
- this.getContainerByType("data-table")
1471
- );
1472
- newCol.widgetList.push(dataTableCon);
1473
- newCol.options.tableRef = dataTableCon.id;
1474
-
1475
- let buttonCon3 = this.copyNewFieldWidget(
1476
- this.getFieldWidgetByType("button")
1477
- );
1478
- buttonCon3.options.label = "新增";
1479
- buttonCon3.options.icon = "el-icon-search";
1480
- // buttonCon3.options.onClick = "this.getWidgetRef('" + dataTableCon.options.name + "').addTableData();"
1481
- buttonCon3.options.clickBindEvent = CLICK_BIND.ADD_TABLE_DATA;
1482
- Object.assign(buttonCon3.options.addTableDataConfig, {
1483
- tableRef: dataTableCon.options.name,
1484
- });
1485
-
1486
- newCol.buttonWidgetList.push(buttonCon3);
1487
- newCon.panes.push(newCol);
1488
-
1489
- newCol = baseRefUtil.deepClone(
1490
- this.getContainerByType("detail-pane")
1491
- );
1492
- tmpId = baseRefUtil.generateId();
1493
- newCol.id = "detail-pane-" + tmpId;
1494
- newCol.options.name = "detailPane" + tmpId;
1495
- newCol.options.label = "附件信息";
1496
- let vabUploadCon = this.copyNewFieldWidget(
1497
- this.getFieldWidgetByType("vabUpload")
1498
- ); //vabUpload
1499
- newCol.widgetList.push(vabUploadCon);
1500
- newCon.panes.push(newCol);
1501
-
1502
- /* 「详情模块(标签)」面板条目:type=detail-tabs + targetType=detail,落地后就是 detail,
1503
- 不是新的容器类型。与「详情模块」的区别是内容模块不直接挂在正文区,而是收进标签里,
1504
- 详见 docs/详情模块标签承载方案.md */
1505
- if (newCon.sourceType === "detail-tabs") {
1506
- // 上面已按 detail 的默认骨架建好一批内容模块,整体挪进第一个标签——
1507
- // 标签形态下正文区只放标签容器,不留散在标签外面的模块。
1508
- let presetPanes = newCon.panes.splice(0);
1509
-
1510
- // 标签内的模块由 detail-plain 承载:它自带一套独立锚点导航,
1511
- // 外层 baseTabs 探测不到标签内的模块(tab-item 不满足 getTabs 的两个条件)。
1512
- let plainCon = this.copyNewContainerWidget(
1513
- this.getContainerByType("detail-plain")
1514
- );
1515
- plainCon.panes = presetPanes; // 丢掉 detail-plain 自带的默认模块,用上面建好的这批
1516
- plainCon.options.hideNav = false; // schema 默认关导航,标签内要开
1517
-
1518
- let tabCon = this.copyNewContainerWidget(
1519
- this.getContainerByType("tab")
1520
- );
1521
- tabCon.tabs[0].widgetList.push(plainCon);
1522
-
1523
- // copyNewContainerWidget 只预置 1 个 tab-pane,只有一个标签页的标签栏看着像 bug,补第二个
1524
- let secondPane = baseRefUtil.deepClone(
1525
- this.getContainerByType("tab-pane")
1526
- );
1527
- secondPane.id = "tab-pane-" + baseRefUtil.generateId();
1528
- secondPane.options.name = "tab2";
1529
- secondPane.options.label = "tab 2";
1530
- tabCon.tabs.push(secondPane);
1531
-
1532
- newCon.panes.push(tabCon);
1533
- }
1534
- } else if (newCon.type === "table-column") {
1535
- newCon.options.label = "tableColumn";
1536
- } else if (newCon.type === "h5-card") {
1537
- let newCol = baseRefUtil.deepClone(
1538
- this.getContainerByType("h5-card-pane")
1539
- );
1540
- let tmpId = baseRefUtil.generateId();
1541
- newCol.id = "h5-card-pane-" + tmpId;
1542
- newCol.options.name = "h5CardPane" + tmpId;
1543
- newCol.options.label = "基本信息";
1544
- newCon.panes.push(newCol);
1545
- } else if (newCon.type === "detail-h5") {
1546
- /*let newTab = this.copyNewContainerWidget(this.getContainerByType('tab'));
1547
- newCon.panes.push(newTab)
1548
-
1549
- newTab.options.tabClass = "tab-box";
1550
- let newTabPane = newTab.tabs[0];
1551
- newTabPane.options.label = '基本信息';*/
1552
-
1553
- //基本信息
1554
- let newCard = this.copyNewContainerWidget(
1555
- this.getContainerByType("h5-card")
1556
- );
1557
- // newTabPane.widgetList.push(newCard);
1558
- newCon.panes.push(newCard);
1559
-
1560
- //明细信息
1561
- let newCardPane = this.copyNewContainerWidget(
1562
- this.getContainerByType("h5-card-pane")
1563
- );
1564
- newCardPane.options.label = "明细信息";
1565
- newCard.panes.push(newCardPane);
1566
-
1567
- //列表
1568
- let listH5 = this.copyNewContainerWidget(
1569
- this.getContainerByType("list-h5")
1570
- ); //vabUpload
1571
- newCardPane.widgetList.push(listH5);
1572
-
1573
- //列表新增按钮
1574
- let buttonCon = this.copyNewFieldWidget(
1575
- this.getFieldWidgetByType("button")
1576
- );
1577
- buttonCon.options.label = "新增";
1578
- buttonCon.options.icon = "el-icon-search";
1579
- buttonCon.options.onClick =
1580
- "this.getWidgetRef('" + listH5.options.name + "').addTableData();";
1581
- newCardPane.buttonWidgetList.push(buttonCon);
1582
-
1583
- //列表行查看按钮
1584
- buttonCon = this.copyNewFieldWidget(
1585
- this.getFieldWidgetByType("button")
1586
- );
1587
- buttonCon.options.rowFlag = true;
1588
- buttonCon.options.label = "查看";
1589
- buttonCon.options.icon = "el-icon-edit";
1590
- buttonCon.options.onClick =
1591
- "this.getWidgetRef('" +
1592
- listH5.options.name +
1593
- "').openRowDetailDialog(row);";
1594
- listH5.lineButtons.push(buttonCon);
1595
-
1596
- //附件信息
1597
- newCardPane = this.copyNewContainerWidget(
1598
- this.getContainerByType("h5-card-pane")
1599
- );
1600
- newCardPane.options.label = "附件信息";
1601
- newCard.panes.push(newCardPane);
1602
-
1603
- let vabUploadCon = this.copyNewFieldWidget(
1604
- this.getFieldWidgetByType("vabUpload")
1605
- ); //vabUpload
1606
- newCardPane.widgetList.push(vabUploadCon);
1607
- } else if (newCon.type === "h5-table") {
1608
- for (let i = 0; i < 4; i++) {
1609
- let newRow = {
1610
- cols: [],
1611
- };
1612
- newRow.id = "table-row-" + baseRefUtil.generateId();
1613
- newRow.merged = false;
1614
-
1615
- let newCell = baseRefUtil.deepClone(
1616
- this.getContainerByType("h5-table-cell")
1617
- );
1618
- newCell.id = "table-cell-" + baseRefUtil.generateId();
1619
- newCell.options.name = newCell.id;
1620
- newCell.merged = false;
1621
- newCell.options.colspan = 1;
1622
- newCell.options.rowspan = 1;
1623
- newRow.cols.push(newCell);
1624
-
1625
- let newInput = this.copyNewFieldWidget(
1626
- this.getFieldWidgetByType("input")
1627
- );
1628
- newCell.widgetList.push(newInput);
1629
-
1630
- newCon.rows.push(newRow);
1631
- }
1632
- } else if (newCon.type === "tree-pane") {
1633
- //初始化列表
1634
- let dataTableCon = this.copyNewContainerWidget(
1635
- this.getContainerByType("data-table")
1636
- );
1637
- dataTableCon.options.showPagination = true;
1638
- dataTableCon.options.showSearchArea = true;
1639
- dataTableCon.options.isQueryTable = true;
1640
- dataTableCon.options.tableHeight = "auto";
1641
- dataTableCon.options.accessReturnType = "2";
1642
-
1643
- newCon.widgetList.push(dataTableCon);
1644
-
1645
- let addButton = this.copyNewFieldWidget(
1646
- this.getFieldWidgetByType("add_button")
1647
- );
1648
- addButton.options.onClick =
1649
- "this.getWidgetRef('" +
1650
- dataTableCon.options.name +
1651
- "').openEditDialog();";
1652
- dataTableCon.buttons.push(addButton);
1653
-
1654
- let tableExportButton = this.copyNewFieldWidget(
1655
- this.getFieldWidgetByType("table-export-button")
1656
- );
1657
- tableExportButton.options.tableExportParam =
1658
- "return { title: '导出', targetRef: '" +
1659
- dataTableCon.options.name +
1660
- "'}";
1661
- dataTableCon.buttons.push(tableExportButton);
1662
-
1663
- // 两个查询条件的值由树节点点击注入,勾上「固定查询条件」后
1664
- // 刷新、查询条件设置的还原/确定都不会把它清掉
1665
- let searchInput = this.copyNewFieldWidget(
1666
- this.getFieldWidgetByType("input")
1667
- );
1668
- searchInput.options.disabled = true;
1669
- searchInput.options.fixedQuery = true;
1670
- searchInput.options.label = newCon.options.treeLabel;
1671
- dataTableCon.widgetList.push(searchInput);
1672
-
1673
- let searchIdInput = this.copyNewFieldWidget(
1674
- this.getFieldWidgetByType("input")
1675
- );
1676
- searchIdInput.options.disabled = true;
1677
- searchIdInput.options.hidden = true;
1678
- searchIdInput.options.fixedQuery = true;
1679
- searchIdInput.options.label = `隐藏${newCon.options.treeLabel}ID`;
1680
- dataTableCon.widgetList.push(searchIdInput);
1681
-
1682
- // 存量表单没有 fixedQuery 开关,仍靠 ignoreFields 兜底刷新按钮;
1683
- // 新建的表单两条通道并存(取并集),不冲突
1684
- dataTableCon.options.onResetTable = `this.resetEvent({\n ignoreFields:['${searchInput.options.name}', '${searchIdInput.options.name}']\n});`;
1685
-
1686
- //初始化树
1687
- let treeCon = this.copyNewContainerWidget(
1688
- this.getContainerByType("tree")
1689
- );
1690
- treeCon.options.onNodeClick = `this.getWidgetRef('${searchInput.options.name}').setValue(data.label);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(data.id);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
1691
-
1692
- newCon.options.onTreeLabelClick = `this.getWidgetRef('${treeCon.options.name}').setCurrentKey();\nthis.getWidgetRef('${searchInput.options.name}').setValue(null);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(null);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
1693
- newCon.leftWidgetList.push(treeCon);
1694
- }
1695
- //newCon.options.customClass = []
1696
-
1697
- delete newCon.displayName;
1698
- return newCon;
1699
- },
1700
-
1701
- addContainerByDbClick(container) {
1702
- let newCon = this.copyNewContainerWidget(container);
1703
- this.widgetList.push(newCon);
1704
- this.setSelected(newCon);
1705
- },
1706
-
1707
- addFieldByDbClick(widget) {
1708
- let newWidget = this.copyNewFieldWidget(widget);
1709
- if (!!this.selectedWidget && this.selectedWidget.type === "tab") {
1710
- //获取当前激活的tabPane
1711
- let activeTab = this.selectedWidget.tabs[0];
1712
- this.selectedWidget.tabs.forEach((tabPane) => {
1713
- if (!!tabPane.options.active) {
1714
- activeTab = tabPane;
1715
- }
1716
- });
1717
-
1718
- !!activeTab && activeTab.widgetList.push(newWidget);
1719
- } else if (!!this.selectedWidget && !!this.selectedWidget.widgetList) {
1720
- this.selectedWidget.widgetList.push(newWidget);
1721
- } else {
1722
- this.widgetList.push(newWidget);
1723
- }
1724
-
1725
- this.setSelected(newWidget);
1726
- this.emitEvent("canvas-add-field", newWidget.options.name),
1727
- this.emitHistoryChange();
1728
- },
1729
- /**
1730
- * 删除详情容器下的一个 pane。
1731
- * @param gridWidget 详情容器(detail / detail-plain)
1732
- * @param paneOrIdx pane 的 widget 引用,或它在 panes 中的下标。
1733
- * detail 的属性面板按 type 做了显隐,下标不再可靠,故走引用;
1734
- * detail-plain 的属性面板仍传下标,这里一并兼容。
1735
- */
1736
- deletePaneOfDetail(gridWidget, paneOrIdx) {
1737
- if (!gridWidget || !gridWidget.panes) return;
1738
- let isIdx = typeof paneOrIdx === "number";
1739
- let colIdx = isIdx ? paneOrIdx : gridWidget.panes.indexOf(paneOrIdx);
1740
- if (colIdx < 0) return;
1741
- gridWidget.panes.splice(colIdx, 1);
1742
- },
1743
- cloneDetailPane(widget, parentWidget) {
1744
- let newGridCol = baseRefUtil.deepClone(
1745
- this.getContainerByType("detail-pane")
1746
- );
1747
- let tmpId = baseRefUtil.generateId();
1748
- newGridCol.id = "detail-pane-" + tmpId;
1749
- newGridCol.options.name = "detailPane" + tmpId;
1750
- newGridCol.options.label = widget.options.label;
1751
- parentWidget.panes.push(newGridCol);
1752
- },
1753
- cloneH5CardPanePane(widget, parentWidget) {
1754
- let newGridCol = baseRefUtil.deepClone(
1755
- this.getContainerByType("h5-card-pane")
1756
- );
1757
- let tmpId = baseRefUtil.generateId();
1758
- newGridCol.id = "h5-card-pane-" + tmpId;
1759
- newGridCol.options.name = "h5CardPane" + tmpId;
1760
- newGridCol.options.label = widget.options.label;
1761
- parentWidget.panes.push(newGridCol);
1762
- },
1763
-
1764
- addNewPaneOfDetail(gridWidget) {
1765
- const cols = gridWidget.panes;
1766
- let newGridCol = baseRefUtil.deepClone(
1767
- this.getContainerByType("detail-pane")
1768
- );
1769
- let tmpId = baseRefUtil.generateId();
1770
- newGridCol.id = "detail-pane-" + tmpId;
1771
- newGridCol.options.name = "detailPane" + tmpId;
1772
- newGridCol.options.label = "detailPane" + tmpId;
1773
- // 默认添加一个栅格控件到新 pane 的 widgetList 中,含3列平均分布
1774
- let defaultGrid = baseRefUtil.deepClone(
1775
- this.getContainerByType("grid")
1776
- );
1777
- defaultGrid.id = "grid-" + baseRefUtil.generateId();
1778
- // 添加3列,每列 span=8(24栏栅格均分)
1779
- for (let i = 0; i < 3; i++) {
1780
- let col = baseRefUtil.deepClone(
1781
- this.getContainerByType("grid-col")
1782
- );
1783
- col.id = "grid-col-" + baseRefUtil.generateId();
1784
- col.options.span = 8;
1785
- defaultGrid.cols.push(col);
1786
- }
1787
- newGridCol.widgetList.push(defaultGrid);
1788
- gridWidget.panes.push(newGridCol);
1789
- },
1790
-
1791
- deleteColOfGrid(gridWidget, colIdx) {
1792
- if (!!gridWidget && !!gridWidget.cols) {
1793
- gridWidget.cols.splice(colIdx, 1);
1794
- }
1795
- },
1796
-
1797
- addNewColOfGrid(gridWidget) {
1798
- const cols = gridWidget.cols;
1799
- let newGridCol = baseRefUtil.deepClone(
1800
- this.getContainerByType("grid-col")
1801
- );
1802
- let tmpId = baseRefUtil.generateId();
1803
- newGridCol.id = "grid-col-" + tmpId;
1804
- newGridCol.options.name = "gridCol" + tmpId;
1805
- if (!!cols && cols.length > 0) {
1806
- let spanSum = 0;
1807
- cols.forEach((col) => {
1808
- spanSum += col.options.span;
1809
- });
1810
-
1811
- if (spanSum >= 24) {
1812
- //this.$message.info('列栅格之和超出24')
1813
- console.log("列栅格之和超出24");
1814
- gridWidget.cols.push(newGridCol);
1815
- } else {
1816
- newGridCol.options.span = 24 - spanSum > 12 ? 12 : 24 - spanSum;
1817
- gridWidget.cols.push(newGridCol);
1818
- }
1819
- } else {
1820
- gridWidget.cols = [newGridCol];
1821
- }
1822
- },
1823
-
1824
- addTabPaneOfTabs(tabsWidget) {
1825
- const tabPanes = tabsWidget.tabs;
1826
- let newTabPane = baseRefUtil.deepClone(
1827
- this.getContainerByType("tab-pane")
1828
- );
1829
- newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
1830
- newTabPane.options.name = newTabPane.id;
1831
- newTabPane.options.label = "tab " + (tabPanes.length + 1);
1832
- tabPanes.push(newTabPane);
1833
- },
1834
-
1835
- deleteTabPaneOfTabs(tabsWidget, tpIdx) {
1836
- tabsWidget.tabs.splice(tpIdx, 1);
1837
- },
1838
-
1839
- addDropdownItem(tabsWidget) {
1840
- const tabPanes = tabsWidget.widgetList;
1841
- let newTabPane = baseRefUtil.deepClone(
1842
- this.getFieldWidgetByType("dropdown-item")
1843
- );
1844
- newTabPane.id = "dropdown-item-" + baseRefUtil.generateId();
1845
- newTabPane.options.name = newTabPane.id;
1846
- newTabPane.options.label = "dropdown-item " + (tabPanes.length + 1);
1847
- tabPanes.push(newTabPane);
1848
- },
1849
-
1850
- deleteDropdownItem(tabsWidget, tpIdx) {
1851
- tabsWidget.widgetList.splice(tpIdx, 1);
1852
- },
1853
-
1854
- emitEvent(evtName, evtData) {
1855
- //用于兄弟组件发射事件
1856
- this.vueInstance.$emit(evtName, evtData);
1857
- },
1858
-
1859
- handleEvent(evtName, callback) {
1860
- //用于兄弟组件接收事件
1861
- this.vueInstance.$on(evtName, (data) => callback(data));
1862
- },
1863
-
1864
- setCssClassList(cssClassList) {
1865
- this.cssClassList = cssClassList;
1866
- },
1867
-
1868
- getCssClassList() {
1869
- return this.cssClassList;
1870
- },
1871
-
1872
- registerFormWidget(formWidget) {
1873
- this.formWidget = formWidget;
1874
- },
1875
-
1876
- initHistoryData() {
1877
- this.loadFormContentFromStorage();
1878
- this.historyData.index++;
1879
- this.historyData.steps[this.historyData.index] = {
1880
- widgetList: baseRefUtil.deepClone(this.widgetList),
1881
- formConfig: baseRefUtil.deepClone(this.formConfig),
1882
- };
1883
- },
1884
-
1885
- emitHistoryChange() {
1886
- //console.log('------------', 'Form history changed!')
1887
-
1888
- if (this.historyData.index === this.historyData.maxStep - 1) {
1889
- this.historyData.steps.shift();
1890
- } else {
1891
- this.historyData.index++;
1892
- }
1893
-
1894
- this.historyData.steps[this.historyData.index] = {
1895
- widgetList: baseRefUtil.deepClone(this.widgetList),
1896
- formConfig: baseRefUtil.deepClone(this.formConfig),
1897
- };
1898
-
1899
- this.saveFormContentToStorage();
1900
-
1901
- if (this.historyData.index < this.historyData.steps.length - 1) {
1902
- this.historyData.steps = this.historyData.steps.slice(
1903
- 0,
1904
- this.historyData.index + 1
1905
- );
1906
- }
1907
-
1908
- //console.log('history', this.historyData.index)
1909
- },
1910
-
1911
- saveCurrentHistoryStep() {
1912
- this.historyData.steps[this.historyData.index] = baseRefUtil.deepClone({
1913
- widgetList: this.widgetList,
1914
- formConfig: this.formConfig,
1915
- });
1916
-
1917
- this.saveFormContentToStorage();
1918
- },
1919
-
1920
- undoHistoryStep() {
1921
- if (this.historyData.index !== 0) {
1922
- this.historyData.index--;
1923
- }
1924
- //console.log('undo', this.historyData.index)
1925
-
1926
- this.widgetList = baseRefUtil.deepClone(
1927
- this.historyData.steps[this.historyData.index].widgetList
1928
- );
1929
- this.formConfig = baseRefUtil.deepClone(
1930
- this.historyData.steps[this.historyData.index].formConfig
1931
- );
1932
- },
1933
-
1934
- redoHistoryStep() {
1935
- if (this.historyData.index !== this.historyData.steps.length - 1) {
1936
- this.historyData.index++;
1937
- }
1938
- //console.log('redo', this.historyData.index)
1939
-
1940
- this.widgetList = baseRefUtil.deepClone(
1941
- this.historyData.steps[this.historyData.index].widgetList
1942
- );
1943
- this.formConfig = baseRefUtil.deepClone(
1944
- this.historyData.steps[this.historyData.index].formConfig
1945
- );
1946
- },
1947
-
1948
- undoEnabled() {
1949
- return this.historyData.index > 0 && this.historyData.steps.length > 0;
1950
- },
1951
-
1952
- redoEnabled() {
1953
- return this.historyData.index < this.historyData.steps.length - 1;
1954
- },
1955
-
1956
- saveFormContentToStorage() {
1957
- window.localStorage.setItem(
1958
- "widget__list__backup",
1959
- JSON.stringify(this.widgetList)
1960
- );
1961
- window.localStorage.setItem(
1962
- "form__config__backup",
1963
- JSON.stringify(this.formConfig)
1964
- );
1965
- },
1966
-
1967
- loadFormContentFromStorage() {
1968
- let widgetListBackup = window.localStorage.getItem(
1969
- "widget__list__backup"
1970
- );
1971
- if (!!widgetListBackup) {
1972
- this.widgetList = JSON.parse(widgetListBackup);
1973
- }
1974
-
1975
- let formConfigBackup = window.localStorage.getItem(
1976
- "form__config__backup"
1977
- );
1978
- if (!!formConfigBackup) {
1979
- //this.formConfig = JSON.parse(formConfigBackup)
1980
- baseRefUtil.overwriteObj(
1981
- this.formConfig,
1982
- JSON.parse(formConfigBackup)
1983
- ); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
1984
- }
1985
- },
1986
- getColumnWidget(row, isEdit) {
1987
- //获取
1988
- let formatS = isEdit ? row.editFormatS : row.formatS;
1989
- let type = columnFormatMap[formatS];
1990
- if (!type) return null;
1991
- if (isEdit) {
1992
- if (row.editWidget) {
1993
- return row.editWidget;
1994
- }
1995
- if (row.editColumnOption) {
1996
- let fieldWidget = this.copyNewFieldWidget(
1997
- this.getFieldWidgetByType(type)
1998
- );
1999
- fieldWidget.options = row.editColumnOption;
2000
- return fieldWidget;
2001
- }
2002
- } else {
2003
- if (row.widget) {
2004
- return row.widget;
2005
- }
2006
- if (row.columnOption) {
2007
- let fieldWidget = this.copyNewFieldWidget(
2008
- this.getFieldWidgetByType(type)
2009
- );
2010
- fieldWidget.options = row.columnOption;
2011
- return fieldWidget;
2012
- }
2013
- }
2014
- return this.createColumnWidget(row, isEdit);
2015
- },
2016
- getIsFileWidget(type) {
2017
- return type === "vabUpload" || type === "baseAttachment";
2018
- },
2019
- createColumnWidget(row, isEdit) {
2020
- let formatS = isEdit ? row.editFormatS : row.formatS;
2021
- let type = columnFormatMap[formatS];
2022
- if (!type) return null;
2023
-
2024
- let columnSelectedWidget = null;
2025
- if (type) {
2026
- columnSelectedWidget = this.copyNewFieldWidget(
2027
- this.getFieldWidgetByType(type)
2028
- );
2029
-
2030
- if (columnSelectedWidget.options.hasOwnProperty("required")) {
2031
- columnSelectedWidget.options.required = row.required || false;
2032
- }
2033
-
2034
- if ("editDelete" === formatS) {
2035
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2036
- columnSelectedWidget.options.label = "删除";
2037
- columnSelectedWidget.options.labelHidden = true;
2038
- columnSelectedWidget.options.hiddenByWf = true;
2039
- columnSelectedWidget.options.onClick =
2040
- "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
2041
- } else if ("editButton" === formatS) {
2042
- columnSelectedWidget.options.prefixIcon = "el-icon-edit";
2043
- columnSelectedWidget.options.label = "查看";
2044
- columnSelectedWidget.options.labelHidden = true;
2045
- columnSelectedWidget.options.onClick =
2046
- "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
2047
- } else if ("addSiblingEditRow" === formatS) {
2048
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2049
- columnSelectedWidget.options.label = "新增兄弟节点";
2050
- columnSelectedWidget.options.labelHidden = false;
2051
- columnSelectedWidget.options.onClick =
2052
- "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
2053
- } else if ("addChildTreeRow" === formatS) {
2054
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2055
- columnSelectedWidget.options.label = "新增子节点";
2056
- columnSelectedWidget.options.labelHidden = false;
2057
- columnSelectedWidget.options.onClick =
2058
- "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
2059
- } else if ("moveUpRow" === formatS) {
2060
- columnSelectedWidget.options.label = "↑上移";
2061
- columnSelectedWidget.options.labelHidden = false;
2062
- columnSelectedWidget.options.onClick =
2063
- "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
2064
- } else if ("moveDownRow" === formatS) {
2065
- columnSelectedWidget.options.label = "↓下移";
2066
- columnSelectedWidget.options.labelHidden = false;
2067
- columnSelectedWidget.options.onClick =
2068
- "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
2069
- } else if ("removeTreeRow" === formatS) {
2070
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2071
- columnSelectedWidget.options.label = "删除";
2072
- columnSelectedWidget.options.labelHidden = true;
2073
- columnSelectedWidget.options.onClick =
2074
- "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
2075
- }
2076
-
2077
- if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
2078
- if (!this.getIsFileWidget(type)) {
2079
- columnSelectedWidget.options.keyName = row.prop;
2080
- }
2081
-
2082
- columnSelectedWidget.options.keyNameEnabled = true;
2083
- } else {
2084
- columnSelectedWidget.options.name = row.prop;
2085
- }
2086
-
2087
- if (type === "dropdown") {
2088
- columnSelectedWidget.options.dropdownType = "link";
2089
- } else if (type !== "button" && type !== "a-link") {
2090
- columnSelectedWidget.options.label = row.label;
2091
- columnSelectedWidget.options.labelHidden = true;
2092
- }
2093
- }
2094
- return columnSelectedWidget;
2095
- },
2096
- };
2097
- };
2098
- })();
2099
-
2100
- export const createDesigner = createDesigner0;
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 {
10
+ deepClone,
11
+ generateId,
12
+ getDefaultFormConfig,
13
+ overwriteObj,
14
+ createUUID,
15
+ columnFormatMap,
16
+ } from "../../../components/xform/utils/util";
17
+ import { CLICK_BIND } from "./setting-panel/property-editor/field-button/clickBindActions";
18
+ import {
19
+ containers,
20
+ advancedFields,
21
+ basicFields,
22
+ customFields,
23
+ businessFields,
24
+ } from "../../../components/xform/form-designer/widget-panel/widgetsConfig.js";
25
+ import { VARIANT_FORM_VERSION } from "../../../components/xform/utils/config";
26
+ import { keyNamePrefixMap } from "../../../components/xform/form-designer/widget-panel/widgetsConfig";
27
+
28
+ let createDesigner0;
29
+ const baseRefUtil = {
30
+ deepClone,
31
+ generateId,
32
+ getDefaultFormConfig,
33
+ overwriteObj,
34
+ containers,
35
+ advancedFields,
36
+ basicFields,
37
+ customFields,
38
+ VARIANT_FORM_VERSION,
39
+ };
40
+
41
+ let chartContainers = [],
42
+ chartWidgets = [];
43
+
44
+ (function () {
45
+ createDesigner0 = function (vueInstance) {
46
+ let defaultFormConfig = baseRefUtil.deepClone(
47
+ baseRefUtil.getDefaultFormConfig()
48
+ );
49
+
50
+ return {
51
+ widgetList: [],
52
+ formConfig: {
53
+ cssCode: "",
54
+ gridConfig: {
55
+ accessReturnType: 1,
56
+ isLoadDataByAccess: false,
57
+ },
58
+ scriptList: [],
59
+ formType: 0,
60
+ dialogScope: null,
61
+ getConfig: {
62
+ accessType: "1",
63
+ accessUrl: null,
64
+ accessParam: null,
65
+ accessCallback: null,
66
+ scriptName: null,
67
+ scriptCode: null,
68
+ },
69
+ saveConfig: {
70
+ accessType: "1",
71
+ accessUrl: null,
72
+ accessParam: null,
73
+ accessCallback: null,
74
+ scriptName: null,
75
+ scriptCode: null,
76
+ },
77
+ editFormCode: null,
78
+ editFormName: null,
79
+ searchDialogNameField: null,
80
+ searchDialogUniqueField: null,
81
+ entity: null,
82
+ wfEnabled: false,
83
+ isLoadEntity: false,
84
+ formScriptCode: "getOne",
85
+ formScriptParam: null,
86
+ formScriptSuccess: null,
87
+ saveScriptCode: "saveUpdate",
88
+ wfConfig: null,
89
+ wfStartBindSave: false,
90
+ wfStartConfirmText: null,
91
+ wfAgreenBindSave: false,
92
+ wfAgreeConfigData: [],
93
+ wfConfigDataEnabled: false,
94
+ wfConfigData: [],
95
+ multiTabEnabled: false,
96
+ multiTabLabelField: null,
97
+ addTabEnabled: false, // 新增打开独立页签(不走「常规」页签)
98
+ submitBehavior: "refreshCurrent", // 提交后行为: refreshCurrent(默认,留在详情页) | closeToList
99
+ billNavEnabled: false, // 详情页签显示「上一单/下一单」翻单按钮
100
+ addFormCode: null,
101
+ addFormName: null,
102
+ wfTheme: null,
103
+ otherTabEnabled: false,
104
+ otherTabList: [],
105
+ hideNormalTab: false,
106
+ customListTabLabel: null,
107
+ globalConfig: null,
108
+ // 表单级动态字段规则
109
+ dynamicFieldEnabled: false,
110
+ dynamicFieldRunMode: "auto",
111
+ dynamicFieldAllowValue: false,
112
+ dynamicFieldSourceType: "local",
113
+ dynamicFieldRules: [],
114
+ dynamicFieldScriptCode: null,
115
+ dynamicFieldScriptParam: null,
116
+ dynamicFieldTriggerFields: [],
117
+ },
118
+ dataSources: [], //数据源
119
+
120
+ selectedId: null,
121
+ selectedWidget: null,
122
+ selectedWidgetName: null, //选中组件名称(唯一)
123
+ vueInstance: vueInstance,
124
+
125
+ formWidget: null, //表单设计容器
126
+
127
+ cssClassList: [], //自定义样式列表
128
+
129
+ historyData: {
130
+ index: -1, //index: 0,
131
+ maxStep: 20,
132
+ steps: [],
133
+ },
134
+
135
+ initDesigner(resetFormJson) {
136
+ this.widgetList = [];
137
+ this.formConfig = baseRefUtil.deepClone(defaultFormConfig);
138
+ this.dataSources = [];
139
+
140
+ //输出版本信息和语雀链接
141
+ /* console.info(`%cVariantForm %cVer${baseRefUtil.VARIANT_FORM_VERSION} %chttps://www.yuque.com/visualdev/vform`,
142
+ "color:#409EFF;font-size: 22px;font-weight:bolder",
143
+ "color:#999;font-size: 12px",
144
+ "color:#333"
145
+ ); */
146
+
147
+ /*if (!resetFormJson) {
148
+ this.initHistoryData();
149
+ }*/
150
+ },
151
+
152
+ clearDesigner(skipHistoryChange) {
153
+ let emptyWidgetListFlag = this.widgetList.length === 0;
154
+ /* 版式是"当前在设计哪一端",不是表单内容的一部分。defaultFormConfig 里没有
155
+ layoutType,overwriteObj 之后 getLayoutType() 会退回 "PC" —— 在 H5 模板里
156
+ 点一下「清空」,左侧面板就跳回 PC 组件列表了。先存后还。 */
157
+ let keepLayoutType = this.getLayoutType();
158
+ this.widgetList = [];
159
+ this.selectedId = null;
160
+ this.selectedWidgetName = null;
161
+ this.selectedWidget = {}; //this.selectedWidget = null
162
+ baseRefUtil.overwriteObj(this.formConfig, defaultFormConfig); //
163
+ this.formConfig.gridConfig = defaultFormConfig.gridConfig;
164
+ this.formConfig.layoutType = keepLayoutType;
165
+
166
+ if (!!skipHistoryChange) {
167
+ //什么也不做!!
168
+ } else if (!emptyWidgetListFlag) {
169
+ this.emitHistoryChange();
170
+ } else {
171
+ this.saveCurrentHistoryStep();
172
+ }
173
+ },
174
+
175
+ loadPresetCssCode(preCssCode) {
176
+ if (this.formConfig.cssCode === "" && !!preCssCode) {
177
+ this.formConfig.cssCode = preCssCode;
178
+ }
179
+ },
180
+
181
+ getLayoutType() {
182
+ return this.formConfig.layoutType || "PC";
183
+ },
184
+
185
+ changeLayoutType(newType) {
186
+ this.formConfig.layoutType = newType;
187
+ },
188
+
189
+ getImportTemplate() {
190
+ return {
191
+ widgetList: [],
192
+ // formConfig: baseRefUtil.deepClone(this.formConfig)
193
+ formConfig: baseRefUtil.deepClone(defaultFormConfig),
194
+ };
195
+ },
196
+
197
+ handleImportJson(formJson) {
198
+ let formConfig = formJson.formConfig;
199
+ if (formConfig.formCode === vueInstance?.reportTemplate?.formCode) {
200
+ return;
201
+ }
202
+ let widgetArr = formJson.widgetList;
203
+ let itemFieldMap = {
204
+ grid: "cols",
205
+ table: "rows",
206
+ "table-cell": "widgetList",
207
+ "h5-table": "rows",
208
+ "h5-table-cell": "widgetList",
209
+ tab: "tabs",
210
+ "tab-pane": "widgetList",
211
+ "grid-col": "widgetList",
212
+ "vf-box": "widgetList",
213
+ card: "widgetList",
214
+ detail: "panes",
215
+ "detail-plain": "panes",
216
+ "detail-pane": "widgetList",
217
+ "detail-h5": "panes",
218
+ "h5-card": "panes",
219
+ "h5-card-pane": "widgetList",
220
+ };
221
+ let loopDo = (widgetList) => {
222
+ if (!widgetList) return;
223
+ widgetList.forEach((widget) => {
224
+ if (widget.type === "data-table" || widget.type === "list-h5") {
225
+ let vailColumns = widget.options.tableColumns.filter(
226
+ (item) => item.prop && item.label
227
+ );
228
+ vailColumns.forEach((item) => {
229
+ if (item.formatS === "editAttachment") {
230
+ let prop = item.prop;
231
+ let columnOption = item.columnOption;
232
+ let editColumnOption = item.editColumnOption;
233
+
234
+ let suffix = this.createAttachmentSuffix();
235
+ let keyName = this.createAttachmentKeyName(suffix);
236
+ if (columnOption) {
237
+ columnOption.keyName = keyName;
238
+ columnOption.keyNameSuffix = suffix;
239
+ }
240
+ if (editColumnOption) {
241
+ editColumnOption.keyName = keyName;
242
+ editColumnOption.keyNameSuffix = suffix;
243
+ }
244
+ item.prop = keyName;
245
+ }
246
+ });
247
+ } else if (
248
+ widget.type === "vabUpload" ||
249
+ widget.type === "baseAttachment"
250
+ ) {
251
+ let suffix = this.createAttachmentSuffix();
252
+ let keyName = this.createAttachmentKeyName(suffix);
253
+ widget.options.keyName = keyName;
254
+ widget.options.keyNameSuffix = suffix;
255
+ } else {
256
+ if (widget.category === "container") {
257
+ let itemField = itemFieldMap[widget.type];
258
+ if (itemField) {
259
+ if ("table" === widget.type) {
260
+ widget[itemField].forEach((item) => {
261
+ loopDo(item.cols);
262
+ });
263
+ } else if ("h5-table" === widget.type) {
264
+ widget[itemField].forEach((item) => {
265
+ loopDo(item.cols);
266
+ });
267
+ } else {
268
+ loopDo(widget[itemField]);
269
+ }
270
+ }
271
+ }
272
+ }
273
+ });
274
+ };
275
+ loopDo(widgetArr);
276
+ },
277
+ loadFormJson(formJson) {
278
+ let modifiedFlag = false;
279
+
280
+ if (!!formJson && !!formJson.widgetList) {
281
+ this.widgetList = formJson.widgetList;
282
+ modifiedFlag = true;
283
+ }
284
+ if (!!formJson && !!formJson.formConfig) {
285
+ //this.formConfig = importObj.formConfig
286
+ baseRefUtil.overwriteObj(
287
+ this.formConfig,
288
+ formJson.formConfig
289
+ ); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
290
+ modifiedFlag = true;
291
+ }
292
+
293
+ if (modifiedFlag) {
294
+ this.emitEvent("form-json-imported", []); // 通知其他组件
295
+ }
296
+ this.setSelected();
297
+ return modifiedFlag;
298
+ },
299
+ handleSelectedWidget(selected) {
300
+ //处理历史未定义的属性
301
+ if (selected.formItemFlag || selected.type === "data-table") {
302
+ if (selected.options.submitFlag === void 0) {
303
+ // selected.options.submitFlag = true;
304
+ this.vueInstance.$set(selected.options, "submitFlag", true);
305
+ }
306
+ }
307
+ this.handleKeyNameSuffix(selected);
308
+ },
309
+ handleKeyNameSuffix(selected) {
310
+ if (!selected) return;
311
+ let optionModel = selected.options;
312
+ let prefix = this.getKeyNamePrefix(selected.type, optionModel);
313
+ if (
314
+ optionModel.keyNameEnabled &&
315
+ !!prefix &&
316
+ !optionModel.keyNameSuffix
317
+ ) {
318
+ let keyName = optionModel.keyName;
319
+ if (keyName.startsWith(prefix)) {
320
+ this.vueInstance.$set(
321
+ optionModel,
322
+ "keyNameSuffix",
323
+ keyName.substring(prefix.length)
324
+ );
325
+ }
326
+ }
327
+ },
328
+ setSelected(selected) {
329
+ if (!selected) {
330
+ this.clearSelected();
331
+ return;
332
+ }
333
+
334
+ //处理历史未定义的属性
335
+ this.handleSelectedWidget(selected);
336
+
337
+ this.selectedWidget = selected;
338
+ if (!!selected.id) {
339
+ this.selectedId = selected.id;
340
+ this.selectedWidgetName = selected.options.name;
341
+ if (!selected.category) {
342
+ this.emitEvent("canvas-select-field", selected.options.name);
343
+ } else {
344
+ this.emitEvent("canvas-select-container", selected.options.name);
345
+ }
346
+ }
347
+ },
348
+
349
+ updateSelectedWidgetNameAndLabel(selectedWidget, newName, newLabel) {
350
+ this.selectedWidgetName = newName;
351
+ //selectedWidget.options.name = newName //此行多余
352
+ if (
353
+ !!newLabel &&
354
+ Object.keys(selectedWidget.options).indexOf("label") > -1
355
+ ) {
356
+ selectedWidget.options.label = newLabel;
357
+ }
358
+ },
359
+
360
+ clearSelected() {
361
+ this.selectedId = null;
362
+ this.selectedWidgetName = null;
363
+ this.selectedWidget = {}; //this.selectedWidget = null
364
+ },
365
+
366
+ checkWidgetMove(evt) {
367
+ /* Only field widget can be dragged into sub-form */
368
+ if (!!evt.draggedContext && !!evt.draggedContext.element) {
369
+ let wgCategory = evt.draggedContext.element.category;
370
+ let wgType = evt.draggedContext.element.type;
371
+ if (!!evt.to) {
372
+ if (
373
+ evt.to.className === "sub-form-table" &&
374
+ wgCategory === "container"
375
+ ) {
376
+ //this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
377
+ return false;
378
+ }
379
+ }
380
+ }
381
+
382
+ return true;
383
+ },
384
+
385
+ checkFieldMove(evt) {
386
+ if (!!evt.draggedContext && !!evt.draggedContext.element) {
387
+ let wgCategory = evt.draggedContext.element.category;
388
+ let wgType = evt.draggedContext.element.type + "";
389
+ //console.log('wgType======', wgType)
390
+ if (!!evt.to) {
391
+ if (evt.to.className === "sub-form-table" && wgType === "slot") {
392
+ //this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
393
+ return false;
394
+ }
395
+ }
396
+ }
397
+
398
+ return true;
399
+ },
400
+
401
+ /**
402
+ * 追加表格新行
403
+ * @param widget
404
+ */
405
+ appendTableRow(widget) {
406
+ let rowIdx = widget.rows.length; //确定插入行位置
407
+ let newRow = baseRefUtil.deepClone(widget.rows[widget.rows.length - 1]);
408
+ newRow.id = "table-row-" + baseRefUtil.generateId();
409
+ newRow.merged = false;
410
+ newRow.cols.forEach((col) => {
411
+ col.id = "table-cell-" + baseRefUtil.generateId();
412
+ col.options.name = col.id;
413
+ col.merged = false;
414
+ col.options.colspan = 1;
415
+ col.options.rowspan = 1;
416
+ col.widgetList.length = 0;
417
+ });
418
+ widget.rows.splice(rowIdx, 0, newRow);
419
+
420
+ this.emitHistoryChange();
421
+ },
422
+
423
+ /**
424
+ * 追加表格新列
425
+ * @param widget
426
+ */
427
+ appendTableCol(widget) {
428
+ let colIdx = widget.rows[0].cols.length; //确定插入列位置
429
+ widget.rows.forEach((row) => {
430
+ let newCol = baseRefUtil.deepClone(
431
+ this.getContainerByType("table-cell")
432
+ );
433
+ newCol.id = "table-cell-" + baseRefUtil.generateId();
434
+ newCol.options.name = newCol.id;
435
+ newCol.merged = false;
436
+ newCol.options.colspan = 1;
437
+ newCol.options.rowspan = 1;
438
+ newCol.widgetList.length = 0;
439
+ row.cols.splice(colIdx, 0, newCol);
440
+ });
441
+
442
+ this.emitHistoryChange();
443
+ },
444
+
445
+ insertTableRow(widget, insertPos, cloneRowIdx, curCol, aboveFlag) {
446
+ let newRowIdx = !!aboveFlag ? insertPos : insertPos + 1; //初步确定插入行位置
447
+ if (!aboveFlag) {
448
+ //继续向下寻找同列第一个未被合并的单元格
449
+ let tmpRowIdx = newRowIdx;
450
+ let rowFoundFlag = false;
451
+ while (tmpRowIdx < widget.rows.length) {
452
+ if (!widget.rows[tmpRowIdx].cols[curCol].merged) {
453
+ newRowIdx = tmpRowIdx;
454
+ rowFoundFlag = true;
455
+ break;
456
+ } else {
457
+ tmpRowIdx++;
458
+ }
459
+ }
460
+
461
+ if (!rowFoundFlag) {
462
+ newRowIdx = widget.rows.length;
463
+ }
464
+ }
465
+
466
+ let newRow = baseRefUtil.deepClone(widget.rows[cloneRowIdx]);
467
+ newRow.id = "table-row-" + baseRefUtil.generateId();
468
+ newRow.merged = false;
469
+ newRow.cols.forEach((col) => {
470
+ col.id = "table-cell-" + baseRefUtil.generateId();
471
+ col.options.name = col.id;
472
+ col.merged = false;
473
+ col.options.colspan = 1;
474
+ col.options.rowspan = 1;
475
+ col.widgetList.length = 0;
476
+ });
477
+ widget.rows.splice(newRowIdx, 0, newRow);
478
+
479
+ let colNo = 0;
480
+ while (
481
+ newRowIdx < widget.rows.length - 1 &&
482
+ colNo < widget.rows[0].cols.length
483
+ ) {
484
+ //越界判断
485
+ const cellOfNextRow = widget.rows[newRowIdx + 1].cols[colNo];
486
+ const rowMerged = cellOfNextRow.merged; //确定插入位置下一行的单元格是否为合并单元格
487
+ if (!!rowMerged) {
488
+ let rowArray = widget.rows;
489
+ let unMergedCell = {};
490
+ let startRowIndex = null;
491
+ for (let i = newRowIdx; i >= 0; i--) {
492
+ //查找该行已合并的主单元格
493
+ if (
494
+ !rowArray[i].cols[colNo].merged &&
495
+ rowArray[i].cols[colNo].options.rowspan > 1
496
+ ) {
497
+ startRowIndex = i;
498
+ unMergedCell = rowArray[i].cols[colNo];
499
+ break;
500
+ }
501
+ }
502
+
503
+ if (!!unMergedCell.options) {
504
+ //如果有符合条件的unMergedCell
505
+ let newRowspan = unMergedCell.options.rowspan + 1;
506
+ this.setPropsOfMergedRows(
507
+ widget.rows,
508
+ startRowIndex,
509
+ colNo,
510
+ unMergedCell.options.colspan,
511
+ newRowspan
512
+ );
513
+ colNo += unMergedCell.options.colspan;
514
+ } else {
515
+ colNo += 1;
516
+ }
517
+ } else {
518
+ //colNo += 1
519
+ colNo += cellOfNextRow.options.colspan || 1;
520
+ }
521
+ }
522
+
523
+ this.emitHistoryChange();
524
+ },
525
+
526
+ insertTableCol(widget, insertPos, curRow, leftFlag) {
527
+ let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
528
+ if (!leftFlag) {
529
+ //继续向右寻找同行第一个未被合并的单元格
530
+ let tmpColIdx = newColIdx;
531
+ let colFoundFlag = false;
532
+ while (tmpColIdx < widget.rows[curRow].cols.length) {
533
+ if (!widget.rows[curRow].cols[tmpColIdx].merged) {
534
+ newColIdx = tmpColIdx;
535
+ colFoundFlag = true;
536
+ break;
537
+ } else {
538
+ tmpColIdx++;
539
+ }
540
+
541
+ if (!colFoundFlag) {
542
+ newColIdx = widget.rows[curRow].cols.length;
543
+ }
544
+ }
545
+ }
546
+
547
+ widget.rows.forEach((row) => {
548
+ let newCol = baseRefUtil.deepClone(
549
+ this.getContainerByType("table-cell")
550
+ );
551
+ newCol.id = "table-cell-" + baseRefUtil.generateId();
552
+ newCol.options.name = newCol.id;
553
+ newCol.merged = false;
554
+ newCol.options.colspan = 1;
555
+ newCol.options.rowspan = 1;
556
+ newCol.widgetList.length = 0;
557
+ row.cols.splice(newColIdx, 0, newCol);
558
+ });
559
+
560
+ let rowNo = 0;
561
+ while (
562
+ newColIdx < widget.rows[0].cols.length - 1 &&
563
+ rowNo < widget.rows.length
564
+ ) {
565
+ //越界判断
566
+ const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
567
+ const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
568
+ if (!!colMerged) {
569
+ let colArray = widget.rows[rowNo].cols;
570
+ let unMergedCell = {};
571
+ let startColIndex = null;
572
+ for (let i = newColIdx; i >= 0; i--) {
573
+ //查找该行已合并的主单元格
574
+ if (!colArray[i].merged && colArray[i].options.colspan > 1) {
575
+ startColIndex = i;
576
+ unMergedCell = colArray[i];
577
+ break;
578
+ }
579
+ }
580
+
581
+ if (!!unMergedCell.options) {
582
+ //如果有符合条件的unMergedCell
583
+ let newColspan = unMergedCell.options.colspan + 1;
584
+ this.setPropsOfMergedCols(
585
+ widget.rows,
586
+ rowNo,
587
+ startColIndex,
588
+ newColspan,
589
+ unMergedCell.options.rowspan
590
+ );
591
+ rowNo += unMergedCell.options.rowspan;
592
+ } else {
593
+ rowNo += 1;
594
+ }
595
+ } else {
596
+ //rowNo += 1
597
+ rowNo += cellOfNextCol.options.rowspan || 1;
598
+ }
599
+ }
600
+
601
+ this.emitHistoryChange();
602
+ },
603
+ insertH5TableCol(widget, insertPos, curRow, leftFlag) {
604
+ let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
605
+ if (!leftFlag) {
606
+ //继续向右寻找同行第一个未被合并的单元格
607
+ let tmpColIdx = newColIdx;
608
+ let colFoundFlag = false;
609
+ while (tmpColIdx < widget.rows[curRow].cols.length) {
610
+ if (!widget.rows[curRow].cols[tmpColIdx].merged) {
611
+ newColIdx = tmpColIdx;
612
+ colFoundFlag = true;
613
+ break;
614
+ } else {
615
+ tmpColIdx++;
616
+ }
617
+
618
+ if (!colFoundFlag) {
619
+ newColIdx = widget.rows[curRow].cols.length;
620
+ }
621
+ }
622
+ }
623
+
624
+ widget.rows.forEach((row) => {
625
+ let newCol = baseRefUtil.deepClone(
626
+ this.getContainerByType("h5-table-cell")
627
+ );
628
+ newCol.id = "table-cell-" + baseRefUtil.generateId();
629
+ newCol.options.name = newCol.id;
630
+ newCol.merged = false;
631
+ newCol.options.colspan = 1;
632
+ newCol.options.rowspan = 1;
633
+ newCol.widgetList.length = 0;
634
+ row.cols.splice(newColIdx, 0, newCol);
635
+ });
636
+
637
+ let rowNo = 0;
638
+ while (
639
+ newColIdx < widget.rows[0].cols.length - 1 &&
640
+ rowNo < widget.rows.length
641
+ ) {
642
+ //越界判断
643
+ const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
644
+ const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
645
+ if (!!colMerged) {
646
+ let colArray = widget.rows[rowNo].cols;
647
+ let unMergedCell = {};
648
+ let startColIndex = null;
649
+ for (let i = newColIdx; i >= 0; i--) {
650
+ //查找该行已合并的主单元格
651
+ if (!colArray[i].merged && colArray[i].options.colspan > 1) {
652
+ startColIndex = i;
653
+ unMergedCell = colArray[i];
654
+ break;
655
+ }
656
+ }
657
+
658
+ if (!!unMergedCell.options) {
659
+ //如果有符合条件的unMergedCell
660
+ let newColspan = unMergedCell.options.colspan + 1;
661
+ this.setPropsOfMergedCols(
662
+ widget.rows,
663
+ rowNo,
664
+ startColIndex,
665
+ newColspan,
666
+ unMergedCell.options.rowspan
667
+ );
668
+ rowNo += unMergedCell.options.rowspan;
669
+ } else {
670
+ rowNo += 1;
671
+ }
672
+ } else {
673
+ //rowNo += 1
674
+ rowNo += cellOfNextCol.options.rowspan || 1;
675
+ }
676
+ }
677
+
678
+ this.emitHistoryChange();
679
+ },
680
+ setPropsOfMergedCols(
681
+ rowArray,
682
+ startRowIndex,
683
+ startColIndex,
684
+ newColspan,
685
+ rowspan
686
+ ) {
687
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
688
+ for (let j = startColIndex; j < startColIndex + newColspan; j++) {
689
+ if (i === startRowIndex && j === startColIndex) {
690
+ rowArray[i].cols[j].options.colspan = newColspan; //合并后的主单元格
691
+ continue;
692
+ }
693
+
694
+ rowArray[i].cols[j].merged = true;
695
+ rowArray[i].cols[j].options.colspan = newColspan;
696
+ rowArray[i].cols[j].widgetList = [];
697
+ }
698
+ }
699
+ },
700
+
701
+ setPropsOfMergedRows(
702
+ rowArray,
703
+ startRowIndex,
704
+ startColIndex,
705
+ colspan,
706
+ newRowspan
707
+ ) {
708
+ for (let i = startRowIndex; i < startRowIndex + newRowspan; i++) {
709
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
710
+ if (i === startRowIndex && j === startColIndex) {
711
+ rowArray[i].cols[j].options.rowspan = newRowspan;
712
+ continue;
713
+ }
714
+
715
+ rowArray[i].cols[j].merged = true;
716
+ rowArray[i].cols[j].options.rowspan = newRowspan;
717
+ rowArray[i].cols[j].widgetList = [];
718
+ }
719
+ }
720
+ },
721
+
722
+ setPropsOfSplitCol(
723
+ rowArray,
724
+ startRowIndex,
725
+ startColIndex,
726
+ colspan,
727
+ rowspan
728
+ ) {
729
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
730
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
731
+ rowArray[i].cols[j].merged = false;
732
+ rowArray[i].cols[j].options.rowspan = 1;
733
+ rowArray[i].cols[j].options.colspan = 1;
734
+ }
735
+ }
736
+ },
737
+
738
+ setPropsOfSplitRow(
739
+ rowArray,
740
+ startRowIndex,
741
+ startColIndex,
742
+ colspan,
743
+ rowspan
744
+ ) {
745
+ for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
746
+ for (let j = startColIndex; j < startColIndex + colspan; j++) {
747
+ rowArray[i].cols[j].merged = false;
748
+ rowArray[i].cols[j].options.rowspan = 1;
749
+ rowArray[i].cols[j].options.colspan = 1;
750
+ }
751
+ }
752
+ },
753
+
754
+ mergeTableCol(rowArray, colArray, curRow, curCol, leftFlag, cellWidget) {
755
+ let mergedColIdx = !!leftFlag
756
+ ? curCol
757
+ : curCol + colArray[curCol].options.colspan;
758
+
759
+ // let remainedColIdx = !!leftFlag ? curCol - colArray[curCol - 1].options.colspan : curCol
760
+ let remainedColIdx = !!leftFlag ? curCol - 1 : curCol;
761
+ if (!!leftFlag) {
762
+ //继续向左寻找同行未被合并的第一个单元格
763
+ let tmpColIdx = remainedColIdx;
764
+ while (tmpColIdx >= 0) {
765
+ if (!rowArray[curRow].cols[tmpColIdx].merged) {
766
+ remainedColIdx = tmpColIdx;
767
+ break;
768
+ } else {
769
+ tmpColIdx--;
770
+ }
771
+ }
772
+ }
773
+
774
+ if (
775
+ !!colArray[mergedColIdx].widgetList &&
776
+ colArray[mergedColIdx].widgetList.length > 0
777
+ ) {
778
+ //保留widgetList
779
+ if (
780
+ !colArray[remainedColIdx].widgetList ||
781
+ colArray[remainedColIdx].widgetList.length === 0
782
+ ) {
783
+ colArray[remainedColIdx].widgetList = baseRefUtil.deepClone(
784
+ colArray[mergedColIdx].widgetList
785
+ );
786
+ }
787
+ }
788
+
789
+ let newColspan =
790
+ colArray[mergedColIdx].options.colspan * 1 +
791
+ colArray[remainedColIdx].options.colspan * 1;
792
+ this.setPropsOfMergedCols(
793
+ rowArray,
794
+ curRow,
795
+ remainedColIdx,
796
+ newColspan,
797
+ cellWidget.options.rowspan
798
+ );
799
+
800
+ this.emitHistoryChange();
801
+ },
802
+
803
+ mergeTableWholeRow(rowArray, colArray, rowIndex, colIndex) {
804
+ //需要考虑操作的行存在已合并的单元格!!
805
+ //整行所有单元格行高不一致不可合并!!
806
+ let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
807
+ let unmatchedFlag = false;
808
+ for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
809
+ if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
810
+ unmatchedFlag = true;
811
+ break;
812
+ }
813
+ }
814
+ if (unmatchedFlag) {
815
+ this.vueInstance.$message.info(
816
+ this.vueInstance.i18nt(
817
+ "designer.hint.rowspanNotConsistentForMergeEntireRow"
818
+ )
819
+ );
820
+ return;
821
+ }
822
+
823
+ let widgetListCols = colArray.filter((colItem) => {
824
+ return (
825
+ !colItem.merged &&
826
+ !!colItem.widgetList &&
827
+ colItem.widgetList.length > 0
828
+ );
829
+ });
830
+ if (!!widgetListCols && widgetListCols.length > 0) {
831
+ //保留widgetList
832
+ if (
833
+ widgetListCols[0].id !== colArray[0].id &&
834
+ (!colArray[0].widgetList || colArray[0].widgetList.length <= 0)
835
+ ) {
836
+ colArray[0].widgetList = baseRefUtil.deepClone(
837
+ widgetListCols[0].widgetList
838
+ );
839
+ }
840
+ }
841
+
842
+ this.setPropsOfMergedCols(
843
+ rowArray,
844
+ rowIndex,
845
+ 0,
846
+ colArray.length,
847
+ colArray[colIndex].options.rowspan
848
+ );
849
+
850
+ this.emitHistoryChange();
851
+ },
852
+
853
+ mergeTableRow(rowArray, curRow, curCol, aboveFlag, cellWidget) {
854
+ let mergedRowIdx = !!aboveFlag
855
+ ? curRow
856
+ : curRow + cellWidget.options.rowspan;
857
+
858
+ //let remainedRowIdx = !!aboveFlag ? curRow - cellWidget.options.rowspan : curRow
859
+ let remainedRowIdx = !!aboveFlag ? curRow - 1 : curRow;
860
+ if (!!aboveFlag) {
861
+ //继续向上寻找同列未被合并的第一个单元格
862
+ let tmpRowIdx = remainedRowIdx;
863
+ while (tmpRowIdx >= 0) {
864
+ if (!rowArray[tmpRowIdx].cols[curCol].merged) {
865
+ remainedRowIdx = tmpRowIdx;
866
+ break;
867
+ } else {
868
+ tmpRowIdx--;
869
+ }
870
+ }
871
+ }
872
+
873
+ if (
874
+ !!rowArray[mergedRowIdx].cols[curCol].widgetList &&
875
+ rowArray[mergedRowIdx].cols[curCol].widgetList.length > 0
876
+ ) {
877
+ //保留widgetList
878
+ if (
879
+ !rowArray[remainedRowIdx].cols[curCol].widgetList ||
880
+ rowArray[remainedRowIdx].cols[curCol].widgetList.length === 0
881
+ ) {
882
+ rowArray[remainedRowIdx].cols[curCol].widgetList =
883
+ baseRefUtil.deepClone(
884
+ rowArray[mergedRowIdx].cols[curCol].widgetList
885
+ );
886
+ }
887
+ }
888
+
889
+ let newRowspan =
890
+ rowArray[mergedRowIdx].cols[curCol].options.rowspan * 1 +
891
+ rowArray[remainedRowIdx].cols[curCol].options.rowspan * 1;
892
+ this.setPropsOfMergedRows(
893
+ rowArray,
894
+ remainedRowIdx,
895
+ curCol,
896
+ cellWidget.options.colspan,
897
+ newRowspan
898
+ );
899
+
900
+ this.emitHistoryChange();
901
+ },
902
+
903
+ mergeTableWholeCol(rowArray, colArray, rowIndex, colIndex) {
904
+ //需要考虑操作的列存在已合并的单元格!!
905
+ //整列所有单元格列宽不一致不可合并!!
906
+ let startColspan = rowArray[0].cols[colIndex].options.colspan;
907
+ let unmatchedFlag = false;
908
+ for (let i = 1; i < rowArray.length; i++) {
909
+ if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
910
+ unmatchedFlag = true;
911
+ break;
912
+ }
913
+ }
914
+ if (unmatchedFlag) {
915
+ this.vueInstance.$message.info(
916
+ this.vueInstance.i18nt(
917
+ "designer.hint.colspanNotConsistentForMergeEntireColumn"
918
+ )
919
+ );
920
+ return;
921
+ }
922
+
923
+ let widgetListCols = [];
924
+ rowArray.forEach((rowItem) => {
925
+ let tempCell = rowItem.cols[colIndex];
926
+ if (
927
+ !tempCell.merged &&
928
+ !!tempCell.widgetList &&
929
+ tempCell.widgetList.length > 0
930
+ ) {
931
+ widgetListCols.push(tempCell);
932
+ }
933
+ });
934
+
935
+ let firstCellOfCol = rowArray[0].cols[colIndex];
936
+ if (!!widgetListCols && widgetListCols.length > 0) {
937
+ //保留widgetList
938
+ if (
939
+ widgetListCols[0].id !== firstCellOfCol.id &&
940
+ (!firstCellOfCol.widgetList ||
941
+ firstCellOfCol.widgetList.length <= 0)
942
+ ) {
943
+ firstCellOfCol.widgetList = baseRefUtil.deepClone(
944
+ widgetListCols[0].widgetList
945
+ );
946
+ }
947
+ }
948
+
949
+ this.setPropsOfMergedRows(
950
+ rowArray,
951
+ 0,
952
+ colIndex,
953
+ firstCellOfCol.options.colspan,
954
+ rowArray.length
955
+ );
956
+
957
+ this.emitHistoryChange();
958
+ },
959
+
960
+ undoMergeTableCol(rowArray, rowIndex, colIndex, colspan, rowspan) {
961
+ this.setPropsOfSplitCol(rowArray, rowIndex, colIndex, colspan, rowspan);
962
+
963
+ this.emitHistoryChange();
964
+ },
965
+
966
+ undoMergeTableRow(rowArray, rowIndex, colIndex, colspan, rowspan) {
967
+ this.setPropsOfSplitRow(rowArray, rowIndex, colIndex, colspan, rowspan);
968
+
969
+ this.emitHistoryChange();
970
+ },
971
+
972
+ deleteTableWholeCol(rowArray, colIndex) {
973
+ //需考虑删除的是合并列!!
974
+ let onlyOneColFlag = true;
975
+ rowArray.forEach((ri) => {
976
+ if (ri.cols[0].options.colspan !== rowArray[0].cols.length) {
977
+ onlyOneColFlag = false;
978
+ }
979
+ });
980
+ //仅剩一列则不可删除!!
981
+ if (onlyOneColFlag) {
982
+ this.vueInstance.$message.info(
983
+ this.vueInstance.i18nt("designer.hint.lastColCannotBeDeleted")
984
+ );
985
+ return;
986
+ }
987
+
988
+ //整列所有单元格列宽不一致不可删除!!
989
+ let startColspan = rowArray[0].cols[colIndex].options.colspan;
990
+ let unmatchedFlag = false;
991
+ for (let i = 1; i < rowArray.length; i++) {
992
+ if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
993
+ unmatchedFlag = true;
994
+ break;
995
+ }
996
+ }
997
+ if (unmatchedFlag) {
998
+ this.vueInstance.$message.info(
999
+ this.vueInstance.i18nt(
1000
+ "designer.hint.colspanNotConsistentForDeleteEntireColumn"
1001
+ )
1002
+ );
1003
+ return;
1004
+ }
1005
+
1006
+ rowArray.forEach((rItem) => {
1007
+ rItem.cols.splice(colIndex, startColspan);
1008
+ });
1009
+
1010
+ this.emitHistoryChange();
1011
+ },
1012
+
1013
+ deleteTableWholeRow(rowArray, rowIndex) {
1014
+ //需考虑删除的是合并行!!
1015
+ let onlyOneRowFlag = true;
1016
+ rowArray[0].cols.forEach((ci) => {
1017
+ if (ci.options.rowspan !== rowArray.length) {
1018
+ onlyOneRowFlag = false;
1019
+ }
1020
+ });
1021
+ //仅剩一行则不可删除!!
1022
+ if (onlyOneRowFlag) {
1023
+ this.vueInstance.$message.info(
1024
+ this.vueInstance.i18nt("designer.hint.lastRowCannotBeDeleted")
1025
+ );
1026
+ return;
1027
+ }
1028
+
1029
+ //整行所有单元格行高不一致不可删除!!
1030
+ let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
1031
+ let unmatchedFlag = false;
1032
+ for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
1033
+ if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
1034
+ unmatchedFlag = true;
1035
+ break;
1036
+ }
1037
+ }
1038
+ if (unmatchedFlag) {
1039
+ this.vueInstance.$message.info(
1040
+ this.vueInstance.i18nt(
1041
+ "designer.hint.rowspanNotConsistentForDeleteEntireRow"
1042
+ )
1043
+ );
1044
+ return;
1045
+ }
1046
+
1047
+ rowArray.splice(rowIndex, startRowspan);
1048
+
1049
+ this.emitHistoryChange();
1050
+ },
1051
+
1052
+ getContainerByType(typeName) {
1053
+ let allWidgets = [
1054
+ ...baseRefUtil.containers,
1055
+ ...baseRefUtil.basicFields,
1056
+ ...baseRefUtil.advancedFields,
1057
+ ...baseRefUtil.customFields,
1058
+ ...businessFields,
1059
+ ];
1060
+ let foundCon = null;
1061
+ allWidgets.forEach((con) => {
1062
+ if (!!con.category && !!con.type && con.type === typeName) {
1063
+ foundCon = con;
1064
+ }
1065
+ });
1066
+
1067
+ return foundCon;
1068
+ },
1069
+
1070
+ getFieldWidgetByType(typeName) {
1071
+ let allWidgets = [
1072
+ ...baseRefUtil.containers,
1073
+ ...baseRefUtil.basicFields,
1074
+ ...baseRefUtil.advancedFields,
1075
+ ...baseRefUtil.customFields,
1076
+ ...chartContainers,
1077
+ ...chartWidgets,
1078
+ ...businessFields,
1079
+ ];
1080
+ let foundWidget = null;
1081
+ allWidgets.forEach((widget) => {
1082
+ if (!!!widget.category && !!widget.type && widget.type === typeName) {
1083
+ foundWidget = widget;
1084
+ }
1085
+ });
1086
+
1087
+ return foundWidget;
1088
+ },
1089
+
1090
+ hasConfig(widget, configName) {
1091
+ let originalWidget = null;
1092
+ if (!!widget.category) {
1093
+ originalWidget = this.getContainerByType(widget.type);
1094
+ } else {
1095
+ originalWidget = this.getFieldWidgetByType(widget.type);
1096
+ }
1097
+
1098
+ if (!originalWidget || !originalWidget.options) {
1099
+ return false;
1100
+ }
1101
+
1102
+ return Object.keys(originalWidget.options).indexOf(configName) > -1;
1103
+ },
1104
+ /*upgradeWidgetConfig(oldWidget) {
1105
+ let newWidget = null;
1106
+ if (!!oldWidget.category) {
1107
+ newWidget = this.getContainerByType(oldWidget.type);
1108
+ } else {
1109
+ newWidget = this.getFieldWidgetByType(oldWidget.type);
1110
+ }
1111
+
1112
+ if (!newWidget || !newWidget.options) {
1113
+ return;
1114
+ }
1115
+
1116
+ Object.keys(newWidget.options).forEach(ck => {
1117
+ if (!oldWidget.options.hasOwnProperty(ck)) {
1118
+ oldWidget.options[ck] = baseRefUtil.deepClone(newWidget.options[ck]);
1119
+ }
1120
+ });
1121
+ },*/
1122
+ upgradeWidgetConfig(oldWidget) {
1123
+ let newWidget = null;
1124
+ if (!!oldWidget.category) {
1125
+ newWidget = this.getContainerByType(oldWidget.type);
1126
+ } else {
1127
+ newWidget = this.getFieldWidgetByType(oldWidget.type);
1128
+ }
1129
+
1130
+ if (!newWidget || !newWidget.options) {
1131
+ return;
1132
+ }
1133
+
1134
+ Object.keys(newWidget.options).forEach((ck) => {
1135
+ if (!oldWidget.options.hasOwnProperty(ck)) {
1136
+ let value = newWidget.options[ck];
1137
+ let nullValue = Array.isArray(value) ? [] : null;
1138
+ oldWidget.options[ck] = nullValue;
1139
+ }
1140
+ });
1141
+ },
1142
+
1143
+ upgradeFormConfig(oldFormConfig) {
1144
+ Object.keys(this.formConfig).forEach((fc) => {
1145
+ if (!oldFormConfig.hasOwnProperty(fc)) {
1146
+ let value = this.formConfig[fc];
1147
+ let nullValue = Array.isArray(value) ? [] : null;
1148
+ oldFormConfig[fc] = baseRefUtil.deepClone(nullValue);
1149
+ }
1150
+ });
1151
+ },
1152
+
1153
+ cloneGridCol(widget, parentWidget) {
1154
+ let newGridCol = baseRefUtil.deepClone(
1155
+ this.getContainerByType("grid-col")
1156
+ );
1157
+ newGridCol.options.span = widget.options.span;
1158
+ let tmpId = baseRefUtil.generateId();
1159
+ newGridCol.id = "grid-col-" + tmpId;
1160
+ newGridCol.options.name = "gridCol" + tmpId;
1161
+
1162
+ parentWidget.cols.push(newGridCol);
1163
+ },
1164
+
1165
+ cloneContainer(containWidget) {
1166
+ if (containWidget.type === "grid") {
1167
+ let newGrid = baseRefUtil.deepClone(this.getContainerByType("grid"));
1168
+ newGrid.id = newGrid.type + baseRefUtil.generateId();
1169
+ newGrid.options.name = newGrid.id;
1170
+ containWidget.cols.forEach((gridCol) => {
1171
+ let newGridCol = baseRefUtil.deepClone(
1172
+ this.getContainerByType("grid-col")
1173
+ );
1174
+ let tmpId = baseRefUtil.generateId();
1175
+ newGridCol.id = "grid-col-" + tmpId;
1176
+ newGridCol.options.name = "gridCol" + tmpId;
1177
+ newGridCol.options.span = gridCol.options.span;
1178
+ newGrid.cols.push(newGridCol);
1179
+ });
1180
+
1181
+ return newGrid;
1182
+ } else if (containWidget.type === "table") {
1183
+ let newTable = baseRefUtil.deepClone(
1184
+ this.getContainerByType("table")
1185
+ );
1186
+ newTable.id = newTable.type + baseRefUtil.generateId();
1187
+ newTable.options.name = newTable.id;
1188
+ containWidget.rows.forEach((tRow) => {
1189
+ let newRow = baseRefUtil.deepClone(tRow);
1190
+ newRow.id = "table-row-" + baseRefUtil.generateId();
1191
+ newRow.cols.forEach((col) => {
1192
+ col.id = "table-cell-" + baseRefUtil.generateId();
1193
+ col.options.name = col.id;
1194
+ col.widgetList = []; //清空组件列表
1195
+ });
1196
+ newTable.rows.push(newRow);
1197
+ });
1198
+
1199
+ return newTable;
1200
+ } else if (containWidget.type === "h5-table") {
1201
+ let newTable = baseRefUtil.deepClone(
1202
+ this.getContainerByType("h5-table")
1203
+ );
1204
+ newTable.id = newTable.type + baseRefUtil.generateId();
1205
+ newTable.options.name = newTable.id;
1206
+ containWidget.rows.forEach((tRow) => {
1207
+ let newRow = baseRefUtil.deepClone(tRow);
1208
+ newRow.id = "table-row-" + baseRefUtil.generateId();
1209
+ newRow.cols.forEach((col) => {
1210
+ col.id = "table-cell-" + baseRefUtil.generateId();
1211
+ col.options.name = col.id;
1212
+ col.widgetList = []; //清空组件列表
1213
+ });
1214
+ newTable.rows.push(newRow);
1215
+ });
1216
+
1217
+ return newTable;
1218
+ } else {
1219
+ //其他容器组件不支持clone操作
1220
+ return null;
1221
+ }
1222
+ },
1223
+
1224
+ moveUpWidget(parentList, indexOfParentList) {
1225
+ if (!!parentList) {
1226
+ if (indexOfParentList === 0) {
1227
+ this.vueInstance.$message(
1228
+ this.vueInstance.i18nt("designer.hint.moveUpFirstChildHint")
1229
+ );
1230
+ return;
1231
+ }
1232
+
1233
+ let tempWidget = parentList[indexOfParentList];
1234
+ parentList.splice(indexOfParentList, 1);
1235
+ parentList.splice(indexOfParentList - 1, 0, tempWidget);
1236
+ }
1237
+ },
1238
+
1239
+ moveDownWidget(parentList, indexOfParentList) {
1240
+ if (!!parentList) {
1241
+ if (indexOfParentList === parentList.length - 1) {
1242
+ this.vueInstance.$message(
1243
+ this.vueInstance.i18nt("designer.hint.moveDownLastChildHint")
1244
+ );
1245
+ return;
1246
+ }
1247
+
1248
+ let tempWidget = parentList[indexOfParentList];
1249
+ parentList.splice(indexOfParentList, 1);
1250
+ parentList.splice(indexOfParentList + 1, 0, tempWidget);
1251
+ }
1252
+ },
1253
+ copyNewFieldWidget(origin) {
1254
+ let newWidget = baseRefUtil.deepClone(origin);
1255
+ let sourceType = newWidget.type;
1256
+ newWidget.type = newWidget.targetType || newWidget.type;
1257
+ newWidget.sourceType = sourceType;
1258
+ let tempId = baseRefUtil.generateId();
1259
+ newWidget.id = newWidget.type.replace(/-/g, "") + tempId;
1260
+ if (newWidget.hasOwnProperty("tableField")) {
1261
+ newWidget.tableField = newWidget.id; //表字段
1262
+ }
1263
+
1264
+ // newWidget.options.name = newWidget.id;
1265
+ // newWidget.options.label = newWidget.options.label || newWidget.type.toLowerCase();
1266
+
1267
+ newWidget.nameReadonly
1268
+ ? newWidget.options.label &&
1269
+ newWidget.options.label.indexOf(".") > -1 &&
1270
+ (newWidget.options.label = newWidget.options.label.substring(
1271
+ newWidget.options.label.indexOf(".") + 1
1272
+ ))
1273
+ : ((newWidget.options.name = newWidget.id),
1274
+ (newWidget.options.label =
1275
+ newWidget.options.label || newWidget.type.toLowerCase()));
1276
+ delete newWidget.displayName;
1277
+ if (!newWidget.nameReadonly) {
1278
+ newWidget.options.keyNameEnabled = true;
1279
+ if (!newWidget.options.keyName)
1280
+ newWidget.options.keyName = newWidget.id;
1281
+ if (
1282
+ newWidget.type === "vabUpload" ||
1283
+ newWidget.type === "baseAttachment"
1284
+ ) {
1285
+ let keyNameSuffix = this.createKeyNameSuffix(newWidget.type);
1286
+ // this.createKeyNameSuffix()
1287
+ newWidget.options.keyName = this.createKeyName(
1288
+ newWidget.type,
1289
+ keyNameSuffix
1290
+ );
1291
+ newWidget.options.keyNameSuffix = keyNameSuffix;
1292
+ }
1293
+ }
1294
+ if (newWidget.type === "dropdown") {
1295
+ let dropdownItem1 = this.copyNewFieldWidget(
1296
+ this.getFieldWidgetByType("dropdown-item")
1297
+ );
1298
+ dropdownItem1.options.label = "下拉按钮1";
1299
+ let dropdownItem2 = this.copyNewFieldWidget(
1300
+ this.getFieldWidgetByType("dropdown-item")
1301
+ );
1302
+ dropdownItem2.options.label = "下拉按钮2";
1303
+ newWidget.widgetList.push(dropdownItem1);
1304
+ newWidget.widgetList.push(dropdownItem2);
1305
+ }
1306
+ this.emitEvent("canvas-add-field", newWidget.options.name);
1307
+ return newWidget;
1308
+ },
1309
+ createKeyName(type, suffix, options) {
1310
+ let keyNameSuffix = suffix ? suffix : this.createKeyNameSuffix(type);
1311
+ let keyNamePrefix = this.getKeyNamePrefix(type, options);
1312
+ let keyName = null;
1313
+ if (keyNamePrefix) {
1314
+ keyName = keyNamePrefix + keyNameSuffix;
1315
+ } else {
1316
+ keyName = keyNameSuffix;
1317
+ }
1318
+ return keyName;
1319
+ },
1320
+ createKeyNameSuffix(type) {
1321
+ let suffix = createUUID();
1322
+ /*if (type === "vabUpload" || type === "baseAttachment") {
1323
+ let formCode = vueInstance.reportTemplate.formCode;
1324
+ suffix = formCode + "_" + suffix;
1325
+ }*/
1326
+ return suffix;
1327
+ },
1328
+ /* 开了「值存为URL」的附件字段存的是主表普通列(值是 URL 字符串),不再走
1329
+ attachments_ 独立附件通道,keyName 不能带前缀——否则保存时会被
1330
+ data-table-mixin 的 attachments_ 提取逻辑当附件包发走,主表列存不到 */
1331
+ getKeyNamePrefix(type, options) {
1332
+ if (options && options.urlValueEnabled) {
1333
+ return null;
1334
+ }
1335
+ return keyNamePrefixMap[type] ?? null;
1336
+ },
1337
+ getFormCodePrefix(type) {
1338
+ let prefix = this.getKeyNamePrefix(type) || "";
1339
+ let attachmentPrefix =
1340
+ prefix + vueInstance.reportTemplate.formCode + "_";
1341
+ return attachmentPrefix;
1342
+ },
1343
+ createAttachmentSuffix() {
1344
+ let type = "vabUpload";
1345
+ return this.createKeyNameSuffix(type);
1346
+ },
1347
+ getAttachmentPrefix() {
1348
+ let type = "vabUpload";
1349
+ return this.getKeyNamePrefix(type);
1350
+ },
1351
+ getAttachmentFormCodePrefix() {
1352
+ let type = "vabUpload";
1353
+ let attachmentPrefix = this.getFormCodePrefix(type);
1354
+ return attachmentPrefix;
1355
+ },
1356
+ createAttachmentKeyName(suffix) {
1357
+ let type = "vabUpload";
1358
+ let keyName = this.createKeyName(type, suffix);
1359
+ return keyName;
1360
+ },
1361
+ copyNewContainerWidget(origin) {
1362
+ let newCon = baseRefUtil.deepClone(origin);
1363
+ let sourceType = newCon.type;
1364
+ newCon.type = newCon.targetType || newCon.type;
1365
+ newCon.sourceType = sourceType;
1366
+ newCon.id = newCon.type.replace(/-/g, "") + baseRefUtil.generateId();
1367
+ newCon.options.name = newCon.id;
1368
+ if ((newCon.options.keyNameEnabled = true)) {
1369
+ newCon.options.keyName = newCon.id;
1370
+ }
1371
+ if (newCon.hasOwnProperty("tableField")) {
1372
+ newCon.tableField = newCon.id; //表字段
1373
+ }
1374
+ if (newCon.type === "grid") {
1375
+ let newCol = baseRefUtil.deepClone(
1376
+ this.getContainerByType("grid-col")
1377
+ );
1378
+ let tmpId = baseRefUtil.generateId();
1379
+ newCol.id = "grid-col-" + tmpId;
1380
+ newCol.options.name = "gridCol" + tmpId;
1381
+ newCon.cols.push(newCol);
1382
+ //
1383
+ newCol = baseRefUtil.deepClone(newCol);
1384
+ tmpId = baseRefUtil.generateId();
1385
+ newCol.id = "grid-col-" + tmpId;
1386
+ newCol.options.name = "gridCol" + tmpId;
1387
+ newCon.cols.push(newCol);
1388
+ } else if (newCon.type === "table") {
1389
+ let newRow = {
1390
+ cols: [],
1391
+ };
1392
+ newRow.id = "table-row-" + baseRefUtil.generateId();
1393
+ newRow.merged = false;
1394
+ for (let i = 0; i < 4; i++) {
1395
+ let newCell = baseRefUtil.deepClone(
1396
+ this.getContainerByType("table-cell")
1397
+ );
1398
+ newCell.id = "table-cell-" + baseRefUtil.generateId();
1399
+ newCell.options.name = newCell.id;
1400
+ newCell.merged = false;
1401
+ newCell.options.colspan = 1;
1402
+ newCell.options.rowspan = 1;
1403
+ newRow.cols.push(newCell);
1404
+ }
1405
+ newCon.rows.push(newRow);
1406
+ } else if (newCon.type === "tab") {
1407
+ let newTabPane = baseRefUtil.deepClone(
1408
+ this.getContainerByType("tab-pane")
1409
+ );
1410
+ newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
1411
+ newTabPane.options.name = "tab1";
1412
+ newTabPane.options.label = "tab 1";
1413
+ newCon.tabs.push(newTabPane);
1414
+ } else if (newCon.type === "data-table") {
1415
+ let add_button = this.copyNewFieldWidget(
1416
+ this.getFieldWidgetByType("add_button")
1417
+ );
1418
+ add_button.options.onClick =
1419
+ "this.getWidgetRef('" +
1420
+ newCon.options.name +
1421
+ "').openEditDialog();";
1422
+ newCon.buttons.push(add_button);
1423
+ } else if (newCon.type === "detail" || newCon.type === "detail-plain") {
1424
+ /* detail-plain 无标题栏,不预置标题栏按钮;其余 panes 结构与 detail 一致 */
1425
+ if (newCon.type === "detail") {
1426
+ let buttonCon1 = this.copyNewFieldWidget(
1427
+ this.getFieldWidgetByType("reset_button")
1428
+ );
1429
+ // buttonCon1.options.label = "重置";
1430
+
1431
+ let buttonCon2 = this.copyNewFieldWidget(
1432
+ this.getFieldWidgetByType("save_button")
1433
+ );
1434
+ buttonCon2.options.label = "保存";
1435
+
1436
+ newCon.widgetList.push(buttonCon1);
1437
+ newCon.widgetList.push(buttonCon2);
1438
+ }
1439
+
1440
+ let newCol = baseRefUtil.deepClone(
1441
+ this.getContainerByType("detail-pane")
1442
+ );
1443
+ let tmpId = baseRefUtil.generateId();
1444
+ newCol.id = "detail-pane-" + tmpId;
1445
+ newCol.options.name = "detailPane" + tmpId;
1446
+ newCol.options.label = "隐藏信息";
1447
+ newCol.options.hidden = true;
1448
+
1449
+ let tableCon = this.copyNewContainerWidget(
1450
+ this.getContainerByType("table")
1451
+ );
1452
+ newCol.widgetList.push(tableCon);
1453
+ newCon.panes.push(newCol);
1454
+
1455
+ newCol = baseRefUtil.deepClone(
1456
+ this.getContainerByType("detail-pane")
1457
+ );
1458
+ tmpId = baseRefUtil.generateId();
1459
+ newCol.id = "detail-pane-" + tmpId;
1460
+ newCol.options.name = "detailPane" + tmpId;
1461
+ newCol.options.label = "基础信息";
1462
+
1463
+ tableCon = this.copyNewContainerWidget(
1464
+ this.getContainerByType("table")
1465
+ );
1466
+ newCol.widgetList.push(tableCon);
1467
+ newCon.panes.push(newCol);
1468
+ //
1469
+ newCol = baseRefUtil.deepClone(
1470
+ this.getContainerByType("detail-pane")
1471
+ );
1472
+ tmpId = baseRefUtil.generateId();
1473
+ newCol.id = "detail-pane-" + tmpId;
1474
+ newCol.options.name = "detailPane" + tmpId;
1475
+ newCol.options.label = "明细信息";
1476
+ newCol.options.tableRef = tableCon.id;
1477
+ let dataTableCon = this.copyNewContainerWidget(
1478
+ this.getContainerByType("data-table")
1479
+ );
1480
+ newCol.widgetList.push(dataTableCon);
1481
+ newCol.options.tableRef = dataTableCon.id;
1482
+
1483
+ let buttonCon3 = this.copyNewFieldWidget(
1484
+ this.getFieldWidgetByType("button")
1485
+ );
1486
+ buttonCon3.options.label = "新增";
1487
+ buttonCon3.options.icon = "el-icon-search";
1488
+ // buttonCon3.options.onClick = "this.getWidgetRef('" + dataTableCon.options.name + "').addTableData();"
1489
+ buttonCon3.options.clickBindEvent = CLICK_BIND.ADD_TABLE_DATA;
1490
+ Object.assign(buttonCon3.options.addTableDataConfig, {
1491
+ tableRef: dataTableCon.options.name,
1492
+ });
1493
+
1494
+ newCol.buttonWidgetList.push(buttonCon3);
1495
+ newCon.panes.push(newCol);
1496
+
1497
+ newCol = baseRefUtil.deepClone(
1498
+ this.getContainerByType("detail-pane")
1499
+ );
1500
+ tmpId = baseRefUtil.generateId();
1501
+ newCol.id = "detail-pane-" + tmpId;
1502
+ newCol.options.name = "detailPane" + tmpId;
1503
+ newCol.options.label = "附件信息";
1504
+ let vabUploadCon = this.copyNewFieldWidget(
1505
+ this.getFieldWidgetByType("vabUpload")
1506
+ ); //vabUpload
1507
+ newCol.widgetList.push(vabUploadCon);
1508
+ newCon.panes.push(newCol);
1509
+
1510
+ /* 「详情模块(标签)」面板条目:type=detail-tabs + targetType=detail,落地后就是 detail,
1511
+ 不是新的容器类型。与「详情模块」的区别是内容模块不直接挂在正文区,而是收进标签里,
1512
+ 详见 docs/详情模块标签承载方案.md */
1513
+ if (newCon.sourceType === "detail-tabs") {
1514
+ // 上面已按 detail 的默认骨架建好一批内容模块,整体挪进第一个标签——
1515
+ // 标签形态下正文区只放标签容器,不留散在标签外面的模块。
1516
+ let presetPanes = newCon.panes.splice(0);
1517
+
1518
+ // 标签内的模块由 detail-plain 承载:它自带一套独立锚点导航,
1519
+ // 外层 baseTabs 探测不到标签内的模块(tab-item 不满足 getTabs 的两个条件)。
1520
+ let plainCon = this.copyNewContainerWidget(
1521
+ this.getContainerByType("detail-plain")
1522
+ );
1523
+ plainCon.panes = presetPanes; // 丢掉 detail-plain 自带的默认模块,用上面建好的这批
1524
+ plainCon.options.hideNav = false; // schema 默认关导航,标签内要开
1525
+
1526
+ let tabCon = this.copyNewContainerWidget(
1527
+ this.getContainerByType("tab")
1528
+ );
1529
+ tabCon.tabs[0].widgetList.push(plainCon);
1530
+
1531
+ // copyNewContainerWidget 只预置 1 个 tab-pane,只有一个标签页的标签栏看着像 bug,补第二个
1532
+ let secondPane = baseRefUtil.deepClone(
1533
+ this.getContainerByType("tab-pane")
1534
+ );
1535
+ secondPane.id = "tab-pane-" + baseRefUtil.generateId();
1536
+ secondPane.options.name = "tab2";
1537
+ secondPane.options.label = "tab 2";
1538
+ tabCon.tabs.push(secondPane);
1539
+
1540
+ newCon.panes.push(tabCon);
1541
+ }
1542
+ } else if (newCon.type === "table-column") {
1543
+ newCon.options.label = "tableColumn";
1544
+ } else if (newCon.type === "h5-card") {
1545
+ let newCol = baseRefUtil.deepClone(
1546
+ this.getContainerByType("h5-card-pane")
1547
+ );
1548
+ let tmpId = baseRefUtil.generateId();
1549
+ newCol.id = "h5-card-pane-" + tmpId;
1550
+ newCol.options.name = "h5CardPane" + tmpId;
1551
+ newCol.options.label = "基本信息";
1552
+ newCon.panes.push(newCol);
1553
+ } else if (newCon.type === "detail-h5") {
1554
+ // 一张 h5-card:基础信息 / 明细信息 / 附件信息
1555
+ let newCard = this.copyNewContainerWidget(
1556
+ this.getContainerByType("h5-card")
1557
+ );
1558
+ newCon.panes.push(newCard);
1559
+
1560
+ // 基础信息:默认放 h5 表格(一行两列),对齐 PC 详情的「基础信息 + 表格」
1561
+ let basicPane = newCard.panes[0];
1562
+ if (basicPane) {
1563
+ basicPane.options.label = "基础信息";
1564
+ let h5Table = this.copyNewContainerWidget(
1565
+ this.getContainerByType("h5-table")
1566
+ );
1567
+ basicPane.widgetList.push(h5Table);
1568
+ }
1569
+
1570
+ // 明细信息:H5 列表;只读阶段不预置新增/查看按钮(点行仍可进详情)
1571
+ let newCardPane = this.copyNewContainerWidget(
1572
+ this.getContainerByType("h5-card-pane")
1573
+ );
1574
+ newCardPane.options.label = "明细信息";
1575
+ newCard.panes.push(newCardPane);
1576
+
1577
+ let listH5 = this.copyNewContainerWidget(
1578
+ this.getContainerByType("list-h5")
1579
+ );
1580
+ newCardPane.widgetList.push(listH5);
1581
+
1582
+ // 附件信息
1583
+ newCardPane = this.copyNewContainerWidget(
1584
+ this.getContainerByType("h5-card-pane")
1585
+ );
1586
+ newCardPane.options.label = "附件信息";
1587
+ newCard.panes.push(newCardPane);
1588
+
1589
+ let vabUploadCon = this.copyNewFieldWidget(
1590
+ this.getFieldWidgetByType("vabUpload")
1591
+ );
1592
+ newCardPane.widgetList.push(vabUploadCon);
1593
+ } else if (newCon.type === "h5-table") {
1594
+ /* 默认 4 行 × 2 列,对齐 H5「一行两个」的紧凑版式。
1595
+ 不再预置 input:H5 面板已下架单行输入,空单元格由设计者拖入字段。 */
1596
+ const h5TableCols = 2;
1597
+ const h5TableRows = 4;
1598
+ for (let i = 0; i < h5TableRows; i++) {
1599
+ let newRow = {
1600
+ cols: [],
1601
+ };
1602
+ newRow.id = "table-row-" + baseRefUtil.generateId();
1603
+ newRow.merged = false;
1604
+
1605
+ for (let j = 0; j < h5TableCols; j++) {
1606
+ let newCell = baseRefUtil.deepClone(
1607
+ this.getContainerByType("h5-table-cell")
1608
+ );
1609
+ newCell.id = "table-cell-" + baseRefUtil.generateId();
1610
+ newCell.options.name = newCell.id;
1611
+ newCell.merged = false;
1612
+ newCell.options.colspan = 1;
1613
+ newCell.options.rowspan = 1;
1614
+ newRow.cols.push(newCell);
1615
+ }
1616
+
1617
+ newCon.rows.push(newRow);
1618
+ }
1619
+ } else if (newCon.type === "tree-pane") {
1620
+ //初始化列表
1621
+ let dataTableCon = this.copyNewContainerWidget(
1622
+ this.getContainerByType("data-table")
1623
+ );
1624
+ dataTableCon.options.showPagination = true;
1625
+ dataTableCon.options.showSearchArea = true;
1626
+ dataTableCon.options.isQueryTable = true;
1627
+ dataTableCon.options.tableHeight = "auto";
1628
+ dataTableCon.options.accessReturnType = "2";
1629
+
1630
+ newCon.widgetList.push(dataTableCon);
1631
+
1632
+ let addButton = this.copyNewFieldWidget(
1633
+ this.getFieldWidgetByType("add_button")
1634
+ );
1635
+ addButton.options.onClick =
1636
+ "this.getWidgetRef('" +
1637
+ dataTableCon.options.name +
1638
+ "').openEditDialog();";
1639
+ dataTableCon.buttons.push(addButton);
1640
+
1641
+ let tableExportButton = this.copyNewFieldWidget(
1642
+ this.getFieldWidgetByType("table-export-button")
1643
+ );
1644
+ tableExportButton.options.tableExportParam =
1645
+ "return { title: '导出', targetRef: '" +
1646
+ dataTableCon.options.name +
1647
+ "'}";
1648
+ dataTableCon.buttons.push(tableExportButton);
1649
+
1650
+ // 两个查询条件的值由树节点点击注入,勾上「固定查询条件」后
1651
+ // 刷新、查询条件设置的还原/确定都不会把它清掉
1652
+ let searchInput = this.copyNewFieldWidget(
1653
+ this.getFieldWidgetByType("input")
1654
+ );
1655
+ searchInput.options.disabled = true;
1656
+ searchInput.options.fixedQuery = true;
1657
+ searchInput.options.label = newCon.options.treeLabel;
1658
+ dataTableCon.widgetList.push(searchInput);
1659
+
1660
+ let searchIdInput = this.copyNewFieldWidget(
1661
+ this.getFieldWidgetByType("input")
1662
+ );
1663
+ searchIdInput.options.disabled = true;
1664
+ searchIdInput.options.hidden = true;
1665
+ searchIdInput.options.fixedQuery = true;
1666
+ searchIdInput.options.label = `隐藏${newCon.options.treeLabel}ID`;
1667
+ dataTableCon.widgetList.push(searchIdInput);
1668
+
1669
+ // 存量表单没有 fixedQuery 开关,仍靠 ignoreFields 兜底刷新按钮;
1670
+ // 新建的表单两条通道并存(取并集),不冲突
1671
+ dataTableCon.options.onResetTable = `this.resetEvent({\n ignoreFields:['${searchInput.options.name}', '${searchIdInput.options.name}']\n});`;
1672
+
1673
+ //初始化树
1674
+ let treeCon = this.copyNewContainerWidget(
1675
+ this.getContainerByType("tree")
1676
+ );
1677
+ treeCon.options.onNodeClick = `this.getWidgetRef('${searchInput.options.name}').setValue(data.label);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(data.id);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
1678
+
1679
+ newCon.options.onTreeLabelClick = `this.getWidgetRef('${treeCon.options.name}').setCurrentKey();\nthis.getWidgetRef('${searchInput.options.name}').setValue(null);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(null);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
1680
+ newCon.leftWidgetList.push(treeCon);
1681
+ }
1682
+ //newCon.options.customClass = []
1683
+
1684
+ delete newCon.displayName;
1685
+ return newCon;
1686
+ },
1687
+
1688
+ addContainerByDbClick(container) {
1689
+ let newCon = this.copyNewContainerWidget(container);
1690
+ this.widgetList.push(newCon);
1691
+ this.setSelected(newCon);
1692
+ },
1693
+
1694
+ addFieldByDbClick(widget) {
1695
+ let newWidget = this.copyNewFieldWidget(widget);
1696
+ if (!!this.selectedWidget && this.selectedWidget.type === "tab") {
1697
+ //获取当前激活的tabPane
1698
+ let activeTab = this.selectedWidget.tabs[0];
1699
+ this.selectedWidget.tabs.forEach((tabPane) => {
1700
+ if (!!tabPane.options.active) {
1701
+ activeTab = tabPane;
1702
+ }
1703
+ });
1704
+
1705
+ !!activeTab && activeTab.widgetList.push(newWidget);
1706
+ } else if (!!this.selectedWidget && !!this.selectedWidget.widgetList) {
1707
+ this.selectedWidget.widgetList.push(newWidget);
1708
+ } else {
1709
+ this.widgetList.push(newWidget);
1710
+ }
1711
+
1712
+ this.setSelected(newWidget);
1713
+ this.emitEvent("canvas-add-field", newWidget.options.name),
1714
+ this.emitHistoryChange();
1715
+ },
1716
+ /**
1717
+ * 删除详情容器下的一个 pane。
1718
+ * @param gridWidget 详情容器(detail / detail-plain)
1719
+ * @param paneOrIdx pane 的 widget 引用,或它在 panes 中的下标。
1720
+ * detail 的属性面板按 type 做了显隐,下标不再可靠,故走引用;
1721
+ * detail-plain 的属性面板仍传下标,这里一并兼容。
1722
+ */
1723
+ deletePaneOfDetail(gridWidget, paneOrIdx) {
1724
+ if (!gridWidget || !gridWidget.panes) return;
1725
+ let isIdx = typeof paneOrIdx === "number";
1726
+ let colIdx = isIdx ? paneOrIdx : gridWidget.panes.indexOf(paneOrIdx);
1727
+ if (colIdx < 0) return;
1728
+ gridWidget.panes.splice(colIdx, 1);
1729
+ },
1730
+ cloneDetailPane(widget, parentWidget) {
1731
+ let newGridCol = baseRefUtil.deepClone(
1732
+ this.getContainerByType("detail-pane")
1733
+ );
1734
+ let tmpId = baseRefUtil.generateId();
1735
+ newGridCol.id = "detail-pane-" + tmpId;
1736
+ newGridCol.options.name = "detailPane" + tmpId;
1737
+ newGridCol.options.label = widget.options.label;
1738
+ parentWidget.panes.push(newGridCol);
1739
+ },
1740
+ cloneH5CardPanePane(widget, parentWidget) {
1741
+ let newGridCol = baseRefUtil.deepClone(
1742
+ this.getContainerByType("h5-card-pane")
1743
+ );
1744
+ let tmpId = baseRefUtil.generateId();
1745
+ newGridCol.id = "h5-card-pane-" + tmpId;
1746
+ newGridCol.options.name = "h5CardPane" + tmpId;
1747
+ newGridCol.options.label = widget.options.label;
1748
+ parentWidget.panes.push(newGridCol);
1749
+ },
1750
+
1751
+ addNewPaneOfDetail(gridWidget) {
1752
+ const cols = gridWidget.panes;
1753
+ let newGridCol = baseRefUtil.deepClone(
1754
+ this.getContainerByType("detail-pane")
1755
+ );
1756
+ let tmpId = baseRefUtil.generateId();
1757
+ newGridCol.id = "detail-pane-" + tmpId;
1758
+ newGridCol.options.name = "detailPane" + tmpId;
1759
+ newGridCol.options.label = "detailPane" + tmpId;
1760
+ // 默认添加一个栅格控件到新 pane 的 widgetList 中,列数取模板模块配置的行列数
1761
+ let colCount = gridWidget.options.rowColCount || 3;
1762
+ let defaultGrid = this.createDefaultGridOfDetailTemp(colCount);
1763
+ newGridCol.widgetList.push(defaultGrid);
1764
+ gridWidget.panes.push(newGridCol);
1765
+ },
1766
+
1767
+ // 模板模块(detail-temp)自动生成的默认栅格:colCount 列平均分布(24 栏均分)。
1768
+ // autoLayout 标记用于行列数变更时识别并同步这些默认栅格,用户手动拖入的栅格不受影响。
1769
+ createDefaultGridOfDetailTemp(colCount) {
1770
+ let defaultGrid = baseRefUtil.deepClone(
1771
+ this.getContainerByType("grid")
1772
+ );
1773
+ defaultGrid.id = "grid-" + baseRefUtil.generateId();
1774
+ defaultGrid.options.autoLayout = true;
1775
+ let span = Math.floor(24 / colCount);
1776
+ for (let i = 0; i < colCount; i++) {
1777
+ let col = baseRefUtil.deepClone(
1778
+ this.getContainerByType("grid-col")
1779
+ );
1780
+ col.id = "grid-col-" + baseRefUtil.generateId();
1781
+ col.options.span = span;
1782
+ defaultGrid.cols.push(col);
1783
+ }
1784
+ return defaultGrid;
1785
+ },
1786
+
1787
+ // 行列数下拉变化:写回配置,并同步所有模块里自动生成的默认栅格
1788
+ changeDetailTempRowCol(gridWidget, colCount) {
1789
+ if (!gridWidget || !gridWidget.options) return;
1790
+ gridWidget.options.rowColCount = colCount;
1791
+ let span = Math.floor(24 / colCount);
1792
+ (gridWidget.panes || []).forEach((paneWidget) => {
1793
+ (paneWidget.widgetList || []).forEach((subWidget) => {
1794
+ if (
1795
+ subWidget.type === "grid" &&
1796
+ subWidget.options &&
1797
+ subWidget.options.autoLayout
1798
+ ) {
1799
+ let gridCols = subWidget.cols || (subWidget.cols = []);
1800
+ // 已有列统一为新的均分 span(列内已拖入的内容保留)
1801
+ gridCols.forEach((col) => {
1802
+ col.options.span = span;
1803
+ });
1804
+ // 列数不足:补齐新列
1805
+ while (gridCols.length < colCount) {
1806
+ let col = baseRefUtil.deepClone(
1807
+ this.getContainerByType("grid-col")
1808
+ );
1809
+ col.id = "grid-col-" + baseRefUtil.generateId();
1810
+ col.options.span = span;
1811
+ gridCols.push(col);
1812
+ }
1813
+ // 列数超出:仅移除尾部空列,非空列保留,避免丢失已拖入的组件
1814
+ while (gridCols.length > colCount) {
1815
+ let lastCol = gridCols[gridCols.length - 1];
1816
+ if (lastCol.widgetList && lastCol.widgetList.length > 0) break;
1817
+ gridCols.pop();
1818
+ }
1819
+ }
1820
+ });
1821
+ });
1822
+ },
1823
+
1824
+ deleteColOfGrid(gridWidget, colIdx) {
1825
+ if (!!gridWidget && !!gridWidget.cols) {
1826
+ gridWidget.cols.splice(colIdx, 1);
1827
+ }
1828
+ },
1829
+
1830
+ addNewColOfGrid(gridWidget) {
1831
+ const cols = gridWidget.cols;
1832
+ let newGridCol = baseRefUtil.deepClone(
1833
+ this.getContainerByType("grid-col")
1834
+ );
1835
+ let tmpId = baseRefUtil.generateId();
1836
+ newGridCol.id = "grid-col-" + tmpId;
1837
+ newGridCol.options.name = "gridCol" + tmpId;
1838
+ if (!!cols && cols.length > 0) {
1839
+ let spanSum = 0;
1840
+ cols.forEach((col) => {
1841
+ spanSum += col.options.span;
1842
+ });
1843
+
1844
+ if (spanSum >= 24) {
1845
+ //this.$message.info('列栅格之和超出24')
1846
+ console.log("列栅格之和超出24");
1847
+ gridWidget.cols.push(newGridCol);
1848
+ } else {
1849
+ newGridCol.options.span = 24 - spanSum > 12 ? 12 : 24 - spanSum;
1850
+ gridWidget.cols.push(newGridCol);
1851
+ }
1852
+ } else {
1853
+ gridWidget.cols = [newGridCol];
1854
+ }
1855
+ },
1856
+
1857
+ addTabPaneOfTabs(tabsWidget) {
1858
+ const tabPanes = tabsWidget.tabs;
1859
+ let newTabPane = baseRefUtil.deepClone(
1860
+ this.getContainerByType("tab-pane")
1861
+ );
1862
+ newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
1863
+ newTabPane.options.name = newTabPane.id;
1864
+ newTabPane.options.label = "tab " + (tabPanes.length + 1);
1865
+ tabPanes.push(newTabPane);
1866
+ },
1867
+
1868
+ deleteTabPaneOfTabs(tabsWidget, tpIdx) {
1869
+ tabsWidget.tabs.splice(tpIdx, 1);
1870
+ },
1871
+
1872
+ addDropdownItem(tabsWidget) {
1873
+ const tabPanes = tabsWidget.widgetList;
1874
+ let newTabPane = baseRefUtil.deepClone(
1875
+ this.getFieldWidgetByType("dropdown-item")
1876
+ );
1877
+ newTabPane.id = "dropdown-item-" + baseRefUtil.generateId();
1878
+ newTabPane.options.name = newTabPane.id;
1879
+ newTabPane.options.label = "dropdown-item " + (tabPanes.length + 1);
1880
+ tabPanes.push(newTabPane);
1881
+ },
1882
+
1883
+ deleteDropdownItem(tabsWidget, tpIdx) {
1884
+ tabsWidget.widgetList.splice(tpIdx, 1);
1885
+ },
1886
+
1887
+ emitEvent(evtName, evtData) {
1888
+ //用于兄弟组件发射事件
1889
+ this.vueInstance.$emit(evtName, evtData);
1890
+ },
1891
+
1892
+ handleEvent(evtName, callback) {
1893
+ //用于兄弟组件接收事件
1894
+ this.vueInstance.$on(evtName, (data) => callback(data));
1895
+ },
1896
+
1897
+ setCssClassList(cssClassList) {
1898
+ this.cssClassList = cssClassList;
1899
+ },
1900
+
1901
+ getCssClassList() {
1902
+ return this.cssClassList;
1903
+ },
1904
+
1905
+ registerFormWidget(formWidget) {
1906
+ this.formWidget = formWidget;
1907
+ },
1908
+
1909
+ initHistoryData() {
1910
+ this.loadFormContentFromStorage();
1911
+ this.historyData.index++;
1912
+ this.historyData.steps[this.historyData.index] = {
1913
+ widgetList: baseRefUtil.deepClone(this.widgetList),
1914
+ formConfig: baseRefUtil.deepClone(this.formConfig),
1915
+ };
1916
+ },
1917
+
1918
+ emitHistoryChange() {
1919
+ //console.log('------------', 'Form history changed!')
1920
+
1921
+ if (this.historyData.index === this.historyData.maxStep - 1) {
1922
+ this.historyData.steps.shift();
1923
+ } else {
1924
+ this.historyData.index++;
1925
+ }
1926
+
1927
+ this.historyData.steps[this.historyData.index] = {
1928
+ widgetList: baseRefUtil.deepClone(this.widgetList),
1929
+ formConfig: baseRefUtil.deepClone(this.formConfig),
1930
+ };
1931
+
1932
+ this.saveFormContentToStorage();
1933
+
1934
+ if (this.historyData.index < this.historyData.steps.length - 1) {
1935
+ this.historyData.steps = this.historyData.steps.slice(
1936
+ 0,
1937
+ this.historyData.index + 1
1938
+ );
1939
+ }
1940
+
1941
+ //console.log('history', this.historyData.index)
1942
+ },
1943
+
1944
+ saveCurrentHistoryStep() {
1945
+ this.historyData.steps[this.historyData.index] = baseRefUtil.deepClone({
1946
+ widgetList: this.widgetList,
1947
+ formConfig: this.formConfig,
1948
+ });
1949
+
1950
+ this.saveFormContentToStorage();
1951
+ },
1952
+
1953
+ undoHistoryStep() {
1954
+ if (this.historyData.index !== 0) {
1955
+ this.historyData.index--;
1956
+ }
1957
+ //console.log('undo', this.historyData.index)
1958
+
1959
+ this.widgetList = baseRefUtil.deepClone(
1960
+ this.historyData.steps[this.historyData.index].widgetList
1961
+ );
1962
+ this.formConfig = baseRefUtil.deepClone(
1963
+ this.historyData.steps[this.historyData.index].formConfig
1964
+ );
1965
+ },
1966
+
1967
+ redoHistoryStep() {
1968
+ if (this.historyData.index !== this.historyData.steps.length - 1) {
1969
+ this.historyData.index++;
1970
+ }
1971
+ //console.log('redo', this.historyData.index)
1972
+
1973
+ this.widgetList = baseRefUtil.deepClone(
1974
+ this.historyData.steps[this.historyData.index].widgetList
1975
+ );
1976
+ this.formConfig = baseRefUtil.deepClone(
1977
+ this.historyData.steps[this.historyData.index].formConfig
1978
+ );
1979
+ },
1980
+
1981
+ undoEnabled() {
1982
+ return this.historyData.index > 0 && this.historyData.steps.length > 0;
1983
+ },
1984
+
1985
+ redoEnabled() {
1986
+ return this.historyData.index < this.historyData.steps.length - 1;
1987
+ },
1988
+
1989
+ saveFormContentToStorage() {
1990
+ window.localStorage.setItem(
1991
+ "widget__list__backup",
1992
+ JSON.stringify(this.widgetList)
1993
+ );
1994
+ window.localStorage.setItem(
1995
+ "form__config__backup",
1996
+ JSON.stringify(this.formConfig)
1997
+ );
1998
+ },
1999
+
2000
+ loadFormContentFromStorage() {
2001
+ let widgetListBackup = window.localStorage.getItem(
2002
+ "widget__list__backup"
2003
+ );
2004
+ if (!!widgetListBackup) {
2005
+ this.widgetList = JSON.parse(widgetListBackup);
2006
+ }
2007
+
2008
+ let formConfigBackup = window.localStorage.getItem(
2009
+ "form__config__backup"
2010
+ );
2011
+ if (!!formConfigBackup) {
2012
+ //this.formConfig = JSON.parse(formConfigBackup)
2013
+ baseRefUtil.overwriteObj(
2014
+ this.formConfig,
2015
+ JSON.parse(formConfigBackup)
2016
+ ); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
2017
+ }
2018
+ },
2019
+ getColumnWidget(row, isEdit) {
2020
+ //获取
2021
+ let formatS = isEdit ? row.editFormatS : row.formatS;
2022
+ let type = columnFormatMap[formatS];
2023
+ if (!type) return null;
2024
+ if (isEdit) {
2025
+ if (row.editWidget) {
2026
+ return row.editWidget;
2027
+ }
2028
+ if (row.editColumnOption) {
2029
+ let fieldWidget = this.copyNewFieldWidget(
2030
+ this.getFieldWidgetByType(type)
2031
+ );
2032
+ fieldWidget.options = row.editColumnOption;
2033
+ return fieldWidget;
2034
+ }
2035
+ } else {
2036
+ if (row.widget) {
2037
+ return row.widget;
2038
+ }
2039
+ if (row.columnOption) {
2040
+ let fieldWidget = this.copyNewFieldWidget(
2041
+ this.getFieldWidgetByType(type)
2042
+ );
2043
+ fieldWidget.options = row.columnOption;
2044
+ return fieldWidget;
2045
+ }
2046
+ }
2047
+ return this.createColumnWidget(row, isEdit);
2048
+ },
2049
+ getIsFileWidget(type) {
2050
+ return type === "vabUpload" || type === "baseAttachment";
2051
+ },
2052
+ createColumnWidget(row, isEdit) {
2053
+ let formatS = isEdit ? row.editFormatS : row.formatS;
2054
+ let type = columnFormatMap[formatS];
2055
+ if (!type) return null;
2056
+
2057
+ let columnSelectedWidget = null;
2058
+ if (type) {
2059
+ columnSelectedWidget = this.copyNewFieldWidget(
2060
+ this.getFieldWidgetByType(type)
2061
+ );
2062
+
2063
+ if (columnSelectedWidget.options.hasOwnProperty("required")) {
2064
+ columnSelectedWidget.options.required = row.required || false;
2065
+ }
2066
+
2067
+ if ("editDelete" === formatS) {
2068
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2069
+ columnSelectedWidget.options.label = "删除";
2070
+ columnSelectedWidget.options.labelHidden = true;
2071
+ columnSelectedWidget.options.hiddenByWf = true;
2072
+ columnSelectedWidget.options.onClick =
2073
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
2074
+ } else if ("editButton" === formatS) {
2075
+ columnSelectedWidget.options.prefixIcon = "el-icon-edit";
2076
+ columnSelectedWidget.options.label = "查看";
2077
+ columnSelectedWidget.options.labelHidden = true;
2078
+ columnSelectedWidget.options.onClick =
2079
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
2080
+ } else if ("addSiblingEditRow" === formatS) {
2081
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2082
+ columnSelectedWidget.options.label = "新增兄弟节点";
2083
+ columnSelectedWidget.options.labelHidden = false;
2084
+ columnSelectedWidget.options.onClick =
2085
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
2086
+ } else if ("addChildTreeRow" === formatS) {
2087
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2088
+ columnSelectedWidget.options.label = "新增子节点";
2089
+ columnSelectedWidget.options.labelHidden = false;
2090
+ columnSelectedWidget.options.onClick =
2091
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
2092
+ } else if ("moveUpRow" === formatS) {
2093
+ columnSelectedWidget.options.label = "↑上移";
2094
+ columnSelectedWidget.options.labelHidden = false;
2095
+ columnSelectedWidget.options.onClick =
2096
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
2097
+ } else if ("moveDownRow" === formatS) {
2098
+ columnSelectedWidget.options.label = "↓下移";
2099
+ columnSelectedWidget.options.labelHidden = false;
2100
+ columnSelectedWidget.options.onClick =
2101
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
2102
+ } else if ("removeTreeRow" === formatS) {
2103
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2104
+ columnSelectedWidget.options.label = "删除";
2105
+ columnSelectedWidget.options.labelHidden = true;
2106
+ columnSelectedWidget.options.onClick =
2107
+ "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
2108
+ }
2109
+
2110
+ if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
2111
+ if (!this.getIsFileWidget(type)) {
2112
+ columnSelectedWidget.options.keyName = row.prop;
2113
+ }
2114
+
2115
+ columnSelectedWidget.options.keyNameEnabled = true;
2116
+ } else {
2117
+ columnSelectedWidget.options.name = row.prop;
2118
+ }
2119
+
2120
+ if (type === "dropdown") {
2121
+ columnSelectedWidget.options.dropdownType = "link";
2122
+ } else if (type !== "button" && type !== "a-link") {
2123
+ columnSelectedWidget.options.label = row.label;
2124
+ columnSelectedWidget.options.labelHidden = true;
2125
+ }
2126
+ }
2127
+ return columnSelectedWidget;
2128
+ },
2129
+ };
2130
+ };
2131
+ })();
2132
+
2133
+ export const createDesigner = createDesigner0;