cloud-web-corejs 1.0.54-dev.61 → 1.0.54-dev.610

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