cloud-web-corejs 1.0.54-dev.62 → 1.0.54-dev.620

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