parent
a2c0d1f58a
commit
4dd9c20bce
@ -0,0 +1,247 @@
|
||||
<div id="app" v-cloak>
|
||||
<el-card class="box-card">
|
||||
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
|
||||
<#list fields as item>
|
||||
<#if item.isQuery>
|
||||
<el-form-item label="${item.fieldComment}" prop="${item.getFName()}">
|
||||
<el-input v-model="vm.${item.getFName()}" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#list>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增
|
||||
</el-button>
|
||||
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
|
||||
|
||||
<el-dialog :title="form.title" :visible.sync="form.dialog">
|
||||
<el-form :model="form" :rules="formRules" ref="form" label-width="90px"
|
||||
style="width: 290px;">
|
||||
<#list fields as item>
|
||||
<#if item.isQuery && !item.isSystem>
|
||||
<el-form-item label="${item.fieldComment}" prop="${item.getFName()}">
|
||||
<el-input v-model="form.${item.getFName()}" clearable size="small" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#list>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="small" @click="form.dialog = false">取 消</el-button>
|
||||
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-button-group style="float: right;">
|
||||
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
@selection-change="onSelectionChange"
|
||||
empty-text="无数据"
|
||||
:data="result"
|
||||
size="small"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
align="center"
|
||||
type="selection"
|
||||
width="40">
|
||||
</el-table-column>
|
||||
<#list fields as item>
|
||||
<#if item.isQuery && !item.isSystem>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="${item.getFName()}"
|
||||
label="${item.fieldComment}">
|
||||
</el-table-column>
|
||||
</#if>
|
||||
</#list>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="createTime"
|
||||
label="创建时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
fixed="right"
|
||||
width="120"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-dropdown size="mini" split-button type="primary" @click="onAction(['edit',scope.row])"
|
||||
@command="onAction">
|
||||
<i class="el-icon-edit"></i>编辑
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-if="vm.totalCount > vm.pageSize"
|
||||
@current-change="onPage"
|
||||
:current-page="vm.pageNumber"
|
||||
:page-size="vm.pageSize"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
:total="vm.totalCount">
|
||||
</el-pagination>
|
||||
</el-card>
|
||||
</div>
|
||||
<style>
|
||||
#app {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
vm: {//条件及分页参数
|
||||
<#list fields as item>
|
||||
<#if item.isQuery>
|
||||
${item.getFName()}: "",
|
||||
</#if>
|
||||
</#list>
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0
|
||||
},
|
||||
form: {//待提交表单
|
||||
title: "",
|
||||
dialog: false,
|
||||
id: '',
|
||||
<#list fields as item>
|
||||
<#if !item.isSystem>
|
||||
${item.getFName()}: "",
|
||||
</#if>
|
||||
</#list>
|
||||
rowVersion: ""
|
||||
},
|
||||
formRules: {
|
||||
code: [
|
||||
{required: true, message: '部门代码不能为空', trigger: 'blur'},
|
||||
{min: 1, max: 100, message: '长度在 1 到 50 个字符', trigger: 'blur'}
|
||||
|
||||
],
|
||||
},
|
||||
select: [],
|
||||
result: [],
|
||||
},
|
||||
methods: {
|
||||
onSearch: function () {
|
||||
this.vm.pageNumber = 1;
|
||||
this.onFind();
|
||||
},
|
||||
onReset: function (form) {
|
||||
this.$refs[form].resetFields();
|
||||
nav.w('重置成功');
|
||||
},
|
||||
onFind: function () {
|
||||
ajax.${table.getFName()}Find(this.vm).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.result = response.result;
|
||||
this.totalCount = Number(response.totalCount);
|
||||
}
|
||||
}.bind(this))
|
||||
},
|
||||
onPage: function (pageNumber) {
|
||||
this.vm.pageNumber = pageNumber;
|
||||
this.onFind();
|
||||
},
|
||||
onSelectionChange: function (select) {
|
||||
this.select = select;
|
||||
},
|
||||
onAction: function (arg) {
|
||||
const action = arg[0];
|
||||
const item = arg[1];
|
||||
switch (action) {
|
||||
case "create":
|
||||
this.form.title = "${table.tableComment}新增";
|
||||
this.form.dialog = true;
|
||||
this.form.id = "";
|
||||
<#list fields as item>
|
||||
<#if !item.isSystem>
|
||||
this.form.${item.getFName()} = "";
|
||||
</#if>
|
||||
</#list>
|
||||
break;
|
||||
case "save":
|
||||
if (this.form.id) {
|
||||
ajax.${table.getFName()}Update(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
} else {
|
||||
ajax.${table.getFName()}Create(this.form).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
this.onFind();
|
||||
this.form.dialog = false;
|
||||
}
|
||||
}.bind(this))
|
||||
}
|
||||
break;
|
||||
case "edit":
|
||||
this.form.title = "${table.tableComment}编辑";
|
||||
this.form.dialog = true;
|
||||
this.form.id = item.id;
|
||||
<#list fields as item>
|
||||
<#if !item.isSystem>
|
||||
this.form.${item.getFName()} = item.${item.getFName()};
|
||||
</#if>
|
||||
</#list>
|
||||
this.form.rowVersion = item.rowVersion;
|
||||
break;
|
||||
case "delete":
|
||||
this.$confirm('将删除该项, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function () {
|
||||
ajax.${table.getFName()}Delete({id: item.id}).then(function (response) {
|
||||
if (response.errors.length > 0) {
|
||||
nav.e(response.errors[0].message);
|
||||
} else {
|
||||
nav.s("删除成功")
|
||||
this.onFind();
|
||||
}
|
||||
}.bind(this))
|
||||
}.bind(this)).catch(function (action) {
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
},
|
||||
created: function () {
|
||||
},
|
||||
mounted: function () {
|
||||
this.onFind();
|
||||
},
|
||||
watch: {}
|
||||
})
|
||||
</script>
|
Loading…
Reference in new issue