cloud-web-corejs 1.0.54-dev.58 → 1.0.54-dev.580

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