t20-common-lib 0.15.21 → 0.15.22
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
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 电子档案 / 附件相关接口(与 Demo DynamicForm 一致)
|
|
3
|
+
*/
|
|
4
|
+
import service from '../../../src/utils/request'
|
|
5
|
+
|
|
6
|
+
export function getByBussValue(data = {}) {
|
|
7
|
+
return service.post(`/api/neams/eamsattachfile/getByBussValue`, data)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getUploadedFile(data = {}) {
|
|
11
|
+
return service.post(`/api/neams/eamsbaserecord/queryList`, data)
|
|
12
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { getByBussValue, getUploadedFile } from '../api/fileApi'
|
|
3
|
+
|
|
4
|
+
function randomString(num) {
|
|
5
|
+
num = num || 32
|
|
6
|
+
const t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
|
|
7
|
+
const a = t.length
|
|
8
|
+
let n = ''
|
|
9
|
+
for (let i = 0; i < num; i++) n += t.charAt(Math.floor(Math.random() * a))
|
|
10
|
+
return n
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getBearerToken() {
|
|
14
|
+
return sessionStorage.getItem('token') || ''
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const fileUploadTableMixin = {
|
|
18
|
+
data() {
|
|
19
|
+
return {
|
|
20
|
+
fileUploadTableData: [],
|
|
21
|
+
fileAction: '/api/neams/eamsbaserecord/save',
|
|
22
|
+
seeTypes: /\.(jpg|png|gif|svg|pdf|swf|xlsx|xls|docx|doc)$/i,
|
|
23
|
+
dataPorp: {
|
|
24
|
+
fileAccept: '.rar,.zip,.doc,.docx,.pdf,image/*,.xls,.xlsx',
|
|
25
|
+
typeOptions: [],
|
|
26
|
+
multiple: false
|
|
27
|
+
},
|
|
28
|
+
mapdata: {}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
addRow() {
|
|
33
|
+
this.fileUploadTableData.splice(0, 0, {
|
|
34
|
+
id: 'n' + Math.random(),
|
|
35
|
+
type: '',
|
|
36
|
+
name: '',
|
|
37
|
+
time: '',
|
|
38
|
+
user: '',
|
|
39
|
+
_fileData: {}
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
downRows(rows) {
|
|
43
|
+
if (!rows || rows.length === 0) return this.$message.error('请选择数据')
|
|
44
|
+
const token = getBearerToken()
|
|
45
|
+
rows.map(item => {
|
|
46
|
+
axios({
|
|
47
|
+
method: 'POST',
|
|
48
|
+
url: '/api/neams/eamsbaserecord/downloadFile',
|
|
49
|
+
responseType: 'blob',
|
|
50
|
+
headers: {
|
|
51
|
+
charset: 'utf-8',
|
|
52
|
+
Authorization: `Bearer ${token}`,
|
|
53
|
+
'Content-Type': 'application/json',
|
|
54
|
+
timestamp: Date.now(),
|
|
55
|
+
OperationDesc: 'yYarJp',
|
|
56
|
+
requestKey: randomString(16)
|
|
57
|
+
},
|
|
58
|
+
data: { beid: item.beid }
|
|
59
|
+
})
|
|
60
|
+
.then(response => {
|
|
61
|
+
const resp = response.data
|
|
62
|
+
if (resp.type === 'application/octet-stream') {
|
|
63
|
+
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
64
|
+
const blob = new Blob([resp], { type: 'application/zip' })
|
|
65
|
+
window.navigator.msSaveOrOpenBlob(blob, item.name)
|
|
66
|
+
} else {
|
|
67
|
+
const blob = new Blob([resp], { type: 'application/zip' })
|
|
68
|
+
const url = window.URL.createObjectURL(blob)
|
|
69
|
+
const link = document.createElement('a')
|
|
70
|
+
link.href = url
|
|
71
|
+
link.download = item.name
|
|
72
|
+
link.click()
|
|
73
|
+
URL.revokeObjectURL(url)
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
this.$message.error((this.$t && this.$t('common_w_0094')) || '下载失败' + '!')
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.catch(error => this.$message.error(error))
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
deleteRows(rows) {
|
|
83
|
+
rows.forEach(row => {
|
|
84
|
+
const index = this.fileUploadTableData.findIndex(r => r.id === row.id)
|
|
85
|
+
if (index > -1 && !row.notBeDelete) {
|
|
86
|
+
this.fileUploadTableData.splice(index, 1)
|
|
87
|
+
this.$message.success('删除成功')
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
uploadRequest(options, row) {
|
|
92
|
+
const token = getBearerToken()
|
|
93
|
+
const { file } = options
|
|
94
|
+
const data = new FormData()
|
|
95
|
+
data.append('file', file)
|
|
96
|
+
const uploadParam = this.uploadParam || {}
|
|
97
|
+
data.append(
|
|
98
|
+
'data',
|
|
99
|
+
JSON.stringify({
|
|
100
|
+
syscode: uploadParam.syscode,
|
|
101
|
+
appno: uploadParam.appno,
|
|
102
|
+
bussValue: this.mapdata[row.type],
|
|
103
|
+
attno: row.type,
|
|
104
|
+
bussId:
|
|
105
|
+
uploadParam && uploadParam.paymentTemplate === 'REQUEST_PAYOUT' ? '' : uploadParam.bussId,
|
|
106
|
+
cltno: JSON.parse(sessionStorage.getItem('userInfo') || '{}').cltNo,
|
|
107
|
+
memo: file.name,
|
|
108
|
+
recordname: file.name,
|
|
109
|
+
fileSize: file.size
|
|
110
|
+
})
|
|
111
|
+
)
|
|
112
|
+
data.append('date', '2022-01-01 00:00:00' + ',2099-12-31 23:59:59')
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
axios
|
|
115
|
+
.post(`/api/neams/eamsbaserecord/batchSavejson`, data, {
|
|
116
|
+
headers: {
|
|
117
|
+
'Content-Type': 'multipart/form-data',
|
|
118
|
+
charset: 'utf-8',
|
|
119
|
+
timestamp: Date.now(),
|
|
120
|
+
Authorization: `Bearer ${token}`,
|
|
121
|
+
requestKey: randomString(16),
|
|
122
|
+
OperationDesc: 'yYarJp'
|
|
123
|
+
},
|
|
124
|
+
loading: false,
|
|
125
|
+
noMsg: true
|
|
126
|
+
})
|
|
127
|
+
.then(({ data: res }) => resolve(res))
|
|
128
|
+
.catch(err => reject(err))
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
getByBussValueFn() {
|
|
132
|
+
this.mapdata = {}
|
|
133
|
+
if (!this.uploadParam || !this.uploadParam.bussValue) return
|
|
134
|
+
if (this.uploadParam.bussValue.split(',').length > 1) {
|
|
135
|
+
this.dataPorp.typeOptions = []
|
|
136
|
+
this.uploadParam.bussValue.split(',').map(item => {
|
|
137
|
+
getByBussValue({
|
|
138
|
+
bussValue: item
|
|
139
|
+
}).then(res => {
|
|
140
|
+
res &&
|
|
141
|
+
res.map(t => {
|
|
142
|
+
this.dataPorp.typeOptions.push({
|
|
143
|
+
...t,
|
|
144
|
+
type: t.attno,
|
|
145
|
+
label: t.attname
|
|
146
|
+
})
|
|
147
|
+
this.mapdata[t.attno] = item
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
getByBussValue({
|
|
154
|
+
bussValue: this.uploadParam.bussValue
|
|
155
|
+
}).then(res => {
|
|
156
|
+
this.dataPorp.typeOptions = (res.data || []).map(item => {
|
|
157
|
+
item.type = item.attno
|
|
158
|
+
item.label = item.attname
|
|
159
|
+
this.mapdata[item.attno] = this.uploadParam.bussValue
|
|
160
|
+
return item
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
},
|
|
164
|
+
getUploadedFiles() {
|
|
165
|
+
if (!this.uploadParam) return
|
|
166
|
+
if (this.uploadParam.bussValue && this.uploadParam.bussValue.includes(',')) {
|
|
167
|
+
this.uploadParam.bussValue.split(',').map(async t => {
|
|
168
|
+
const rr = await getUploadedFile({
|
|
169
|
+
bussId: this.uploadParam && this.uploadParam.bussId,
|
|
170
|
+
bussValue: t
|
|
171
|
+
})
|
|
172
|
+
const data = rr && rr.data != null ? rr.data : rr
|
|
173
|
+
this.fileUploadTableData = this.fileUploadTableData.concat(
|
|
174
|
+
(data || []).map(item => ({
|
|
175
|
+
id: item.beid,
|
|
176
|
+
beid: item.beid,
|
|
177
|
+
type: item.attno,
|
|
178
|
+
name: item.recordname,
|
|
179
|
+
time: item.updatetime,
|
|
180
|
+
user: item.creator,
|
|
181
|
+
url: item.filepath
|
|
182
|
+
}))
|
|
183
|
+
)
|
|
184
|
+
})
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
getUploadedFile({
|
|
188
|
+
bussValue: this.uploadParam.bussValue,
|
|
189
|
+
bussId: this.uploadParam.bussId
|
|
190
|
+
}).then(res => {
|
|
191
|
+
const list = res && res.data != null ? res.data : res
|
|
192
|
+
this.fileUploadTableData =
|
|
193
|
+
(list || []).map(item => {
|
|
194
|
+
item.type = item.attno
|
|
195
|
+
item.name = item.memo || item.recordname
|
|
196
|
+
item.time = item.uploadtime
|
|
197
|
+
item.user = item.creator
|
|
198
|
+
item.url = `/api/neams/eamsbaserecord/download/${item.beid}`
|
|
199
|
+
item._name = item.memo
|
|
200
|
+
return item
|
|
201
|
+
}) || []
|
|
202
|
+
})
|
|
203
|
+
},
|
|
204
|
+
onSuccess(file, row) {
|
|
205
|
+
const _fileData = file.response
|
|
206
|
+
this.$set(row, 'id', _fileData.data)
|
|
207
|
+
this.$set(row, 'bussValue', this.mapdata[row.type])
|
|
208
|
+
let userName = ''
|
|
209
|
+
try {
|
|
210
|
+
const raw = sessionStorage.getItem('User_Info') || sessionStorage.getItem('userInfo')
|
|
211
|
+
if (raw) userName = JSON.parse(raw).userName || ''
|
|
212
|
+
} catch (e) {
|
|
213
|
+
userName = ''
|
|
214
|
+
}
|
|
215
|
+
this.$set(row, 'user', userName)
|
|
216
|
+
this.$set(row, 'archiveId', _fileData.data)
|
|
217
|
+
this.$set(row, 'beid', _fileData.data)
|
|
218
|
+
},
|
|
219
|
+
onRemove(file) {
|
|
220
|
+
if (file.status === 'success') {
|
|
221
|
+
const { beid } = file.response
|
|
222
|
+
const i = this.fileUploadTableData.findIndex(d => d.id === beid)
|
|
223
|
+
if (i !== -1) this.fileUploadTableData.splice(i, 1)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
watch: {
|
|
228
|
+
uploadParam: {
|
|
229
|
+
immediate: true,
|
|
230
|
+
deep: true,
|
|
231
|
+
handler() {
|
|
232
|
+
if (!this.needFile) return
|
|
233
|
+
if (!this.uploadParam) return
|
|
234
|
+
if (this.uploadParam.bussValue) {
|
|
235
|
+
this.getByBussValueFn()
|
|
236
|
+
}
|
|
237
|
+
if (this.uploadParam.bussId) {
|
|
238
|
+
this.getUploadedFiles()
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -95,6 +95,7 @@ const context = require.context('./components/', true, /\.vue$/)
|
|
|
95
95
|
const demoComponents = {}
|
|
96
96
|
context.keys().forEach(key => {
|
|
97
97
|
const component = context(key).default
|
|
98
|
+
if (!component || !component.name) return
|
|
98
99
|
demoComponents[component.name] = component
|
|
99
100
|
})
|
|
100
101
|
|