t20-common-lib 0.15.19 → 0.15.21
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 +1 -1
- package/packages/dynamic-form/api/fileApi.js +0 -12
- package/packages/dynamic-form/mixins/fileUpload.js +0 -242
- package/packages/dynamic-form/src/components/Amount.vue +1 -1
- package/packages/dynamic-form/src/components/AmountRange.vue +2 -6
- package/packages/dynamic-form/src/components/CheckboxGroup.vue +0 -1
- package/packages/dynamic-form/src/components/DMY.vue +2 -6
- package/packages/dynamic-form/src/components/Date.vue +0 -1
- package/packages/dynamic-form/src/components/DateRange.vue +0 -1
- package/packages/dynamic-form/src/components/Input.vue +0 -1
- package/packages/dynamic-form/src/components/InputNumber.vue +0 -1
- package/packages/dynamic-form/src/components/InputNumberRange.vue +0 -1
- package/packages/dynamic-form/src/components/RadioGroup.vue +0 -1
- package/packages/dynamic-form/src/components/Rate.vue +0 -1
- package/packages/dynamic-form/src/components/Select.vue +50 -0
- package/packages/dynamic-form/src/components/Switch.vue +0 -1
- package/packages/dynamic-form/src/components/Textarea.vue +0 -1
- package/packages/dynamic-form/src/main.vue +4 -4
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,242 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -51,9 +51,7 @@ export default {
|
|
|
51
51
|
return "";
|
|
52
52
|
},
|
|
53
53
|
set(val) {
|
|
54
|
-
|
|
55
|
-
this.$emit("input", nextValue);
|
|
56
|
-
this.$emit("change", nextValue);
|
|
54
|
+
this.$emit("input", `${val},${this._value2 || this._value2===0?this._value2 : ''}`);
|
|
57
55
|
},
|
|
58
56
|
},
|
|
59
57
|
_value2: {
|
|
@@ -64,9 +62,7 @@ export default {
|
|
|
64
62
|
return "";
|
|
65
63
|
},
|
|
66
64
|
set(val) {
|
|
67
|
-
|
|
68
|
-
this.$emit("input", nextValue);
|
|
69
|
-
this.$emit("change", nextValue);
|
|
65
|
+
this.$emit("input", `${this._value1},${val || val===0?val : ''}`);
|
|
70
66
|
},
|
|
71
67
|
},
|
|
72
68
|
},
|
|
@@ -79,9 +79,7 @@ export default {
|
|
|
79
79
|
return "";
|
|
80
80
|
},
|
|
81
81
|
set(val) {
|
|
82
|
-
|
|
83
|
-
this.$emit("input", nextValue);
|
|
84
|
-
this.$emit("change", nextValue);
|
|
82
|
+
this.$emit("input", `${val}${this.value2}`);
|
|
85
83
|
},
|
|
86
84
|
},
|
|
87
85
|
value2: {
|
|
@@ -94,9 +92,7 @@ export default {
|
|
|
94
92
|
return "D";
|
|
95
93
|
},
|
|
96
94
|
set(val) {
|
|
97
|
-
|
|
98
|
-
this.$emit("input", nextValue);
|
|
99
|
-
this.$emit("change", nextValue);
|
|
95
|
+
this.$emit("input", `${this.value1}${val}`);
|
|
100
96
|
},
|
|
101
97
|
},
|
|
102
98
|
},
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
:key="item.value + items.prop"
|
|
24
24
|
:label="item.label | $l"
|
|
25
25
|
:value="item.value"
|
|
26
|
+
:disabled="isOptionDisabled(item)"
|
|
26
27
|
>
|
|
27
28
|
{{labelKey ? item._label : item.label | $l}}
|
|
28
29
|
</el-option>
|
|
@@ -57,6 +58,14 @@ export default {
|
|
|
57
58
|
return {};
|
|
58
59
|
},
|
|
59
60
|
},
|
|
61
|
+
formData: {
|
|
62
|
+
type: Object,
|
|
63
|
+
default: () => ({})
|
|
64
|
+
},
|
|
65
|
+
groupProp: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: ''
|
|
68
|
+
},
|
|
60
69
|
label: {
|
|
61
70
|
type: String,
|
|
62
71
|
defalut: "",
|
|
@@ -91,6 +100,9 @@ export default {
|
|
|
91
100
|
// 判断数据类型,格式化回显数据
|
|
92
101
|
valueType() {
|
|
93
102
|
return typeof this.value
|
|
103
|
+
},
|
|
104
|
+
optionDisableConfig() {
|
|
105
|
+
return this.items?.props?.optionDisable || {}
|
|
94
106
|
}
|
|
95
107
|
},
|
|
96
108
|
watch: {
|
|
@@ -193,6 +205,44 @@ export default {
|
|
|
193
205
|
clearFn() {
|
|
194
206
|
this.options = this.optionsCopy
|
|
195
207
|
},
|
|
208
|
+
/**
|
|
209
|
+
* 从 formData 读取控制字段值。
|
|
210
|
+
* 支持两种写法:
|
|
211
|
+
* - "group.field"(推荐)
|
|
212
|
+
* - "field"(默认读取当前 groupProp 下字段)
|
|
213
|
+
*/
|
|
214
|
+
getControlValue(controlField) {
|
|
215
|
+
if (!controlField || !this.formData) return undefined
|
|
216
|
+
const path = String(controlField).split('.')
|
|
217
|
+
if (path.length >= 2) {
|
|
218
|
+
let cur = this.formData
|
|
219
|
+
for (let i = 0; i < path.length; i++) {
|
|
220
|
+
if (cur == null) return undefined
|
|
221
|
+
cur = cur[path[i]]
|
|
222
|
+
}
|
|
223
|
+
return cur
|
|
224
|
+
}
|
|
225
|
+
return this.groupProp ? this.formData?.[this.groupProp]?.[controlField] : this.formData?.[controlField]
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
* 下拉项禁用规则(声明式):
|
|
229
|
+
* items.props.optionDisable = {
|
|
230
|
+
* controlField: 'groupA.ctrlType' 或 'ctrlType',
|
|
231
|
+
* map: { 'A': ['v1', 'v2'], 'B': ['v3'] },
|
|
232
|
+
* defaultDisabledValues: []
|
|
233
|
+
* }
|
|
234
|
+
*/
|
|
235
|
+
isOptionDisabled(option) {
|
|
236
|
+
const cfg = this.optionDisableConfig
|
|
237
|
+
const controlField = cfg.controlField
|
|
238
|
+
const map = cfg.map || {}
|
|
239
|
+
const defaultDisabledValues = cfg.defaultDisabledValues || []
|
|
240
|
+
if (!controlField) return false
|
|
241
|
+
const controlValue = this.getControlValue(controlField)
|
|
242
|
+
const disabledValues = map[controlValue] || defaultDisabledValues
|
|
243
|
+
if (!Array.isArray(disabledValues)) return false
|
|
244
|
+
return disabledValues.some(v => String(v) === String(option?.value))
|
|
245
|
+
},
|
|
196
246
|
changVariable(val){
|
|
197
247
|
if (!val) {
|
|
198
248
|
return val || "";
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
</N20-anchor-item>
|
|
79
79
|
</N20-anchor>
|
|
80
80
|
<div slot="footer">
|
|
81
|
-
<el-button type="primary" @click="submit('
|
|
82
|
-
<el-button @click="submit('
|
|
81
|
+
<el-button type="primary" @click="submit('SUBMIT')">{{ $lc('提交') }}</el-button>
|
|
82
|
+
<el-button @click="submit('SAVE')">{{ $lc('保存') }}</el-button>
|
|
83
83
|
</div>
|
|
84
84
|
</T20-Form-Page>
|
|
85
85
|
</template>
|
|
@@ -445,10 +445,10 @@ export default {
|
|
|
445
445
|
})
|
|
446
446
|
},
|
|
447
447
|
// 第一步仅做模板渲染校验,提交逻辑后续步骤再扩展
|
|
448
|
-
async submit() {
|
|
448
|
+
async submit(operate) {
|
|
449
449
|
const valid = await this.$refs.dynamicForms.validate()
|
|
450
450
|
if (!valid) return
|
|
451
|
-
const payload = { formData: this.formData }
|
|
451
|
+
const payload = { formData: this.formData, operate }
|
|
452
452
|
if (this.needFile) {
|
|
453
453
|
payload.fileUploadTableData = (this.fileUploadTableData || []).filter(t => t.beid)
|
|
454
454
|
}
|