mirror of https://gitee.com/maxjhandsome/pig
end: 完成代码生成,支持vue增删查改
This commit is contained in:
parent
3539be7054
commit
9a8300e731
|
@ -55,7 +55,7 @@ public class MybatisPlusGenerator {
|
||||||
// 策略配置
|
// 策略配置
|
||||||
StrategyConfig strategy = new StrategyConfig();
|
StrategyConfig strategy = new StrategyConfig();
|
||||||
// strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
|
// strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
|
||||||
//strategy.setTablePrefix(new String[]{"tlog_", "tsys_"});// 此处可以修改为您的表前缀
|
strategy.setTablePrefix(new String[]{"sys_"});// 此处可以修改为您的表前缀
|
||||||
// 表名生成策略
|
// 表名生成策略
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||||
mpg.setStrategy(strategy);
|
mpg.setStrategy(strategy);
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container calendar-list-container">
|
<div class="app-container calendar-list-container">
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
|
<el-button v-if="${table.name}_add" class="filter-item" style="margin-left: 10px;" @click="handleCreate" type="primary" icon="edit">添加
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit
|
<el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit
|
||||||
highlight-current-row style="width: 100%">
|
highlight-current-row style="width: 100%">
|
||||||
#foreach($field in $table.fields)
|
#foreach($field in $table.fields)
|
||||||
<template scope="scope">
|
<el-table-column align="center" label="${field.comment}">
|
||||||
<el-table-column align="center" label="${field.comment}">
|
<template scope="scope">
|
||||||
<span>{{scope.row.${field.propertyName}}}</span>
|
<span>{{ scope.row.${field.propertyName} }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
#end
|
#end
|
||||||
|
|
||||||
<el-table-column label="操作">
|
<el-table-column label="操作">
|
||||||
<template scope="scope">
|
<template scope="scope">
|
||||||
<el-button size="mini" type="danger"
|
<el-button v-if="${table.name}_upd" size="small" type="success"
|
||||||
|
@click="handleUpdate(scope.row)">编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="${table.name}_del" size="mini" type="danger"
|
||||||
@click="handleDelete(scope.row)">删除
|
@click="handleDelete(scope.row)">删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -27,12 +32,27 @@
|
||||||
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
||||||
</el-pagination>
|
</el-pagination>
|
||||||
</div>
|
</div>
|
||||||
|
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
||||||
|
<el-form :model="form" :rules="rules" ref="form" label-width="100px">
|
||||||
|
#foreach($field in $table.fields)
|
||||||
|
<el-form-item label="${field.comment}" prop="username">
|
||||||
|
<el-input v-model="form.${field.propertyName}" placeholder="${field.comment}"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="cancel('form')">取 消</el-button>
|
||||||
|
<el-button v-if="dialogStatus=='create'" type="primary" @click="create('form')">确 定</el-button>
|
||||||
|
<el-button v-else type="primary" @click="update('form')">修 改</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fetchList, delObj } from '@/api/${table.name}'
|
import { fetchList, addObj, putObj, delObj } from '@/api/${table.name}'
|
||||||
import waves from '@/directive/waves/index.js' // 水波纹指令
|
import waves from '@/directive/waves/index.js' // 水波纹指令
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'table_${table.name}',
|
name: 'table_${table.name}',
|
||||||
|
@ -48,11 +68,41 @@
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 20
|
limit: 20
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
},
|
||||||
|
dialogFormVisible: false,
|
||||||
|
dialogStatus: '',
|
||||||
|
${table.name}_add: false,
|
||||||
|
${table.name}_upd: false,
|
||||||
|
${table.name}_del: false,
|
||||||
|
textMap: {
|
||||||
|
update: '编辑',
|
||||||
|
create: '创建'
|
||||||
|
},
|
||||||
tableKey: 0
|
tableKey: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters([
|
||||||
|
'permissions'
|
||||||
|
])
|
||||||
|
},
|
||||||
|
filters: {
|
||||||
|
statusFilter(status) {
|
||||||
|
const statusMap = {
|
||||||
|
0: '有效',
|
||||||
|
1: '无效'
|
||||||
|
}
|
||||||
|
return statusMap[status]
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList()
|
this.getList()
|
||||||
|
this.${table.name}_add = this.permissions['${table.name}_add']
|
||||||
|
this.${table.name}_upd = this.permissions['${table.name}_upd']
|
||||||
|
this.${table.name}_del = this.permissions['${table.name}_del']
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getList() {
|
getList() {
|
||||||
|
@ -83,7 +133,57 @@
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
handleCreate() {
|
||||||
|
this.dialogStatus = 'create'
|
||||||
|
this.dialogFormVisible = true
|
||||||
|
},
|
||||||
|
create(formName) {
|
||||||
|
const set = this.$refs
|
||||||
|
set[formName].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
addObj(this.form)
|
||||||
|
.then(() => {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
this.getList()
|
||||||
|
this.$notify({
|
||||||
|
title: '成功',
|
||||||
|
message: '创建成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
cancel(formName) {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
const set = this.$refs
|
||||||
|
set[formName].resetFields()
|
||||||
|
},
|
||||||
|
update(formName) {
|
||||||
|
const set = this.$refs
|
||||||
|
set[formName].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
this.form.password = undefined
|
||||||
|
putObj(this.form).then(() => {
|
||||||
|
this.dialogFormVisible = false
|
||||||
|
this.getList()
|
||||||
|
this.$notify({
|
||||||
|
title: '成功',
|
||||||
|
message: '修改成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 2000
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue