6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
1
|
<template>
|
9d019fa6
wuxw
测试OA相关流程
|
2
3
4
5
6
|
<div class="new-oa-workflow-form-edit-container">
<el-card class="box-card">
<div slot="header" class="flex justify-between">
<span>{{ $t('newOaWorkflowFormEdit.title') }}</span>
</div>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
7
|
<el-form ref="form" :model="formData" class="text-left" label-width="120px">
|
9d019fa6
wuxw
测试OA相关流程
|
8
9
10
|
<el-row :gutter="20">
<el-col :span="24">
<div v-for="(item, index) in newOaWorkflowFormEditInfo.components" :key="index">
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
11
|
<!-- 文本框 -->
|
9d019fa6
wuxw
测试OA相关流程
|
12
|
<el-form-item v-if="item.type === 'textfield'" :label="item.label"
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
13
14
15
|
:prop="item.key"
:rules="getValidationRules(item)">
<el-input v-model="formData[item.key]" :placeholder="item.description" clearable />
|
9d019fa6
wuxw
测试OA相关流程
|
16
17
|
</el-form-item>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
18
19
20
21
22
23
|
<!-- 数字框 -->
<el-form-item v-if="item.type === 'number'" :label="item.label"
:prop="item.key"
:rules="getValidationRules(item)">
<el-input-number v-model="formData[item.key]" :placeholder="item.description"
controls-position="right" style="width: 100%" />
|
9d019fa6
wuxw
测试OA相关流程
|
24
25
|
</el-form-item>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
26
|
<!-- 文本域 -->
|
9d019fa6
wuxw
测试OA相关流程
|
27
|
<el-form-item v-if="item.type === 'textarea'" :label="item.label"
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
28
29
30
31
|
:prop="item.key"
:rules="getValidationRules(item)">
<el-input v-model="formData[item.key]" type="textarea" :placeholder="item.description"
:rows="4" />
|
9d019fa6
wuxw
测试OA相关流程
|
32
33
|
</el-form-item>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
34
|
<!-- 日期选择 -->
|
9d019fa6
wuxw
测试OA相关流程
|
35
|
<el-form-item v-if="item.type === 'textdate'" :label="item.label"
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
36
37
38
39
|
:prop="item.key"
:rules="getValidationRules(item)">
<el-date-picker v-model="formData[item.key]" type="date" :placeholder="item.description"
value-format="yyyy-MM-dd" style="width: 100%" />
|
9d019fa6
wuxw
测试OA相关流程
|
40
41
|
</el-form-item>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
42
|
<!-- 日期时间选择 -->
|
9d019fa6
wuxw
测试OA相关流程
|
43
|
<el-form-item v-if="item.type === 'textdatetime'" :label="item.label"
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
44
45
|
:prop="item.key"
:rules="getValidationRules(item)">
|
b25b036d
wuxw
v1.9 优化日期
|
46
|
<el-date-picker v-model="formData[item.key]" type="datetime" :placeholder="item.description" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
|
9d019fa6
wuxw
测试OA相关流程
|
47
48
|
</el-form-item>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<!-- 单选框 -->
<el-form-item v-if="item.type === 'radio'" :label="item.label"
:prop="item.key"
:rules="getValidationRules(item)">
<el-radio-group v-model="formData[item.key]">
<el-radio v-for="(option, optionIndex) in item.values" :key="optionIndex"
:label="option.value">
{{ option.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<!-- 下拉选择 -->
<el-form-item v-if="item.type === 'select'" :label="item.label"
:prop="item.key"
:rules="getValidationRules(item)">
<el-select v-model="formData[item.key]" :placeholder="item.description"
style="width: 100%" clearable>
<el-option v-for="(option, optionIndex) in item.values" :key="optionIndex"
:label="option.label" :value="option.value">
</el-option>
</el-select>
</el-form-item>
<!-- 复选框 - 修复数组类型问题 -->
|
9d019fa6
wuxw
测试OA相关流程
|
74
|
<el-form-item v-if="item.type === 'checkbox'" :label="item.label"
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
75
76
77
78
79
80
81
|
:prop="item.key"
:rules="getValidationRules(item)">
<el-checkbox-group v-model="formData[item.key]">
<el-checkbox v-for="(option, optionIndex) in item.values" :key="optionIndex"
:label="option.value">
{{ option.label }}
</el-checkbox>
|
9d019fa6
wuxw
测试OA相关流程
|
82
83
84
85
|
</el-checkbox-group>
</el-form-item>
</div>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
86
87
88
89
90
91
92
|
<!-- 文件上传 -->
<el-form-item :label="$t('common.file')">
<div class="file-info" v-if="newOaWorkflowFormEditInfo.fileName">
<el-tag type="info">{{ newOaWorkflowFormEditInfo.fileName }}</el-tag>
</div>
<upload-file ref="uploadFile" @notify="handleFileUpload" />
</el-form-item>
|
9d019fa6
wuxw
测试OA相关流程
|
93
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
94
|
<!-- 按钮区域 -->
|
9d019fa6
wuxw
测试OA相关流程
|
95
|
<div class="form-footer">
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
96
|
<el-button type="primary" @click="_submitFormData" :loading="submitLoading">
|
9d019fa6
wuxw
测试OA相关流程
|
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<i class="el-icon-check"></i>
{{ $t('newOaWorkflowFormEdit.submit') }}
</el-button>
<el-button type="warning" @click="closeEditInfo">
{{ $t('newOaWorkflowFormEdit.cancel') }}
</el-button>
</div>
</el-col>
</el-row>
</el-form>
</el-card>
</div>
</template>
<script>
import { queryOaWorkflowForm, queryOaWorkflowFormData, updateOaWorkflowFormData } from '@/api/oa/newOaWorkflowFormEditApi'
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
113
|
import UploadFile from '@/components/upload/uploadFile'
|
9d019fa6
wuxw
测试OA相关流程
|
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
export default {
name: 'NewOaWorkflowFormEditList',
components: {
UploadFile
},
data() {
return {
newOaWorkflowFormEditInfo: {
formJson: {},
components: [],
conditions: {},
flowId: '',
id: '',
fileName: '',
realFileName: ''
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
130
131
132
|
},
formData: {}, // 新增:用于表单数据绑定
submitLoading: false
|
9d019fa6
wuxw
测试OA相关流程
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
}
},
created() {
this.newOaWorkflowFormEditInfo.flowId = this.$route.query.flowId
this.newOaWorkflowFormEditInfo.id = this.$route.query.id
this._listOaWorkflowFormEdit(1, 100)
},
methods: {
async _listOaWorkflowFormEdit(page, rows) {
try {
const params = {
page,
row: rows,
flowId: this.newOaWorkflowFormEditInfo.flowId
}
const { data } = await queryOaWorkflowForm(params)
const formData = JSON.parse(data[0].formJson)
this.newOaWorkflowFormEditInfo.formJson = formData
this.newOaWorkflowFormEditInfo.components = formData.components
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
153
154
155
156
|
// 初始化表单数据
this.initFormData()
|
9d019fa6
wuxw
测试OA相关流程
|
157
158
159
|
this._listOaWorkflowDetails()
} catch (error) {
console.error('获取表单数据失败:', error)
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
160
|
this.$message.error('获取表单数据失败')
|
9d019fa6
wuxw
测试OA相关流程
|
161
162
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
initFormData() {
// 初始化表单数据对象
this.formData = {}
this.newOaWorkflowFormEditInfo.components.forEach(item => {
if (item.type !== 'button' && item.type !== 'text') {
if (item.type === 'checkbox') {
// 确保复选框的值是数组类型
this.$set(this.formData, item.key, [])
} else if (item.type === 'radio' || item.type === 'select') {
this.$set(this.formData, item.key, item.values && item.values.length > 0 ? item.values[0].value : '')
} else {
this.$set(this.formData, item.key, '')
}
}
})
},
|
9d019fa6
wuxw
测试OA相关流程
|
181
182
183
184
185
186
187
188
189
190
191
192
|
async _listOaWorkflowDetails() {
try {
const params = {
page: 1,
row: 1,
id: this.newOaWorkflowFormEditInfo.id,
flowId: this.newOaWorkflowFormEditInfo.flowId
}
const { data } = await queryOaWorkflowFormData(params)
const detailData = data[0]
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
193
|
// 更新表单数据
|
9d019fa6
wuxw
测试OA相关流程
|
194
|
this.newOaWorkflowFormEditInfo.components.forEach(item => {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
if (item.type !== 'button' && item.type !== 'text') {
const value = detailData[item.key]
if (value !== undefined && value !== null) {
if (item.type === 'checkbox') {
// 确保复选框数据是数组类型
if (Array.isArray(value)) {
this.$set(this.formData, item.key, value)
} else if (typeof value === 'string' && value) {
// 如果是字符串,转换为数组
this.$set(this.formData, item.key, [value])
} else {
this.$set(this.formData, item.key, [])
}
} else {
this.$set(this.formData, item.key, value)
}
}
}
|
9d019fa6
wuxw
测试OA相关流程
|
213
214
|
})
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
215
216
|
// 处理文件数据
if (detailData.files && detailData.files.length > 0) {
|
9d019fa6
wuxw
测试OA相关流程
|
217
218
|
this.newOaWorkflowFormEditInfo.fileName = detailData.files[0].fileName
this.newOaWorkflowFormEditInfo.realFileName = detailData.files[0].realFileName
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
219
220
221
222
223
|
this.$nextTick(() => {
if (this.$refs.uploadFile) {
this.$refs.uploadFile.notifyVedio(detailData.files[0].fileName)
}
})
|
9d019fa6
wuxw
测试OA相关流程
|
224
225
226
|
}
} catch (error) {
console.error('获取表单详情失败:', error)
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
227
|
this.$message.error('获取表单详情失败')
|
9d019fa6
wuxw
测试OA相关流程
|
228
229
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
230
231
232
233
234
235
236
237
238
239
240
241
242
|
getValidationRules(item) {
const rules = []
if (item.validate && item.validate.required) {
rules.push({
required: true,
message: `${item.label}不能为空`,
trigger: 'blur'
})
}
return rules
},
|
9d019fa6
wuxw
测试OA相关流程
|
243
244
|
async _submitFormData() {
try {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
245
246
247
248
249
|
// 表单验证
await this.$refs.form.validate()
this.submitLoading = true
|
9d019fa6
wuxw
测试OA相关流程
|
250
251
252
253
|
const formData = {
id: this.newOaWorkflowFormEditInfo.id,
flowId: this.newOaWorkflowFormEditInfo.flowId,
fileName: this.newOaWorkflowFormEditInfo.fileName,
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
254
255
|
realFileName: this.newOaWorkflowFormEditInfo.realFileName,
|
9d019fa6
wuxw
测试OA相关流程
|
256
257
|
}
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
258
259
|
// 收集表单数据
this.newOaWorkflowFormEditInfo.components.forEach(item => {
|
9d019fa6
wuxw
测试OA相关流程
|
260
|
if (item.type !== 'button' && item.type !== 'text') {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
261
|
formData[item.key] = this.formData[item.key]
|
9d019fa6
wuxw
测试OA相关流程
|
262
|
if (item.type === 'checkbox') {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
263
264
265
266
|
// 复选框提交时取第一个值或空字符串
formData[item.key] = this.formData[item.key] && this.formData[item.key].length > 0
? this.formData[item.key][0]
: ''
|
9d019fa6
wuxw
测试OA相关流程
|
267
268
269
270
271
272
|
}
}
})
const res = await updateOaWorkflowFormData(formData)
if (res.code === 0) {
|
6ec243d6
wuxw
v1.9 点击提交后,成功提示没有...
|
273
|
this.$message.success(this.$t('common.operationSuccess'))
|
9d019fa6
wuxw
测试OA相关流程
|
274
275
|
this.closeEditInfo()
} else {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
276
|
this.$message.error(res.msg || this.$t('newOaWorkflowFormEdit.submitError'))
|
9d019fa6
wuxw
测试OA相关流程
|
277
278
|
}
} catch (error) {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
279
280
281
282
|
if (error.message) {
// 表单验证错误
return
}
|
9d019fa6
wuxw
测试OA相关流程
|
283
284
|
console.error('提交表单失败:', error)
this.$message.error(this.$t('newOaWorkflowFormEdit.submitError'))
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
285
286
|
} finally {
this.submitLoading = false
|
9d019fa6
wuxw
测试OA相关流程
|
287
288
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
289
|
|
9d019fa6
wuxw
测试OA相关流程
|
290
291
|
closeEditInfo() {
this.$router.go(-1)
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
292
293
294
295
296
|
},
handleFileUpload(data) {
this.newOaWorkflowFormEditInfo.fileName = data.fileName
this.newOaWorkflowFormEditInfo.realFileName = data.realFileName
|
9d019fa6
wuxw
测试OA相关流程
|
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
}
}
}
</script>
<style lang="scss" scoped>
.new-oa-workflow-form-edit-container {
padding: 20px;
.box-card {
margin-bottom: 20px;
}
.form-footer {
margin-top: 20px;
text-align: right;
}
.el-form-item {
margin-bottom: 22px;
}
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
318
319
320
321
|
.file-info {
margin-bottom: 10px;
}
|
9d019fa6
wuxw
测试OA相关流程
|
322
323
|
}
</style>
|