cloud-web-corejs 1.0.54-dev.63 → 1.0.54-dev.630

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 (499) hide show
  1. package/package.json +21 -13
  2. package/src/App.vue +30 -34
  3. package/src/api/user.js +16 -0
  4. package/src/components/Qrcode/fileParse.vue +0 -1
  5. package/src/components/Tinymce/index.vue +112 -71
  6. package/src/components/VabUpload/image-viewer.vue +2 -2
  7. package/src/components/VabUpload/index.js +49 -1
  8. package/src/components/VabUpload/mixins.js +1822 -2
  9. package/src/components/VabUpload/propertiesDialog.vue +1 -1
  10. package/src/components/VabUpload/view.vue +209 -120
  11. package/src/components/advancedSearchDialog/mixins.js +28 -1
  12. package/src/components/base-textarea/index.vue +104 -0
  13. package/src/components/baseAlert/index.js +44 -1
  14. package/src/components/baseAlert/index.vue +24 -20
  15. package/src/components/baseAlert/mixins.js +61 -1
  16. package/src/components/baseAttachment/index.vue +49 -40
  17. package/src/components/baseAttachment/install.js +21 -5
  18. package/src/components/baseAttachment/mixins.js +310 -1
  19. package/src/components/baseInputBatch/mixins.js +58 -1
  20. package/src/components/baseInputExport/index.vue +21 -14
  21. package/src/components/baseInputExport/mixins.js +391 -1
  22. package/src/components/baseTabs/index.vue +16 -8
  23. package/src/components/baseTabs/mixins.js +166 -1
  24. package/src/components/cnPrint/index.js +44 -1
  25. package/src/components/cnPrint/mixins.js +189 -1
  26. package/src/components/code-editor/index.vue +102 -63
  27. package/src/components/confirmDialog/index.js +41 -1
  28. package/src/components/confirmDialog/index.vue +24 -17
  29. package/src/components/confirmDialog/mixins.js +31 -1
  30. package/src/components/errorMsg/index.js +44 -1
  31. package/src/components/errorMsg/index.vue +78 -70
  32. package/src/components/errorMsg/mixins.js +101 -5
  33. package/src/components/excelExport/button.vue +86 -24
  34. package/src/components/excelExport/exportFieldDialog.vue +215 -81
  35. package/src/components/excelExport/index.js +6 -6
  36. package/src/components/excelExport/index.vue +108 -26
  37. package/src/components/excelExport/mixins.js +970 -2
  38. package/src/components/excelImport/index.js +13 -13
  39. package/src/components/excelImport/mixins.js +2 -1
  40. package/src/components/fileLibrary/fileObjAuthDialog.vue +179 -89
  41. package/src/components/fileLibrary/fileObjAuthEditDialog.vue +6 -0
  42. package/src/components/fileLibrary/filterDialog.vue +454 -0
  43. package/src/components/fileLibrary/index.vue +605 -262
  44. package/src/components/fileLibrary/mixins/categoryMoveDialogMixins.js +1 -1
  45. package/src/components/fileLibrary/mixins/fileCategoryDialogMixins.js +1 -1
  46. package/src/components/fileLibrary/mixins/fileHistoryDialogMixins.js +2 -2
  47. package/src/components/fileLibrary/mixins/fileObjAuthDialogMixin.js +339 -211
  48. package/src/components/fileLibrary/mixins/fileObjAuthEditDialogMixin.js +31 -27
  49. package/src/components/fileLibrary/mixins/fileObjAuthEditMixin.js +4 -4
  50. package/src/components/fileLibrary/mixins/indexMixins.js +220 -101
  51. package/src/components/fileLibrary/mixins/propertiesDialogMixins.js +64 -4
  52. package/src/components/fileLibrary/mixins/recycleBinDialogMixins.js +3 -3
  53. package/src/components/fileLibrary/propertiesDialog.vue +113 -74
  54. package/src/components/fileLibrary/shareDialog.vue +1 -1
  55. package/src/components/formOplog/mixins.js +85 -4
  56. package/src/components/hiprint/css/bootstrap.min.css +6 -0
  57. package/src/components/hiprint/fonts/glyphicons-halflings-regular.eot +0 -0
  58. package/src/components/hiprint/fonts/glyphicons-halflings-regular.svg +288 -0
  59. package/src/components/hiprint/fonts/glyphicons-halflings-regular.ttf +0 -0
  60. package/src/components/hiprint/fonts/glyphicons-halflings-regular.woff +0 -0
  61. package/src/components/hiprint/fonts/glyphicons-halflings-regular.woff2 +0 -0
  62. package/src/components/hiprint/hiprint.bundle.js +7 -2
  63. package/src/components/hiprint/view/design/index.vue +140 -47
  64. package/src/components/hiprint/view/design/mixins.js +611 -1
  65. package/src/components/hiprint/view/design/preview.vue +75 -52
  66. package/src/components/hiprint/view/json-view.vue +31 -31
  67. package/src/components/jdPrint/index.js +44 -1
  68. package/src/components/jdPrint/mixins.js +208 -1
  69. package/src/components/jsonImport/index.js +187 -17
  70. package/src/components/jsonImport/mixins.js +333 -1
  71. package/src/components/langImport/index.js +80 -1
  72. package/src/components/langImport/mixins.js +500 -16
  73. package/src/components/langTag/mixins/addButton.js +51 -5
  74. package/src/components/langTag/mixins/deleteButton.js +55 -5
  75. package/src/components/langTag/mixins/view.js +47 -5
  76. package/src/components/luckysheet/dialog.vue +159 -0
  77. package/src/components/luckysheet/export.js +595 -0
  78. package/src/components/luckysheet/fileUtils.js +147 -0
  79. package/src/components/luckysheet/index.js +72 -0
  80. package/src/components/luckysheet/templateJson.js +12078 -0
  81. package/src/components/luckysheet/view.vue +210 -0
  82. package/src/components/obsUpload/index.js +34 -0
  83. package/src/components/obsUpload/index.vue +231 -0
  84. package/src/components/obsUpload/mixins.js +1476 -0
  85. package/src/components/onlineTalk/mixins.js +852 -1
  86. package/src/components/oplogTable/mixins.js +83 -4
  87. package/src/components/pddPrint/index.js +44 -1
  88. package/src/components/pddPrint/mixins.js +252 -1
  89. package/src/components/projectTag/mixins/addButton.js +52 -1
  90. package/src/components/projectTag/mixins/deleteButton.js +52 -1
  91. package/src/components/projectTag/mixins/view.js +43 -1
  92. package/src/components/scriptDescription/button.vue +12 -4
  93. package/src/components/scriptDescription/mixins.js +30 -1
  94. package/src/components/scriptTest/mixins.js +90 -1
  95. package/src/components/statusTag/mixins.js +66 -1
  96. package/src/components/table/CellSlot.vue +1 -0
  97. package/src/components/table/config.js +74 -1
  98. package/src/components/table/index.js +1156 -11
  99. package/src/components/table/plugins/extend-cell-area/vxe-table-extend-cell-area.es6.min.js +11028 -0
  100. package/src/components/table/plugins/extend-cell-area/vxe-table-extend-cell-area.min.css +200 -0
  101. package/src/components/table/tableForm.vue +99 -63
  102. package/src/components/table/tableFormMixin.js +285 -1
  103. package/src/components/table/util/index.js +339 -0
  104. package/src/components/table/vxeFilter/index.js +154 -1
  105. package/src/components/table/vxeFilter/mixin.js +308 -6
  106. package/src/components/tempStorage/index.vue +76 -55
  107. package/src/components/tempStorage/tempStorageDialog.vue +179 -54
  108. package/src/components/vb-tabs/x-tabs.vue +56 -30
  109. package/src/components/vipPrint/index.js +44 -1
  110. package/src/components/vipPrint/mixins.js +268 -1
  111. package/src/components/wf/addOpinionButton.vue +57 -0
  112. package/src/components/wf/content.vue +834 -362
  113. package/src/components/wf/mixins/addOpinionButton.js +53 -0
  114. package/src/components/wf/mixins/setCandidateButton.js +161 -0
  115. package/src/components/wf/mixins/setCandidateDialog.js +213 -1
  116. package/src/components/wf/mixins/setCandidateDialog2.js +252 -0
  117. package/src/components/wf/mixins/wfFlowEleScriptDialog.js +131 -0
  118. package/src/components/wf/mixins/wfTaskUserRangeDialog.js +69 -0
  119. package/src/components/wf/setCandidateButton.vue +40 -0
  120. package/src/components/wf/setCandidateDialog.vue +10 -0
  121. package/src/components/wf/setCandidateDialog2.vue +105 -0
  122. package/src/components/wf/wf.js +2156 -1
  123. package/src/components/wf/wfFlowEleScriptDialog.vue +89 -0
  124. package/src/components/wf/wfStartDialog.vue +66 -42
  125. package/src/components/wf/wfTaskUserRangeDialog.vue +65 -0
  126. package/src/components/wf/wfUtil.js +279 -1
  127. package/src/components/xform/form-designer/designer.js +1995 -9
  128. package/src/components/xform/form-designer/form-widget/components/gantt/index.vue +434 -0
  129. package/src/components/xform/form-designer/form-widget/container-widget/containerMixin.js +1 -1
  130. package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +9 -8
  131. package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +4 -1
  132. package/src/components/xform/form-designer/form-widget/container-widget/detail-pane-widget.vue +3 -2
  133. package/src/components/xform/form-designer/form-widget/container-widget/detail-widget.vue +3 -3
  134. package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog copy.vue +971 -0
  135. package/src/components/xform/form-designer/form-widget/dialog/baseFormulaDialog.vue +971 -0
  136. package/src/components/xform/form-designer/form-widget/dialog/exportDialog.vue +13 -0
  137. package/src/components/xform/form-designer/form-widget/dialog/fileReferenceDialog.vue +301 -0
  138. package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +85 -48
  139. package/src/components/xform/form-designer/form-widget/dialog/formDrawer.vue +5 -1
  140. package/src/components/xform/form-designer/form-widget/dialog/formulaDialog.vue +799 -0
  141. package/src/components/xform/form-designer/form-widget/dialog/importDialog.vue +30 -7
  142. package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +1762 -9
  143. package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +222 -75
  144. package/src/components/xform/form-designer/form-widget/field-widget/a-link-widget.vue +2 -2
  145. package/src/components/xform/form-designer/form-widget/field-widget/a-text-widget.vue +1 -1
  146. package/src/components/xform/form-designer/form-widget/field-widget/baseAttachment-widget.vue +32 -4
  147. package/src/components/xform/form-designer/form-widget/field-widget/button-widget.vue +1 -1
  148. package/src/components/xform/form-designer/form-widget/field-widget/cascader-widget.vue +19 -1
  149. package/src/components/xform/form-designer/form-widget/field-widget/census-widget.vue +40 -28
  150. package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +18 -7
  151. package/src/components/xform/form-designer/form-widget/field-widget/color-widget.vue +4 -1
  152. package/src/components/xform/form-designer/form-widget/field-widget/copy_button-widget.vue +95 -0
  153. package/src/components/xform/form-designer/form-widget/field-widget/date-range-widget.vue +13 -2
  154. package/src/components/xform/form-designer/form-widget/field-widget/date-widget.vue +30 -4
  155. package/src/components/xform/form-designer/form-widget/field-widget/download-button-widget.vue +133 -0
  156. package/src/components/xform/form-designer/form-widget/field-widget/dropdown-item-widget.vue +86 -0
  157. package/src/components/xform/form-designer/form-widget/field-widget/dropdown-widget.vue +170 -0
  158. package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +25 -997
  159. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +705 -379
  160. package/src/components/xform/form-designer/form-widget/field-widget/gantt-widget.vue +964 -0
  161. package/src/components/xform/form-designer/form-widget/field-widget/html-text-widget.vue +6 -2
  162. package/src/components/xform/form-designer/form-widget/field-widget/import-button-widget.vue +22 -11
  163. package/src/components/xform/form-designer/form-widget/field-widget/import2-button-widget.vue +90 -0
  164. package/src/components/xform/form-designer/form-widget/field-widget/input-widget.vue +7 -2
  165. package/src/components/xform/form-designer/form-widget/field-widget/mixins/echart-bar-mixin.js +40 -10
  166. package/src/components/xform/form-designer/form-widget/field-widget/mixins/echart-category-mixin.js +58 -91
  167. package/src/components/xform/form-designer/form-widget/field-widget/mixins/echart-pie-mixin.js +8 -1
  168. package/src/components/xform/form-designer/form-widget/field-widget/mixins/vabsearch-mixin.js +179 -0
  169. package/src/components/xform/form-designer/form-widget/field-widget/multiSearch-widget.vue +53 -0
  170. package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +114 -81
  171. package/src/components/xform/form-designer/form-widget/field-widget/oplog-widget.vue +186 -0
  172. package/src/components/xform/form-designer/form-widget/field-widget/print-button-widget.vue +55 -28
  173. package/src/components/xform/form-designer/form-widget/field-widget/print-detail-button-widget.vue +119 -0
  174. package/src/components/xform/form-designer/form-widget/field-widget/project-tag-widget.vue +154 -47
  175. package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +26 -6
  176. package/src/components/xform/form-designer/form-widget/field-widget/search_button-widget.vue +2 -2
  177. package/src/components/xform/form-designer/form-widget/field-widget/select-export-button-widget.vue +86 -0
  178. package/src/components/xform/form-designer/form-widget/field-widget/select-export-item-button-widget.vue +92 -0
  179. package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +24 -9
  180. package/src/components/xform/form-designer/form-widget/field-widget/singerSearch-widget.vue +53 -0
  181. package/src/components/xform/form-designer/form-widget/field-widget/singleUpload-widget.vue +145 -0
  182. package/src/components/xform/form-designer/form-widget/field-widget/static-content-wrapper.vue +12 -1
  183. package/src/components/xform/form-designer/form-widget/field-widget/static-text-widget.vue +8 -3
  184. package/src/components/xform/form-designer/form-widget/field-widget/status-widget.vue +31 -17
  185. package/src/components/xform/form-designer/form-widget/field-widget/table-export-button-widget.vue +38 -37
  186. package/src/components/xform/form-designer/form-widget/field-widget/tableexportbuttonwidget.vue +99 -0
  187. package/src/components/xform/form-designer/form-widget/field-widget/tempStorage-widget.vue +147 -0
  188. package/src/components/xform/form-designer/form-widget/field-widget/text-widget.vue +106 -33
  189. package/src/components/xform/form-designer/form-widget/field-widget/time-range-widget.vue +2 -2
  190. package/src/components/xform/form-designer/form-widget/field-widget/vabSearch-widget.vue +3 -171
  191. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +191 -66
  192. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload2-widget.vue +753 -0
  193. package/src/components/xform/form-designer/form-widget/indexMixin.js +1 -1
  194. package/src/components/xform/form-designer/indexMixin.js +3 -772
  195. package/src/components/xform/form-designer/refMixinDesign.js +1 -28
  196. package/src/components/xform/form-designer/setting-panel/form-setting.vue +981 -172
  197. package/src/components/xform/form-designer/setting-panel/index.vue +4 -0
  198. package/src/components/xform/form-designer/setting-panel/indexMixin.js +1 -1
  199. package/src/components/xform/form-designer/setting-panel/option-items-setting.vue +537 -302
  200. package/src/components/xform/form-designer/setting-panel/property-editor/a-link-editor.vue +4 -4
  201. package/src/components/xform/form-designer/setting-panel/property-editor/a-text-editor.vue +3 -3
  202. package/src/components/xform/form-designer/setting-panel/property-editor/autoValueEnabled-editor.vue +38 -0
  203. package/src/components/xform/form-designer/setting-panel/property-editor/censusClass-editor.vue +6 -0
  204. package/src/components/xform/form-designer/setting-panel/property-editor/colorClass-editor.vue +28 -0
  205. package/src/components/xform/form-designer/setting-panel/property-editor/commonAttributeEnabled-editor.vue +41 -0
  206. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/columnRenderDialog.vue +125 -0
  207. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +956 -1042
  208. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/exportItemColumns-dialog.vue +432 -0
  209. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/onCheckboxChange-editor.vue +1 -1
  210. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +1193 -520
  211. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail/detail-editor.vue +3 -3
  212. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail-pane/detail-pane-editor.vue +3 -3
  213. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-offset-editor.vue +1 -1
  214. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-pull-editor.vue +1 -1
  215. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-push-editor.vue +1 -1
  216. package/src/components/xform/form-designer/setting-panel/property-editor/container-list-h5/list-h5-editor.vue +0 -8
  217. package/src/components/xform/form-designer/setting-panel/property-editor/container-tree/tree-customClass-editor.vue +31 -2
  218. package/src/components/xform/form-designer/setting-panel/property-editor/copyButton-editor.vue +36 -0
  219. package/src/components/xform/form-designer/setting-panel/property-editor/downloadButtonFlag-editor.vue +32 -0
  220. package/src/components/xform/form-designer/setting-panel/property-editor/dropdownFlag-editor.vue +133 -0
  221. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin.js +2 -2
  222. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onAfterConfirmFile-editor.vue +5 -3
  223. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +23 -8
  224. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/clickBindEvent-editor.vue +35 -20
  225. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/search-dialog-event-editor.vue +64 -5
  226. package/src/components/xform/form-designer/setting-panel/property-editor/field-dropdown-menu/dropdown-item-editor.vue +21 -0
  227. package/src/components/xform/form-designer/setting-panel/property-editor/field-dropdown-menu/dropdown-menu-editor.vue +59 -0
  228. package/src/components/xform/form-designer/setting-panel/property-editor/field-echart/echart-bar-editor.vue +25 -0
  229. package/src/components/xform/form-designer/setting-panel/property-editor/field-echart/echart-category-editor.vue +5 -5
  230. package/src/components/xform/form-designer/setting-panel/property-editor/field-gantt/gantt-editor.vue +36 -0
  231. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import-button-editor.vue +77 -20
  232. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import2-button-editor.vue +96 -0
  233. package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-button-editor.vue +44 -15
  234. package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-detail-button-editor.vue +115 -0
  235. package/src/components/xform/form-designer/setting-panel/property-editor/field-rate/rate-defaultValue-editor.vue +1 -1
  236. package/src/components/xform/form-designer/setting-panel/property-editor/field-static-text/preWrap-editor.vue +23 -0
  237. package/src/components/xform/form-designer/setting-panel/property-editor/field-static-text/textContent-editor.vue +1 -1
  238. package/src/components/xform/form-designer/setting-panel/property-editor/field-status/field-status-editor.vue +67 -41
  239. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-button-editor.vue +56 -0
  240. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-item-button-editor.vue +71 -0
  241. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/table-export-button-editor.vue +24 -8
  242. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabSearch/vabSearchName-editor.vue +13 -1
  243. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/field-vabUpload-editor.vue +33 -1
  244. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload2/field-vabUpload2-editor.vue +66 -0
  245. package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +89 -19
  246. package/src/components/xform/form-designer/setting-panel/property-editor/formatType-editor.vue +137 -0
  247. package/src/components/xform/form-designer/setting-panel/property-editor/formula-editor.vue +721 -466
  248. package/src/components/xform/form-designer/setting-panel/property-editor/labelColor-editor.vue +20 -11
  249. package/src/components/xform/form-designer/setting-panel/property-editor/labelIconClass-editor.vue +1 -1
  250. package/src/components/xform/form-designer/setting-panel/property-editor/labelIconPosition-editor.vue +1 -1
  251. package/src/components/xform/form-designer/setting-panel/property-editor/labelTooltip-editor.vue +1 -1
  252. package/src/components/xform/form-designer/setting-panel/property-editor/limit-editor.vue +1 -1
  253. package/src/components/xform/form-designer/setting-panel/property-editor/multiple-editor.vue +19 -14
  254. package/src/components/xform/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +1 -1
  255. package/src/components/xform/form-designer/setting-panel/property-editor/name-editor.vue +126 -50
  256. package/src/components/xform/form-designer/setting-panel/property-editor/oplog-editor.vue +31 -0
  257. package/src/components/xform/form-designer/setting-panel/property-editor/precision-editor.vue +1 -1
  258. package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +349 -0
  259. package/src/components/xform/form-designer/setting-panel/property-editor/required-editor.vue +10 -6
  260. package/src/components/xform/form-designer/setting-panel/property-editor/requiredHint-editor.vue +3 -3
  261. package/src/components/xform/form-designer/setting-panel/property-editor/showRuleFlag-editor.vue +1 -1
  262. package/src/components/xform/form-designer/setting-panel/property-editor/tempStorage-editor.vue +42 -0
  263. package/src/components/xform/form-designer/setting-panel/property-editor/textFlag-editor.vue +305 -19
  264. package/src/components/xform/form-designer/setting-panel/property-editor/validation-editor.vue +2 -2
  265. package/src/components/xform/form-designer/setting-panel/property-editor/validationHint-editor.vue +2 -2
  266. package/src/components/xform/form-designer/setting-panel/property-editor/wfFlag-editor.vue +372 -50
  267. package/src/components/xform/form-designer/setting-panel/property-editor/widgetShowRuleFlag-editor.vue +263 -0
  268. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +33 -11
  269. package/src/components/xform/form-designer/toolbar-panel/index.vue +12 -11
  270. package/src/components/xform/form-designer/toolbar-panel/indexMixin.js +1 -1
  271. package/src/components/xform/form-designer/widget-panel/index.vue +21 -1
  272. package/src/components/xform/form-designer/widget-panel/indexMixin.js +19 -18
  273. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +1729 -918
  274. package/src/components/xform/form-render/container-item/containerItemMixin.js +12 -11
  275. package/src/components/xform/form-render/container-item/data-table-item.vue +206 -198
  276. package/src/components/xform/form-render/container-item/data-table-mixin.js +3326 -1685
  277. package/src/components/xform/form-render/container-item/detail-item.vue +72 -48
  278. package/src/components/xform/form-render/container-item/detail-pane-item.vue +17 -3
  279. package/src/components/xform/form-render/container-item/grid-col-item.vue +10 -3
  280. package/src/components/xform/form-render/container-item/grid-item.vue +1 -1
  281. package/src/components/xform/form-render/container-item/list-h5-item.vue +1 -9
  282. package/src/components/xform/form-render/container-item/list-h5-item2.vue +1 -8
  283. package/src/components/xform/form-render/container-item/tab-item.vue +62 -25
  284. package/src/components/xform/form-render/container-item/table-cell-item.vue +38 -32
  285. package/src/components/xform/form-render/container-item/table-item.vue +4 -2
  286. package/src/components/xform/form-render/container-item/table2-cell-item.vue +53 -34
  287. package/src/components/xform/form-render/container-item/table2-item.vue +167 -92
  288. package/src/components/xform/form-render/container-item/tree-item.vue +32 -11
  289. package/src/components/xform/form-render/dynamicDialogRender.js +1 -1
  290. package/src/components/xform/form-render/index.vue +77 -20
  291. package/src/components/xform/form-render/indexMixin.js +3719 -12
  292. package/src/components/xform/form-render/refMixin.js +3 -3
  293. package/src/components/xform/lang/zh-CN.js +29 -4
  294. package/src/components/xform/mixins/defaultHandle.js +367 -2
  295. package/src/components/xform/mixins/scriptHttp.js +3 -1
  296. package/src/components/xform/utils/emitter.js +4 -4
  297. package/src/components/xform/utils/formHttp.js +162 -0
  298. package/src/components/xform/utils/format.js +41 -34
  299. package/src/components/xform/utils/formula-util.js +969 -0
  300. package/src/components/xform/utils/smart-vue-i18n/index.js +2 -1
  301. package/src/components/xform/utils/util.js +1475 -1
  302. package/src/components/xform/utils/validators.js +2 -5
  303. package/src/components/xform/utils/vue2js-generator.js +2 -2
  304. package/src/components/xhsPrint/index.js +44 -1
  305. package/src/components/xhsPrint/mixins.js +269 -1
  306. package/src/directive/LimitNumber/index.js +125 -1
  307. package/src/directive/el-dialog-center/index.js +34 -1
  308. package/src/directive/el-drag-dialog/drag.js +86 -1
  309. package/src/directive/el-readonly/index.js +15 -1
  310. package/src/directive/permission/hasPermi.js +34 -1
  311. package/src/index.js +215 -190
  312. package/src/lang/index.js +56 -51
  313. package/src/lang/locale/en/login.js +20 -0
  314. package/src/lang/locale/zh/login.js +20 -0
  315. package/src/layout/components/AppMain.vue +8 -1
  316. package/src/layout/components/Sidebar/default.vue +1432 -1222
  317. package/src/layout/components/Sidebar/index.vue +6 -1
  318. package/src/layout/components/TagsView/index.vue +43 -12
  319. package/src/layout/components/createCompany/createCompanyDialog.vue +157 -0
  320. package/src/layout/components/extractedCode/createDialog.vue +92 -0
  321. package/src/layout/components/extractedCode/queryDialog.vue +103 -0
  322. package/src/layout/components/extractedCode/viewDialog.vue +207 -0
  323. package/src/layout/components/langTool.vue +32 -29
  324. package/src/layout/components/watermark/index.vue +83 -0
  325. package/src/layout/defaultLayout.vue +17 -9
  326. package/src/mixins/selectDialog/index.js +266 -1
  327. package/src/mixins/tableTree/index.js +199 -4
  328. package/src/mixins/wf/index.js +33 -1
  329. package/src/permission.js +135 -18
  330. package/src/resources/js/base/common.js +109 -109
  331. package/src/router/modules/customer.js +0 -15
  332. package/src/router/modules/system.js +4 -0
  333. package/src/store/config/index.js +667 -1
  334. package/src/store/getters.js +4 -1
  335. package/src/store/modules/permission.js +46 -41
  336. package/src/store/modules/settings.js +1 -1
  337. package/src/store/modules/tagsView.js +5 -8
  338. package/src/store/modules/user.js +367 -16
  339. package/src/utils/aes.js +2 -1
  340. package/src/utils/auth.js +1 -1
  341. package/src/utils/global.js +1 -1
  342. package/src/utils/index.js +2 -3
  343. package/src/utils/keepAlive.js +1 -1
  344. package/src/utils/pddLog.js +92 -0
  345. package/src/utils/pdfUtil.js +71 -0
  346. package/src/utils/request.js +1 -1
  347. package/src/utils/vab.js +1268 -27
  348. package/src/utils/validate.js +1 -1
  349. package/src/utils/wf.js +4 -4
  350. package/src/views/bd/setting/bd_attach_setting/edit.vue +5 -5
  351. package/src/views/bd/setting/bd_attach_setting/list.vue +28 -55
  352. package/src/views/bd/setting/bd_attach_setting/mixins/dialog.js +84 -1
  353. package/src/views/bd/setting/bd_attach_setting/mixins/edit.js +116 -5
  354. package/src/views/bd/setting/bd_attach_setting/mixins/list.js +239 -1
  355. package/src/views/bd/setting/bd_company_env/dialog.vue +174 -0
  356. package/src/views/bd/setting/bd_company_env/edit.vue +193 -0
  357. package/src/views/bd/setting/bd_company_env/list.vue +175 -0
  358. package/src/views/bd/setting/config_manage/list.vue +83 -0
  359. package/src/views/bd/setting/formVersion/button.vue +55 -0
  360. package/src/views/bd/setting/formVersion/compareDialog.vue +287 -0
  361. package/src/views/bd/setting/formVersion/fieldCompare.vue +54 -0
  362. package/src/views/bd/setting/formVersion/ftHistoryDialog.vue +400 -0
  363. package/src/views/bd/setting/formVersion/link.vue +58 -0
  364. package/src/views/bd/setting/formVersion/preformDialog.vue +86 -0
  365. package/src/views/bd/setting/formVersion/reverButton.vue +82 -0
  366. package/src/views/bd/setting/form_import_log/edit.vue +130 -0
  367. package/src/views/bd/setting/form_import_log/list.vue +211 -0
  368. package/src/views/bd/setting/form_script/edit.vue +196 -74
  369. package/src/views/bd/setting/form_script/edit1.vue +410 -187
  370. package/src/views/bd/setting/form_script/form_list.vue +118 -37
  371. package/src/views/bd/setting/form_script/list.vue +90 -21
  372. package/src/views/bd/setting/form_script/list1.vue +200 -118
  373. package/src/views/bd/setting/form_script/mixins/dialog.js +130 -1
  374. package/src/views/bd/setting/form_script/mixins/edit.js +265 -7
  375. package/src/views/bd/setting/form_script/mixins/edit1.js +259 -9
  376. package/src/views/bd/setting/form_script/mixins/form_list.js +322 -14
  377. package/src/views/bd/setting/form_script/mixins/list.js +278 -4
  378. package/src/views/bd/setting/form_script/mixins/list1.js +480 -14
  379. package/src/views/bd/setting/form_script/mixins/list2.js +10 -1
  380. package/src/views/bd/setting/form_script/mixins/otherAuthDialog.js +194 -0
  381. package/src/views/bd/setting/form_script/mixins/preformDialog.js +34 -1
  382. package/src/views/bd/setting/form_script/otherAuthDialog.vue +83 -0
  383. package/src/views/bd/setting/form_template/batchWfObjConfigDialog.vue +2 -2
  384. package/src/views/bd/setting/form_template/edit.vue +355 -184
  385. package/src/views/bd/setting/form_template/editWfObjConfigDialog.vue +2 -2
  386. package/src/views/bd/setting/form_template/formDesignerDialog.vue +171 -0
  387. package/src/views/bd/setting/form_template/list.vue +296 -214
  388. package/src/views/bd/setting/form_template/mixins/batchWfObjConfigDialog.js +11 -9
  389. package/src/views/bd/setting/form_template/mixins/dialog.js +103 -1
  390. package/src/views/bd/setting/form_template/mixins/edit.js +277 -9
  391. package/src/views/bd/setting/form_template/mixins/editWfObjConfigDialog.js +92 -1
  392. package/src/views/bd/setting/form_template/mixins/ftHistoryDialog.js +91 -1
  393. package/src/views/bd/setting/form_template/mixins/itemEdit.js +104 -1
  394. package/src/views/bd/setting/form_template/mixins/itemList.js +234 -1
  395. package/src/views/bd/setting/form_template/mixins/list.js +672 -22
  396. package/src/views/bd/setting/form_template/mixins/list2.js +411 -0
  397. package/src/views/bd/setting/form_template/mixins/otherAuthDialog.js +193 -0
  398. package/src/views/bd/setting/form_template/mixins/preformDialog.js +28 -3
  399. package/src/views/bd/setting/form_template/mixins/wf_list.js +3 -7
  400. package/src/views/bd/setting/form_template/otherAuthDialog.vue +83 -0
  401. package/src/views/bd/setting/form_template/wfObjConfigDialog.vue +4 -4
  402. package/src/views/bd/setting/form_template/wf_list.vue +161 -127
  403. package/src/views/bd/setting/logic_param/edit.vue +146 -0
  404. package/src/views/bd/setting/logic_param/edit1.vue +106 -0
  405. package/src/views/bd/setting/logic_param/edit2.vue +139 -0
  406. package/src/views/bd/setting/logic_param/list.vue +74 -0
  407. package/src/views/bd/setting/logic_param/list1.vue +12 -0
  408. package/src/views/bd/setting/logic_param/list2.vue +12 -0
  409. package/src/views/bd/setting/logic_param/mixins/edit.js +93 -0
  410. package/src/views/bd/setting/logic_param/mixins/list.js +376 -0
  411. package/src/views/bd/setting/menu_kind/list.vue +172 -83
  412. package/src/views/bd/setting/menu_kind/mixins/authDialog.js +300 -7
  413. package/src/views/bd/setting/menu_kind/mixins/dialog.js +139 -1
  414. package/src/views/bd/setting/menu_kind/mixins/list.js +201 -1
  415. package/src/views/bd/setting/push_data/edit.vue +139 -0
  416. package/src/views/bd/setting/push_data/list.vue +283 -0
  417. package/src/views/bd/setting/push_data_h/edit.vue +153 -0
  418. package/src/views/bd/setting/push_data_h/list.vue +293 -0
  419. package/src/views/bd/setting/request_async_setting/edit.vue +320 -0
  420. package/src/views/bd/setting/request_async_setting/list.vue +372 -0
  421. package/src/views/bd/setting/request_setting/edit.vue +300 -0
  422. package/src/views/bd/setting/request_setting/list.vue +311 -0
  423. package/src/views/bd/setting/table_model/edit.vue +1073 -426
  424. package/src/views/bd/setting/table_model/list.vue +213 -128
  425. package/src/views/bd/setting/table_model/mixins/dialog.js +71 -1
  426. package/src/views/bd/setting/table_model/mixins/edit.js +1284 -13
  427. package/src/views/bd/setting/table_model/mixins/list.js +441 -14
  428. package/src/views/bd/setting/table_model/mixins/otherAuthDialog.js +201 -0
  429. package/src/views/bd/setting/table_model/mixins/zdDialog.js +108 -1
  430. package/src/views/bd/setting/table_model/otherAuthDialog.vue +83 -0
  431. package/src/views/bd/setting/utils/index.js +60 -1
  432. package/src/views/user/access_log/list.vue +418 -349
  433. package/src/views/user/area/dialog.vue +223 -117
  434. package/src/views/user/area/list.vue +318 -0
  435. package/src/views/user/bill_setting/edit.vue +1 -1
  436. package/src/views/user/bill_setting/list.vue +1 -1
  437. package/src/views/user/common_attribute/itemEdit.vue +2 -2
  438. package/src/views/user/common_attribute/list.vue +5 -2
  439. package/src/views/user/common_script/edit.vue +1 -1
  440. package/src/views/user/common_script/list.vue +1 -1
  441. package/src/views/user/company_info/dialog.vue +195 -163
  442. package/src/views/user/company_info/edit.vue +1 -1
  443. package/src/views/user/extend_datasource/dialog.vue +3 -0
  444. package/src/views/user/extend_datasource/edit.vue +2 -1
  445. package/src/views/user/extend_datasource/list.vue +3 -0
  446. package/src/views/user/fieldTranslation/editDialog.vue +8 -8
  447. package/src/views/user/fieldTranslation/list.vue +33 -33
  448. package/src/views/user/form/vform/designer.vue +790 -749
  449. package/src/views/user/form/vform/out_render.vue +1 -1
  450. package/src/views/user/form/vform/render.vue +67 -37
  451. package/src/views/user/form/view/edit.vue +38 -37
  452. package/src/views/user/form/view/list.vue +270 -49
  453. package/src/views/user/home/default.vue +1026 -979
  454. package/src/views/user/home/dev.vue +29 -0
  455. package/src/views/user/home/index.vue +18 -7
  456. package/src/views/user/login/default.vue +165 -36
  457. package/src/views/user/login/index.vue +4 -6
  458. package/src/views/user/login/indexMixin.js +186 -9
  459. package/src/views/user/menu/list.vue +27 -1
  460. package/src/views/user/notify_message/dialog.vue +44 -22
  461. package/src/views/user/notify_template/edit.vue +188 -187
  462. package/src/views/user/notify_template/edit2.vue +176 -0
  463. package/src/views/user/notify_template/list.vue +4 -1
  464. package/src/views/user/notify_template/list2.vue +190 -0
  465. package/src/views/user/outLink/form_view.vue +211 -211
  466. package/src/views/user/outLink/index.vue +67 -11
  467. package/src/views/user/position/list.vue +4 -4
  468. package/src/views/user/project_tag/dialog.vue +9 -4
  469. package/src/views/user/project_tag/edit.vue +2 -2
  470. package/src/views/user/project_tag/list.vue +9 -4
  471. package/src/views/user/push_setting/list.vue +2 -2
  472. package/src/views/user/request_setting/edit.vue +258 -0
  473. package/src/views/user/request_setting/list.vue +248 -0
  474. package/src/views/user/role/authConfig.vue +89 -0
  475. package/src/views/user/role/dialog.vue +70 -48
  476. package/src/views/user/role/edit.vue +609 -429
  477. package/src/views/user/role/list.vue +4 -4
  478. package/src/views/user/sale_org/dialog.vue +1 -1
  479. package/src/views/user/sale_org/list.vue +4 -1
  480. package/src/views/user/system_notice/infoDialog.vue +2 -1
  481. package/src/views/user/user/dialog.vue +46 -23
  482. package/src/views/user/user/edit.vue +1338 -1021
  483. package/src/views/user/user/form_dialog.vue +158 -0
  484. package/src/views/user/user/form_info.vue +210 -0
  485. package/src/views/user/user/info.vue +253 -140
  486. package/src/views/user/user/list.vue +652 -563
  487. package/src/views/user/user/modifyPasswordDialog.vue +64 -53
  488. package/src/views/user/wf/wfReport/index.vue +619 -0
  489. package/src/views/user/wf/wf_auto_submit_data/list.vue +2 -0
  490. package/src/views/user/wf/wf_manage/list.vue +379 -250
  491. package/src/views/user/wf/wf_manage/wfContentDialog.vue +25 -22
  492. package/src/views/user/wf/wf_obj_config/importItemDialog.vue +109 -0
  493. package/src/views/user/wf/wf_obj_config/itemEdit.vue +25 -1
  494. package/src/views/user/wf/wf_obj_config/list.vue +114 -9
  495. package/src/views/user/wf/wf_obj_config/wfBizDataSettingDialog.vue +2 -2
  496. package/src/views/user/wf/wf_transfer_setting/edit.vue +282 -0
  497. package/src/views/user/wf/wf_transfer_setting/list.vue +319 -0
  498. package/src/views/user/workbench_menu/list.vue +555 -0
  499. package/src/utils/renderUtils.js +0 -76
@@ -1,1685 +1,3326 @@
1
- import emitter from '../../../../components/xform/utils/emitter';
2
- import i18n from '../../../../components/xform/utils/i18n';
3
- import refMixin from '../../../../components/xform/form-render/refMixin';
4
- import containerItemMixin from './containerItemMixin';
5
-
6
- import * as formatUtil from '../../../../components/xform/utils/format.js';
7
- import tableConfig from '../../../../components/table/config.js';
8
- import {extendDeeply} from "../../../../utils/index.js";
9
- import {
10
- assembleAxiosConfig,
11
- getReportGlobalMap,
12
- generateId
13
- } from '../../../../components/xform/utils/util';
14
- import {tableTreeMixins} from '../../../../mixins/tableTree/index.js';
15
-
16
- let modules = {};
17
- const baseRefUtil = {
18
- emitter,
19
- i18n,
20
- refMixin,
21
- containerItemMixin,
22
- formatUtil,
23
- assembleAxiosConfig,
24
- tableConfig,
25
- getReportGlobalMap
26
- };
27
-
28
- modules = {
29
- mixins: [baseRefUtil.emitter, baseRefUtil.i18n, baseRefUtil.refMixin, baseRefUtil.containerItemMixin, tableTreeMixins],
30
- componentName: 'ContainerItem',
31
- props: {
32
- widget: Object,
33
- parentWidget: Object,
34
- parentList: Array,
35
- indexOfParentList: Number,
36
- subFormRowIndex: {
37
- type: Number,
38
- default: -1
39
- },
40
- subFormColIndex: {
41
- type: Number,
42
- default: -1
43
- },
44
- subFormRowId: {
45
- type: String,
46
- default: ''
47
- }
48
- },
49
- inject: ['refList', 'sfRefList', 'globalModel', 'getFormConfig', 'getGlobalDsv', 'previewState'],
50
- data: function () {
51
- let that = this;
52
- return {
53
- fieldModel: [],
54
- selectedIndices: [],
55
- pageSize: this.widget.options.pagination.pageSize,
56
- pageSizes: this.widget.options.pagination.pageSizes,
57
- currentPage: this.widget.options.pagination.currentPage,
58
- total: this.widget.options.pagination.total,
59
- formData: {
60
- saleOrgName: '',
61
- loginAccount: '',
62
- mobile: '',
63
- enabled: 1
64
- },
65
- vxeOption: {},
66
- requestAccess: null,
67
- columnFormatMap: {
68
- editInput: 'input',
69
- editNumber: 'number',
70
- editDate: 'date',
71
- editSelect: 'select',
72
- editSearch: 'vabsearch',
73
- editAttachment: 'baseAttachment',
74
- editStatus: 'status',
75
- aText: 'a-text',
76
- aLink: 'a-link',
77
- editDelete: 'a-link',
78
- editButton: 'a-link',
79
- button: 'button',
80
- addSiblingEditRow: 'a-link',
81
- addChildTreeRow: 'a-link',
82
- moveUpRow: 'a-link',
83
- moveDownRow: 'a-link',
84
- removeTreeRow: 'a-link'
85
- },
86
- dataTableConfig: {},
87
- widgets: [],
88
- editWidgets: [],
89
-
90
- sortParentRow: null,
91
- sortRows: [],
92
- showTreeMoveDialog: false,
93
- tableConfig: {}
94
- };
95
- },
96
- watch: {
97
- fieldModel(val) {
98
- this.formModel[this.fieldKeyName] = val || [];
99
- }
100
- },
101
- computed: {
102
- hasWf() {
103
- return this.getFormRef().hasWf || false;
104
- },
105
- tableDatas: {
106
- cache: !1,
107
- get: function () {
108
- return this.globalModel.formModel[this.fieldKeyName] || [];
109
- }
110
- },
111
- formConfig: function () {
112
- return this.getFormConfig();
113
- },
114
- paginationLayout: function () {
115
- return this.widget.options.smallPagination ? 'prev, pager, next' : 'total, sizes, prev, pager, next, jumper';
116
- },
117
- customClass: function () {
118
- return this.widget.options.customClass || '';
119
- },
120
- singleRowSelectFlag: function () {
121
- return !this.widget.options.showCheckBox;
122
- },
123
- buttonsColumnFixed: function () {
124
- return void 0 === this.widget.options.buttonsColumnFixed ? 'right' : !!this.widget.options
125
- .buttonsColumnFixed && this.widget.options.buttonsColumnFixed;
126
- },
127
- formModel: {
128
- cache: !1,
129
- get: function () {
130
- return this.globalModel.formModel;
131
- }
132
- },
133
- formDataId() {
134
- let formRef = this.getFormRef();
135
- return formRef.dataId;
136
- }
137
- },
138
- created: function () {
139
- if (!this.formModel[this.fieldKeyName]) this.formModel[this.fieldKeyName] = [];
140
- this.initRefList();
141
- this.handleOnCreated();
142
- },
143
- mounted: async function () {
144
- this.handleOnMounted();
145
- this.initTableList();
146
- },
147
- beforeDestroy: function () {
148
- this.unregisterFromRefList();
149
- },
150
- methods: {
151
- getGridTableName() {
152
- let formCode = this.getFormRef().reportTemplate.formCode;
153
- let tableName = formCode + "_" + this.widget.options.name;
154
- return tableName;
155
- },
156
- updateFormField: function () {
157
- let rows = this.fieldModel || [];
158
- let formRows = this.formModel[this.fieldKeyName];
159
- if (formRows) {
160
- this.formModel[this.fieldKeyName].splice(0, formRows.length);
161
- this.formModel[this.fieldKeyName].push(...rows);
162
- } else {
163
- this.formModel[this.fieldKeyName] = rows;
164
- }
165
- },
166
- setValue(val) {
167
- // console.log("rows:",val);
168
- let rows = val || []
169
- this.formModel[this.fieldKeyName] = rows;
170
- let $grid = this.getGridTable();
171
- this.fieldModel = rows;
172
- // $grid.loadData(rows);
173
- },
174
- getValue() {
175
- return this.formModel[this.fieldKeyName];
176
- },
177
- getFieldKeyName(widget) {
178
- let o = widget.options.name;
179
- return (
180
- (widget.options.keyNameEnabled
181
- && widget.options.keyName)
182
- || o
183
- );
184
- },
185
- selectWidget: function (e) {
186
- this.designer.setSelected(e);
187
- },
188
- formatterValue: function ({cellValue, row, column}) {
189
- if (cellValue === null || cellValue === undefined) return cellValue;
190
-
191
- if (column.params && column.params.formatS)
192
- switch (column.params.formatS) {
193
- case 'd1':
194
- return baseRefUtil.formatUtil.formatDate1(cellValue);
195
- case 'd2':
196
- return baseRefUtil.formatUtil.formatDate2(cellValue);
197
- case 'd3':
198
- return baseRefUtil.formatUtil.formatDate3(cellValue);
199
- case 'd4':
200
- return baseRefUtil.formatUtil.formatDate4(cellValue);
201
- case 'd5':
202
- return baseRefUtil.formatUtil.formatDate4(cellValue);
203
- case 'n1':
204
- return baseRefUtil.formatUtil.formatNumber1(cellValue);
205
- case 'n2':
206
- return baseRefUtil.formatUtil.formatNumber2(cellValue);
207
- case 'n3':
208
- return baseRefUtil.formatUtil.formatNumber3(cellValue);
209
- case 'n4':
210
- return baseRefUtil.formatUtil.formatNumber4(cellValue);
211
- case 'n5':
212
- return baseRefUtil.formatUtil.formatNumber5(cellValue);
213
- case 'n6':
214
- return baseRefUtil.formatUtil.formatNumber6(cellValue);
215
- case 'n7':
216
- return baseRefUtil.formatUtil.formatNumber7(cellValue);
217
- }
218
- return cellValue;
219
- },
220
- getRowIndex: function (e) {
221
- return this.widget.options.tableData.lastIndexOf(e);
222
- },
223
- setTableColumns: function (e) {
224
- var t = this;
225
- (this.widget.options.tableColumns = e),
226
- this.$nextTick(function () {
227
- t.$refs.dataTable.doLayout();
228
- });
229
- },
230
- setTableColumn: function (e) {
231
- this.setTableColumns(e);
232
- },
233
- getTableData: function () {
234
- return this.widget.options.tableData;
235
- },
236
- resetForm(options) {
237
- let formData = this.formModel;
238
- let ignoreFields = options?.ignoreFields || [];
239
- this.widget.widgetList.forEach(subWidget => {
240
- if (!ignoreFields.length || !ignoreFields.includes(subWidget.options.name)) {
241
- let widgetRef = this.getWidgetRef(subWidget.options.name)
242
- if (widgetRef && widgetRef.setValue) widgetRef.setValue(null);
243
- }
244
- });
245
- },
246
- searchEvent() {
247
- this.getGridTable().commitProxy('reload');
248
- },
249
- async resetEvent(options) {
250
- this.resetForm(options);
251
- this.getGridTable().commitProxy('reload');
252
- },
253
- handleSearchClick() {
254
- if (this.widget.options.onSearchTable) {
255
- this.handleCustomEvent(this.widget.options.onSearchTable);
256
- return
257
- }
258
- this.searchEvent();
259
- },
260
- handleResetClick() {
261
- if (this.widget.options.onResetTable) {
262
- this.handleCustomEvent(this.widget.options.onResetTable);
263
- return
264
- }
265
- this.resetEvent();
266
- },
267
- openEditDialog(row, param) {
268
- let formRef = this.getFormRef();
269
- let parentTarget = formRef.$attrs["parent-target"];
270
- parentTarget && parentTarget.$attrs.openEditDialog && parentTarget.$attrs.openEditDialog(row, param);
271
- },
272
- importExcel() {
273
- },
274
- getGrid(that, tableRef) {
275
- var $grid;
276
- if (Array.isArray(that.$refs[tableRef])) {
277
- $grid = that.$refs[tableRef][0];
278
- } else {
279
- $grid = that.$refs[tableRef];
280
- }
281
- return $grid;
282
- },
283
- getTableCondition: function () {
284
- if (this.widget.options.tableCondition) {
285
- var e = new Function(this.widget.options.tableCondition);
286
- return e.call(this);
287
- }
288
- },
289
- getSearchCondition: function () {
290
- let extraAccessData = this.extraAccessData || {};
291
- let searchFormData = this.getSearchFormData();
292
- let defaultData = {};
293
-
294
- // let globalReqData = baseRefUtil.getReportGlobalMap();//全局请求参数
295
- let tableCondition = this.getTableCondition();
296
- let conditions = {
297
- ...defaultData,
298
- ...tableCondition,
299
- ...searchFormData,
300
- ...extraAccessData,
301
- // ...globalReqData
302
- };
303
- return conditions;
304
- },
305
- createColumns() {
306
- let tableColumns = this.widget.options.tableColumns;
307
- let newColumns = [];
308
- newColumns.push({
309
- type: 'checkbox',
310
- width: 48,
311
- resizable: false,
312
- fixed: 'left'
313
- });
314
-
315
- const createColumn = (t, isChild) => {
316
- let col = {
317
- fixed: !!t.fixed && t.fixed,
318
- field: t.prop,
319
- title: this.getI18nLabel(t.label),
320
- sortable: t.sortable,
321
- align: t.align ? t.align : 'center',
322
- formatter: this.formatterValue,
323
- params: {
324
- formatS: t.formatS,
325
- columnId: t.columnId,
326
- exportType: t.exportType
327
- },
328
- visible: t.show,
329
- slots: {}
330
- };
331
- if (t.treeNode) {
332
- col.treeNode = true;
333
- }
334
- if (t.children && t.children.length) {
335
- col.align = 'center';
336
- delete col.field
337
- let childColumns = t.children.map(child => {
338
- return createColumn(child, true);
339
- });
340
- col.children = childColumns;
341
-
342
- col.sortable = false;
343
- col.filterType = false;
344
- } else {
345
- col.width = t.width;
346
- if (isChild) {
347
- if (col.title && col.field) {
348
- col.filters = [
349
- {
350
- data: {},
351
- },
352
- ];
353
- col.filterRender = {
354
- name: "FilterContent",
355
- };
356
- }
357
- }
358
- }
359
- col = addColumProperty(col, t)
360
- return col;
361
- };
362
-
363
- const addColumProperty = (col, t) => {
364
- let columnOption;
365
- let widget;
366
- let columnWidgetConfig = this.getColumnWidgetConfig(t);
367
- let {columnSelectedWidget, columnEditFields} = columnWidgetConfig;
368
- if (columnSelectedWidget) {
369
- widget = columnSelectedWidget
370
- columnOption = widget.options;
371
- } else {
372
- columnOption = {};
373
- }
374
-
375
- let {columnSelectedWidget: editWidget} = this.getColumnWidgetConfig(t, true);
376
-
377
- let params = {
378
- ...columnOption,
379
- widget: widget,
380
- formatS: t.formatS,
381
- required: t.required || false,
382
- columnConfig: t,
383
- editWidget
384
- }
385
- Object.assign(col.params, params);
386
- if (!col.children || !col.children.length) {
387
- if (t.formatS == 'render') {
388
- let r = t.render ? new Function('params', 'h', t.render) : null;
389
- col.slots.default = (params, h) => {
390
- return r ? r.call(this, params, h) : '';
391
- };
392
- } else if (columnSelectedWidget) {
393
- // col.slots.default = columnSelectedWidget.id;
394
- col.slots.default = "widget";
395
- } else if (t.formatS == 'editTreeButtonGroup') {
396
- col.slots.default = 'editTreeButtonGroup';
397
- }
398
-
399
- if (editWidget) {
400
- col.editRender = {name: 'input'};
401
- // col.slots.edit = editWidget.id;
402
- col.slots.edit = "editWidget"
403
- }
404
- }
405
- if (t.tableColumnConfig) {
406
- let tableColumnConfig = this.handleCustomEvent(t.tableColumnConfig) || {};
407
- col = extendDeeply(col, tableColumnConfig);
408
- }
409
- return col
410
- }
411
-
412
- let formRef = this.getFormRef();
413
- tableColumns.forEach(t => {
414
- let col = createColumn(t);
415
- newColumns.push(col);
416
- });
417
-
418
- if (baseRefUtil.tableConfig && baseRefUtil.tableConfig.className == "list-table") {
419
- if (tableColumns.length) {
420
- let tableColumn = [tableColumns.length - 1];
421
- if (tableColumn.fixed != "right") {
422
- newColumns.push({
423
- width: 47,
424
- title: '',
425
- fixed: 'right',
426
- sortable: false,
427
- });
428
- }
429
- }
430
- }
431
- return this.$baseLodash.cloneDeep(newColumns);
432
- },
433
- initTableList() {
434
- let that = this;
435
- let path = null;
436
- let paramFun = null;
437
- // let mainDataSetDTO = null;
438
- let requestAccess = this.requestAccess;
439
- let tableRef = this.getTableRef();
440
- let formDataModel = this.getFormRef().formDataModel;
441
- let isQueryTable = this.widget.options.isQueryTable || false;
442
- let isDataPage = this.widget.options.accessReturnType == "2";
443
- let reportTemplate = this.getFormRef().reportTemplate;
444
- let formCode = reportTemplate.formCode;
445
- let dataId = this.formDataId;
446
- let accessScript = this.widget.options.accessScript;
447
- let searchColumns = null;
448
- if (isQueryTable) {
449
- path = "#";
450
- paramFun = () => {
451
- let conditions = this.getSearchCondition();
452
- let $grid = this.getGridTable();
453
- if (this.widget.options.showPagination) {
454
- let proxyInfo = $grid.getProxyInfo();
455
- let searchCount = true;
456
- let isQueryAllPage = $grid.isQueryAllPage;
457
- if (isQueryAllPage == false) {
458
- searchCount = false;
459
- }
460
- let pager = proxyInfo ? proxyInfo.pager : null;
461
- if (pager) {
462
- conditions.current = pager.currentPage;
463
- conditions.size = pager.pageSize;
464
- conditions.searchCount = searchCount;
465
- }
466
- }
467
-
468
- /*let formData = {
469
- accessCode: requestAccess.accessCode,
470
- conditions: conditions
471
- };*/
472
- let formData = conditions;
473
- return formData;
474
- };
475
-
476
- searchColumns = [];
477
- let widgetList = this.widget.widgetList;
478
- let typeMap = {
479
- "input": "input",
480
- "number": "number",
481
- "inputBatch": "inputBatch",
482
- "date": "date"
483
- }
484
-
485
- widgetList.forEach(widget => {
486
- if ('container' !== widget.category) {
487
- let options = widget.options;
488
- let type = typeMap[widget.type] || null;
489
- searchColumns.push({
490
- title: this.getI18nLabel(options.label),
491
- field: this.getFieldKeyName(widget),
492
- type: type,
493
- common: true,
494
- disabled: options.disabled,
495
- defaultValueEnabled: !!type,
496
- slot: options.name,
497
- widget: widget,
498
- formItem: false
499
- });
500
- }
501
- });
502
- }
503
-
504
- let formRef = this.getFormRef();
505
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
506
- this.dataTableConfig = dataTableConfig;
507
-
508
- let columns = this.createColumns();
509
- this.widgets = columns.filter(column => !!column?.params?.widget).map(column => column.params.widget);
510
- this.editWidgets = columns.filter(column => !!column?.params?.editWidget).map(column => column.params.editWidget);
511
-
512
- let height = this.widget.options.tableHeight || (isQueryTable ? "auto" : null);
513
- if (!this.widget.options.tableHeight && isQueryTable && this.previewState) {
514
- height = "550px";
515
- }
516
-
517
- let formConfig = this.formConfig;
518
- let scriptCode = this.getScriptCode();
519
-
520
- let otherParam = {}
521
- let attachmentType = this.getAttachmentType();
522
- if (attachmentType.length) {
523
- otherParam.attachmentType = attachmentType;
524
- }
525
- let thirdtabm = this.getThirdtabm();
526
- if (thirdtabm.length) {
527
- otherParam.thirdtabm = thirdtabm;
528
- }
529
-
530
- let pagerConfig = {};
531
- let editDefaultRow, treeNodeParam, treeConfig;
532
- let isTreeTable = this.widget.options.isTreeTable;
533
- if (isTreeTable) {
534
- pagerConfig.pagerClass = "is--hidden"
535
- if (this.widget.options.editDefaultRow) {
536
- editDefaultRow = this.handleCustomEvent(this.widget.options.editDefaultRow);
537
- }
538
- treeNodeParam = row => {
539
- return {
540
- [this.widget.options.parentField]: row.id
541
- };
542
- }
543
- treeConfig = {
544
- lazy: false,
545
- children: "f_children",
546
- hasChild: "f_has_child", // 设置是否有子节点标识
547
- parentField: "f_parent",
548
- transform: true,
549
- expandAll: true,
550
- loadMethod({$table, row}) {
551
- // 模拟后台接口
552
- let $grid = that.getGridTable();
553
- let parentField = $grid.treeConfig.parentField;
554
- return new Promise((resolve, reject) => {
555
- let treeParam = that.widget.options.tableConfig?.treeNodeParam;
556
- let reqPram = {};
557
- if (treeParam) {
558
- reqPram = treeParam(row) || {}
559
- }
560
- Object.assign(reqPram, {
561
- [parentField]: row.id,
562
- });
563
- let accessParam = this.getAccessParam() || {};
564
- let defaultOption = that.getHttpConfigForUser();
565
- that.formHttp({
566
- scriptCode: scriptCode,
567
- data: {
568
- formCode: formCode,
569
- formVersion: reportTemplate.formVersion,
570
- taBm: that.fieldKeyName,
571
- data: {
572
- ...reqPram,
573
- ...otherParam,
574
- ...accessParam
575
- }
576
- },
577
- callback: (res) => {
578
- if (res.type == "success") {
579
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
580
-
581
- let hasChildField = $grid.treeConfig.hasChild;
582
- if (row[hasChildField] && !rows.length) {
583
- row[hasChildField] = false;
584
- }
585
-
586
- resolve(rows);
587
- let treeCallback = that.widget.options.tableConfig?.treeCallback;
588
- if (treeCallback) {
589
- that.$nextTick(() => {
590
- setTimeout(function () {
591
- treeCallback(rows);
592
- }, 0);
593
- });
594
- }
595
- } else {
596
- reject(res);
597
- }
598
- },
599
- });
600
- });
601
- },
602
- };
603
-
604
- }
605
- let editOpts = {};
606
- if (this.widget.options.isEditTable) {
607
- editOpts = {
608
- keepSource: true,
609
- editConfig: {
610
- trigger: "manual",
611
- mode: "row",
612
- showStatus: true,
613
- autoClear: false,
614
- }
615
- }
616
- }
617
- let tableOption = {
618
- // vue: this,
619
- tableRef: tableRef,
620
- tableName: this.getGridTableName(),
621
- param: paramFun,
622
- columns: columns,
623
- searchColumns: searchColumns,
624
- vform: true,
625
- config: {
626
- height: height,
627
- pagerConfig,
628
- treeConfig,
629
- ...editOpts,
630
- ...dataTableConfig.config
631
- },
632
- exportAjax: (param) => {
633
- let $grid = this.getGridTable();
634
- let pageSize = param.size;
635
- let currentPage = param.current;
636
- let page = {pageSize, currentPage};
637
- return $grid.$options.propsData.proxyConfig.ajax.query.call(this, {page, param})
638
- },
639
- // treeNodeUrl,
640
- editDefaultRow,
641
- treeNodeParam
642
- };
643
-
644
- if (isQueryTable) {
645
- /*if(this.widget.options.isTreeTable){
646
- tableOption.config.pagerConfig.autoHidden = false;
647
- }*/
648
- tableOption.path = path;
649
- tableOption.config.proxyConfig = {
650
- props: {
651
- result: isDataPage ? 'objx.records' : 'objx', // 配置响应结果列表字段
652
- total: isDataPage ? 'objx.total' : 'objx.length' // 配置响应结果总页数字段
653
- },
654
- ajax: {
655
- // 接收 Promise 对象
656
- query: ({page, sorts, filters, form, param}) => {
657
-
658
- let formData = tableOption.param ? tableOption.param() || {} : {};
659
- const queryParams = Object.assign({}, formData);
660
-
661
- // 处理排序条件
662
- if (sorts) {
663
- const firstSort = sorts[0];
664
- if (firstSort) {
665
- queryParams.sort = firstSort.property;
666
- queryParams.order = firstSort.order;
667
- }
668
- }
669
-
670
- // 处理筛选条件
671
- if (filters) {
672
- filters.forEach(({property, values}) => {
673
- queryParams[property] = values.join(",");
674
- });
675
- }
676
-
677
- if (page.pageSize !== undefined) {
678
- queryParams["size"] = `${page.pageSize}`;
679
- queryParams["current"] = `${page.currentPage}`;
680
- }
681
-
682
- let $grid = this.getGridTable();
683
- let isQueryAllPage = $grid.isQueryAllPage;
684
- let pathStr1 = "";
685
- if (isQueryAllPage === false) {
686
- queryParams.searchCount = false;
687
- }
688
- Object.assign(queryParams, param)
689
-
690
- var reqPath = typeof path == "function" ? path() : path;
691
- let accessReturnType = this.widget.options.accessReturnType || 2;
692
- let scriptCode = this.getScriptCode();
693
- return new Promise((resolve, reject) => {
694
- let reqData = {
695
- ...queryParams
696
- }
697
- if (scriptCode) {
698
- let index = 0;
699
- let toDo = () => {
700
- // let f = new Function("dataId", "formCode", "param", "done", accessScript);
701
- let done = (res) => {
702
- resolve(res);
703
- if (res.type == "success") {
704
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
705
- if (that.widget.options.isTreeTable) {
706
- if (rows.length > 0) {
707
- let fullAllDataRowMap
708
- = $grid.$refs.xTable.fullAllDataRowMap;
709
- let parentField = $grid.treeConfig.parentField;
710
- let expandAll = $grid.treeConfig.expandAll || false;
711
- let isLazy = $grid.treeConfig.lazy;
712
- let expandIds = rows.filter(item => item[parentField]).map(item => item[parentField])
713
- let expandRows = expandIds.length ? rows.filter(item => expandIds.includes(item.id)) : [];
714
- if (expandAll && expandRows.length) {
715
- that.$nextTick(() => {
716
- setTimeout(function () {
717
- $grid.treeConfig.lazy = false;
718
- $grid.setTreeExpand(expandRows, true);
719
- expandRows.forEach((lineData) => {
720
- if ($grid.$refs.xTable.isTreeExpandByRow(lineData)) {
721
- let rest = fullAllDataRowMap.get(lineData);
722
- rest.treeLoaded = true;
723
- }
724
- });
725
-
726
- $grid.treeConfig.lazy = isLazy;
727
- }, 0);
728
- });
729
- }
730
-
731
- let row = rows.find(item => !item[parentField]);
732
- if (row && (!expandAll || !expandIds.includes(row.id))) {
733
- let hasChild = $grid.treeConfig.hasChild;
734
- if (row[hasChild]) {
735
- that.$nextTick(() => {
736
- setTimeout(function () {
737
- $grid.setTreeExpand(row, true);
738
- }, 0);
739
- });
740
- }
741
- }
742
- }
743
- }
744
- that.$nextTick(() => {
745
- setTimeout(function () {
746
- tableOption.callback && tableOption.callback(rows);
747
- that.handleCustomEvent(that.widget.options.formScriptCallback, ['rows'], [rows])
748
- }, 0);
749
- });
750
- }
751
- }
752
- this.loadDefaultQueryList(reqData, done)
753
- };
754
- let loopHandle = () => {
755
- if (index < 500 && $grid.tableFormStop === true) {
756
- //阻塞列表查询,或者次数达到500时,自动释放
757
- index++
758
- setTimeout(() => {
759
- loopHandle();
760
- }, 10)
761
- } else {
762
- if ($grid.tableFormStop) $grid.tableFormStop = false;
763
- toDo();
764
- }
765
- }
766
- loopHandle();
767
- } else {
768
- resolve();
769
- }
770
- });
771
- }
772
- }
773
- };
774
- tableOption.callback = (rows) => {
775
- // this.fieldModel = rows;
776
- this.formModel[this.fieldKeyName] = rows
777
- }
778
- }
779
-
780
- if (isTreeTable) {
781
- tableOption.filterType = false;
782
- }
783
-
784
- if (this.widget.options.tableConfig) {
785
- let tableConfig = this.handleCustomEvent(this.widget.options.tableConfig) || {};
786
- tableOption = extendDeeply(tableOption, tableConfig);
787
- this.tableConfig = tableConfig;
788
- }
789
- tableOption.vue = this;
790
- this.$vxeTableUtil.initVxeTable(tableOption).then(opts => {
791
- this.vxeOption = opts;
792
- if (!isQueryTable) {
793
- setTimeout(() => {
794
- this.loadAccessData(1);
795
- }, 20);
796
- }
797
- });
798
- },
799
- getSearchFormData() {
800
- let map = {condition: []};
801
- let formData = this.globalModel.formModel;
802
- let widgetList = this.widget.widgetList;
803
- if (!!widgetList && widgetList.length > 0) {
804
- let loop = (wItem) => {
805
- if (wItem.category === 'container') {
806
- loop(wItem);
807
- } else {
808
- let formField = this.getFieldKeyName(wItem);
809
- let vaule = formData[formField];
810
- if (vaule !== null && vaule !== undefined && vaule !== '') {
811
- if (!Array.isArray(vaule) || vaule.length > 0) {
812
- let item = {
813
- "value": vaule,
814
- "field": formField,
815
- "filter": null
816
- };
817
- let wType = wItem.type;
818
- if (["date-range", "time-range"].includes(wType)) {
819
- item.filter = "between"
820
- } else if (["input-batch", "checkbox"].includes(wType) || (wType == "select" && wItem.options.multiple)) {
821
- item.filter = "in"
822
- } else if (["radio", "time", "date"].includes(wType) || (wType == "select" && !wItem.options.multiple)) {
823
- item.filter = "eq"
824
- } else {
825
- item.filter = "like"
826
- }
827
- map.condition.push(item);
828
- }
829
- }
830
- }
831
- };
832
- widgetList.forEach(wItem => {
833
- loop(wItem);
834
- });
835
- }
836
- return map;
837
- },
838
- getUrl() {
839
- let accessUrl = this.widget.options.accessUrl
840
- return accessUrl || (USER_PREFIX + `/form_ins/getFormInsData`);
841
- },
842
- getAttachmentType() {
843
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
844
- let result = vailColumns.filter(item => {
845
- return item.formatS == 'editAttachment'
846
- }).map(item => item.prop);
847
- return result;
848
- },
849
- getThirdtabm() {
850
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
851
- let result = vailColumns.filter(item => {
852
- return item.formatS == "editSearch" && item.columnOption.multipleChoices
853
- }).map(item => item.prop);
854
- return result;
855
- },
856
-
857
- loadDefaultViewList() {
858
- let dataId = this.formDataId;
859
- let reportTemplate = this.getFormRef().reportTemplate;
860
- let formCode = reportTemplate.formCode;
861
- let accessParam = this.getAccessParam() || {};
862
- let otherParam = {}
863
- let attachmentType = this.getAttachmentType();
864
- if (attachmentType.length) {
865
- otherParam.attachmentType = attachmentType;
866
- }
867
- let thirdtabm = this.getThirdtabm();
868
- if (thirdtabm.length) {
869
- otherParam.thirdtabm = thirdtabm;
870
- }
871
- let scriptCode = this.getScriptCode();
872
- return this.formHttp({
873
- /*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
874
- scriptCode: scriptCode,
875
- data: {
876
- formCode: formCode,
877
- formVersion: reportTemplate.formVersion,
878
- taBm: this.fieldKeyName,
879
- data: {
880
- id: dataId,
881
- ...otherParam,
882
- ...accessParam
883
- }
884
- },
885
- callback: res => {
886
- let $grid = this.getGridTable();
887
- let rows = res.objx ? res.objx.records || res.objx || [] : [];
888
- let defaultRow = this.createNewTableData();
889
- rows = rows.map(row => {
890
- return {
891
- ...defaultRow,
892
- ...row
893
- }
894
- });
895
- this.setValue(rows)
896
- this.$nextTick(() => {
897
- /*if (this.widget.options.isTreeTable) {
898
- let $grid = this.getGridTable();
899
- $grid.treeConfig.lazy = false;
900
- $grid.setAllTreeExpand(true);
901
- }*/
902
- this.tableConfig.callback && this.tableConfig.callback(rows);
903
- this.handleCustomEvent(this.widget.options.formScriptCallback, ['rows'], [rows])
904
- this.$forceUpdate();
905
- })
906
- }
907
- });
908
- },
909
- getAccessParam() {
910
- if (!this.widget.options.formScriptParam) return;
911
- return this.handleCustomEvent(this.widget.options.formScriptParam)
912
- },
913
- getScriptCode() {
914
- let accessReturnType = this.widget.options.accessReturnType
915
- let defaultScriptCode = "getList";
916
- if (accessReturnType == 1) {
917
- defaultScriptCode = "getList";
918
- } else if (accessReturnType == 2) {
919
- defaultScriptCode = "getPage";
920
- }
921
- let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
922
- return scriptCode;
923
- },
924
- loadDefaultQueryList(reqData, done) {
925
- let reportTemplate = this.getFormRef().reportTemplate;
926
- let prefix = "/" + reportTemplate.serviceName;
927
- let formCode = reportTemplate.formCode;
928
- let formConfig = this.formConfig;
929
- let accessReturnType = this.widget.options.accessReturnType
930
- let scriptCode = this.getScriptCode();
931
- let accessParam = this.getAccessParam() || {};
932
-
933
- let otherParam = {}
934
- let attachmentType = this.getAttachmentType();
935
- if (attachmentType.length) {
936
- otherParam.attachmentType = attachmentType;
937
- }
938
-
939
- let defaultOption = this.getHttpConfigForUser();
940
-
941
- return this.formHttp({
942
- // url: prefix + "/form_ins/getPage",
943
- scriptCode: scriptCode,
944
- data: {
945
- formCode: formCode,
946
- formVersion: reportTemplate.formVersion,
947
- taBm: this.fieldKeyName,
948
- data: {
949
- ...reqData,
950
- ...otherParam,
951
- ...accessParam
952
- }
953
- },
954
- ...defaultOption,
955
- callback: res => {
956
- done(res);
957
- }
958
- });
959
- },
960
- loadAccessData(flag) {
961
- if (flag === 1) {
962
- let tableConfig = this.tableConfig;
963
- let accessEnabled = tableConfig.accessEnabled ?? true;
964
- if (accessEnabled === false) {
965
- return
966
- }
967
- if ((this.formConfig.isLoadEntity && !this.formDataId)) {
968
- return
969
- }
970
- }
971
-
972
- let scriptCode = this.getScriptCode()
973
- if (scriptCode) {
974
- this.loadDefaultViewList();
975
- }
976
- },
977
- getReqParam(item, dataId, billData) {
978
- let param = {};
979
- if (item.accessParam) {
980
- if (typeof item.accessParam === "string") {
981
- let n = new Function('billData', item.accessParam);
982
- param = n.call(this, billData);
983
- } else {
984
- param = item.accessParam
985
- }
986
- } else {
987
- param = {id: dataId}
988
- }
989
- return param;
990
- },
991
- getTableRef() {
992
- let tableRef = this.widget.id;
993
- return tableRef;
994
- },
995
- exportData(option) {
996
- let tableRef = this.getTableRef();
997
- let serviceName = this.getFormRef().reportTemplate.serviceName;
998
- option.prefix = option.prefix || ('/' + serviceName);
999
- this.$excelExport({targetRef: tableRef, ...option})
1000
- },
1001
- async deleteRow(row, rowIndex) {
1002
- let isTreeTable = this.widget.options.isTreeTable;
1003
- if (isTreeTable) {
1004
- this.removeTreeRow({row})
1005
- return
1006
- }
1007
- let $grid = this.getGridTable();
1008
- $grid.remove(row)
1009
- let tableData = $grid.getTableData();
1010
- let isEditTable = this.widget.options.isEditTable;
1011
- let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
1012
- await this.$nextTick(() => {
1013
- this.formModel[this.fieldKeyName] = fullData
1014
- this.fieldModel = fullData;
1015
- });
1016
- this.$nextTick(() => {
1017
- this.handleWbs();
1018
- });
1019
- },
1020
- createNewTableData(isEdit) {
1021
- let vailColumns = this.widget.options.tableColumns.filter(item => item.prop && item.label);
1022
- let newData = {};
1023
- vailColumns.forEach(item => {
1024
- let formatS = !isEdit ? item.formatS : item.editFormatS;
1025
- let columnOption = !isEdit ? item.columnOption : item.editColumnOption;
1026
- if (formatS == 'editSearch') {
1027
- newData[item.prop] = null;
1028
- let vabSearchName = item?.columnOption?.vabSearchName;
1029
- if (vabSearchName) newData[vabSearchName] = null;
1030
- }
1031
- if (formatS == 'editAttachment') {
1032
- newData[item.prop] = [];
1033
- } else {
1034
- newData[item.prop] = null;
1035
- if (columnOption && columnOption.defaultValue !== undefined && columnOption.defaultValue !== null && columnOption.defaultValue !== '') {
1036
- newData[item.prop] = columnOption.defaultValue;
1037
- }
1038
- }
1039
- });
1040
- return newData;
1041
- },
1042
- addTableData(rows, field) {
1043
- let $grid = this.getGridTable();
1044
- let formDataModel = this.formModel;
1045
- let tableRows = formDataModel[this.fieldKeyName] || [];
1046
- let fullData = $grid.getTableData().fullData;
1047
- let items;
1048
- if (field) {
1049
- let keys = fullData.map(item => {
1050
- return item[field] + "";
1051
- });
1052
- items = rows.filter(item => {
1053
- let value = item[field] + ""
1054
- return !keys.includes(value);
1055
- });
1056
- } else {
1057
- items = rows;
1058
- }
1059
- if (items) {
1060
- if (items.length) {
1061
- items.forEach(row => {
1062
- let newData = this.createNewTableData();
1063
- Object.assign(newData, row);
1064
-
1065
- tableRows.push(newData);
1066
- })
1067
- }
1068
- } else {
1069
- let newData = this.createNewTableData();
1070
- tableRows.push(newData);
1071
- }
1072
- // this.formModel[this.fieldKeyName] = this.$baseLodash(this.fieldModel)
1073
- // this.fieldModel = tableRows
1074
- this.setValue(tableRows)
1075
- this.$nextTick(() => {
1076
- this.handleWbs();
1077
- });
1078
- // $grid.loadData(tableRows);
1079
- },
1080
- getColumnWidgetConfig(row, isEdit) {
1081
- let formatS = isEdit ? row.editFormatS : row.formatS
1082
- let formRef = this.getFormRef();
1083
- let columnSelectedWidget = null;
1084
- let columnEditFields = null;
1085
-
1086
- let type = this.columnFormatMap[formatS];
1087
- /*if (type == 'date') {
1088
- columnEditFields = ['type', 'format', 'valueFormat']
1089
- } else if (type == 'select') {
1090
-
1091
- }
1092
- if (type == 'vabsearch') {
1093
- columnEditFields = ['vabSearchField', 'formCode', 'formVersion', 'required', 'showFormField', 'onSearchConfirm', 'onSearchClear']
1094
- }*/
1095
-
1096
- if (type) {
1097
- columnSelectedWidget = this.$baseLodash.cloneDeep(formRef.getFieldWidgetByType(type));
1098
- let tmpId = generateId();
1099
- let idVal = row.prop ? row.prop : (type + tmpId);
1100
- columnSelectedWidget.id = idVal;
1101
- columnSelectedWidget.options.name = idVal;
1102
-
1103
- let columnOption;
1104
- if (!isEdit) {
1105
- columnOption = row.columnOption;
1106
- } else {
1107
- columnOption = row.editColumnOption;
1108
- }
1109
-
1110
- if (columnOption && Object.keys(columnOption).length) {
1111
- columnOption.required = row.required || false;
1112
- columnSelectedWidget.options = columnOption;
1113
- if ('editDelete' == formatS) {
1114
- columnSelectedWidget.options.hiddenByWf = columnSelectedWidget.options.hiddenByWf ?? true;
1115
- columnSelectedWidget.options.prefixIcon = columnSelectedWidget.options.prefixIcon || "el-icon-delete";
1116
- } else if ('editButton' == formatS) {
1117
- columnSelectedWidget.options.prefixIcon = columnSelectedWidget.options.prefixIcon || "el-icon-edit";
1118
- }
1119
- } else {
1120
- columnSelectedWidget.options.required = row.required || false;
1121
- if ('editDelete' == formatS) {
1122
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1123
- columnSelectedWidget.options.label = "删除";
1124
- columnSelectedWidget.options.labelHidden = true;
1125
- columnSelectedWidget.options.hiddenByWf = true;
1126
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
1127
- } else if ('editButton' == formatS) {
1128
- columnSelectedWidget.options.prefixIcon = "el-icon-edit";
1129
- columnSelectedWidget.options.label = "查看";
1130
- columnSelectedWidget.options.labelHidden = true;
1131
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
1132
- } else if ('addSiblingEditRow' == formatS) {
1133
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1134
- columnSelectedWidget.options.label = "新增兄弟节点";
1135
- columnSelectedWidget.options.labelHidden = false;
1136
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
1137
- } else if ('addChildTreeRow' == formatS) {
1138
- columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1139
- columnSelectedWidget.options.label = "新增子节点";
1140
- columnSelectedWidget.options.labelHidden = false;
1141
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
1142
- } else if ('moveUpRow' == formatS) {
1143
- // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1144
- columnSelectedWidget.options.label = "↑上移";
1145
- columnSelectedWidget.options.labelHidden = false;
1146
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
1147
- } else if ('moveDownRow' == formatS) {
1148
- // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
1149
- columnSelectedWidget.options.label = "↓下移";
1150
- columnSelectedWidget.options.labelHidden = false;
1151
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
1152
- } else if ('removeTreeRow' == formatS) {
1153
- columnSelectedWidget.options.prefixIcon = "el-icon-delete";
1154
- columnSelectedWidget.options.label = "删除";
1155
- columnSelectedWidget.options.labelHidden = true;
1156
- columnSelectedWidget.options.onClick = "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
1157
- }
1158
- columnOption = columnSelectedWidget.options;
1159
- }
1160
- if (columnSelectedWidget.options.hasOwnProperty('keyName')) {
1161
- columnSelectedWidget.options.keyName = row.prop;
1162
- columnSelectedWidget.options.keyNameEnabled = true;
1163
- } else {
1164
- columnSelectedWidget.options.name = row.prop;
1165
- }
1166
- if (type != "button" && type != "a-link") {
1167
- columnSelectedWidget.options.label = row.label;
1168
- columnSelectedWidget.options.labelHidden = true;
1169
- }
1170
- }
1171
- return {columnSelectedWidget, columnEditFields};
1172
- },
1173
- getColumnProp(widget, obj, isEdit) {
1174
- if (!widget) {
1175
- return "false"
1176
- }
1177
- /*if(isEdit){
1178
- return "false"
1179
- }*/
1180
-
1181
- let fieldKeyName = this.getFieldKeyName(widget);
1182
- let rowIndex = Math.max(obj.rowIndex, 0)
1183
- let isQueryTable = this.widget.options.isQueryTable || false;
1184
- if (isEdit || !isQueryTable) {
1185
- let propName = fieldKeyName + '.' + rowIndex + '.' + obj.column.property
1186
- let lineWidget = !isEdit ? obj.column.params.widget : obj.column.params.editWidget;
1187
- if (!lineWidget) {
1188
- return "false";
1189
- }
1190
- if (lineWidget?.type == 'vabsearch') {
1191
- let fieldName = lineWidget.options.vabSearchName || this.getFieldKeyName(lineWidget);
1192
- propName = fieldKeyName + '.' + rowIndex + '.' + fieldName;
1193
- }
1194
-
1195
- return propName;
1196
- } else {
1197
- return "false";
1198
- }
1199
- },
1200
- getColumnWidgetName(e) {
1201
- if (e && e.type) {
1202
- return e.type + '-widget';
1203
- }
1204
- },
1205
- getGridTable() {
1206
- let $grid = this.$refs[this.getTableRef()];
1207
- return $grid;
1208
- },
1209
- getContainerWidgetName: function (e) {
1210
- return 'grid' === e.type ? 'grid-item' : e.type + '-item';
1211
- },
1212
- getWidgetName: function (e) {
1213
- return (e.targetType || e.type) + '-widget';
1214
- },
1215
- handleCheckboxChange(param) {
1216
- if (this.widget.options.onCheckboxChange) {
1217
- let t = new Function("param", this.widget.options.onCheckboxChange);
1218
- t.call(this, param);
1219
- }
1220
- let formRef = this.getFormRef();
1221
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1222
- dataTableConfig.onCheckboxChange && dataTableConfig.onCheckboxChange(param);
1223
- },
1224
- handleCheckboxAll(param) {
1225
- if (this.widget.options.onCheckboxAll) {
1226
- let t = new Function("param", this.widget.options.onCheckboxAll);
1227
- t.call(this, param);
1228
- }
1229
- let formRef = this.getFormRef();
1230
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1231
- dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
1232
- },
1233
- handleCellDblclick(param) {
1234
- if (this.widget.options.onCellDblclick) {
1235
- let t = new Function("param", this.widget.options.onCellDblclick);
1236
- t.call(this, param);
1237
- }
1238
- let formRef = this.getFormRef();
1239
- let dataTableConfig = formRef.$attrs.dataTableOption || {}
1240
- dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
1241
- },
1242
- advancedClear() {
1243
- let formModel = this.formModel;
1244
- this.getFormRef().setFormData(formModel);
1245
- },
1246
- tableFormSettingConfirm() {
1247
- let formModel = this.formModel;
1248
- this.getFormRef().setFormData(formModel);
1249
- },
1250
-
1251
- //editTable begin
1252
- saveEditRow(obj) {
1253
-
1254
- let formRef = this.getFormRef();
1255
- let formConfig = this.formConfig;
1256
- let entity = formConfig.entity;
1257
- if (!entity) return
1258
- let dataId = formRef?.dataId;
1259
- let reportTemplate = formRef?.reportTemplate;
1260
- let formCode = reportTemplate?.formCode;
1261
- let scriptCode = formConfig.saveScriptCode || "saveUpdate"
1262
-
1263
- let that = this;
1264
- let $grid = obj.$table.$xegrid;
1265
- let originOption = $grid.originOption;
1266
-
1267
- let formModel = this.formModel;
1268
- let dataMap = this.getGridTable().getTableData();
1269
-
1270
- formRef.validate(valid => {
1271
- if (valid) {
1272
- $grid.clearActived().then(() => {
1273
- $grid.setActiveRow(obj.row);
1274
- let mainData = commonDataUtil.handleForm(obj.row);
1275
-
1276
- delete mainData._createNickName;
1277
- delete mainData._createMobile;
1278
- delete mainData._modifyNickName;
1279
- delete mainData._modifyMobile;
1280
- delete mainData._createBy;
1281
- delete mainData._modifyBy;
1282
-
1283
- let formData = {
1284
- [entity]: mainData
1285
- };
1286
-
1287
- let reqData = {
1288
- formCode: formCode,
1289
- formVersion: reportTemplate.formVersion,
1290
- taBm: entity,
1291
- data: formData
1292
- };
1293
-
1294
- this.formHttp({
1295
- scriptCode: scriptCode,
1296
- data: reqData,
1297
- successMsg: true,
1298
- isConfirm: true,
1299
- confirmText: "您确定要保存吗?",
1300
- success: res0 => {
1301
- this.getRowData(res0.objx, (res) => {
1302
- if (obj.row.id == res.objx.id) {
1303
- $grid.clearActived().then(() => {
1304
- Object.assign(obj.row, res.objx);
1305
- });
1306
- } else {
1307
- $grid.remove(obj.row);
1308
- $grid.insertAt(res.objx);
1309
- }
1310
- delete obj.$table.editCloneRow
1311
- })
1312
- }
1313
- });
1314
- })
1315
- }
1316
- });
1317
- },
1318
- getRowData(dataId, callback) {
1319
- let reportTemplate = this.getFormRef()?.reportTemplate;
1320
- let formCode = reportTemplate.formCode;
1321
- let formConfig = this.formConfig;
1322
- // let isLoadEntity = formConfig.isLoadEntity;
1323
- let entity = formConfig.entity;
1324
- let scriptCode = formConfig.formScriptCode || "getOne";
1325
- let defaultOption = this.getHttpConfigForUser();
1326
- this.formHttp({
1327
- scriptCode: scriptCode,
1328
- data: {
1329
- formCode: formCode,
1330
- formVersion: reportTemplate.formVersion,
1331
- taBm: entity,
1332
- data: {
1333
- id: dataId
1334
- }
1335
- },
1336
- ...defaultOption,
1337
- success: res => {
1338
- callback && callback(res)
1339
- }
1340
- });
1341
- },
1342
- addChildTreeRow(rowData, obj, toTop) {
1343
- let toEnd = !toTop;
1344
- this.addTreeRow(rowData, obj, toEnd, null)
1345
- },
1346
- addTopTreeRow(rowData, toTop) {
1347
- let toEnd = !toTop;
1348
- this.addTreeRow(rowData, null, toEnd, null)
1349
- },
1350
- addSiblingTreeRow(rowData, obj) {
1351
- this.addTreeRow(rowData, obj, null, true)
1352
- },
1353
- addTreeRow(rowData, obj, toEnd, toSibling) {
1354
- let isEditTable = this.widget.options.isEditTable || false;
1355
- let parent = obj?.row;
1356
- let $grid = this.getGridTable()
1357
- if (isEditTable && this.hasEditingRow($grid, 1)) {
1358
- return false;
1359
- }
1360
- let parentField = $grid.treeConfig.parentField;
1361
- let newRow = {};
1362
- let originOption = $grid.originOption;
1363
- let editDefaultRow;
1364
- if (originOption.editDefaultRow) {
1365
- if (typeof originOption.editDefaultRow == "function") {
1366
- editDefaultRow = originOption.editDefaultRow() || {};
1367
- } else {
1368
- editDefaultRow = originOption.editDefaultRow || {};
1369
- }
1370
- }
1371
- // Object.assign(newRow, editDefaultRow, rowData);
1372
- newRow.id = "row_" + (new Date()).valueOf() + Math.floor(Math.random() * 1000000);
1373
- if (!toSibling) {
1374
- newRow[parentField] = parent?.id || 0;
1375
- } else {
1376
- newRow[parentField] = obj?.row[parentField] || 0;
1377
- }
1378
-
1379
- let newData = this.createNewTableData(isEditTable);
1380
- newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1381
-
1382
- let tableRows = this.formModel[this.fieldKeyName] || [];
1383
- if (!parent) {
1384
- if (toEnd === true) {
1385
- tableRows.push(newRow)
1386
- } else if (toSibling === true) {
1387
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1388
- tableRows.splice(addIndex, 0, newRow)
1389
- } else {
1390
- tableRows.splice(0, 0, newRow)
1391
- }
1392
- this.setValue(tableRows)
1393
- this.$nextTick(() => {
1394
- this.handleWbs();
1395
- if (isEditTable) {
1396
- $grid.setActiveRow(newRow);
1397
- }
1398
- })
1399
-
1400
- // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1401
- } else {
1402
- $grid.setTreeExpand(obj.row, true).then(() => {
1403
- if (toEnd === true) {
1404
- tableRows.push(newRow)
1405
- } else if (toSibling === true) {
1406
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1407
- tableRows.splice(addIndex, 0, newRow)
1408
- } else {
1409
- tableRows.splice(0, 0, newRow)
1410
- }
1411
- this.setValue(tableRows)
1412
- this.$nextTick(() => {
1413
- this.handleWbs();
1414
- $grid.setTreeExpand(obj.row, true).then(() => {
1415
- if (isEditTable) {
1416
- $grid.setActiveRow(newRow);
1417
- }
1418
- });
1419
- })
1420
- });
1421
- }
1422
- },
1423
- removeTreeRow(obj) {
1424
- let row = obj.row;
1425
- let $grid = this.getGridTable()
1426
- let childrenField = $grid.treeConfig.children;
1427
- let tableRows = this.formModel[this.fieldKeyName];
1428
- // let index = tableRows.findIndex(item => item.id === row.id)
1429
- let delIds = [];
1430
- if (row[childrenField]) {
1431
- let loopDo = (item) => {
1432
- if (item.id) delIds.push(item.id);
1433
- item[childrenField] && item[childrenField].forEach(subItem => {
1434
- loopDo(subItem)
1435
- })
1436
- }
1437
- loopDo(row);
1438
- }
1439
- delIds.forEach(id => {
1440
- let index = tableRows.findIndex(item => item.id === id);
1441
- tableRows.splice(index, 1);
1442
- })
1443
- this.$nextTick(() => {
1444
- this.handleWbs();
1445
- });
1446
- },
1447
- addSiblingEditRow(rowData, obj) {
1448
- this.addEditRow(rowData, obj, null, true)
1449
- },
1450
- addEditRow(rowData, obj, toEnd, toSibling) {
1451
- let isEditTable = this.widget.options.isEditTable || false;
1452
- let parent = obj?.row;
1453
- let $grid = this.getGridTable()
1454
- if (isEditTable && this.hasEditingRow($grid, 1)) {
1455
- return false;
1456
- }
1457
- let parentField = $grid.treeConfig.parentField;
1458
- let newRow = {};
1459
- let originOption = $grid.originOption;
1460
- let editDefaultRow;
1461
- if (originOption.editDefaultRow) {
1462
- if (typeof originOption.editDefaultRow == "function") {
1463
- editDefaultRow = originOption.editDefaultRow() || {};
1464
- } else {
1465
- editDefaultRow = originOption.editDefaultRow || {};
1466
- }
1467
- }
1468
- // Object.assign(newRow, editDefaultRow, rowData);
1469
- newRow.id = "row_" + (new Date()).valueOf() + Math.floor(Math.random() * 1000000);
1470
- if (!toSibling) {
1471
- newRow[parentField] = parent?.id || 0;
1472
- } else {
1473
- newRow[parentField] = obj?.row[parentField] || 0;
1474
- }
1475
-
1476
- let newData = this.createNewTableData(isEditTable);
1477
- newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
1478
-
1479
- let tableRows = this.formModel[this.fieldKeyName] || [];
1480
- if (!parent) {
1481
- if (toEnd === true) {
1482
- tableRows.push(newRow)
1483
- } else if (toSibling === true) {
1484
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1485
- tableRows.splice(addIndex, 0, newRow)
1486
- } else {
1487
- tableRows.splice(0, 0, newRow)
1488
- }
1489
- this.setValue(tableRows)
1490
- this.$nextTick(() => {
1491
- this.handleWbs();
1492
- if (isEditTable) {
1493
- $grid.setActiveRow(newRow);
1494
- }
1495
- })
1496
-
1497
- // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
1498
- } else {
1499
- $grid.setTreeExpand(obj.row, true).then(() => {
1500
- if (toEnd === true) {
1501
- tableRows.push(newRow)
1502
- } else if (toSibling === true) {
1503
- let addIndex = tableRows.findIndex(item => item._X_ROW_KEY == obj.row._X_ROW_KEY) + 1;
1504
- tableRows.splice(addIndex, 0, newRow)
1505
- } else {
1506
- tableRows.splice(0, 0, newRow)
1507
- }
1508
- this.setValue(tableRows)
1509
- this.$nextTick(() => {
1510
- this.handleWbs();
1511
- $grid.setTreeExpand(obj.row, true).then(() => {
1512
- if (isEditTable) {
1513
- $grid.setActiveRow(newRow);
1514
- }
1515
- });
1516
- })
1517
- });
1518
- }
1519
- },
1520
- async removeEditRow(obj) {
1521
- this.removeTreeRow(obj)
1522
- },
1523
- //editTable end
1524
- getHttpConfigForUser() {
1525
- let defaultOption = {
1526
- addCreateInfo: true,
1527
- queryCreateInfo: window.$vueRoot.$store.getters.queryCreateInfo || "0"
1528
- };
1529
- return defaultOption;
1530
- },
1531
- handleWbs() {
1532
- if (this.widget.options.wbsEnabled) {
1533
- this.updateWbs();
1534
- }
1535
- },
1536
- updateWbs() {
1537
- let that = this;
1538
- let $grid = that.getGridTable();
1539
- let childrenField = $grid.treeConfig.children;
1540
- let fullData = $grid.getTableData().fullData;
1541
- let tableRows = this.formModel[that.fieldKeyName] || [];
1542
- let map = {}
1543
- let loopDo = (item, wbs) => {
1544
- item.f_wbs = wbs;
1545
- map[item._X_ROW_KEY] = wbs;
1546
- item[childrenField] && item[childrenField].forEach((subitem, subindex) => {
1547
- let sub_wbs = wbs + '.' + (subindex + 1) + '';
1548
- loopDo(subitem, sub_wbs)
1549
- })
1550
- }
1551
- fullData.forEach((item, index) => {
1552
- let wbs = (index + 1) + '';
1553
- loopDo(item, wbs)
1554
- })
1555
- $grid.updateData();
1556
- },
1557
- moveUpRow(obj) {
1558
- let row = obj.row;
1559
- let $grid = this.getGridTable();
1560
- let tableRows = this.formModel[this.fieldKeyName] || [];
1561
- let isTreeTable = this.widget.options.isTreeTable;
1562
- if (isTreeTable) {
1563
- let parentField = $grid.treeConfig.parentField;
1564
- let rowField = $grid.treeConfig.rowField || "id";
1565
- let paretValue = row[parentField];
1566
- let siblingRows = tableRows.filter(item => item[parentField] === paretValue)
1567
- if (siblingRows.length > 1) {
1568
- let currentIndex = tableRows.findIndex(item => item[rowField] == row[rowField]);
1569
- let index1 = siblingRows.findIndex(item => item[rowField] == row[rowField]);
1570
- if (index1 > 0) {
1571
- let prevRow = siblingRows[index1 - 1];
1572
- let prevIndex = tableRows.findIndex(item => item[rowField] == prevRow[rowField]);
1573
- tableRows.splice(currentIndex, 1)
1574
- tableRows.splice(prevIndex, 0, row)
1575
- this.setValue(tableRows);
1576
- this.$nextTick(() => {
1577
- this.handleWbs();
1578
- });
1579
- }
1580
- }
1581
- } else {
1582
- let rowIndex = $grid.getRowIndex(row);
1583
- if (rowIndex >= 0) {
1584
- tableRows.splice(rowIndex, 1)
1585
- tableRows.splice(rowIndex - 1, 0, row)
1586
- this.setValue(tableRows);
1587
- this.$nextTick(() => {
1588
- this.handleWbs();
1589
- });
1590
- }
1591
- }
1592
- },
1593
- moveDownRow(obj) {
1594
- let row = obj.row;
1595
- let $grid = this.getGridTable();
1596
- let tableRows = this.formModel[this.fieldKeyName] || [];
1597
- let isTreeTable = this.widget.options.isTreeTable;
1598
- if (isTreeTable) {
1599
- let parentField = $grid.treeConfig.parentField;
1600
- let rowField = $grid.treeConfig.rowField || "id";
1601
- let paretValue = row[parentField];
1602
- let siblingRows = tableRows.filter(item => item[parentField] === paretValue)
1603
- if (siblingRows.length > 1) {
1604
- let currentIndex = tableRows.findIndex(item => item[rowField] == row[rowField]);
1605
- let index1 = siblingRows.findIndex(item => item[rowField] == row[rowField]);
1606
- if (index1 < siblingRows.length - 1) {
1607
- let nextRow = siblingRows[index1 + 1];
1608
- let nextIndex = tableRows.findIndex(item => item[rowField] == nextRow[rowField]);
1609
- tableRows.splice(currentIndex, 1)
1610
- tableRows.splice(nextIndex, 0, row)
1611
- this.setValue(tableRows);
1612
- this.$nextTick(() => {
1613
- this.handleWbs();
1614
- });
1615
- }
1616
- }
1617
- } else {
1618
- let rowIndex = $grid.getRowIndex(row);
1619
- if (rowIndex < tableRows.length - 1) {
1620
- tableRows.splice(rowIndex, 1)
1621
- tableRows.splice(rowIndex + 1, 0, row)
1622
- this.setValue(tableRows);
1623
- this.$nextTick(() => {
1624
- this.handleWbs();
1625
- });
1626
- }
1627
- }
1628
- },
1629
-
1630
- openSortRowDialog(obj) {
1631
- let $grid = this.getGridTable();
1632
- let parentField = $grid.treeConfig.parentField;
1633
- let rowField = $grid.treeConfig.rowField || "id";
1634
- let row = obj.row;
1635
- let tableRows = this.formModel[this.fieldKeyName] || [];
1636
-
1637
- let sortParentRow = tableRows.find(item => item[rowField] === row[parentField])
1638
- let sortRows = tableRows.filter(item => item[parentField] === row[parentField])
1639
- this.sortRows = sortRows;
1640
- this.sortParentRow = sortParentRow;
1641
- this.showTreeMoveDialog = true;
1642
- },
1643
- confirmTreeMoveDialog(rows) {
1644
- if (this.widget.options.isEditTable) {
1645
- let reportTemplate = this.getFormRef().reportTemplate;
1646
- let formConfig = this.formConfig;
1647
- let entity = formConfig.entity;
1648
- let reqData = {
1649
- formCode: reportTemplate.formCode,
1650
- formVersion: reportTemplate.formVersion,
1651
- taBm: entity,
1652
- data: rows
1653
- };
1654
- let scriptCode = this.widget.options.sortScriptCode;
1655
- this.formHttp({
1656
- scriptCode: scriptCode,
1657
- data: reqData,
1658
- successMsg: true,
1659
- isConfirm: true,
1660
- confirmText: "您确定要保存排序吗?",
1661
- success: res => {
1662
- this.getGridTable().reloadTreeExpand(this.sortParentRow)
1663
- }
1664
- });
1665
- } else {
1666
- let $grid = this.getGridTable();
1667
- let rowField = $grid.treeConfig.rowField || "id";
1668
- let tableRows = this.formModel[this.fieldKeyName] || [];
1669
-
1670
- let ids = rows.map(item => item[rowField]);
1671
- let index = tableRows.findIndex(item => ids.includes(item[rowField]))
1672
- let items = tableRows.filter(item => !ids.includes(item[rowField]));
1673
- rows.forEach((row, index1) => {
1674
- items.splice(index + index1, 0, row);
1675
- })
1676
- this.setValue(items);
1677
- this.$nextTick(() => {
1678
- this.handleWbs();
1679
- })
1680
- }
1681
- }
1682
- }
1683
- };
1684
-
1685
- export default modules;
1
+ import emitter from "../../../../components/xform/utils/emitter";
2
+ import i18n from "../../../../components/xform/utils/i18n";
3
+ import refMixin from "../../../../components/xform/form-render/refMixin";
4
+ import containerItemMixin from "./containerItemMixin";
5
+
6
+ import * as formatUtil from "../../../../components/xform/utils/format.js";
7
+ import tableConfig from "../../../../components/table/config.js";
8
+ import { extendDeeply } from "../../../../utils/index.js";
9
+ import {
10
+ assembleAxiosConfig,
11
+ getReportGlobalMap,
12
+ generateId,
13
+ deepClone,
14
+ loopHandleWidget,
15
+ columnFormatMap,
16
+ traverseAllWidgetsNew,
17
+ } from "../../../../components/xform/utils/util";
18
+ import { tableTreeMixins } from "../../../../mixins/tableTree/index.js";
19
+
20
+ let modules = {};
21
+ const baseRefUtil = {
22
+ emitter,
23
+ i18n,
24
+ refMixin,
25
+ containerItemMixin,
26
+ formatUtil,
27
+ assembleAxiosConfig,
28
+ tableConfig,
29
+ getReportGlobalMap,
30
+ };
31
+
32
+ modules = {
33
+ mixins: [
34
+ baseRefUtil.emitter,
35
+ baseRefUtil.i18n,
36
+ baseRefUtil.refMixin,
37
+ baseRefUtil.containerItemMixin,
38
+ tableTreeMixins,
39
+ ],
40
+ componentName: "ContainerItem",
41
+ props: {
42
+ widget: Object,
43
+ parentWidget: Object,
44
+ parentList: Array,
45
+ indexOfParentList: Number,
46
+ subFormRowIndex: {
47
+ type: Number,
48
+ default: -1,
49
+ },
50
+ subFormColIndex: {
51
+ type: Number,
52
+ default: -1,
53
+ },
54
+ subFormRowId: {
55
+ type: String,
56
+ default: "",
57
+ },
58
+ },
59
+ inject: [
60
+ "refList",
61
+ "sfRefList",
62
+ "globalModel",
63
+ "getFormConfig",
64
+ "getGlobalDsv",
65
+ "previewState",
66
+ ],
67
+ data: function () {
68
+ let that = this;
69
+ return {
70
+ fieldModel: [],
71
+ selectedIndices: [],
72
+ pageSize: this.widget.options.pagination.pageSize,
73
+ pageSizes: this.widget.options.pagination.pageSizes,
74
+ currentPage: this.widget.options.pagination.currentPage,
75
+ total: this.widget.options.pagination.total,
76
+ formData: {
77
+ saleOrgName: "",
78
+ loginAccount: "",
79
+ mobile: "",
80
+ enabled: 1,
81
+ },
82
+ vxeOption: {},
83
+ requestAccess: null,
84
+ /* columnFormatMap: {
85
+ editInput: "input",
86
+ editNumber: "number",
87
+ editDate: "date",
88
+ editSelect: "select",
89
+ editSearch: "vabsearch",
90
+ editAttachment: "baseAttachment",
91
+ editStatus: "status",
92
+ aText: "a-text",
93
+ aLink: "a-link",
94
+ editDelete: "a-link",
95
+ editButton: "a-link",
96
+ button: "button",
97
+ addSiblingEditRow: "a-link",
98
+ addChildTreeRow: "a-link",
99
+ moveUpRow: "a-link",
100
+ moveDownRow: "a-link",
101
+ removeTreeRow: "a-link",
102
+ text: "text",
103
+ checkbox: "checkbox",
104
+ radio: "radio",
105
+ }, */
106
+ dataTableConfig: {},
107
+ widgets: [],
108
+ editWidgets: [],
109
+
110
+ sortParentRow: null,
111
+ sortRows: [],
112
+ showTreeMoveDialog: false,
113
+ tableConfig: {},
114
+ showTableFormDialogContent: true,
115
+ widgetMap: {},
116
+ rowWidgetList: [],
117
+
118
+ rowIdData: [],
119
+ fieldSchemaMap: {},
120
+ fieldSchemaData: [],
121
+ eventConfig: {},
122
+ };
123
+ },
124
+ watch: {
125
+ fieldModel(val) {
126
+ this.formModel[this.fieldKeyName] = val || [];
127
+ },
128
+ },
129
+ computed: {
130
+ hasWf() {
131
+ return this.getFormRef().hasWf || false;
132
+ },
133
+ tableDatas: {
134
+ cache: !1,
135
+ get: function () {
136
+ return this.globalModel.formModel[this.fieldKeyName] || [];
137
+ },
138
+ },
139
+ formConfig: function () {
140
+ return this.getFormConfig();
141
+ },
142
+ paginationLayout: function () {
143
+ return this.widget.options.smallPagination
144
+ ? "prev, pager, next"
145
+ : "total, sizes, prev, pager, next, jumper";
146
+ },
147
+ customClass: function () {
148
+ return this.widget.options.customClass || "";
149
+ },
150
+ singleRowSelectFlag: function () {
151
+ return !this.widget.options.showCheckBox;
152
+ },
153
+ buttonsColumnFixed: function () {
154
+ return void 0 === this.widget.options.buttonsColumnFixed
155
+ ? "right"
156
+ : !!this.widget.options.buttonsColumnFixed &&
157
+ this.widget.options.buttonsColumnFixed;
158
+ },
159
+ formModel: {
160
+ cache: !1,
161
+ get: function () {
162
+ return this.globalModel.formModel;
163
+ },
164
+ },
165
+ formDataId() {
166
+ let formRef = this.getFormRef();
167
+ return formRef.dataId;
168
+ },
169
+ },
170
+ created: function () {
171
+ if (!this.formModel[this.fieldKeyName])
172
+ this.formModel[this.fieldKeyName] = [];
173
+ this.initRefList();
174
+ // this.initConfig();
175
+ this.initTableCustomEvent();
176
+ this.initEventHandler();
177
+ this.registerTableRefList();
178
+ this.handleOnCreated();
179
+ },
180
+ mounted: async function () {
181
+ this.handleOnMounted();
182
+ this.initColumnWidgetConfig(() => {
183
+ this.initTableList();
184
+ });
185
+ },
186
+ beforeDestroy: function () {
187
+ this.unregisterFromRefList();
188
+ },
189
+ methods: {
190
+ initTableCustomEvent() {
191
+ let tableConfig =
192
+ this.handleCustomEvent(this.widget.options.tableConfig) || {};
193
+ this.eventConfig = tableConfig.eventConfig || {};
194
+ },
195
+ getTableColumnStatusWidgetLabelKey(obj) {
196
+ let widget = this.getTableColumnWidget(obj);
197
+ return widget ? this.getOptionItemLabelKey(widget) : null;
198
+ },
199
+ getOptionItemValueKey(widget) {
200
+ return widget.options.valueKey || "value";
201
+ },
202
+ getOptionItemLabelKey(widget) {
203
+ return widget.options.labelKey || "label";
204
+ },
205
+ getTableColumnWidget(obj) {
206
+ let item = this.fieldSchemaMap[obj.row._X_ROW_KEY];
207
+ return item ? item[obj.column.params?.widget.id] : null;
208
+ },
209
+ isShowColumnStatusWidget(obj, item) {
210
+ let widget = this.getTableColumnWidget(obj);
211
+ let valueKey = widget.options.valueKey || "value";
212
+ return (
213
+ obj.row[this.getTableColumnWidgetFieldKeyName(obj)] === item[valueKey]
214
+ );
215
+ },
216
+ getTableColumnWidgetFieldKeyName(obj) {
217
+ let widget = this.getTableColumnWidget(obj);
218
+ return widget ? this.getFieldKeyName(widget) : null;
219
+ },
220
+ initColumnWidgetConfig(callback) {
221
+ let tableColumns = this.widget.options.tableColumns;
222
+ let requests = [];
223
+ this.loodHandleColumns(tableColumns, (row) => {
224
+ requests.push(this.handleColumnWidgetConfig(row.widget));
225
+ requests.push(this.handleColumnWidgetConfig(row.editWidget));
226
+ let widgetList = row.widgetList;
227
+ if (widgetList && widgetList.length) {
228
+ traverseAllWidgetsNew(widgetList, (widget) => {
229
+ requests.push(this.handleColumnWidgetConfig(widget));
230
+ });
231
+ }
232
+ });
233
+ if (requests.length) {
234
+ Promise.all(requests).then(() => {
235
+ callback();
236
+ });
237
+ } else {
238
+ callback();
239
+ }
240
+ },
241
+ fillColumnWidgetOptionItems(widget, rows) {
242
+ let widgetType = widget.type;
243
+ let formScriptEnabledTypes = ["select", "checkbox", "radio"];
244
+ if (formScriptEnabledTypes.includes(widgetType)) {
245
+ widget.options.optionItems = rows || [];
246
+ } else if (widgetType === "status") {
247
+ widget.options.statusParam = rows || [];
248
+ }
249
+ widget._syncInited = true;
250
+ },
251
+ async handleColumnWidgetConfig(widget, callback) {
252
+ if (!widget) return;
253
+ let widgetType = widget.type;
254
+ let formScriptEnabledTypes = ["select", "checkbox", "radio", "status"];
255
+ if (!formScriptEnabledTypes.includes(widgetType)) return;
256
+
257
+ let formScriptEnabled = widget.options.formScriptEnabled || false;
258
+ let commonAttributeEnabled =
259
+ widget.options.commonAttributeEnabled || false;
260
+ let commonAttributeCode = widget.options.commonAttributeCode;
261
+ if (commonAttributeEnabled) {
262
+ if (!commonAttributeCode) return;
263
+ }
264
+
265
+ if (!formScriptEnabled && !commonAttributeEnabled) return;
266
+
267
+ let reportTemplate = this.getFormRef().reportTemplate;
268
+ let formCode = reportTemplate.formCode;
269
+ let scriptCode = widget.options.formScriptCode || "getList";
270
+ let fieldKeyName = this.getFieldKeyName(widget);
271
+
272
+ if (formScriptEnabled) {
273
+ let accessParam = this.handleCustomEvent(
274
+ widget.options.formScriptParam
275
+ );
276
+ return this.formHttp({
277
+ scriptCode: scriptCode,
278
+ data: {
279
+ formCode: formCode,
280
+ formVersion: reportTemplate.formVersion,
281
+ taBm: fieldKeyName,
282
+ data: {
283
+ ...accessParam,
284
+ },
285
+ },
286
+ success: (res) => {
287
+ let rows = res.objx?.records || res.objx || [];
288
+ this.fillColumnWidgetOptionItems(widget, rows);
289
+ },
290
+ });
291
+ } else if (commonAttributeEnabled) {
292
+ let accessParam = this.handleCustomEvent(
293
+ widget.options.formScriptParam
294
+ );
295
+
296
+ return this.$getBaseDicts({
297
+ code: commonAttributeCode,
298
+ data: {
299
+ ...accessParam,
300
+ },
301
+ success: ({ dicts, dictMap }) => {
302
+ this.fillColumnWidgetOptionItems(widget, dicts);
303
+ },
304
+ });
305
+ }
306
+ },
307
+ initConfig() {
308
+ let formRef = this.getFormRef();
309
+ this.widget.options.tableColumns.forEach((row) => {
310
+ let type = columnFormatMap[row.formatS];
311
+ if (type && row.columnOption && !row.widget) {
312
+ let fieldWidget = formRef.copyNewFieldWidget(
313
+ formRef.getFieldWidgetByType(type)
314
+ );
315
+ fieldWidget.options = row.columnOption;
316
+ row.widget = fieldWidget;
317
+ }
318
+ let type2 = columnFormatMap[row.editFormatS];
319
+ if (type2 && row.editColumnOption && !row.editWidget) {
320
+ let fieldWidget = formRef.copyNewFieldWidget(
321
+ formRef.getFieldWidgetByType(type2)
322
+ );
323
+ fieldWidget.options = row.editColumnOption;
324
+ row.editWidget = fieldWidget;
325
+ }
326
+ });
327
+ },
328
+ registerTableRefList() {
329
+ this.sfRefList[this.widget.options.name] = this;
330
+ },
331
+ getRowRefKey(row, name) {
332
+ let keyVal = row._X_ROW_KEY;
333
+ let key = name + "_" + keyVal;
334
+ return key;
335
+ },
336
+ getWidgetByTableRow(index, name) {
337
+ // let target = this.getWidgetRefByTableRow(index, name)
338
+ // let widget = target.field || target.widget;
339
+ // let row = this.getGridTable().getTableData().fullData[index];
340
+ let formRows = this.formModel[this.fieldKeyName];
341
+ let row = formRows[index];
342
+ let widget = this.getWidgetByTableRowData(row, name);
343
+ return widget;
344
+ },
345
+ getWidgetRefByTableRow(index, name) {
346
+ // let row = this.getGridTable().getTableData().fullData[index];
347
+ let formRows = this.formModel[this.fieldKeyName];
348
+ let row = formRows[index];
349
+ return this.getWidgetRefByTableRowData(row, name);
350
+ },
351
+ getWidgetByTableRowData(row, name) {
352
+ let target = this.getWidgetRefByTableRowData(row, name);
353
+ let widget = target.field || target.widget;
354
+ return widget;
355
+ },
356
+ getWidgetRefByTableRowData(row, name) {
357
+ let key = this.getRowRefKey(row, name);
358
+ return this.getWidgetRef(key);
359
+ },
360
+
361
+ getWidgetRefByTableParam(tableParam) {
362
+ let params = tableParam.column.params;
363
+ let name = params.widget.options.name;
364
+ // let key = this.getRowRefKey(tableParam.row, name);
365
+ return this.getWidgetRefByTableRowData(tableParam.row, name);
366
+ // return this.getWidgetRef(key);
367
+ },
368
+ getRowWidget(rowParam, fieldWidget) {
369
+ let row = rowParam.row;
370
+ let params = rowParam.column.params;
371
+ let widgetId = fieldWidget ? fieldWidget.id : params.widget.id;
372
+ let widget = this.fieldSchemaMap[row._X_ROW_KEY][widgetId];
373
+ return widget;
374
+ },
375
+ loopHandleWidgetByName(name, callback) {
376
+ let rows = this.getValue();
377
+ rows.forEach((row, index) => {
378
+ let target = this.getWidgetRefByTableRow(index, name);
379
+ if (target) {
380
+ let widget = target.field || target.widget;
381
+ callback(row, widget, target);
382
+ }
383
+ });
384
+ },
385
+ getRowWidgetOption(rowParam, fieldWidget) {
386
+ let widget = this.getRowWidget(rowParam, fieldWidget);
387
+ let field = widget.category === "container" ? "widget" : "field";
388
+ let option = {
389
+ [field]: widget,
390
+ };
391
+ return option;
392
+ },
393
+ getRowWidgetKey(rowParam, fieldWidget) {
394
+ let widget = this.getRowWidget(rowParam, fieldWidget);
395
+ let key = widget.id;
396
+ return key;
397
+ },
398
+ getGridTableName() {
399
+ let formCode = this.getFormRef().reportTemplate.formCode;
400
+ let tableName = formCode + "_" + this.widget.options.name;
401
+ return tableName;
402
+ },
403
+ updateFormField: function () {
404
+ let rows = this.fieldModel || [];
405
+ let formRows = this.formModel[this.fieldKeyName];
406
+ if (formRows) {
407
+ this.formModel[this.fieldKeyName].splice(0, formRows.length);
408
+ this.formModel[this.fieldKeyName].push(...rows);
409
+ } else {
410
+ this.formModel[this.fieldKeyName] = rows;
411
+ }
412
+ },
413
+ initFieldSchema(val) {
414
+ let rows = val || [];
415
+ // 处理树结构数据排序
416
+ this.formModel[this.fieldKeyName] = rows;
417
+ this.fieldModel = rows;
418
+ this.initRowIdData(true);
419
+ this.initFieldSchemaData();
420
+ },
421
+ initValue(val) {
422
+ // this.clearRowWidgets()
423
+ let rows = val || [];
424
+ // this.handleNullValue(rows);
425
+ rows.forEach((row, index) => {
426
+ row._X_ROW_KEY = "row_" + generateId();
427
+ });
428
+ this.formModel[this.fieldKeyName] = rows;
429
+ this.fieldModel = rows;
430
+ this.initRowIdData(true);
431
+ this.initFieldSchemaData(true);
432
+ },
433
+ handleTreeData(rows) {
434
+ let isTreeTable = this.widget.options.isTreeTable;
435
+ if (isTreeTable) {
436
+ let $grid = this.getGridTable();
437
+ if (!$grid) return;
438
+ let parentField = $grid.treeConfig.parentField;
439
+ if (parentField) {
440
+ // 构建树结构并排序
441
+ let sortedRows = [];
442
+ let nodeMap = new Map();
443
+
444
+ // 第一步:构建节点映射
445
+ rows.forEach((row) => {
446
+ if (row.id !== undefined && row.id !== null) {
447
+ nodeMap.set(row.id, row);
448
+ }
449
+ });
450
+
451
+ // 第二步:按层次排序,先根节点,然后子节点
452
+ rows.forEach((row) => {
453
+ let parentValue = row[parentField];
454
+ // 根节点(parentField为null、undefined、空字符串或0)
455
+ if (
456
+ parentValue === null ||
457
+ parentValue === undefined ||
458
+ parentValue === "" ||
459
+ parentValue === 0
460
+ ) {
461
+ sortedRows.push(row);
462
+ // 递归添加子节点
463
+ this.addChildNodes(row.id, nodeMap, parentField, sortedRows);
464
+ }
465
+ });
466
+
467
+ // 如果没有找到根节点,返回原始数组
468
+ if (sortedRows.length === 0) {
469
+ return rows;
470
+ }
471
+
472
+ return sortedRows;
473
+ }
474
+ }
475
+ return rows;
476
+ },
477
+ addChildNodes(parentId, nodeMap, parentField, sortedRows) {
478
+ // 遍历所有节点,找出当前父节点的子节点
479
+ for (let [id, node] of nodeMap.entries()) {
480
+ // 处理parentField值的类型转换,确保比较正确
481
+ let nodeParentValue = node[parentField];
482
+ let targetParentId = parentId;
483
+
484
+ // 转换为相同类型进行比较
485
+ if (typeof nodeParentValue !== typeof targetParentId) {
486
+ nodeParentValue = String(nodeParentValue);
487
+ targetParentId = String(targetParentId);
488
+ }
489
+
490
+ if (nodeParentValue === targetParentId) {
491
+ sortedRows.push(node);
492
+ // 递归添加子节点的子节点
493
+ this.addChildNodes(id, nodeMap, parentField, sortedRows);
494
+ }
495
+ }
496
+ },
497
+ setValue(val) {
498
+ // console.log("rows:",val);
499
+ this.clearRowWidgets();
500
+ let rows = val || [];
501
+ rows.forEach((row, index) => {
502
+ if (!row._X_ROW_KEY) {
503
+ row._X_ROW_KEY = "row_" + generateId();
504
+ }
505
+ });
506
+ this.formModel[this.fieldKeyName] = rows;
507
+ let $grid = this.getGridTable();
508
+ this.fieldModel = rows;
509
+
510
+ this.initRowIdData();
511
+ this.initFieldSchemaData();
512
+ // $grid.loadData(rows);
513
+ },
514
+ getValue() {
515
+ return this.formModel[this.fieldKeyName];
516
+ },
517
+ getFieldKeyName(widget) {
518
+ let o = widget.options.name;
519
+ return (widget.options.keyNameEnabled && widget.options.keyName) || o;
520
+ },
521
+ selectWidget: function (e) {
522
+ this.designer.setSelected(e);
523
+ },
524
+ getFormatterValue(cellValue, formatS) {
525
+ switch (formatS) {
526
+ case "d1":
527
+ return baseRefUtil.formatUtil.formatDate1(cellValue);
528
+ case "d2":
529
+ return baseRefUtil.formatUtil.formatDate2(cellValue);
530
+ case "d3":
531
+ return baseRefUtil.formatUtil.formatDate3(cellValue);
532
+ case "d4":
533
+ return baseRefUtil.formatUtil.formatDate4(cellValue);
534
+ case "d5":
535
+ return baseRefUtil.formatUtil.formatDate4(cellValue);
536
+ case "n1":
537
+ return baseRefUtil.formatUtil.formatNumber1(cellValue);
538
+ case "n2":
539
+ return baseRefUtil.formatUtil.formatNumber2(cellValue);
540
+ case "n3":
541
+ return baseRefUtil.formatUtil.formatNumber3(cellValue);
542
+ case "n4":
543
+ return baseRefUtil.formatUtil.formatNumber4(cellValue);
544
+ case "n5":
545
+ return baseRefUtil.formatUtil.formatNumber5(cellValue);
546
+ case "n6":
547
+ return baseRefUtil.formatUtil.formatNumber6(cellValue);
548
+ case "n7":
549
+ return baseRefUtil.formatUtil.formatNumber7(cellValue);
550
+ }
551
+ return cellValue;
552
+ },
553
+ formatterValue: function ({ cellValue, row, column }) {
554
+ if (cellValue === null || cellValue === undefined) return cellValue;
555
+
556
+ if (column.params && column.params.formatS) {
557
+ return this.getFormatterValue(cellValue, column.params.formatS);
558
+ }
559
+ return cellValue;
560
+ },
561
+ getRowIndex: function (e) {
562
+ return this.widget.options.tableData.lastIndexOf(e);
563
+ },
564
+ setTableColumns: function (e) {
565
+ let t = this;
566
+ (this.widget.options.tableColumns = e),
567
+ this.$nextTick(function () {
568
+ t.$refs.dataTable.doLayout();
569
+ });
570
+ },
571
+ setTableColumn: function (e) {
572
+ this.setTableColumns(e);
573
+ },
574
+ getTableData: function () {
575
+ return this.widget.options.tableData;
576
+ },
577
+ resetForm(options) {
578
+ let formData = this.formModel;
579
+ let ignoreFields = options?.ignoreFields || [];
580
+ this.widget.widgetList.forEach((subWidget) => {
581
+ if (
582
+ !ignoreFields.length ||
583
+ !ignoreFields.includes(subWidget.options.name)
584
+ ) {
585
+ let widgetRef = this.getWidgetRef(subWidget.options.name);
586
+ if (widgetRef && widgetRef.setValue) widgetRef.setValue(null);
587
+ if (this.isVabsearchFlagWidget(subWidget))
588
+ widgetRef.setShowValue(null);
589
+ }
590
+ });
591
+ },
592
+ searchEvent() {
593
+ this.getGridTable().commitProxy("reload");
594
+ },
595
+ async resetEvent(options) {
596
+ this.resetForm(options);
597
+ this.getGridTable().commitProxy("reload");
598
+ },
599
+ handleSearchClick() {
600
+ if (this.widget.options.onSearchTable) {
601
+ this.handleCustomEvent(this.widget.options.onSearchTable);
602
+ return;
603
+ }
604
+ this.searchEvent();
605
+ },
606
+ handleResetClick() {
607
+ if (this.widget.options.onResetTable) {
608
+ this.handleCustomEvent(this.widget.options.onResetTable);
609
+ return;
610
+ }
611
+ this.resetEvent();
612
+ },
613
+ openEditDialog(row, param, option) {
614
+ let formRef = this.getFormRef();
615
+ let formConfig = this.formConfig;
616
+ let formCode = null;
617
+ if (row?.id) {
618
+ formCode = formConfig.editFormCode;
619
+ } else {
620
+ formCode = formConfig.addFormCode || formConfig.editFormCode;
621
+ }
622
+ let parentTarget = formRef.$attrs["parent-target"];
623
+ parentTarget &&
624
+ parentTarget.$attrs.openEditDialog &&
625
+ parentTarget.$attrs.openEditDialog(row, param, {
626
+ formCode,
627
+ ...option,
628
+ });
629
+ },
630
+ importExcel() {},
631
+ getGrid(that, tableRef) {
632
+ let $grid;
633
+ if (Array.isArray(that.$refs[tableRef])) {
634
+ $grid = that.$refs[tableRef][0];
635
+ } else {
636
+ $grid = that.$refs[tableRef];
637
+ }
638
+ return $grid;
639
+ },
640
+ getTableCondition: function () {
641
+ if (this.widget.options.tableCondition) {
642
+ let e = new Function(this.widget.options.tableCondition);
643
+ return e.call(this);
644
+ }
645
+ },
646
+ getSearchCondition: function () {
647
+ let extraAccessData = this.extraAccessData || {};
648
+ let searchFormData = this.getSearchFormData();
649
+ let defaultData = {};
650
+
651
+ // let globalReqData = baseRefUtil.getReportGlobalMap();//全局请求参数
652
+ let tableCondition = this.getTableCondition();
653
+ let conditions = {
654
+ ...defaultData,
655
+ ...tableCondition,
656
+ ...searchFormData,
657
+ ...extraAccessData,
658
+ // ...globalReqData
659
+ };
660
+ return conditions;
661
+ },
662
+ createColumns() {
663
+ let rowWidgetList = [];
664
+ let tableColumns = this.widget.options.tableColumns;
665
+ let newColumns = [];
666
+ if (!this.widget.options.hideGridCheckBox) {
667
+ newColumns.push({
668
+ type: "checkbox",
669
+ width: 48,
670
+ resizable: false,
671
+ fixed: "left",
672
+ });
673
+ }
674
+
675
+ let tableWidgetName = this.widget.options.name;
676
+ let isEditTable = this.widget.options.isEditTable || false;
677
+ const createColumn = (t, isChild) => {
678
+ let filterable = t.filterable ?? true;
679
+ let filterType = filterable ? null : false;
680
+ let col = {
681
+ fixed: !!t.fixed && t.fixed,
682
+ field: t.prop,
683
+ title: this.getI18nLabel(t.label),
684
+ sortable: t.sortable,
685
+ filterType,
686
+ align: t.align ? t.align : "center",
687
+ formatter: this.formatterValue,
688
+ params: {
689
+ title: this.getI18nLabel(t.label),
690
+ formatS: t.formatS,
691
+ columnId: t.columnId,
692
+ exportType: t.exportType,
693
+ isItemLine: t.isItemLine,
694
+ footerDataType: t.footerDataType,
695
+ footerMethodConfg: t.footerMethodConfg,
696
+ widgetList: t.widgetList,
697
+ tableWidgetName,
698
+ },
699
+ visible: t.show,
700
+ slots: {},
701
+ };
702
+ if (t.required) {
703
+ col.title = col.title;
704
+ /* if(!isEditTable){
705
+ col.titlePrefix = {
706
+ icon: "vxe-cell--required-icon"
707
+ }
708
+ } */
709
+ col.titlePrefix = {
710
+ icon: "vxe-cell--required-icon",
711
+ };
712
+ }
713
+ if (t.treeNode) {
714
+ col.treeNode = true;
715
+ }
716
+ if (t.children && t.children.length) {
717
+ col.align = "center";
718
+ delete col.field;
719
+ let childColumns = t.children.map((child) => {
720
+ return createColumn(child, true);
721
+ });
722
+ col.children = childColumns;
723
+
724
+ col.sortable = false;
725
+ col.filterType = false;
726
+ } else {
727
+ col.width = t.width;
728
+ if (isChild) {
729
+ if (col.title && col.field) {
730
+ if (filterable) {
731
+ col.filters = [
732
+ {
733
+ data: {},
734
+ },
735
+ ];
736
+ col.filterRender = {
737
+ name: "FilterContent",
738
+ };
739
+ }
740
+ }
741
+ }
742
+ }
743
+ col = addColumProperty(col, t);
744
+
745
+ if (col.params.widget) {
746
+ rowWidgetList.push(col.params.widget);
747
+ }
748
+ if (col.params.editWidget) {
749
+ rowWidgetList.push(col.params.editWidget);
750
+ }
751
+ if (col.params.widgetList && col.params.widgetList.length) {
752
+ col.params.widgetList.forEach((item) => {
753
+ rowWidgetList.push(item);
754
+ });
755
+ }
756
+ return col;
757
+ };
758
+
759
+ const addColumProperty = (col, t) => {
760
+ /*let columnOption;
761
+ let widget;
762
+ let columnWidgetConfig = this.getColumnWidgetConfig(t);
763
+ let {columnSelectedWidget, columnEditFields} = columnWidgetConfig;
764
+ if (columnSelectedWidget) {
765
+ widget = columnSelectedWidget;
766
+ columnOption = widget.options;
767
+ } else {
768
+ columnOption = {};
769
+ }
770
+
771
+ let {columnSelectedWidget: editWidget} = this.getColumnWidgetConfig(
772
+ t,
773
+ true
774
+ );*/
775
+
776
+ let widget = t.widget ?? null;
777
+ let editWidget = t.editWidget ?? null;
778
+ let columnOption = {};
779
+ if (widget) {
780
+ columnOption = widget.options;
781
+ }
782
+ let params = {
783
+ ...columnOption,
784
+ widget,
785
+ formatS: t.formatS,
786
+ required: t.required || false,
787
+ columnConfig: t,
788
+ editWidget,
789
+ };
790
+
791
+ Object.assign(col.params, params);
792
+ let types = [
793
+ "input",
794
+ "number",
795
+ "text",
796
+ "select",
797
+ "checkbox",
798
+ "radio",
799
+ "status",
800
+ "vabsearch",
801
+ "date",
802
+ "textarea",
803
+ ];
804
+ if (widget && types.includes(widget.type)) {
805
+ const func = (obj) => {
806
+ let value = obj.row[obj.column.field];
807
+ let fieldWidget = null;
808
+ if (!!obj.column?.params?.widget) {
809
+ fieldWidget = this.getRowWidget(obj);
810
+ }
811
+ if (fieldWidget && !fieldWidget.options.hidden) {
812
+ let widgetType = fieldWidget.type;
813
+ if (["input", "number", "textarea"].includes(widgetType)) {
814
+ return value;
815
+ }
816
+ let widgetRef = this.getWidgetRefByTableParam(obj);
817
+ if ("text" === widgetType) {
818
+ return widgetRef ? widgetRef.showVaule : value;
819
+ } else if ("select" === widgetType) {
820
+ return this.getOptionLabel(fieldWidget, value);
821
+ } else if ("checkbox" === widgetType) {
822
+ return this.getOptionLabel(fieldWidget, value);
823
+ } else if ("radio" === widgetType) {
824
+ return this.getOptionLabel(fieldWidget, value);
825
+ } else if ("status" === widgetType) {
826
+ let statusParam = fieldWidget.options.statusParam || [];
827
+ let statusItem = statusParam.find(
828
+ (item) => item.value === value
829
+ );
830
+ return statusItem ? this.$t1(statusItem.label) : null;
831
+ } else if ("vabsearch" === widgetType) {
832
+ let result = null;
833
+ let currentData = obj.row;
834
+ let fieldKeyName = this.getFieldKeyName(fieldWidget);
835
+ let vabSearchName = fieldWidget.options.vabSearchName;
836
+ let multipleChoices =
837
+ fieldWidget.options.multipleChoices || false;
838
+ let labelField = vabSearchName || fieldKeyName;
839
+ if (!multipleChoices) {
840
+ result = currentData[labelField] ?? null;
841
+ } else {
842
+ if (value) {
843
+ result = value.map((item) => item[labelField]).join(",");
844
+ }
845
+ }
846
+ return result;
847
+ } else if ("date" === widgetType) {
848
+ let dateType = fieldWidget.options.type;
849
+ if (["date", "week"].includes(dateType)) {
850
+ return value ? value.substring(0, 10) : null;
851
+ } else if (dateType === "dates") {
852
+ if (value) {
853
+ if (Array.isArray(value)) {
854
+ return value
855
+ .map((item) => item.substring(0, 10))
856
+ .join(",");
857
+ } else {
858
+ return value;
859
+ }
860
+ }
861
+ return null;
862
+ } else {
863
+ return value;
864
+ }
865
+ }
866
+ } else {
867
+ return null;
868
+ }
869
+ };
870
+ col.slots.filterVal = func;
871
+ }
872
+ if (!col.children || !col.children.length) {
873
+ if (t.formatS === "render") {
874
+ let r = t.render ? new Function("params", "h", t.render) : null;
875
+ col.slots.default = (params, h) => {
876
+ return r ? r.call(this, params, h) : "";
877
+ };
878
+ } else if (widget) {
879
+ // col.slots.default = columnSelectedWidget.id;
880
+ col.slots.default = "widget";
881
+ } else if (t.formatS === "editTreeButtonGroup") {
882
+ col.slots.default = "editTreeButtonGroup";
883
+ } else if (t.formatS === "widgetRender") {
884
+ col.slots.default = "widgetList";
885
+ }
886
+
887
+ if (editWidget) {
888
+ col.editRender = { name: "input" };
889
+ // col.slots.edit = editWidget.id;
890
+ col.slots.edit = "editWidget";
891
+ }
892
+ }
893
+ if (t.tableColumnConfig) {
894
+ let tableColumnConfig =
895
+ this.handleCustomEvent(t.tableColumnConfig) || {};
896
+ col = extendDeeply(col, tableColumnConfig);
897
+ }
898
+ return col;
899
+ };
900
+
901
+ let formRef = this.getFormRef();
902
+ tableColumns.forEach((t) => {
903
+ let col = createColumn(t);
904
+ newColumns.push(col);
905
+ });
906
+
907
+ /* let tableConfig = this.tableConfig;
908
+ let flag = tableConfig?.config?.toolbarConfig?.custom !== false;
909
+ if (
910
+ baseRefUtil.tableConfig &&
911
+ baseRefUtil.tableConfig.className === "list-table" &&
912
+ flag
913
+ ) {
914
+ if (tableColumns.length) {
915
+ let tableColumn = tableColumns[tableColumns.length - 1];
916
+ if (tableColumn.fixed !== "right") {
917
+ newColumns.push({
918
+ width: 47,
919
+ title: "",
920
+ fixed: "right",
921
+ sortable: false,
922
+ });
923
+ }
924
+ }
925
+ } */
926
+ this.rowWidgetList = rowWidgetList;
927
+ return this.$baseLodash.cloneDeep(newColumns);
928
+ },
929
+ //begin
930
+ getOptionLabel(fieldWidget, fieldModel) {
931
+ if (fieldModel === null) {
932
+ return null;
933
+ } else {
934
+ let resultList = [];
935
+ let labelField = fieldWidget.options.labelKey || "label";
936
+ let valueField = fieldWidget.options.valueKey || "value";
937
+ fieldWidget.options.optionItems.forEach((oItem) => {
938
+ if (
939
+ oItem[valueField] === fieldModel ||
940
+ this.findInArray(fieldModel, oItem[valueField]) !== -1
941
+ ) {
942
+ resultList.push(this.$t1(oItem[labelField]));
943
+ }
944
+ });
945
+ return resultList.join(",");
946
+ }
947
+ },
948
+ findInArray: function (e, t) {
949
+ if (!Array.isArray(e)) return -1;
950
+ var i = -1;
951
+ return (
952
+ e.forEach(function (e, n) {
953
+ e === t && (i = n);
954
+ }),
955
+ i
956
+ );
957
+ },
958
+ //end
959
+
960
+ async initTableList() {
961
+ let that = this;
962
+ let tableOption = null;
963
+ let path = null;
964
+ let paramFun = null;
965
+ // let mainDataSetDTO = null;
966
+ let requestAccess = this.requestAccess;
967
+ let tableRef = this.getTableRef();
968
+ let formDataModel = this.getFormRef().formDataModel;
969
+ let isQueryTable = this.widget.options.isQueryTable || false;
970
+ let isDataPage = this.widget.options.accessReturnType === "2";
971
+ let reportTemplate = this.getFormRef().reportTemplate;
972
+ let formCode = reportTemplate.formCode;
973
+ let dataId = this.formDataId;
974
+ let accessScript = this.widget.options.accessScript;
975
+ let searchColumns = null;
976
+
977
+ let isQueryAllPage = !this.widget.options.isNotQueryAllPage;
978
+
979
+ let tableConfig =
980
+ this.handleCustomEvent(this.widget.options.tableConfig) || {};
981
+ this.tableConfig = tableConfig;
982
+
983
+ let tableConfig2 = this.$baseLodash.cloneDeep(tableConfig);
984
+ delete tableConfig2.config;
985
+ delete tableConfig2.eventConfig;
986
+
987
+ if (isQueryTable) {
988
+ path = "#";
989
+ paramFun = () => {
990
+ let conditions = this.getSearchCondition();
991
+ let $grid = this.getGridTable();
992
+ if (this.widget.options.showPagination) {
993
+ let proxyInfo = $grid.getProxyInfo();
994
+ let searchCount = true;
995
+ let isQueryAllPage = $grid.isQueryAllPage;
996
+ if (isQueryAllPage === false) {
997
+ searchCount = false;
998
+ }
999
+ let pager = proxyInfo ? proxyInfo.pager : null;
1000
+ if (pager) {
1001
+ conditions.current = pager.currentPage;
1002
+ conditions.size = pager.pageSize;
1003
+ conditions.searchCount = searchCount;
1004
+ }
1005
+ }
1006
+
1007
+ /*let formData = {
1008
+ accessCode: requestAccess.accessCode,
1009
+ conditions: conditions
1010
+ };*/
1011
+ let formData = conditions;
1012
+ return formData;
1013
+ };
1014
+
1015
+ searchColumns = [];
1016
+ let widgetList = this.widget.widgetList;
1017
+
1018
+ let getDateItem = (widget) => {
1019
+ let options = widget.options;
1020
+
1021
+ let dateConfig = {
1022
+ format: options.format,
1023
+ valueFormat: options.valueFormat ?? null,
1024
+ };
1025
+ let typeMap = {
1026
+ input: { type: "input" },
1027
+ number: { type: "number" },
1028
+ inputBatch: { type: "inputBatch" },
1029
+ date: {
1030
+ type: "date",
1031
+ widgetType: options.type,
1032
+ widgetConfig: dateConfig,
1033
+ },
1034
+ time: {
1035
+ type: "time",
1036
+ widgetConfig: {
1037
+ ...dateConfig,
1038
+ valueFormat: "HH:mm:ss",
1039
+ },
1040
+ },
1041
+ "date-range": {
1042
+ type: "date",
1043
+ widgetType: "daterange",
1044
+ widgetConfig: { ...dateConfig, isRange: true },
1045
+ },
1046
+ "time-range": {
1047
+ type: "time",
1048
+ widgetConfig: {
1049
+ ...dateConfig,
1050
+ isRange: true,
1051
+ valueFormat: "HH:mm:ss",
1052
+ },
1053
+ },
1054
+ };
1055
+ let item = typeMap[widget.type] || {};
1056
+ return item;
1057
+ };
1058
+
1059
+ widgetList.forEach((widget) => {
1060
+ if ("container" !== widget.category) {
1061
+ let options = widget.options;
1062
+ let item = getDateItem(widget);
1063
+ let type = item.type ?? null;
1064
+ // let widgetType = item.widgetType ?? widgetType;
1065
+ // let isRange = item.isRange || false;
1066
+ searchColumns.push({
1067
+ title: this.getI18nLabel(options.label),
1068
+ field: this.getFieldKeyName(widget),
1069
+ // type,
1070
+ // widgetType,
1071
+ // isRange,
1072
+ common: true,
1073
+ disabled: options.disabled,
1074
+ defaultValueEnabled: !!type,
1075
+ slot: options.name,
1076
+ widget: widget,
1077
+ formItem: false,
1078
+ ...item,
1079
+ });
1080
+ }
1081
+ });
1082
+ }
1083
+
1084
+ let formRef = this.getFormRef();
1085
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
1086
+ this.dataTableConfig = dataTableConfig;
1087
+
1088
+ let columns = this.createColumns();
1089
+ this.widgets = columns
1090
+ .filter((column) => !!column?.params?.widget)
1091
+ .map((column) => column.params.widget);
1092
+ this.editWidgets = columns
1093
+ .filter((column) => !!column?.params?.editWidget)
1094
+ .map((column) => column.params.editWidget);
1095
+
1096
+ let height =
1097
+ this.widget.options.tableHeight || (isQueryTable ? "auto" : null);
1098
+ if (
1099
+ !this.widget.options.tableHeight &&
1100
+ isQueryTable &&
1101
+ this.previewState
1102
+ ) {
1103
+ height = "550px";
1104
+ }
1105
+
1106
+ let formConfig = this.formConfig;
1107
+ let scriptCode = this.getScriptCode();
1108
+
1109
+ let otherParam = {};
1110
+ let attachmentType = this.getAttachmentType();
1111
+ if (attachmentType.length) {
1112
+ otherParam.attachmentType = attachmentType;
1113
+ }
1114
+ let thirdtabm = this.getThirdtabm();
1115
+ if (thirdtabm.length) {
1116
+ otherParam.thirdtabm = thirdtabm;
1117
+ }
1118
+
1119
+ let pagerConfig = {};
1120
+ let editDefaultRow, treeNodeParam, treeConfig;
1121
+ let isTreeTable = this.widget.options.isTreeTable;
1122
+ if (isTreeTable) {
1123
+ pagerConfig.pagerClass = "is--hidden";
1124
+ if (this.widget.options.editDefaultRow) {
1125
+ editDefaultRow = this.handleCustomEvent(
1126
+ this.widget.options.editDefaultRow
1127
+ );
1128
+ }
1129
+ treeNodeParam = (row) => {
1130
+ return {
1131
+ [this.widget.options.parentField]: row.id,
1132
+ };
1133
+ };
1134
+ treeConfig = {
1135
+ lazy: false,
1136
+ children: "f_children",
1137
+ hasChild: "f_has_child", // 设置是否有子节点标识
1138
+ parentField: "f_parent",
1139
+ transform: true,
1140
+ expandAll: true,
1141
+ loadMethod: ({ $table, row }) => {
1142
+ // 模拟后台接口
1143
+ let $grid = that.getGridTable();
1144
+ let parentField = $grid.treeConfig.parentField;
1145
+ return new Promise((resolve, reject) => {
1146
+ let treeParam = tableConfig?.treeNodeParam;
1147
+ let reqPram = {};
1148
+ if (treeParam) {
1149
+ reqPram = treeParam(row) || {};
1150
+ }
1151
+ Object.assign(reqPram, {
1152
+ [parentField]: row.id,
1153
+ });
1154
+ let accessParam = that.getAccessParam() || {};
1155
+ let defaultOption = that.getHttpConfigForUser();
1156
+ that.formHttp({
1157
+ scriptCode: scriptCode,
1158
+ data: {
1159
+ formCode: formCode,
1160
+ formVersion: reportTemplate.formVersion,
1161
+ taBm: that.fieldKeyName,
1162
+ data: {
1163
+ ...reqPram,
1164
+ ...otherParam,
1165
+ ...accessParam,
1166
+ },
1167
+ },
1168
+ callback: (res) => {
1169
+ if (res.type === "success") {
1170
+ let items = this.handleTreeData(
1171
+ res.objx?.records || res.objx || []
1172
+ );
1173
+ if (res.objx?.records !== undefined) {
1174
+ res.objx.records = items;
1175
+ } else {
1176
+ res.objx = items;
1177
+ }
1178
+ let rows = res.objx
1179
+ ? res.objx.records || res.objx || []
1180
+ : [];
1181
+ // let rows = res.objx
1182
+ // ? res.objx.records || res.objx || []
1183
+ // : [];
1184
+ // that.handleNullValue(rows);
1185
+ that.initExportFieldSchemaData(rows);
1186
+ /* rows.forEach((row, index) => {
1187
+ if (!row._X_ROW_KEY) {
1188
+ row._X_ROW_KEY = "row_" + generateId();
1189
+ }
1190
+ }); */
1191
+
1192
+ let hasChildField = $grid.treeConfig.hasChild;
1193
+ if (row[hasChildField] && !rows.length) {
1194
+ row[hasChildField] = false;
1195
+ }
1196
+
1197
+ resolve(rows);
1198
+ /* let treeCallback = tableConfig?.treeCallback;
1199
+ if (treeCallback) {
1200
+ that.$nextTick(() => {
1201
+ setTimeout(function () {
1202
+ treeCallback(rows);
1203
+ }, 0);
1204
+ });
1205
+ } */
1206
+ that.$nextTick(() => {
1207
+ setTimeout(function () {
1208
+ dataTableConfig.callback &&
1209
+ dataTableConfig.callback(rows);
1210
+ tableOption.callback && tableOption.callback(rows);
1211
+ tableConfig.treeCallback &&
1212
+ tableConfig.treeCallback(rows);
1213
+ }, 0);
1214
+ });
1215
+ } else {
1216
+ reject(res);
1217
+ }
1218
+ },
1219
+ });
1220
+ });
1221
+ },
1222
+ };
1223
+ }
1224
+ let editOpts = {};
1225
+ if (this.widget.options.isEditTable) {
1226
+ // let editRules = {};
1227
+ this.loodHandleColumns(this.widget.options.tableColumns, (item) => {
1228
+ if (!item.children?.length) {
1229
+ let editWidget = item.editWidget;
1230
+ if (editWidget && editWidget.options.required) {
1231
+ let formField = this.getFieldKeyName(editWidget);
1232
+ /* editRules[formField] = [
1233
+ { required: true, message: `[${editWidget.options.label}]不能为空` }
1234
+ ]; */
1235
+ }
1236
+ }
1237
+ });
1238
+ editOpts = {
1239
+ keepSource: true,
1240
+ editConfig: {
1241
+ trigger: "manual",
1242
+ mode: "row",
1243
+ showStatus: true,
1244
+ autoClear: false,
1245
+ },
1246
+ // editRules
1247
+ };
1248
+ }
1249
+ let showFooter = this.widget.options.showGridFooter || false;
1250
+ let otherConfig = {};
1251
+ if (this.widget.options.hideGridCheckBox) {
1252
+ otherConfig.checkBoxRequired = false;
1253
+ }
1254
+
1255
+ let gridPageSize = this.widget.options.gridPageSize;
1256
+ if (gridPageSize === 1) {
1257
+ gridPageSize = null;
1258
+ }
1259
+ let gridPageSizeList = this.widget.options.gridPageSizeList || [];
1260
+ if (!gridPageSizeList || !gridPageSizeList.length) {
1261
+ pagerConfig.pageSizes = [50, 100, 200, 500];
1262
+ if (!gridPageSize) gridPageSize = 100;
1263
+ pagerConfig.pageSize = gridPageSize;
1264
+ } else {
1265
+ pagerConfig.pageSizes = gridPageSizeList
1266
+ .filter((item) => item.value)
1267
+ .map((item) => item.value);
1268
+ if (!gridPageSize) gridPageSize = pagerConfig.pageSizes[0];
1269
+ pagerConfig.pageSize = gridPageSize;
1270
+ }
1271
+
1272
+ //标题颜色
1273
+ let headerCellStyle = null;
1274
+ let tableColumns = this.widget.options.tableColumns;
1275
+ let colorMap = {};
1276
+ let flag = 0;
1277
+ /* tableColumns.forEach(item=>{
1278
+ if(item.labelColor){
1279
+ flag = 1;
1280
+ colorMap[item.columnId] = item.labelColor
1281
+ }
1282
+ }) */
1283
+
1284
+ this.loodHandleColumns(tableColumns, (item) => {
1285
+ if (item.labelColor) {
1286
+ flag = 1;
1287
+ colorMap[item.columnId] = item.labelColor;
1288
+ }
1289
+ });
1290
+
1291
+ if (flag) {
1292
+ headerCellStyle = (rowParam) => {
1293
+ let columnId = rowParam.column?.params?.columnId;
1294
+ if (columnId) {
1295
+ let color = colorMap[rowParam.column.params.columnId];
1296
+ if (color) {
1297
+ return `color:${color};`;
1298
+ }
1299
+ }
1300
+ };
1301
+ }
1302
+
1303
+ let exportItemConfig = null;
1304
+ if (
1305
+ this.widget.options.exportItemColumns &&
1306
+ this.widget.options.exportItemColumns.length > 0
1307
+ ) {
1308
+ let formatKeys = [
1309
+ "d1",
1310
+ "d2",
1311
+ "d3",
1312
+ "d4",
1313
+ "d5",
1314
+ "n1",
1315
+ "n2",
1316
+ "n3",
1317
+ "n4",
1318
+ "n5",
1319
+ "n6",
1320
+ "n7",
1321
+ ];
1322
+ let exportItemColumns = this.widget.options.exportItemColumns.map(
1323
+ (item) => {
1324
+ let columnSlots = null;
1325
+ let columnParams = {};
1326
+ if (item.formatS === "render") {
1327
+ let r = item.render
1328
+ ? new Function("params", "h", item.render)
1329
+ : null;
1330
+ columnSlots = {
1331
+ default: (params, h) => {
1332
+ return r ? r.call(this, params, h) : "";
1333
+ },
1334
+ };
1335
+ } else if (formatKeys.includes(item.formatS)) {
1336
+ columnSlots = {
1337
+ default: (params, h) => {
1338
+ let cellValue = params.row[params.column.field];
1339
+ return this.getFormatterValue(cellValue, item.formatS);
1340
+ },
1341
+ };
1342
+ }
1343
+ if (item.exportType) {
1344
+ columnParams.exportType = item.exportType;
1345
+ }
1346
+ return {
1347
+ id: item.id,
1348
+ title: item.title,
1349
+ field: item.field,
1350
+ params: columnParams,
1351
+ slots: columnSlots,
1352
+ };
1353
+ }
1354
+ );
1355
+ exportItemConfig = {
1356
+ scriptCode:
1357
+ this.widget.options.exportItemScriptCode ||
1358
+ this.widget.options.formScriptCode,
1359
+ columns: exportItemColumns,
1360
+ param: () => {
1361
+ if (this.widget.options.exportItemParam) {
1362
+ return this.handleCustomParam(
1363
+ this.widget.options.exportItemParam
1364
+ );
1365
+ }
1366
+ },
1367
+ };
1368
+ }
1369
+ let rowConfig = {};
1370
+ if (this.widget.options.tableRowHeight) {
1371
+ rowConfig.height = this.widget.options.tableRowHeight;
1372
+ }
1373
+
1374
+ tableOption = {
1375
+ // vue: this,
1376
+ tableRef: tableRef,
1377
+ tableName: this.getGridTableName(),
1378
+ customAlign: false,
1379
+ param: paramFun,
1380
+ columns: columns,
1381
+ searchColumns: searchColumns,
1382
+ isQueryAllPage,
1383
+ exportItemConfig,
1384
+ vform: true,
1385
+ ...(dataTableConfig.otherConfig || {}),
1386
+ config: {
1387
+ height: height,
1388
+ showFooter,
1389
+ pagerConfig,
1390
+ treeConfig,
1391
+ rowConfig,
1392
+ headerCellStyle,
1393
+ ...editOpts,
1394
+ ...dataTableConfig.config,
1395
+
1396
+ /*rowConfig:{
1397
+ height: 40
1398
+ },*/
1399
+ /*scrollX: {
1400
+ gt: 30,
1401
+ oSize: 10, //<!-- 每次渲染额外10行(缓冲区) -->
1402
+ rSize: 20 //<!-- 每次渲染30行(可视区行数) -->
1403
+ },
1404
+ scrollY: {
1405
+ gt: 100, //<!-- 超过100行启用虚拟滚动 -->
1406
+ oSize: 10, //<!-- 每次渲染额外10行(缓冲区) -->
1407
+ rSize: 30 //<!-- 每次渲染30行(可视区行数) -->
1408
+ }*/
1409
+ },
1410
+ exportAjax: (param, options) => {
1411
+ let $grid = this.getGridTable();
1412
+ let pageSize = param.size;
1413
+ let currentPage = param.current;
1414
+ let page = { pageSize, currentPage };
1415
+ let customParam = {
1416
+ config: {
1417
+ modal: false,
1418
+ },
1419
+ export: true,
1420
+ exportParam: options,
1421
+ };
1422
+ return $grid.$options.propsData.proxyConfig.ajax.query.call(this, {
1423
+ page,
1424
+ param,
1425
+ customParam,
1426
+ });
1427
+ },
1428
+ // treeNodeUrl,
1429
+ editDefaultRow,
1430
+ treeNodeParam,
1431
+ ...otherConfig,
1432
+ // ...tableConfig2
1433
+ };
1434
+
1435
+ if (isQueryTable) {
1436
+ /*if(this.widget.options.isTreeTable){
1437
+ tableOption.config.pagerConfig.autoHidden = false;
1438
+ }*/
1439
+ tableOption.path = path;
1440
+ tableOption.config.proxyConfig = {
1441
+ props: {
1442
+ result: isDataPage ? "objx.records" : "objx", // 配置响应结果列表字段
1443
+ total: isDataPage ? "objx.total" : "objx.length", // 配置响应结果总页数字段
1444
+ },
1445
+ ajax: {
1446
+ // 接收 Promise 对象
1447
+ query: ({ page, sorts, filters, form, param, customParam }) => {
1448
+ let scriptCode = this.getScriptCode();
1449
+ let $grid = this.getGridTable();
1450
+ let originOption = $grid.params.originOption;
1451
+ let formData = {};
1452
+
1453
+ if (customParam?.exportParam?.type !== "exportItem") {
1454
+ //非导出明细
1455
+ formData = tableOption.param ? tableOption.param() || {} : {};
1456
+ }
1457
+ const queryParams = Object.assign({}, formData);
1458
+
1459
+ // 处理排序条件
1460
+ /*if (sorts) {
1461
+ const firstSort = sorts[0];
1462
+ if (firstSort) {
1463
+ queryParams.sort = firstSort.property;
1464
+ queryParams.order = firstSort.order;
1465
+ }
1466
+ }*/
1467
+
1468
+ // 处理筛选条件
1469
+ if (filters) {
1470
+ filters.forEach(({ property, values }) => {
1471
+ queryParams[property] = values.join(",");
1472
+ });
1473
+ }
1474
+
1475
+ if (page.pageSize !== undefined) {
1476
+ queryParams["size"] = page.pageSize;
1477
+ queryParams["current"] = page.currentPage;
1478
+ }
1479
+
1480
+ // let $grid = this.getGridTable();
1481
+ let isQueryAllPage = $grid.isQueryAllPage;
1482
+ let pathStr1 = "";
1483
+ /* if (isQueryAllPage === false) {
1484
+ queryParams.searchCount = false;
1485
+ } */
1486
+ queryParams.searchCount = isQueryAllPage !== false;
1487
+ Object.assign(queryParams, param);
1488
+
1489
+ // let formRef = that.getFormRef();
1490
+ // let dataTableConfig = formRef.$attrs.dataTableOption || {};
1491
+ if (that.dataTableConfig.queryParam) {
1492
+ Object.assign(queryParams, that.dataTableConfig.queryParam);
1493
+ }
1494
+
1495
+ let reqPath = typeof path === "function" ? path() : path;
1496
+ let accessReturnType =
1497
+ this.widget.options.accessReturnType || "2";
1498
+
1499
+ return new Promise((resolve, reject) => {
1500
+ let reqData = {
1501
+ ...queryParams,
1502
+ };
1503
+ if (scriptCode) {
1504
+ let index = 0;
1505
+ let toDo = () => {
1506
+ // let f = new Function("dataId", "formCode", "param", "done", accessScript);
1507
+ let done = (res) => {
1508
+ // this.clearRowWidgets();
1509
+
1510
+ let items = this.handleTreeData(
1511
+ res.objx?.records || res.objx || []
1512
+ );
1513
+ if (res.objx?.records !== undefined) {
1514
+ res.objx.records = items;
1515
+ } else {
1516
+ res.objx = items;
1517
+ }
1518
+ let rows = res.objx
1519
+ ? res.objx.records || res.objx || []
1520
+ : [];
1521
+ // that.handleNullValue(rows);
1522
+ if (customParam?.export) {
1523
+ //导出
1524
+ this.initExportFieldSchemaData(rows);
1525
+ } else {
1526
+ this.initValue(rows);
1527
+ }
1528
+
1529
+ resolve(res);
1530
+ if (res.type === "success") {
1531
+ if (that.widget.options.isTreeTable) {
1532
+ if (rows.length > 0) {
1533
+ let fullAllDataRowMap =
1534
+ $grid.$refs.xTable.fullAllDataRowMap;
1535
+ let parentField = $grid.treeConfig.parentField;
1536
+ let expandAll = $grid.treeConfig.expandAll || false;
1537
+ let isLazy = $grid.treeConfig.lazy;
1538
+ let expandIds = rows
1539
+ .filter((item) => item[parentField])
1540
+ .map((item) => item[parentField]);
1541
+ let expandRows = expandIds.length
1542
+ ? rows.filter((item) =>
1543
+ expandIds.includes(item.id)
1544
+ )
1545
+ : [];
1546
+ if (expandAll && expandRows.length) {
1547
+ that.$nextTick(() => {
1548
+ setTimeout(function () {
1549
+ $grid.treeConfig.lazy = false;
1550
+ $grid.setTreeExpand(expandRows, true);
1551
+ expandRows.forEach((lineData) => {
1552
+ if (
1553
+ $grid.$refs.xTable.isTreeExpandByRow(
1554
+ lineData
1555
+ )
1556
+ ) {
1557
+ let rest =
1558
+ fullAllDataRowMap.get(lineData);
1559
+ rest.treeLoaded = true;
1560
+ }
1561
+ });
1562
+
1563
+ $grid.treeConfig.lazy = isLazy;
1564
+ }, 0);
1565
+ });
1566
+ }
1567
+
1568
+ let row = rows.find((item) => !item[parentField]);
1569
+ if (
1570
+ row &&
1571
+ (!expandAll || !expandIds.includes(row.id))
1572
+ ) {
1573
+ let hasChild = $grid.treeConfig.hasChild;
1574
+ if (row[hasChild]) {
1575
+ that.$nextTick(() => {
1576
+ setTimeout(function () {
1577
+ $grid.setTreeExpand(row, true);
1578
+ }, 0);
1579
+ });
1580
+ }
1581
+ }
1582
+ }
1583
+ }
1584
+ that.$nextTick(() => {
1585
+ setTimeout(function () {
1586
+ dataTableConfig.callback &&
1587
+ dataTableConfig.callback(rows);
1588
+ tableOption.callback && tableOption.callback(rows);
1589
+ that.handleCustomEvent(
1590
+ that.widget.options.formScriptCallback,
1591
+ ["rows"],
1592
+ [rows]
1593
+ );
1594
+ }, 0);
1595
+ });
1596
+ }
1597
+ };
1598
+ this.loadDefaultQueryList(reqData, done, customParam);
1599
+ };
1600
+ let loopHandle = () => {
1601
+ if (index < 500 && $grid.tableFormStop === true) {
1602
+ //阻塞列表查询,或者次数达到500时,自动释放
1603
+ index++;
1604
+ setTimeout(() => {
1605
+ loopHandle();
1606
+ }, 10);
1607
+ } else {
1608
+ if ($grid.tableFormStop) $grid.tableFormStop = false;
1609
+ toDo();
1610
+ }
1611
+ };
1612
+ loopHandle();
1613
+ } else {
1614
+ resolve();
1615
+ }
1616
+ });
1617
+ },
1618
+ },
1619
+ };
1620
+ tableOption.callback = (rows) => {
1621
+ // this.fieldModel = rows;
1622
+ this.formModel[this.fieldKeyName] = rows;
1623
+ };
1624
+ }
1625
+
1626
+ if (isTreeTable) {
1627
+ tableOption.filterType = false;
1628
+ }
1629
+ tableOption = extendDeeply(tableOption, tableConfig);
1630
+ /* if (this.widget.options.tableConfig) {
1631
+ let tableConfig =
1632
+ this.handleCustomEvent(this.widget.options.tableConfig) || {};
1633
+ tableOption = extendDeeply(tableOption, tableConfig);
1634
+ this.tableConfig = tableConfig;
1635
+ } */
1636
+
1637
+ if (tableOption.config.showFooter && !tableOption.config.footerMethod) {
1638
+ let footerColumnIds = [];
1639
+ this.loodHandleColumns(columns, (item) => {
1640
+ if (!item.children?.length && !!item.params?.footerDataType) {
1641
+ footerColumnIds.push(item.params.columnId);
1642
+ }
1643
+ });
1644
+
1645
+ /* let footerColumnIds = columns
1646
+ .filter((item) => !!item.params?.footerDataType)
1647
+ .map((item) => item.params.columnId); */
1648
+ if (footerColumnIds.length) {
1649
+ tableOption.config.footerMethod = (param) => {
1650
+ let { columns: column1s, data } = param;
1651
+ return [
1652
+ column1s.map((column, columnIndex) => {
1653
+ let columnId = column.params?.columnId;
1654
+ if (columnId && footerColumnIds.includes(columnId)) {
1655
+ let footerDataType = column.params.footerDataType;
1656
+ if (footerDataType === "1") {
1657
+ //求和
1658
+ return this.sumNum(data, column.field);
1659
+ } else if (footerDataType === "2") {
1660
+ //求平均值
1661
+ return this.meanNum(data, column.field);
1662
+ } else if (footerDataType === "3") {
1663
+ if (column.params.footerMethodConfg) {
1664
+ let n = new Function(
1665
+ "dataId",
1666
+ "formCode",
1667
+ "param",
1668
+ column.params.footerMethodConfg
1669
+ );
1670
+ return n.call(this, dataId, formCode, param) ?? null;
1671
+ }
1672
+ }
1673
+ }
1674
+ return null;
1675
+ }),
1676
+ ];
1677
+ };
1678
+ }
1679
+ }
1680
+ tableOption.vue = this;
1681
+
1682
+ //合并单元格
1683
+ let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
1684
+ let unikey = this.widget.options.mergeRowKey;
1685
+ if (mergeRowEnabled && unikey) {
1686
+ tableOption.config.spanMethod = this.mergeRowMethod;
1687
+ }
1688
+ this.$vxeTableUtil.initVxeTable(tableOption).then((opts) => {
1689
+ this.vxeOption = opts;
1690
+ if (!isQueryTable) {
1691
+ setTimeout(() => {
1692
+ this.loadAccessData(1);
1693
+ }, 20);
1694
+ }
1695
+ });
1696
+ },
1697
+ loodHandleColumns(columns, callback) {
1698
+ let columnLoopDo = (t, e) => {
1699
+ callback && callback(t);
1700
+ if (t.children && t.children.length) {
1701
+ this.loodHandleColumns(t.children, callback);
1702
+ /* for (let item of t.children) {
1703
+ columnLoopDo(item);
1704
+ } */
1705
+ }
1706
+ };
1707
+ for (let item of columns) {
1708
+ columnLoopDo(item);
1709
+ }
1710
+ },
1711
+
1712
+ meanNum(list, field) {
1713
+ let count = this.sumNum(list, field);
1714
+ return this.$baseDiv(count, list.length);
1715
+ },
1716
+ sumNum(list, field) {
1717
+ let count = 0;
1718
+ list.forEach((item) => {
1719
+ count = this.$baseAdd(count, item[field]);
1720
+ });
1721
+ return count;
1722
+ },
1723
+ getSearchFormData() {
1724
+ let map = { condition: [] };
1725
+ let formData = this.globalModel.formModel;
1726
+ let widgetList = this.widget.widgetList;
1727
+ if (!!widgetList && widgetList.length > 0) {
1728
+ let loop = (wItem) => {
1729
+ if (wItem.category === "container") {
1730
+ loop(wItem);
1731
+ } else {
1732
+ let formField = this.getFieldKeyName(wItem);
1733
+ let vaule = formData[formField];
1734
+ if (vaule !== null && vaule !== undefined && vaule !== "") {
1735
+ if (!Array.isArray(vaule) || vaule.length > 0) {
1736
+ let item = {
1737
+ value: vaule,
1738
+ field: formField,
1739
+ filter: null,
1740
+ };
1741
+ let wType = wItem.type;
1742
+ if (["date-range", "time-range"].includes(wType)) {
1743
+ item.filter = "between";
1744
+ } else if (
1745
+ ["input-batch", "checkbox"].includes(wType) ||
1746
+ (wType === "select" && wItem.options.multiple)
1747
+ ) {
1748
+ item.filter = "in";
1749
+ } else if (
1750
+ ["radio", "time", "date"].includes(wType) ||
1751
+ (wType === "select" && !wItem.options.multiple)
1752
+ ) {
1753
+ item.filter = "eq";
1754
+ } else {
1755
+ item.filter = "like";
1756
+ }
1757
+ map.condition.push(item);
1758
+ }
1759
+ }
1760
+ }
1761
+ };
1762
+ widgetList.forEach((wItem) => {
1763
+ loop(wItem);
1764
+ });
1765
+ }
1766
+ return map;
1767
+ },
1768
+ getUrl() {
1769
+ let accessUrl = this.widget.options.accessUrl;
1770
+ return accessUrl || USER_PREFIX + `/form_ins/getFormInsData`;
1771
+ },
1772
+ getAttachmentType() {
1773
+ /* let vailColumns = this.widget.options.tableColumns.filter(
1774
+ (item) => item.prop && item.label
1775
+ );
1776
+ let result = vailColumns
1777
+ .filter((item) => {
1778
+ return item.formatS === "editAttachment";
1779
+ })
1780
+ .map((item) => item.prop); */
1781
+
1782
+ let result = [];
1783
+ this.loodHandleColumns(this.widget.options.tableColumns, (item) => {
1784
+ if (!item.children?.length && item.prop && item.label) {
1785
+ if (item.formatS === "editAttachment") {
1786
+ result.push(item.prop);
1787
+ }
1788
+ }
1789
+ });
1790
+ return result;
1791
+ },
1792
+ getThirdtabm() {
1793
+ /* let vailColumns = this.widget.options.tableColumns.filter(
1794
+ (item) => item.prop && item.label
1795
+ );
1796
+ let result = vailColumns
1797
+ .filter((item) => {
1798
+ return (
1799
+ item.formatS === "editSearch" && item.columnOption.multipleChoices
1800
+ );
1801
+ })
1802
+ .map((item) => item.prop); */
1803
+ let result = [];
1804
+ this.loodHandleColumns(this.widget.options.tableColumns, (item) => {
1805
+ if (!item.children?.length && item.prop && item.label) {
1806
+ if (
1807
+ item.formatS === "editSearch" &&
1808
+ item.widget?.options?.multipleChoices
1809
+ ) {
1810
+ result.push(item.prop);
1811
+ }
1812
+ }
1813
+ });
1814
+ return result;
1815
+ },
1816
+
1817
+ loadDefaultViewList(option) {
1818
+ let dataId = this.formDataId;
1819
+ let reportTemplate = this.getFormRef().reportTemplate;
1820
+ let formCode = reportTemplate.formCode;
1821
+ let accessParam = this.getAccessParam() || {};
1822
+ let otherParam = {};
1823
+ let attachmentType = this.getAttachmentType();
1824
+ if (attachmentType.length) {
1825
+ otherParam.attachmentType = attachmentType;
1826
+ }
1827
+ let thirdtabm = this.getThirdtabm();
1828
+ if (thirdtabm.length) {
1829
+ otherParam.thirdtabm = thirdtabm;
1830
+ }
1831
+ let scriptCode = this.getScriptCode();
1832
+ return this.formHttp({
1833
+ /*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
1834
+ scriptCode: scriptCode,
1835
+ data: {
1836
+ formCode: formCode,
1837
+ formVersion: reportTemplate.formVersion,
1838
+ taBm: this.fieldKeyName,
1839
+ data: {
1840
+ id: dataId,
1841
+ ...otherParam,
1842
+ ...accessParam,
1843
+ },
1844
+ },
1845
+ callback: (res) => {
1846
+ let $grid = this.getGridTable();
1847
+ // let rows = res.objx ? res.objx.records || res.objx || [] : [];
1848
+
1849
+ let items = this.handleTreeData(res.objx?.records || res.objx || []);
1850
+ if (res.objx?.records !== undefined) {
1851
+ res.objx.records = items;
1852
+ } else {
1853
+ res.objx = items;
1854
+ }
1855
+ let rows = res.objx ? res.objx.records || res.objx || [] : [];
1856
+
1857
+ // that.handleNullValue(rows);
1858
+ let defaultRow = this.createNewTableData();
1859
+ rows = rows.map((row) => {
1860
+ return {
1861
+ ...defaultRow,
1862
+ ...row,
1863
+ };
1864
+ });
1865
+ this.initValue(rows);
1866
+ this.$nextTick(() => {
1867
+ /*if (this.widget.options.isTreeTable) {
1868
+ let $grid = this.getGridTable();
1869
+ $grid.treeConfig.lazy = false;
1870
+ $grid.setAllTreeExpand(true);
1871
+ }*/
1872
+ this.tableConfig.callback && this.tableConfig.callback(rows);
1873
+ this.handleCustomEvent(
1874
+ this.widget.options.formScriptCallback,
1875
+ ["rows"],
1876
+ [rows]
1877
+ );
1878
+ this.$forceUpdate();
1879
+ });
1880
+ },
1881
+ });
1882
+ },
1883
+ getAccessParam() {
1884
+ if (!this.widget.options.formScriptParam) return;
1885
+ return this.handleCustomEvent(this.widget.options.formScriptParam);
1886
+ },
1887
+ getScriptCode() {
1888
+ let accessReturnType = this.widget.options.accessReturnType;
1889
+ let defaultScriptCode = "getList";
1890
+ if (accessReturnType === "1") {
1891
+ defaultScriptCode = "getList";
1892
+ } else if (accessReturnType === "2") {
1893
+ defaultScriptCode = "getPage";
1894
+ }
1895
+ let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
1896
+ return scriptCode;
1897
+ },
1898
+ loadDefaultQueryList(reqData, done, customParam) {
1899
+ let reportTemplate = this.getFormRef().reportTemplate;
1900
+ let prefix = "/" + reportTemplate.serviceName;
1901
+ let formCode = reportTemplate.formCode;
1902
+ let formConfig = this.formConfig;
1903
+ let accessReturnType = this.widget.options.accessReturnType;
1904
+ let scriptCode = this.getScriptCode();
1905
+ let accessParam = {};
1906
+ let otherParam = {};
1907
+ if (customParam?.exportParam?.type === "exportItem") {
1908
+ let $grid = this.getGridTable();
1909
+ let originOption = $grid.params.originOption;
1910
+ let exportItemConfig = originOption.exportItemConfig || {};
1911
+ if (exportItemConfig.scriptCode) {
1912
+ scriptCode = exportItemConfig.scriptCode;
1913
+ }
1914
+ if (exportItemConfig.columns?.length) {
1915
+ let result = [];
1916
+ this.loodHandleColumns(exportItemConfig.columns, (item) => {
1917
+ if (!item.children?.length && item.field && item.title) {
1918
+ if (item.field.startsWith("attachments_")) {
1919
+ result.push(item.field);
1920
+ }
1921
+ }
1922
+ });
1923
+ if (result.length) {
1924
+ otherParam.attachmentType = result;
1925
+ }
1926
+ }
1927
+ let ids = $grid.getCheckboxRecords(true).map((item) => {
1928
+ return item.id;
1929
+ });
1930
+
1931
+ if (originOption.exportItemConfig.param) {
1932
+ accessParam = originOption.exportItemConfig.param() || {};
1933
+ }
1934
+ accessParam.ids = ids;
1935
+ } else {
1936
+ accessParam = this.getAccessParam() || {};
1937
+ let attachmentType = this.getAttachmentType();
1938
+ if (attachmentType.length) {
1939
+ otherParam.attachmentType = attachmentType;
1940
+ }
1941
+ }
1942
+
1943
+ let defaultOption = this.getHttpConfigForUser();
1944
+
1945
+ let ajaxConfig = customParam?.config || {};
1946
+
1947
+ let requestData = {
1948
+ ...reqData,
1949
+ ...otherParam,
1950
+ };
1951
+ requestData = extendDeeply(requestData, accessParam);
1952
+
1953
+ return this.formHttp({
1954
+ // url: prefix + "/form_ins/getPage",
1955
+ scriptCode: scriptCode,
1956
+ data: {
1957
+ formCode: formCode,
1958
+ formVersion: reportTemplate.formVersion,
1959
+ taBm: this.fieldKeyName,
1960
+ data: requestData,
1961
+ },
1962
+ isLoading: false,
1963
+ ...defaultOption,
1964
+ ...ajaxConfig,
1965
+ callback: (res) => {
1966
+ done(res);
1967
+ },
1968
+ });
1969
+ },
1970
+ loadAccessData(flag) {
1971
+ if (
1972
+ this.formModel[this.fieldKeyName] &&
1973
+ this.formModel[this.fieldKeyName].length
1974
+ ) {
1975
+ this.initValue(this.formModel[this.fieldKeyName]);
1976
+ }
1977
+ if (flag === 1) {
1978
+ let tableConfig = this.tableConfig;
1979
+ let accessEnabled = tableConfig.accessEnabled ?? true;
1980
+ if (accessEnabled === false) {
1981
+ return;
1982
+ }
1983
+ if (this.formConfig.isLoadEntity && !this.formDataId) {
1984
+ return;
1985
+ }
1986
+ }
1987
+
1988
+ let scriptCode = this.getScriptCode();
1989
+ if (scriptCode) {
1990
+ this.loadDefaultViewList();
1991
+ }
1992
+ },
1993
+ getReqParam(item, dataId, billData) {
1994
+ let param = {};
1995
+ if (item.accessParam) {
1996
+ if (typeof item.accessParam === "string") {
1997
+ let n = new Function("billData", item.accessParam);
1998
+ param = n.call(this, billData);
1999
+ } else {
2000
+ param = item.accessParam;
2001
+ }
2002
+ } else {
2003
+ param = { id: dataId };
2004
+ }
2005
+ return param;
2006
+ },
2007
+ getTableRef() {
2008
+ let tableRef = this.widget.id;
2009
+ return tableRef;
2010
+ },
2011
+ exportData(option) {
2012
+ let tableRef = this.getTableRef();
2013
+ let serviceName = this.getFormRef().reportTemplate.serviceName;
2014
+ option.prefix = option.prefix || "/" + serviceName;
2015
+ let exportTableTarget = this.$refs.exportTable;
2016
+ let getExportTableRef = () => {
2017
+ return exportTableTarget;
2018
+ };
2019
+ this.$excelExport({ targetRef: tableRef, ...option });
2020
+ },
2021
+ async deleteRow(row, rowIndex) {
2022
+ let isTreeTable = this.widget.options.isTreeTable;
2023
+ if (isTreeTable) {
2024
+ this.removeTreeRow({ row });
2025
+ return;
2026
+ }
2027
+ delete this.fieldSchemaMap[row._X_ROW_KEY];
2028
+ let $grid = this.getGridTable();
2029
+ $grid.remove(row);
2030
+ let tableData = $grid.getTableData();
2031
+ let isEditTable = this.widget.options.isEditTable;
2032
+ let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
2033
+ this.formModel[this.fieldKeyName] = fullData;
2034
+ this.fieldModel = fullData;
2035
+ this.$nextTick(() => {
2036
+ this.handleWbs();
2037
+ });
2038
+ // this.deleteRowWidgets(row);
2039
+ },
2040
+ isSingerlSearch(widget) {
2041
+ let widgetType = widget?.type;
2042
+ let result =
2043
+ widgetType === "singerSearch" ||
2044
+ (widgetType === "vabsearch" && !widget.options.multipleChoices);
2045
+ return result;
2046
+ },
2047
+ getColumnNullValue(widget, defaultValueEnabled) {
2048
+ if (!widget) return null;
2049
+ let nullValue = null;
2050
+ let widgetType = widget.type;
2051
+ let multiWidgetTypes = [
2052
+ "checkbox",
2053
+ "time-range",
2054
+ "baseAttachment",
2055
+ "vabUpload",
2056
+ "project-tag",
2057
+ ];
2058
+
2059
+ let defaultValue = widget.options.defaultValue;
2060
+ if (
2061
+ defaultValue !== undefined &&
2062
+ defaultValue !== null &&
2063
+ defaultValue !== "" &&
2064
+ defaultValueEnabled !== false
2065
+ ) {
2066
+ nullValue = defaultValue;
2067
+ } else if (widgetType === "select" && widget.options.multiple) {
2068
+ nullValue = [];
2069
+ } else if (widgetType === "date" && widget.options.type === "dates") {
2070
+ nullValue = [];
2071
+ } else if (widgetType === "vabsearch" && widget.options.multipleChoices) {
2072
+ nullValue = [];
2073
+ } else if (multiWidgetTypes.includes(widgetType)) {
2074
+ nullValue = [];
2075
+ }
2076
+ return nullValue;
2077
+ },
2078
+ getIsFormWidget(widget) {
2079
+ let widgetTypes = ["baseAttachment"];
2080
+ let result = false;
2081
+ if (widget.formItemFlag) {
2082
+ result = true;
2083
+ }
2084
+ return result;
2085
+ },
2086
+ handleWidgetNullValue(widget, newData) {
2087
+ if (!widget || !newData) return;
2088
+ if (this.getIsFormWidget(widget)) {
2089
+ let field = this.getFieldKeyName(widget);
2090
+ let nullValue = newData.hasOwnProperty(field)
2091
+ ? null
2092
+ : this.getColumnNullValue(widget);
2093
+ newData[field] = nullValue;
2094
+ if (this.isSingerlSearch(widget)) {
2095
+ let vabSearchName = widget.options.vabSearchName;
2096
+ if (vabSearchName) newData[vabSearchName] = null;
2097
+ }
2098
+ }
2099
+ },
2100
+ createNewTableData(isEdit, defaultValueEnabled = true) {
2101
+ let newData = {};
2102
+ this.loodHandleColumns(this.widget.options.tableColumns, (item) => {
2103
+ if (!item.children?.length && item.prop && item.label) {
2104
+ let formatS = !isEdit ? item.formatS : item.editFormatS;
2105
+ let widget = null;
2106
+ if (isEdit) {
2107
+ widget = item.editWidget || item.widget;
2108
+ } else {
2109
+ widget = item.widget;
2110
+ }
2111
+ if (formatS === "widgetRender") {
2112
+ if (item.widgetList) {
2113
+ loopHandleWidget(item.widgetList, (w, p) => {
2114
+ this.handleWidgetNullValue(w, newData, defaultValueEnabled);
2115
+ });
2116
+ }
2117
+ } else {
2118
+ if (widget) {
2119
+ this.handleWidgetNullValue(widget, newData, defaultValueEnabled);
2120
+ } else {
2121
+ newData[item.prop] = null;
2122
+ }
2123
+ }
2124
+ }
2125
+ });
2126
+ return newData;
2127
+ },
2128
+ addTableData(rows, field) {
2129
+ let $grid = this.getGridTable();
2130
+ let formDataModel = this.formModel;
2131
+ let tableRows = formDataModel[this.fieldKeyName] || [];
2132
+ let fullData = $grid.getTableData().fullData;
2133
+ let items;
2134
+ if (field) {
2135
+ let keys = fullData.map((item) => {
2136
+ return item[field] + "";
2137
+ });
2138
+ items = rows.filter((item) => {
2139
+ let value = item[field] + "";
2140
+ return !keys.includes(value);
2141
+ });
2142
+ } else {
2143
+ items = rows;
2144
+ }
2145
+ if (items) {
2146
+ if (items.length) {
2147
+ items.forEach((row) => {
2148
+ let newData = this.createNewTableData();
2149
+ Object.assign(newData, row);
2150
+
2151
+ tableRows.push(newData);
2152
+ });
2153
+ }
2154
+ } else {
2155
+ let newData = this.createNewTableData();
2156
+ tableRows.push(newData);
2157
+ }
2158
+ // this.formModel[this.fieldKeyName] = this.$baseLodash(this.fieldModel)
2159
+ // this.fieldModel = tableRows
2160
+ this.setValue(tableRows);
2161
+ this.$nextTick(() => {
2162
+ this.handleWbs();
2163
+ });
2164
+ // $grid.loadData(tableRows);
2165
+ },
2166
+ getColumnWidgetConfig(row, isEdit) {
2167
+ let formatS = isEdit ? row.editFormatS : row.formatS;
2168
+ let formRef = this.getFormRef();
2169
+ let columnSelectedWidget = null;
2170
+ let columnEditFields = null;
2171
+
2172
+ let type = columnFormatMap[formatS];
2173
+
2174
+ if (type) {
2175
+ columnSelectedWidget = this.$baseLodash.cloneDeep(
2176
+ formRef.getFieldWidgetByType(type)
2177
+ );
2178
+ let tmpId = generateId();
2179
+ let idVal = row.prop ? row.prop : type + tmpId;
2180
+ /*
2181
+ columnSelectedWidget.id = idVal;*/
2182
+ /*if(isEdit){
2183
+ columnSelectedWidget.id = "edit_"+row.columnId;
2184
+ }else{
2185
+ columnSelectedWidget.id = row.columnId;
2186
+ }*/
2187
+ // columnSelectedWidget.id = row.columnId;
2188
+
2189
+ columnSelectedWidget.options.name = idVal;
2190
+
2191
+ let columnOption;
2192
+ if (!isEdit) {
2193
+ columnOption = row.columnOption;
2194
+ } else {
2195
+ columnOption = row.editColumnOption;
2196
+ }
2197
+
2198
+ if (columnOption && Object.keys(columnOption).length) {
2199
+ columnOption.required = row.required || false;
2200
+ columnSelectedWidget.options = columnOption;
2201
+ if ("editDelete" === formatS) {
2202
+ columnSelectedWidget.options.hiddenByWf =
2203
+ columnSelectedWidget.options.hiddenByWf ?? true;
2204
+ columnSelectedWidget.options.prefixIcon =
2205
+ columnSelectedWidget.options.prefixIcon || "el-icon-delete";
2206
+ } else if ("editButton" === formatS) {
2207
+ columnSelectedWidget.options.prefixIcon =
2208
+ columnSelectedWidget.options.prefixIcon || "el-icon-edit";
2209
+ }
2210
+ } else {
2211
+ columnSelectedWidget.options.required = row.required || false;
2212
+ if ("editDelete" === formatS) {
2213
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2214
+ columnSelectedWidget.options.label = "删除";
2215
+ columnSelectedWidget.options.labelHidden = true;
2216
+ columnSelectedWidget.options.hiddenByWf = true;
2217
+ columnSelectedWidget.options.onClick =
2218
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
2219
+ } else if ("editButton" === formatS) {
2220
+ columnSelectedWidget.options.prefixIcon = "el-icon-edit";
2221
+ columnSelectedWidget.options.label = "查看";
2222
+ columnSelectedWidget.options.labelHidden = true;
2223
+ columnSelectedWidget.options.onClick =
2224
+ "let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
2225
+ } else if ("addSiblingEditRow" === formatS) {
2226
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2227
+ columnSelectedWidget.options.label = "新增兄弟节点";
2228
+ columnSelectedWidget.options.labelHidden = false;
2229
+ columnSelectedWidget.options.onClick =
2230
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
2231
+ } else if ("addChildTreeRow" === formatS) {
2232
+ columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2233
+ columnSelectedWidget.options.label = "新增子节点";
2234
+ columnSelectedWidget.options.labelHidden = false;
2235
+ columnSelectedWidget.options.onClick =
2236
+ "let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
2237
+ } else if ("moveUpRow" === formatS) {
2238
+ // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2239
+ columnSelectedWidget.options.label = "↑上移";
2240
+ columnSelectedWidget.options.labelHidden = false;
2241
+ columnSelectedWidget.options.onClick =
2242
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
2243
+ } else if ("moveDownRow" === formatS) {
2244
+ // columnSelectedWidget.options.prefixIcon = "el-icon-plus";
2245
+ columnSelectedWidget.options.label = "↓下移";
2246
+ columnSelectedWidget.options.labelHidden = false;
2247
+ columnSelectedWidget.options.onClick =
2248
+ "let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
2249
+ } else if ("removeTreeRow" === formatS) {
2250
+ columnSelectedWidget.options.prefixIcon = "el-icon-delete";
2251
+ columnSelectedWidget.options.label = "删除";
2252
+ columnSelectedWidget.options.labelHidden = true;
2253
+ columnSelectedWidget.options.onClick =
2254
+ "let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
2255
+ }
2256
+ columnOption = columnSelectedWidget.options;
2257
+ }
2258
+ if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
2259
+ columnSelectedWidget.options.keyName = row.prop;
2260
+ columnSelectedWidget.options.keyNameEnabled = true;
2261
+ } else {
2262
+ columnSelectedWidget.options.name = row.prop;
2263
+ }
2264
+ if (type !== "button" && type !== "a-link") {
2265
+ columnSelectedWidget.options.label = row.label;
2266
+ columnSelectedWidget.options.labelHidden = true;
2267
+ }
2268
+ }
2269
+ return { columnSelectedWidget, columnEditFields };
2270
+ },
2271
+ getColumnProp2(fieldWidget, obj) {
2272
+ let isQueryTable = this.widget.options.isQueryTable || false;
2273
+ let rowWidget = this.getRowWidget(obj, fieldWidget);
2274
+ let required = rowWidget.options.required || false;
2275
+
2276
+ let fieldKeyName = this.getFieldKeyName(this.widget);
2277
+ let property = this.getFieldKeyName(rowWidget);
2278
+ if (this.isVabsearchFlagWidget(rowWidget)) {
2279
+ property = rowWidget.options.vabSearchName || property;
2280
+ }
2281
+ let rowIndex = Math.max(obj.rowIndex, 0);
2282
+
2283
+ let propName = fieldKeyName + "." + rowIndex + "." + property;
2284
+ if (isQueryTable && !required) {
2285
+ propName = "false";
2286
+ }
2287
+ return propName;
2288
+ },
2289
+ validateCheckRow() {
2290
+ let $grid = this.getGridTable();
2291
+ let checkRows = $grid.getCheckboxRecords(true);
2292
+ if (checkRows.length === 0) {
2293
+ this.$message({
2294
+ message: "请选择要操作的行",
2295
+ type: "warning",
2296
+ });
2297
+ return false;
2298
+ }
2299
+ const fieldsToValidate = [];
2300
+ let tableColumns = this.widget.options.tableColumns;
2301
+ checkRows.forEach((row) => {
2302
+ let fieldSchema = this.fieldSchemaMap[row._X_ROW_KEY];
2303
+ tableColumns.forEach((column) => {
2304
+ if (column.widget) {
2305
+ let widget = fieldSchema[column.widget.id];
2306
+ let required = widget.options.required || false;
2307
+ if (required) {
2308
+ let propName = this.getColumnWidgetProp(widget, row);
2309
+ fieldsToValidate.push(propName);
2310
+ }
2311
+ }
2312
+ if (column.widgetList) {
2313
+ column.widgetList.forEach((itemWidget) => {
2314
+ let widget = fieldSchema[itemWidget.id];
2315
+ let required = widget.options.required || false;
2316
+ if (required) {
2317
+ let propName = this.getColumnWidgetProp(widget, row);
2318
+ fieldsToValidate.push(propName);
2319
+ }
2320
+ });
2321
+ }
2322
+ });
2323
+ });
2324
+ let formRef = this.getFormRef();
2325
+ let renderForm = formRef.$refs.renderForm;
2326
+ let hasError = false;
2327
+ renderForm.validateField(fieldsToValidate, (errors) => {
2328
+ if (!hasError && errors) {
2329
+ this.$message.error(errors);
2330
+ hasError = true;
2331
+ }
2332
+ });
2333
+ return !hasError;
2334
+ },
2335
+ getColumnWidgetProp(widget, row) {
2336
+ if (!widget) return;
2337
+ let $grid = this.getGridTable();
2338
+ let rowIndex = $grid.getRowIndex(row);
2339
+ let fieldKeyName = this.getFieldKeyName(this.widget);
2340
+ let property = this.getFieldKeyName(widget);
2341
+ if (this.isVabsearchFlagWidget(widget)) {
2342
+ property = widget.options.vabSearchName || property;
2343
+ }
2344
+ let propName = fieldKeyName + "." + rowIndex + "." + property;
2345
+ return propName;
2346
+ },
2347
+ getColumnProp(obj, isEdit) {
2348
+ let sourceWidgetId = isEdit
2349
+ ? obj.column?.params?.editWidget?.id
2350
+ : obj.column?.params?.widget?.id;
2351
+ if (!sourceWidgetId || !this.fieldSchemaMap[obj.row._X_ROW_KEY])
2352
+ return "false";
2353
+ let fieldWidget = this.fieldSchemaMap[obj.row._X_ROW_KEY][sourceWidgetId];
2354
+ if (!fieldWidget) {
2355
+ return "false";
2356
+ }
2357
+ let isQueryTable = this.widget.options.isQueryTable || false;
2358
+
2359
+ let required = fieldWidget.options.required || false;
2360
+ if (isEdit || !isQueryTable || required) {
2361
+ let fieldKeyName = this.getFieldKeyName(this.widget);
2362
+ let rowIndex = Math.max(obj.rowIndex, 0);
2363
+
2364
+ let isTreeTable = this.widget.options.isTreeTable || false;
2365
+ if (isTreeTable) {
2366
+ rowIndex = this.getValue().findIndex(
2367
+ (item) => item._X_ROW_KEY === obj.row._X_ROW_KEY
2368
+ );
2369
+ if (rowIndex < 0) {
2370
+ return "false";
2371
+ }
2372
+ }
2373
+
2374
+ let property = this.getFieldKeyName(fieldWidget);
2375
+ if (obj.row[property] && Array.isArray(obj.row[property])) {
2376
+ return "false";
2377
+ }
2378
+ // let property = obj.column.property
2379
+ if (this.isVabsearchFlagWidget(fieldWidget)) {
2380
+ property = fieldWidget.options.vabSearchName || property;
2381
+ }
2382
+ let propName = fieldKeyName + "." + rowIndex + "." + property;
2383
+ return propName;
2384
+ } else {
2385
+ return "false";
2386
+ }
2387
+ },
2388
+ isVabsearchFlagWidget(widget) {
2389
+ let type = widget?.type;
2390
+ return (
2391
+ type === "vabsearch" ||
2392
+ type === "singerSearch" ||
2393
+ type === "multiSearch"
2394
+ );
2395
+ },
2396
+ getColumnWidgetName(e) {
2397
+ if (e && e.type) {
2398
+ if (e.category === "container") {
2399
+ return this.getContainerWidgetName(e);
2400
+ } else {
2401
+ return e.type + "-widget";
2402
+ }
2403
+ }
2404
+ },
2405
+ getGridTable() {
2406
+ let $grid = this.$refs[this.getTableRef()];
2407
+ return $grid;
2408
+ },
2409
+ getContainerWidgetName: function (e) {
2410
+ return "grid" === e.type ? "grid-item" : e.type + "-item";
2411
+ },
2412
+ getWidgetName: function (e) {
2413
+ return (e.targetType || e.type) + "-widget";
2414
+ },
2415
+ handleCheckboxChange(param) {
2416
+ let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
2417
+ let mergeRowKey = this.widget.options.mergeRowKey;
2418
+ if (mergeRowEnabled && mergeRowKey) {
2419
+ let grid = this.getGridTable();
2420
+ let fullData = grid.getTableData().fullData;
2421
+ let row = param.row;
2422
+ let val = row[mergeRowKey];
2423
+ let items = fullData.filter((item) => item[mergeRowKey] === val);
2424
+ if (items.length) {
2425
+ grid.setCheckboxRow(items, param.checked);
2426
+ }
2427
+ }
2428
+ if (this.widget.options.onCheckboxChange) {
2429
+ let t = new Function("param", this.widget.options.onCheckboxChange);
2430
+ t.call(this, param);
2431
+ }
2432
+ let formRef = this.getFormRef();
2433
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
2434
+ dataTableConfig.onCheckboxChange &&
2435
+ dataTableConfig.onCheckboxChange(param);
2436
+ },
2437
+ handleCheckboxAll(param) {
2438
+ if (this.widget.options.onCheckboxAll) {
2439
+ let t = new Function("param", this.widget.options.onCheckboxAll);
2440
+ t.call(this, param);
2441
+ }
2442
+ let formRef = this.getFormRef();
2443
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
2444
+ dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
2445
+ },
2446
+ handleCellDblclick(param) {
2447
+ if (this.widget.options.onCellDblclick) {
2448
+ let t = new Function("param", this.widget.options.onCellDblclick);
2449
+ t.call(this, param);
2450
+ }
2451
+ let formRef = this.getFormRef();
2452
+ let dataTableConfig = formRef.$attrs.dataTableOption || {};
2453
+ dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
2454
+ },
2455
+ advancedClear() {
2456
+ let formModel = this.formModel;
2457
+ let searchColumns = this.getGridTable().params.searchColumns;
2458
+ searchColumns.forEach((form1Field) => {
2459
+ if (!form1Field.common) {
2460
+ let field = form1Field.field;
2461
+ let options = form1Field.widget.options;
2462
+ let value = formModel[field] ?? null;
2463
+ let widgetRef = this.getWidgetRef(options.name);
2464
+ widgetRef && widgetRef.setValue(value);
2465
+ }
2466
+ });
2467
+ // this.getGridTable().$forceUpdate();
2468
+ },
2469
+ tableFormSettingConfirm() {
2470
+ let formModel = this.formModel;
2471
+ this.getFormRef().setFormData(formModel);
2472
+ },
2473
+
2474
+ //editTable begin
2475
+ async saveEditRow(obj) {
2476
+ let formRef = this.getFormRef();
2477
+ let formConfig = this.formConfig;
2478
+ let entity = formConfig.entity;
2479
+ if (!entity) return;
2480
+ let dataId = formRef?.dataId;
2481
+ let reportTemplate = formRef?.reportTemplate;
2482
+ let formCode = reportTemplate?.formCode;
2483
+ let scriptCode = formConfig.saveScriptCode || "saveUpdate";
2484
+
2485
+ let that = this;
2486
+ let $grid = obj.$table.$xegrid;
2487
+ let originOption = $grid.params.originOption;
2488
+
2489
+ let formModel = this.formModel;
2490
+ let dataMap = this.getGridTable().getTableData();
2491
+
2492
+ /* const errMap = await $grid.validate(obj.row).catch(errMap => errMap)
2493
+ if (errMap) {
2494
+ let title = errMap[Object.keys(errMap)[0]][0].column.title
2495
+ this.$message.error(`[${title}]不能为空`)
2496
+ return
2497
+ } */
2498
+
2499
+ formRef.validate((valid) => {
2500
+ if (valid) {
2501
+ $grid.clearActived().then(() => {
2502
+ $grid.setActiveRow(obj.row);
2503
+ let mainData = commonDataUtil.handleForm(obj.row);
2504
+
2505
+ delete mainData._createNickName;
2506
+ delete mainData._createMobile;
2507
+ delete mainData._modifyNickName;
2508
+ delete mainData._modifyMobile;
2509
+ delete mainData._createBy;
2510
+ delete mainData._modifyBy;
2511
+
2512
+ let formData = {
2513
+ [entity]: mainData,
2514
+ };
2515
+
2516
+ Object.keys(mainData).forEach((key) => {
2517
+ if (key.startsWith("attachments_")) {
2518
+ formData[key] = mainData[key];
2519
+ }
2520
+ });
2521
+
2522
+ let reqData = {
2523
+ formCode: formCode,
2524
+ formVersion: reportTemplate.formVersion,
2525
+ taBm: entity,
2526
+ data: formData,
2527
+ };
2528
+
2529
+ this.formHttp({
2530
+ scriptCode: scriptCode,
2531
+ data: reqData,
2532
+ successMsg: true,
2533
+ isConfirm: true,
2534
+ confirmText: "您确定要保存吗?",
2535
+ success: (res0) => {
2536
+ this.getRowData(res0.objx, (res) => {
2537
+ if (obj.row.id === res.objx.id) {
2538
+ $grid.clearActived().then(() => {
2539
+ Object.assign(obj.row, res.objx);
2540
+ });
2541
+ } else {
2542
+ // $grid.remove(obj.row);
2543
+ // $grid.insertAt(res.objx);
2544
+ let items = that.getValue();
2545
+ let index = items.findIndex(
2546
+ (item) => item.id === obj.row.id
2547
+ );
2548
+ items.splice(index, 1, res.objx);
2549
+ that.setValue(items);
2550
+ }
2551
+ delete obj.$table.editCloneRow;
2552
+ });
2553
+ },
2554
+ });
2555
+ });
2556
+ }
2557
+ });
2558
+ },
2559
+ getRowData(dataId, callback) {
2560
+ let reportTemplate = this.getFormRef()?.reportTemplate;
2561
+ let formCode = reportTemplate.formCode;
2562
+ let formConfig = this.formConfig;
2563
+ // let isLoadEntity = formConfig.isLoadEntity;
2564
+ let entity = formConfig.entity;
2565
+ let scriptCode = formConfig.formScriptCode || "getOne";
2566
+ let defaultOption = this.getHttpConfigForUser();
2567
+ this.formHttp({
2568
+ scriptCode: scriptCode,
2569
+ data: {
2570
+ formCode: formCode,
2571
+ formVersion: reportTemplate.formVersion,
2572
+ taBm: entity,
2573
+ data: {
2574
+ id: dataId,
2575
+ },
2576
+ },
2577
+ ...defaultOption,
2578
+ success: (res) => {
2579
+ callback && callback(res);
2580
+ },
2581
+ });
2582
+ },
2583
+ addChildTreeRow(rowData, obj, toTop) {
2584
+ let toEnd = !toTop;
2585
+ this.addTreeRow(rowData, obj, toEnd, null);
2586
+ },
2587
+ addTopTreeRow(rowData, toTop) {
2588
+ let toEnd = !toTop;
2589
+ this.addTreeRow(rowData, null, toEnd, null);
2590
+ },
2591
+ addSiblingTreeRow(rowData, obj) {
2592
+ this.addTreeRow(rowData, obj, null, true);
2593
+ },
2594
+ addTreeRow(rowData, obj, toEnd, toSibling) {
2595
+ let isEditTable = this.widget.options.isEditTable || false;
2596
+ let parent = obj?.row;
2597
+ let $grid = this.getGridTable();
2598
+ if (isEditTable && this.hasEditingRow($grid, 1)) {
2599
+ return false;
2600
+ }
2601
+ let parentField = $grid.treeConfig.parentField;
2602
+ let newRow = {};
2603
+ let originOption = $grid.params.originOption;
2604
+ let editDefaultRow;
2605
+ if (originOption.editDefaultRow) {
2606
+ if (typeof originOption.editDefaultRow === "function") {
2607
+ editDefaultRow = originOption.editDefaultRow() || {};
2608
+ } else {
2609
+ editDefaultRow = originOption.editDefaultRow || {};
2610
+ }
2611
+ }
2612
+
2613
+ // Object.assign(newRow, editDefaultRow, rowData);
2614
+ newRow.id =
2615
+ "row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
2616
+ if (!toSibling) {
2617
+ newRow[parentField] = parent?.id || 0;
2618
+ } else {
2619
+ newRow[parentField] = obj?.row[parentField] || 0;
2620
+ }
2621
+
2622
+ let newData = this.createNewTableData(isEditTable);
2623
+ newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
2624
+
2625
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2626
+ if (!parent) {
2627
+ if (toEnd === true) {
2628
+ tableRows.push(newRow);
2629
+ } else if (toSibling === true) {
2630
+ let addIndex =
2631
+ tableRows.findIndex(
2632
+ (item) => item._X_ROW_KEY === obj.row._X_ROW_KEY
2633
+ ) + 1;
2634
+ tableRows.splice(addIndex, 0, newRow);
2635
+ } else {
2636
+ tableRows.splice(0, 0, newRow);
2637
+ }
2638
+ this.setValue(tableRows);
2639
+ this.$nextTick(() => {
2640
+ this.handleWbs();
2641
+ if (isEditTable) {
2642
+ $grid.setActiveRow(newRow);
2643
+ }
2644
+ });
2645
+
2646
+ // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
2647
+ } else {
2648
+ $grid.setTreeExpand(obj.row, true).then(() => {
2649
+ if (toEnd === true) {
2650
+ tableRows.push(newRow);
2651
+ } else if (toSibling === true) {
2652
+ let addIndex =
2653
+ tableRows.findIndex(
2654
+ (item) => item._X_ROW_KEY === obj.row._X_ROW_KEY
2655
+ ) + 1;
2656
+ tableRows.splice(addIndex, 0, newRow);
2657
+ } else {
2658
+ tableRows.splice(0, 0, newRow);
2659
+ }
2660
+ this.setValue(tableRows);
2661
+ this.$nextTick(() => {
2662
+ this.handleWbs();
2663
+ $grid.setTreeExpand(obj.row, true).then(() => {
2664
+ if (isEditTable) {
2665
+ $grid.setActiveRow(newRow);
2666
+ }
2667
+ });
2668
+ });
2669
+ });
2670
+ }
2671
+ },
2672
+ removeTreeRow(obj) {
2673
+ let row = obj.row;
2674
+ let $grid = this.getGridTable();
2675
+ let childrenField = $grid.treeConfig?.children;
2676
+ // let tableRows = this.formModel[this.fieldKeyName];
2677
+ // let index = tableRows.findIndex(item => item.id === row.id)
2678
+ let delIds = [];
2679
+ let loopDo = (item) => {
2680
+ if (item._X_ROW_KEY) delIds.push(item._X_ROW_KEY);
2681
+ if (childrenField && item[childrenField]) {
2682
+ item[childrenField].forEach((subItem) => {
2683
+ loopDo(subItem);
2684
+ });
2685
+ }
2686
+ };
2687
+ loopDo(row);
2688
+ /* delIds.forEach((id) => {
2689
+ let index = tableRows.findIndex((item) => item.id === id);
2690
+ let delRow = tableRows[index];
2691
+ tableRows.splice(index, 1);
2692
+ this.deleteRowWidgets(delRow);
2693
+ }); */
2694
+ let tableRows = this.getValue();
2695
+ let delIndex = [];
2696
+ tableRows.map((item, index) => {
2697
+ if (delIds.includes(item._X_ROW_KEY)) {
2698
+ delIndex.push(index);
2699
+ }
2700
+ });
2701
+ delIndex.reverse().forEach((index) => {
2702
+ tableRows.splice(index, 1);
2703
+ });
2704
+
2705
+ // $grid.remove(obj.row);
2706
+
2707
+ // let newRows = tableRows.filter((item) => !delIds.includes(item.id));
2708
+ // this.setValue(newRows);
2709
+ this.$nextTick(() => {
2710
+ this.handleWbs();
2711
+ });
2712
+ },
2713
+ addSiblingEditRow(rowData, obj) {
2714
+ this.addEditRow(rowData, obj, null, true);
2715
+ },
2716
+ addEditRow(rowData, obj, toEnd, toSibling) {
2717
+ let isEditTable = this.widget.options.isEditTable || false;
2718
+ let isTreeTable = this.widget.options.isTreeTable || false;
2719
+ let parent = obj?.row;
2720
+ let $grid = this.getGridTable();
2721
+ if (isEditTable && this.hasEditingRow($grid, 1)) {
2722
+ return false;
2723
+ }
2724
+
2725
+ let newRow = {};
2726
+ let originOption = $grid.params.originOption;
2727
+ let editDefaultRow;
2728
+ if (originOption.editDefaultRow) {
2729
+ if (typeof originOption.editDefaultRow === "function") {
2730
+ editDefaultRow = originOption.editDefaultRow() || {};
2731
+ } else {
2732
+ editDefaultRow = originOption.editDefaultRow || {};
2733
+ }
2734
+ }
2735
+
2736
+ newRow.id =
2737
+ "row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
2738
+ if (isTreeTable) {
2739
+ let parentField = $grid.treeConfig.parentField;
2740
+ if (!toSibling) {
2741
+ newRow[parentField] = parent?.id || 0;
2742
+ } else {
2743
+ newRow[parentField] = obj?.row[parentField] || 0;
2744
+ }
2745
+ }
2746
+
2747
+ let newData = this.createNewTableData(isEditTable);
2748
+ newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
2749
+
2750
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2751
+ if (!parent) {
2752
+ if (toEnd === true) {
2753
+ tableRows.push(newRow);
2754
+ } else if (toSibling === true) {
2755
+ let addIndex =
2756
+ tableRows.findIndex(
2757
+ (item) => item._X_ROW_KEY === obj.row._X_ROW_KEY
2758
+ ) + 1;
2759
+ tableRows.splice(addIndex, 0, newRow);
2760
+ } else {
2761
+ tableRows.splice(0, 0, newRow);
2762
+ }
2763
+ this.setValue(tableRows);
2764
+ this.$nextTick(() => {
2765
+ this.handleWbs();
2766
+ if (isEditTable) {
2767
+ $grid.setActiveRow(newRow);
2768
+ }
2769
+ });
2770
+
2771
+ // $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
2772
+ } else {
2773
+ $grid.setTreeExpand(obj.row, true).then(() => {
2774
+ if (toEnd === true) {
2775
+ tableRows.push(newRow);
2776
+ } else if (toSibling === true) {
2777
+ let addIndex =
2778
+ tableRows.findIndex(
2779
+ (item) => item._X_ROW_KEY === obj.row._X_ROW_KEY
2780
+ ) + 1;
2781
+ tableRows.splice(addIndex, 0, newRow);
2782
+ } else {
2783
+ tableRows.splice(0, 0, newRow);
2784
+ }
2785
+ this.setValue(tableRows);
2786
+ this.$nextTick(() => {
2787
+ this.handleWbs();
2788
+ $grid.setTreeExpand(obj.row, true).then(() => {
2789
+ if (isEditTable) {
2790
+ $grid.setActiveRow(newRow);
2791
+ }
2792
+ });
2793
+ });
2794
+ });
2795
+ }
2796
+ },
2797
+ async removeEditRow(obj) {
2798
+ this.removeTreeRow(obj);
2799
+ },
2800
+ //editTable end
2801
+ getHttpConfigForUser() {
2802
+ let defaultOption = {
2803
+ addCreateInfo: true,
2804
+ queryCreateInfo: window.$vueRoot.$store.getters.queryCreateInfo || "0",
2805
+ };
2806
+ return defaultOption;
2807
+ },
2808
+ handleWbs() {
2809
+ if (this.widget.options.wbsEnabled) {
2810
+ this.updateWbs();
2811
+ }
2812
+ },
2813
+ updateWbs() {
2814
+ let that = this;
2815
+ let $grid = that.getGridTable();
2816
+ let childrenField = $grid.treeConfig.children;
2817
+ let fullData = $grid.getTableData().fullData;
2818
+ let tableRows = this.formModel[that.fieldKeyName] || [];
2819
+ let map = {};
2820
+ let loopDo = (item, wbs) => {
2821
+ item.f_wbs = wbs;
2822
+ map[item._X_ROW_KEY] = wbs;
2823
+ item[childrenField] &&
2824
+ item[childrenField].forEach((subitem, subindex) => {
2825
+ let sub_wbs = wbs + "." + (subindex + 1) + "";
2826
+ loopDo(subitem, sub_wbs);
2827
+ });
2828
+ };
2829
+ fullData.forEach((item, index) => {
2830
+ let wbs = index + 1 + "";
2831
+ loopDo(item, wbs);
2832
+ });
2833
+ $grid.updateData();
2834
+ },
2835
+ moveUpRow(obj) {
2836
+ let row = obj.row;
2837
+ let $grid = this.getGridTable();
2838
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2839
+ let isTreeTable = this.widget.options.isTreeTable;
2840
+ if (isTreeTable) {
2841
+ let parentField = $grid.treeConfig.parentField;
2842
+ let rowField = $grid.treeConfig.rowField || "id";
2843
+ let paretValue = row[parentField];
2844
+ let siblingRows = tableRows.filter(
2845
+ (item) => item[parentField] === paretValue
2846
+ );
2847
+ if (siblingRows.length > 1) {
2848
+ let currentIndex = tableRows.findIndex(
2849
+ (item) => item[rowField] === row[rowField]
2850
+ );
2851
+ let index1 = siblingRows.findIndex(
2852
+ (item) => item[rowField] === row[rowField]
2853
+ );
2854
+ if (index1 > 0) {
2855
+ let prevRow = siblingRows[index1 - 1];
2856
+ let prevIndex = tableRows.findIndex(
2857
+ (item) => item[rowField] === prevRow[rowField]
2858
+ );
2859
+ tableRows.splice(currentIndex, 1);
2860
+ tableRows.splice(prevIndex, 0, row);
2861
+ this.setValue(tableRows);
2862
+ this.$nextTick(() => {
2863
+ this.handleWbs();
2864
+ });
2865
+ }
2866
+ }
2867
+ } else {
2868
+ let rowIndex = $grid.getRowIndex(row);
2869
+ if (rowIndex >= 0) {
2870
+ tableRows.splice(rowIndex, 1);
2871
+ tableRows.splice(rowIndex - 1, 0, row);
2872
+ this.setValue(tableRows);
2873
+ this.$nextTick(() => {
2874
+ this.handleWbs();
2875
+ });
2876
+ }
2877
+ }
2878
+ },
2879
+ moveDownRow(obj) {
2880
+ let row = obj.row;
2881
+ let $grid = this.getGridTable();
2882
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2883
+ let isTreeTable = this.widget.options.isTreeTable;
2884
+ if (isTreeTable) {
2885
+ let parentField = $grid.treeConfig.parentField;
2886
+ let rowField = $grid.treeConfig.rowField || "id";
2887
+ let paretValue = row[parentField];
2888
+ let siblingRows = tableRows.filter(
2889
+ (item) => item[parentField] === paretValue
2890
+ );
2891
+ if (siblingRows.length > 1) {
2892
+ let currentIndex = tableRows.findIndex(
2893
+ (item) => item[rowField] === row[rowField]
2894
+ );
2895
+ let index1 = siblingRows.findIndex(
2896
+ (item) => item[rowField] === row[rowField]
2897
+ );
2898
+ if (index1 < siblingRows.length - 1) {
2899
+ let nextRow = siblingRows[index1 + 1];
2900
+ let nextIndex = tableRows.findIndex(
2901
+ (item) => item[rowField] === nextRow[rowField]
2902
+ );
2903
+ tableRows.splice(currentIndex, 1);
2904
+ tableRows.splice(nextIndex, 0, row);
2905
+ this.setValue(tableRows);
2906
+ this.$nextTick(() => {
2907
+ this.handleWbs();
2908
+ });
2909
+ }
2910
+ }
2911
+ } else {
2912
+ let rowIndex = $grid.getRowIndex(row);
2913
+ if (rowIndex < tableRows.length - 1) {
2914
+ tableRows.splice(rowIndex, 1);
2915
+ tableRows.splice(rowIndex + 1, 0, row);
2916
+ this.setValue(tableRows);
2917
+ this.$nextTick(() => {
2918
+ this.handleWbs();
2919
+ });
2920
+ }
2921
+ }
2922
+ },
2923
+
2924
+ openSortRowDialog(obj) {
2925
+ let $grid = this.getGridTable();
2926
+ let parentField = $grid.treeConfig.parentField;
2927
+ let rowField = $grid.treeConfig.rowField || "id";
2928
+ let row = obj.row;
2929
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2930
+
2931
+ let sortParentRow = tableRows.find(
2932
+ (item) => item[rowField] === row[parentField]
2933
+ );
2934
+ let sortRows = tableRows.filter(
2935
+ (item) => item[parentField] === row[parentField]
2936
+ );
2937
+ this.sortRows = sortRows;
2938
+ this.sortParentRow = sortParentRow;
2939
+ this.showTreeMoveDialog = true;
2940
+ },
2941
+ confirmTreeMoveDialog(rows) {
2942
+ if (this.widget.options.isEditTable) {
2943
+ let reportTemplate = this.getFormRef().reportTemplate;
2944
+ let formConfig = this.formConfig;
2945
+ let entity = formConfig.entity;
2946
+ let reqData = {
2947
+ formCode: reportTemplate.formCode,
2948
+ formVersion: reportTemplate.formVersion,
2949
+ taBm: entity,
2950
+ data: rows,
2951
+ };
2952
+ let scriptCode = this.widget.options.sortScriptCode;
2953
+ this.formHttp({
2954
+ scriptCode: scriptCode,
2955
+ data: reqData,
2956
+ successMsg: true,
2957
+ isConfirm: true,
2958
+ confirmText: "您确定要保存排序吗?",
2959
+ success: (res) => {
2960
+ this.getGridTable().reloadTreeExpand(this.sortParentRow);
2961
+ },
2962
+ });
2963
+ } else {
2964
+ let $grid = this.getGridTable();
2965
+ let rowField = $grid.treeConfig.rowField || "id";
2966
+ let tableRows = this.formModel[this.fieldKeyName] || [];
2967
+
2968
+ let ids = rows.map((item) => item[rowField]);
2969
+ let index = tableRows.findIndex((item) => ids.includes(item[rowField]));
2970
+ let items = tableRows.filter((item) => !ids.includes(item[rowField]));
2971
+ rows.forEach((row, index1) => {
2972
+ items.splice(index + index1, 0, row);
2973
+ });
2974
+ this.setValue(items);
2975
+ this.$nextTick(() => {
2976
+ this.handleWbs();
2977
+ });
2978
+ }
2979
+ },
2980
+ // 通用行合并函数(将相同多列数据合并为一行)
2981
+ mergeRowMethod(tableParam) {
2982
+ let { row, _rowIndex, column, visibleData } = tableParam;
2983
+ let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
2984
+ let unikey = this.widget.options.mergeRowKey;
2985
+ const cellValue = row[unikey];
2986
+ let isItemLine = column.params?.isItemLine || false;
2987
+ if (mergeRowEnabled && unikey && !isItemLine) {
2988
+ const prevRow = visibleData[_rowIndex - 1];
2989
+ let nextRow = visibleData[_rowIndex + 1];
2990
+ if (prevRow && prevRow[unikey] === cellValue) {
2991
+ return { rowspan: 0, colspan: 0 };
2992
+ } else {
2993
+ let countRowspan = 1;
2994
+ while (nextRow && nextRow[unikey] === cellValue) {
2995
+ nextRow = visibleData[++countRowspan + _rowIndex];
2996
+ }
2997
+ if (countRowspan > 1) {
2998
+ return { rowspan: countRowspan, colspan: 1 };
2999
+ }
3000
+ }
3001
+ } else {
3002
+ // return { rowspan: 1, colspan: 1 }
3003
+ }
3004
+ },
3005
+ mergeRowMethod2({ row, _rowIndex, column, visibleData }) {
3006
+ const fields = ["key"];
3007
+ const cellValue = row[column.field];
3008
+ if (cellValue && fields.includes(column.field)) {
3009
+ const prevRow = visibleData[_rowIndex - 1];
3010
+ let nextRow = visibleData[_rowIndex + 1];
3011
+ if (prevRow && prevRow[column.field] === cellValue) {
3012
+ return { rowspan: 0, colspan: 0 };
3013
+ } else {
3014
+ let countRowspan = 1;
3015
+ while (nextRow && nextRow[column.field] === cellValue) {
3016
+ nextRow = visibleData[++countRowspan + _rowIndex];
3017
+ }
3018
+ if (countRowspan > 1) {
3019
+ return { rowspan: countRowspan, colspan: 1 };
3020
+ }
3021
+ }
3022
+ }
3023
+ },
3024
+
3025
+ /**begin*/
3026
+ /*initFieldSchemaData() { //初始化fieldSchemaData!!!
3027
+
3028
+ let rowWidgetList = this.rowWidgetList
3029
+ let rows = this.getValue();
3030
+ let rowLength = rows.length
3031
+ this.widgetMap = {} //清除数组必须用splice,length=0不会响应式更新!!
3032
+ if (rowLength > 0) {
3033
+ for (let i = 0; i < rowLength; i++) {
3034
+ let row = rows[i];
3035
+ let fieldSchemas = []
3036
+ rowWidgetList.forEach(swItem => {
3037
+ fieldSchemas.push( this.cloneFieldSchema(swItem) )
3038
+ })
3039
+ let keyVal = row._X_ROW_KEY;
3040
+ this.widgetMap[keyVal] = fieldSchemas;
3041
+ }
3042
+ }
3043
+ },
3044
+
3045
+ addToFieldSchemaData(row) {
3046
+ let fieldSchemas = []
3047
+ this.rowWidgetList.forEach(swItem => {
3048
+ fieldSchemas.push( this.cloneFieldSchema(swItem) )
3049
+ })
3050
+
3051
+ let keyVal = row._X_ROW_KEY;
3052
+ this.widgetMap[keyVal] = fieldSchemas;
3053
+ },
3054
+
3055
+ deleteFromFieldSchemaData(row) {
3056
+ let keyVal = row._X_ROW_KEY;
3057
+ delete this.widgetMap[keyVal] ;
3058
+ },
3059
+
3060
+ cloneFieldSchema(fieldWidget) {
3061
+ let newFieldSchema = this.$baseLodash.cloneDeep(fieldWidget)
3062
+ newFieldSchema.id = fieldWidget.type + generateId()
3063
+ return newFieldSchema
3064
+ },*/
3065
+ clearRowWidgets() {
3066
+ // this.widgetMap = {};
3067
+ },
3068
+ deleteRowWidgets(row) {
3069
+ this.rowWidgetList.forEach((widget) => {
3070
+ let key = this.getRowRefKey(row, widget.options.name);
3071
+ delete this.widgetMap[key];
3072
+ });
3073
+ },
3074
+ /**end*/
3075
+
3076
+ //begin1
3077
+ initAllFieldSchema() {
3078
+ this.initRowIdData(true);
3079
+ this.initFieldSchemaData();
3080
+ },
3081
+ initRowIdData(initFlag) {
3082
+ this.rowIdData.splice(0, this.rowIdData.length); //清除数组必须用splice,length=0不会响应式更新!!
3083
+ let subFormModel = this.formModel[this.fieldKeyName];
3084
+ if (!!subFormModel && subFormModel.length > 0) {
3085
+ subFormModel.forEach((row) => {
3086
+ if (!row._X_ROW_KEY) row._X_ROW_KEY = "row_" + generateId();
3087
+ this.rowIdData.push(row._X_ROW_KEY);
3088
+ });
3089
+
3090
+ /*if (!!initFlag) {
3091
+ //注意:事件触发需延期执行,SumFormDataChange事件处理代码中可能存在尚未创建完成的组件!!
3092
+ setTimeout(() => {
3093
+ this.handleSubFormRowChange(subFormModel)
3094
+ }, 800)
3095
+ }*/
3096
+ }
3097
+ },
3098
+ initFieldSchemaData(initFlag) {
3099
+ //初始化fieldSchemaData!!!
3100
+ /*if (this.widget.type !== 'sub-form') {
3101
+ return
3102
+ }*/
3103
+
3104
+ let rows = this.formModel[this.fieldKeyName];
3105
+ let rowIdData = this.rowIdData;
3106
+ let rowLength = this.rowIdData.length;
3107
+ // this.fieldSchemaData.splice(0, this.fieldSchemaData.length) //清除数组必须用splice,length=0不会响应式更新!!
3108
+ // if(initFlag)this.fieldSchemaMap = {};
3109
+ if (rowLength > 0) {
3110
+ let target = this.getGridTable();
3111
+ if (!target) return;
3112
+ let { fullColumn } = target.getTableColumn();
3113
+ let allWidgets = [];
3114
+ let fieldSchemaMap = {};
3115
+ let fieldSchemaMap0 = this.fieldSchemaMap;
3116
+ for (let i = 0; i < rowLength; i++) {
3117
+ let rowId = rowIdData[i];
3118
+ let fieldSchemas = [];
3119
+ let fieldSchemaMap2 = null;
3120
+ if (initFlag) {
3121
+ fieldSchemaMap2 = this.createRowFieldSchemaMap();
3122
+ } else {
3123
+ let fieldSchemaMap01 = fieldSchemaMap0[rowId];
3124
+ fieldSchemaMap2 = fieldSchemaMap01
3125
+ ? this.$baseLodash.cloneDeep(fieldSchemaMap01)
3126
+ : this.createRowFieldSchemaMap();
3127
+ }
3128
+ fieldSchemaMap[rowId] = fieldSchemaMap2;
3129
+ }
3130
+ this.fieldSchemaMap = fieldSchemaMap;
3131
+ }
3132
+ },
3133
+ createRowFieldSchemaMap() {
3134
+ let target = this.getGridTable();
3135
+ let { fullColumn } = target.getTableColumn();
3136
+
3137
+ let fieldSchemaMap2 = {};
3138
+ fullColumn.forEach((column) => {
3139
+ let params = column.params;
3140
+ if (params) {
3141
+ if (params.widget) {
3142
+ let item1 = this.cloneFieldSchema(params.widget);
3143
+ fieldSchemaMap2[params.widget.id] = item1;
3144
+ }
3145
+ if (params.editWidget) {
3146
+ let item1 = this.cloneFieldSchema(params.editWidget);
3147
+ fieldSchemaMap2[params.editWidget.id] = item1;
3148
+ }
3149
+ if (params.widgetList) {
3150
+ let widgetList = this.$baseLodash.cloneDeep(params.widgetList);
3151
+ loopHandleWidget(widgetList, (w, p) => {
3152
+ // let item1 = this.cloneFieldSchema(w)
3153
+ let id = w.id;
3154
+ w.id = w.type + generateId();
3155
+ fieldSchemaMap2[id] = w;
3156
+ });
3157
+ }
3158
+ }
3159
+ });
3160
+ return fieldSchemaMap2;
3161
+ },
3162
+ addToFieldSchemaData(rowIndex) {
3163
+ let fieldSchemas = [];
3164
+ this.widget.widgetList.forEach((swItem) => {
3165
+ fieldSchemas.push(this.cloneFieldSchema(swItem));
3166
+ });
3167
+
3168
+ if (rowIndex === undefined) {
3169
+ this.fieldSchemaData.push(fieldSchemas);
3170
+ } else {
3171
+ this.fieldSchemaData.splice(rowIndex, 0, fieldSchemas);
3172
+ }
3173
+ },
3174
+
3175
+ deleteFromFieldSchemaData(rowIndex) {
3176
+ this.fieldSchemaData.splice(rowIndex, 1);
3177
+ },
3178
+
3179
+ cloneFieldSchema(fieldWidget) {
3180
+ let newFieldSchema = deepClone(fieldWidget);
3181
+ newFieldSchema.id = fieldWidget.type + generateId();
3182
+ return newFieldSchema;
3183
+ },
3184
+ //end1
3185
+ initExportFieldSchemaData(rows) {
3186
+ if (!rows) return;
3187
+ //初始化fieldSchemaData!!!
3188
+ let fieldSchemaMap = this.fieldSchemaMap;
3189
+ for (let row of rows) {
3190
+ if (!row._X_ROW_KEY) row._X_ROW_KEY = "row_" + generateId();
3191
+ this.rowIdData.push(row._X_ROW_KEY);
3192
+ let fieldSchemaMap2 = this.createRowFieldSchemaMap();
3193
+ fieldSchemaMap[row._X_ROW_KEY] = fieldSchemaMap2;
3194
+ }
3195
+ },
3196
+ initEventHandler() {
3197
+ if (this.designState) return;
3198
+ this.$on("setFormData", (o) => {
3199
+ let rows = this.formModel[this.fieldKeyName] || [];
3200
+ this.setValue(rows);
3201
+ });
3202
+ },
3203
+ isDisHandleWidget(widget, ignoreFields) {
3204
+ let flag1 = widget.options.hasOwnProperty("disabled");
3205
+ let flag2 = !ignoreFields || !ignoreFields.includes(widget.options.name);
3206
+ return flag1 && flag2;
3207
+ },
3208
+ setGridDisabled(disabled, ignoreFields) {
3209
+ if (!!this.widget.widgetList) {
3210
+ traverseAllWidgetsNew(this.widget.widgetList, (widget) => {
3211
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3212
+ widget.options.disabled = disabled;
3213
+ }
3214
+ });
3215
+ }
3216
+ if (!!this.widget.buttons) {
3217
+ traverseAllWidgetsNew(this.widget.buttons, (widget) => {
3218
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3219
+ widget.options.disabled = disabled;
3220
+ }
3221
+ });
3222
+ }
3223
+
3224
+ this.loodHandleColumns(this.widget.options.tableColumns, (column) => {
3225
+ if (column.widget) {
3226
+ let widget = column.widget;
3227
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3228
+ widget.options.disabled = disabled;
3229
+ }
3230
+ }
3231
+ let widgetList = column.widgetList;
3232
+ if (widgetList && widgetList.length) {
3233
+ traverseAllWidgetsNew(widgetList, (widget) => {
3234
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3235
+ widget.options.disabled = disabled;
3236
+ }
3237
+ });
3238
+ }
3239
+ });
3240
+
3241
+ let target = this.getGridTable();
3242
+ let { fullColumn } = target.getTableColumn();
3243
+ this.loodHandleColumns(fullColumn, (column) => {
3244
+ if (column.params?.widget) {
3245
+ let widget = column.params.widget;
3246
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3247
+ widget.options.disabled = disabled;
3248
+ }
3249
+ }
3250
+ let widgetList = column.params?.widgetList;
3251
+ if (widgetList && widgetList.length) {
3252
+ traverseAllWidgetsNew(widgetList, (widget) => {
3253
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3254
+ widget.options.disabled = disabled;
3255
+ }
3256
+ });
3257
+ }
3258
+ });
3259
+ let rows = this.getValue();
3260
+ if (rows.length > 0) {
3261
+ rows.forEach((dataRow, rowIndex) => {
3262
+ this.setRowDisabled(disabled, rowIndex, ignoreFields);
3263
+ });
3264
+ }
3265
+ },
3266
+ setRowDisabled(disabled, rowIndex, ignoreFields) {
3267
+ let gsfFWList = [];
3268
+ let fieldListFn = (fw) => {
3269
+ gsfFWList.push(fw);
3270
+ };
3271
+
3272
+ let target = this.getGridTable();
3273
+ let { fullColumn } = target.getTableColumn();
3274
+ this.loodHandleColumns(fullColumn, (column) => {
3275
+ if (column.params?.widget) {
3276
+ let widget = column.params.widget;
3277
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3278
+ gsfFWList.push(widget);
3279
+ }
3280
+ }
3281
+ let widgetList = column.params?.widgetList;
3282
+ if (widgetList && widgetList.length) {
3283
+ traverseAllWidgetsNew(widgetList, (widget) => {
3284
+ if (this.isDisHandleWidget(widget, ignoreFields)) {
3285
+ gsfFWList.push(widget);
3286
+ }
3287
+ });
3288
+ }
3289
+ });
3290
+
3291
+ let rows = this.getValue();
3292
+ let row = rows[rowIndex];
3293
+ gsfFWList.forEach((fw) => {
3294
+ let swRefName = this.getRowRefKey(row, fw.options.name);
3295
+ // let swRefName = fw.options.name + '@row' + this.rowIdData[rowIndex]
3296
+ let foundSW = this.getWidgetRef(swRefName);
3297
+ if (!!foundSW && !!foundSW.setDisabled) {
3298
+ foundSW.setDisabled(disabled);
3299
+ }
3300
+ });
3301
+ },
3302
+ //xk begin
3303
+ disableGridForm() {
3304
+ this.setGridDisabled(true);
3305
+ },
3306
+ enableGridForm() {
3307
+ this.setGridDisabled(false);
3308
+ },
3309
+ //xk end
3310
+ handleNullValue(rows) {
3311
+ let newData = this.createNewTableData(true, false);
3312
+ let keys = Object.keys(newData);
3313
+ if (keys.length) {
3314
+ rows.forEach((row) => {
3315
+ keys.forEach((key) => {
3316
+ if (row[key] === undefined) {
3317
+ row[key] = newData[key];
3318
+ }
3319
+ });
3320
+ });
3321
+ }
3322
+ },
3323
+ },
3324
+ };
3325
+
3326
+ export default modules;