1
0
suochencheng преди 8 години
родител
ревизия
0517983515
променени са 1 файла, в които са добавени 19 реда и са изтрити 1 реда
  1. 19 1
      src/main/resources/templates/FormTemplate.vm

+ 19 - 1
src/main/resources/templates/FormTemplate.vm

@@ -106,6 +106,7 @@
             #end
             <el-form-item>
                 <el-button @click="onSave" :loading="${esc.d}store.state.fetchingData" type="primary">保存</el-button>
+                <el-button @click="onDelete" v-if="formData.id" type="danger">删除</el-button>
                 <el-button @click="${esc.d}router.go(-1)">取消</el-button>
             </el-form-item>
         </el-form>
@@ -194,7 +195,24 @@
                         this.${esc.d}message.warning('失败')
                     }
                 });
-            }
+            },
+            onDelete() {
+                this.${esc.d}alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
+                    return this.${esc.d}http.post({
+                    url: '/${display.uncapitalize($model.className)}/del',
+                    data: { id: this.formData.id }
+                    })
+                }).then(() => {
+                    this.${esc.d}message.success('删除成功');
+                    this.${esc.d}router.go(-1);
+                }).catch(action => {
+                    if (action === 'cancel') {
+                        this.${esc.d}message.info('删除取消');
+                    } else {
+                        this.${esc.d}message.error('删除失败');
+                    }
+                })
+            },
         }
     }
 </script>