cloud-web-corejs 1.0.54-dev.798 → 1.0.54-dev.799

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 (187) hide show
  1. package/package.json +3 -1
  2. package/src/components/baseTabs/mixins.js +11 -12
  3. package/src/components/bizTab/BizBillActions.vue +129 -0
  4. package/src/components/bizTab/BizTabListPage.vue +391 -0
  5. package/src/components/bizTab/README.md +378 -0
  6. package/src/components/bizTab/billTableUtil.js +48 -0
  7. package/src/components/bizTab/billValidators.js +136 -0
  8. package/src/components/bizTab/bizBillDetailMixin.js +687 -0
  9. package/src/components/bizTab/index.js +24 -0
  10. package/src/components/excelExport/exportFieldDialog.vue +373 -367
  11. package/src/components/excelExport/exportType.js +49 -0
  12. package/src/components/excelExport/mixins.js +1153 -1144
  13. package/src/components/vb-tabs/x-tabs.vue +167 -143
  14. package/src/components/wf/wfUtil.js +327 -292
  15. package/src/components/xform/form-designer/designer.js +56 -8
  16. package/src/components/xform/form-designer/form-widget/container-widget/detail-widget.vue +59 -5
  17. package/src/components/xform/form-designer/form-widget/field-widget/baseAttachment-widget.vue +60 -8
  18. package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +8 -2
  19. package/src/components/xform/form-designer/form-widget/field-widget/select-export-item-button-widget.vue +120 -92
  20. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +63 -94
  21. package/src/components/xform/form-designer/index.vue +0 -1
  22. package/src/components/xform/form-designer/setting-panel/dataSource-setting.vue +397 -397
  23. package/src/components/xform/form-designer/setting-panel/form-dynamicField-setting.vue +602 -602
  24. package/src/components/xform/form-designer/setting-panel/form-setting.vue +13 -13
  25. package/src/components/xform/form-designer/setting-panel/option-items-setting.vue +585 -585
  26. package/src/components/xform/form-designer/setting-panel/property-editor/a-link-editor.vue +1 -1
  27. package/src/components/xform/form-designer/setting-panel/property-editor/a-text-editor.vue +1 -1
  28. package/src/components/xform/form-designer/setting-panel/property-editor/alignType-editor.vue +1 -1
  29. package/src/components/xform/form-designer/setting-panel/property-editor/censusClass-editor.vue +1 -1
  30. package/src/components/xform/form-designer/setting-panel/property-editor/colorClass-editor.vue +1 -1
  31. package/src/components/xform/form-designer/setting-panel/property-editor/commonAttributeEnabled-editor.vue +3 -3
  32. package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +1154 -1154
  33. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail/detail-editor.vue +96 -80
  34. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail-plain/detail-plain-editor.vue +75 -75
  35. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid/colHeight-editor.vue +1 -1
  36. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid/gutter-editor.vue +1 -1
  37. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-height-editor.vue +1 -1
  38. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-offset-editor.vue +1 -1
  39. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-pull-editor.vue +1 -1
  40. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-push-editor.vue +1 -1
  41. package/src/components/xform/form-designer/setting-panel/property-editor/container-grid-col/grid-col-span-editor.vue +4 -4
  42. package/src/components/xform/form-designer/setting-panel/property-editor/container-h5-card/h5-card-editor.vue +124 -124
  43. package/src/components/xform/form-designer/setting-panel/property-editor/container-panel/height-editor.vue +1 -1
  44. package/src/components/xform/form-designer/setting-panel/property-editor/container-panel/width-editor.vue +1 -1
  45. package/src/components/xform/form-designer/setting-panel/property-editor/container-tab/tab-customClass-editor.vue +119 -119
  46. package/src/components/xform/form-designer/setting-panel/property-editor/container-tab/tabClass-editor.vue +45 -45
  47. package/src/components/xform/form-designer/setting-panel/property-editor/container-table/table-dynamicField-editor.vue +344 -344
  48. package/src/components/xform/form-designer/setting-panel/property-editor/container-table-cell/cellHeight-editor.vue +1 -1
  49. package/src/components/xform/form-designer/setting-panel/property-editor/container-table-cell/cellWidth-editor.vue +1 -1
  50. package/src/components/xform/form-designer/setting-panel/property-editor/container-tree/tree-customClass-editor.vue +2 -2
  51. package/src/components/xform/form-designer/setting-panel/property-editor/container-tree-pane/tree-pane-editor.vue +1 -1
  52. package/src/components/xform/form-designer/setting-panel/property-editor/container-vf-dialog/cancelButtonLabel-editor.vue +1 -1
  53. package/src/components/xform/form-designer/setting-panel/property-editor/container-vf-dialog/okButtonLabel-editor.vue +1 -1
  54. package/src/components/xform/form-designer/setting-panel/property-editor/container-vf-dialog/title-editor.vue +1 -1
  55. package/src/components/xform/form-designer/setting-panel/property-editor/container-vf-dialog/width-editor.vue +1 -1
  56. package/src/components/xform/form-designer/setting-panel/property-editor/containerClass-editor.vue +1 -1
  57. package/src/components/xform/form-designer/setting-panel/property-editor/customClass-editor.vue +1 -1
  58. package/src/components/xform/form-designer/setting-panel/property-editor/defaultValue-editor.vue +1 -1
  59. package/src/components/xform/form-designer/setting-panel/property-editor/descriptionsItems-editor.vue +4 -4
  60. package/src/components/xform/form-designer/setting-panel/property-editor/downloadButtonFlag-editor.vue +3 -3
  61. package/src/components/xform/form-designer/setting-panel/property-editor/dropdownFlag-editor.vue +2 -2
  62. package/src/components/xform/form-designer/setting-panel/property-editor/dsName-editor.vue +1 -1
  63. package/src/components/xform/form-designer/setting-panel/property-editor/echartHeight-editor.vue +1 -1
  64. package/src/components/xform/form-designer/setting-panel/property-editor/endPlaceholder-editor.vue +1 -1
  65. package/src/components/xform/form-designer/setting-panel/property-editor/field-accessUrl/accessUrl-editor.vue +2 -2
  66. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaDataType-editor.vue +1 -1
  67. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaMinLevel-editor.vue +50 -50
  68. package/src/components/xform/form-designer/setting-panel/property-editor/field-area-select/areaName-editor.vue +1 -1
  69. package/src/components/xform/form-designer/setting-panel/property-editor/field-autocomplete/autocomplete-vabSearchName-editor.vue +7 -7
  70. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/addTableData-event-editor.vue +84 -84
  71. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/button-type-editor.vue +1 -1
  72. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/clickBindEvent-editor.vue +97 -97
  73. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/form-host-event-editor.vue +188 -188
  74. package/src/components/xform/form-designer/setting-panel/property-editor/field-button/search-dialog-event-editor.vue +237 -237
  75. package/src/components/xform/form-designer/setting-panel/property-editor/field-common/keyName-editor.vue +74 -67
  76. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-dateLimit-editor.vue +4 -4
  77. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-defaultValue-editor.vue +1 -1
  78. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-format-editor.vue +1 -1
  79. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-type-editor.vue +1 -1
  80. package/src/components/xform/form-designer/setting-panel/property-editor/field-date/date-valueFormat-editor.vue +1 -1
  81. package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultTime-editor.vue +1 -1
  82. package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultValue-editor.vue +1 -1
  83. package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-format-editor.vue +1 -1
  84. package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-type-editor.vue +1 -1
  85. package/src/components/xform/form-designer/setting-panel/property-editor/field-date-range/date-range-valueFormat-editor.vue +1 -1
  86. package/src/components/xform/form-designer/setting-panel/property-editor/field-divider/contentPosition-editor.vue +1 -1
  87. package/src/components/xform/form-designer/setting-panel/property-editor/field-dropdown-menu/dropdown-menu-editor.vue +59 -59
  88. package/src/components/xform/form-designer/setting-panel/property-editor/field-echart/echart-bar-editor.vue +11 -11
  89. package/src/components/xform/form-designer/setting-panel/property-editor/field-echart/echart-category-editor.vue +10 -10
  90. package/src/components/xform/form-designer/setting-panel/property-editor/field-echart/echart-pie-editor.vue +12 -12
  91. package/src/components/xform/form-designer/setting-panel/property-editor/field-file-upload/file-upload-fileTypes-editor.vue +44 -44
  92. package/src/components/xform/form-designer/setting-panel/property-editor/field-html-text/htmlContent-editor.vue +29 -29
  93. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import-button-editor.vue +6 -6
  94. package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import2-button-editor.vue +3 -3
  95. package/src/components/xform/form-designer/setting-panel/property-editor/field-number/controlsPosition-editor.vue +1 -1
  96. package/src/components/xform/form-designer/setting-panel/property-editor/field-picture-upload/picture-upload-fileTypes-editor.vue +44 -44
  97. package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-button-editor.vue +115 -115
  98. package/src/components/xform/form-designer/setting-panel/property-editor/field-print-button/print-detail-button-editor.vue +115 -115
  99. package/src/components/xform/form-designer/setting-panel/property-editor/field-rate/highThreshold-editor.vue +1 -1
  100. package/src/components/xform/form-designer/setting-panel/property-editor/field-rate/lowThreshold-editor.vue +1 -1
  101. package/src/components/xform/form-designer/setting-panel/property-editor/field-rate/rate-defaultValue-editor.vue +1 -1
  102. package/src/components/xform/form-designer/setting-panel/property-editor/field-rate/rate-max-editor.vue +1 -1
  103. package/src/components/xform/form-designer/setting-panel/property-editor/field-script/script-editor.vue +4 -4
  104. package/src/components/xform/form-designer/setting-panel/property-editor/field-script-input/script-input-editor.vue +4 -4
  105. package/src/components/xform/form-designer/setting-panel/property-editor/field-static-text/fontSize-editor.vue +1 -1
  106. package/src/components/xform/form-designer/setting-panel/property-editor/field-static-text/textContent-editor.vue +1 -1
  107. package/src/components/xform/form-designer/setting-panel/property-editor/field-status/field-status-editor.vue +3 -3
  108. package/src/components/xform/form-designer/setting-panel/property-editor/field-switch/activeText-editor.vue +1 -1
  109. package/src/components/xform/form-designer/setting-panel/property-editor/field-switch/inactiveText-editor.vue +1 -1
  110. package/src/components/xform/form-designer/setting-panel/property-editor/field-switch/switchWidth-editor.vue +1 -1
  111. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-button-editor.vue +2 -2
  112. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/select-export-item-button-editor.vue +74 -71
  113. package/src/components/xform/form-designer/setting-panel/property-editor/field-table-export-button/table-export-button-editor.vue +3 -3
  114. package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +1 -1
  115. package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-format-editor.vue +1 -1
  116. package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-timeLimit-editor.vue +1 -1
  117. package/src/components/xform/form-designer/setting-panel/property-editor/field-time-range/time-range-defaultValue-editor.vue +1 -1
  118. package/src/components/xform/form-designer/setting-panel/property-editor/field-time-range/time-range-format-editor.vue +1 -1
  119. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabSearch/vabSearchField-editor.vue +2 -2
  120. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabSearch/vabSearchName-editor.vue +2 -2
  121. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload/field-vabUpload-editor.vue +1 -1
  122. package/src/components/xform/form-designer/setting-panel/property-editor/field-vabUpload2/field-vabUpload2-editor.vue +1 -1
  123. package/src/components/xform/form-designer/setting-panel/property-editor/field-vue-page/vue-page-editor.vue +2 -2
  124. package/src/components/xform/form-designer/setting-panel/property-editor/fileMaxSize-editor.vue +1 -1
  125. package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesSelect.vue +176 -176
  126. package/src/components/xform/form-designer/setting-panel/property-editor/formScriptEnabled-editor.vue +2 -1
  127. package/src/components/xform/form-designer/setting-panel/property-editor/formatType-editor.vue +2 -2
  128. package/src/components/xform/form-designer/setting-panel/property-editor/formula-editor.vue +972 -972
  129. package/src/components/xform/form-designer/setting-panel/property-editor/iconClass-editor.vue +1 -1
  130. package/src/components/xform/form-designer/setting-panel/property-editor/label-editor.vue +1 -1
  131. package/src/components/xform/form-designer/setting-panel/property-editor/labelAlign-editor.vue +1 -1
  132. package/src/components/xform/form-designer/setting-panel/property-editor/labelColor-editor.vue +1 -1
  133. package/src/components/xform/form-designer/setting-panel/property-editor/labelIconPosition-editor.vue +1 -1
  134. package/src/components/xform/form-designer/setting-panel/property-editor/labelWidth-editor.vue +1 -1
  135. package/src/components/xform/form-designer/setting-panel/property-editor/limit-editor.vue +1 -1
  136. package/src/components/xform/form-designer/setting-panel/property-editor/max-editor.vue +1 -1
  137. package/src/components/xform/form-designer/setting-panel/property-editor/maxLength-editor.vue +1 -1
  138. package/src/components/xform/form-designer/setting-panel/property-editor/min-editor.vue +1 -1
  139. package/src/components/xform/form-designer/setting-panel/property-editor/minLength-editor.vue +1 -1
  140. package/src/components/xform/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +1 -1
  141. package/src/components/xform/form-designer/setting-panel/property-editor/name-editor.vue +178 -178
  142. package/src/components/xform/form-designer/setting-panel/property-editor/oplog-editor.vue +3 -3
  143. package/src/components/xform/form-designer/setting-panel/property-editor/placeholder-editor.vue +1 -1
  144. package/src/components/xform/form-designer/setting-panel/property-editor/precision-editor.vue +1 -1
  145. package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +6 -6
  146. package/src/components/xform/form-designer/setting-panel/property-editor/requiredHint-editor.vue +1 -1
  147. package/src/components/xform/form-designer/setting-panel/property-editor/rows-editor.vue +1 -1
  148. package/src/components/xform/form-designer/setting-panel/property-editor/space-editor-editor.vue +1 -1
  149. package/src/components/xform/form-designer/setting-panel/property-editor/startPlaceholder-editor.vue +1 -1
  150. package/src/components/xform/form-designer/setting-panel/property-editor/step-editor.vue +1 -1
  151. package/src/components/xform/form-designer/setting-panel/property-editor/styleTableClass-editor.vue +1 -1
  152. package/src/components/xform/form-designer/setting-panel/property-editor/styleTitClass-editor.vue +1 -1
  153. package/src/components/xform/form-designer/setting-panel/property-editor/tempStorage-editor.vue +1 -1
  154. package/src/components/xform/form-designer/setting-panel/property-editor/type-editor.vue +1 -1
  155. package/src/components/xform/form-designer/setting-panel/property-editor/uploadTip-editor.vue +1 -1
  156. package/src/components/xform/form-designer/setting-panel/property-editor/uploadURL-editor.vue +1 -1
  157. package/src/components/xform/form-designer/setting-panel/property-editor/urlValueEnabled-editor.vue +91 -0
  158. package/src/components/xform/form-designer/setting-panel/property-editor/validation-editor.vue +1 -1
  159. package/src/components/xform/form-designer/setting-panel/property-editor/validationHint-editor.vue +1 -1
  160. package/src/components/xform/form-designer/setting-panel/property-editor/widgetWidth-editor.vue +1 -1
  161. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +1 -0
  162. package/src/components/xform/form-designer/widget-panel/index.vue +3 -1
  163. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +55 -13
  164. package/src/components/xform/form-render/container-item/data-table-mixin copy.js +5910 -0
  165. package/src/components/xform/form-render/container-item/data-table-mixin.js +59 -13
  166. package/src/components/xform/form-render/container-item/detail-item.vue +52 -11
  167. package/src/components/xform/form-render/container-item/tab-item.vue +6 -2
  168. package/src/components/xform/form-render/indexMixin.js +56 -16
  169. package/src/components/xform/lang/zh-CN.js +2 -1
  170. package/src/components/xform/utils/attachmentValueUtil.js +239 -0
  171. package/src/components/xform/utils/util.js +27 -0
  172. package/src/mixins/wf/index.js +40 -38
  173. package/src/router/modules/customer.js +50 -0
  174. package/src/store/config/index.js +46 -0
  175. package/src/utils/scrollUtil.js +25 -0
  176. package/src/views/demo/bizTab/bill/billConfig.js +41 -0
  177. package/src/views/demo/bizTab/bill/detail.vue +436 -0
  178. package/src/views/demo/bizTab/bill/list.vue +288 -0
  179. package/src/views/demo/bizTab/bill/productDialog.vue +176 -0
  180. package/src/views/demo/bizTab/simple/billApi.js +123 -0
  181. package/src/views/demo/bizTab/simple/detail.vue +407 -0
  182. package/src/views/demo/bizTab/simple/list.vue +217 -0
  183. package/src/views/demo/bizTab/standalone/index.vue +121 -0
  184. package/src/views/demo/bizTab/wf/billConfig.js +44 -0
  185. package/src/views/demo/bizTab/wf/detail.vue +661 -0
  186. package/src/views/demo/bizTab/wf/list.vue +242 -0
  187. package/src/views/user/outLink/cc_form_view.vue +185 -0
@@ -1,1144 +1,1153 @@
1
- /**version-1.0*/
2
- let tmixins = {};
3
- import { getToken } from "../../utils/auth";
4
- import indexUtil from "../../utils/index.js";
5
- import exportFieldDialog from "./exportFieldDialog.vue";
6
- import { getCellValue } from "@base/components/table/util/index";
7
-
8
- let configUtil = {
9
- baseUrl: process.env.VUE_APP_BASE_API,
10
- getToken,
11
- indexUtil,
12
- };
13
-
14
- function getGrid(that, tableRef) {
15
- let $grid;
16
- if (Array.isArray(that.$refs[tableRef])) {
17
- $grid = that.$refs[tableRef][0];
18
- } else {
19
- $grid = that.$refs[tableRef];
20
- }
21
- return $grid;
22
- }
23
-
24
- (function () {
25
- tmixins = {
26
- props: ["param"],
27
- components: {
28
- exportFieldDialog,
29
- },
30
- data() {
31
- return {
32
- showImportDialog: false,
33
- showImportDialog2: false,
34
- falseValue: false,
35
- fileRaw: false,
36
- tTotalPage: 0,
37
- tTotalSize: 0,
38
- doneSize: 0,
39
- CURRENT_PREFIX: "",
40
- option: {},
41
- uuid: "",
42
- fileRows: [],
43
- title: this.$t2("导出", "components.excelExport.title"),
44
- tableTarget: null,
45
- showContent: true,
46
- percentageNum: 0,
47
- exportGrid: {
48
- className: "list-table",
49
- resizable: true,
50
- height: 120,
51
- stripe: true,
52
- highlightCurrentRow: true,
53
- highlightHoverRow: true,
54
- columns: [
55
- {
56
- field: "name",
57
- minWidth: 140,
58
- title: this.$t2("文件名", "components.excelExport.fileName"),
59
- sortable: true,
60
- slots: {
61
- default: ({ row }) => {
62
- return row.title + "-" + row.uuid;
63
- },
64
- },
65
- },
66
- {
67
- field: "fileSize",
68
- minWidth: 140,
69
- title: this.$t2("大小", "components.excelExport.fileSize"),
70
- sortable: true,
71
- },
72
- {
73
- field: "oper",
74
- width: 140,
75
- fixed: "right",
76
- title: "",
77
- sortable: false,
78
- slots: {
79
- default: "row_edit",
80
- },
81
- },
82
- ],
83
- },
84
- excTime: 0,
85
- showExportFieldDialog: false,
86
- leafColumns: [],
87
- columns: [],
88
- queryParam: {},
89
- isMinimize: false,
90
- // 定时器必须放实例上:模块级共享会导致并发导出互相清除对方的定时器
91
- exportTimer: null,
92
- countTimer: null,
93
- exportError: false,
94
- };
95
- },
96
- created() {},
97
- mounted() {
98
- // this.exc();
99
- },
100
- beforeDestroy() {
101
- this.clearExportTimer();
102
- this.unlockMenu();
103
- },
104
- methods: {
105
- exc() {
106
- this.option = this.param;
107
- let $grid = getGrid(this.option.vue, this.option.targetRef);
108
- let datas = [];
109
- if (
110
- this.option.type === "selected" ||
111
- this.option.type === "exportItem"
112
- ) {
113
- datas = $grid.getCheckboxRecords(true);
114
- if (!datas.length) {
115
- this.$baseAlert(
116
- this.$t2("请选择导出的数据", "components.excelExport.warmMsg1")
117
- );
118
- this.param.destroyComponent();
119
- return;
120
- }
121
- } else if (this.option.type === "current") {
122
- datas = $grid.getTableData().fullData;
123
- if (!datas.length) {
124
- this.$baseAlert(
125
- this.$t2("不存在可导出的数据", "components.excelExport.warmMsg2")
126
- );
127
- this.param.destroyComponent();
128
- return;
129
- }
130
- }
131
-
132
- this.isMinimize = false;
133
- this.showExportFieldDialog = true;
134
- },
135
- handleMinimize() {
136
- let result = !this.showImportDialog2;
137
- this.isMinimize = !result;
138
- this.showImportDialog2 = result;
139
- },
140
- dialogClose2() {
141
- if (this.isMinimize) return;
142
- let loadingObj = window.$vueRoot.$baseLoading({
143
- target: document.body,
144
- background: "unset",
145
- });
146
-
147
- this.$emit("update:visiable", false);
148
- this.clearExportTimer();
149
- // this.showImportDialog2 = false;
150
- this.showExportFieldDialog = false;
151
- // this.showContent = false;
152
- setTimeout(() => {
153
- this.param.destroyComponent(loadingObj);
154
- }, 0);
155
- },
156
- dialogPrimary2() {
157
- // this.showUserDialog=false
158
- this.$emit("confirm");
159
- this.$emit("close");
160
- this.clearExportTimer();
161
- },
162
- startProcess() {
163
- this.lockMenu();
164
- this.createCountTimer();
165
- this.tableTarget = getGrid(this.option.vue, this.option.targetRef);
166
-
167
- //获取查询条件
168
- let originOption = this.tableTarget.params.originOption;
169
- this.queryParam = this.$baseLodash.cloneDeep(
170
- originOption.param() || {}
171
- );
172
-
173
- let that = this;
174
- let options = this.option;
175
- let title = options.title
176
- ? this.$t1(options.title)
177
- : this.$t2("导出", "components.excelExport.title");
178
- if (!options.prefix && options.prefix !== "") {
179
- let originOption = this.tableTarget.params.originOption;
180
- let path = originOption.exportPath || originOption.path;
181
- if (typeof path === "function") path = path();
182
- if (path && typeof path === "string" && path !== "#") {
183
- let os = path.split("/");
184
- if (path.indexOf("http://") >= 0 || path.indexOf("https://") >= 0) {
185
- options.prefix = "/" + os[3];
186
- } else {
187
- options.prefix = "/" + os[1];
188
- }
189
- }
190
- }
191
- if (!options.prefix) {
192
- this.abortExport(
193
- this.$t1("无法确定导出服务前缀,请在导出配置中指定 prefix")
194
- );
195
- this.unlockMenu();
196
- return;
197
- }
198
- this.CURRENT_PREFIX = options.prefix;
199
-
200
- this.title = title;
201
- that.tTotalPage = 0;
202
- that.tTotalSize = 0;
203
- that
204
- .createExcelFile()
205
- .then((resultMsg) => {
206
- if (resultMsg.type === "success") {
207
- let aObj = resultMsg.objx;
208
- that.uuid = aObj.uuid;
209
- that.nowDate = aObj.nowDate;
210
- that.ippaaapp = aObj.ippaaapp;
211
- setTimeout(function () {
212
- /*num = 1;
213
- loopToDo(0, num);*/
214
- that.handleLoopToDo();
215
- }, 300);
216
- } else {
217
- that.abortExport();
218
- that.showImportDialog = false;
219
- that.showImportDialog2 = false;
220
- }
221
- })
222
- .catch((error) => {
223
- console.error(error);
224
- that.abortExport(that.$t1("创建导出文件失败,导出已中止"));
225
- that.showImportDialog = false;
226
- that.showImportDialog2 = false;
227
- });
228
- },
229
- getExportPageSize() {
230
- let pageSize = Math.min(this.option.pageSize || 1000, 1000);
231
- let showImageAtTable = this.option.showImageAtTable || false;
232
- let hasExportImage = !!this.leafColumns.find((item) => {
233
- let exportType = item?.params?.exportType;
234
- return exportType === "Image";
235
- });
236
- let hasExportImage2 = !!this.leafColumns.find((item) => {
237
- let exportType = item?.params?.exportType;
238
- return exportType === "Image2";
239
- });
240
- if (hasExportImage || (hasExportImage2 && showImageAtTable)) {
241
- pageSize = Math.min(pageSize, 150);
242
- }
243
- return pageSize;
244
- },
245
- hadleMergeExcel(pPageSize) {
246
- let that = this;
247
- let title = this.title;
248
- let options = this.option;
249
- // let pPageSize = this.getExportPageSize();
250
- let limitFileSize = options.limitFileSize || 100000;
251
- let limitThreadNum = options.limitThreadNum || 5;
252
- let totalPages = this.tTotalPage || 1;
253
-
254
- let kTotalPages = parseInt(limitFileSize / pPageSize);
255
-
256
- let fileNum = parseInt(totalPages / kTotalPages);
257
- if (totalPages % kTotalPages !== 0) {
258
- fileNum = fileNum + 1;
259
- }
260
-
261
- let currentIndex = 0;
262
- let mtExcedNum = 0;
263
- let mtExcedSuccessNum = 0;
264
- const loopDo = () => {
265
- let startPage = currentIndex + 1;
266
- if (mtExcedNum < fileNum) {
267
- mtExcedNum++;
268
-
269
- let endPage = currentIndex + kTotalPages;
270
- if (endPage > totalPages) {
271
- endPage = totalPages;
272
- }
273
- if (startPage > endPage) {
274
- // 页码越界属异常状态,中止并不再发出非法页码的合并请求
275
- that.abortExport();
276
- return;
277
- }
278
- currentIndex = endPage;
279
-
280
- that
281
- .mergeExcel(startPage, endPage)
282
- .then(function (resultMsg3) {
283
- if (resultMsg3.type === "success") {
284
- mtExcedSuccessNum++;
285
- let fileInfo = resultMsg3.objx;
286
- let fileName = fileInfo.fileName;
287
- let fileSize = fileInfo.fileSize;
288
-
289
- let dataMap = {};
290
- dataMap["startPage"] = startPage;
291
- dataMap["endPage"] = endPage;
292
- dataMap["title"] = title;
293
- dataMap["uuid"] = fileName;
294
- dataMap["fileSize"] = fileSize;
295
- // fileRows.push(dataMap);
296
-
297
- that.$refs["exportTable"].insertAt(dataMap, -1);
298
-
299
- let fileSizeStr = fileSize;
300
-
301
- // that.fileRows.push(dataMap);
302
- if (mtExcedNum < fileNum) {
303
- loopDo();
304
- } else if (
305
- mtExcedNum >= fileNum &&
306
- mtExcedSuccessNum >= fileNum
307
- ) {
308
- setTimeout(function () {
309
- that.percentageNum = parseInt(100);
310
- }, 100);
311
- that.clearExportTimer();
312
- } else if (mtExcedSuccessNum >= fileNum) {
313
- setTimeout(function () {
314
- that.percentageNum = parseInt(100);
315
- }, 100);
316
- that.clearExportTimer();
317
- }
318
- } else {
319
- that.abortExport();
320
- }
321
- })
322
- .catch(function (e) {
323
- console.error(e);
324
- that.abortExport(that.$t1("文件合并异常,导出已中止"));
325
- });
326
- // 注意:此处不能同步 clearExportTimer,否则计时统计会在合并完成前被提前停掉
327
- }
328
- };
329
- loopDo();
330
- },
331
- handleLoopToDo() {
332
- let that = this;
333
- let uuid;
334
- let num = 0;
335
- let title = this.title;
336
-
337
- let options = this.option;
338
-
339
- let pPageSize = this.getExportPageSize();
340
- let limitFileSize = options.limitFileSize || 100000;
341
- let limitThreadNum = options.limitThreadNum || 5;
342
-
343
- /**处理返回值*/
344
- this.doneSize = 0;
345
- let excedNum = 0;
346
- let cSize = this.doneSize;
347
-
348
- let handleData = function (resultMsg) {
349
- let pageNumber = resultMsg.objx.pageNumber || 1;
350
- that
351
- .addExcelData({
352
- rows: resultMsg.objx.records,
353
- pageNumber: pageNumber,
354
- })
355
- .then(function (resultMsg2) {
356
- let data = resultMsg.objx;
357
- let total = data.total;
358
-
359
- let pageNumber = data.pageNumber || 1;
360
- let totalPages = that.tTotalPage || 1;
361
- if (resultMsg2.type === "success") {
362
- excedNum++;
363
- let pageNumber = data.pageNumber || 1;
364
- let k = (excedNum * 100) / totalPages;
365
- if (k > 0 && k < 1) {
366
- k = 1;
367
- }
368
- if (k > 100) k = 100;
369
- let cTotal = that.tTotalSize;
370
- let pageSize = data.pageSize;
371
- // let datas = data.records;
372
- let size = data.records.length;
373
- cSize = cSize + size;
374
-
375
- let ttNum = cSize + "/" + cTotal;
376
- let percentageStr = parseInt(k) + "%";
377
-
378
- let percentageNum = k;
379
- if (percentageNum >= 100) {
380
- percentageNum = 99;
381
- }
382
- // that.$set(that, "doneSize", parseInt(cSize));
383
- // that.$set(that, "percentageNum", parseInt(percentageNum));
384
-
385
- that.doneSize = parseInt(cSize);
386
- that.percentageNum = parseInt(percentageNum);
387
-
388
- if (totalPages === 0 || excedNum >= totalPages) {
389
- that.hadleMergeExcel(data.pageSize);
390
- return;
391
-
392
- /*let kTotalPages = parseInt(limitFileSize / data.pageSize);
393
-
394
- let fileNum = parseInt(totalPages / kTotalPages);
395
- if (totalPages % kTotalPages !== 0) {
396
- fileNum = fileNum + 1;
397
- }
398
-
399
- let currentIndex = 0;
400
- let excingNum = 0;
401
- let mtExcedNum = 0;
402
- let mtExcedSuccessNum = 0;
403
-
404
- let fileRows = [];
405
-
406
- setTimeout(function () {
407
- let startPage = currentIndex + 1;
408
- if (mtExcedNum < fileNum) {
409
- if (excingNum >= limitThreadNum) return false;
410
- excingNum++;
411
- mtExcedNum++;
412
-
413
- let endPage = currentIndex + kTotalPages;
414
- if (endPage > totalPages) {
415
- endPage = totalPages;
416
- }
417
- if (startPage > endPage) {
418
- that.clearExportTimer();
419
- }
420
- currentIndex = endPage;
421
-
422
- that.mergeExcel(startPage, endPage).then(function (resultMsg3) {
423
- if (resultMsg3.type === "success") {
424
- excingNum--;
425
- mtExcedSuccessNum++;
426
- let fileInfo = resultMsg3.objx;
427
- let fileName = fileInfo.fileName;
428
- let fileSize = fileInfo.fileSize;
429
-
430
- let dataMap = {};
431
- dataMap["startPage"] = startPage;
432
- dataMap["endPage"] = endPage;
433
- dataMap["title"] = title;
434
- dataMap["uuid"] = fileName;
435
- dataMap["fileSize"] = fileSize;
436
- // fileRows.push(dataMap);
437
-
438
- that.$refs["exportTable"].insertAt(
439
- dataMap, -1);
440
-
441
- let fileSizeStr = fileSize;
442
-
443
- // that.fileRows.push(dataMap);
444
-
445
- if (mtExcedNum >= fileNum && mtExcedSuccessNum >= fileNum) {
446
- setTimeout(function () {
447
- that.percentageNum =
448
- parseInt(100);
449
- }, 100);
450
- that.clearExportTimer();
451
- } else if (mtExcedSuccessNum >= fileNum) {
452
- setTimeout(function () {
453
- that.percentageNum = parseInt(100);
454
- }, 100);
455
- that.clearExportTimer();
456
- }
457
- } else {
458
- that.clearExportTimer();
459
- }
460
- }).catch(function (e) {
461
- console.error(e);
462
- that.clearExportTimer();
463
- });
464
- that.clearExportTimer();
465
- }
466
- }, 100);*/
467
- return false;
468
- }
469
- } else {
470
- that.abortExport();
471
- }
472
- })
473
- .catch(function (e) {
474
- console.error(e);
475
- that.abortExport(that.$t1("导出数据写入失败,导出已中止"));
476
- });
477
- };
478
-
479
- let waitReqNum = 0;
480
- let promise;
481
- let loopToDo = function (flag, pageNumber, retryCount = 0) {
482
- let maxWaitNum = limitThreadNum;
483
- let nowDate = options.nowDate;
484
- if (flag === 1) {
485
- /*if (num > that.tTotalPage) {
486
- let size = page.records.length;
487
- if (size === 0 || page.totalPages === 0 || (page.pageNumber >= page.totalPages)) {
488
- that.clearExportTimer();
489
- return;
490
- }
491
- }*/
492
- } else {
493
- waitReqNum = 0;
494
- }
495
-
496
- let target = that.tableTarget;
497
- let originOption = target.params.originOption;
498
- let url = originOption.exportPath || originOption.path;
499
-
500
- // let params = originOption.param() || {};
501
- let params = that.queryParam;
502
- let aParam = {
503
- current: pageNumber,
504
- size: pPageSize,
505
- nowDate: nowDate,
506
- searchCount: flag !== 1,
507
- };
508
- let cpParam;
509
- if (originOption.vform === true) {
510
- params.conditions = params.conditions || {};
511
- cpParam = params.conditions;
512
- } else {
513
- cpParam = params;
514
- }
515
- Object.assign(cpParam, aParam);
516
-
517
- if (!originOption.exportAjax) {
518
- let turl = url.replace("searchCount=false", "1=1");
519
- let finaParams = params;
520
- if (originOption.paramHandle) {
521
- finaParams = originOption.paramHandle
522
- ? originOption.paramHandle(params) || {}
523
- : {};
524
- }
525
- promise = that.$commonHttp({
526
- aes: originOption.aes || false,
527
- url: turl,
528
- method: "post",
529
- data: finaParams,
530
- modal: false,
531
- queryCreateInfo: originOption.queryCreateInfo,
532
- addCreateInfo: originOption.addCreateInfo,
533
- });
534
- } else {
535
- promise = originOption.exportAjax(aParam, options);
536
- }
537
-
538
- promise
539
- .then(function (resultMsg) {
540
- if (resultMsg.type === "success") {
541
- let objx = resultMsg.objx;
542
- objx.pageNumber = objx.current || 1;
543
- objx.totalPages = objx.pages || 1;
544
- objx.pageSize = objx.size;
545
- let size = objx.records.length;
546
- if (flag === 0) {
547
- that.tTotalPage = objx.pages;
548
- // that.tTotalSize = objx.total;
549
- setTimeout(function () {
550
- that.$set(that, "tTotalSize", objx.total);
551
- }, 0);
552
- let tTotalPage = objx.pages;
553
- let tTotalSize = objx.total;
554
- let ttNum = 0 + "/" + objx.total;
555
-
556
- let opNum = limitFileSize;
557
- let kTotalPages = parseInt(opNum / objx.size);
558
-
559
- let fileNum = parseInt(tTotalPage / kTotalPages);
560
- if (tTotalPage % kTotalPages !== 0) {
561
- fileNum = fileNum + 1;
562
- }
563
- if (
564
- size > 0 ||
565
- objx.totalPages > 0 ||
566
- objx.pageNumber < objx.totalPages
567
- ) {
568
- that.exportTimer = setInterval(function () {
569
- if (waitReqNum < maxWaitNum && num < tTotalPage) {
570
- waitReqNum++;
571
- num++;
572
- let pageNumber = num;
573
- loopToDo(1, pageNumber);
574
- }
575
- if (num >= tTotalPage) {
576
- // 所有页已派发,停掉调度器(数据写入完成与否由 handleData 计数判断)
577
- clearInterval(that.exportTimer);
578
- that.exportTimer = null;
579
- }
580
- }, 100);
581
- } else {
582
- clearInterval(that.exportTimer);
583
- that.exportTimer = null;
584
- }
585
- } else {
586
- if (waitReqNum > 0) waitReqNum--;
587
- }
588
-
589
- setTimeout(function () {
590
- handleData(resultMsg, flag);
591
- }, 1);
592
- } else {
593
- // 单页拉取失败自动重试一次;仍失败则中止(缺页合并会静默丢数据,必须中止)
594
- if (retryCount < 1) {
595
- setTimeout(function () {
596
- loopToDo(flag, pageNumber, retryCount + 1);
597
- }, 500);
598
- } else {
599
- that.abortExport();
600
- }
601
- }
602
- })
603
- .catch(function (e) {
604
- console.error(e);
605
- if (retryCount < 1) {
606
- setTimeout(function () {
607
- loopToDo(flag, pageNumber, retryCount + 1);
608
- }, 500);
609
- } else {
610
- that.abortExport(
611
- that.$t1("第{n}页数据拉取失败,导出已中止", {
612
- n: pageNumber,
613
- })
614
- );
615
- }
616
- });
617
- };
618
-
619
- num = 1;
620
- loopToDo(0, num);
621
- },
622
- createExcelFile(loading) {
623
- let url1 = this.CURRENT_PREFIX + "/excel/createExcelTemplate";
624
- let datas = this.getHeadTitleJson();
625
- return this.$http({
626
- url: url1,
627
- method: "post",
628
- headers: {
629
- "Content-Type": "application/json;charset=utf-8",
630
- },
631
- data: datas,
632
- modal: loading || false,
633
- isLoading: loading,
634
- });
635
- },
636
- /*getExportTitleJson() {
637
- let target = this.tableTarget;
638
- // let columns = target.getColumns();
639
- let columns = this.columns;
640
- let titles = [];
641
- columns.forEach(column => {
642
- if (column.title) {
643
- // titles.push(column.title)
644
- titles.push({
645
- colspan: 1,
646
- rowspan: 1,
647
- title: column.title
648
- });
649
- }
650
- });
651
- return [titles];
652
- },*/
653
- computeRealColSpan(columns) {
654
- // 深拷贝避免修改原数据(可选)
655
- // const result = JSON.parse(JSON.stringify(columns));
656
-
657
- function traverse(node) {
658
- if (!node.children || node.children.length === 0) {
659
- // 叶子节点:realColSpan = 原始 colSpan
660
- node.realColSpan = node.colSpan || 1;
661
- } else {
662
- // 非叶子节点:递归处理子节点,然后求和
663
- let sum = 0;
664
- for (const child of node.children) {
665
- traverse(child);
666
- sum += child.realColSpan;
667
- }
668
- node.realColSpan = sum;
669
- }
670
- }
671
-
672
- for (const col of columns) {
673
- traverse(col);
674
- }
675
-
676
- return columns;
677
- },
678
- getHeadTitleJson() {
679
- let that = this;
680
- let target = this.tableTarget;
681
- // let columns = target.getTableColumn().collectColumn;
682
- let columns = this.columns;
683
-
684
- this.computeRealColSpan(columns);
685
-
686
- let maxRowNum = 0;
687
- let loop = function (column, n) {
688
- if (column.children && column.children.length > 0) {
689
- let num = n + 1;
690
- column.children.forEach((child) => {
691
- return loop(child, num);
692
- });
693
- } else {
694
- let num = n;
695
- if (num > maxRowNum) maxRowNum = num;
696
- }
697
- };
698
-
699
- columns.forEach((column) => {
700
- if (column.title) {
701
- loop(column, 0);
702
- }
703
- });
704
- maxRowNum = maxRowNum + 1;
705
-
706
- let titleArr = [];
707
- let columnsArr = [columns];
708
- for (let i = 0; i < maxRowNum; i++) {
709
- let contents = [];
710
- let items = columnsArr[i];
711
- let nextArr = [];
712
- let colspan = 1;
713
- let rowspan = 1;
714
- items.forEach((column, index) => {
715
- if (column.title) {
716
- if (column.children && column.children.length > 0) {
717
- nextArr = nextArr.concat(column.children);
718
- }
719
-
720
- contents.push({
721
- colspan: column.realColSpan,
722
- rowspan: column.rowSpan,
723
- title:
724
- column.title !== null && column.title !== undefined
725
- ? column.title
726
- : "",
727
- });
728
- }
729
- });
730
- titleArr.push(contents);
731
- if (nextArr.length > 0) columnsArr.push(nextArr);
732
- }
733
- return titleArr;
734
- },
735
- addExcelData(opts, loading) {
736
- let target = opts.target;
737
- let pageNumber = opts.pageNumber || 1;
738
- let callback = opts.callback;
739
- let datas = this.getExcelData(opts.rows);
740
- let cUUid = this.uuid;
741
- let ippaaapp = this.ippaaapp;
742
- let url1 =
743
- this.CURRENT_PREFIX +
744
- "/excel/appendExcelData?uuid=" +
745
- cUUid +
746
- "&ippaaapp=" +
747
- ippaaapp +
748
- "&pageNumber=" +
749
- pageNumber;
750
- return this.$http({
751
- url: url1,
752
- method: "post",
753
- headers: {
754
- "Content-Type": "application/json;charset=utf-8",
755
- },
756
- data: datas,
757
- modal: loading || false,
758
- isLoading: loading || false,
759
- });
760
- },
761
- mergeExcel(startPage, endPage, loading) {
762
- let url1 =
763
- this.CURRENT_PREFIX +
764
- "/excel/mergeExcel?uuid=" +
765
- this.uuid +
766
- "&ippaaapp=" +
767
- this.ippaaapp;
768
- return this.$http({
769
- url: url1 + "&startPage=" + startPage + "&endPage=" + endPage,
770
- method: "post",
771
- modal: loading || false,
772
- isLoading: loading || false,
773
- });
774
- },
775
- createCountTimer() {
776
- this.excTime = 0;
777
- let beginTime = new Date().getTime();
778
- this.countTimer = setInterval(() => {
779
- let nowTime = new Date().getTime();
780
- let diffTime = (nowTime - beginTime) / 1000;
781
- this.$set(this, "excTime", this.$baseLodash.round(diffTime, 2));
782
- }, 100);
783
- },
784
- clearExportTimer() {
785
- if (this.exportTimer) clearInterval(this.exportTimer);
786
- if (this.countTimer) clearInterval(this.countTimer);
787
- this.exportTimer = null;
788
- this.countTimer = null;
789
- },
790
- /**
791
- * 中止导出:停止全部定时器并把进度条置为错误态。
792
- * @param {String} [msg] 需要额外弹给用户的提示;服务端已 toast 过的失败不传,避免重复提示。
793
- */
794
- abortExport(msg) {
795
- this.clearExportTimer();
796
- this.exportError = true;
797
- if (msg) this.$baseAlert(msg);
798
- },
799
- isPicture: function (suffix) {
800
- if (!suffix || suffix === "") {
801
- return false;
802
- }
803
- suffix = suffix.toLowerCase();
804
- let fileTypeMap = {
805
- jpg: true,
806
- jpeg: true,
807
- png: true,
808
- // gif: true,
809
- bmp: true,
810
- mpg: true,
811
- };
812
-
813
- let type = fileTypeMap[suffix];
814
- if (undefined === type) {
815
- return false;
816
- }
817
-
818
- return true;
819
- },
820
- /**
821
- * 导出取值快路径:优先纯函数取值(filterVal → formatter → 原始字段),
822
- * 只有真正配置了自定义渲染(renderCell/函数型 slots.default)的列才走
823
- * getCellValue vNode 挂载渲染兜底 —— 后者每个单元格要挂载一次 Vue
824
- * 组件再爬 DOM,是导出耗时的大头。
825
- * 字符串型 slots.default(具名插槽,如 xform 的 "widget")由 getCellValue
826
- * 从 grid 作用域插槽解析后渲染;解析不到时其内部回退原始字段。
827
- */
828
- getExportCellValue(params) {
829
- let column = params.column;
830
- if (column.slots && typeof column.slots.filterVal === "function") {
831
- return column.slots.filterVal(params);
832
- }
833
- let slotDefault = column.slots && column.slots.default;
834
- let hasRenderFn =
835
- !!column.renderCell ||
836
- typeof slotDefault === "function" ||
837
- typeof slotDefault === "string";
838
- if (!hasRenderFn) {
839
- let cellValue = params.row[column.field];
840
- if (typeof column.formatter === "function") {
841
- return column.formatter({
842
- cellValue,
843
- row: params.row,
844
- column,
845
- });
846
- }
847
- return cellValue;
848
- }
849
- return getCellValue(params);
850
- },
851
- getExcelData(rows) {
852
- let that = this;
853
-
854
- let showImageAtTable = this.option.showImageAtTable || false;
855
- // let target = this.option.vue.$refs[this.option.targetRef];
856
- let target = getGrid(this.option.vue, this.option.targetRef);
857
- let $table = target.$refs.xTable;
858
-
859
- // let columns = target.getColumns();
860
- let columns = this.leafColumns.filter(
861
- (column) => !column.params?.exportDisabled
862
- );
863
-
864
- let arr = [];
865
- let contents;
866
- let params;
867
- let resultStr;
868
- // 批量取值期间复用 vNode 渲染的临时实例,结束时统一销毁
869
- rows.forEach(function (row, index) {
870
- contents = [];
871
- columns.forEach((column) => {
872
- if (column.title) {
873
- params = {
874
- $table: $table,
875
- row: row,
876
- rowIndex: index,
877
- $rowIndex: index,
878
- column: column,
879
- // columnIndex: 0,
880
- // $columnIndex: 0,
881
- // _columnIndex
882
- };
883
- let exportType = column.params?.exportType;
884
- let exportVal =
885
- column.params && column.params.exportVal
886
- ? column.params.exportVal
887
- : null;
888
- if (exportVal) {
889
- resultStr = exportVal(params);
890
- } else if (exportType === "Number") {
891
- resultStr = that.getExportCellValue(params);
892
- if (
893
- resultStr !== null &&
894
- resultStr !== undefined &&
895
- resultStr !== "" &&
896
- !(resultStr + "").startsWith("[EXPNUM]")
897
- ) {
898
- resultStr = "[EXPNUM]" + resultStr;
899
- }
900
- } else if (
901
- exportType === "Image" ||
902
- (showImageAtTable && exportType === "Image2")
903
- ) {
904
- resultStr = that.getExportCellValue(params);
905
- let attachments = row[column.field];
906
- if (attachments) {
907
- if (Array.isArray(attachments)) {
908
- let items = attachments.filter((item) =>
909
- that.isPicture(item.extension)
910
- );
911
- if (items.length > 0) {
912
- resultStr =
913
- "[EXPIMG]" +
914
- items
915
- .map((item) => {
916
- let url = item.large || item.medium;
917
- return item.domain + url;
918
- })
919
- .join(",");
920
- } else {
921
- resultStr = null;
922
- }
923
- } else {
924
- if (
925
- that.isPicture(
926
- that.$commonFileUtil.getFileSuffix(resultStr)
927
- )
928
- ) {
929
- if (
930
- resultStr !== null &&
931
- resultStr !== undefined &&
932
- resultStr !== "" &&
933
- !(resultStr + "").startsWith("[EXPIMG]")
934
- ) {
935
- resultStr = "[EXPIMG]" + resultStr;
936
- }
937
- } else {
938
- resultStr = null;
939
- }
940
- }
941
- } else {
942
- resultStr = null;
943
- }
944
- } else {
945
- resultStr = that.getExportCellValue(params);
946
- }
947
- contents.push(resultStr);
948
- resultStr = null;
949
- }
950
- });
951
- arr.push(contents);
952
- });
953
- return arr;
954
- },
955
- exportAll(row) {
956
- let cUUid = encodeURIComponent(row.uuid);
957
- let ippaaapp = this.ippaaapp;
958
- let fileName = row.title;
959
- let fileUrl =
960
- configUtil.baseUrl +
961
- this.CURRENT_PREFIX +
962
- "/excel/download?uuid=" +
963
- cUUid +
964
- "&ippaaapp=" +
965
- ippaaapp;
966
-
967
- function downLoadFile2() {
968
- let params = {
969
- n: fileName,
970
- };
971
- params["access_token"] = configUtil.getToken();
972
-
973
- let form = document.createElement("form");
974
-
975
- let randomNum =
976
- new Date().valueOf() + Math.floor(Math.random() * 1000000);
977
- let formId = "formId-" + randomNum;
978
- let formName = "formName-" + randomNum;
979
-
980
- form.id = formId;
981
- form.name = formName;
982
- form.target = "_blank";
983
- document.body.appendChild(form);
984
- for (let obj in params) {
985
- if (params.hasOwnProperty(obj)) {
986
- let input = document.createElement("input");
987
- input.type = "hidden";
988
- input.name = obj;
989
- input.value = params[obj];
990
- form.appendChild(input);
991
- }
992
- }
993
- form.method = "post"; //请求方式
994
- form.action = fileUrl;
995
- form.submit();
996
- document.body.removeChild(form);
997
- }
998
-
999
- downLoadFile2();
1000
- },
1001
- startProcess2(datas) {
1002
- this.tableTarget = getGrid(this.option.vue, this.option.targetRef);
1003
- let that = this;
1004
- let options = this.option;
1005
- let title =
1006
- options.title || this.$t2("导出", "components.excelExport.title");
1007
- if (!options.prefix && options.prefix !== "") {
1008
- let originOption = this.tableTarget.params.originOption;
1009
- let path = originOption.exportPath || originOption.path;
1010
- if (typeof path === "function") path = path();
1011
- if (path && typeof path === "string" && path !== "#") {
1012
- let os = path.split("/");
1013
- if (path.indexOf("http://") >= 0 || path.indexOf("https://") >= 0) {
1014
- options.prefix = "/" + os[3];
1015
- } else {
1016
- options.prefix = "/" + os[1];
1017
- }
1018
- }
1019
- }
1020
- if (!options.prefix) {
1021
- this.$baseAlert(
1022
- this.$t1("无法确定导出服务前缀,请在导出配置中指定 prefix")
1023
- );
1024
- return;
1025
- }
1026
- this.CURRENT_PREFIX = options.prefix;
1027
-
1028
- let handleData = function () {
1029
- let total = datas.length;
1030
- that
1031
- .addExcelData(
1032
- {
1033
- rows: datas,
1034
- pageNumber: 1,
1035
- },
1036
- true
1037
- )
1038
- .then((resultMsg2) => {
1039
- if (resultMsg2.type === "success") {
1040
- setTimeout(() => {
1041
- that.mergeExcel(1, 1, true).then((resultMsg3) => {
1042
- if (resultMsg3.type === "success") {
1043
- let fileInfo = resultMsg3.objx;
1044
- let fileName = fileInfo.fileName;
1045
- let fileSize = fileInfo.fileSize;
1046
-
1047
- let dataMap = {};
1048
- dataMap["startPage"] = 1;
1049
- dataMap["endPage"] = 1;
1050
- dataMap["title"] = title;
1051
- dataMap["uuid"] = fileName;
1052
- dataMap["fileSize"] = fileSize;
1053
- that.exportAll(dataMap);
1054
- }
1055
- });
1056
- }, 0);
1057
- }
1058
- });
1059
- };
1060
- that.createExcelFile(true).then((resultMsg) => {
1061
- if (resultMsg.type === "success") {
1062
- let aObj = resultMsg.objx;
1063
- that.uuid = aObj.uuid;
1064
- that.nowDate = aObj.nowDate;
1065
- that.ippaaapp = aObj.ippaaapp;
1066
- setTimeout(() => {
1067
- handleData();
1068
- }, 0);
1069
- }
1070
- });
1071
- },
1072
- closeExportFieldDialog() {
1073
- this.dialogClose2();
1074
- },
1075
- confirmExportFieldDialog({ columns, leafColumns }) {
1076
- this.columns = columns;
1077
- this.leafColumns = leafColumns;
1078
- let flag =
1079
- this.option.type === "selected" || this.option.type === "current";
1080
- if (!flag) {
1081
- this.showImportDialog2 = true;
1082
- }
1083
- this.$nextTick(() => {
1084
- if (flag) {
1085
- let $grid = getGrid(this.option.vue, this.option.targetRef);
1086
- let datas = [];
1087
- if (this.option.type === "selected") {
1088
- datas = $grid.getCheckboxRecords(true);
1089
- if (!datas.length) {
1090
- this.$baseAlert(
1091
- this.$t2(
1092
- "请选择导出的数据",
1093
- "components.excelExport.warmMsg1"
1094
- )
1095
- );
1096
- return;
1097
- }
1098
- } else if (this.option.type === "current") {
1099
- datas = $grid.getTableData().fullData;
1100
- if (!datas.length) {
1101
- this.$baseAlert(
1102
- this.$t2(
1103
- "不存在可导出的数据",
1104
- "components.excelExport.warmMsg2"
1105
- )
1106
- );
1107
- return;
1108
- }
1109
- }
1110
- this.startProcess2(datas);
1111
- } else {
1112
- this.startProcess();
1113
- }
1114
- });
1115
- },
1116
- lockMenu() {
1117
- let vueTarget = window.$vueRoot;
1118
- let path = vueTarget.$route.path;
1119
- let visitedViews = vueTarget.$store.state.tagsView.visitedViews;
1120
- if (visitedViews) {
1121
- let currentItem = visitedViews.find((item) => item.path === path);
1122
- if (currentItem && !currentItem.meta.affix) {
1123
- this.$set(currentItem.meta, "affix", true);
1124
- this.$set(currentItem.meta, "user_affix", true);
1125
- }
1126
- }
1127
- },
1128
- unlockMenu() {
1129
- let vueTarget = window.$vueRoot;
1130
- let path = vueTarget.$route.path;
1131
- let visitedViews = vueTarget.$store.state.tagsView.visitedViews;
1132
- if (visitedViews) {
1133
- let currentItem = visitedViews.find((item) => item.path === path);
1134
- if (currentItem && currentItem.meta.user_affix) {
1135
- currentItem.meta.affix = false;
1136
- currentItem.meta.user_affix = false;
1137
- }
1138
- }
1139
- },
1140
- },
1141
- };
1142
- })();
1143
-
1144
- export const mixins = tmixins;
1
+ /**version-1.0*/
2
+ let tmixins = {};
3
+ import { getToken } from "../../utils/auth";
4
+ import indexUtil from "../../utils/index.js";
5
+ import exportFieldDialog from "./exportFieldDialog.vue";
6
+ import { getCellValue } from "@base/components/table/util/index";
7
+ import { isItemExport, isRowExport, requiresCheckedRows } from "./exportType";
8
+
9
+ let configUtil = {
10
+ baseUrl: process.env.VUE_APP_BASE_API,
11
+ getToken,
12
+ indexUtil,
13
+ };
14
+
15
+ function getGrid(that, tableRef) {
16
+ let $grid;
17
+ if (Array.isArray(that.$refs[tableRef])) {
18
+ $grid = that.$refs[tableRef][0];
19
+ } else {
20
+ $grid = that.$refs[tableRef];
21
+ }
22
+ return $grid;
23
+ }
24
+
25
+ (function () {
26
+ tmixins = {
27
+ props: ["param"],
28
+ components: {
29
+ exportFieldDialog,
30
+ },
31
+ data() {
32
+ return {
33
+ showImportDialog: false,
34
+ showImportDialog2: false,
35
+ falseValue: false,
36
+ fileRaw: false,
37
+ tTotalPage: 0,
38
+ tTotalSize: 0,
39
+ doneSize: 0,
40
+ CURRENT_PREFIX: "",
41
+ option: {},
42
+ uuid: "",
43
+ fileRows: [],
44
+ title: this.$t2("导出", "components.excelExport.title"),
45
+ tableTarget: null,
46
+ showContent: true,
47
+ percentageNum: 0,
48
+ exportGrid: {
49
+ className: "list-table",
50
+ resizable: true,
51
+ height: 120,
52
+ stripe: true,
53
+ highlightCurrentRow: true,
54
+ highlightHoverRow: true,
55
+ columns: [
56
+ {
57
+ field: "name",
58
+ minWidth: 140,
59
+ title: this.$t2("文件名", "components.excelExport.fileName"),
60
+ sortable: true,
61
+ slots: {
62
+ default: ({ row }) => {
63
+ return row.title + "-" + row.uuid;
64
+ },
65
+ },
66
+ },
67
+ {
68
+ field: "fileSize",
69
+ minWidth: 140,
70
+ title: this.$t2("大小", "components.excelExport.fileSize"),
71
+ sortable: true,
72
+ },
73
+ {
74
+ field: "oper",
75
+ width: 140,
76
+ fixed: "right",
77
+ title: "",
78
+ sortable: false,
79
+ slots: {
80
+ default: "row_edit",
81
+ },
82
+ },
83
+ ],
84
+ },
85
+ excTime: 0,
86
+ showExportFieldDialog: false,
87
+ leafColumns: [],
88
+ columns: [],
89
+ queryParam: {},
90
+ isMinimize: false,
91
+ // 定时器必须放实例上:模块级共享会导致并发导出互相清除对方的定时器
92
+ exportTimer: null,
93
+ countTimer: null,
94
+ exportError: false,
95
+ };
96
+ },
97
+ created() {},
98
+ mounted() {
99
+ // this.exc();
100
+ },
101
+ beforeDestroy() {
102
+ this.clearExportTimer();
103
+ this.unlockMenu();
104
+ },
105
+ methods: {
106
+ exc() {
107
+ this.option = this.param;
108
+ let $grid = getGrid(this.option.vue, this.option.targetRef);
109
+ let datas = [];
110
+ // 明细导出的列来自 exportItemConfig,未维护时字段树为空、表头 JSON 也无从生成,
111
+ // 必须在此拦掉:这里是所有导出的唯一入口,放行下去会在字段选择弹框里抛异常。
112
+ if (isItemExport(this.option.type)) {
113
+ let originOption = $grid.params.originOption || {};
114
+ if (!originOption.exportItemConfig?.columns?.length) {
115
+ this.$baseAlert(
116
+ this.$t1("未维护明细导出列,请先在数据表格属性中配置")
117
+ );
118
+ this.param.destroyComponent();
119
+ return;
120
+ }
121
+ }
122
+ if (requiresCheckedRows(this.option.type)) {
123
+ datas = $grid.getCheckboxRecords(true);
124
+ if (!datas.length) {
125
+ this.$baseAlert(
126
+ this.$t2("请选择导出的数据", "components.excelExport.warmMsg1")
127
+ );
128
+ this.param.destroyComponent();
129
+ return;
130
+ }
131
+ } else if (this.option.type === "current") {
132
+ datas = $grid.getTableData().fullData;
133
+ if (!datas.length) {
134
+ this.$baseAlert(
135
+ this.$t2("不存在可导出的数据", "components.excelExport.warmMsg2")
136
+ );
137
+ this.param.destroyComponent();
138
+ return;
139
+ }
140
+ }
141
+
142
+ this.isMinimize = false;
143
+ this.showExportFieldDialog = true;
144
+ },
145
+ handleMinimize() {
146
+ let result = !this.showImportDialog2;
147
+ this.isMinimize = !result;
148
+ this.showImportDialog2 = result;
149
+ },
150
+ dialogClose2() {
151
+ if (this.isMinimize) return;
152
+ let loadingObj = window.$vueRoot.$baseLoading({
153
+ target: document.body,
154
+ background: "unset",
155
+ });
156
+
157
+ this.$emit("update:visiable", false);
158
+ this.clearExportTimer();
159
+ // this.showImportDialog2 = false;
160
+ this.showExportFieldDialog = false;
161
+ // this.showContent = false;
162
+ setTimeout(() => {
163
+ this.param.destroyComponent(loadingObj);
164
+ }, 0);
165
+ },
166
+ dialogPrimary2() {
167
+ // this.showUserDialog=false
168
+ this.$emit("confirm");
169
+ this.$emit("close");
170
+ this.clearExportTimer();
171
+ },
172
+ startProcess() {
173
+ this.lockMenu();
174
+ this.createCountTimer();
175
+ this.tableTarget = getGrid(this.option.vue, this.option.targetRef);
176
+
177
+ //获取查询条件
178
+ let originOption = this.tableTarget.params.originOption;
179
+ this.queryParam = this.$baseLodash.cloneDeep(
180
+ originOption.param() || {}
181
+ );
182
+
183
+ let that = this;
184
+ let options = this.option;
185
+ let title = options.title
186
+ ? this.$t1(options.title)
187
+ : this.$t2("导出", "components.excelExport.title");
188
+ if (!options.prefix && options.prefix !== "") {
189
+ let originOption = this.tableTarget.params.originOption;
190
+ let path = originOption.exportPath || originOption.path;
191
+ if (typeof path === "function") path = path();
192
+ if (path && typeof path === "string" && path !== "#") {
193
+ let os = path.split("/");
194
+ if (path.indexOf("http://") >= 0 || path.indexOf("https://") >= 0) {
195
+ options.prefix = "/" + os[3];
196
+ } else {
197
+ options.prefix = "/" + os[1];
198
+ }
199
+ }
200
+ }
201
+ if (!options.prefix) {
202
+ this.abortExport(
203
+ this.$t1("无法确定导出服务前缀,请在导出配置中指定 prefix")
204
+ );
205
+ this.unlockMenu();
206
+ return;
207
+ }
208
+ this.CURRENT_PREFIX = options.prefix;
209
+
210
+ this.title = title;
211
+ that.tTotalPage = 0;
212
+ that.tTotalSize = 0;
213
+ that
214
+ .createExcelFile()
215
+ .then((resultMsg) => {
216
+ if (resultMsg.type === "success") {
217
+ let aObj = resultMsg.objx;
218
+ that.uuid = aObj.uuid;
219
+ that.nowDate = aObj.nowDate;
220
+ that.ippaaapp = aObj.ippaaapp;
221
+ setTimeout(function () {
222
+ /*num = 1;
223
+ loopToDo(0, num);*/
224
+ that.handleLoopToDo();
225
+ }, 300);
226
+ } else {
227
+ that.abortExport();
228
+ that.showImportDialog = false;
229
+ that.showImportDialog2 = false;
230
+ }
231
+ })
232
+ .catch((error) => {
233
+ console.error(error);
234
+ that.abortExport(that.$t1("创建导出文件失败,导出已中止"));
235
+ that.showImportDialog = false;
236
+ that.showImportDialog2 = false;
237
+ });
238
+ },
239
+ getExportPageSize() {
240
+ let pageSize = Math.min(this.option.pageSize || 1000, 1000);
241
+ let showImageAtTable = this.option.showImageAtTable || false;
242
+ let hasExportImage = !!this.leafColumns.find((item) => {
243
+ let exportType = item?.params?.exportType;
244
+ return exportType === "Image";
245
+ });
246
+ let hasExportImage2 = !!this.leafColumns.find((item) => {
247
+ let exportType = item?.params?.exportType;
248
+ return exportType === "Image2";
249
+ });
250
+ if (hasExportImage || (hasExportImage2 && showImageAtTable)) {
251
+ pageSize = Math.min(pageSize, 150);
252
+ }
253
+ return pageSize;
254
+ },
255
+ hadleMergeExcel(pPageSize) {
256
+ let that = this;
257
+ let title = this.title;
258
+ let options = this.option;
259
+ // let pPageSize = this.getExportPageSize();
260
+ let limitFileSize = options.limitFileSize || 100000;
261
+ let limitThreadNum = options.limitThreadNum || 5;
262
+ let totalPages = this.tTotalPage || 1;
263
+
264
+ let kTotalPages = parseInt(limitFileSize / pPageSize);
265
+
266
+ let fileNum = parseInt(totalPages / kTotalPages);
267
+ if (totalPages % kTotalPages !== 0) {
268
+ fileNum = fileNum + 1;
269
+ }
270
+
271
+ let currentIndex = 0;
272
+ let mtExcedNum = 0;
273
+ let mtExcedSuccessNum = 0;
274
+ const loopDo = () => {
275
+ let startPage = currentIndex + 1;
276
+ if (mtExcedNum < fileNum) {
277
+ mtExcedNum++;
278
+
279
+ let endPage = currentIndex + kTotalPages;
280
+ if (endPage > totalPages) {
281
+ endPage = totalPages;
282
+ }
283
+ if (startPage > endPage) {
284
+ // 页码越界属异常状态,中止并不再发出非法页码的合并请求
285
+ that.abortExport();
286
+ return;
287
+ }
288
+ currentIndex = endPage;
289
+
290
+ that
291
+ .mergeExcel(startPage, endPage)
292
+ .then(function (resultMsg3) {
293
+ if (resultMsg3.type === "success") {
294
+ mtExcedSuccessNum++;
295
+ let fileInfo = resultMsg3.objx;
296
+ let fileName = fileInfo.fileName;
297
+ let fileSize = fileInfo.fileSize;
298
+
299
+ let dataMap = {};
300
+ dataMap["startPage"] = startPage;
301
+ dataMap["endPage"] = endPage;
302
+ dataMap["title"] = title;
303
+ dataMap["uuid"] = fileName;
304
+ dataMap["fileSize"] = fileSize;
305
+ // fileRows.push(dataMap);
306
+
307
+ that.$refs["exportTable"].insertAt(dataMap, -1);
308
+
309
+ let fileSizeStr = fileSize;
310
+
311
+ // that.fileRows.push(dataMap);
312
+ if (mtExcedNum < fileNum) {
313
+ loopDo();
314
+ } else if (
315
+ mtExcedNum >= fileNum &&
316
+ mtExcedSuccessNum >= fileNum
317
+ ) {
318
+ setTimeout(function () {
319
+ that.percentageNum = parseInt(100);
320
+ }, 100);
321
+ that.clearExportTimer();
322
+ } else if (mtExcedSuccessNum >= fileNum) {
323
+ setTimeout(function () {
324
+ that.percentageNum = parseInt(100);
325
+ }, 100);
326
+ that.clearExportTimer();
327
+ }
328
+ } else {
329
+ that.abortExport();
330
+ }
331
+ })
332
+ .catch(function (e) {
333
+ console.error(e);
334
+ that.abortExport(that.$t1("文件合并异常,导出已中止"));
335
+ });
336
+ // 注意:此处不能同步 clearExportTimer,否则计时统计会在合并完成前被提前停掉
337
+ }
338
+ };
339
+ loopDo();
340
+ },
341
+ handleLoopToDo() {
342
+ let that = this;
343
+ let uuid;
344
+ let num = 0;
345
+ let title = this.title;
346
+
347
+ let options = this.option;
348
+
349
+ let pPageSize = this.getExportPageSize();
350
+ let limitFileSize = options.limitFileSize || 100000;
351
+ let limitThreadNum = options.limitThreadNum || 5;
352
+
353
+ /**处理返回值*/
354
+ this.doneSize = 0;
355
+ let excedNum = 0;
356
+ let cSize = this.doneSize;
357
+
358
+ let handleData = function (resultMsg) {
359
+ let pageNumber = resultMsg.objx.pageNumber || 1;
360
+ that
361
+ .addExcelData({
362
+ rows: resultMsg.objx.records,
363
+ pageNumber: pageNumber,
364
+ })
365
+ .then(function (resultMsg2) {
366
+ let data = resultMsg.objx;
367
+ let total = data.total;
368
+
369
+ let pageNumber = data.pageNumber || 1;
370
+ let totalPages = that.tTotalPage || 1;
371
+ if (resultMsg2.type === "success") {
372
+ excedNum++;
373
+ let pageNumber = data.pageNumber || 1;
374
+ let k = (excedNum * 100) / totalPages;
375
+ if (k > 0 && k < 1) {
376
+ k = 1;
377
+ }
378
+ if (k > 100) k = 100;
379
+ let cTotal = that.tTotalSize;
380
+ let pageSize = data.pageSize;
381
+ // let datas = data.records;
382
+ let size = data.records.length;
383
+ cSize = cSize + size;
384
+
385
+ let ttNum = cSize + "/" + cTotal;
386
+ let percentageStr = parseInt(k) + "%";
387
+
388
+ let percentageNum = k;
389
+ if (percentageNum >= 100) {
390
+ percentageNum = 99;
391
+ }
392
+ // that.$set(that, "doneSize", parseInt(cSize));
393
+ // that.$set(that, "percentageNum", parseInt(percentageNum));
394
+
395
+ that.doneSize = parseInt(cSize);
396
+ that.percentageNum = parseInt(percentageNum);
397
+
398
+ if (totalPages === 0 || excedNum >= totalPages) {
399
+ that.hadleMergeExcel(data.pageSize);
400
+ return;
401
+
402
+ /*let kTotalPages = parseInt(limitFileSize / data.pageSize);
403
+
404
+ let fileNum = parseInt(totalPages / kTotalPages);
405
+ if (totalPages % kTotalPages !== 0) {
406
+ fileNum = fileNum + 1;
407
+ }
408
+
409
+ let currentIndex = 0;
410
+ let excingNum = 0;
411
+ let mtExcedNum = 0;
412
+ let mtExcedSuccessNum = 0;
413
+
414
+ let fileRows = [];
415
+
416
+ setTimeout(function () {
417
+ let startPage = currentIndex + 1;
418
+ if (mtExcedNum < fileNum) {
419
+ if (excingNum >= limitThreadNum) return false;
420
+ excingNum++;
421
+ mtExcedNum++;
422
+
423
+ let endPage = currentIndex + kTotalPages;
424
+ if (endPage > totalPages) {
425
+ endPage = totalPages;
426
+ }
427
+ if (startPage > endPage) {
428
+ that.clearExportTimer();
429
+ }
430
+ currentIndex = endPage;
431
+
432
+ that.mergeExcel(startPage, endPage).then(function (resultMsg3) {
433
+ if (resultMsg3.type === "success") {
434
+ excingNum--;
435
+ mtExcedSuccessNum++;
436
+ let fileInfo = resultMsg3.objx;
437
+ let fileName = fileInfo.fileName;
438
+ let fileSize = fileInfo.fileSize;
439
+
440
+ let dataMap = {};
441
+ dataMap["startPage"] = startPage;
442
+ dataMap["endPage"] = endPage;
443
+ dataMap["title"] = title;
444
+ dataMap["uuid"] = fileName;
445
+ dataMap["fileSize"] = fileSize;
446
+ // fileRows.push(dataMap);
447
+
448
+ that.$refs["exportTable"].insertAt(
449
+ dataMap, -1);
450
+
451
+ let fileSizeStr = fileSize;
452
+
453
+ // that.fileRows.push(dataMap);
454
+
455
+ if (mtExcedNum >= fileNum && mtExcedSuccessNum >= fileNum) {
456
+ setTimeout(function () {
457
+ that.percentageNum =
458
+ parseInt(100);
459
+ }, 100);
460
+ that.clearExportTimer();
461
+ } else if (mtExcedSuccessNum >= fileNum) {
462
+ setTimeout(function () {
463
+ that.percentageNum = parseInt(100);
464
+ }, 100);
465
+ that.clearExportTimer();
466
+ }
467
+ } else {
468
+ that.clearExportTimer();
469
+ }
470
+ }).catch(function (e) {
471
+ console.error(e);
472
+ that.clearExportTimer();
473
+ });
474
+ that.clearExportTimer();
475
+ }
476
+ }, 100);*/
477
+ return false;
478
+ }
479
+ } else {
480
+ that.abortExport();
481
+ }
482
+ })
483
+ .catch(function (e) {
484
+ console.error(e);
485
+ that.abortExport(that.$t1("导出数据写入失败,导出已中止"));
486
+ });
487
+ };
488
+
489
+ let waitReqNum = 0;
490
+ let promise;
491
+ let loopToDo = function (flag, pageNumber, retryCount = 0) {
492
+ let maxWaitNum = limitThreadNum;
493
+ let nowDate = options.nowDate;
494
+ if (flag === 1) {
495
+ /*if (num > that.tTotalPage) {
496
+ let size = page.records.length;
497
+ if (size === 0 || page.totalPages === 0 || (page.pageNumber >= page.totalPages)) {
498
+ that.clearExportTimer();
499
+ return;
500
+ }
501
+ }*/
502
+ } else {
503
+ waitReqNum = 0;
504
+ }
505
+
506
+ let target = that.tableTarget;
507
+ let originOption = target.params.originOption;
508
+ let url = originOption.exportPath || originOption.path;
509
+
510
+ // let params = originOption.param() || {};
511
+ let params = that.queryParam;
512
+ let aParam = {
513
+ current: pageNumber,
514
+ size: pPageSize,
515
+ nowDate: nowDate,
516
+ searchCount: flag !== 1,
517
+ };
518
+ let cpParam;
519
+ if (originOption.vform === true) {
520
+ params.conditions = params.conditions || {};
521
+ cpParam = params.conditions;
522
+ } else {
523
+ cpParam = params;
524
+ }
525
+ Object.assign(cpParam, aParam);
526
+
527
+ if (!originOption.exportAjax) {
528
+ let turl = url.replace("searchCount=false", "1=1");
529
+ let finaParams = params;
530
+ if (originOption.paramHandle) {
531
+ finaParams = originOption.paramHandle
532
+ ? originOption.paramHandle(params) || {}
533
+ : {};
534
+ }
535
+ promise = that.$commonHttp({
536
+ aes: originOption.aes || false,
537
+ url: turl,
538
+ method: "post",
539
+ data: finaParams,
540
+ modal: false,
541
+ queryCreateInfo: originOption.queryCreateInfo,
542
+ addCreateInfo: originOption.addCreateInfo,
543
+ });
544
+ } else {
545
+ promise = originOption.exportAjax(aParam, options);
546
+ }
547
+
548
+ promise
549
+ .then(function (resultMsg) {
550
+ if (resultMsg.type === "success") {
551
+ let objx = resultMsg.objx;
552
+ objx.pageNumber = objx.current || 1;
553
+ objx.totalPages = objx.pages || 1;
554
+ objx.pageSize = objx.size;
555
+ let size = objx.records.length;
556
+ if (flag === 0) {
557
+ that.tTotalPage = objx.pages;
558
+ // that.tTotalSize = objx.total;
559
+ setTimeout(function () {
560
+ that.$set(that, "tTotalSize", objx.total);
561
+ }, 0);
562
+ let tTotalPage = objx.pages;
563
+ let tTotalSize = objx.total;
564
+ let ttNum = 0 + "/" + objx.total;
565
+
566
+ let opNum = limitFileSize;
567
+ let kTotalPages = parseInt(opNum / objx.size);
568
+
569
+ let fileNum = parseInt(tTotalPage / kTotalPages);
570
+ if (tTotalPage % kTotalPages !== 0) {
571
+ fileNum = fileNum + 1;
572
+ }
573
+ if (
574
+ size > 0 ||
575
+ objx.totalPages > 0 ||
576
+ objx.pageNumber < objx.totalPages
577
+ ) {
578
+ that.exportTimer = setInterval(function () {
579
+ if (waitReqNum < maxWaitNum && num < tTotalPage) {
580
+ waitReqNum++;
581
+ num++;
582
+ let pageNumber = num;
583
+ loopToDo(1, pageNumber);
584
+ }
585
+ if (num >= tTotalPage) {
586
+ // 所有页已派发,停掉调度器(数据写入完成与否由 handleData 计数判断)
587
+ clearInterval(that.exportTimer);
588
+ that.exportTimer = null;
589
+ }
590
+ }, 100);
591
+ } else {
592
+ clearInterval(that.exportTimer);
593
+ that.exportTimer = null;
594
+ }
595
+ } else {
596
+ if (waitReqNum > 0) waitReqNum--;
597
+ }
598
+
599
+ setTimeout(function () {
600
+ handleData(resultMsg, flag);
601
+ }, 1);
602
+ } else {
603
+ // 单页拉取失败自动重试一次;仍失败则中止(缺页合并会静默丢数据,必须中止)
604
+ if (retryCount < 1) {
605
+ setTimeout(function () {
606
+ loopToDo(flag, pageNumber, retryCount + 1);
607
+ }, 500);
608
+ } else {
609
+ that.abortExport();
610
+ }
611
+ }
612
+ })
613
+ .catch(function (e) {
614
+ console.error(e);
615
+ if (retryCount < 1) {
616
+ setTimeout(function () {
617
+ loopToDo(flag, pageNumber, retryCount + 1);
618
+ }, 500);
619
+ } else {
620
+ that.abortExport(
621
+ that.$t1("第{n}页数据拉取失败,导出已中止", {
622
+ n: pageNumber,
623
+ })
624
+ );
625
+ }
626
+ });
627
+ };
628
+
629
+ num = 1;
630
+ loopToDo(0, num);
631
+ },
632
+ createExcelFile(loading) {
633
+ let url1 = this.CURRENT_PREFIX + "/excel/createExcelTemplate";
634
+ let datas = this.getHeadTitleJson();
635
+ return this.$http({
636
+ url: url1,
637
+ method: "post",
638
+ headers: {
639
+ "Content-Type": "application/json;charset=utf-8",
640
+ },
641
+ data: datas,
642
+ modal: loading || false,
643
+ isLoading: loading,
644
+ });
645
+ },
646
+ /*getExportTitleJson() {
647
+ let target = this.tableTarget;
648
+ // let columns = target.getColumns();
649
+ let columns = this.columns;
650
+ let titles = [];
651
+ columns.forEach(column => {
652
+ if (column.title) {
653
+ // titles.push(column.title)
654
+ titles.push({
655
+ colspan: 1,
656
+ rowspan: 1,
657
+ title: column.title
658
+ });
659
+ }
660
+ });
661
+ return [titles];
662
+ },*/
663
+ computeRealColSpan(columns) {
664
+ // 深拷贝避免修改原数据(可选)
665
+ // const result = JSON.parse(JSON.stringify(columns));
666
+
667
+ function traverse(node) {
668
+ if (!node.children || node.children.length === 0) {
669
+ // 叶子节点:realColSpan = 原始 colSpan
670
+ node.realColSpan = node.colSpan || 1;
671
+ } else {
672
+ // 非叶子节点:递归处理子节点,然后求和
673
+ let sum = 0;
674
+ for (const child of node.children) {
675
+ traverse(child);
676
+ sum += child.realColSpan;
677
+ }
678
+ node.realColSpan = sum;
679
+ }
680
+ }
681
+
682
+ for (const col of columns) {
683
+ traverse(col);
684
+ }
685
+
686
+ return columns;
687
+ },
688
+ getHeadTitleJson() {
689
+ let that = this;
690
+ let target = this.tableTarget;
691
+ // let columns = target.getTableColumn().collectColumn;
692
+ let columns = this.columns;
693
+
694
+ this.computeRealColSpan(columns);
695
+
696
+ let maxRowNum = 0;
697
+ let loop = function (column, n) {
698
+ if (column.children && column.children.length > 0) {
699
+ let num = n + 1;
700
+ column.children.forEach((child) => {
701
+ return loop(child, num);
702
+ });
703
+ } else {
704
+ let num = n;
705
+ if (num > maxRowNum) maxRowNum = num;
706
+ }
707
+ };
708
+
709
+ columns.forEach((column) => {
710
+ if (column.title) {
711
+ loop(column, 0);
712
+ }
713
+ });
714
+ maxRowNum = maxRowNum + 1;
715
+
716
+ let titleArr = [];
717
+ let columnsArr = [columns];
718
+ for (let i = 0; i < maxRowNum; i++) {
719
+ let contents = [];
720
+ let items = columnsArr[i];
721
+ let nextArr = [];
722
+ let colspan = 1;
723
+ let rowspan = 1;
724
+ items.forEach((column, index) => {
725
+ if (column.title) {
726
+ if (column.children && column.children.length > 0) {
727
+ nextArr = nextArr.concat(column.children);
728
+ }
729
+
730
+ contents.push({
731
+ colspan: column.realColSpan,
732
+ rowspan: column.rowSpan,
733
+ title:
734
+ column.title !== null && column.title !== undefined
735
+ ? column.title
736
+ : "",
737
+ });
738
+ }
739
+ });
740
+ titleArr.push(contents);
741
+ if (nextArr.length > 0) columnsArr.push(nextArr);
742
+ }
743
+ return titleArr;
744
+ },
745
+ addExcelData(opts, loading) {
746
+ let target = opts.target;
747
+ let pageNumber = opts.pageNumber || 1;
748
+ let callback = opts.callback;
749
+ let datas = this.getExcelData(opts.rows);
750
+ let cUUid = this.uuid;
751
+ let ippaaapp = this.ippaaapp;
752
+ let url1 =
753
+ this.CURRENT_PREFIX +
754
+ "/excel/appendExcelData?uuid=" +
755
+ cUUid +
756
+ "&ippaaapp=" +
757
+ ippaaapp +
758
+ "&pageNumber=" +
759
+ pageNumber;
760
+ return this.$http({
761
+ url: url1,
762
+ method: "post",
763
+ headers: {
764
+ "Content-Type": "application/json;charset=utf-8",
765
+ },
766
+ data: datas,
767
+ modal: loading || false,
768
+ isLoading: loading || false,
769
+ });
770
+ },
771
+ mergeExcel(startPage, endPage, loading) {
772
+ let url1 =
773
+ this.CURRENT_PREFIX +
774
+ "/excel/mergeExcel?uuid=" +
775
+ this.uuid +
776
+ "&ippaaapp=" +
777
+ this.ippaaapp;
778
+ return this.$http({
779
+ url: url1 + "&startPage=" + startPage + "&endPage=" + endPage,
780
+ method: "post",
781
+ modal: loading || false,
782
+ isLoading: loading || false,
783
+ });
784
+ },
785
+ createCountTimer() {
786
+ this.excTime = 0;
787
+ let beginTime = new Date().getTime();
788
+ this.countTimer = setInterval(() => {
789
+ let nowTime = new Date().getTime();
790
+ let diffTime = (nowTime - beginTime) / 1000;
791
+ this.$set(this, "excTime", this.$baseLodash.round(diffTime, 2));
792
+ }, 100);
793
+ },
794
+ clearExportTimer() {
795
+ if (this.exportTimer) clearInterval(this.exportTimer);
796
+ if (this.countTimer) clearInterval(this.countTimer);
797
+ this.exportTimer = null;
798
+ this.countTimer = null;
799
+ },
800
+ /**
801
+ * 中止导出:停止全部定时器并把进度条置为错误态。
802
+ * @param {String} [msg] 需要额外弹给用户的提示;服务端已 toast 过的失败不传,避免重复提示。
803
+ */
804
+ abortExport(msg) {
805
+ this.clearExportTimer();
806
+ this.exportError = true;
807
+ if (msg) this.$baseAlert(msg);
808
+ },
809
+ isPicture: function (suffix) {
810
+ if (!suffix || suffix === "") {
811
+ return false;
812
+ }
813
+ suffix = suffix.toLowerCase();
814
+ let fileTypeMap = {
815
+ jpg: true,
816
+ jpeg: true,
817
+ png: true,
818
+ // gif: true,
819
+ bmp: true,
820
+ mpg: true,
821
+ };
822
+
823
+ let type = fileTypeMap[suffix];
824
+ if (undefined === type) {
825
+ return false;
826
+ }
827
+
828
+ return true;
829
+ },
830
+ /**
831
+ * 导出取值快路径:优先纯函数取值(filterVal → formatter → 原始字段),
832
+ * 只有真正配置了自定义渲染(renderCell/函数型 slots.default)的列才走
833
+ * getCellValue vNode 挂载渲染兜底 —— 后者每个单元格要挂载一次 Vue
834
+ * 组件再爬 DOM,是导出耗时的大头。
835
+ * 字符串型 slots.default(具名插槽,如 xform 的 "widget")由 getCellValue
836
+ * grid 作用域插槽解析后渲染;解析不到时其内部回退原始字段。
837
+ */
838
+ getExportCellValue(params) {
839
+ let column = params.column;
840
+ if (column.slots && typeof column.slots.filterVal === "function") {
841
+ return column.slots.filterVal(params);
842
+ }
843
+ let slotDefault = column.slots && column.slots.default;
844
+ let hasRenderFn =
845
+ !!column.renderCell ||
846
+ typeof slotDefault === "function" ||
847
+ typeof slotDefault === "string";
848
+ if (!hasRenderFn) {
849
+ let cellValue = params.row[column.field];
850
+ if (typeof column.formatter === "function") {
851
+ return column.formatter({
852
+ cellValue,
853
+ row: params.row,
854
+ column,
855
+ });
856
+ }
857
+ return cellValue;
858
+ }
859
+ return getCellValue(params);
860
+ },
861
+ getExcelData(rows) {
862
+ let that = this;
863
+
864
+ let showImageAtTable = this.option.showImageAtTable || false;
865
+ // let target = this.option.vue.$refs[this.option.targetRef];
866
+ let target = getGrid(this.option.vue, this.option.targetRef);
867
+ let $table = target.$refs.xTable;
868
+
869
+ // let columns = target.getColumns();
870
+ let columns = this.leafColumns.filter(
871
+ (column) => !column.params?.exportDisabled
872
+ );
873
+
874
+ let arr = [];
875
+ let contents;
876
+ let params;
877
+ let resultStr;
878
+ // 批量取值期间复用 vNode 渲染的临时实例,结束时统一销毁
879
+ rows.forEach(function (row, index) {
880
+ contents = [];
881
+ columns.forEach((column) => {
882
+ if (column.title) {
883
+ params = {
884
+ $table: $table,
885
+ row: row,
886
+ rowIndex: index,
887
+ $rowIndex: index,
888
+ column: column,
889
+ // columnIndex: 0,
890
+ // $columnIndex: 0,
891
+ // _columnIndex
892
+ };
893
+ let exportType = column.params?.exportType;
894
+ let exportVal =
895
+ column.params && column.params.exportVal
896
+ ? column.params.exportVal
897
+ : null;
898
+ if (exportVal) {
899
+ resultStr = exportVal(params);
900
+ } else if (exportType === "Number") {
901
+ resultStr = that.getExportCellValue(params);
902
+ if (
903
+ resultStr !== null &&
904
+ resultStr !== undefined &&
905
+ resultStr !== "" &&
906
+ !(resultStr + "").startsWith("[EXPNUM]")
907
+ ) {
908
+ resultStr = "[EXPNUM]" + resultStr;
909
+ }
910
+ } else if (
911
+ exportType === "Image" ||
912
+ (showImageAtTable && exportType === "Image2")
913
+ ) {
914
+ resultStr = that.getExportCellValue(params);
915
+ let attachments = row[column.field];
916
+ if (attachments) {
917
+ if (Array.isArray(attachments)) {
918
+ let items = attachments.filter((item) =>
919
+ that.isPicture(item.extension)
920
+ );
921
+ if (items.length > 0) {
922
+ resultStr =
923
+ "[EXPIMG]" +
924
+ items
925
+ .map((item) => {
926
+ let url = item.large || item.medium;
927
+ return item.domain + url;
928
+ })
929
+ .join(",");
930
+ } else {
931
+ resultStr = null;
932
+ }
933
+ } else {
934
+ if (
935
+ that.isPicture(
936
+ that.$commonFileUtil.getFileSuffix(resultStr)
937
+ )
938
+ ) {
939
+ if (
940
+ resultStr !== null &&
941
+ resultStr !== undefined &&
942
+ resultStr !== "" &&
943
+ !(resultStr + "").startsWith("[EXPIMG]")
944
+ ) {
945
+ resultStr = "[EXPIMG]" + resultStr;
946
+ }
947
+ } else {
948
+ resultStr = null;
949
+ }
950
+ }
951
+ } else {
952
+ resultStr = null;
953
+ }
954
+ } else {
955
+ resultStr = that.getExportCellValue(params);
956
+ }
957
+ contents.push(resultStr);
958
+ resultStr = null;
959
+ }
960
+ });
961
+ arr.push(contents);
962
+ });
963
+ return arr;
964
+ },
965
+ exportAll(row) {
966
+ let cUUid = encodeURIComponent(row.uuid);
967
+ let ippaaapp = this.ippaaapp;
968
+ let fileName = row.title;
969
+ let fileUrl =
970
+ configUtil.baseUrl +
971
+ this.CURRENT_PREFIX +
972
+ "/excel/download?uuid=" +
973
+ cUUid +
974
+ "&ippaaapp=" +
975
+ ippaaapp;
976
+
977
+ function downLoadFile2() {
978
+ let params = {
979
+ n: fileName,
980
+ };
981
+ params["access_token"] = configUtil.getToken();
982
+
983
+ let form = document.createElement("form");
984
+
985
+ let randomNum =
986
+ new Date().valueOf() + Math.floor(Math.random() * 1000000);
987
+ let formId = "formId-" + randomNum;
988
+ let formName = "formName-" + randomNum;
989
+
990
+ form.id = formId;
991
+ form.name = formName;
992
+ form.target = "_blank";
993
+ document.body.appendChild(form);
994
+ for (let obj in params) {
995
+ if (params.hasOwnProperty(obj)) {
996
+ let input = document.createElement("input");
997
+ input.type = "hidden";
998
+ input.name = obj;
999
+ input.value = params[obj];
1000
+ form.appendChild(input);
1001
+ }
1002
+ }
1003
+ form.method = "post"; //请求方式
1004
+ form.action = fileUrl;
1005
+ form.submit();
1006
+ document.body.removeChild(form);
1007
+ }
1008
+
1009
+ downLoadFile2();
1010
+ },
1011
+ startProcess2(datas) {
1012
+ this.tableTarget = getGrid(this.option.vue, this.option.targetRef);
1013
+ let that = this;
1014
+ let options = this.option;
1015
+ let title =
1016
+ options.title || this.$t2("导出", "components.excelExport.title");
1017
+ if (!options.prefix && options.prefix !== "") {
1018
+ let originOption = this.tableTarget.params.originOption;
1019
+ let path = originOption.exportPath || originOption.path;
1020
+ if (typeof path === "function") path = path();
1021
+ if (path && typeof path === "string" && path !== "#") {
1022
+ let os = path.split("/");
1023
+ if (path.indexOf("http://") >= 0 || path.indexOf("https://") >= 0) {
1024
+ options.prefix = "/" + os[3];
1025
+ } else {
1026
+ options.prefix = "/" + os[1];
1027
+ }
1028
+ }
1029
+ }
1030
+ if (!options.prefix) {
1031
+ this.$baseAlert(
1032
+ this.$t1("无法确定导出服务前缀,请在导出配置中指定 prefix")
1033
+ );
1034
+ return;
1035
+ }
1036
+ this.CURRENT_PREFIX = options.prefix;
1037
+
1038
+ let handleData = function () {
1039
+ let total = datas.length;
1040
+ that
1041
+ .addExcelData(
1042
+ {
1043
+ rows: datas,
1044
+ pageNumber: 1,
1045
+ },
1046
+ true
1047
+ )
1048
+ .then((resultMsg2) => {
1049
+ if (resultMsg2.type === "success") {
1050
+ setTimeout(() => {
1051
+ that.mergeExcel(1, 1, true).then((resultMsg3) => {
1052
+ if (resultMsg3.type === "success") {
1053
+ let fileInfo = resultMsg3.objx;
1054
+ let fileName = fileInfo.fileName;
1055
+ let fileSize = fileInfo.fileSize;
1056
+
1057
+ let dataMap = {};
1058
+ dataMap["startPage"] = 1;
1059
+ dataMap["endPage"] = 1;
1060
+ dataMap["title"] = title;
1061
+ dataMap["uuid"] = fileName;
1062
+ dataMap["fileSize"] = fileSize;
1063
+ that.exportAll(dataMap);
1064
+ }
1065
+ });
1066
+ }, 0);
1067
+ }
1068
+ });
1069
+ };
1070
+ that.createExcelFile(true).then((resultMsg) => {
1071
+ if (resultMsg.type === "success") {
1072
+ let aObj = resultMsg.objx;
1073
+ that.uuid = aObj.uuid;
1074
+ that.nowDate = aObj.nowDate;
1075
+ that.ippaaapp = aObj.ippaaapp;
1076
+ setTimeout(() => {
1077
+ handleData();
1078
+ }, 0);
1079
+ }
1080
+ });
1081
+ },
1082
+ closeExportFieldDialog() {
1083
+ this.dialogClose2();
1084
+ },
1085
+ confirmExportFieldDialog({ columns, leafColumns }) {
1086
+ this.columns = columns;
1087
+ this.leafColumns = leafColumns;
1088
+ let flag = isRowExport(this.option.type);
1089
+ if (!flag) {
1090
+ this.showImportDialog2 = true;
1091
+ }
1092
+ this.$nextTick(() => {
1093
+ if (flag) {
1094
+ let $grid = getGrid(this.option.vue, this.option.targetRef);
1095
+ let datas = [];
1096
+ if (this.option.type === "selected") {
1097
+ datas = $grid.getCheckboxRecords(true);
1098
+ if (!datas.length) {
1099
+ this.$baseAlert(
1100
+ this.$t2(
1101
+ "请选择导出的数据",
1102
+ "components.excelExport.warmMsg1"
1103
+ )
1104
+ );
1105
+ return;
1106
+ }
1107
+ } else if (this.option.type === "current") {
1108
+ datas = $grid.getTableData().fullData;
1109
+ if (!datas.length) {
1110
+ this.$baseAlert(
1111
+ this.$t2(
1112
+ "不存在可导出的数据",
1113
+ "components.excelExport.warmMsg2"
1114
+ )
1115
+ );
1116
+ return;
1117
+ }
1118
+ }
1119
+ this.startProcess2(datas);
1120
+ } else {
1121
+ this.startProcess();
1122
+ }
1123
+ });
1124
+ },
1125
+ lockMenu() {
1126
+ let vueTarget = window.$vueRoot;
1127
+ let path = vueTarget.$route.path;
1128
+ let visitedViews = vueTarget.$store.state.tagsView.visitedViews;
1129
+ if (visitedViews) {
1130
+ let currentItem = visitedViews.find((item) => item.path === path);
1131
+ if (currentItem && !currentItem.meta.affix) {
1132
+ this.$set(currentItem.meta, "affix", true);
1133
+ this.$set(currentItem.meta, "user_affix", true);
1134
+ }
1135
+ }
1136
+ },
1137
+ unlockMenu() {
1138
+ let vueTarget = window.$vueRoot;
1139
+ let path = vueTarget.$route.path;
1140
+ let visitedViews = vueTarget.$store.state.tagsView.visitedViews;
1141
+ if (visitedViews) {
1142
+ let currentItem = visitedViews.find((item) => item.path === path);
1143
+ if (currentItem && currentItem.meta.user_affix) {
1144
+ currentItem.meta.affix = false;
1145
+ currentItem.meta.user_affix = false;
1146
+ }
1147
+ }
1148
+ },
1149
+ },
1150
+ };
1151
+ })();
1152
+
1153
+ export const mixins = tmixins;