cloud-web-corejs 1.1.0-dev.4 → 1.1.0-dev.40

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