vue2-client 1.16.27 → 1.16.29
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/package.json +112 -112
- package/src/base-client/components/common/HIS/HForm/HForm.vue +1 -1
- package/src/base-client/components/common/Upload/Upload.vue +333 -333
- package/src/base-client/components/common/XForm/XFormItem.vue +1504 -1504
- package/src/base-client/components/common/XFormTable/demo.vue +16 -45
- package/src/base-client/components/common/XReport/print.js +186 -186
- package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +4 -1
- package/src/components/FileImageItem/FileItem.vue +320 -320
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandle.vue +1766 -1766
- package/src/router/guards.js +7 -2
- package/src/services/api/common.js +4 -0
- package/src/utils/map-utils.js +47 -47
@@ -1,333 +1,333 @@
|
|
1
|
-
<template>
|
2
|
-
<div>
|
3
|
-
<template v-if="uploadStyle === 'simple'">
|
4
|
-
<a-upload
|
5
|
-
:accept="model.accept?.join('')"
|
6
|
-
:customRequest="uploadFiles"
|
7
|
-
:multiple="model.acceptCount && model.acceptCount>1"
|
8
|
-
:file-list="uploadedFileList"
|
9
|
-
:remove="deleteFileItem">
|
10
|
-
<a-space>
|
11
|
-
<a-button style="margin-top: 2%">
|
12
|
-
<a-icon type="upload"/>
|
13
|
-
上传
|
14
|
-
</a-button>
|
15
|
-
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
16
|
-
高拍仪
|
17
|
-
</a-button>
|
18
|
-
</a-space>
|
19
|
-
</a-upload>
|
20
|
-
</template>
|
21
|
-
<a-upload-dragger
|
22
|
-
v-else-if="model.type === 'file'"
|
23
|
-
:accept="model.accept?.join('')"
|
24
|
-
:customRequest="uploadFiles"
|
25
|
-
:file-list="uploadedFileList"
|
26
|
-
:multiple="true"
|
27
|
-
:remove="deleteFileItem"
|
28
|
-
name="file">
|
29
|
-
<p class="ant-upload-drag-icon">
|
30
|
-
<a-icon type="inbox"/>
|
31
|
-
</p>
|
32
|
-
<p class="ant-upload-text">
|
33
|
-
点击或拖动文件到该区域上传
|
34
|
-
</p>
|
35
|
-
<p class="ant-upload-hint">
|
36
|
-
支持单个或多个文件
|
37
|
-
</p>
|
38
|
-
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
39
|
-
高拍仪
|
40
|
-
</a-button>
|
41
|
-
</a-upload-dragger>
|
42
|
-
<a-upload
|
43
|
-
v-else
|
44
|
-
@preview="handlePreview"
|
45
|
-
:accept="model.accept?.join('')"
|
46
|
-
:multiple="model.acceptCount && model.acceptCount>1"
|
47
|
-
:customRequest="uploadFiles"
|
48
|
-
:file-list="uploadedFileList"
|
49
|
-
:remove="deleteFileItem"
|
50
|
-
:show-upload-list="{
|
51
|
-
showRemoveIcon: !readOnly,
|
52
|
-
showPreviewIcon: true,
|
53
|
-
showDownloadIcon: false
|
54
|
-
}"
|
55
|
-
list-type="picture-card">
|
56
|
-
<a-icon v-if="!readOnly" type="plus"/>
|
57
|
-
<div v-if="!readOnly" class="ant-upload-text">
|
58
|
-
上传图片
|
59
|
-
</div>
|
60
|
-
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
61
|
-
高拍仪
|
62
|
-
</a-button>
|
63
|
-
</a-upload>
|
64
|
-
<height-scanner v-if="useScanner" @confirmPhoto="confirmPhoto" ref="heightScanner"/>
|
65
|
-
<a-modal
|
66
|
-
v-model="previewVisible"
|
67
|
-
:footer="null"
|
68
|
-
width="60vw"
|
69
|
-
:dialogStyle="{ top: '20px' }"
|
70
|
-
wrapClassName="image-preview-modal"
|
71
|
-
>
|
72
|
-
<div class="image-preview-container">
|
73
|
-
<img
|
74
|
-
:src="previewImage"
|
75
|
-
alt=""
|
76
|
-
class="preview-image"
|
77
|
-
style="width: 100%; height: 100%;"
|
78
|
-
>
|
79
|
-
</div>
|
80
|
-
</a-modal>
|
81
|
-
</div>
|
82
|
-
</template>
|
83
|
-
|
84
|
-
<script>
|
85
|
-
|
86
|
-
import { mapState } from 'vuex'
|
87
|
-
import { fileDelete, fileDeleteV4, upload } from '@vue2-client/services/api/common'
|
88
|
-
import HeightScanner from '@vue2-client/components/HeightScanner/index.vue'
|
89
|
-
import { base64ToFile } from '@vue2-client/utils/util'
|
90
|
-
import moment from 'moment'
|
91
|
-
export default {
|
92
|
-
name: 'Uploads',
|
93
|
-
data () {
|
94
|
-
return {
|
95
|
-
uploadedFileList: [],
|
96
|
-
previewVisible: false,
|
97
|
-
previewImage: ''
|
98
|
-
}
|
99
|
-
},
|
100
|
-
props: {
|
101
|
-
// 表单属性
|
102
|
-
model: {
|
103
|
-
type: Object,
|
104
|
-
default: () => {
|
105
|
-
return {}
|
106
|
-
}
|
107
|
-
},
|
108
|
-
files: {
|
109
|
-
type: Array,
|
110
|
-
default: () => {
|
111
|
-
return []
|
112
|
-
}
|
113
|
-
},
|
114
|
-
images: {
|
115
|
-
type: Array,
|
116
|
-
default: () => {
|
117
|
-
return []
|
118
|
-
}
|
119
|
-
},
|
120
|
-
serviceName: {
|
121
|
-
type: String,
|
122
|
-
default: undefined
|
123
|
-
},
|
124
|
-
uploadStyle: {
|
125
|
-
type: String,
|
126
|
-
default: undefined
|
127
|
-
},
|
128
|
-
// outerContainerIndex,是为了XReport,返回外侧行的Index,每一行都有可能有图片,所以要知道是哪一个Index发出的事件
|
129
|
-
outerContainerIndex: {
|
130
|
-
type: [String, Number],
|
131
|
-
default: undefined
|
132
|
-
},
|
133
|
-
// 图片上传后添加前缀
|
134
|
-
imgPrefix: {
|
135
|
-
type: String,
|
136
|
-
default: undefined
|
137
|
-
},
|
138
|
-
// 是否开启高拍仪
|
139
|
-
useScanner: {
|
140
|
-
type: Boolean,
|
141
|
-
default: false
|
142
|
-
},
|
143
|
-
// 是否只读
|
144
|
-
readOnly: {
|
145
|
-
type: Boolean,
|
146
|
-
default: false
|
147
|
-
}
|
148
|
-
},
|
149
|
-
computed: {
|
150
|
-
...mapState('account', { currUser: 'user' }),
|
151
|
-
...mapState('setting', ['compatible'])
|
152
|
-
},
|
153
|
-
created () {
|
154
|
-
const list = this.model.type === 'file' ? [...this.files] : [...this.images]
|
155
|
-
if (this.model.useType) {
|
156
|
-
// {uid,url,name,f_use_type?,f_form_type?}
|
157
|
-
this.uploadedFileList = list.filter(item => item.f_use_type === this.model.useType)
|
158
|
-
} else {
|
159
|
-
this.uploadedFileList = list
|
160
|
-
}
|
161
|
-
// 第三个参数‘created’,是因为XReport,有些图片上传需要外界自己控制上传下载的逻辑
|
162
|
-
// 如果在组件加载完成就emit的话,外侧组件会以为图片已经更新,会调用后端,造成性能浪费
|
163
|
-
// 所以外侧需要一个标识来判断,该emit事件是不是初始化的时候发出的
|
164
|
-
if (this.outerContainerIndex !== undefined) {
|
165
|
-
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done'), this.outerContainerIndex, 'created')
|
166
|
-
} else {
|
167
|
-
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id), undefined, 'created')
|
168
|
-
}
|
169
|
-
},
|
170
|
-
methods: {
|
171
|
-
async handlePreview (file) {
|
172
|
-
this.previewImage = file.url
|
173
|
-
this.previewVisible = true
|
174
|
-
},
|
175
|
-
confirmPhoto (img) {
|
176
|
-
const fileName = `GaoPaiYi_${moment().format('YYYYMMDDHHmmss')}.png`
|
177
|
-
const file = base64ToFile(img, fileName)
|
178
|
-
file.uid = fileName
|
179
|
-
const info = {
|
180
|
-
file
|
181
|
-
}
|
182
|
-
this.uploadFiles(info)
|
183
|
-
},
|
184
|
-
useScannerUpload (e) {
|
185
|
-
// 打开高拍仪
|
186
|
-
this.$refs.heightScanner.show = true
|
187
|
-
},
|
188
|
-
uploadFiles (info) {
|
189
|
-
if (this.uploadedFileList.length >= this.model.acceptCount) {
|
190
|
-
this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
|
191
|
-
return
|
192
|
-
}
|
193
|
-
// 初始化文件信息
|
194
|
-
const fileInfo = {
|
195
|
-
uid: info.file.uid,
|
196
|
-
name: info.file.name,
|
197
|
-
status: 'uploading',
|
198
|
-
response: '',
|
199
|
-
url: '',
|
200
|
-
}
|
201
|
-
// 放入上传列表中,以便于显示上传进度
|
202
|
-
this.uploadedFileList.push(fileInfo)
|
203
|
-
// 组装上传数据
|
204
|
-
const headers = {
|
205
|
-
'Content-Type': 'multipart/form-data',
|
206
|
-
}
|
207
|
-
const formData = new FormData()
|
208
|
-
formData.append('avatar', info.file)
|
209
|
-
formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
|
210
|
-
if (this.model.pathKey) {
|
211
|
-
formData.append('pathKey', this.model.pathKey ?? 'Default')
|
212
|
-
}
|
213
|
-
// formData.append('stockAlias', this.model.stockAlias)
|
214
|
-
formData.append('formType', this.model.type)
|
215
|
-
formData.append('useType', this.model.useType ?? 'Default')
|
216
|
-
formData.append('resUploadStock', this.model.resUploadStock ?? 1)
|
217
|
-
formData.append('filename', info.file.name)
|
218
|
-
formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
|
219
|
-
formData.append('f_operator', this.currUser ? this.currUser.username : '')
|
220
|
-
|
221
|
-
upload(formData, this.serviceName, { headers, timeout: 600 * 1000 }).then(res => {
|
222
|
-
// 根据服务端返回的结果判断成功与否,设置文件条目的状态
|
223
|
-
if (res.success || res.id) {
|
224
|
-
fileInfo.status = 'done'
|
225
|
-
let dataObj
|
226
|
-
if (res.id) {
|
227
|
-
dataObj = res
|
228
|
-
} else if (typeof res.data === 'string') {
|
229
|
-
dataObj = JSON.parse(res.data)
|
230
|
-
} else {
|
231
|
-
dataObj = res.data
|
232
|
-
}
|
233
|
-
fileInfo.response = dataObj
|
234
|
-
fileInfo.id = dataObj.id
|
235
|
-
// 如果新上传的图片是V4,需要携带serviceName前缀,但是同时也要回显老系统图片
|
236
|
-
if (this.imgPrefix) {
|
237
|
-
fileInfo.url = this.imgPrefix + dataObj.f_downloadpath
|
238
|
-
} else {
|
239
|
-
fileInfo.url = dataObj.f_downloadpath
|
240
|
-
}
|
241
|
-
if (this.outerContainerIndex !== undefined) {
|
242
|
-
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done'), this.outerContainerIndex)
|
243
|
-
} else {
|
244
|
-
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
245
|
-
this.$emit('setFilesAllInfo', this.uploadedFileList.filter(item => item.status === 'done').map(item => item))
|
246
|
-
}
|
247
|
-
this.$message.success('上传成功!')
|
248
|
-
} else {
|
249
|
-
fileInfo.status = 'error'
|
250
|
-
fileInfo.response = res.data
|
251
|
-
this.$message.error('上传失败!')
|
252
|
-
}
|
253
|
-
}).catch((e) => {
|
254
|
-
fileInfo.status = 'error'
|
255
|
-
fileInfo.response = e
|
256
|
-
})
|
257
|
-
},
|
258
|
-
// 删除文件
|
259
|
-
deleteFileItem (file) {
|
260
|
-
const that = this
|
261
|
-
this.$confirm({
|
262
|
-
title: '提醒',
|
263
|
-
content: '确定删除该文件吗?',
|
264
|
-
okText: '删除',
|
265
|
-
okType: 'danger',
|
266
|
-
cancelText: '取消',
|
267
|
-
zIndex: 2000,
|
268
|
-
onOk () {
|
269
|
-
// 阳春博能工单信息V4页面有时会删除V3照片, V3照片不能通过这个请求删除, 已经在外层进行删除处理
|
270
|
-
if (file.id && !file.version) {
|
271
|
-
switch (that.compatible) {
|
272
|
-
case 'V3':
|
273
|
-
fileDelete({ id: file.id, f_state: '删除' })
|
274
|
-
.then(res => {
|
275
|
-
}).catch(e => {
|
276
|
-
})
|
277
|
-
break
|
278
|
-
case 'V4':
|
279
|
-
fileDeleteV4({ id: file.id, resDeleteMode: 'server' })
|
280
|
-
.then(res => {
|
281
|
-
}).catch(e => {
|
282
|
-
})
|
283
|
-
break
|
284
|
-
}
|
285
|
-
}
|
286
|
-
// 找到当前文件所在列表的索引
|
287
|
-
const index = that.uploadedFileList.indexOf(file)
|
288
|
-
// 从列表中移除该文件
|
289
|
-
that.uploadedFileList.splice(index, 1)
|
290
|
-
if (that.outerContainerIndex !== undefined) {
|
291
|
-
that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done'), that.outerContainerIndex)
|
292
|
-
} else {
|
293
|
-
that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
294
|
-
}
|
295
|
-
},
|
296
|
-
onCancel () {
|
297
|
-
console.log('取消删除')
|
298
|
-
},
|
299
|
-
})
|
300
|
-
return true
|
301
|
-
}
|
302
|
-
},
|
303
|
-
components: {
|
304
|
-
HeightScanner
|
305
|
-
}
|
306
|
-
}
|
307
|
-
</script>
|
308
|
-
<style lang="less" scoped>
|
309
|
-
.image-preview-container {
|
310
|
-
display: flex;
|
311
|
-
justify-content: center;
|
312
|
-
align-items: center;
|
313
|
-
min-height: 400px;
|
314
|
-
|
315
|
-
.preview-image {
|
316
|
-
max-width: 100%;
|
317
|
-
max-height: 80vh;
|
318
|
-
object-fit: contain;
|
319
|
-
}
|
320
|
-
}
|
321
|
-
|
322
|
-
// 修改弹窗样式
|
323
|
-
:deep(.image-preview-modal) {
|
324
|
-
.ant-modal {
|
325
|
-
max-width: 90vw;
|
326
|
-
|
327
|
-
.ant-modal-body {
|
328
|
-
padding: 24px;
|
329
|
-
background: #fafafa;
|
330
|
-
}
|
331
|
-
}
|
332
|
-
}
|
333
|
-
</style>
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<template v-if="uploadStyle === 'simple'">
|
4
|
+
<a-upload
|
5
|
+
:accept="model.accept?.join('')"
|
6
|
+
:customRequest="uploadFiles"
|
7
|
+
:multiple="model.acceptCount && model.acceptCount>1"
|
8
|
+
:file-list="uploadedFileList"
|
9
|
+
:remove="deleteFileItem">
|
10
|
+
<a-space>
|
11
|
+
<a-button style="margin-top: 2%">
|
12
|
+
<a-icon type="upload"/>
|
13
|
+
上传
|
14
|
+
</a-button>
|
15
|
+
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
16
|
+
高拍仪
|
17
|
+
</a-button>
|
18
|
+
</a-space>
|
19
|
+
</a-upload>
|
20
|
+
</template>
|
21
|
+
<a-upload-dragger
|
22
|
+
v-else-if="model.type === 'file'"
|
23
|
+
:accept="model.accept?.join('')"
|
24
|
+
:customRequest="uploadFiles"
|
25
|
+
:file-list="uploadedFileList"
|
26
|
+
:multiple="true"
|
27
|
+
:remove="deleteFileItem"
|
28
|
+
name="file">
|
29
|
+
<p class="ant-upload-drag-icon">
|
30
|
+
<a-icon type="inbox"/>
|
31
|
+
</p>
|
32
|
+
<p class="ant-upload-text">
|
33
|
+
点击或拖动文件到该区域上传
|
34
|
+
</p>
|
35
|
+
<p class="ant-upload-hint">
|
36
|
+
支持单个或多个文件
|
37
|
+
</p>
|
38
|
+
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
39
|
+
高拍仪
|
40
|
+
</a-button>
|
41
|
+
</a-upload-dragger>
|
42
|
+
<a-upload
|
43
|
+
v-else
|
44
|
+
@preview="handlePreview"
|
45
|
+
:accept="model.accept?.join('')"
|
46
|
+
:multiple="model.acceptCount && model.acceptCount>1"
|
47
|
+
:customRequest="uploadFiles"
|
48
|
+
:file-list="uploadedFileList"
|
49
|
+
:remove="deleteFileItem"
|
50
|
+
:show-upload-list="{
|
51
|
+
showRemoveIcon: !readOnly,
|
52
|
+
showPreviewIcon: true,
|
53
|
+
showDownloadIcon: false
|
54
|
+
}"
|
55
|
+
list-type="picture-card">
|
56
|
+
<a-icon v-if="!readOnly" type="plus"/>
|
57
|
+
<div v-if="!readOnly" class="ant-upload-text">
|
58
|
+
上传图片
|
59
|
+
</div>
|
60
|
+
<a-button v-if="useScanner" style="margin-top: 2%" @click.stop="useScannerUpload" icon="camera">
|
61
|
+
高拍仪
|
62
|
+
</a-button>
|
63
|
+
</a-upload>
|
64
|
+
<height-scanner v-if="useScanner" @confirmPhoto="confirmPhoto" ref="heightScanner"/>
|
65
|
+
<a-modal
|
66
|
+
v-model="previewVisible"
|
67
|
+
:footer="null"
|
68
|
+
width="60vw"
|
69
|
+
:dialogStyle="{ top: '20px' }"
|
70
|
+
wrapClassName="image-preview-modal"
|
71
|
+
>
|
72
|
+
<div class="image-preview-container">
|
73
|
+
<img
|
74
|
+
:src="previewImage"
|
75
|
+
alt=""
|
76
|
+
class="preview-image"
|
77
|
+
style="width: 100%; height: 100%;"
|
78
|
+
>
|
79
|
+
</div>
|
80
|
+
</a-modal>
|
81
|
+
</div>
|
82
|
+
</template>
|
83
|
+
|
84
|
+
<script>
|
85
|
+
|
86
|
+
import { mapState } from 'vuex'
|
87
|
+
import { fileDelete, fileDeleteV4, upload } from '@vue2-client/services/api/common'
|
88
|
+
import HeightScanner from '@vue2-client/components/HeightScanner/index.vue'
|
89
|
+
import { base64ToFile } from '@vue2-client/utils/util'
|
90
|
+
import moment from 'moment'
|
91
|
+
export default {
|
92
|
+
name: 'Uploads',
|
93
|
+
data () {
|
94
|
+
return {
|
95
|
+
uploadedFileList: [],
|
96
|
+
previewVisible: false,
|
97
|
+
previewImage: ''
|
98
|
+
}
|
99
|
+
},
|
100
|
+
props: {
|
101
|
+
// 表单属性
|
102
|
+
model: {
|
103
|
+
type: Object,
|
104
|
+
default: () => {
|
105
|
+
return {}
|
106
|
+
}
|
107
|
+
},
|
108
|
+
files: {
|
109
|
+
type: Array,
|
110
|
+
default: () => {
|
111
|
+
return []
|
112
|
+
}
|
113
|
+
},
|
114
|
+
images: {
|
115
|
+
type: Array,
|
116
|
+
default: () => {
|
117
|
+
return []
|
118
|
+
}
|
119
|
+
},
|
120
|
+
serviceName: {
|
121
|
+
type: String,
|
122
|
+
default: undefined
|
123
|
+
},
|
124
|
+
uploadStyle: {
|
125
|
+
type: String,
|
126
|
+
default: undefined
|
127
|
+
},
|
128
|
+
// outerContainerIndex,是为了XReport,返回外侧行的Index,每一行都有可能有图片,所以要知道是哪一个Index发出的事件
|
129
|
+
outerContainerIndex: {
|
130
|
+
type: [String, Number],
|
131
|
+
default: undefined
|
132
|
+
},
|
133
|
+
// 图片上传后添加前缀
|
134
|
+
imgPrefix: {
|
135
|
+
type: String,
|
136
|
+
default: undefined
|
137
|
+
},
|
138
|
+
// 是否开启高拍仪
|
139
|
+
useScanner: {
|
140
|
+
type: Boolean,
|
141
|
+
default: false
|
142
|
+
},
|
143
|
+
// 是否只读
|
144
|
+
readOnly: {
|
145
|
+
type: Boolean,
|
146
|
+
default: false
|
147
|
+
}
|
148
|
+
},
|
149
|
+
computed: {
|
150
|
+
...mapState('account', { currUser: 'user' }),
|
151
|
+
...mapState('setting', ['compatible'])
|
152
|
+
},
|
153
|
+
created () {
|
154
|
+
const list = this.model.type === 'file' ? [...this.files] : [...this.images]
|
155
|
+
if (this.model.useType) {
|
156
|
+
// {uid,url,name,f_use_type?,f_form_type?}
|
157
|
+
this.uploadedFileList = list.filter(item => item.f_use_type === this.model.useType)
|
158
|
+
} else {
|
159
|
+
this.uploadedFileList = list
|
160
|
+
}
|
161
|
+
// 第三个参数‘created’,是因为XReport,有些图片上传需要外界自己控制上传下载的逻辑
|
162
|
+
// 如果在组件加载完成就emit的话,外侧组件会以为图片已经更新,会调用后端,造成性能浪费
|
163
|
+
// 所以外侧需要一个标识来判断,该emit事件是不是初始化的时候发出的
|
164
|
+
if (this.outerContainerIndex !== undefined) {
|
165
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done'), this.outerContainerIndex, 'created')
|
166
|
+
} else {
|
167
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id), undefined, 'created')
|
168
|
+
}
|
169
|
+
},
|
170
|
+
methods: {
|
171
|
+
async handlePreview (file) {
|
172
|
+
this.previewImage = file.url
|
173
|
+
this.previewVisible = true
|
174
|
+
},
|
175
|
+
confirmPhoto (img) {
|
176
|
+
const fileName = `GaoPaiYi_${moment().format('YYYYMMDDHHmmss')}.png`
|
177
|
+
const file = base64ToFile(img, fileName)
|
178
|
+
file.uid = fileName
|
179
|
+
const info = {
|
180
|
+
file
|
181
|
+
}
|
182
|
+
this.uploadFiles(info)
|
183
|
+
},
|
184
|
+
useScannerUpload (e) {
|
185
|
+
// 打开高拍仪
|
186
|
+
this.$refs.heightScanner.show = true
|
187
|
+
},
|
188
|
+
uploadFiles (info) {
|
189
|
+
if (this.uploadedFileList.length >= this.model.acceptCount) {
|
190
|
+
this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
|
191
|
+
return
|
192
|
+
}
|
193
|
+
// 初始化文件信息
|
194
|
+
const fileInfo = {
|
195
|
+
uid: info.file.uid,
|
196
|
+
name: info.file.name,
|
197
|
+
status: 'uploading',
|
198
|
+
response: '',
|
199
|
+
url: '',
|
200
|
+
}
|
201
|
+
// 放入上传列表中,以便于显示上传进度
|
202
|
+
this.uploadedFileList.push(fileInfo)
|
203
|
+
// 组装上传数据
|
204
|
+
const headers = {
|
205
|
+
'Content-Type': 'multipart/form-data',
|
206
|
+
}
|
207
|
+
const formData = new FormData()
|
208
|
+
formData.append('avatar', info.file)
|
209
|
+
formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
|
210
|
+
if (this.model.pathKey) {
|
211
|
+
formData.append('pathKey', this.model.pathKey ?? 'Default')
|
212
|
+
}
|
213
|
+
// formData.append('stockAlias', this.model.stockAlias)
|
214
|
+
formData.append('formType', this.model.type)
|
215
|
+
formData.append('useType', this.model.useType ?? 'Default')
|
216
|
+
formData.append('resUploadStock', this.model.resUploadStock ?? 1)
|
217
|
+
formData.append('filename', info.file.name)
|
218
|
+
formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
|
219
|
+
formData.append('f_operator', this.currUser ? this.currUser.username : '')
|
220
|
+
|
221
|
+
upload(formData, this.serviceName, { headers, timeout: 600 * 1000 }).then(res => {
|
222
|
+
// 根据服务端返回的结果判断成功与否,设置文件条目的状态
|
223
|
+
if (res.success || res.id) {
|
224
|
+
fileInfo.status = 'done'
|
225
|
+
let dataObj
|
226
|
+
if (res.id) {
|
227
|
+
dataObj = res
|
228
|
+
} else if (typeof res.data === 'string') {
|
229
|
+
dataObj = JSON.parse(res.data)
|
230
|
+
} else {
|
231
|
+
dataObj = res.data
|
232
|
+
}
|
233
|
+
fileInfo.response = dataObj
|
234
|
+
fileInfo.id = dataObj.id
|
235
|
+
// 如果新上传的图片是V4,需要携带serviceName前缀,但是同时也要回显老系统图片
|
236
|
+
if (this.imgPrefix) {
|
237
|
+
fileInfo.url = this.imgPrefix + dataObj.f_downloadpath
|
238
|
+
} else {
|
239
|
+
fileInfo.url = dataObj.f_downloadpath
|
240
|
+
}
|
241
|
+
if (this.outerContainerIndex !== undefined) {
|
242
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done'), this.outerContainerIndex)
|
243
|
+
} else {
|
244
|
+
this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
245
|
+
this.$emit('setFilesAllInfo', this.uploadedFileList.filter(item => item.status === 'done').map(item => item))
|
246
|
+
}
|
247
|
+
this.$message.success('上传成功!')
|
248
|
+
} else {
|
249
|
+
fileInfo.status = 'error'
|
250
|
+
fileInfo.response = res.data
|
251
|
+
this.$message.error('上传失败!')
|
252
|
+
}
|
253
|
+
}).catch((e) => {
|
254
|
+
fileInfo.status = 'error'
|
255
|
+
fileInfo.response = e
|
256
|
+
})
|
257
|
+
},
|
258
|
+
// 删除文件
|
259
|
+
deleteFileItem (file) {
|
260
|
+
const that = this
|
261
|
+
this.$confirm({
|
262
|
+
title: '提醒',
|
263
|
+
content: '确定删除该文件吗?',
|
264
|
+
okText: '删除',
|
265
|
+
okType: 'danger',
|
266
|
+
cancelText: '取消',
|
267
|
+
zIndex: 2000,
|
268
|
+
onOk () {
|
269
|
+
// 阳春博能工单信息V4页面有时会删除V3照片, V3照片不能通过这个请求删除, 已经在外层进行删除处理
|
270
|
+
if (file.id && !file.version) {
|
271
|
+
switch (that.compatible) {
|
272
|
+
case 'V3':
|
273
|
+
fileDelete({ id: file.id, f_state: '删除' })
|
274
|
+
.then(res => {
|
275
|
+
}).catch(e => {
|
276
|
+
})
|
277
|
+
break
|
278
|
+
case 'V4':
|
279
|
+
fileDeleteV4({ id: file.id, resDeleteMode: 'server' })
|
280
|
+
.then(res => {
|
281
|
+
}).catch(e => {
|
282
|
+
})
|
283
|
+
break
|
284
|
+
}
|
285
|
+
}
|
286
|
+
// 找到当前文件所在列表的索引
|
287
|
+
const index = that.uploadedFileList.indexOf(file)
|
288
|
+
// 从列表中移除该文件
|
289
|
+
that.uploadedFileList.splice(index, 1)
|
290
|
+
if (that.outerContainerIndex !== undefined) {
|
291
|
+
that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done'), that.outerContainerIndex)
|
292
|
+
} else {
|
293
|
+
that.$emit('setFiles', that.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
|
294
|
+
}
|
295
|
+
},
|
296
|
+
onCancel () {
|
297
|
+
console.log('取消删除')
|
298
|
+
},
|
299
|
+
})
|
300
|
+
return true
|
301
|
+
}
|
302
|
+
},
|
303
|
+
components: {
|
304
|
+
HeightScanner
|
305
|
+
}
|
306
|
+
}
|
307
|
+
</script>
|
308
|
+
<style lang="less" scoped>
|
309
|
+
.image-preview-container {
|
310
|
+
display: flex;
|
311
|
+
justify-content: center;
|
312
|
+
align-items: center;
|
313
|
+
min-height: 400px;
|
314
|
+
|
315
|
+
.preview-image {
|
316
|
+
max-width: 100%;
|
317
|
+
max-height: 80vh;
|
318
|
+
object-fit: contain;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
// 修改弹窗样式
|
323
|
+
:deep(.image-preview-modal) {
|
324
|
+
.ant-modal {
|
325
|
+
max-width: 90vw;
|
326
|
+
|
327
|
+
.ant-modal-body {
|
328
|
+
padding: 24px;
|
329
|
+
background: #fafafa;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}
|
333
|
+
</style>
|