#foreach($column in $columns) #if ($column.createOperation || $column.updateOperation) #set ($dictType = $column.dictType) #set ($javaField = $column.javaField) #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set ($comment = $column.columnComment) #if ($column.htmlType == "input") #if (!$column.primaryKey)## 忽略主键,不用在表单里 #end #elseif($column.htmlType == "imageUpload")## 图片上传 #set ($hasImageUploadColumn = true) #elseif($column.htmlType == "fileUpload")## 文件上传 #set ($hasFileUploadColumn = true) #elseif($column.htmlType == "editor")## 文本编辑器 #set ($hasEditorColumn = true) #elseif($column.htmlType == "select")## 下拉框 #if ("" != $dictType)## 有数据字典 #else##没数据字典 #end #elseif($column.htmlType == "checkbox")## 多选框 #if ("" != $dictType)## 有数据字典 {{dict.label}} #else##没数据字典 请选择字典生成 #end #elseif($column.htmlType == "radio")## 单选框 #if ("" != $dictType)## 有数据字典 {{dict.label}} #else##没数据字典 请选择字典生成 #end #elseif($column.htmlType == "datetime")## 时间框 #elseif($column.htmlType == "textarea")## 文本框 #end #end #end // 弹出层标题 title: "", // 是否显示弹出层 open: false, // 表单参数 form: {}, // 表单校验 rules: { #foreach ($column in $columns) #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 #set($comment=$column.columnComment) $column.javaField: [{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }], #end #end } /** 表单重置 */ reset() { this.form = { #foreach ($column in $columns) #if ($column.createOperation || $column.updateOperation) #if ($column.htmlType == "checkbox") $column.javaField: [], #else $column.javaField: undefined, #end #end #end }; this.resetForm("form"); }, /** 新增按钮操作 */ handleAdd() { this.reset(); this.open = true; this.title = "添加${table.classComment}"; }, /** 修改按钮操作 */ handleUpdate(row) { this.reset(); const ${primaryColumn.javaField} = row.${primaryColumn.javaField}; get${simpleClassName}(${primaryColumn.javaField}).then(response => { this.form = response.data; #foreach ($column in $columns) #if($column.htmlType == "checkbox")## checkbox 特殊处理 this.form.$column.javaField = this.form.${column.javaField}.split(","); #end #end this.open = true; this.title = "修改${table.classComment}"; }); }, /** 提交按钮 */ submitForm() { this.#[[$]]#refs["form"].validate(valid => { if (!valid) { return; } #foreach ($column in $columns) #if($column.htmlType == "checkbox") this.form.$column.javaField = this.form.${column.javaField}.join(","); #end #end // 修改的提交 if (this.form.${primaryColumn.javaField} != null) { update${simpleClassName}(this.form).then(response => { this.#[[$modal]]#.msgSuccess("修改成功"); this.open = false; this.getList(); }); return; } // 添加的提交 create${simpleClassName}(this.form).then(response => { this.#[[$modal]]#.msgSuccess("新增成功"); this.open = false; this.getList(); }); }); },