mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-13 22:09:00 +08:00
♻️ Refactoring code. pigx-codegen 适配最新V5 UI
This commit is contained in:
1 parent
3c047a59de
commit
e6838a19e1
93 files changed
+3219
-2736
No files matched your search
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/${pathName}" )
|
||||
@Tag(description = "${pathName}", name = "${comments}管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ${className}Controller {
|
||||
|
||||
private final ${className}Service ${classname}Service;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param ${classname} ${comments}
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_view')" )
|
||||
public R get${className}Page(Page page, ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.page(page, Wrappers.query(${classname})));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询${comments}
|
||||
* @param ${pk.lowerAttrName} id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_view')" )
|
||||
public R getById(@PathVariable("${pk.lowerAttrName}" ) ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return R.ok(${classname}Service.getById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${comments}
|
||||
* @param ${classname} ${comments}
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增${comments}", description = "新增${comments}")
|
||||
@SysLog("新增${comments}" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_add')" )
|
||||
public R save(@RequestBody ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.save(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${comments}
|
||||
* @param ${classname} ${comments}
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改${comments}", description = "修改${comments}")
|
||||
@SysLog("修改${comments}" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_edit')" )
|
||||
public R updateById(@RequestBody ${className} ${classname}) {
|
||||
return R.ok(${classname}Service.updateById(${classname}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除${comments}
|
||||
* @param ${pk.lowerAttrName} id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除${comments}", description = "通过id删除${comments}")
|
||||
@SysLog("通过id删除${comments}" )
|
||||
@DeleteMapping("/{${pk.lowerAttrName}}" )
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_del')" )
|
||||
public R removeById(@PathVariable ${pk.attrType} ${pk.lowerAttrName}) {
|
||||
return R.ok(${classname}Service.removeById(${pk.lowerAttrName}));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param ${classname} 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('${moduleName}_${pathName}_export')" )
|
||||
public List<${className}> export(${className} ${classname}) {
|
||||
return ${classname}Service.list(Wrappers.query(${classname}));
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "${comments}")
|
||||
public class ${className} extends Model<${className}> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
#if($column.columnName == $pk.columnName)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
#end
|
||||
#if($column.columnName == 'del_flag')
|
||||
@TableLogic
|
||||
#end
|
||||
@Schema(description="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
|
||||
private $column.attrType $column.lowerAttrName;
|
||||
|
||||
#end
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.mapper;
|
||||
|
||||
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${className}Mapper extends PigxBaseMapper<${className}> {
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~
|
||||
~ Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
~
|
||||
~ Redistribution and use in source and binary forms, with or without
|
||||
~ modification, are permitted provided that the following conditions are met:
|
||||
~
|
||||
~ Redistributions of source code must retain the above copyright notice,
|
||||
~ this list of conditions and the following disclaimer.
|
||||
~ Redistributions in binary form must reproduce the above copyright
|
||||
~ notice, this list of conditions and the following disclaimer in the
|
||||
~ documentation and/or other materials provided with the distribution.
|
||||
~ Neither the name of the pig4cloud.com developer nor the names of its
|
||||
~ contributors may be used to endorse or promote products derived from
|
||||
~ this software without specific prior written permission.
|
||||
~ Author: lengleng (wangiegie@gmail.com)
|
||||
~
|
||||
-->
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="${package}.${moduleName}.mapper.${className}Mapper">
|
||||
|
||||
<resultMap id="${classname}Map" type="${package}.${moduleName}.entity.${className}">
|
||||
#foreach($column in $columns)
|
||||
#if($column.lowerAttrName==$pk.lowerAttrName)
|
||||
<id property="${pk.lowerAttrName}" column="${pk.columnName}"/>
|
||||
#else
|
||||
<result property="${column.lowerAttrName}" column="${column.columnName}"/>
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package ${package}.${moduleName}.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${className}Service extends IService<${className}> {
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
package ${package}.${moduleName}.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import ${package}.${moduleName}.entity.${className};
|
||||
import ${package}.${moduleName}.mapper.${className}Mapper;
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Service
|
||||
public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${className}> implements ${className}Service {
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
import request from '@/router/axios'
|
||||
|
||||
export function fetchList(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
export const tableOption = {
|
||||
"border": true,
|
||||
"index": true,
|
||||
"indexLabel": "序号",
|
||||
"stripe": true,
|
||||
"menuAlign": "center",
|
||||
"align": "center",
|
||||
"searchMenuSpan": 6,
|
||||
"column": [
|
||||
#foreach ($column in $columns)
|
||||
{
|
||||
"type": "input",
|
||||
"label": "$column.comments",
|
||||
"prop": "$column.lowerAttrName",
|
||||
"span": 12
|
||||
}#if($foreach.hasNext),#end
|
||||
#end
|
||||
]
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
<!--
|
||||
- Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
-
|
||||
- Redistribution and use in source and binary forms, with or without
|
||||
- modification, are permitted provided that the following conditions are met:
|
||||
-
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
- this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
- notice, this list of conditions and the following disclaimer in the
|
||||
- documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of the pig4cloud.com developer nor the names of its
|
||||
- contributors may be used to endorse or promote products derived from
|
||||
- this software without specific prior written permission.
|
||||
- Author: lengleng (wangiegie@gmail.com)
|
||||
-->
|
||||
<template>
|
||||
<div class="execution">
|
||||
<basic-container>
|
||||
<avue-crud
|
||||
ref="crud"
|
||||
:page.sync="page"
|
||||
:data="tableData"
|
||||
:permission="permissionList"
|
||||
:table-loading="tableLoading"
|
||||
:option="tableOption"
|
||||
@on-load="getList"
|
||||
@search-change="searchChange"
|
||||
@refresh-change="refreshChange"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
@row-update="handleUpdate"
|
||||
@row-save="handleSave"
|
||||
@row-del="handleDel">
|
||||
<template slot="menuLeft">
|
||||
<el-button
|
||||
v-if="permissions.${moduleName}_${pathName}_export"
|
||||
class="filter-item"
|
||||
plain
|
||||
type="primary"
|
||||
size="small"
|
||||
icon="el-icon-download"
|
||||
@click="exportExcel">导出
|
||||
</el-button>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</basic-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, addObj, putObj, delObj } from '@/api/${pathName}'
|
||||
import { tableOption } from '@/const/crud/${pathName}'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: '${pathName}',
|
||||
data() {
|
||||
return {
|
||||
searchForm: {},
|
||||
tableData: [],
|
||||
page: {
|
||||
total: 0, // 总页数
|
||||
currentPage: 1, // 当前页数
|
||||
pageSize: 20 // 每页显示多少条
|
||||
},
|
||||
tableLoading: false,
|
||||
tableOption: tableOption
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissions']),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_add, false),
|
||||
delBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_del, false),
|
||||
editBtn: this.vaildData(this.permissions.${moduleName}_${pathName}_edit, false)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 列表查询
|
||||
getList(page, params) {
|
||||
this.tableLoading = true
|
||||
fetchList(Object.assign({
|
||||
current: page.currentPage,
|
||||
size: page.pageSize
|
||||
}, params, this.searchForm)).then(response => {
|
||||
this.tableData = response.data.data.records
|
||||
this.page.total = response.data.data.total
|
||||
this.tableLoading = false
|
||||
}).catch(() => {
|
||||
this.tableLoading = false
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
handleDel: function(row, index) {
|
||||
this.$confirm('是否确认删除ID为' + row.$pk.lowerAttrName, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
return delObj(row.$pk.lowerAttrName)
|
||||
}).then(data => {
|
||||
this.$message.success('删除成功')
|
||||
this.getList(this.page)
|
||||
})
|
||||
},
|
||||
// 更新
|
||||
handleUpdate: function(row, index, done, loading) {
|
||||
putObj(row).then(data => {
|
||||
this.$message.success('修改成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
}).catch(() => {
|
||||
loading()
|
||||
})
|
||||
},
|
||||
// 保存
|
||||
handleSave: function(row, done, loading) {
|
||||
addObj(row).then(data => {
|
||||
this.$message.success('添加成功')
|
||||
done()
|
||||
this.getList(this.page)
|
||||
}).catch(() => {
|
||||
loading()
|
||||
})
|
||||
},
|
||||
// 每页条数改变事件
|
||||
sizeChange(pageSize) {
|
||||
this.page.pageSize = pageSize
|
||||
},
|
||||
// 当前页发生改变事件
|
||||
currentChange(current) {
|
||||
this.page.currentPage = current
|
||||
},
|
||||
// 查询事件
|
||||
searchChange(form, done) {
|
||||
this.searchForm = form
|
||||
this.page.currentPage = 1
|
||||
this.getList(this.page, form)
|
||||
done()
|
||||
},
|
||||
// 刷新事件
|
||||
refreshChange() {
|
||||
this.getList(this.page)
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downBlobFile('/${moduleName}/${pathName}/export', this.searchForm, '${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"project": {
|
||||
"packageName": "com.pig4cloud.pigx",
|
||||
"version": "1.0.0",
|
||||
"backendPath": "pigx",
|
||||
"frontendPath": "pigx-ui"
|
||||
},
|
||||
"developer": {
|
||||
"author": "pig",
|
||||
"email": "sw@mail.pigx.vip"
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
import request from '@/router/axios'
|
||||
|
||||
export function fetchList(query) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObj(id) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj) {
|
||||
return request({
|
||||
url: '/${moduleName}/${pathName}',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
<el-form-item label="${column.comments}" prop="${column.lowerAttrName}">
|
||||
<el-input v-model="dataForm.${column.lowerAttrName}" placeholder="${column.comments}"></el-input>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getObj, addObj, putObj } from '@/api/${pathName}'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
canSubmit: false,
|
||||
dataForm: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == $pk.columnName)
|
||||
${column.lowerAttrName}: 0,
|
||||
#else
|
||||
${column.lowerAttrName}: ''#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
dataRule: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
${column.lowerAttrName}: [
|
||||
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init(id) {
|
||||
this.dataForm.${pk.lowerAttrName} = id || 0
|
||||
this.visible = true
|
||||
this.canSubmit = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.${pk.lowerAttrName}) {
|
||||
getObj(this.dataForm.${pk.lowerAttrName}).then(response => {
|
||||
this.dataForm = response.data.data
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit() {
|
||||
#[[this.$refs['dataForm'].validate((valid) => {]]#
|
||||
if (valid) {
|
||||
this.canSubmit = false
|
||||
if (this.dataForm.${pk.lowerAttrName}) {
|
||||
putObj(this.dataForm).then(data => {
|
||||
this.$notify.success('修改成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true
|
||||
})
|
||||
} else {
|
||||
addObj(this.dataForm).then(data => {
|
||||
this.$notify.success('添加成功')
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}).catch(() => {
|
||||
this.canSubmit = true
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,132 +0,0 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<basic-container>
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_add" icon="el-icon-plus" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_export" icon="el-icon-download" type="primary" plain @click="exportExcel()">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="avue-crud">
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading">
|
||||
#foreach($column in $columns)
|
||||
<el-table-column
|
||||
prop="${column.lowerAttrName}"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="${column.comments}">
|
||||
</el-table-column>
|
||||
#end
|
||||
<el-table-column
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_edit" type="text" size="small" icon="el-icon-edit" @click="addOrUpdateHandle(scope.row.${pk.lowerAttrName})">修改</el-button>
|
||||
<el-button v-if="permissions.${moduleName}_${pathName}_del" type="text" size="small" icon="el-icon-delete" @click="deleteHandle(scope.row.${pk.lowerAttrName})">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="avue-crud__pagination">
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
</div>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></table-form>
|
||||
</basic-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, delObj } from '@/api/${pathName}'
|
||||
import TableForm from './${pathName}-form'
|
||||
import { mapGetters } from 'vuex'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
searchForm: {},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
TableForm
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissions'])
|
||||
},
|
||||
created() {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList() {
|
||||
this.dataListLoading = true
|
||||
fetchList(Object.assign({
|
||||
current: this.pageIndex,
|
||||
size: this.pageSize
|
||||
})).then(response => {
|
||||
this.dataList = response.data.data.records
|
||||
this.totalPage = response.data.data.total
|
||||
})
|
||||
this.dataListLoading = false
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle(val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle(val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle(id) {
|
||||
this.addOrUpdateVisible = true
|
||||
#[[this.$nextTick(() => {]]#
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle(id) {
|
||||
this.$confirm('是否确认删除ID为' + id, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
return delObj(id)
|
||||
}).then(data => {
|
||||
this.$message.success('删除成功')
|
||||
this.getDataList()
|
||||
})
|
||||
},
|
||||
// 导出excel
|
||||
exportExcel() {
|
||||
this.downBlobFile('/${moduleName}/${pathName}/export', this.searchForm, '${pathName}.xlsx')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +0,0 @@
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
import response;
|
||||
import log;
|
||||
|
||||
var dbId = new DefaultIdentifierGenerator().nextId(null)
|
||||
return db.${dsName}.table("${tableName}").primary("$pk.columnName", dbId).save(body)
|
||||
@@ -1,21 +0,0 @@
|
||||
import response;
|
||||
|
||||
// 判断是否逻辑删除
|
||||
var logicFlag = false
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == "del_flag")
|
||||
logicFlag = true
|
||||
#end
|
||||
#end
|
||||
|
||||
var result;
|
||||
if(logicFlag){
|
||||
result = db.${dsName}.table("${tableName}").primary("$pk.columnName").update({
|
||||
"$pk.columnName": id,
|
||||
del_flag: 1
|
||||
})
|
||||
}else{
|
||||
result = db.${dsName}.table("${tableName}").where().eq("$pk.columnName", id).delete()
|
||||
}
|
||||
|
||||
return response.json(result)
|
||||
@@ -1,4 +0,0 @@
|
||||
import response;
|
||||
|
||||
// 执行DSL 分页输出结果
|
||||
return response.text("$pk.lowerAttrName")
|
||||
@@ -1,24 +0,0 @@
|
||||
import request;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import response;
|
||||
|
||||
// 基础查询语句
|
||||
var queryDsl = db.${dsName}.table("${tableName}")
|
||||
|
||||
// 判断是否逻辑删除
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == "del_flag")
|
||||
queryDsl = queryDsl.where().eq("del_flag", 0)
|
||||
#end
|
||||
#end
|
||||
|
||||
// 模糊查询
|
||||
if (query != null) {
|
||||
var jsonObj = JSONUtil.parseObj(query)
|
||||
for (key in jsonObj.keySet()) {
|
||||
queryDsl.like(key, "%" + jsonObj.get(key) + "%")
|
||||
}
|
||||
}
|
||||
|
||||
// 执行DSL 分页输出结果
|
||||
return response.json(queryDsl.page())
|
||||
@@ -1,5 +0,0 @@
|
||||
import response;
|
||||
|
||||
var data = db.${dsName}.table("${tableName}").primary("$pk.columnName").update(body)
|
||||
|
||||
return response.json(data)
|
||||
@@ -1,25 +0,0 @@
|
||||
-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-1 , 默认租户 1
|
||||
#set($menuId=${dateTool.getSystemTime()})
|
||||
|
||||
-- 菜单SQL
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `path`, `permission`, `menu_type`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${menuId}, '-1', '/${moduleName}/${pathName}/index', '', '0', 'icon-bangzhushouji', '0', null , '8', null , '${comments}管理', 1);
|
||||
|
||||
-- 按钮父菜单ID
|
||||
set @parentId = @@identity;
|
||||
|
||||
-- 菜单对应按钮SQL
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,1)},${menuId}, '${moduleName}_${pathName}_view', '1', null, '1', '0', null, '0', null, '${comments}查看', 1);
|
||||
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,2)},${menuId}, '${moduleName}_${pathName}_add', '1', null, '1', '0', null, '1', null, '${comments}新增', 1);
|
||||
|
||||
insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,3)},${menuId}, '${moduleName}_${pathName}_edit', '1', null, '1', '0', null, '2', null, '${comments}修改', 1);
|
||||
|
||||
insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,4)},${menuId}, '${moduleName}_${pathName}_del', '1', null, '1', '0', null, '3', null, '${comments}删除', 1);
|
||||
|
||||
insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`, `tenant_id`)
|
||||
values (${math.add($menuId,5)},${menuId}, '${moduleName}_${pathName}_export', '1', null, '1', '0', null, '3', null, '导入导出', 1);
|
||||
@@ -1,18 +0,0 @@
|
||||
// 以下内容请复制到http.api.js中
|
||||
pigx${className}: {
|
||||
// 分页
|
||||
#[[fetchList: (params={}) => vm.$u.get]]#('/${moduleName}/${pathName}/page',params),
|
||||
|
||||
// 新增
|
||||
#[[addObj: (obj={}) => vm.$u.post]]#('/${moduleName}/${pathName}', obj),
|
||||
|
||||
// 修改
|
||||
#[[putObj: (obj={}) => vm.$u.put]]#('/${moduleName}/${pathName}',obj),
|
||||
|
||||
// 删除
|
||||
#[[delObj: (params) => vm.$u.delete]]#('/${moduleName}/${pathName}/'+params.id),
|
||||
|
||||
// 查询
|
||||
#[[getObj: (params) => vm.$u.get]]#('/${moduleName}/${pathName}/' + params.id)
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
<u-form-item label="${column.comments}" prop="${column.lowerAttrName}" label-width="180">
|
||||
<u-input v-model="model.${column.lowerAttrName}" placeholder="${column.comments}"></u-input>
|
||||
</u-form-item>
|
||||
#end
|
||||
#end
|
||||
</u-form>
|
||||
<view class="form-footer">
|
||||
<u-button class="btn" type="primary" @click="submit">提交</u-button>
|
||||
<u-button class="btn" type="default" @click="cancel">关闭</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
type:'',
|
||||
model: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName == $pk.columnName)
|
||||
${column.lowerAttrName}: 0,
|
||||
#else
|
||||
${column.lowerAttrName}: ''#if($velocityCount != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
rules: {
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pk.columnName)
|
||||
${column.lowerAttrName}: [
|
||||
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(params) {
|
||||
if(params&¶ms.id!= "undefined"){
|
||||
this.type = 'edit'
|
||||
#[[this.$u.api]]#.pigx${className}.getObj(params).then(res => {
|
||||
this.model = res.data;
|
||||
});
|
||||
}else{
|
||||
this.type = 'add'
|
||||
this.model = {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
#[[this.$refs.uForm.validate(async valid => {]]#
|
||||
if (valid) {
|
||||
if(this.type==='edit'){
|
||||
await #[[this.$u.api]]#.pigx${className}.putObj(this.model)
|
||||
}else{
|
||||
await #[[this.$u.api]]#.pigx${className}.addObj(this.model)
|
||||
}
|
||||
setTimeout(() => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
ccontent: this.type === 'edit' ? '修改成功' : '添加成功',
|
||||
showCancel: false,
|
||||
success: function() {
|
||||
uni.setStorageSync('refreshList', true);
|
||||
uni.navigateTo({
|
||||
url: '/pages/${moduleName}/${pathName}/${pathName}-index'
|
||||
})
|
||||
}
|
||||
})
|
||||
}, 200)
|
||||
} else {
|
||||
#[[this.$u.toast('您填写的信息有误,请根据提示修正。')]]#
|
||||
}
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
|
||||
<u-cell-group class="list" :border="false">
|
||||
<u-card :title="item.${pk.lowerAttrName}" v-for="(item, index) in list" :key="item.${pk.lowerAttrName}"
|
||||
:index="item.${pk.lowerAttrName}" @click="cardClick(item.${pk.lowerAttrName})">
|
||||
<view class="" slot="body">
|
||||
#foreach($column in $columns)
|
||||
<view class="row-list">
|
||||
<span class="span-lable">${column.comments}: </span>{{item.${column.lowerAttrName}}}
|
||||
</view>
|
||||
#end
|
||||
</view>
|
||||
<view class="card-foot" slot="foot">
|
||||
<u-button type="primary" size="medium" @click="cardClick(item.${pk.lowerAttrName})">编辑</u-button>
|
||||
<u-button size="medium" @click="del(item.${pk.lowerAttrName})">删除</u-button>
|
||||
</view>
|
||||
</u-card>
|
||||
</u-cell-group>
|
||||
<view class="loadmore" @click="loadMore">
|
||||
<u-loadmore :status="loadStatus"></u-loadmore>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="btn-plus" @click="cardClick()">
|
||||
<u-icon name="plus-circle-fill" size="90" color="#3d87ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keywords: '',
|
||||
query: {
|
||||
current: 1,
|
||||
size: 20
|
||||
},
|
||||
list: [],
|
||||
count: 0,
|
||||
loadStatus: 'loadmore',
|
||||
options: [{
|
||||
text: '删除',
|
||||
style: {
|
||||
background: '#dd524d'
|
||||
}
|
||||
}]
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.loadList();
|
||||
},
|
||||
onShow() {
|
||||
if (uni.getStorageSync('refreshList') === true) {
|
||||
uni.removeStorageSync('refreshList');
|
||||
this.search('');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cardClick(id) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/${moduleName}/${pathName}/${pathName}-form?id='+id
|
||||
})
|
||||
},
|
||||
loadMore() {
|
||||
this.loadStatus = "loading";
|
||||
setTimeout(() => {
|
||||
this.query.current += 1;
|
||||
this.loadList();
|
||||
}, 100);
|
||||
},
|
||||
loadList() {
|
||||
#[[this.$u.api]]#.pigx${className}.fetchList(this.query).then(res => {
|
||||
if (!res.data.records || res.data.records.length == 0) {
|
||||
this.loadStatus = "nomore";
|
||||
return;
|
||||
}
|
||||
this.list = this.list.concat(res.data.records);
|
||||
this.total = res.data.total;
|
||||
this.query.current = res.data.current;
|
||||
this.query.size = res.data.size;
|
||||
this.loadStatus = "loadmore";
|
||||
});
|
||||
},
|
||||
del(id) {
|
||||
let self = this;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确认要删除该数据吗?',
|
||||
showCancel: true,
|
||||
success: function(res2) {
|
||||
if (res2.confirm) {
|
||||
#[[self.$u.api]]#.pigx${className}.delObj({id:id}).then(res => {
|
||||
#[[self.$u.toast('删除成功');]]#
|
||||
self.query.current = 1
|
||||
self.list = []
|
||||
self.loadList()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,17 +0,0 @@
|
||||
// 以下内容请复制到pages.json
|
||||
"pages": [
|
||||
|
||||
/**${comments}**/
|
||||
{
|
||||
"path": "pages/${moduleName}/${pathName}/${pathName}-index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "${comments}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/${moduleName}/${pathName}/${pathName}-form",
|
||||
"style": {
|
||||
"navigationBarTitleText": "${comments}详情"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user