commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<a-modal |
|
3 |
title="新增${functionName}" |
|
4 |
:width="900" |
|
5 |
:visible="visible" |
|
6 |
:confirmLoading="confirmLoading" |
|
7 |
@ok="handleSubmit" |
|
8 |
@cancel="handleCancel" |
|
9 |
> |
|
10 |
<a-spin :spinning="confirmLoading"> |
|
11 |
<a-form :form="form"> |
|
12 |
#foreach ($column in $tableField) |
|
13 |
#if (${column.columnKey} != "PRI") |
|
14 |
#if (${column.whetherAddUpdate} == "Y") |
|
15 |
#if (${column.effectType} == 'select' || ${column.effectType} == 'radio' || ${column.effectType} == 'checkbox') |
|
16 |
<a-form-item |
|
17 |
label="${column.columnComment}" |
|
18 |
:labelCol="labelCol" |
|
19 |
:wrapperCol="wrapperCol" |
|
20 |
> |
|
21 |
#else |
|
22 |
<a-form-item |
|
23 |
label="${column.columnComment}" |
|
24 |
:labelCol="labelCol" |
|
25 |
:wrapperCol="wrapperCol" |
|
26 |
has-feedback |
|
27 |
> |
|
28 |
#end |
|
29 |
#if (${column.effectType} == "user") |
|
30 |
#if (${column.whetherRequired} == "Y") |
|
31 |
<user-select placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}', {rules: [{required: true, message: '请输入${column.columnComment}!'}]}]" /> |
|
32 |
#else |
|
33 |
<user-select placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}']" /> |
|
34 |
#end |
|
35 |
#end |
|
36 |
#if (${column.effectType} == "depart") |
|
37 |
#if (${column.whetherRequired} == "Y") |
|
38 |
<depart-select placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}', {rules: [{required: true, message: '请输入${column.columnComment}!'}]}]" /> |
|
39 |
#else |
|
40 |
<depart-select placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}']" /> |
|
41 |
#end |
|
42 |
#end |
|
43 |
#if (${column.effectType} == "input") |
|
44 |
#if (${column.whetherRequired} == "Y") |
|
45 |
<a-input placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}', {rules: [{required: true, message: '请输入${column.columnComment}!'}]}]" /> |
|
46 |
#else |
|
47 |
<a-input placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}']" /> |
|
48 |
#end |
|
49 |
#end |
|
50 |
#if (${column.effectType} == "textarea") |
|
51 |
#if (${column.whetherRequired} == "Y") |
|
52 |
<a-textarea placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}', {rules: [{required: true, message: '请输入${column.columnComment}!'}]}]" :auto-size="{ minRows: 3, maxRows: 6 }"/> |
|
53 |
#else |
|
54 |
<a-textarea placeholder="请输入${column.columnComment}" v-decorator="['${column.javaName}']" :auto-size="{ minRows: 3, maxRows: 6 }"/> |
|
55 |
#end |
|
56 |
#end |
|
57 |
#if (${column.effectType} == "inputnumber") |
|
58 |
#if (${column.whetherRequired} == "Y") |
|
59 |
<a-input-number placeholder="请输入${column.columnComment}" style="width: 100%" v-decorator="['${column.javaName}', {rules: [{required: true, message: '请输入${column.columnComment}!'}]}]" /> |
|
60 |
#else |
|
61 |
<a-input-number placeholder="请输入${column.columnComment}" style="width: 100%" v-decorator="['${column.javaName}']" /> |
|
62 |
#end |
|
63 |
#end |
|
64 |
#if (${column.effectType} == "select") |
|
65 |
#if (${column.whetherRequired} == "Y") |
|
66 |
<a-select style="width: 100%" placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}', {rules: [{ required: true, message: '请选择${column.columnComment}!' }]}]"> |
|
67 |
<a-select-option v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
68 |
</a-select> |
|
69 |
#else |
|
70 |
<a-select style="width: 100%" placeholder="请选择${column.columnComment}"> |
|
71 |
<a-select-option v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-select-option> |
|
72 |
</a-select> |
|
73 |
#end |
|
74 |
#end |
|
75 |
#if (${column.effectType} == "radio") |
|
76 |
#if (${column.whetherRequired} == "Y") |
|
77 |
<a-radio-group placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}',{rules: [{ required: true, message: '请选择${column.columnComment}!' }]}]" > |
|
78 |
<a-radio v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-radio> |
|
79 |
</a-radio-group> |
|
80 |
#else |
|
81 |
<a-radio-group placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}']" > |
|
82 |
<a-radio v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-radio> |
|
83 |
</a-radio-group> |
|
84 |
#end |
|
85 |
#end |
|
86 |
#if (${column.effectType} == "checkbox") |
|
87 |
#if (${column.whetherRequired} == "Y") |
|
88 |
<a-checkbox-group placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}',{rules: [{ required: true, message: '请选择${column.columnComment}!' }]}]" > |
|
89 |
<a-checkbox v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-checkbox> |
|
90 |
</a-checkbox-group> |
|
91 |
#else |
|
92 |
<a-checkbox-group placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}']" > |
|
93 |
<a-checkbox v-for="(item,index) in ${column.javaName}Data" :key="index" :value="item.code">{{ item.name }}</a-checkbox> |
|
94 |
</a-checkbox-group> |
|
95 |
#end |
|
96 |
#end |
|
97 |
#if (${column.effectType} == "datepicker") |
|
98 |
#if (${column.whetherRequired} == "Y") |
|
99 |
<a-date-picker style="width: 100%" placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}',{rules: [{ required: true, message: '请选择${column.columnComment}!' }]}]" @change="${column.javaName}OnChange"/> |
|
100 |
#else |
|
101 |
<a-date-picker style="width: 100%" placeholder="请选择${column.columnComment}" v-decorator="['${column.javaName}']" @change="${column.javaName}OnChange"/> |
|
102 |
#end |
|
103 |
#end |
|
104 |
</a-form-item> |
|
105 |
#end |
|
106 |
#end |
|
107 |
#end |
|
108 |
</a-form> |
|
109 |
</a-spin> |
|
110 |
</a-modal> |
|
111 |
</template> |
|
112 |
|
|
113 |
<script> |
|
114 |
import { ${className}Add } from '@/api/modular/main/${busName}/${className}Manage' |
|
115 |
export default { |
|
116 |
data () { |
|
117 |
return { |
|
118 |
labelCol: { |
|
119 |
xs: { span: 24 }, |
|
120 |
sm: { span: 5 } |
|
121 |
}, |
|
122 |
wrapperCol: { |
|
123 |
xs: { span: 24 }, |
|
124 |
sm: { span: 15 } |
|
125 |
}, |
|
126 |
#foreach ($column in $tableField) |
|
127 |
#if (${column.whetherAddUpdate} == "Y") |
|
128 |
#if (${column.dictTypeCode}) |
|
129 |
#if(${column.effectType} == 'select' || ${column.effectType} == 'radio' || ${column.effectType} == 'checkbox') |
|
130 |
${column.javaName}Data: [], |
|
131 |
#end |
|
132 |
#end |
|
133 |
#if (${column.effectType} == "datepicker") |
|
134 |
${column.javaName}DateString: '', |
|
135 |
#end |
|
136 |
#end |
|
137 |
#end |
|
138 |
visible: false, |
|
139 |
confirmLoading: false, |
|
140 |
form: this.$form.createForm(this) |
|
141 |
} |
|
142 |
}, |
|
143 |
methods: { |
|
144 |
// 初始化方法 |
|
145 |
add (record) { |
|
146 |
this.visible = true |
|
147 |
#foreach ($column in $tableField) |
|
148 |
#if (${column.dictTypeCode}) |
|
149 |
#if(${column.effectType} == 'select' || ${column.effectType} == 'radio' || ${column.effectType} == 'checkbox') |
|
150 |
const ${column.javaName}Option = this.$options |
|
151 |
this.${column.javaName}Data = ${column.javaName}Option.filters['dictData']('${column.dictTypeCode}') |
|
152 |
#end |
|
153 |
#end |
|
154 |
#end |
|
155 |
}, |
|
156 |
/** |
|
157 |
* 提交表单 |
|
158 |
*/ |
|
159 |
handleSubmit () { |
|
160 |
const { form: { validateFields } } = this |
|
161 |
this.confirmLoading = true |
|
162 |
validateFields((errors, values) => { |
|
163 |
if (!errors) { |
|
164 |
for (const key in values) { |
|
165 |
if (typeof (values[key]) === 'object' && values[key] != null) { |
|
166 |
values[key] = JSON.stringify(values[key]) |
|
167 |
} |
|
168 |
} |
|
169 |
#foreach ($column in $tableField) |
|
170 |
#if (${column.whetherAddUpdate} == "Y") |
|
171 |
#if (${column.effectType} == "datepicker") |
|
172 |
values.${column.javaName} = this.${column.javaName}DateString || null |
|
173 |
#end |
|
174 |
#end |
|
175 |
#end |
|
176 |
${className}Add(values).then((res) => { |
|
177 |
if (res.success) { |
|
178 |
this.$message.success('新增成功') |
|
179 |
this.confirmLoading = false |
|
180 |
this.$emit('ok', values) |
|
181 |
this.handleCancel() |
|
182 |
} else { |
|
183 |
this.$message.error('新增失败')// + res.message |
|
184 |
} |
|
185 |
}).finally((res) => { |
|
186 |
this.confirmLoading = false |
|
187 |
}) |
|
188 |
} else { |
|
189 |
this.confirmLoading = false |
|
190 |
} |
|
191 |
}) |
|
192 |
}, |
|
193 |
#foreach ($column in $tableField) |
|
194 |
#if (${column.whetherAddUpdate} == "Y") |
|
195 |
#if (${column.effectType} == "datepicker") |
|
196 |
${column.javaName}OnChange(date, dateString) { |
|
197 |
this.${column.javaName}DateString = dateString |
|
198 |
}, |
|
199 |
#end |
|
200 |
#end |
|
201 |
#end |
|
202 |
handleCancel () { |
|
203 |
#foreach ($column in $tableField) |
|
204 |
#if (${column.whetherAddUpdate} == "Y") |
|
205 |
#if (${column.effectType} == "datepicker") |
|
206 |
this.${column.javaName}DateString ='' |
|
207 |
this.form.getFieldDecorator('${column.javaName}', { initialValue: null }) |
|
208 |
#end |
|
209 |
#end |
|
210 |
#end |
|
211 |
this.form.resetFields() |
|
212 |
this.visible = false |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
</script> |