@smart100/spu-web-plugin 0.0.9 → 0.0.12
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.
- package/dist/index.d.ts +12 -19
- package/dist/spu-web-plugin.mjs +44388 -6
- package/package.json +1 -5
- package/src/axios.ts +1 -1
- package/src/components/common/index.ts +19 -0
- package/src/components/expandexp/export.vue +820 -0
- package/src/components/expandexp/icons/icon_csv.png +0 -0
- package/src/components/expandexp/icons/icon_excel.png +0 -0
- package/src/components/expandexp/icons/icon_pdf.png +0 -0
- package/src/components/expandexp/icons/icon_zip.png +0 -0
- package/src/components/expandexp/index.ts +697 -0
- package/src/components/expandexp/step.ts +46 -0
- package/src/components/expandexp/template.ts +320 -0
- package/src/components/expandexp/util.ts +91 -0
- package/src/components/index.ts +7 -0
- package/src/components/loadding/index.ts +152 -0
- package/src/core.js +471 -0
- package/src/index.ts +8 -4
- package/src/install.ts +38 -12
- package/src/login.ts +27 -10
- package/src/oss/downloadService.ts +72 -9
- package/src/test.ts +23 -0
- package/src/types/global.d.ts +1 -1
- package/src/types/shims-lib.d.ts +2 -2
- /package/src/{loadding → components/loadding-vue3}/img/loading.gif +0 -0
- /package/src/{loadding → components/loadding-vue3}/index.ts +0 -0
- /package/src/{loadding → components/loadding-vue3}/index.vue +0 -0
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="spu-export">
|
|
3
|
+
<div
|
|
4
|
+
v-if="!state.isOldVersionService && state.runningTaskCount > 0"
|
|
5
|
+
style="text-align: center; justify-content: center"
|
|
6
|
+
class="el-alert el-alert--error is-light"
|
|
7
|
+
>
|
|
8
|
+
<div class="el-alert__content">
|
|
9
|
+
<span
|
|
10
|
+
class="el-alert__title"
|
|
11
|
+
v-html="
|
|
12
|
+
`导出等待队列中:还有<span style='color: #f5222d;'> ${state.runningTaskCount} </span>位,请耐心稍等...`
|
|
13
|
+
"
|
|
14
|
+
></span>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<section class="title-container">
|
|
19
|
+
<section class="title-tip-container">{{ step.statusText }}</section>
|
|
20
|
+
</section>
|
|
21
|
+
|
|
22
|
+
<div class="select-container" v-if="config.expandStatus !== '1' && step.statusName === 'initial'">
|
|
23
|
+
<section class="title">请选择导出内容</section>
|
|
24
|
+
<div>
|
|
25
|
+
<el-radio-group class="column-checkbox-group" v-model="extconfigParams.exportcontent">
|
|
26
|
+
<el-radio v-for="option in exportcontentOptions" :key="option.value" :label="option.value">{{
|
|
27
|
+
option.label
|
|
28
|
+
}}</el-radio>
|
|
29
|
+
</el-radio-group>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="select-container" v-if="config.expandStatus == '1' && step.statusName === 'initial'">
|
|
34
|
+
<section class="title">请选择导出文件类型</section>
|
|
35
|
+
<div>
|
|
36
|
+
<el-radio-group class="column-checkbox-group" v-model="extconfigParams.filetype">
|
|
37
|
+
<el-radio v-for="option in filetypeOptions" :key="option.value" :label="option.value">{{
|
|
38
|
+
option.label
|
|
39
|
+
}}</el-radio>
|
|
40
|
+
</el-radio-group>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div class="file-container" v-if="step.statusName !== 'initial'">
|
|
45
|
+
<!-- <div class="file-container"> -->
|
|
46
|
+
<div class="file-msg-container">
|
|
47
|
+
<span class="name">
|
|
48
|
+
<span style="padding-right: 10px" v-if="extconfigParams.exportcontent === 'link'">
|
|
49
|
+
<img style="width: 24px" src="./icons/icon_zip.png" />
|
|
50
|
+
</span>
|
|
51
|
+
<span style="padding-right: 10px" v-else>
|
|
52
|
+
<img style="width: 24px" v-if="extconfigParams.filetype === '1'" src="./icons/icon_excel.png" />
|
|
53
|
+
<img style="width: 24px" v-else-if="extconfigParams.filetype === '2'" src="./icons/icon_csv.png" />
|
|
54
|
+
<img style="width: 24px" v-else-if="extconfigParams.filetype === '3'" src="./icons/icon_pdf.png" />
|
|
55
|
+
</span>
|
|
56
|
+
<span class="name-text">{{ filename }}</span>
|
|
57
|
+
</span>
|
|
58
|
+
<span class="size">{{ state.fileSize }}</span>
|
|
59
|
+
</div>
|
|
60
|
+
<el-button
|
|
61
|
+
size="small"
|
|
62
|
+
v-if="(step.statusName === 'error' || step.statusName === 'success') && state.exportDataItem.exportfileurl"
|
|
63
|
+
style="float: right; position: absolute; right: 15px; top: 16px"
|
|
64
|
+
type="primary"
|
|
65
|
+
:class="{
|
|
66
|
+
'success-color': step.statusName === 'success',
|
|
67
|
+
'error-color': step.statusName === 'error'
|
|
68
|
+
}"
|
|
69
|
+
@click="downloadResultFile"
|
|
70
|
+
>
|
|
71
|
+
下载
|
|
72
|
+
</el-button>
|
|
73
|
+
<!-- 取消 -->
|
|
74
|
+
<span
|
|
75
|
+
class="self-icon icon-close status-icon delete-icon"
|
|
76
|
+
@click="cancelHandler"
|
|
77
|
+
v-if="
|
|
78
|
+
(step.statusName === 'running' || step.statusName === 'ready') &&
|
|
79
|
+
(!state.exportDataItem.exportstate ||
|
|
80
|
+
state.exportDataItem.exportstate === 'readyrun' ||
|
|
81
|
+
state.exportDataItem.exportstate === 'running')
|
|
82
|
+
"
|
|
83
|
+
/>
|
|
84
|
+
<el-progress
|
|
85
|
+
v-if="
|
|
86
|
+
step.statusName === 'running' ||
|
|
87
|
+
step.statusName === 'success' ||
|
|
88
|
+
step.statusName === 'error' ||
|
|
89
|
+
step.statusName === 'ext_readyrun' ||
|
|
90
|
+
step.statusName === 'ext_running'
|
|
91
|
+
"
|
|
92
|
+
:percentage="state.percentage"
|
|
93
|
+
:stroke-width="8"
|
|
94
|
+
:show-text="state.percentage == 100 ? false : true"
|
|
95
|
+
:status="
|
|
96
|
+
state.percentage != 100
|
|
97
|
+
? ''
|
|
98
|
+
: step.statusName == 'success'
|
|
99
|
+
? 'success'
|
|
100
|
+
: step.statusName == 'error'
|
|
101
|
+
? 'exception'
|
|
102
|
+
: ''
|
|
103
|
+
"
|
|
104
|
+
/>
|
|
105
|
+
|
|
106
|
+
<div
|
|
107
|
+
:class="{
|
|
108
|
+
'result-container': true,
|
|
109
|
+
success: step.statusName === 'success',
|
|
110
|
+
error: step.statusName === 'error'
|
|
111
|
+
}"
|
|
112
|
+
v-if="state.resultMessage"
|
|
113
|
+
>
|
|
114
|
+
{{ state.resultMessage }}
|
|
115
|
+
</div>
|
|
116
|
+
<div
|
|
117
|
+
class="result-tip"
|
|
118
|
+
v-if="
|
|
119
|
+
step.statusName === 'running' ||
|
|
120
|
+
step.statusName === 'ready' ||
|
|
121
|
+
step.statusName === 'ext_readyrun' ||
|
|
122
|
+
step.statusName === 'ext_running' ||
|
|
123
|
+
step.statusName === 'success'
|
|
124
|
+
"
|
|
125
|
+
>
|
|
126
|
+
您可以随时关闭该弹框,之后在导入导出列表中查看结果。
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="btnwrap" v-if="step.statusName === 'initial'">
|
|
131
|
+
<el-button type="primary" @click="handleExport">导出</el-button>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
<script lang="ts" setup>
|
|
136
|
+
import { ElMessageBox, ElMessage } from 'element-plus'
|
|
137
|
+
import {
|
|
138
|
+
watchEffect,
|
|
139
|
+
computed,
|
|
140
|
+
nextTick,
|
|
141
|
+
onBeforeUnmount,
|
|
142
|
+
onMounted,
|
|
143
|
+
onBeforeMount,
|
|
144
|
+
PropType,
|
|
145
|
+
reactive,
|
|
146
|
+
ref
|
|
147
|
+
} from 'vue'
|
|
148
|
+
import { Step } from './step'
|
|
149
|
+
import { merge } from 'lodash-es'
|
|
150
|
+
import {
|
|
151
|
+
apaasAxios,
|
|
152
|
+
spuAxios,
|
|
153
|
+
getUniqueid,
|
|
154
|
+
spuConfig,
|
|
155
|
+
downloadService,
|
|
156
|
+
getUser,
|
|
157
|
+
lsProxy
|
|
158
|
+
} from '@smart100/spu-web-plugin'
|
|
159
|
+
import { dealResultMessage } from './util'
|
|
160
|
+
import { dealFileSize } from './util'
|
|
161
|
+
import { downloadFileForUrl } from '@/utils/index'
|
|
162
|
+
|
|
163
|
+
const props = withDefaults(
|
|
164
|
+
defineProps<{
|
|
165
|
+
exportApi: string
|
|
166
|
+
sheetname: string
|
|
167
|
+
pagecode?: string
|
|
168
|
+
data?: any
|
|
169
|
+
}>(),
|
|
170
|
+
{
|
|
171
|
+
sheetname: '',
|
|
172
|
+
pagecode: '',
|
|
173
|
+
data: {}
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const config = reactive({
|
|
178
|
+
expandStatus: '1', // 1普通导出(没有做图片导出服务) 2服务端导出(做了图片导出服务未SPU化) 3安装了图片导出SPU
|
|
179
|
+
exportcontentArray: ['excel', 'link', 'photo'], // 当 expandStatus = 2 | 3时才显示导出内容给用户选择
|
|
180
|
+
// 新导出的文件类型选择
|
|
181
|
+
filetypeArray: ['1', '2']
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const extconfigParams = reactive<any>({
|
|
185
|
+
filetype: '1', // 导出文件类型 1: xls 2: csv 3: pdf 目前spu的导出只实现了xls 因此写死xls
|
|
186
|
+
exportcontent: 'excel', // excel.仅导出单据,link,导出单据和本地链接,photo.导出单据和图片
|
|
187
|
+
filewatermark: '0', // 1.开启文件水印,0.关闭文件水印
|
|
188
|
+
iscompress: '0', // 1.压缩,0.原图
|
|
189
|
+
displaytype: 'horizontal', // horizontal:横向排列 vertical:纵向排列 multi-row:分行展示
|
|
190
|
+
imagetype: 'origin', // 导出图片类型 png jpg origin 默认origin
|
|
191
|
+
imagename: '', // 图片命名规则
|
|
192
|
+
// imagesizepercolumn 和 imageheightcm 为 图片导出SPU新增配置项
|
|
193
|
+
imagesizepercolumn: '5',
|
|
194
|
+
imageheightcm: '2'
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
const filename = computed(() => {
|
|
198
|
+
let filename = ''
|
|
199
|
+
if (extconfigParams.exportcontent === 'link') {
|
|
200
|
+
filename = props.sheetname + '.zip'
|
|
201
|
+
} else {
|
|
202
|
+
if (extconfigParams.filetype === '1') {
|
|
203
|
+
filename = props.sheetname + '.xlsx'
|
|
204
|
+
} else if (extconfigParams.filetype === '2') {
|
|
205
|
+
filename = props.sheetname + '.csv'
|
|
206
|
+
} else if (extconfigParams.filetype === '3') {
|
|
207
|
+
filename = props.sheetname + '.pdf'
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return filename
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
const exportcontentOptions = computed(() => {
|
|
214
|
+
const mapTitle: any = {
|
|
215
|
+
excel: '仅导出单据',
|
|
216
|
+
link: '导出单据和本地链接',
|
|
217
|
+
photo: '导出单据和图片'
|
|
218
|
+
}
|
|
219
|
+
return config.exportcontentArray.map((item) => {
|
|
220
|
+
return {
|
|
221
|
+
label: mapTitle[item],
|
|
222
|
+
value: item
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
const filetypeOptions = computed(() => {
|
|
228
|
+
const mapTitle: any = {
|
|
229
|
+
'1': 'xlsx',
|
|
230
|
+
'2': 'csv',
|
|
231
|
+
'3': 'pdf'
|
|
232
|
+
}
|
|
233
|
+
const options = config.filetypeArray.map((item) => {
|
|
234
|
+
return {
|
|
235
|
+
label: mapTitle[item],
|
|
236
|
+
value: item
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
if (extconfigParams.exportcontent === 'link' || extconfigParams.exportcontent === 'photo') {
|
|
240
|
+
return options.filter((v) => {
|
|
241
|
+
return v.value !== '2' && v.value !== '3'
|
|
242
|
+
})
|
|
243
|
+
} else {
|
|
244
|
+
return options
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
watchEffect(() => {
|
|
249
|
+
if (extconfigParams.exportcontent === 'link' || extconfigParams.exportcontent === 'photo') {
|
|
250
|
+
// 当选择了 link 或者 photo 时 文件类型只能选择导出xlsx
|
|
251
|
+
extconfigParams.filetype = '1'
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
const step = ref(new Step())
|
|
256
|
+
|
|
257
|
+
const state = reactive<any>({
|
|
258
|
+
percentage: 0,
|
|
259
|
+
resultMessage: '',
|
|
260
|
+
exportDataItem: {},
|
|
261
|
+
exportId: '',
|
|
262
|
+
fileSize: '',
|
|
263
|
+
runningTaskCount: 0,
|
|
264
|
+
isOldVersionService: false
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// 获取导出服务配置
|
|
268
|
+
const getConfig = async () => {
|
|
269
|
+
let isInstallexpandexp = false
|
|
270
|
+
// isInstallexpandexp = true
|
|
271
|
+
if (window?.Module?.checkPermission) {
|
|
272
|
+
isInstallexpandexp = window.Module.checkPermission({
|
|
273
|
+
modulekey: 'expandexp'
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (isInstallexpandexp) {
|
|
278
|
+
config.expandStatus = '3'
|
|
279
|
+
config.filetypeArray = ['1']
|
|
280
|
+
extconfigParams.filewatermark = '1'
|
|
281
|
+
extconfigParams.iscompress = '1'
|
|
282
|
+
|
|
283
|
+
if (window?.Module?.apiRequest) {
|
|
284
|
+
console.log('调用 window.Module.apiRequest')
|
|
285
|
+
window.Module.apiRequest({
|
|
286
|
+
modulekey: 'expandexp',
|
|
287
|
+
apitag: 'imageConfig-getByPageCode',
|
|
288
|
+
body: {
|
|
289
|
+
pagecode: props.pagecode
|
|
290
|
+
},
|
|
291
|
+
complete: (code: any, data: any, msg: any) => {
|
|
292
|
+
// console.log('imageConfig', code, data, msg)
|
|
293
|
+
if (code === 200) {
|
|
294
|
+
config.exportcontentArray = data.exportcontent
|
|
295
|
+
|
|
296
|
+
extconfigParams.iscompress = data.iscompress.toString()
|
|
297
|
+
extconfigParams.filewatermark = data.filewatermark.toString()
|
|
298
|
+
extconfigParams.imagesizepercolumn = data.imagesizepercolumn.toString()
|
|
299
|
+
extconfigParams.imageheightcm = data.imageheightcm.toString()
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
} else {
|
|
304
|
+
apaasAxios
|
|
305
|
+
.post('/api/expandexp/v1.0/imageConfig/getByPageCode', {
|
|
306
|
+
pagecode: props.pagecode
|
|
307
|
+
})
|
|
308
|
+
.then((res: any) => {
|
|
309
|
+
// console.log(res)
|
|
310
|
+
// debugger
|
|
311
|
+
if (res?.data?.code === 200 && res?.data?.data) {
|
|
312
|
+
const data = res.data.data
|
|
313
|
+
config.exportcontentArray = data.exportcontent
|
|
314
|
+
|
|
315
|
+
extconfigParams.iscompress = data.iscompress.toString()
|
|
316
|
+
extconfigParams.filewatermark = data.filewatermark.toString()
|
|
317
|
+
extconfigParams.imagesizepercolumn = data.imagesizepercolumn.toString()
|
|
318
|
+
extconfigParams.imageheightcm = data.imageheightcm.toString()
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
extconfigParams.filewatermark = '0'
|
|
324
|
+
extconfigParams.iscompress = '0'
|
|
325
|
+
apaasAxios
|
|
326
|
+
.post('/api/expandexp/global/searchExpGloConfig', {
|
|
327
|
+
key: 'export-config-switch',
|
|
328
|
+
tenantcode: getUser('tenantcode'),
|
|
329
|
+
productcode: getUser('productcode')
|
|
330
|
+
})
|
|
331
|
+
.then((res: any) => {
|
|
332
|
+
// res.data.exttype = '1'
|
|
333
|
+
// res.data.exttype: 2开启了为服务端导出 1为普通导出
|
|
334
|
+
if (res.code === 200 && res?.data?.exttype === '2') {
|
|
335
|
+
config.expandStatus = '2'
|
|
336
|
+
config.filetypeArray = ['1']
|
|
337
|
+
} else {
|
|
338
|
+
config.expandStatus = '1'
|
|
339
|
+
config.filetypeArray = ['1', '2']
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
.catch((err: Error) => {
|
|
343
|
+
config.expandStatus = '1'
|
|
344
|
+
config.filetypeArray = ['1', '2']
|
|
345
|
+
})
|
|
346
|
+
// 获取文件水印开关
|
|
347
|
+
apaasAxios
|
|
348
|
+
.post('/api/expandexp/global/searchWatermarkConfig', '')
|
|
349
|
+
.then((res: any) => {
|
|
350
|
+
if (res.code === 200 && res?.data?.configjson) {
|
|
351
|
+
extconfigParams.filewatermark = JSON.parse(res.data.configjson).isWatermark === '1' ? '1' : '0'
|
|
352
|
+
} else {
|
|
353
|
+
extconfigParams.filewatermark = '0'
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
.catch(() => {
|
|
357
|
+
extconfigParams.filewatermark = '0'
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
let statusTimer: number | null = null
|
|
363
|
+
|
|
364
|
+
const handleExport = async () => {
|
|
365
|
+
// window.setInterval(() => {
|
|
366
|
+
// step.value.next()
|
|
367
|
+
// }, 2000)
|
|
368
|
+
// return false
|
|
369
|
+
|
|
370
|
+
step.value.next()
|
|
371
|
+
state.fileSize = dealFileSize('')
|
|
372
|
+
|
|
373
|
+
// console.log({
|
|
374
|
+
// expfile: {
|
|
375
|
+
// pagecode: props.pagecode,
|
|
376
|
+
// sheetname: props.sheetname,
|
|
377
|
+
// filename: filename.value,
|
|
378
|
+
// filetype: extconfigParams.filetype,
|
|
379
|
+
// // exttype 1.普通导出,2.服务端导出
|
|
380
|
+
// // 如果为1 或没有这个属性,视为不拓展,前端做兼容
|
|
381
|
+
// // 如果是仅导出单据 默认走普通导出 exttype = '1'
|
|
382
|
+
// // 因为如果仅导出单据 + 支持水印,又要传 exttype = '2',很麻烦,改为后端处理,如果 expandStatus = 2 | 3 ,exttype就传2,其他情况传1
|
|
383
|
+
// // exttype: (config.exportcontentValue === 'excel' || config.expandStatus === '1') ? '1' : '2',
|
|
384
|
+
// exttype: config.expandStatus === '1' ? '1' : '2',
|
|
385
|
+
// // 扩展导出参数
|
|
386
|
+
// extconfig: {
|
|
387
|
+
// ...extconfigParams
|
|
388
|
+
// }
|
|
389
|
+
// }
|
|
390
|
+
// })
|
|
391
|
+
// debugger
|
|
392
|
+
|
|
393
|
+
const post = merge(props.data, {
|
|
394
|
+
expfile: {
|
|
395
|
+
pagecode: props.pagecode,
|
|
396
|
+
sheetname: props.sheetname,
|
|
397
|
+
filename: filename.value,
|
|
398
|
+
filetype: extconfigParams.filetype,
|
|
399
|
+
// exttype 1.普通导出,2.服务端导出
|
|
400
|
+
// 如果为1 或没有这个属性,视为不拓展,前端做兼容
|
|
401
|
+
// 如果是仅导出单据 默认走普通导出 exttype = '1'
|
|
402
|
+
// 因为如果仅导出单据 + 支持水印,又要传 exttype = '2',很麻烦,改为后端处理,如果 expandStatus = 2 | 3 ,exttype就传2,其他情况传1
|
|
403
|
+
// exttype: (config.exportcontentValue === 'excel' || config.expandStatus === '1') ? '1' : '2',
|
|
404
|
+
exttype: config.expandStatus === '1' ? '1' : '2',
|
|
405
|
+
// 扩展导出参数
|
|
406
|
+
extconfig: {
|
|
407
|
+
...extconfigParams
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
})
|
|
411
|
+
apaasAxios
|
|
412
|
+
.post(props.exportApi, post)
|
|
413
|
+
.then((res: any) => {
|
|
414
|
+
// console.log(res)
|
|
415
|
+
// debugger
|
|
416
|
+
if (res?.data?.code === 200 && res?.data?.data) {
|
|
417
|
+
state.exportId = res.data.data
|
|
418
|
+
state.percentage = 0
|
|
419
|
+
// 到ready
|
|
420
|
+
step.value.go('ready')
|
|
421
|
+
nextTick(() => {
|
|
422
|
+
updateStatus()
|
|
423
|
+
})
|
|
424
|
+
statusTimer = window.setInterval(() => {
|
|
425
|
+
updateStatus()
|
|
426
|
+
}, 2000)
|
|
427
|
+
} else {
|
|
428
|
+
step.value.go('error')
|
|
429
|
+
state.percentage = 100
|
|
430
|
+
state.resultMessage = res?.data?.msg || '网络连接错误'
|
|
431
|
+
stopInterval()
|
|
432
|
+
}
|
|
433
|
+
})
|
|
434
|
+
.catch((error: any) => {
|
|
435
|
+
// debugger
|
|
436
|
+
step.value.go('error')
|
|
437
|
+
state.percentage = 100
|
|
438
|
+
state.resultMessage = '网络连接错误'
|
|
439
|
+
// if (!error || error.response.status === 0 || error.response.status === 404) {
|
|
440
|
+
// state.resultMessage = '网络连接错误'
|
|
441
|
+
// } else {
|
|
442
|
+
// state.resultMessage = '网络连接错误'
|
|
443
|
+
// }
|
|
444
|
+
stopInterval()
|
|
445
|
+
})
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const updateStatus = async () => {
|
|
449
|
+
apaasAxios
|
|
450
|
+
.post(`/api/teapi/queue/impexp/expStatus?dynamicid=${state.exportId}`)
|
|
451
|
+
.then((res: any) => {
|
|
452
|
+
let responseData = res?.data?.states
|
|
453
|
+
let currentData = null
|
|
454
|
+
if (!responseData) {
|
|
455
|
+
state.isOldVersionService = true
|
|
456
|
+
return
|
|
457
|
+
} else {
|
|
458
|
+
if (Array.isArray(responseData)) {
|
|
459
|
+
state.isOldVersionService = true
|
|
460
|
+
if (responseData.length > 1) {
|
|
461
|
+
responseData = responseData.filter((item: any) => {
|
|
462
|
+
return item.dynamicid === state.exportId
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
currentData = responseData[0]
|
|
466
|
+
} else {
|
|
467
|
+
state.isOldVersionService = false
|
|
468
|
+
state.runningTaskCount = responseData.queuesize
|
|
469
|
+
if (responseData.states && responseData.states.length > 1) {
|
|
470
|
+
responseData.states = responseData.states.filter((item: any) => {
|
|
471
|
+
return item.dynamicid === state.exportId
|
|
472
|
+
})
|
|
473
|
+
}
|
|
474
|
+
currentData = responseData.states && responseData.states[0]
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (!currentData) {
|
|
478
|
+
return
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (currentData.exportstate === 'complete') {
|
|
482
|
+
const data = currentData
|
|
483
|
+
state.percentage = 100
|
|
484
|
+
if (data.errorfileurl || data.fatalerrormsg) {
|
|
485
|
+
step.value.go('error')
|
|
486
|
+
} else {
|
|
487
|
+
step.value.go('success')
|
|
488
|
+
}
|
|
489
|
+
if (data.filesize) {
|
|
490
|
+
// 普通导出服务返回 4000 服务端导出返回 4kb
|
|
491
|
+
// 这里做兼容处理
|
|
492
|
+
state.fileSize = dealFileSize(data.filesize)
|
|
493
|
+
}
|
|
494
|
+
state.exportDataItem = data
|
|
495
|
+
state.resultMessage = dealResultMessage(data)
|
|
496
|
+
stopInterval()
|
|
497
|
+
} else if (currentData.exportstate === 'readyrun') {
|
|
498
|
+
step.value.go('ready')
|
|
499
|
+
} else if (currentData.exportstate === 'fatalerror') {
|
|
500
|
+
state.percentage = 100
|
|
501
|
+
step.value.go('error')
|
|
502
|
+
state.resultMessage = dealResultMessage(currentData)
|
|
503
|
+
stopInterval()
|
|
504
|
+
} else if (currentData.exportstate === 'cancel') {
|
|
505
|
+
console.log('cancel')
|
|
506
|
+
} else if (currentData.exportstate === 'ext_readyrun') {
|
|
507
|
+
step.value.go('ext_readyrun')
|
|
508
|
+
if (currentData) {
|
|
509
|
+
state.percentage = +currentData.finishRate * 0.5 + 50
|
|
510
|
+
}
|
|
511
|
+
} else if (currentData.exportstate === 'ext_running') {
|
|
512
|
+
step.value.go('ext_running')
|
|
513
|
+
// debugger
|
|
514
|
+
if (currentData) {
|
|
515
|
+
state.percentage = +currentData.finishRate * 0.5 + 50
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
step.value.go('running')
|
|
519
|
+
if (currentData) {
|
|
520
|
+
state.percentage = +currentData.finishRate * 0.5
|
|
521
|
+
// state.percentage = +currentData.finishRate
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
.catch((err: any) => {
|
|
526
|
+
console.error(err)
|
|
527
|
+
step.value.go('error')
|
|
528
|
+
state.percentage = 100
|
|
529
|
+
if (err.status === 0) {
|
|
530
|
+
state.resultMessage = '网络链接错误'
|
|
531
|
+
stopInterval()
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const downloadResultFile = async () => {
|
|
537
|
+
// // 下载错误的数据
|
|
538
|
+
// let fixExportFileUrl = this.exportDataItem.exportfileurl[0] === '/' ? this.exportDataItem.exportfileurl : '/' + this.exportDataItem.exportfileurl
|
|
539
|
+
// let exportFileName = this.exportDataItem.filename
|
|
540
|
+
// let date = this.exportDataItem.initdate
|
|
541
|
+
// DownloadService.downloadFile(this, fixExportFileUrl, date, exportFileName, 'att', 'storage-1d')
|
|
542
|
+
|
|
543
|
+
const fixExportFileUrl =
|
|
544
|
+
state.exportDataItem.exportfileurl[0] === '/'
|
|
545
|
+
? state.exportDataItem.exportfileurl
|
|
546
|
+
: '/' + state.exportDataItem.exportfileurl
|
|
547
|
+
const exportFileName = state.exportDataItem.filename
|
|
548
|
+
// const date = state.exportDataItem.initdate + ''
|
|
549
|
+
// downloadFile(fixExportFileUrl, date, {
|
|
550
|
+
// storage: 'storage-1d',
|
|
551
|
+
// uploadType: 'att',
|
|
552
|
+
// fileName: exportFileName
|
|
553
|
+
// })
|
|
554
|
+
|
|
555
|
+
const cloudserv: any = JSON.parse(lsProxy.getItem('cloudserv') as string)
|
|
556
|
+
const endpoint = cloudserv?.storage?.cloudserv_storage_storageendpoint
|
|
557
|
+
const bucket = cloudserv?.storage?.cloudserv_storage_storagebucket
|
|
558
|
+
downloadFileForUrl(`https://${bucket}.${endpoint}${fixExportFileUrl}`, exportFileName)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const cancelHandler = () => {
|
|
562
|
+
// ElMessageBox.confirm('确认是否取消该任务?', '提示', {
|
|
563
|
+
// distinguishCancelAndClose: true,
|
|
564
|
+
// confirmButtonText: '确定取消',
|
|
565
|
+
// cancelButtonText: '放弃'
|
|
566
|
+
// })
|
|
567
|
+
// .then(async () => {
|
|
568
|
+
// try {
|
|
569
|
+
// await cancelFormImportExport(state.exportId)
|
|
570
|
+
// step.value.go('cancel')
|
|
571
|
+
// state.resultMessage = $t('任务已取消')
|
|
572
|
+
// ElMessage.success($t('任务已取消'))
|
|
573
|
+
// } catch (error) {
|
|
574
|
+
// window.$logger.error(error)
|
|
575
|
+
// ElMessage.error($t('删除失败'))
|
|
576
|
+
// }
|
|
577
|
+
// })
|
|
578
|
+
// .catch(() => { })
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const stopInterval = () => {
|
|
582
|
+
if (statusTimer) {
|
|
583
|
+
window.clearInterval(statusTimer)
|
|
584
|
+
statusTimer = null
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
onBeforeMount(() => {
|
|
589
|
+
getConfig()
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
onBeforeUnmount(() => {
|
|
593
|
+
stopInterval()
|
|
594
|
+
})
|
|
595
|
+
</script>
|
|
596
|
+
|
|
597
|
+
<style lang="less">
|
|
598
|
+
.spu-export {
|
|
599
|
+
padding: 0 12px;
|
|
600
|
+
|
|
601
|
+
.title-container {
|
|
602
|
+
display: flex;
|
|
603
|
+
justify-content: space-between;
|
|
604
|
+
vertical-align: baseline;
|
|
605
|
+
align-content: space-between;
|
|
606
|
+
.title-tip-container {
|
|
607
|
+
line-height: 32px;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.select-container {
|
|
612
|
+
.title {
|
|
613
|
+
margin-bottom: 20px;
|
|
614
|
+
margin-top: 10px;
|
|
615
|
+
position: relative;
|
|
616
|
+
|
|
617
|
+
&:before {
|
|
618
|
+
content: '*';
|
|
619
|
+
display: inline;
|
|
620
|
+
color: #e53c51;
|
|
621
|
+
padding-right: 2px;
|
|
622
|
+
font-size: 24px;
|
|
623
|
+
vertical-align: middle;
|
|
624
|
+
position: absolute;
|
|
625
|
+
left: -12px;
|
|
626
|
+
top: 1px;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.error-tips {
|
|
631
|
+
font-size: 12px;
|
|
632
|
+
color: #e53c51;
|
|
633
|
+
position: absolute;
|
|
634
|
+
left: 0px;
|
|
635
|
+
top: 18px;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.el-radio-group {
|
|
639
|
+
width: 100%;
|
|
640
|
+
padding-bottom: 10px;
|
|
641
|
+
|
|
642
|
+
.el-radio {
|
|
643
|
+
padding: 4px 0;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.el-checkbox,
|
|
648
|
+
.el-radio-wrapper {
|
|
649
|
+
width: 50%;
|
|
650
|
+
line-height: 2;
|
|
651
|
+
margin-right: 0px;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.column-checkbox-container {
|
|
655
|
+
display: block;
|
|
656
|
+
|
|
657
|
+
.column-checkbox-group {
|
|
658
|
+
width: 100%;
|
|
659
|
+
display: block;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
.el-checkbox {
|
|
664
|
+
display: inline-flex;
|
|
665
|
+
margin-bottom: 8px;
|
|
666
|
+
|
|
667
|
+
.el-checkbox__label {
|
|
668
|
+
flex: 1;
|
|
669
|
+
white-space: break-spaces;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
.select-all-columns {
|
|
674
|
+
float: right;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.file-container {
|
|
679
|
+
border: 1px solid #d9d9d9;
|
|
680
|
+
min-height: 98px;
|
|
681
|
+
padding: 15px;
|
|
682
|
+
position: relative;
|
|
683
|
+
|
|
684
|
+
.file-msg-container {
|
|
685
|
+
display: flex;
|
|
686
|
+
margin-bottom: 10px;
|
|
687
|
+
width: calc(100% - 72px);
|
|
688
|
+
position: relative;
|
|
689
|
+
justify-content: space-between;
|
|
690
|
+
// align-items: baseline;
|
|
691
|
+
align-content: center;
|
|
692
|
+
|
|
693
|
+
.icon {
|
|
694
|
+
font-size: 32px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.self-icon {
|
|
698
|
+
font-size: 28px;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.icon-inoutbox {
|
|
702
|
+
color: #1989fa;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.name {
|
|
706
|
+
line-height: 32px;
|
|
707
|
+
height: 32px;
|
|
708
|
+
margin-right: 10px;
|
|
709
|
+
white-space: nowrap;
|
|
710
|
+
overflow: hidden;
|
|
711
|
+
text-overflow: ellipsis;
|
|
712
|
+
display: flex;
|
|
713
|
+
align-items: center;
|
|
714
|
+
|
|
715
|
+
.name-text {
|
|
716
|
+
margin-left: 4px;
|
|
717
|
+
font-size: 14px;
|
|
718
|
+
color: #333333;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.size {
|
|
723
|
+
line-height: 32px;
|
|
724
|
+
white-space: nowrap;
|
|
725
|
+
padding-right: 20px;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.delete-icon {
|
|
730
|
+
position: absolute;
|
|
731
|
+
right: 15px;
|
|
732
|
+
top: 26px;
|
|
733
|
+
font-size: 22px;
|
|
734
|
+
width: 22px;
|
|
735
|
+
height: 22px;
|
|
736
|
+
line-height: 22px;
|
|
737
|
+
border-radius: 11px;
|
|
738
|
+
color: #999;
|
|
739
|
+
cursor: pointer;
|
|
740
|
+
/*background: #d9d9d9;*/
|
|
741
|
+
padding-top: 3px;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.status-icon {
|
|
745
|
+
position: absolute;
|
|
746
|
+
right: 15px;
|
|
747
|
+
top: 26px;
|
|
748
|
+
font-size: 22px;
|
|
749
|
+
width: 22px;
|
|
750
|
+
height: 22px;
|
|
751
|
+
line-height: 22px;
|
|
752
|
+
|
|
753
|
+
&.success-icon {
|
|
754
|
+
color: #13ce66;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.self-icon.icon-download {
|
|
759
|
+
font-size: 13px;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.error-color {
|
|
763
|
+
background: #e75b41;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.success-color {
|
|
767
|
+
background: #00b389;
|
|
768
|
+
border-color: #00b389;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.result-container {
|
|
772
|
+
height: 28px;
|
|
773
|
+
line-height: 28px;
|
|
774
|
+
text-align: right;
|
|
775
|
+
font-size: 12px;
|
|
776
|
+
padding: 0px 8px;
|
|
777
|
+
|
|
778
|
+
&.error {
|
|
779
|
+
background: #fdf1ef;
|
|
780
|
+
white-space: nowrap;
|
|
781
|
+
text-overflow: ellipsis;
|
|
782
|
+
overflow: hidden;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
&.success {
|
|
786
|
+
background: #e5f7f3;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.result-tip {
|
|
791
|
+
height: 28px;
|
|
792
|
+
line-height: 28px;
|
|
793
|
+
margin-top: 8px;
|
|
794
|
+
font-size: 12px;
|
|
795
|
+
text-align: right;
|
|
796
|
+
color: #999;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.el-progress--line {
|
|
801
|
+
.el-progress__text {
|
|
802
|
+
display: none;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.el-progress-bar__outer {
|
|
806
|
+
border-radius: 0px;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.el-progress-bar__inner {
|
|
810
|
+
border-radius: 0px;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
.btnwrap {
|
|
815
|
+
margin-top: 12px;
|
|
816
|
+
display: flex;
|
|
817
|
+
flex-direction: row-reverse;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
</style>
|