cloud-web-corejs 1.0.276 → 1.0.277

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