t20-common-lib 0.15.10 → 0.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t20-common-lib",
3
- "version": "0.15.10",
3
+ "version": "0.15.12",
4
4
  "description": "T20",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -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,242 @@
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: () => {},
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
+ data.append(
97
+ 'data',
98
+ JSON.stringify({
99
+ syscode: this.uploadParam.syscode,
100
+ appno: this.uploadParam.appno,
101
+ bussValue: this.mapdata[row.type],
102
+ attno: row.type,
103
+ bussId:
104
+ this.uploadParam && this.uploadParam.paymentTemplate === 'REQUEST_PAYOUT' ? '' : this.uploadParam.bussId,
105
+ cltno: JSON.parse(sessionStorage.getItem('userInfo') || '{}').cltNo,
106
+ memo: file.name,
107
+ recordname: file.name,
108
+ fileSize: file.size
109
+ })
110
+ )
111
+ data.append('date', '2022-01-01 00:00:00' + ',2099-12-31 23:59:59')
112
+ return new Promise((resolve, reject) => {
113
+ axios
114
+ .post(`/api/neams/eamsbaserecord/batchSavejson`, data, {
115
+ headers: {
116
+ 'Content-Type': 'multipart/form-data',
117
+ charset: 'utf-8',
118
+ timestamp: Date.now(),
119
+ Authorization: `Bearer ${token}`,
120
+ requestKey: randomString(16),
121
+ OperationDesc: 'yYarJp'
122
+ },
123
+ loading: false,
124
+ noMsg: true
125
+ })
126
+ .then(({ data: res }) => resolve(res))
127
+ .catch(err => reject(err))
128
+ })
129
+ },
130
+ getByBussValueFn() {
131
+ this.mapdata = {}
132
+ if (!this.uploadParam || !this.uploadParam.bussValue) return
133
+ if (this.uploadParam.bussValue.split(',').length > 1) {
134
+ this.dataPorp.typeOptions = []
135
+ this.uploadParam.bussValue.split(',').map(item => {
136
+ getByBussValue({
137
+ bussValue: item
138
+ }).then(res => {
139
+ res &&
140
+ res.map(t => {
141
+ this.dataPorp.typeOptions.push({
142
+ ...t,
143
+ type: t.attno,
144
+ label: t.attname
145
+ })
146
+ this.mapdata[t.attno] = item
147
+ })
148
+ })
149
+ })
150
+ return
151
+ }
152
+ getByBussValue({
153
+ bussValue: this.uploadParam.bussValue
154
+ }).then(res => {
155
+ this.dataPorp.typeOptions = (res.data || []).map(item => {
156
+ item.type = item.attno
157
+ item.label = item.attname
158
+ this.mapdata[item.attno] = this.uploadParam.bussValue
159
+ return item
160
+ })
161
+ })
162
+ },
163
+ getUploadedFiles() {
164
+ if (!this.uploadParam) return
165
+ if (this.uploadParam.bussValue && this.uploadParam.bussValue.includes(',')) {
166
+ this.uploadParam.bussValue.split(',').map(async t => {
167
+ const rr = await getUploadedFile({
168
+ bussId: this.uploadParam && this.uploadParam.bussId,
169
+ bussValue: t
170
+ })
171
+ const data = rr && rr.data != null ? rr.data : rr
172
+ this.fileUploadTableData = this.fileUploadTableData.concat(
173
+ (data || []).map(item => ({
174
+ id: item.beid,
175
+ beid: item.beid,
176
+ type: item.attno,
177
+ name: item.recordname,
178
+ time: item.updatetime,
179
+ user: item.creator,
180
+ url: item.filepath
181
+ }))
182
+ )
183
+ })
184
+ return
185
+ }
186
+ getUploadedFile({
187
+ bussValue: this.uploadParam.bussValue,
188
+ bussId: this.uploadParam.bussId
189
+ }).then(res => {
190
+ const list = res && res.data != null ? res.data : res
191
+ this.fileUploadTableData =
192
+ (list || []).map(item => {
193
+ item.type = item.attno
194
+ item.name = item.memo || item.recordname
195
+ item.time = item.uploadtime
196
+ item.user = item.creator
197
+ item.url = `/api/neams/eamsbaserecord/download/${item.beid}`
198
+ item._name = item.memo
199
+ return item
200
+ }) || []
201
+ })
202
+ },
203
+ onSuccess(file, row) {
204
+ const _fileData = file.response
205
+ this.$set(row, 'id', _fileData.data)
206
+ this.$set(row, 'bussValue', this.mapdata[row.type])
207
+ let userName = ''
208
+ try {
209
+ const raw = sessionStorage.getItem('User_Info') || sessionStorage.getItem('userInfo')
210
+ if (raw) userName = JSON.parse(raw).userName || ''
211
+ } catch (e) {
212
+ userName = ''
213
+ }
214
+ this.$set(row, 'user', userName)
215
+ this.$set(row, 'archiveId', _fileData.data)
216
+ this.$set(row, 'beid', _fileData.data)
217
+ },
218
+ onRemove(file) {
219
+ if (file.status === 'success') {
220
+ const { beid } = file.response
221
+ const i = this.fileUploadTableData.findIndex(d => d.id === beid)
222
+ if (i !== -1) this.fileUploadTableData.splice(i, 1)
223
+ }
224
+ }
225
+ },
226
+ watch: {
227
+ uploadParam: {
228
+ immediate: true,
229
+ deep: true,
230
+ handler() {
231
+ if (!this.needFile) return
232
+ if (!this.uploadParam) return
233
+ if (this.uploadParam.bussValue) {
234
+ this.getByBussValueFn()
235
+ }
236
+ if (this.uploadParam.bussId) {
237
+ this.getUploadedFiles()
238
+ }
239
+ }
240
+ }
241
+ }
242
+ }
@@ -52,6 +52,29 @@
52
52
  </template>
53
53
  </N20-anchor-item>
54
54
  </el-form>
55
+ <N20-anchor-item
56
+ v-if="needFile"
57
+ key="fileuploadtable"
58
+ id="fileuploadtable"
59
+ :title="$lc('附件信息')"
60
+ >
61
+ <N20-file-upload-table
62
+ v-if="!needFileDIY"
63
+ :action="fileAction"
64
+ :table-data="fileUploadTableData"
65
+ :see-types="seeTypes"
66
+ :show-batch-upload="false"
67
+ :data-porp="dataPorp"
68
+ :upload-http-request="uploadRequest"
69
+ :readonly="uploadReadOnly"
70
+ @on-success="onSuccess"
71
+ @on-remove="onRemove"
72
+ @add-row="addRow"
73
+ @down-rows="downRows"
74
+ @delete-rows="deleteRows"
75
+ />
76
+ <slot v-else name="fileUploadTable"></slot>
77
+ </N20-anchor-item>
55
78
  </N20-anchor>
56
79
  <div slot="footer">
57
80
  <el-button type="primary" @click="submit('submit')">{{ $lc('提交') }}</el-button>
@@ -71,6 +94,7 @@
71
94
  *
72
95
  * fieldControlList:与 dynamicData 同时传入,仅在收到模版时按 fieldNo 与 elements[].prop 合并一次 isShow、showName→label、isRequired;之后渲染均以合并后的 mergedTemplateBase 为唯一数据源。
73
96
  */
97
+ import { fileUploadTableMixin } from '../mixins/fileUpload'
74
98
  // 复用 Demo 中的字段组件,按模板的 elementType 动态渲染
75
99
  const context = require.context('./components/', true, /\.vue$/)
76
100
  const demoComponents = {}
@@ -84,6 +108,7 @@ export default {
84
108
  components: {
85
109
  ...demoComponents
86
110
  },
111
+ mixins: [fileUploadTableMixin],
87
112
  props: {
88
113
  title: {
89
114
  type: String,
@@ -107,6 +132,31 @@ export default {
107
132
  fieldControlList: {
108
133
  type: Array,
109
134
  default: () => []
135
+ },
136
+ /** 是否展示附件锚点(默认关闭,不影响现有用法) */
137
+ needFile: {
138
+ type: Boolean,
139
+ default: true
140
+ },
141
+ /** true 时使用 fileUploadTable 插槽自定义附件区 */
142
+ needFileDIY: {
143
+ type: Boolean,
144
+ default: false
145
+ },
146
+ /** 电子档案 / 上传参数,与 Demo DynamicForm uploadParam 一致 */
147
+ uploadParam: {
148
+ type: Object,
149
+ default: () => ({
150
+ syscode: '060000000',
151
+ appno: '060500000',
152
+ bussValue: 'invest_041001001',
153
+ attno: 'invest_002',
154
+ bussId: null
155
+ })
156
+ },
157
+ uploadReadOnly: {
158
+ type: Boolean,
159
+ default: false
110
160
  }
111
161
  },
112
162
  data() {
@@ -440,9 +490,11 @@ export default {
440
490
  async submit() {
441
491
  const valid = await this.$refs.dynamicForms.validate()
442
492
  if (!valid) return
443
- this.$emit('submit', {
444
- formData: this.formData
445
- })
493
+ const payload = { formData: this.formData }
494
+ if (this.needFile) {
495
+ payload.fileUploadTableData = (this.fileUploadTableData || []).filter(t => t.beid)
496
+ }
497
+ this.$emit('submit', payload)
446
498
  }
447
499
  }
448
500
  }