9d019fa6
wuxw
测试OA相关流程
|
1
2
3
|
<template>
<div class="new-oa-workflow-form">
<el-card class="form-card">
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
4
5
6
7
8
9
|
<el-form ref="form" :model="formData" label-width="120px" label-position="right" class="text-left">
<div v-for="(item, index) in components" :key="index">
<!-- 标题 -->
<el-divider v-if="item.type == 'text'" content-position="left">
<span class="form-title">{{ item.text }}</span>
</el-divider>
|
9d019fa6
wuxw
测试OA相关流程
|
10
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<!-- 文本框 -->
<el-form-item v-if="item.type == 'textfield'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-input v-model="item.value" :placeholder="item.description" clearable>
</el-input>
</el-form-item>
<!-- 数字框 -->
<el-form-item v-if="item.type == 'number'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-input-number v-model="item.value" :placeholder="item.description" :min="0" style="width: 100%">
</el-input-number>
</el-form-item>
<!-- 文本域 -->
<el-form-item v-if="item.type == 'textarea'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-input v-model="item.value" type="textarea" :rows="4" :placeholder="item.description">
</el-input>
</el-form-item>
<!-- 日期选择 -->
<el-form-item v-if="item.type == 'textdate'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-date-picker v-model="item.value" type="date" :placeholder="item.description" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" style="width: 100%">
</el-date-picker>
</el-form-item>
<!-- 时间选择 -->
<el-form-item v-if="item.type == 'textdatetime'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-time-picker v-model="item.value" :placeholder="item.description" format="HH:mm"
value-format="HH:mm" style="width: 100%">
</el-time-picker>
</el-form-item>
<!-- 单选框 -->
<el-form-item v-if="item.type == 'radio'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-radio-group v-model="item.value">
<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="item.value" :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>
<!-- 复选框 -->
<el-form-item v-if="item.type == 'checkbox'" :label="item.label" :prop="item.key"
:rules="getValidationRules(item)">
<el-checkbox-group v-model="item.value">
<el-checkbox v-for="(option, optionIndex) in item.values" :key="optionIndex" :label="option.value">
{{ option.label }}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<!-- 文件上传 -->
<el-form-item v-if="item.type == 'button' && item.action == 'submit'" :label="$t('common.file')">
<div class="upload-section">
<upload-file ref="uploadFile" @notify="handleFileUpload" />
</div>
</el-form-item>
<!-- 提交按钮 -->
<el-form-item v-if="item.type == 'button' && item.action == 'submit'" class="text-right">
<el-button type="primary" @click="_doSubmit" :loading="submitLoading">
<i class="el-icon-check"></i>
{{ item.label }}
</el-button>
</el-form-item>
<!-- 重置按钮 -->
<el-form-item v-if="item.type == 'button' && item.action == 'reset'" class="text-right">
<el-button @click="_doReset">
<i class="el-icon-refresh"></i>
{{ item.label }}
</el-button>
</el-form-item>
|
9d019fa6
wuxw
测试OA相关流程
|
100
|
</div>
|
9d019fa6
wuxw
测试OA相关流程
|
101
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
102
|
</el-form>
|
9d019fa6
wuxw
测试OA相关流程
|
103
104
105
106
107
108
109
|
</el-card>
</div>
</template>
<script>
import UploadFile from '@/components/upload/uploadFile'
import { queryOaWorkflowForm, saveOaWorkflowFormData } from '@/api/oa/newOaWorkflowApi'
|
9d019fa6
wuxw
测试OA相关流程
|
110
111
112
113
114
115
116
117
|
export default {
name: 'NewOaWorkflowForm',
components: { UploadFile },
data() {
return {
formJson: {},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
118
119
|
components: [],
formData: {},
|
9d019fa6
wuxw
测试OA相关流程
|
120
121
122
123
|
fileName: '',
realFileName: '',
callBackListener: 'newOaWorkflowForm',
callBackFunction: 'fileName',
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
124
125
|
submitLoading: false,
showUploadComponent: false
|
9d019fa6
wuxw
测试OA相关流程
|
126
127
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
128
|
|
9d019fa6
wuxw
测试OA相关流程
|
129
130
|
mounted() {
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
131
|
|
9d019fa6
wuxw
测试OA相关流程
|
132
133
134
135
136
|
methods: {
open(params) {
this.flowId = params.flowId
this.listOaWorkflowForm()
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
137
|
|
9d019fa6
wuxw
测试OA相关流程
|
138
139
140
141
142
143
144
145
146
147
148
149
|
async listOaWorkflowForm() {
try {
const res = await queryOaWorkflowForm({
page: 1,
row: 1,
flowId: this.flowId
})
console.log(res)
this.formJson = JSON.parse(res.data[0].formJson)
this.initForm()
} catch (error) {
console.error('获取表单配置失败:', error)
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
150
|
this.$message.error('获取表单配置失败')
|
9d019fa6
wuxw
测试OA相关流程
|
151
152
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
153
|
|
9d019fa6
wuxw
测试OA相关流程
|
154
|
initForm() {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
155
156
|
this.components = this.formJson.components
this.formData = {}
|
9d019fa6
wuxw
测试OA相关流程
|
157
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
158
159
160
161
162
163
164
165
166
167
168
169
|
this.components.forEach(item => {
if (item.type !== 'button' && item.type !== 'text') {
// 初始化表单数据
if (item.type === 'checkbox') {
this.formData[item.key] = []
} else if (item.type === 'radio' || item.type === 'select') {
this.formData[item.key] = item.values && item.values.length > 0 ? item.values[0].value : ''
} else {
this.formData[item.key] = ''
}
}
})
|
9d019fa6
wuxw
测试OA相关流程
|
170
|
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
171
172
173
174
175
176
177
178
179
|
getValidationRules(item) {
const rules = []
if (item.validate && item.validate.required) {
rules.push({
required: true,
message: `${item.label}不能为空`,
trigger: 'blur'
})
|
9d019fa6
wuxw
测试OA相关流程
|
180
|
}
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
181
182
|
return rules
},
|
9d019fa6
wuxw
测试OA相关流程
|
183
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
184
|
async _doSubmit() {
|
9d019fa6
wuxw
测试OA相关流程
|
185
|
try {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
186
187
188
189
190
191
192
193
194
195
196
197
198
|
// 表单验证
await this.$refs.form.validate()
this.submitLoading = true
const _data = {
fileName: this.fileName,
realFileName: this.realFileName,
flowId: this.flowId,
...this.formData
}
const res = await saveOaWorkflowFormData(_data)
|
9d019fa6
wuxw
测试OA相关流程
|
199
200
201
202
203
|
if (res.code === 0) {
this.$message.success(this.$t('common.submitSuccess'))
this.resetForm()
this.$emit('switch-tab', 'newOaWorkflowPool')
} else {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
204
|
this.$message.error(res.msg || this.$t('common.submitFailed'))
|
9d019fa6
wuxw
测试OA相关流程
|
205
206
|
}
} catch (error) {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
207
208
209
210
|
if (error.message) {
// 表单验证错误
return
}
|
9d019fa6
wuxw
测试OA相关流程
|
211
212
|
console.error('提交表单失败:', error)
this.$message.error(this.$t('common.submitFailed'))
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
213
214
|
} finally {
this.submitLoading = false
|
9d019fa6
wuxw
测试OA相关流程
|
215
216
|
}
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
_doReset() {
let _that = this;
_that.components.forEach(item => {
item.value = "";
if (item.type == 'textdate' || item.type == 'textdatetime') {
item.value = "请选择";
}
if (item.type == "radio" || item.type == "select") {
item.valueIndex = 0;
}
});
this.$forceUpdate();
},
_doUploadFile() {
this.showUploadComponent = true
this.$nextTick(() => {
this.$refs.uploadFile.open()
})
},
|
9d019fa6
wuxw
测试OA相关流程
|
240
|
resetForm() {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
241
242
243
|
this.$refs.form.resetFields()
if (this.$refs.uploadFile) {
this.$refs.uploadFile.clear()
|
9d019fa6
wuxw
测试OA相关流程
|
244
|
}
|
9d019fa6
wuxw
测试OA相关流程
|
245
246
247
|
this.fileName = ''
this.realFileName = ''
this.formJson = {}
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
248
249
250
|
this.components = []
this.formData = {}
this.showUploadComponent = false
|
9d019fa6
wuxw
测试OA相关流程
|
251
|
},
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
252
|
|
9d019fa6
wuxw
测试OA相关流程
|
253
254
255
256
257
258
259
260
|
handleFileUpload(fileInfo) {
this.fileName = fileInfo.fileName
this.realFileName = fileInfo.realFileName
}
}
}
</script>
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
261
|
<style lang="scss" scoped>
|
9d019fa6
wuxw
测试OA相关流程
|
262
263
|
.new-oa-workflow-form {
.form-card {
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
264
265
266
267
|
.form-title {
font-size: 16px;
font-weight: 600;
color: #303133;
|
9d019fa6
wuxw
测试OA相关流程
|
268
|
}
|
9d019fa6
wuxw
测试OA相关流程
|
269
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
270
271
272
273
274
|
.upload-section {
.file-info {
margin-bottom: 10px;
}
}
|
9d019fa6
wuxw
测试OA相关流程
|
275
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
276
277
278
|
.el-form-item {
margin-bottom: 22px;
}
|
9d019fa6
wuxw
测试OA相关流程
|
279
|
|
caba9d96
wuxw
oa 中除了 工作办理没有测试其他...
|
280
281
282
|
.el-divider {
margin: 24px 0;
}
|
9d019fa6
wuxw
测试OA相关流程
|
283
284
285
|
}
}
</style>
|