@smart100/spu-web-plugin 0.0.38 → 1.0.3

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.
@@ -1,4 +1,7 @@
1
- import { Module, axios, getUser, wxworkSuite, spuAxios } from '../../index'
1
+ import { Module } from '../../core'
2
+ import { wxworkSuite } from '../../wxworksuitePlugin'
3
+ import { spuAxios, axios } from '../../axios'
4
+ import { getUser } from '../../login'
2
5
  import { cloneDeep, merge } from 'lodash-es'
3
6
  import { downloadService } from '../../oss'
4
7
  import { apaasSpuTrackSendLog } from '../../apaasSpuTrack'
@@ -8,9 +11,8 @@ import { Step } from './step'
8
11
  import { fixFileName, dealFileSize, dealResultMessage } from './util'
9
12
 
10
13
  export default class SpuExpandexp extends HTMLElement {
11
-
12
14
  static componentName: string = 'spu-expandexp'
13
- static register () {
15
+ static register() {
14
16
  if (!window.customElements.get(SpuExpandexp.componentName)) {
15
17
  window.customElements.define(SpuExpandexp.componentName, SpuExpandexp)
16
18
  }
@@ -28,195 +30,233 @@ export default class SpuExpandexp extends HTMLElement {
28
30
 
29
31
  statusTimer: number | null = null
30
32
 
31
- constructor () {
33
+ constructor() {
32
34
  super()
33
35
  this.shadow = this.attachShadow({ mode: 'open' })
34
36
  }
35
37
 
36
38
  // 当自定义元素第一次被连接到文档DOM时被调用。
37
- connectedCallback () {
39
+ connectedCallback() {
38
40
  this.initProps()
39
41
  this.shadow.innerHTML = renderTemplate(this)
40
42
 
41
- this.initData({
42
- filetype: '1', // 导出文件类型 1: xls 2: csv 目前spu的导出只实现了xls 因此写死xls
43
- exportcontent: 'excel', // excel.仅导出单据,link,导出单据和本地链接,photo.导出单据和图片
44
- filewatermark: '0', // 1.开启文件水印,0.关闭文件水印
45
- iscompress: '0', // 1.压缩,0.原图
46
- displaytype: 'horizontal', // horizontal:横向排列 vertical:纵向排列 multi-row:分行展示
47
- imagetype: 'origin', // 导出图片类型 png jpg origin 默认origin
48
- imagename: '', // 图片命名规则
49
- // imagesizepercolumn imageheightcm 为 图片导出SPU新增配置项
50
- imagesizepercolumn: '5',
51
- imageheightcm: '2',
52
-
53
- expandStatus: '1', // 1普通导出(没有做图片导出服务) 2服务端导出(做了图片导出服务未SPU化) 3安装了图片导出SPU
54
- filewatermarkGlobalConfig: '0', // 全局文件水印开关
55
- exportConfigInit: false,
56
- exportcontentArray: ['excel', 'link', 'photo'], // 当 expandStatus = 2 | 3时才显示导出内容给用户选择
57
- percentage: 0,
58
- step: new Step(),
59
- stepStatus: 0,
60
- stepName: 'initial',
61
- stepText: '',
62
- resultMessage: '',
63
- exportDataItem: {},
64
- exportId: '',
65
- fileName: '',
66
- fileSize: '',
67
- runningTaskCount: 0,
68
- isOldVersionService: false,
69
- isWxworkSuiteTenant: wxworkSuite.isWxworkSuiteTenant()
70
- }, (key: string, value: any) => {
71
- const { exportConfigInit, stepName, stepText, exportcontentArray, exportcontent, isOldVersionService, runningTaskCount, fileName, filetype, fileSize, exportDataItem, percentage, resultMessage, isWxworkSuiteTenant } = this.data
72
-
73
- // debugger
74
- const $exportSel = this.shadow.querySelector('.export-sel') as any
75
- const $exportSelCon = this.shadow.querySelector('.export-sel-con') as any
76
- const $exportSectionWrap = this.shadow.querySelector('.export-section-wrap') as any
77
- const $exportBtnwrap = this.shadow.querySelector('.export-btnwrap') as any
78
- const $exportDownload = this.shadow.querySelector('.export-file-r-download') as any
79
- const $exportCancel = this.shadow.querySelector('.export-file-r-cancel') as any
80
- const $exportProgress = this.shadow.querySelector('.export-progress') as any
81
- const $exportProgressInner = this.shadow.querySelector('.export-progress-inner') as any
82
- const $exportProgressText = this.shadow.querySelector('.export-progress-text') as any
83
- const $exportTip = this.shadow.querySelector('.export-tip') as any
84
- const $exportTit = this.shadow.querySelector('.export-tit') as any
85
- const $exportResult = this.shadow.querySelector('.export-result') as any
86
- const $fileimg = this.shadow.querySelector('.export-file-l-img') as any
87
- const $filename = this.shadow.querySelector('.export-file-l-filename') as any
88
- const $filesize = this.shadow.querySelector('.export-file-l-filesize') as any
89
- const $wait = this.shadow.querySelector('.export-wait') as any
90
- const $waitSpan = this.shadow.querySelector('.export-wait span') as any
91
- const $exportWxworkTip = this.shadow.querySelector('.export-wxwork-tip') as any
92
-
93
-
94
- if (key === 'isWxworkSuiteTenant' || key === 'stepName') {
95
- this.vIf($exportWxworkTip, isWxworkSuiteTenant && stepName === 'initial')
96
- }
43
+ this.initData(
44
+ {
45
+ filetype: '1', // 导出文件类型 1: xls 2: csv 目前spu的导出只实现了xls 因此写死xls
46
+ exportcontent: 'excel', // excel.仅导出单据,link,导出单据和本地链接,photo.导出单据和图片
47
+ filewatermark: '0', // 1.开启文件水印,0.关闭文件水印
48
+ iscompress: '0', // 1.压缩,0.原图
49
+ displaytype: 'horizontal', // horizontal:横向排列 vertical:纵向排列 multi-row:分行展示
50
+ imagetype: 'origin', // 导出图片类型 png jpg origin 默认origin
51
+ imagename: '', // 图片命名规则
52
+ // imagesizepercolumn 和 imageheightcm 为 图片导出SPU新增配置项
53
+ imagesizepercolumn: '5',
54
+ imageheightcm: '2',
55
+
56
+ expandStatus: '1', // 1普通导出(没有做图片导出服务) 2服务端导出(做了图片导出服务未SPU化) 3安装了图片导出SPU
57
+ filewatermarkGlobalConfig: '0', // 全局文件水印开关
58
+ exportConfigInit: false,
59
+ exportcontentArray: ['excel', 'link', 'photo'], // 当 expandStatus = 2 | 3时才显示导出内容给用户选择
60
+ percentage: 0,
61
+ step: new Step(),
62
+ stepStatus: 0,
63
+ stepName: 'initial',
64
+ stepText: '',
65
+ resultMessage: '',
66
+ exportDataItem: {},
67
+ exportId: '',
68
+ fileName: '',
69
+ fileSize: '',
70
+ runningTaskCount: 0,
71
+ isOldVersionService: false,
72
+ isWxworkSuiteTenant: wxworkSuite.isWxworkSuiteTenant()
73
+ },
74
+ (key: string, value: any) => {
75
+ const {
76
+ exportConfigInit,
77
+ stepName,
78
+ stepText,
79
+ exportcontentArray,
80
+ exportcontent,
81
+ isOldVersionService,
82
+ runningTaskCount,
83
+ fileName,
84
+ filetype,
85
+ fileSize,
86
+ exportDataItem,
87
+ percentage,
88
+ resultMessage,
89
+ isWxworkSuiteTenant
90
+ } = this.data
97
91
 
98
- if (key === 'exportConfigInit') {
99
- this.vIf($exportSelCon, exportConfigInit)
100
- }
92
+ // debugger
93
+ const $exportSel = this.shadow.querySelector('.export-sel') as any
94
+ const $exportSelCon = this.shadow.querySelector('.export-sel-con') as any
95
+ const $exportSectionWrap = this.shadow.querySelector('.export-section-wrap') as any
96
+ const $exportBtnwrap = this.shadow.querySelector('.export-btnwrap') as any
97
+ const $exportDownload = this.shadow.querySelector('.export-file-r-download') as any
98
+ const $exportCancel = this.shadow.querySelector('.export-file-r-cancel') as any
99
+ const $exportProgress = this.shadow.querySelector('.export-progress') as any
100
+ const $exportProgressInner = this.shadow.querySelector('.export-progress-inner') as any
101
+ const $exportProgressText = this.shadow.querySelector('.export-progress-text') as any
102
+ const $exportTip = this.shadow.querySelector('.export-tip') as any
103
+ const $exportTit = this.shadow.querySelector('.export-tit') as any
104
+ const $exportResult = this.shadow.querySelector('.export-result') as any
105
+ const $fileimg = this.shadow.querySelector('.export-file-l-img') as any
106
+ const $filename = this.shadow.querySelector('.export-file-l-filename') as any
107
+ const $filesize = this.shadow.querySelector('.export-file-l-filesize') as any
108
+ const $wait = this.shadow.querySelector('.export-wait') as any
109
+ const $waitSpan = this.shadow.querySelector('.export-wait span') as any
110
+ const $exportWxworkTip = this.shadow.querySelector('.export-wxwork-tip') as any
111
+
112
+ if (key === 'isWxworkSuiteTenant' || key === 'stepName') {
113
+ this.vIf($exportWxworkTip, isWxworkSuiteTenant && stepName === 'initial')
114
+ }
101
115
 
102
- if (key === 'expandStatus' || key === 'stepName') {
103
- // this.vIf($exportSel, (expandStatus !== '1' && stepName === 'initial'))
104
- this.vIf($exportSel, (stepName === 'initial'))
105
- }
106
- if (key === 'exportcontentArray' || key === 'exportcontent') {
107
- const mapTitle: any = {
108
- excel: '仅导出单据',
109
- link: '导出单据和本地链接',
110
- photo: '导出单据和图片'
116
+ if (key === 'exportConfigInit') {
117
+ this.vIf($exportSelCon, exportConfigInit)
111
118
  }
112
119
 
113
- const exportcontentOptions = exportcontentArray.map((item: string) => {
114
- return {
115
- label: mapTitle[item],
116
- value: item
120
+ if (key === 'expandStatus' || key === 'stepName') {
121
+ // this.vIf($exportSel, (expandStatus !== '1' && stepName === 'initial'))
122
+ this.vIf($exportSel, stepName === 'initial')
123
+ }
124
+ if (key === 'exportcontentArray' || key === 'exportcontent') {
125
+ const mapTitle: any = {
126
+ excel: '仅导出单据',
127
+ link: '导出单据和本地链接',
128
+ photo: '导出单据和图片'
117
129
  }
118
- })
119
130
 
120
- const html = exportcontentOptions.map((item: any) => {
121
- return `
131
+ const exportcontentOptions = exportcontentArray.map((item: string) => {
132
+ return {
133
+ label: mapTitle[item],
134
+ value: item
135
+ }
136
+ })
137
+
138
+ const html = exportcontentOptions
139
+ .map((item: any) => {
140
+ return `
122
141
  <div class="export-sel-con-item">
123
- <input type="radio" id="${item.value}" name="exportcontent" value="${item.value}" ${item.value === exportcontent ? 'checked' : ''} />
142
+ <input type="radio" id="${item.value}" name="exportcontent" value="${item.value}" ${
143
+ item.value === exportcontent ? 'checked' : ''
144
+ } />
124
145
  <label for="${item.value}">${item.label}</label>
125
146
  </div>
126
147
  `
127
- }).join('')
148
+ })
149
+ .join('')
128
150
 
129
- $exportSelCon.innerHTML = html
130
- // set(exportcontent)
131
- }
151
+ $exportSelCon.innerHTML = html
152
+ // set(exportcontent)
153
+ }
132
154
 
155
+ // 状态标题
156
+ if (key === 'stepText') {
157
+ this.vText($exportTit, stepText)
158
+ }
133
159
 
134
- // 状态标题
135
- if (key === 'stepText') {
136
- this.vText($exportTit, stepText)
137
- }
160
+ // 下载按钮显隐
161
+ this.vIf($exportDownload, (stepName === 'error' || stepName === 'success') && exportDataItem?.exportfileurl)
138
162
 
139
- // 下载按钮显隐
140
- this.vIf($exportDownload, ((stepName === 'error' || stepName === 'success') && exportDataItem?.exportfileurl))
163
+ // 取消按钮显隐
164
+ this.vIf(
165
+ $exportCancel,
166
+ (stepName === 'running' || stepName === 'ready') &&
167
+ (!exportDataItem?.exportstate ||
168
+ exportDataItem?.exportstate === 'readyrun' ||
169
+ exportDataItem?.exportstate === 'running')
170
+ )
141
171
 
142
- // 取消按钮显隐
143
- this.vIf($exportCancel, ((stepName === 'running' || stepName === 'ready') && (!exportDataItem?.exportstate || exportDataItem?.exportstate === 'readyrun' || exportDataItem?.exportstate === 'running')))
172
+ // 进度条
173
+ if (key === 'stepName') {
174
+ this.vIf(
175
+ $exportProgress,
176
+ stepName === 'running' ||
177
+ stepName === 'ready' ||
178
+ stepName === 'success' ||
179
+ stepName === 'error' ||
180
+ stepName === 'ext_readyrun' ||
181
+ stepName === 'ext_running'
182
+ )
183
+ }
184
+ if (key === 'percentage' || key === 'stepName') {
185
+ this.vIf($exportProgressText, percentage < 100)
186
+ if (percentage >= 100) {
187
+ this.vText($exportProgressText, `100%`)
188
+ $exportProgressInner.setAttribute('style', `width: 100%`)
189
+
190
+ if (stepName === 'success') {
191
+ $exportProgressInner.classList.add('success')
192
+ } else if (stepName === 'error') {
193
+ $exportProgressInner.classList.add('error')
194
+ }
195
+ } else {
196
+ this.vText($exportProgressText, `${percentage}%`)
197
+ $exportProgressInner.setAttribute('style', `width: ${percentage}%`)
144
198
 
145
- // 进度条
146
- if (key === 'stepName') {
147
- this.vIf($exportProgress, (stepName === 'running' || stepName === 'ready' || stepName === 'success' || stepName === 'error' || stepName === 'ext_readyrun' || stepName === 'ext_running'))
148
- }
149
- if (key === 'percentage' || key === 'stepName') {
150
- this.vIf($exportProgressText, percentage < 100)
151
- if (percentage >= 100) {
152
- this.vText($exportProgressText, `100%`)
153
- $exportProgressInner.setAttribute('style', `width: 100%`)
199
+ $exportProgressInner.classList.remove('success')
200
+ $exportProgressInner.classList.remove('error')
201
+ }
202
+ }
154
203
 
204
+ if (key === 'stepName') {
205
+ this.vIf($exportSectionWrap, stepName !== 'initial')
206
+ this.vIf($exportBtnwrap, stepName === 'initial')
207
+ this.vIf(
208
+ $exportTip,
209
+ stepName === 'running' ||
210
+ stepName === 'ready' ||
211
+ stepName === 'ext_readyrun' ||
212
+ stepName === 'ext_running' ||
213
+ stepName === 'success'
214
+ )
215
+ }
216
+
217
+ if (key === 'resultMessage') {
218
+ this.vIf($exportResult, !!resultMessage)
219
+ this.vText($exportResult, resultMessage)
220
+ }
221
+ if (key === 'stepName') {
155
222
  if (stepName === 'success') {
156
- $exportProgressInner.classList.add('success')
223
+ $exportResult.classList.add('success')
157
224
  } else if (stepName === 'error') {
158
- $exportProgressInner.classList.add('error')
225
+ $exportResult.classList.add('error')
226
+ } else {
227
+ $exportResult.classList.remove('success')
159
228
  }
160
- } else {
161
- this.vText($exportProgressText, `${percentage}%`)
162
- $exportProgressInner.setAttribute('style', `width: ${percentage}%`)
163
-
164
- $exportProgressInner.classList.remove('success')
165
- $exportProgressInner.classList.remove('error')
166
229
  }
167
- }
168
-
169
-
170
- if (key === 'stepName') {
171
- this.vIf($exportSectionWrap, stepName !== 'initial')
172
- this.vIf($exportBtnwrap, stepName === 'initial')
173
- this.vIf($exportTip, (stepName === 'running' || stepName === 'ready' || stepName === 'ext_readyrun' || stepName === 'ext_running' || stepName === 'success'))
174
- }
175
230
 
176
- if (key === 'resultMessage') {
177
- this.vIf($exportResult, !!resultMessage)
178
- this.vText($exportResult, resultMessage)
179
- }
180
- if (key === 'stepName') {
181
- if (stepName === 'success') {
182
- $exportResult.classList.add('success')
183
- } else if (stepName === 'error') {
184
- $exportResult.classList.add('error')
185
- } else {
186
- $exportResult.classList.remove('success')
231
+ if (key === 'exportcontent') {
232
+ if (exportcontent === 'link') {
233
+ $fileimg.classList.add('zip')
234
+ $fileimg.classList.remove('excel')
235
+ } else {
236
+ $fileimg.classList.add('excel')
237
+ $fileimg.classList.remove('zip')
238
+ }
187
239
  }
188
- }
189
240
 
190
- if (key === 'exportcontent') {
191
- if (exportcontent === 'link') {
192
- $fileimg.classList.add('zip')
193
- $fileimg.classList.remove('excel')
194
- } else {
195
- $fileimg.classList.add('excel')
196
- $fileimg.classList.remove('zip')
241
+ if (key === 'fileName' || key === 'filetype' || key === 'exportcontent') {
242
+ const fileNameWithSuffix = fixFileName(fileName, filetype, exportcontent)
243
+ this.vText($filename, fileNameWithSuffix)
244
+ }
245
+ if (key === 'fileSize') {
246
+ this.vText($filesize, fileSize)
197
247
  }
198
- }
199
-
200
- if (key === 'fileName' || key === 'filetype' || key === 'exportcontent') {
201
- const fileNameWithSuffix = fixFileName(fileName, filetype, exportcontent)
202
- this.vText($filename, fileNameWithSuffix)
203
- }
204
- if (key === 'fileSize') {
205
- this.vText($filesize, fileSize)
206
- }
207
248
 
208
- if (key === 'isOldVersionService' || key === 'runningTaskCount') {
209
- const flag = !isOldVersionService && runningTaskCount > 0
210
- this.vIf($wait, flag)
211
- if (flag) {
212
- this.vText($waitSpan, runningTaskCount)
213
- } else {
214
- this.vText($waitSpan, '')
249
+ if (key === 'isOldVersionService' || key === 'runningTaskCount') {
250
+ const flag = !isOldVersionService && runningTaskCount > 0
251
+ this.vIf($wait, flag)
252
+ if (flag) {
253
+ this.vText($waitSpan, runningTaskCount)
254
+ } else {
255
+ this.vText($waitSpan, '')
256
+ }
215
257
  }
216
258
  }
217
-
218
-
219
- })
259
+ )
220
260
  this.data.fileName = this.props.sheetname
221
261
 
222
262
  this.initEvent()
@@ -224,7 +264,7 @@ export default class SpuExpandexp extends HTMLElement {
224
264
  this.getExpandexpConfig()
225
265
  }
226
266
 
227
- vText (ele: any, text: string) {
267
+ vText(ele: any, text: string) {
228
268
  const oldValue = ele.innerHTML || ''
229
269
  const newValue = text || ''
230
270
  if (oldValue !== newValue) {
@@ -233,7 +273,7 @@ export default class SpuExpandexp extends HTMLElement {
233
273
  }
234
274
  }
235
275
 
236
- vIf (ele: any, flag: boolean) {
276
+ vIf(ele: any, flag: boolean) {
237
277
  const elc = ele.classList
238
278
  if (flag) {
239
279
  elc.contains('hide') && elc.remove('hide')
@@ -242,7 +282,7 @@ export default class SpuExpandexp extends HTMLElement {
242
282
  }
243
283
  }
244
284
 
245
- vOp (ele: any, flag: boolean) {
285
+ vOp(ele: any, flag: boolean) {
246
286
  const elc = ele.classList
247
287
  if (flag) {
248
288
  elc.contains('opacity0') && elc.remove('opacity0')
@@ -251,16 +291,16 @@ export default class SpuExpandexp extends HTMLElement {
251
291
  }
252
292
  }
253
293
 
254
- initData (data: any, setCallback: any) {
294
+ initData(data: any, setCallback: any) {
255
295
  this.data = cloneDeep(data)
256
296
  const dataP = cloneDeep(data)
257
297
  for (const x in dataP) {
258
298
  Object.defineProperty(this.data, x, {
259
- get: function getter () {
299
+ get: function getter() {
260
300
  // console.log('get!')
261
301
  return dataP[x]
262
302
  },
263
- set: function getter (value) {
303
+ set: function getter(value) {
264
304
  // console.log('set!')
265
305
  dataP[x] = value
266
306
  setCallback(x, value)
@@ -271,7 +311,7 @@ export default class SpuExpandexp extends HTMLElement {
271
311
  }
272
312
  }
273
313
 
274
- initProps () {
314
+ initProps() {
275
315
  const attributes = getAttributes(this)
276
316
  this.props = {
277
317
  ...this.defaultProps,
@@ -284,7 +324,7 @@ export default class SpuExpandexp extends HTMLElement {
284
324
  console.log('this.props', this.props)
285
325
  }
286
326
 
287
- initEvent () {
327
+ initEvent() {
288
328
  // this.shadow.querySelector('.spu-expandexp')!.addEventListener('click', (e) => {
289
329
  // // console.log(this)
290
330
  // // console.log(this.shadow)
@@ -314,7 +354,6 @@ export default class SpuExpandexp extends HTMLElement {
314
354
  this.vIf(ele, true)
315
355
  })
316
356
 
317
-
318
357
  this.shadow.querySelector('.spu-expandexp-confirm-modal-th-close')!.addEventListener('click', () => {
319
358
  const ele = this.shadow.querySelector('.spu-expandexp-confirm')
320
359
  this.vIf(ele, false)
@@ -340,7 +379,7 @@ export default class SpuExpandexp extends HTMLElement {
340
379
  })
341
380
  }
342
381
 
343
- async getExpandexpConfig () {
382
+ async getExpandexpConfig() {
344
383
  let isInstallexpandexp = await Module.checkModule('expandexp')
345
384
  // isInstallexpandexp = false
346
385
  console.log('isInstallexpandexp', isInstallexpandexp)
@@ -387,13 +426,18 @@ export default class SpuExpandexp extends HTMLElement {
387
426
  })
388
427
  } else {
389
428
  axios
390
- .post('/api/expandexp/global/searchExpGloConfig', {
391
- key: 'export-config-switch',
392
- tenantcode: getUser('tenantcode'),
393
- productcode: getUser('productcode')
394
- }, {}, {
395
- isShowLoading: false
396
- })
429
+ .post(
430
+ '/api/expandexp/global/searchExpGloConfig',
431
+ {
432
+ key: 'export-config-switch',
433
+ tenantcode: getUser('tenantcode'),
434
+ productcode: getUser('productcode')
435
+ },
436
+ {},
437
+ {
438
+ isShowLoading: false
439
+ }
440
+ )
397
441
  .then((res: any) => {
398
442
  // res.data.exttype = '1'
399
443
  // res.data.exttype: 2开启了为服务端导出 1为普通导出
@@ -405,7 +449,8 @@ export default class SpuExpandexp extends HTMLElement {
405
449
  })
406
450
  .catch((err: Error) => {
407
451
  this.data.expandStatus = '1'
408
- }).finally(() => {
452
+ })
453
+ .finally(() => {
409
454
  // 发送日志
410
455
  this.sendLog({
411
456
  types: 'exportopenmodal',
@@ -436,7 +481,8 @@ export default class SpuExpandexp extends HTMLElement {
436
481
  })
437
482
  .catch(() => {
438
483
  this.data.filewatermarkGlobalConfig = '0'
439
- }).finally(() => {
484
+ })
485
+ .finally(() => {
440
486
  this.data.filewatermark = this.data.filewatermarkGlobalConfig === '1' ? '1' : '0'
441
487
  this.data.exportConfigInit = true
442
488
  })
@@ -445,7 +491,7 @@ export default class SpuExpandexp extends HTMLElement {
445
491
  }
446
492
  }
447
493
 
448
- getExportcontentValue () {
494
+ getExportcontentValue() {
449
495
  let result = ''
450
496
  const eles = this.shadow.querySelectorAll('.export-sel-con input[type=radio][name=exportcontent]') as any
451
497
  // console.log(eles)
@@ -458,7 +504,7 @@ export default class SpuExpandexp extends HTMLElement {
458
504
  return result
459
505
  }
460
506
 
461
- async handleExport () {
507
+ async handleExport() {
462
508
  this.updateStep('ready')
463
509
  this.data.fileSize = dealFileSize('')
464
510
 
@@ -534,11 +580,14 @@ export default class SpuExpandexp extends HTMLElement {
534
580
  })
535
581
  }
536
582
 
537
- handleDownload () {
583
+ handleDownload() {
538
584
  // console.log(this.data)
539
585
  // console.log(this.data.exportDataItem)
540
586
 
541
- let fixExportFileUrl = this.data.exportDataItem.exportfileurl[0] === '/' ? this.data.exportDataItem.exportfileurl : '/' + this.data.exportDataItem.exportfileurl
587
+ let fixExportFileUrl =
588
+ this.data.exportDataItem.exportfileurl[0] === '/'
589
+ ? this.data.exportDataItem.exportfileurl
590
+ : '/' + this.data.exportDataItem.exportfileurl
542
591
  let exportFileName = this.data.exportDataItem.filename
543
592
  let date = this.data.exportDataItem.initdate
544
593
 
@@ -572,7 +621,7 @@ export default class SpuExpandexp extends HTMLElement {
572
621
  })
573
622
  }
574
623
 
575
- async handleTest () {
624
+ async handleTest() {
576
625
  console.log(this.data)
577
626
  console.log(this.data.exportDataItem)
578
627
 
@@ -597,7 +646,7 @@ export default class SpuExpandexp extends HTMLElement {
597
646
  // DownloadService.downloadFile(this, fixExportFileUrl, date, exportFileName, 'att', 'storage-1d')
598
647
  }
599
648
 
600
- handleCencel () {
649
+ handleCencel() {
601
650
  const $message = this.shadow.querySelector('.spu-expandexp-message') as any
602
651
  // this.vText($message, '取消成功!')
603
652
  // this.vIf($message, true)
@@ -644,11 +693,10 @@ export default class SpuExpandexp extends HTMLElement {
644
693
  this.vIf($message, false)
645
694
  }, 2000)
646
695
  }, 2000)
647
-
648
696
  })
649
697
  }
650
698
 
651
- updateStep (statusName: string) {
699
+ updateStep(statusName: string) {
652
700
  if (statusName === 'next') {
653
701
  this.data.step.next()
654
702
  } else {
@@ -659,11 +707,15 @@ export default class SpuExpandexp extends HTMLElement {
659
707
  this.data.stepText = this.data.step.statusText
660
708
  }
661
709
 
662
- async updateStatus () {
710
+ async updateStatus() {
663
711
  axios
664
- .post(`/api/teapi/queue/impexp/expStatus?dynamicid=${this.data.exportId}`, {}, {
665
- isShowLoading: false
666
- })
712
+ .post(
713
+ `/api/teapi/queue/impexp/expStatus?dynamicid=${this.data.exportId}`,
714
+ {},
715
+ {
716
+ isShowLoading: false
717
+ }
718
+ )
667
719
  .then((res: any) => {
668
720
  let responseData = res?.data?.states
669
721
  let currentData = null
@@ -750,35 +802,40 @@ export default class SpuExpandexp extends HTMLElement {
750
802
  })
751
803
  }
752
804
 
753
- stopInterval () {
805
+ stopInterval() {
754
806
  if (this.statusTimer) {
755
807
  window.clearInterval(this.statusTimer)
756
808
  this.statusTimer = null
757
809
  }
758
810
  }
759
811
 
760
- sendLog (data: any) {
761
- apaasSpuTrackSendLog(merge({
762
- // types: 'exportdownloadfile',
763
- // event: 'exportdownloadfile',
764
- properties: {
765
- formtype: 'spu',
766
- exporttype: this.data.expandStatus,
767
- pagecode: this.props.pagecode
768
- }
769
- }, data))
812
+ sendLog(data: any) {
813
+ apaasSpuTrackSendLog(
814
+ merge(
815
+ {
816
+ // types: 'exportdownloadfile',
817
+ // event: 'exportdownloadfile',
818
+ properties: {
819
+ formtype: 'spu',
820
+ exporttype: this.data.expandStatus,
821
+ pagecode: this.props.pagecode
822
+ }
823
+ },
824
+ data
825
+ )
826
+ )
770
827
  }
771
828
 
772
- removeSelf () {
829
+ removeSelf() {
773
830
  this.parentNode!.removeChild(this)
774
831
  }
775
832
 
776
- attributeChangedCallback (name: any, oldValue: any, newValue: any) {
833
+ attributeChangedCallback(name: any, oldValue: any, newValue: any) {
777
834
  console.log('属性变化', name, oldValue, newValue)
778
835
  }
779
836
 
780
837
  // 当组件从 DOM 文档移除后调用。
781
- disconnectedCallback () {
838
+ disconnectedCallback() {
782
839
  this.stopInterval()
783
840
  // console.log('disconnectedCallback')
784
841
  // setTimeout(() => {
@@ -791,7 +848,7 @@ class Expandexp {
791
848
  ele!: HTMLElement
792
849
  config!: any
793
850
 
794
- constructor (config: any) {
851
+ constructor(config: any) {
795
852
  SpuExpandexp.register()
796
853
  this.config = config
797
854
  this.ele = document.createElement('spu-expandexp')
@@ -823,6 +880,4 @@ const expandexp = (config: any) => {
823
880
  new Expandexp(config)
824
881
  }
825
882
 
826
- export {
827
- expandexp
828
- }
883
+ export { expandexp }