JeecgBoot 2.3 里程碑版本发布,支持微服务和单体自由切换、提供新行编辑表格JVXETable

This commit is contained in:
zhangdaiscott
2020-09-13 18:23:23 +08:00
parent c5f055d004
commit 024272eb7c
533 changed files with 187550 additions and 36942 deletions

View File

@ -187,10 +187,10 @@ jeecg :
accessKey: ??
secretKey: ??
bucketName: jeecgos
staticDomain: ??
staticDomain: https://static.jeecg.com
# ElasticSearch 6设置
elasticsearch:
cluster-name: jeecg-ES
cluster-name: docker-cluster
cluster-nodes: 127.0.0.1:9200
check-enabled: false
# 表单设计器配置
@ -200,7 +200,7 @@ jeecg :
# 文件、图片上传方式可选项qiniu七牛云、system跟随系统配置
upload-type: system
# 在线预览文件服务器地址配置
file-view-domain: 127.0.0.1:8012
file-view-domain: http://fileview.jeecg.com
# minio文件上传
minio:
minio_url: http://minio.jeecg.com

View File

@ -169,7 +169,7 @@ mybatis-plus:
#jeecg专用配置
jeecg :
# 本地local\Miniominio\阿里云alioss
uploadType: local
uploadType: alioss
path :
#文件上传根目录 设置
upload: /opt/jeecg-boot/upload

View File

@ -22,7 +22,7 @@ justauth:
agent-id: 1000002
DINGTALK:
client-id: dingoa33vjqxrbyidnmgwo
client-secret:
client-secret: ??
redirect-uri: http://sso.test.com:8080/jeecg-boot/thirdLogin/dingtalk/callback
cache:
type: default

View File

@ -9,6 +9,6 @@ ${AnsiColor.BRIGHT_BLUE}
${AnsiColor.BRIGHT_GREEN}
Jeecg Boot Version: 2.2.1
Jeecg Boot Version: 2.3
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
${AnsiColor.BLACK}

View File

@ -0,0 +1,14 @@
server:
port: 7001
spring:
profiles:
active: dev
application:
name: jeecg-system
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
feign:
sentinel:
enabled: true

View File

@ -0,0 +1,8 @@
DELETE FROM demo;
INSERT INTO demo (id, name, age, email,sex,birthday,content) VALUES
(1, 'Jone', 18, 'test1@baomidou.com','1','2017-12-28','很好'),
(2, 'Jack', 20, 'test2@baomidou.com','2','2018-02-28','努力型'),
(3, 'Tom', 28, 'test3@baomidou.com','1','2018-11-28','吃苦'),
(4, 'Sandy', 21, 'test4@baomidou.com','1','2018-07-28','聪明'),
(5, 'Billie', 24, 'test5@baomidou.com','2','2018-12-11','出色');

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS demo;
CREATE TABLE demo (
id BIGINT(20) NOT NULL auto_increment COMMENT '主键ID',
name varchar(30) default NULL COMMENT '姓名',
sex varchar(2) default NULL,
age int(11) default NULL COMMENT '年龄',
birthday date default NULL COMMENT '生日',
email varchar(50) default NULL COMMENT '邮箱',
content varchar(1000) default NULL COMMENT '个人简介',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -75,7 +75,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -92,7 +92,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
${entityName?uncap_first}.setBpmStatus("1");
</#if>
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -106,7 +106,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -120,7 +120,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.removeById(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -134,7 +134,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -151,7 +151,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
/**

View File

@ -345,6 +345,9 @@
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {

View File

@ -89,7 +89,7 @@ public class ${entityName}Controller {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -108,7 +108,7 @@ public class ${entityName}Controller {
${entityName?uncap_first}.setBpmStatus("1");
</#if>
${entityName?uncap_first}Service.saveMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -128,7 +128,7 @@ public class ${entityName}Controller {
return Result.error("未找到对应数据");
}
${entityName?uncap_first}Service.updateMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -142,7 +142,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -156,7 +156,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -173,7 +173,7 @@ public class ${entityName}Controller {
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
@ -189,7 +189,7 @@ public class ${entityName}Controller {
@GetMapping(value = "/query${sub.entityName}ByMainId")
public Result<?> query${sub.entityName}ListByMainId(@RequestParam(name="id",required=true) String id) {
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(id);
return Result.ok(${sub.entityName?uncap_first}List);
return Result.OK(${sub.entityName?uncap_first}List);
}
</#list>
@ -262,7 +262,7 @@ public class ${entityName}Controller {
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.ok("文件导入成功!数据行数:" + list.size());
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -274,7 +274,7 @@ public class ${entityName}Controller {
}
}
}
return Result.ok("文件导入失败!");
return Result.OK("文件导入失败!");
}
}

View File

@ -328,6 +328,9 @@
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {
@ -368,6 +371,7 @@
dataIndex: 'action',
align:"center",
fixed:"right",
width:147,
scopedSlots: { customRender: 'action' },
}
],

View File

@ -72,22 +72,31 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
String parentId = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
if (oConvertUtils.isEmpty(parentId)) {
parentId = "0";
}
${entityName?uncap_first}.set${pidFieldName?cap_first}(null);
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
// 使用 eq 防止模糊查询
queryWrapper.eq("${Format.humpToUnderline(pidFieldName)}", parentId);
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
String hasQuery = req.getParameter("hasQuery");
if(hasQuery != null && "true".equals(hasQuery)){
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
List<${entityName}> list = ${entityName?uncap_first}Service.queryTreeListNoPage(queryWrapper);
IPage<${entityName}> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
}else{
String parentId = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
if (oConvertUtils.isEmpty(parentId)) {
parentId = "0";
}
${entityName?uncap_first}.set${pidFieldName?cap_first}(null);
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
// 使用 eq 防止模糊查询
queryWrapper.eq("${Format.humpToUnderline(pidFieldName)}", parentId);
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.OK(pageList);
}
}
/**
* 获取子数据
* @param ${entityName}
* @param ${entityName?uncap_first}
* @param req
* @return
*/
@ -99,7 +108,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
List<${entityName}> list = ${entityName?uncap_first}Service.list(queryWrapper);
IPage<${entityName}> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -120,7 +129,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
List<${entityName}> list = ${entityName?uncap_first}Service.list(queryWrapper);
IPage<${entityName}> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.ok(pageList);
return Result.OK(pageList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("批量查询子节点失败:" + e.getMessage());
@ -138,7 +147,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.add${entityName}(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -152,7 +161,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.update${entityName}(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -166,7 +175,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delete${entityName}(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -180,7 +189,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -197,7 +206,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
/**

View File

@ -3,6 +3,8 @@ package ${bussiPackage}.${entityPackage}.service;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.exception.JeecgBootException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
/**
* @Description: ${tableVo.ftlDescription}
@ -30,4 +32,7 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**删除节点*/
void delete${entityName}(String id) throws JeecgBootException;
/**查询所有数据,无分页*/
List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper);
}

View File

@ -7,6 +7,10 @@ import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
<#assign pidFieldName = "">
@ -65,16 +69,63 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete${entityName}(String id) throws JeecgBootException {
${entityName} ${entityName?uncap_first} = this.getById(id);
if(${entityName?uncap_first}==null) {
throw new JeecgBootException("未找到对应实体");
}
updateOldParentNode(${entityName?uncap_first}.get${pidFieldName?cap_first}());
baseMapper.deleteById(id);
//查询选中节点下所有子节点一并删除
id = this.queryTreeChildIds(id);
if(id.indexOf(",")>0) {
StringBuffer sb = new StringBuffer();
String[] idArr = id.split(",");
for (String idVal : idArr) {
if(idVal != null){
${entityName} ${entityName?uncap_first} = this.getById(idVal);
String pidVal = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
//查询此节点上一级是否还有其他子节点
List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal).notIn("id",Arrays.asList(idArr)));
if((dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(pidVal)
&& !sb.toString().contains(pidVal)){
//如果当前节点原本有子节点 现在木有了,更新状态
sb.append(pidVal).append(",");
}
}
}
//批量删除节点
baseMapper.deleteBatchIds(Arrays.asList(idArr));
//修改已无子节点的标识
String[] pidArr = sb.toString().split(",");
for(String pid : pidArr){
this.updateOldParentNode(pid);
}
}else{
${entityName} ${entityName?uncap_first} = this.getById(id);
if(${entityName?uncap_first}==null) {
throw new JeecgBootException("未找到对应实体");
}
updateOldParentNode(${entityName?uncap_first}.get${pidFieldName?cap_first}());
baseMapper.deleteById(id);
}
}
@Override
public List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper) {
List<${entityName}> dataList = baseMapper.selectList(queryWrapper);
List<${entityName}> mapList = new ArrayList<>();
for(${entityName} data : dataList){
String pidVal = data.get${pidFieldName?cap_first}();
//递归查询子节点的根节点
if(pidVal != null && !"0".equals(pidVal)){
${entityName} rootVal = this.getTreeRoot(pidVal);
if(rootVal != null && !mapList.contains(rootVal)){
mapList.add(rootVal);
}
}else{
if(!mapList.contains(data)){
mapList.add(data);
}
}
}
return mapList;
}
/**
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值
@ -89,4 +140,60 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
}
}
/**
* 递归查询节点的根节点
* @param pidVal
* @return
*/
private ${entityName} getTreeRoot(String pidVal){
${entityName} data = baseMapper.selectById(pidVal);
if(data != null && !"0".equals(data.get${pidFieldName?cap_first}())){
return this.getTreeRoot(data.get${pidFieldName?cap_first}());
}else{
return data;
}
}
/**
* 根据id查询所有子节点id
* @param ids
* @return
*/
private String queryTreeChildIds(String ids) {
//获取id数组
String[] idArr = ids.split(",");
StringBuffer sb = new StringBuffer();
for (String pidVal : idArr) {
if(pidVal != null){
if(!sb.toString().contains(pidVal)){
if(sb.toString().length() > 0){
sb.append(",");
}
sb.append(pidVal);
this.getTreeChildIds(pidVal,sb);
}
}
}
return sb.toString();
}
/**
* 递归查询所有子节点
* @param pidVal
* @param sb
* @return
*/
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
List<${entityName}> dataList = baseMapper.selectList(new QueryWrapper<${entityName}>().eq("${tableVo.extendParams.pidField}", pidVal));
if(dataList != null && dataList.size()>0){
for(${entityName} tree : dataList) {
if(!sb.toString().contains(tree.getId())){
sb.append(",").append(tree.getId());
}
this.getTreeChildIds(tree.getId(),sb);
}
}
return sb;
}
}

View File

@ -217,7 +217,7 @@
<a @click="handleAddChild(record)">添加下级</a>
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record)">
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
@ -332,6 +332,9 @@
{
title:'${po.filedComment}',
align:"left",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {
@ -356,6 +359,7 @@
title: '操作',
dataIndex: 'action',
align:"center",
width:147,
scopedSlots: { customRender: 'action' },
}
],
@ -424,7 +428,7 @@
let records = res.result.records
const listMap = new Map();
for (let item of records) {
let pid = item.pid;
let pid = item[this.pidField];
if (this.expandedRowKeys.join(',').includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
@ -436,12 +440,14 @@
}
let childrenMap = listMap;
let fn = (list) => {
list.forEach(data => {
if (this.expandedRowKeys.includes(data.id)) {
data.children = this.getDataByResult(childrenMap.get(data.id))
fn(data.children)
}
})
if(list) {
list.forEach(data => {
if (this.expandedRowKeys.includes(data.id)) {
data.children = this.getDataByResult(childrenMap.get(data.id))
fn(data.children)
}
})
}
}
fn(dataList)
}
@ -463,6 +469,11 @@
}else{
param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
}
if(JSON.stringify(this.queryParam) === "{}" || arg){
param.hasQuery = 'false'
}else{
param.hasQuery = 'true'
}
param.field = this.getQueryField();
param.pageNo = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
@ -491,7 +502,7 @@
if (expanded) {
this.expandedRowKeys.push(record.id)
if (record.children.length>0 && record.children[0].isLoading === true) {
let params = this.getQueryParams();//查询条件
let params = this.getQueryParams(1);//查询条件
params[this.pidField] = record.id
getAction(this.url.childList,params).then((res)=>{
if(res.success){
@ -520,20 +531,40 @@
obj[this.pidField] = record['id']
this.$refs.modalForm.add(obj);
},
handleDeleteNode(record) {
handleDeleteNode(id) {
if(!this.url.delete){
this.$message.error("请设置url.delete属性!")
return
}
var that = this;
deleteAction(that.url.delete, {id: record.id}).then((res) => {
deleteAction(that.url.delete, {id: id}).then((res) => {
if (res.success) {
that.loadData(1)
} else {
that.$message.warning(res.message);
}
});
}
},
batchDel(){
if(this.selectedRowKeys.length<=0){
this.$message.warning('请选择一条记录!');
return false;
}else{
let ids = "";
let that = this;
that.selectedRowKeys.forEach(function(val) {
ids+=val+",";
});
that.$confirm({
title:"确认删除",
content:"是否删除选中数据?",
onOk: function(){
that.handleDeleteNode(ids)
that.onClearSelected();
}
});
}
},
}
}

View File

@ -80,7 +80,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -93,7 +93,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -106,7 +106,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -119,7 +119,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -132,7 +132,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -171,7 +171,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
QueryWrapper<${sub.entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${sub.entityName?uncap_first}, req.getParameterMap());
Page<${sub.entityName}> page = new Page<${sub.entityName}>(pageNo, pageSize);
IPage<${sub.entityName}> pageList = ${sub.entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -184,7 +184,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PostMapping(value = "/add${sub.entityName}")
public Result<?> add${sub.entityName}(@RequestBody ${sub.entityName} ${sub.entityName?uncap_first}) {
${sub.entityName?uncap_first}Service.save(${sub.entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -197,7 +197,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit${sub.entityName}")
public Result<?> edit${sub.entityName}(@RequestBody ${sub.entityName} ${sub.entityName?uncap_first}) {
${sub.entityName?uncap_first}Service.updateById(${sub.entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -210,7 +210,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete${sub.entityName}")
public Result<?> delete${sub.entityName}(@RequestParam(name="id",required=true) String id) {
${sub.entityName?uncap_first}Service.removeById(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -223,7 +223,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch${sub.entityName}")
public Result<?> deleteBatch${sub.entityName}(@RequestParam(name="ids",required=true) String ids) {
this.${sub.entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -282,7 +282,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
long start = System.currentTimeMillis();
${sub.entityName?uncap_first}Service.saveBatch(list);
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
return Result.ok("文件导入成功!数据行数:" + list.size());
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());

View File

@ -314,6 +314,9 @@
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {

View File

@ -134,6 +134,9 @@
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {

View File

@ -83,7 +83,7 @@ public class ${entityName}Controller {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -99,7 +99,7 @@ public class ${entityName}Controller {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.saveMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -119,7 +119,7 @@ public class ${entityName}Controller {
return Result.error("未找到对应数据");
}
${entityName?uncap_first}Service.updateMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -133,7 +133,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -147,7 +147,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -164,7 +164,7 @@ public class ${entityName}Controller {
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
@ -184,7 +184,7 @@ public class ${entityName}Controller {
IPage <${sub.entityName}> page = new Page<>();
page.setRecords(${sub.entityName?uncap_first}List);
page.setTotal(${sub.entityName?uncap_first}List.size());
return Result.ok(page);
return Result.OK(page);
}
</#list>
@ -257,7 +257,7 @@ public class ${entityName}Controller {
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.ok("文件导入成功!数据行数:" + list.size());
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -269,7 +269,7 @@ public class ${entityName}Controller {
}
}
}
return Result.ok("文件导入失败!");
return Result.OK("文件导入失败!");
}
}

View File

@ -290,6 +290,9 @@
{
title: '${po.filedComment}',
align: 'center',
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType == 'date'>
dataIndex: '${po.fieldName}',
<#elseif po.fieldDbType=='Blob'>

View File

@ -0,0 +1,280 @@
package ${bussiPackage}.${entityPackage}.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import ${bussiPackage}.${entityPackage}.vo.${entityName}Page;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.service.I${sub.entityName}Service;
</#list>
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
<#assign bpm_flag=false>
<#list originalColumns as po>
<#if po.fieldDbName=='bpm_status'>
<#assign bpm_flag=true>
</#if>
</#list>
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Api(tags="${tableVo.ftlDescription}")
@RestController
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
@Slf4j
public class ${entityName}Controller {
@Autowired
private I${entityName}Service ${entityName?uncap_first}Service;
<#list subTables as sub>
@Autowired
private I${sub.entityName}Service ${sub.entityName?uncap_first}Service;
</#list>
/**
* 分页列表查询
*
* @param ${entityName?uncap_first}
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")
@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param ${entityName?uncap_first}Page
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-添加")
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
<#if bpm_flag>
${entityName?uncap_first}.setBpmStatus("1");
</#if>
${entityName?uncap_first}Service.saveMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param ${entityName?uncap_first}Page
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName} ${entityName?uncap_first}Entity = ${entityName?uncap_first}Service.getById(${entityName?uncap_first}.getId());
if(${entityName?uncap_first}Entity==null) {
return Result.error("未找到对应数据");
}
${entityName?uncap_first}Service.updateMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-通过id删除")
@ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-批量删除")
@ApiOperation(value="${tableVo.ftlDescription}-批量删除", notes="${tableVo.ftlDescription}-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-通过id查询")
@ApiOperation(value="${tableVo.ftlDescription}-通过id查询", notes="${tableVo.ftlDescription}-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.OK(${entityName?uncap_first});
}
<#list subTables as sub>
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "${sub.ftlDescription}通过主表ID查询")
@ApiOperation(value="${sub.ftlDescription}主表ID查询", notes="${sub.ftlDescription}-通主表ID查询")
@GetMapping(value = "/query${sub.entityName}ByMainId")
public Result<?> query${sub.entityName}ListByMainId(@RequestParam(name="id",required=true) String id) {
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(id);
return Result.OK(${sub.entityName?uncap_first}List);
}
</#list>
/**
* 导出excel
*
* @param request
* @param ${entityName?uncap_first}
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, ${entityName} ${entityName?uncap_first}) {
// Step.1 组装查询条件查询数据
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//Step.2 获取导出数据
List<${entityName}> queryList = ${entityName?uncap_first}Service.list(queryWrapper);
// 过滤选中数据
String selections = request.getParameter("selections");
List<${entityName}> ${entityName?uncap_first}List = new ArrayList<${entityName}>();
if(oConvertUtils.isEmpty(selections)) {
${entityName?uncap_first}List = queryList;
}else {
List<String> selectionList = Arrays.asList(selections.split(","));
${entityName?uncap_first}List = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
}
// Step.3 组装pageList
List<${entityName}Page> pageList = new ArrayList<${entityName}Page>();
for (${entityName} main : ${entityName?uncap_first}List) {
${entityName}Page vo = new ${entityName}Page();
BeanUtils.copyProperties(main, vo);
<#list subTables as sub>
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(main.getId());
vo.set${sub.entityName}List(${sub.entityName?uncap_first}List);
</#list>
pageList.add(vo);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "${tableVo.ftlDescription}列表");
mv.addObject(NormalExcelConstants.CLASS, ${entityName}Page.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("${tableVo.ftlDescription}数据", "导出人:"+sysUser.getRealname(), "${tableVo.ftlDescription}"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<${entityName}Page> list = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}Page.class, params);
for (${entityName}Page page : list) {
${entityName} po = new ${entityName}();
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.OK("文件导入失败!");
}
}

View File

@ -0,0 +1,103 @@
package ${bussiPackage}.${entityPackage}.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
@Data
@TableName("${tableName}")
public class ${entityName} implements Serializable {
private static final long serialVersionUID = 1L;
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
<#if list_field_dictCode?length gt 1>
@Dict(${list_field_dictCode?substring(2)})
</#if>
</#if>
<#if po.fieldDbType=='Blob'>
private transient java.lang.String ${po.fieldName}String;
private byte[] ${po.fieldName};
public byte[] get${po.fieldName?cap_first}(){
if(${po.fieldName}String==null){
return null;
}
try {
return ${po.fieldName}String.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public String get${po.fieldName?cap_first}String(){
if(${po.fieldName}==null || ${po.fieldName}.length==0){
return "";
}
try {
return new String(${po.fieldName},"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
<#else>
@ApiModelProperty(value = "${po.filedComment}")
private ${po.fieldType} ${po.fieldName};
</#if>
</#list>
}

View File

@ -0,0 +1,72 @@
<#list subTables as subTab>
#segment#${subTab.entityName}.java
package ${bussiPackage}.${entityPackage}.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
@Data
@TableName("${subTab.tableName}")
public class ${subTab.entityName} implements Serializable {
private static final long serialVersionUID = 1L;
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list subTab.originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#elseif !subTab.foreignKeys?seq_contains(po.fieldName?cap_first)>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
}
</#list>

View File

@ -0,0 +1,17 @@
package ${bussiPackage}.${entityPackage}.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
}

View File

@ -0,0 +1,22 @@
<#list subTables as subTab>
#segment#${subTab.entityName}Mapper.java
package ${bussiPackage}.${entityPackage}.mapper;
import java.util.List;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
public boolean deleteByMainId(@Param("mainId") String mainId);
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}
</#list>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper">
</mapper>

View File

@ -0,0 +1,26 @@
<#list subTables as subTab>
<#assign originalForeignKeys = subTab.originalForeignKeys>
#segment#${subTab.entityName}Mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${bussiPackage}.${entityPackage}.mapper.${subTab.entityName}Mapper">
<delete id="deleteByMainId" parameterType="java.lang.String">
DELETE
FROM ${subTab.tableName}
WHERE
<#list originalForeignKeys as key>
${key} = ${r'#'}{mainId} <#rt/>
</#list>
</delete>
<select id="selectByMainId" parameterType="java.lang.String" resultType="${bussiPackage}.${entityPackage}.entity.${subTab.entityName}">
SELECT *
FROM ${subTab.tableName}
WHERE
<#list originalForeignKeys as key>
${key} = ${r'#'}{mainId} <#rt/>
</#list>
</select>
</mapper>
</#list>

View File

@ -0,0 +1,42 @@
package ${bussiPackage}.${entityPackage}.service;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface I${entityName}Service extends IService<${entityName}> {
/**
* 添加一对多
*
*/
public void saveMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) ;
/**
* 修改一对多
*
*/
public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>);
/**
* 删除一对多
*/
public void delMain (String id);
/**
* 批量删除一对多
*/
public void delBatchMain (Collection<? extends Serializable> idList);
}

View File

@ -0,0 +1,19 @@
<#list subTables as subTab>
#segment#I${subTab.entityName}Service.java
package ${bussiPackage}.${entityPackage}.service;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -0,0 +1,105 @@
package ${bussiPackage}.${entityPackage}.service.impl;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
</#list>
import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Service
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
@Autowired
private ${entityName}Mapper ${entityName?uncap_first}Mapper;
<#list subTables as sub>
@Autowired
private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
</#list>
@Override
@Transactional
public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
<#list subTables as sub>
if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
<#list sub.foreignKeys as key>
//外键设置
<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
<#else>
entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
</#if>
</#list>
${sub.entityName?uncap_first}Mapper.insert(entity);
}
}
</#list>
}
@Override
@Transactional
public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
//1.先删除子表数据
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
</#list>
//2.子表数据重新插入
<#list subTables as sub>
if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
<#list sub.foreignKeys as key>
//外键设置
<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
<#else>
entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
</#if>
</#list>
${sub.entityName?uncap_first}Mapper.insert(entity);
}
}
</#list>
}
@Override
@Transactional
public void delMain(String id) {
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
</#list>
${entityName?uncap_first}Mapper.deleteById(id);
}
@Override
@Transactional
public void delBatchMain(Collection<? extends Serializable> idList) {
for(Serializable id:idList) {
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
</#list>
${entityName?uncap_first}Mapper.deleteById(id);
}
}
}

View File

@ -0,0 +1,30 @@
<#list subTables as subTab>
#segment#${subTab.entityName}ServiceImpl.java
package ${bussiPackage}.${entityPackage}.service.impl;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import ${bussiPackage}.${entityPackage}.mapper.${subTab.entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${subTab.entityName}Service;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Service
public class ${subTab.entityName}ServiceImpl extends ServiceImpl<${subTab.entityName}Mapper, ${subTab.entityName}> implements I${subTab.entityName}Service {
@Autowired
private ${subTab.entityName}Mapper ${subTab.entityName?uncap_first}Mapper;
@Override
public List<${subTab.entityName}> selectByMainId(String mainId) {
return ${subTab.entityName?uncap_first}Mapper.selectByMainId(mainId);
}
}
</#list>

View File

@ -0,0 +1,80 @@
package ${bussiPackage}.${entityPackage}.vo;
import java.util.List;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Data
@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
public class ${entityName}Page {
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
<#if list_field_dictCode?length gt 1>
@Dict(${list_field_dictCode?substring(2)})
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
<#list subTables as sub>
@ExcelCollection(name="${sub.ftlDescription}")
@ApiModelProperty(value = "${sub.ftlDescription}")
private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
</#list>
}

View File

@ -0,0 +1,454 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<#assign query_field_no=0>
<#assign query_field_select=false>
<#assign query_field_date=false>
<#assign list_need_dict=false>
<#assign list_need_category=false>
<#assign query_field_pca=false>
<#assign list_need_pca=false>
<#assign query_flag=false>
<#assign query_inp=false>
<#assign query_popup=false>
<#assign query_sel_user=false>
<#assign query_sel_dep=false>
<#assign query_sel_multi=false>
<#assign query_sel_cat=false>
<#assign query_sel_search=false>
<#assign bpm_flag=false>
<#-- 开始循环 -->
<#list columns as po>
<#if po.fieldDbName=='bpm_status'>
<#assign bpm_flag=true>
</#if>
<#if po.isQuery=='Y'>
<#assign query_flag=true>
<#if query_field_no==2>
<template v-if="toggleSearchStatus">
</#if>
<#assign query_field_dictCode="">
<#if po.dictTable?default("")?trim?length gt 1>
<#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign query_field_dictCode="${po.dictField}">
</#if>
<#if po.queryMode=='single'>
<#if query_field_no gt 1> </#if><a-col :xl="6" :lg="7" :md="8" :sm="24">
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
<#if po.classType=='sel_search'>
<#assign query_sel_search=true>
<#if query_field_no gt 1> </#if><j-search-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dict="${po.dictTable},${po.dictText},${po.dictField}"/>
<#elseif po.classType=='sel_user'>
<#assign query_sel_user=true>
<#if query_field_no gt 1> </#if><j-select-user-by-dep placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='sel_depart'>
<#assign query_sel_dep=true>
<#if query_field_no gt 1> </#if><j-select-depart placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='list_multi'>
<#assign query_sel_multi=true>
<#if query_field_no gt 1> </#if><j-multi-select-tag placeholder="请选择${po.filedComment}" dictCode="${query_field_dictCode?default("")}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='cat_tree'>
<#assign query_sel_cat=true>
<#if query_field_no gt 1> </#if><j-category-select placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" pcode="${po.dictField?default("")}"/>
<#elseif po.classType=='date'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"></j-date>
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"></j-date>
<#elseif po.classType=='pca'>
<#assign query_field_pca=true>
<#if query_field_no gt 1> </#if><j-area-linkage type="cascader" v-model="queryParam.${po.fieldName}" placeholder="请选择省市区"/>
<#elseif po.classType=='popup'>
<#if query_field_no gt 1> </#if><j-popup placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" code="${po.dictTable}" org-fields="${po.dictField}" dest-fields="${po.dictText}" :field="getPopupField('${po.dictText}')"/>
<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
<#assign query_field_select=true>
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
<#if po.dictTable?default("")?trim?length gt 1>
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dictCode="${po.dictTable},${po.dictText},${po.dictField}"/>
<#elseif po.dictField?default("")?trim?length gt 1>
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dictCode="${po.dictField}"/>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model="queryParam.${po.fieldName}"></a-input>
</#if>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model="queryParam.${po.fieldName}"></a-input>
</#if>
<#if query_field_no gt 1> </#if></a-form-item>
<#if query_field_no gt 1> </#if></a-col>
<#else>
<#if query_field_no gt 1> </#if><a-col :xl="10" :lg="11" :md="12" :sm="24">
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
<#if po.classType=='date'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></j-date>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></j-date>
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></j-date>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></j-date>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最小值" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></a-input>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最大值" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></a-input>
</#if>
<#if query_field_no gt 1> </#if></a-form-item>
<#if query_field_no gt 1> </#if></a-col>
</#if>
<#assign query_field_no=query_field_no+1>
</#if>
<#if !list_need_dict && po.fieldShowType!='popup' && po.dictField?default("")?trim?length gt 1>
<#assign list_need_dict=true>
</#if>
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
<#assign list_need_category=true>
</#if>
<#if po.classType=='pca'>
<#assign list_need_pca=true>
</#if>
</#list>
<#-- 结束循环 -->
<#t>
<#if query_field_no gt 2>
</template>
</#if>
<#if query_flag>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<a @click="handleToggleSearch" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('${tableVo.ftlDescription}')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:scroll="{x:true}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<template slot="htmlSlot" slot-scope="text">
<div v-html="text"></div>
</template>
<template slot="imgSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
<img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
type="primary"
icon="download"
size="small"
@click="downloadFile(text)">
下载
</a-button>
</template>
<#if list_need_pca>
<template slot="pcaSlot" slot-scope="text">
<div>{{ getPcaText(text) }}</div>
</template>
</#if>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a-dropdown>
<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
<a-menu slot="overlay">
<a-menu-item>
<a @click="handleDetail(record)">详情</a>
</a-menu-item>
<#if bpm_flag>
<a-menu-item v-if="record.bpmStatus === '1'">
<a @click="startProcess(record)">发起流程</a>
</a-menu-item>
</#if>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<${Format.humpToShortbar(entityName)}-modal ref="modalForm" @ok="modalFormOk"/>
</a-card>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ${entityName}Modal from './modules/${entityName}Modal'
<#if query_field_select>
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
</#if>
<#if query_field_date>
import JDate from '@/components/jeecg/JDate.vue'
</#if>
<#if list_need_category>
import { loadCategoryData } from '@/api/api'
</#if>
<#if list_need_dict>
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#if>
<#if query_field_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if list_need_pca>
import Area from '@/components/_util/Area'
</#if>
<#if query_inp>
import JInput from '@comp/jeecg/JInput'
</#if>
<#if query_sel_user>
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if query_sel_dep>
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if query_sel_multi>
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
</#if>
<#if query_sel_cat>
import JCategorySelect from '@comp/jeecg/JCategorySelect'
</#if>
<#if query_sel_search>
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
import '@/assets/less/TableExpand.less'
<#if bpm_flag>
import { postAction } from '@/api/manage'
</#if>
export default {
name: "${entityName}List",
mixins:[JeecgListMixin],
components: {
<#if query_field_select>
JDictSelectTag,
</#if>
<#if query_field_date>
JDate,
</#if>
<#if query_field_pca>
JAreaLinkage,
</#if>
<#if query_inp>
JInput,
</#if>
<#if query_sel_user>
JSelectUserByDep,
</#if>
<#if query_sel_dep>
JSelectDepart,
</#if>
<#if query_sel_multi>
JMultiSelectTag,
</#if>
<#if query_sel_cat>
JCategorySelect,
</#if>
<#if query_sel_search>
JSearchSelectTag,
</#if>
${entityName}Modal
},
data () {
return {
description: '${tableVo.ftlDescription}管理页面',
// 表头
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:60,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
<#assign showColNum=0>
<#list columns as po>
<#if po.isShowList =='Y'>
<#assign showColNum=showColNum+1>
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {
return !text?"":(text.length>10?text.substr(0,10):text)
}
<#elseif po.fieldDbType=='Blob'>
dataIndex: '${po.fieldName}String'
<#elseif po.classType=='umeditor'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'htmlSlot'}
<#elseif po.classType=='file'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'fileSlot'}
<#elseif po.classType=='pca'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'pcaSlot'}
<#elseif po.classType=='image'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'imgSlot'}
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'>
dataIndex: '${po.fieldName}_dictText'
<#elseif po.classType=='cat_tree'>
<#if list_need_category>
dataIndex: '${po.fieldName}',
customRender: (text) => (text ? filterMultiDictText(this.dictOptions['${po.fieldName}'], text) : '')
<#else>
dataIndex: '${po.fieldName}',
customRender: (text, record) => (text ? record['${po.dictText}'] : '')
</#if>
<#else>
dataIndex: '${po.fieldName}'
</#if>
},
</#if>
</#list>
{
title: '操作',
dataIndex: 'action',
align:"center",
fixed:"right",
width:147,
scopedSlots: { customRender: 'action' },
}
],
url: {
list: "/${entityPackage}/${entityName?uncap_first}/list",
delete: "/${entityPackage}/${entityName?uncap_first}/delete",
deleteBatch: "/${entityPackage}/${entityName?uncap_first}/deleteBatch",
exportXlsUrl: "/${entityPackage}/${entityName?uncap_first}/exportXls",
importExcelUrl: "${entityPackage}/${entityName?uncap_first}/importExcel",
<#if bpm_flag>startProcess: '/process/extActProcess/startMutilProcess'</#if>
},
<#if bpm_flag>
flowCode: 'dev_${tableName}_001',
</#if>
dictOptions:{},
}
},
created() {
<#if list_need_pca>
this.pcaData = new Area()
</#if>
},
computed: {
importExcelUrl: function(){
<#noparse>return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;</#noparse>
}
},
methods: {
<#if list_need_pca>
getPcaText(code){
return this.pcaData.getText(code);
},
</#if>
initDictConfig(){
<#list columns as po>
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
<#if po.classType=='cat_tree' && list_need_category==true>
loadCategoryData({code:"${po.dictField?default('')}"}).then((res) => {
if (res.success) {
this.$set(this.dictOptions, '${po.fieldName}', res.result)
}
})
</#if>
</#if>
</#list>
},
<#if bpm_flag>
startProcess(record){
this.$confirm({
title:'提示',
content:'确认提交流程吗?',
onOk:()=>{
let params = {
flowCode: this.flowCode,
id: record.id,
formUrl: '${entityPackage}/modules/${entityName}Form',
formUrlMobile: ''
}
postAction(this.url.startProcess, params).then(res=>{
if(res.success){
this.$message.success(res.message);
this.loadData();
this.onClearSelected();
}else{
this.$message.warning(res.message);
}
}).catch((e)=>{
this.$message.warning('不识别的请求!');
})
}
})
},
</#if>
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>

View File

@ -0,0 +1,546 @@
<#include "/common/utils.ftl">
<template>
<a-spin :spinning="confirmLoading">
<j-form-container :disabled="formDisabled">
<!-- 主表单区域 -->
<a-form :form="form" slot="detail">
<a-row>
<#assign form_date = false>
<#assign form_select = false>
<#assign form_select_multi = false>
<#assign form_select_search = false>
<#assign form_popup = false>
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#assign form_editor = false>
<#assign form_cat_tree = false>
<#assign form_cat_back = "">
<#assign form_pca = false>
<#assign form_md = false>
<#assign form_switch=false>
<#assign form_span = 24>
<#if tableVo.fieldRowNum==2>
<#assign form_span = 12>
<#elseif tableVo.fieldRowNum==3>
<#assign form_span = 8>
<#elseif tableVo.fieldRowNum==4>
<#assign form_span = 6>
</#if>
<#list columns as po>
<#if po.isShow =='Y' && po.fieldName != 'id'>
<#assign form_field_dictCode="">
<#if po.dictTable?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictField}">
</#if>
<#if po.classType =='textarea'>
<a-col :span="24">
<a-form-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
<#else>
<a-col :span="${form_span}" >
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
</#if>
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" style="width: 100%"/>
<#elseif po.classType =='datetime'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<#elseif po.classType =='popup'>
<#assign form_popup=true>
<j-popup
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${Format.underlineToHump(po.dictText)}"
code="${po.dictTable}"
@callback="popupCallback"/>
<#elseif po.classType =='sel_depart'>
<#assign form_sel_depart=true>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" multi/>
<#elseif po.classType =='switch'>
<#assign form_switch=true>
<j-switch v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" <#if po.dictField?default("")?trim?length gt 1>:options="${po.dictField}"</#if>></j-switch>
<#elseif po.classType =='pca'>
<#assign form_pca=true>
<j-area-linkage type="cascader" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入省市区"/>
<#elseif po.classType =='markdown'>
<#assign form_md=true>
<j-markdown-editor v-decorator="['${po.fieldName}']" id="${po.fieldName}"></j-markdown-editor>
<#elseif po.classType =='password'>
<a-input-password v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" rows="4" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType=='list' || po.classType=='radio'>
<#assign form_select = true>
<j-dict-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='list_multi' || po.classType=='checkbox'>
<#assign form_select_multi = true>
<j-multi-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='sel_search'>
<#assign form_select_search = true>
<j-search-select-tag v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" dict="${form_field_dictCode}" />
<#elseif po.classType=='cat_tree'>
<#assign form_cat_tree = true>
<j-category-select v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<#if po.dictText?default("")?trim?length gt 1>
<#assign form_cat_back = "${po.dictText}">
</#if>
<#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file'>
<#assign form_file = true>
<j-upload v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"></j-upload>
<#elseif po.classType=='image'>
<#assign form_image = true>
<j-image-upload isMultiple v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"></j-image-upload>
<#elseif po.classType=='umeditor'>
<#assign form_editor = true>
<j-editor v-decorator="['${po.fieldName}',{trigger:'input'}]"/>
<#elseif po.fieldDbType=='Blob'>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
<#if form_cat_tree && form_cat_back?length gt 1>
<a-form-item v-show="false">
<a-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-col>
</#if>
</#list>
</a-row>
</a-form>
</j-form-container>
<!-- 子表单区域 -->
<a-tabs v-model="activeKey" @change="handleChangeTabs">
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='1'>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<${Format.humpToShortbar(sub.entityName)}-form ref="${sub.entityName?uncap_first}Form" @validateError="validateError" :disabled="formDisabled"></${Format.humpToShortbar(sub.entityName)}-form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<j-vxe-table
keep-source
:ref="refKeys[${sub_index}]"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"
:maxHeight="300"
:disabled="formDisabled"
:rowNumber="true"
:rowSelection="true"
:toolbar="true"
/>
</a-tab-pane>
</#if>
</#list>
</a-tabs>
</a-spin>
</template>
<script>
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import { JVxeTableMixin } from '@/mixins/JVxeTableMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import { getRefPromise} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
import { validateDuplicateValue } from '@/utils/util'
import JFormContainer from '@/components/jeecg/JFormContainer'
<#list subTables as sub>
<#if sub.foreignRelationType =='1'>
import ${sub.entityName}Form from './${sub.entityName}Form.vue'
</#if>
</#list>
<#if form_date>
import JDate from '@/components/jeecg/JDate'
</#if>
<#if form_file>
import JUpload from '@/components/jeecg/JUpload'
</#if>
<#if form_image>
import JImageUpload from '@/components/jeecg/JImageUpload'
</#if>
<#if form_sel_depart>
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if form_sel_user>
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if form_select>
import JDictSelectTag from "@/components/dict/JDictSelectTag"
</#if>
<#if form_select_multi>
import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
</#if>
<#if form_select_search>
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
<#if form_editor>
import JEditor from '@/components/jeecg/JEditor'
</#if>
<#if form_cat_tree>
import JCategorySelect from '@/components/jeecg/JCategorySelect'
</#if>
<#if form_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if form_md>
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
</#if>
<#if form_switch==true >
import JSwitch from '@/components/jeecg/JSwitch'
</#if>
export default {
name: '${entityName}Form',
mixins: [JVxeTableMixin],
components: {
JFormContainer,
<#list subTables as sub>
<#if sub.foreignRelationType =='1'>
${sub.entityName}Form,
</#if>
</#list>
<#if form_date>
JDate,
</#if>
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
<#if form_sel_user>
JSelectUserByDep,
</#if>
<#if form_select>
JDictSelectTag,
</#if>
<#if form_select_multi>
JMultiSelectTag,
</#if>
<#if form_select_search>
JSearchSelectTag,
</#if>
<#if form_editor>
JEditor,
</#if>
<#if form_pca>
JAreaLinkage,
</#if>
<#if form_cat_tree>
JCategorySelect,
</#if>
<#if form_md>
JMarkdownEditor,
</#if>
<#if form_switch==true >
JSwitch,
</#if>
},
data() {
return {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
labelCol2: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol2: {
xs: { span: 24 },
sm: { span: 20 },
},
// 新增时子表默认添加几行空数据
addDefaultRowNum: 1,
<#include "/common/validatorRulesTemplate/main.ftl">
refKeys: [<#list subTables as sub>'${sub.entityName?uncap_first}', </#list>],
<#assign hasOne2Many = false>
tableKeys:[<#list subTables as sub><#if sub.foreignRelationType =='0'>'${sub.entityName?uncap_first}', <#assign hasOne2Many = true></#if></#list>],
activeKey: '${subTables[0].entityName?uncap_first}',
<#list subTables as sub><#rt/>
// ${sub.ftlDescription}
${sub.entityName?uncap_first}Table: {
loading: false,
dataSource: [],
columns: [
<#if sub.foreignRelationType =='0'>
<#assign popupBackFields = "">
<#-- 循环子表的列 开始 -->
<#list sub.colums as col><#rt/>
<#if col.isShow =='Y'>
<#if col.filedComment !='外键' >
{
title: '${col.filedComment}',
key: '${col.fieldName}',
<#if col.classType =='date'>
type: JVXETypes.date,
<#elseif col.classType =='datetime'>
type: JVXETypes.datetime,
<#elseif col.classType =='textarea'>
type: JVXETypes.textarea,
<#elseif "int,decimal,double,"?contains(col.classType)>
type: JVXETypes.inputNumber,
<#elseif col.classType =='list' || col.classType =='radio'>
type: JVXETypes.select,
options:[],
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='list_multi' || col.classType =='checkbox'>
type: JVXETypes.selectMultiple,
options:[],
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='sel_search'>
type: JVXETypes.selectSearch,
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='image'>
type: JVXETypes.image,
token:true,
responseName:"message",
<#elseif col.classType =='file'>
type: JVXETypes.file,
token:true,
responseName:"message",
<#elseif col.classType =='popup'>
<#if popupBackFields?length gt 0>
<#assign popupBackFields = "${popupBackFields}"+","+"${col.dictText}">
<#else>
<#assign popupBackFields = "${col.dictText}">
</#if>
type: JVXETypes.popup,
popupCode:"${col.dictTable}",
field:"${col.dictField}",
orgFields:"${col.dictField}",
destFields:"${Format.underlineToHump(col.dictText)}",
<#else>
type: JVXETypes.input,
</#if>
<#if col.classType =='list_multi' || col.classType =='checkbox'>
width:"250px",
<#else>
width:"200px",
</#if>
<#if col.classType =='file'>
placeholder: '请选择文件',
<#else>
placeholder: '请输入${'$'}{title}',
</#if>
defaultValue: '',
<#-- 子表的校验 -->
<#assign subFieldValidType = col.fieldValidType!''>
<#-- 非空校验 -->
<#if col.nullable == 'N' || subFieldValidType == '*'>
validateRules: [{ required: true, message: '${'$'}{title}不能为空' }],
<#-- 其他情况下,只要有值就被认为是正则校验 -->
<#elseif subFieldValidType?length gt 0>
<#assign subMessage = '格式不正确'>
<#if subFieldValidType == 'only' >
<#assign subMessage = '不能重复'>
</#if>
validateRules: [{ pattern: "${subFieldValidType}", message: "${'$'}{title}${subMessage}" }],
</#if>
},
</#if>
</#if>
</#list>
<#-- 循环子表的列 结束 -->
<#-- 处理popup的隐藏列 -->
<#if popupBackFields?length gt 0>
<#list popupBackFields?split(",") as item>
<#if item?length gt 0>
<#assign tempItemFlag = true>
<#list sub.colums as col>
<#if col.isShow =='Y' && col.fieldName == item>
<#assign tempItemFlag = false>
</#if>
</#list>
<#if tempItemFlag>
{
title: '${item}',
key: '${item}',
type:"hidden"
},
</#if>
</#if>
</#list>
</#if>
</#if>
]
},
</#list>
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",
queryById: "/${entityPackage}/${entityName?uncap_first}/queryById",
<#list subTables as sub><#rt/>
${sub.entityName?uncap_first}: {
list: '/${entityPackage}/${entityName?uncap_first}/query${sub.entityName}ByMainId'
},
</#list>
}
}
},
props: {
//流程表单data
formData: {
type: Object,
default: ()=>{},
required: false
},
//表单模式false流程表单 true普通表单
formBpm: {
type: Boolean,
default: false,
required: false
},
//表单禁用
disabled: {
type: Boolean,
default: false,
required: false
}
},
computed: {
formDisabled(){
if(this.formBpm===true){
if(this.formData.disabled===false){
return false
}
return true
}
return this.disabled
},
showFlowSubmitButton(){
if(this.formBpm===true){
if(this.formData.disabled===false){
return true
}
}
return false
}
},
created () {
//如果是流程中表单则需要加载流程表单data
this.showFlowData();
},
methods: {
addBefore(){
this.form.resetFields()
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='1'>
this.$refs.${sub.entityName?uncap_first}Form.clearFormData()
<#else>
this.${sub.entityName?uncap_first}Table.dataSource=[]
</#if>
</#list>
},
getAllTable() {
<#if hasOne2Many==true>
let values = this.tableKeys.map(key => getRefPromise(this, key))
return Promise.all(values)
<#else>
return new Promise(resolve => {
resolve([]);
})
</#if>
},
/** 调用完edit()方法之后会自动调用此方法 */
editAfter() {
let fieldval = pick(this.model<#list columns as po><#if po.fieldName !='id'><#if po.fieldDbType=='Blob'>,'${po.fieldName}String'<#else>,'${po.fieldName}'</#if></#if></#list>)
this.$nextTick(() => {
this.form.setFieldsValue(fieldval)
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='1'>
this.$refs.${sub.entityName?uncap_first}Form.initFormData(this.url.${sub.entityName?uncap_first}.list,this.model.id)
</#if>
</#list>
})
// 加载子表数据
if (this.model.id) {
let params = { id: this.model.id }
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='0'>
this.requestSubTableData(this.url.${sub.entityName?uncap_first}.list, params, this.${sub.entityName?uncap_first}Table)
</#if>
</#list>
}
},
/** 整理成formData */
classifyIntoFormData(allValues) {
let main = Object.assign(this.model, allValues.formValue)
return {
...main, // 展开
<#assign subManyIndex = 0>
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='0'>
${sub.entityName?uncap_first}List: allValues.tablesValue[${subManyIndex}].tableData,
<#assign subManyIndex = subManyIndex+1>
<#else>
${sub.entityName?uncap_first}List: this.$refs.${sub.entityName?uncap_first}Form.getFormData(),
</#if>
</#list>
}
},
//渲染流程表单数据
showFlowData(){
if(this.formBpm === true){
let params = {id:this.formData.dataId};
getAction(this.url.queryById,params).then((res)=>{
if(res.success){
this.edit (res.result);
}
})
}
},
validateError(msg){
this.$message.error(msg)
},
popupCallback(row){
this.form.setFieldsValue(pick(row<#list columns as po><#if po.fieldName !='id'><#if po.fieldDbType=='Blob'>,'${po.fieldName}String'<#else>,'${po.fieldName}'</#if></#if></#list>))
},
<#if form_cat_tree>
handleCategoryChange(value,backObj){
this.form.setFieldsValue(backObj)
}
</#if>
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,65 @@
<#include "/common/utils.ftl">
<template>
<j-modal
:title="title"
:width="1200"
:visible="visible"
:maskClosable="false"
switchFullscreen
@ok="handleOk"
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
@cancel="handleCancel">
<${Format.humpToShortbar(entityName)}-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"/>
</j-modal>
</template>
<script>
import ${entityName}Form from './${entityName}Form'
export default {
name: '${entityName}Modal',
components: {
${entityName}Form
},
data() {
return {
title:'',
width:800,
visible: false,
disableSubmit: false
}
},
methods:{
add () {
this.visible=true
this.$nextTick(()=>{
this.$refs.realForm.add();
})
},
edit (record) {
this.visible=true
this.$nextTick(()=>{
this.$refs.realForm.edit(record);
})
},
close () {
this.$emit('close');
this.visible = false;
},
handleOk () {
this.$refs.realForm.handleOk();
},
submitCallback(){
this.$emit('ok');
this.visible = false;
},
handleCancel () {
this.close()
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,306 @@
<#include "/common/utils.ftl">
<#list subTables as sub>
<#if sub.foreignRelationType=='1'>
#segment#${sub.entityName}Form.vue
<template>
<j-form-container :disabled="disabled">
<a-form :form="form" slot="detail">
<a-row>
<#assign form_date = false>
<#assign form_select = false>
<#assign form_select_multi = false>
<#assign form_select_search = false>
<#assign form_popup = false>
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#assign form_editor = false>
<#assign form_cat_tree = false>
<#assign form_cat_back = "">
<#assign form_pca = false>
<#assign form_md = false>
<#assign form_switch=false>
<#assign form_span = 24>
<#if tableVo.fieldRowNum == 2>
<#assign form_span = 12>
<#elseif tableVo.fieldRowNum==3>
<#assign form_span = 8>
<#elseif tableVo.fieldRowNum==4>
<#assign form_span = 6>
</#if>
<#list sub.colums as po>
<#if po.isShow =='Y' && po.fieldName != 'id'>
<#assign form_field_dictCode="">
<#if po.dictTable?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictField}">
</#if>
<#if po.classType =='textarea'>
<a-col :span="24">
<a-form-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
<#else>
<a-col :span="${form_span}">
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
</#if>
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" style="width: 100%"/>
<#elseif po.classType =='datetime'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<#elseif po.classType =='popup'>
<#assign form_popup=true>
<j-popup
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${Format.underlineToHump(po.dictText)}"
code="${po.dictTable}"
@callback="popupCallback"/>
<#elseif po.classType =='sel_depart'>
<#assign form_sel_depart=true>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" multi/>
<#elseif po.classType =='switch'>
<#assign form_switch=true>
<j-switch v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" <#if po.dictField?default("")?trim?length gt 1>:options="${po.dictField}"</#if>></j-switch>
<#elseif po.classType =='pca'>
<#assign form_pca=true>
<j-area-linkage type="cascader" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入省市区"/>
<#elseif po.classType =='markdown'>
<#assign form_md=true>
<j-markdown-editor v-decorator="['${po.fieldName}']" id="${po.fieldName}"></j-markdown-editor>
<#elseif po.classType =='password'>
<a-input-password v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" rows="4" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType=='list' || po.classType=='radio'>
<#assign form_select = true>
<j-dict-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='list_multi' || po.classType=='checkbox'>
<#assign form_select_multi = true>
<j-multi-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='sel_search'>
<#assign form_select_search = true>
<j-search-select-tag v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" dict="${form_field_dictCode}" />
<#elseif po.classType=='cat_tree'>
<#assign form_cat_tree = true>
<j-category-select v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<#if po.dictText?default("")?trim?length gt 1>
<#assign form_cat_back = "${po.dictText}">
</#if>
<#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file'>
<#assign form_file = true>
<j-upload v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"></j-upload>
<#elseif po.classType=='image'>
<#assign form_image = true>
<j-image-upload isMultiple v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"></j-image-upload>
<#elseif po.classType=='umeditor'>
<#assign form_editor = true>
<j-editor v-decorator="['${po.fieldName}',{trigger:'input'}]"/>
<#elseif po.fieldDbType=='Blob'>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
<#if form_cat_tree && form_cat_back?length gt 1>
<a-form-item v-show="false">
<a-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-col>
</#if>
</#list>
</a-row>
</a-form>
</j-form-container>
</template>
<script>
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
import JFormContainer from '@/components/jeecg/JFormContainer'
<#if form_date>
import JDate from '@/components/jeecg/JDate'
</#if>
<#if form_file>
import JUpload from '@/components/jeecg/JUpload'
</#if>
<#if form_image>
import JImageUpload from '@/components/jeecg/JImageUpload'
</#if>
<#if form_sel_depart>
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if form_sel_user>
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if form_select>
import JDictSelectTag from "@/components/dict/JDictSelectTag"
</#if>
<#if form_select_multi>
import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
</#if>
<#if form_select_search>
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
<#if form_editor>
import JEditor from '@/components/jeecg/JEditor'
</#if>
<#if form_cat_tree>
import JCategorySelect from '@/components/jeecg/JCategorySelect'
</#if>
<#if form_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if form_md>
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
</#if>
<#if form_switch==true >
import JSwitch from '@/components/jeecg/JSwitch'
</#if>
export default {
name: '${sub.entityName}Form',
components: {
JFormContainer,
<#if form_date>
JDate,
</#if>
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
<#if form_sel_user>
JSelectUserByDep,
</#if>
<#if form_select>
JDictSelectTag,
</#if>
<#if form_select_multi>
JMultiSelectTag,
</#if>
<#if form_select_search>
JSearchSelectTag,
</#if>
<#if form_editor>
JEditor,
</#if>
<#if form_pca>
JAreaLinkage,
</#if>
<#if form_cat_tree>
JCategorySelect,
</#if>
<#if form_md>
JMarkdownEditor,
</#if>
<#if form_switch==true >
JSwitch,
</#if>
},
props:{
disabled: {
type: Boolean,
default: false,
required: false
}
},
data () {
return {
form: this.$form.createForm(this),
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
labelCol2: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol2: {
xs: { span: 24 },
sm: { span: 20 },
},
<#include "/common/validatorRulesTemplate/sub.ftl">
confirmLoading: false,
}
},
methods:{
initFormData(url,id){
this.clearFormData()
if(!id){
this.edit({})
}else{
getAction(url,{id:id}).then(res=>{
if(res.success){
let records = res.result
if(records && records.length>0){
this.edit(records[0])
}
}
})
}
},
edit(record){
this.model = Object.assign({}, record)
console.log("${sub.entityName}Form-edit",this.model);
let fieldval = pick(this.model<#list sub.colums as po><#if po.fieldName !='id'>,'${po.fieldName}'</#if></#list>)
this.$nextTick(() => {
this.form.setFieldsValue(fieldval)
})
},
getFormData(){
let formdata_arr = []
this.form.validateFields((err, values) => {
if (!err) {
let formdata = Object.assign(this.model, values)
let isNullObj = true
Object.keys(formdata).forEach(key=>{
if(formdata[key]){
isNullObj = false
}
})
if(!isNullObj){
formdata_arr.push(formdata)
}
}else{
this.$emit("validateError","${sub.ftlDescription}表单校验未通过");
}
})
console.log("${sub.ftlDescription}表单数据集",formdata_arr);
return formdata_arr;
},
popupCallback(row){
this.form.setFieldsValue(pick(row<#list sub.colums as po><#if po.fieldName !='id'>,'${po.fieldName}'</#if></#list>))
},
clearFormData(){
this.form.resetFields()
this.model={}
},
<#if form_cat_tree>
handleCategoryChange(value,backObj){
this.form.setFieldsValue(backObj);
}
</#if>
}
}
</script>
</#if>
</#list>

View File

@ -0,0 +1,271 @@
package ${bussiPackage}.${entityPackage}.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.vo.LoginUser;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import ${bussiPackage}.${entityPackage}.vo.${entityName}Page;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.service.I${sub.entityName}Service;
</#list>
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Api(tags="${tableVo.ftlDescription}")
@RestController
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
@Slf4j
public class ${entityName}Controller {
@Autowired
private I${entityName}Service ${entityName?uncap_first}Service;
<#list subTables as sub>
@Autowired
private I${sub.entityName}Service ${sub.entityName?uncap_first}Service;
</#list>
/**
* 分页列表查询
*
* @param ${entityName?uncap_first}
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")
@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param ${entityName?uncap_first}Page
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-添加")
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.saveMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param ${entityName?uncap_first}Page
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName} ${entityName?uncap_first}Entity = ${entityName?uncap_first}Service.getById(${entityName?uncap_first}.getId());
if(${entityName?uncap_first}Entity==null) {
return Result.error("未找到对应数据");
}
${entityName?uncap_first}Service.updateMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-通过id删除")
@ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-批量删除")
@ApiOperation(value="${tableVo.ftlDescription}-批量删除", notes="${tableVo.ftlDescription}-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-通过id查询")
@ApiOperation(value="${tableVo.ftlDescription}-通过id查询", notes="${tableVo.ftlDescription}-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
if(${entityName?uncap_first}==null) {
return Result.error("未找到对应数据");
}
return Result.OK(${entityName?uncap_first});
}
<#list subTables as sub>
/**
* 通过id查询
*
* @param id
* @return
*/
@AutoLog(value = "${sub.ftlDescription}通过主表ID查询")
@ApiOperation(value="${sub.ftlDescription}主表ID查询", notes="${sub.ftlDescription}-通主表ID查询")
@GetMapping(value = "/query${sub.entityName}ByMainId")
public Result<?> query${sub.entityName}ListByMainId(@RequestParam(name="id",required=true) String id) {
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(id);
return Result.OK(${sub.entityName?uncap_first}List);
}
</#list>
/**
* 导出excel
*
* @param request
* @param ${entityName?uncap_first}
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, ${entityName} ${entityName?uncap_first}) {
// Step.1 组装查询条件查询数据
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//Step.2 获取导出数据
List<${entityName}> queryList = ${entityName?uncap_first}Service.list(queryWrapper);
// 过滤选中数据
String selections = request.getParameter("selections");
List<${entityName}> ${entityName?uncap_first}List = new ArrayList<${entityName}>();
if(oConvertUtils.isEmpty(selections)) {
${entityName?uncap_first}List = queryList;
}else {
List<String> selectionList = Arrays.asList(selections.split(","));
${entityName?uncap_first}List = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
}
// Step.3 组装pageList
List<${entityName}Page> pageList = new ArrayList<${entityName}Page>();
for (${entityName} main : ${entityName?uncap_first}List) {
${entityName}Page vo = new ${entityName}Page();
BeanUtils.copyProperties(main, vo);
<#list subTables as sub>
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(main.getId());
vo.set${sub.entityName}List(${sub.entityName?uncap_first}List);
</#list>
pageList.add(vo);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "${tableVo.ftlDescription}列表");
mv.addObject(NormalExcelConstants.CLASS, ${entityName}Page.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("${tableVo.ftlDescription}数据", "导出人:"+sysUser.getRealname(), "${tableVo.ftlDescription}"));
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<${entityName}Page> list = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}Page.class, params);
for (${entityName}Page page : list) {
${entityName} po = new ${entityName}();
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.OK("文件导入失败!");
}
}

View File

@ -0,0 +1,103 @@
package ${bussiPackage}.${entityPackage}.entity;
import java.io.Serializable;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
@Data
@TableName("${tableName}")
public class ${entityName} implements Serializable {
private static final long serialVersionUID = 1L;
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
<#if list_field_dictCode?length gt 1>
@Dict(${list_field_dictCode?substring(2)})
</#if>
</#if>
<#if po.fieldDbType=='Blob'>
private transient java.lang.String ${po.fieldName}String;
private byte[] ${po.fieldName};
public byte[] get${po.fieldName?cap_first}(){
if(${po.fieldName}String==null){
return null;
}
try {
return ${po.fieldName}String.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public String get${po.fieldName?cap_first}String(){
if(${po.fieldName}==null || ${po.fieldName}.length==0){
return "";
}
try {
return new String(${po.fieldName},"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
<#else>
@ApiModelProperty(value = "${po.filedComment}")
private ${po.fieldType} ${po.fieldName};
</#if>
</#list>
}

View File

@ -0,0 +1,72 @@
<#list subTables as subTab>
#segment#${subTab.entityName}.java
package ${bussiPackage}.${entityPackage}.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
@Data
@TableName("${subTab.tableName}")
public class ${subTab.entityName} implements Serializable {
private static final long serialVersionUID = 1L;
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list subTab.originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#elseif !subTab.foreignKeys?seq_contains(po.fieldName?cap_first)>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
}
</#list>

View File

@ -0,0 +1,17 @@
package ${bussiPackage}.${entityPackage}.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
}

View File

@ -0,0 +1,22 @@
<#list subTables as subTab>
#segment#${subTab.entityName}Mapper.java
package ${bussiPackage}.${entityPackage}.mapper;
import java.util.List;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
public boolean deleteByMainId(@Param("mainId") String mainId);
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}
</#list>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper">
</mapper>

View File

@ -0,0 +1,26 @@
<#list subTables as subTab>
<#assign originalForeignKeys = subTab.originalForeignKeys>
#segment#${subTab.entityName}Mapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${bussiPackage}.${entityPackage}.mapper.${subTab.entityName}Mapper">
<delete id="deleteByMainId" parameterType="java.lang.String">
DELETE
FROM ${subTab.tableName}
WHERE
<#list originalForeignKeys as key>
${key} = ${r'#'}{mainId} <#rt/>
</#list>
</delete>
<select id="selectByMainId" parameterType="java.lang.String" resultType="${bussiPackage}.${entityPackage}.entity.${subTab.entityName}">
SELECT *
FROM ${subTab.tableName}
WHERE
<#list originalForeignKeys as key>
${key} = ${r'#'}{mainId} <#rt/>
</#list>
</select>
</mapper>
</#list>

View File

@ -0,0 +1,42 @@
package ${bussiPackage}.${entityPackage}.service;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface I${entityName}Service extends IService<${entityName}> {
/**
* 添加一对多
*
*/
public void saveMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) ;
/**
* 修改一对多
*
*/
public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>);
/**
* 删除一对多
*/
public void delMain (String id);
/**
* 批量删除一对多
*/
public void delBatchMain (Collection<? extends Serializable> idList);
}

View File

@ -0,0 +1,19 @@
<#list subTables as subTab>
#segment#I${subTab.entityName}Service.java
package ${bussiPackage}.${entityPackage}.service;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -0,0 +1,105 @@
package ${bussiPackage}.${entityPackage}.service.impl;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.mapper.${sub.entityName}Mapper;
</#list>
import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Service
public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
@Autowired
private ${entityName}Mapper ${entityName?uncap_first}Mapper;
<#list subTables as sub>
@Autowired
private ${sub.entityName}Mapper ${sub.entityName?uncap_first}Mapper;
</#list>
@Override
@Transactional
public void saveMain(${entityName} ${entityName?uncap_first}, <#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
${entityName?uncap_first}Mapper.insert(${entityName?uncap_first});
<#list subTables as sub>
if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
<#list sub.foreignKeys as key>
//外键设置
<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
<#else>
entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
</#if>
</#list>
${sub.entityName?uncap_first}Mapper.insert(entity);
}
}
</#list>
}
@Override
@Transactional
public void updateMain(${entityName} ${entityName?uncap_first},<#list subTables as sub>List<${sub.entityName}> ${sub.entityName?uncap_first}List<#if sub_has_next>,</#if></#list>) {
${entityName?uncap_first}Mapper.updateById(${entityName?uncap_first});
//1.先删除子表数据
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(${entityName?uncap_first}.getId());
</#list>
//2.子表数据重新插入
<#list subTables as sub>
if(${sub.entityName?uncap_first}List!=null && ${sub.entityName?uncap_first}List.size()>0) {
for(${sub.entityName} entity:${sub.entityName?uncap_first}List) {
<#list sub.foreignKeys as key>
//外键设置
<#if key?lower_case?index_of("${primaryKeyField}")!=-1>
entity.set${key?cap_first}(${entityName?uncap_first}.get${primaryKeyField?cap_first}());
<#else>
entity.set${key?cap_first}(${entityName?uncap_first}.get${key}());
</#if>
</#list>
${sub.entityName?uncap_first}Mapper.insert(entity);
}
}
</#list>
}
@Override
@Transactional
public void delMain(String id) {
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(id);
</#list>
${entityName?uncap_first}Mapper.deleteById(id);
}
@Override
@Transactional
public void delBatchMain(Collection<? extends Serializable> idList) {
for(Serializable id:idList) {
<#list subTables as sub>
${sub.entityName?uncap_first}Mapper.deleteByMainId(id.toString());
</#list>
${entityName?uncap_first}Mapper.deleteById(id);
}
}
}

View File

@ -0,0 +1,30 @@
<#list subTables as subTab>
#segment#${subTab.entityName}ServiceImpl.java
package ${bussiPackage}.${entityPackage}.service.impl;
import ${bussiPackage}.${entityPackage}.entity.${subTab.entityName};
import ${bussiPackage}.${entityPackage}.mapper.${subTab.entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${subTab.entityName}Service;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description: ${subTab.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Service
public class ${subTab.entityName}ServiceImpl extends ServiceImpl<${subTab.entityName}Mapper, ${subTab.entityName}> implements I${subTab.entityName}Service {
@Autowired
private ${subTab.entityName}Mapper ${subTab.entityName?uncap_first}Mapper;
@Override
public List<${subTab.entityName}> selectByMainId(String mainId) {
return ${subTab.entityName?uncap_first}Mapper.selectByMainId(mainId);
}
}
</#list>

View File

@ -0,0 +1,80 @@
package ${bussiPackage}.${entityPackage}.vo;
import java.util.List;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.entity.${sub.entityName};
</#list>
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelEntity;
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: jeecg-boot
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Data
@ApiModel(value="${tableName}Page对象", description="${tableVo.ftlDescription}")
public class ${entityName}Page {
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list originalColumns as po>
<#-- 生成字典Code -->
<#assign list_field_dictCode="">
<#if po.classType='sel_user'>
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
<#elseif po.classType='sel_depart'>
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
<#if po.dictTable?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
</#if>
</#if>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
</#if>
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#else>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
</#if>
</#if>
<#if list_field_dictCode?length gt 1>
@Dict(${list_field_dictCode?substring(2)})
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
<#list subTables as sub>
@ExcelCollection(name="${sub.ftlDescription}")
@ApiModelProperty(value = "${sub.ftlDescription}")
private List<${sub.entityName}> ${sub.entityName?uncap_first}List;
</#list>
}

View File

@ -0,0 +1,407 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<#assign query_field_no=0>
<#assign query_field_select=false>
<#assign query_field_date=false>
<#assign list_need_dict=false>
<#assign list_need_category=false>
<#assign query_field_pca=false>
<#assign list_need_pca=false>
<#assign query_flag=false>
<#assign query_inp=false>
<#assign query_popup=false>
<#assign query_sel_user=false>
<#assign query_sel_dep=false>
<#assign query_sel_multi=false>
<#assign query_sel_cat=false>
<#assign query_sel_search=false>
<#-- 开始循环 -->
<#list columns as po>
<#if po.isQuery=='Y'>
<#assign query_flag=true>
<#if query_field_no==2>
<template v-if="toggleSearchStatus">
</#if>
<#assign query_field_dictCode="">
<#if po.dictTable?default("")?trim?length gt 1>
<#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign query_field_dictCode="${po.dictField}">
</#if>
<#if po.queryMode=='single'>
<#if query_field_no gt 1> </#if><a-col :xl="6" :lg="7" :md="8" :sm="24">
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
<#if po.classType=='sel_search'>
<#assign query_sel_search=true>
<#if query_field_no gt 1> </#if><j-search-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dict="${po.dictTable},${po.dictText},${po.dictField}"/>
<#elseif po.classType=='sel_user'>
<#assign query_sel_user=true>
<#if query_field_no gt 1> </#if><j-select-user-by-dep placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='sel_depart'>
<#assign query_sel_dep=true>
<#if query_field_no gt 1> </#if><j-select-depart placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='list_multi'>
<#assign query_sel_multi=true>
<#if query_field_no gt 1> </#if><j-multi-select-tag placeholder="请选择${po.filedComment}" dictCode="${query_field_dictCode?default("")}" v-model="queryParam.${po.fieldName}"/>
<#elseif po.classType=='cat_tree'>
<#assign query_sel_cat=true>
<#if query_field_no gt 1> </#if><j-category-select placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" pcode="${po.dictField?default("")}"/>
<#elseif po.classType=='date'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"></j-date>
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}"></j-date>
<#elseif po.classType=='pca'>
<#assign query_field_pca=true>
<#if query_field_no gt 1> </#if><j-area-linkage type="cascader" v-model="queryParam.${po.fieldName}" placeholder="请选择省市区"/>
<#elseif po.classType=='popup'>
<#if query_field_no gt 1> </#if><j-popup placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" code="${po.dictTable}" org-fields="${po.dictField}" dest-fields="${po.dictText}" :field="getPopupField('${po.dictText}')"/>
<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
<#assign query_field_select=true>
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
<#if po.dictTable?default("")?trim?length gt 1>
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dictCode="${po.dictTable},${po.dictText},${po.dictField}"/>
<#elseif po.dictField?default("")?trim?length gt 1>
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model="queryParam.${po.fieldName}" dictCode="${po.dictField}"/>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model="queryParam.${po.fieldName}"></a-input>
</#if>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model="queryParam.${po.fieldName}"></a-input>
</#if>
<#if query_field_no gt 1> </#if></a-form-item>
<#if query_field_no gt 1> </#if></a-col>
<#else>
<#if query_field_no gt 1> </#if><a-col :xl="10" :lg="11" :md="12" :sm="24">
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
<#if po.classType=='date'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></j-date>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></j-date>
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></j-date>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></j-date>
<#else>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最小值" class="query-group-cust" v-model="queryParam.${po.fieldName}_begin"></a-input>
<#if query_field_no gt 1> </#if><span class="query-group-split-cust"></span>
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最大值" class="query-group-cust" v-model="queryParam.${po.fieldName}_end"></a-input>
</#if>
<#if query_field_no gt 1> </#if></a-form-item>
<#if query_field_no gt 1> </#if></a-col>
</#if>
<#assign query_field_no=query_field_no+1>
</#if>
<#if !list_need_dict && po.fieldShowType!='popup' && po.dictField?default("")?trim?length gt 1>
<#assign list_need_dict=true>
</#if>
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
<#assign list_need_category=true>
</#if>
<#if po.classType=='pca'>
<#assign list_need_pca=true>
</#if>
</#list>
<#-- 结束循环 -->
<#t>
<#if query_field_no gt 2>
</template>
</#if>
<#if query_flag>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<a @click="handleToggleSearch" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('${tableVo.ftlDescription}')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:scroll="{x:true}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<template slot="htmlSlot" slot-scope="text">
<div v-html="text"></div>
</template>
<template slot="imgSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
<img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
type="primary"
icon="download"
size="small"
@click="uploadFile(text)">
下载
</a-button>
</template>
<#if list_need_pca>
<template slot="pcaSlot" slot-scope="text">
<div>{{ getPcaText(text) }}</div>
</template>
</#if>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a-dropdown>
<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
<a-menu slot="overlay">
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<${entityName?uncap_first}-modal ref="modalForm" @ok="modalFormOk"></${entityName?uncap_first}-modal>
</a-card>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ${entityName}Modal from './modules/${entityName}Modal'
<#if query_field_select>
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
</#if>
<#if query_field_date>
import JDate from '@/components/jeecg/JDate.vue'
</#if>
<#if list_need_category>
import { loadCategoryData } from '@/api/api'
</#if>
<#if list_need_dict>
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#if>
<#if query_field_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if list_need_pca>
import Area from '@/components/_util/Area'
</#if>
<#if query_inp>
import JInput from '@comp/jeecg/JInput'
</#if>
<#if query_sel_user>
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if query_sel_dep>
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if query_sel_multi>
import JMultiSelectTag from '@/components/dict/JMultiSelectTag'
</#if>
<#if query_sel_cat>
import JCategorySelect from '@comp/jeecg/JCategorySelect'
</#if>
<#if query_sel_search>
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
import '@/assets/less/TableExpand.less'
export default {
name: "${entityName}List",
mixins:[JeecgListMixin],
components: {
<#if query_field_select>
JDictSelectTag,
</#if>
<#if query_field_date>
JDate,
</#if>
<#if query_field_pca>
JAreaLinkage,
</#if>
<#if query_inp>
JInput,
</#if>
<#if query_sel_user>
JSelectUserByDep,
</#if>
<#if query_sel_dep>
JSelectDepart,
</#if>
<#if query_sel_multi>
JMultiSelectTag,
</#if>
<#if query_sel_cat>
JCategorySelect,
</#if>
<#if query_sel_search>
JSearchSelectTag,
</#if>
${entityName}Modal
},
data () {
return {
description: '${tableVo.ftlDescription}管理页面',
// 表头
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:60,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
<#assign showColNum=0>
<#list columns as po>
<#if po.isShowList =='Y'>
<#assign showColNum=showColNum+1>
{
title:'${po.filedComment}',
align:"center",
<#if po.sort=='Y'>
sorter: true,
</#if>
<#if po.classType=='date'>
dataIndex: '${po.fieldName}',
customRender:function (text) {
return !text?"":(text.length>10?text.substr(0,10):text)
}
<#elseif po.fieldDbType=='Blob'>
dataIndex: '${po.fieldName}String'
<#elseif po.classType=='umeditor'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'htmlSlot'}
<#elseif po.classType=='file'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'fileSlot'}
<#elseif po.classType=='pca'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'pcaSlot'}
<#elseif po.classType=='image'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'imgSlot'}
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'>
dataIndex: '${po.fieldName}_dictText'
<#elseif po.classType=='cat_tree'>
<#if list_need_category>
dataIndex: '${po.fieldName}',
customRender: (text) => (text ? filterMultiDictText(this.dictOptions['${po.fieldName}'], text) : '')
<#else>
dataIndex: '${po.fieldName}',
customRender: (text, record) => (text ? record['${po.dictText}'] : '')
</#if>
<#else>
dataIndex: '${po.fieldName}'
</#if>
},
</#if>
</#list>
{
title: '操作',
dataIndex: 'action',
align:"center",
fixed:"right",
width:147,
scopedSlots: { customRender: 'action' },
}
],
url: {
list: "/${entityPackage}/${entityName?uncap_first}/list",
delete: "/${entityPackage}/${entityName?uncap_first}/delete",
deleteBatch: "/${entityPackage}/${entityName?uncap_first}/deleteBatch",
exportXlsUrl: "/${entityPackage}/${entityName?uncap_first}/exportXls",
importExcelUrl: "${entityPackage}/${entityName?uncap_first}/importExcel",
},
dictOptions:{},
}
},
created() {
<#if list_need_pca>
this.pcaData = new Area()
</#if>
},
computed: {
importExcelUrl: function(){
<#noparse>return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;</#noparse>
}
},
methods: {
<#if list_need_pca>
getPcaText(code){
return this.pcaData.getText(code);
},
</#if>
initDictConfig(){
<#list columns as po>
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
<#if po.classType=='cat_tree' && list_need_category==true>
loadCategoryData({code:"${po.dictField?default('')}"}).then((res) => {
if (res.success) {
this.$set(this.dictOptions, '${po.fieldName}', res.result)
}
})
</#if>
</#if>
</#list>
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>

View File

@ -0,0 +1,505 @@
<#include "/common/utils.ftl">
<template>
<j-modal
:width="1200"
:visible="visible"
:maskClosable="false"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel">
<a-spin :spinning="confirmLoading">
<#assign form_date = false>
<#assign form_select = false>
<#assign form_select_multi = false>
<#assign form_select_search = false>
<#assign form_popup = false>
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#assign form_editor = false>
<#assign form_cat_tree = false>
<#assign form_cat_back = "">
<#assign form_pca = false>
<#assign form_md = false>
<#assign form_switch=false>
<#assign form_span = 24>
<a-tabs v-model="activeKey" @change="handleChangeTabs">
<!--主表区域 -->
<a-tab-pane tab="${tableVo.ftlDescription}" :key="refKeys[0]" :forceRender="true">
<a-form :form="form">
<a-row>
<#list columns as po>
<#if po.isShow =='Y' && po.fieldName != 'id'>
<#assign form_field_dictCode="">
<#if po.dictTable?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
<#elseif po.dictField?default("")?trim?length gt 1>
<#assign form_field_dictCode="${po.dictField}">
</#if>
<#if po.classType =='textarea'>
<a-col :span="24">
<a-form-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
<#else>
<a-col :xs="24" :sm="12">
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
</#if>
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" style="width: 100%"/>
<#elseif po.classType =='datetime'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<#elseif po.classType =='popup'>
<#assign form_popup=true>
<j-popup
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${Format.underlineToHump(po.dictText)}"
code="${po.dictTable}"
@callback="popupCallback"/>
<#elseif po.classType =='sel_depart'>
<#assign form_sel_depart=true>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" multi/>
<#elseif po.classType =='switch'>
<#assign form_switch=true>
<j-switch v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" <#if po.dictField?default("")?trim?length gt 1>:options="${po.dictField}"</#if>></j-switch>
<#elseif po.classType =='pca'>
<#assign form_pca=true>
<j-area-linkage type="cascader" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入省市区"/>
<#elseif po.classType =='markdown'>
<#assign form_md=true>
<j-markdown-editor v-decorator="['${po.fieldName}']" id="${po.fieldName}"></j-markdown-editor>
<#elseif po.classType =='password'>
<a-input-password v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" rows="4" placeholder="请输入${po.filedComment}"/>
<#elseif po.classType=='list' || po.classType=='radio'>
<#assign form_select = true>
<j-dict-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='list_multi' || po.classType=='checkbox'>
<#assign form_select_multi = true>
<j-multi-select-tag type="${po.classType}" v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<#elseif po.classType=='sel_search'>
<#assign form_select_search = true>
<j-search-select-tag v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" dict="${form_field_dictCode}" />
<#elseif po.classType=='cat_tree'>
<#assign form_cat_tree = true>
<j-category-select v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<#if po.dictText?default("")?trim?length gt 1>
<#assign form_cat_back = "${po.dictText}">
</#if>
<#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file'>
<#assign form_file = true>
<j-upload v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"></j-upload>
<#elseif po.classType=='image'>
<#assign form_image = true>
<j-image-upload isMultiple v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"></j-image-upload>
<#elseif po.classType=='umeditor'>
<#assign form_editor = true>
<j-editor v-decorator="['${po.fieldName}',{trigger:'input'}]"/>
<#elseif po.fieldDbType=='Blob'>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
<#if form_cat_tree && form_cat_back?length gt 1>
<a-form-item v-show="false">
<a-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-col>
</#if>
</#list>
</a-row>
</a-form>
</a-tab-pane>
<!--子表单区域 -->
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='1'>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true">
<${Format.humpToShortbar(sub.entityName)}-form ref="${sub.entityName?uncap_first}Form" @validateError="validateError"></${Format.humpToShortbar(sub.entityName)}-form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true">
<j-editable-table
:ref="refKeys[${sub_index+1}]"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"
:maxHeight="300"
:rowNumber="true"
:rowSelection="true"
:actionButton="true"/>
</a-tab-pane>
</#if>
</#list>
</a-tabs>
</a-spin>
</j-modal>
</template>
<script>
import pick from 'lodash.pick'
import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
import { validateDuplicateValue } from '@/utils/util'
import { VALIDATE_NO_PASSED, validateFormAndTables } from '@/utils/JEditableTableUtil'
<#list subTables as sub>
<#if sub.foreignRelationType =='1'>
import ${sub.entityName}Form from './${sub.entityName}Form.vue'
</#if>
</#list>
<#if form_date>
import JDate from '@/components/jeecg/JDate'
</#if>
<#if form_file>
import JUpload from '@/components/jeecg/JUpload'
</#if>
<#if form_image>
import JImageUpload from '@/components/jeecg/JImageUpload'
</#if>
<#if form_sel_depart>
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
</#if>
<#if form_sel_user>
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
</#if>
<#if form_select>
import JDictSelectTag from "@/components/dict/JDictSelectTag"
</#if>
<#if form_select_multi>
import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
</#if>
<#if form_select_search>
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
</#if>
<#if form_editor>
import JEditor from '@/components/jeecg/JEditor'
</#if>
<#if form_cat_tree>
import JCategorySelect from '@/components/jeecg/JCategorySelect'
</#if>
<#if form_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if form_md>
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
</#if>
<#if form_switch==true >
import JSwitch from '@/components/jeecg/JSwitch'
</#if>
export default {
name: '${entityName}Modal',
mixins: [JEditableTableMixin],
components: {
<#list subTables as sub>
<#if sub.foreignRelationType =='1'>
${sub.entityName}Form,
</#if>
</#list>
<#if form_date>
JDate,
</#if>
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
<#if form_sel_user>
JSelectUserByDep,
</#if>
<#if form_select>
JDictSelectTag,
</#if>
<#if form_select_multi>
JMultiSelectTag,
</#if>
<#if form_select_search>
JSearchSelectTag,
</#if>
<#if form_editor>
JEditor,
</#if>
<#if form_pca>
JAreaLinkage,
</#if>
<#if form_cat_tree>
JCategorySelect,
</#if>
<#if form_md>
JMarkdownEditor,
</#if>
<#if form_switch==true >
JSwitch,
</#if>
},
data() {
return {
labelCol: {
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
labelCol2: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol2: {
xs: { span: 24 },
sm: { span: 20 },
},
// 新增时子表默认添加几行空数据
addDefaultRowNum: 1,
<#include "/common/validatorRulesTemplate/main.ftl">
refKeys: ['${tableVo.entityName?uncap_first}',<#list subTables as sub>'${sub.entityName?uncap_first}', </#list>],
<#assign hasOne2Many = false>
tableKeys:[<#list subTables as sub><#if sub.foreignRelationType =='0'>'${sub.entityName?uncap_first}', <#assign hasOne2Many = true></#if></#list>],
activeKey: '${tableVo.entityName?uncap_first}',
<#list subTables as sub><#rt/>
// ${sub.ftlDescription}
${sub.entityName?uncap_first}Table: {
loading: false,
dataSource: [],
columns: [
<#if sub.foreignRelationType =='0'>
<#assign popupBackFields = "">
<#-- 循环子表的列 开始 -->
<#list sub.colums as col><#rt/>
<#if col.isShow =='Y'>
<#if col.filedComment !='外键' >
{
title: '${col.filedComment}',
key: '${col.fieldName}',
<#if col.classType =='date'>
type: FormTypes.date,
<#elseif col.classType =='datetime'>
type: FormTypes.datetime,
<#elseif "int,decimal,double,"?contains(col.classType)>
type: FormTypes.inputNumber,
<#elseif col.classType =='list' || col.classType =='radio'>
type: FormTypes.select,
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='list_multi' || col.classType =='checkbox'>
type: FormTypes.list_multi,
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='sel_search'>
type: FormTypes.sel_search,
<#if col.dictTable?default("")?trim?length gt 1>
dictCode:"${col.dictTable},${col.dictText},${col.dictField}",
<#else>
dictCode:"${col.dictField}",
</#if>
<#elseif col.classType =='image'>
type: FormTypes.image,
token:true,
responseName:"message",
<#elseif col.classType =='file'>
type: FormTypes.file,
token:true,
responseName:"message",
<#elseif col.classType =='popup'>
<#if popupBackFields?length gt 0>
<#assign popupBackFields = "${popupBackFields}"+","+"${col.dictText}">
<#else>
<#assign popupBackFields = "${col.dictText}">
</#if>
type: FormTypes.popup,
popupCode:"${col.dictTable}",
destFields:"${Format.underlineToHump(col.dictText)}",
orgFields:"${col.dictField}",
<#elseif col.fieldDbType=='int' || col.fieldDbType=='double' || col.fieldDbType=='BigDecimal'>
type: FormTypes.inputNumber,
<#else>
type: FormTypes.input,
</#if>
<#if col.classType =='list_multi' || col.classType =='checkbox'>
width:"250px",
<#else>
width:"200px",
</#if>
<#if col.classType =='file'>
placeholder: '请选择文件',
<#else>
placeholder: '请输入${'$'}{title}',
</#if>
defaultValue: '',
<#-- 子表的校验 -->
<#assign subFieldValidType = col.fieldValidType!''>
<#-- 非空校验 -->
<#if col.nullable == 'N' || subFieldValidType == '*'>
validateRules: [{ required: true, message: '${'$'}{title}不能为空' }],
<#-- 其他情况下,只要有值就被认为是正则校验 -->
<#elseif subFieldValidType?length gt 0>
<#assign subMessage = '格式不正确'>
<#if subFieldValidType == 'only' >
<#assign subMessage = '不能重复'>
</#if>
validateRules: [{ pattern: "${subFieldValidType}", message: "${'$'}{title}${subMessage}" }],
</#if>
},
</#if>
</#if>
</#list>
<#-- 循环子表的列 结束 -->
<#-- 处理popup的隐藏列 -->
<#if popupBackFields?length gt 0>
<#list popupBackFields?split(",") as item>
<#if item?length gt 0>
<#assign tempItemFlag = true>
<#list sub.colums as col>
<#if col.isShow =='Y' && col.fieldName == item>
<#assign tempItemFlag = false>
</#if>
</#list>
<#if tempItemFlag>
{
title: '${item}',
key: '${item}',
type:"hidden"
},
</#if>
</#if>
</#list>
</#if>
</#if>
]
},
</#list>
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",
${tableVo.entityName?uncap_first}: {
list: '/${entityPackage}/${entityName?uncap_first}/queryById'
},
<#list subTables as sub><#rt/>
${sub.entityName?uncap_first}: {
list: '/${entityPackage}/${entityName?uncap_first}/query${sub.entityName}ByMainId'
},
</#list>
}
}
},
methods: {
getAllTable() {
<#if hasOne2Many==true>
let values = this.tableKeys.map(key => getRefPromise(this, key))
return Promise.all(values)
<#else>
return new Promise(resolve => {
resolve([]);
})
</#if>
},
/** 调用完edit()方法之后会自动调用此方法 */
editAfter() {
let fieldval = pick(this.model<#list columns as po><#if po.fieldName !='id'><#if po.fieldDbType=='Blob'>,'${po.fieldName}String'<#else>,'${po.fieldName}'</#if></#if></#list>)
this.$nextTick(() => {
this.form.setFieldsValue(fieldval)
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='1'>
this.$refs.${sub.entityName?uncap_first}Form.initFormData(this.url.${sub.entityName?uncap_first}.list,this.model.id)
</#if>
</#list>
})
// 加载子表数据
if (this.model.id) {
let params = { id: this.model.id }
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='0'>
this.requestSubTableData(this.url.${sub.entityName?uncap_first}.list, params, this.${sub.entityName?uncap_first}Table)
</#if>
</#list>
}
},
/** 整理成formData */
classifyIntoFormData(allValues) {
let main = Object.assign(this.model, allValues.formValue)
return {
...main, // 展开
<#assign subManyIndex = 0>
<#list subTables as sub><#rt/>
<#if sub.foreignRelationType =='0'>
${sub.entityName?uncap_first}List: allValues.tablesValue[${subManyIndex}].values,
<#assign subManyIndex = subManyIndex+1>
<#else>
${sub.entityName?uncap_first}List: this.$refs.${sub.entityName?uncap_first}Form.getFormData(),
</#if>
</#list>
}
},
/** 确定按钮点击事件 */
handleOk() {
/** 触发表单验证 */
this.getAllTable().then(tables => {
return validateFormAndTables(this.form, tables)
}).then(allValues => {
if (typeof this.classifyIntoFormData !== 'function') {
throw this.throwNotFunction('classifyIntoFormData')
}
console.log("this.classifyIntoFormData",typeof this.classifyIntoFormData)
let formData = this.classifyIntoFormData(allValues)
// 发起请求
return this.request(formData)
}).catch(e => {
if (e.error === VALIDATE_NO_PASSED) {
// 如果有未通过表单验证的子表就自动跳转到它所在的tab
this.activeKey = e.index == null ? this.refKeys[0] : this.refKeys[e.index+1]
} else {
console.error(e)
}
})
},
validateError(msg){
this.$message.error(msg)
},
popupCallback(row){
this.form.setFieldsValue(pick(row<#list columns as po><#if po.fieldName !='id'><#if po.fieldDbType=='Blob'>,'${po.fieldName}String'<#else>,'${po.fieldName}'</#if></#if></#list>))
},
<#if form_cat_tree>
handleCategoryChange(value,backObj){
this.form.setFieldsValue(backObj)
}
</#if>
}
}
</script>
<style scoped>
</style>

View File

@ -68,7 +68,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -82,7 +82,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -96,7 +96,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -110,7 +110,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.removeById(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -124,7 +124,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -138,7 +138,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
/**

View File

@ -31,7 +31,7 @@ public class ${entityName} {
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -72,7 +72,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
@ -86,7 +86,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -100,7 +100,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -113,7 +113,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.removeById(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -127,7 +127,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -141,7 +141,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
/**

View File

@ -27,7 +27,7 @@ public class ${entityName} implements Serializable {
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -82,7 +82,7 @@ public class ${entityName}Controller {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -98,7 +98,7 @@ public class ${entityName}Controller {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.saveMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -114,7 +114,7 @@ public class ${entityName}Controller {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.updateMain(${entityName?uncap_first}, <#list subTables as sub>${entityName?uncap_first}Page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -128,7 +128,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -142,7 +142,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -156,7 +156,7 @@ public class ${entityName}Controller {
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
<#list subTables as sub>
@ -171,7 +171,7 @@ public class ${entityName}Controller {
@GetMapping(value = "/query${sub.entityName}ByMainId")
public Result<?> query${sub.entityName}ListByMainId(@RequestParam(name="id",required=true) String id) {
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(id);
return Result.ok(${sub.entityName?uncap_first}List);
return Result.OK(${sub.entityName?uncap_first}List);
}
</#list>
@ -232,7 +232,7 @@ public class ${entityName}Controller {
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.ok("文件导入成功!数据行数:" + list.size());
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -244,7 +244,7 @@ public class ${entityName}Controller {
}
}
}
return Result.ok("文件导入失败!");
return Result.OK("文件导入失败!");
}
}

View File

@ -26,7 +26,7 @@ public class ${entityName} implements Serializable {
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
</#if>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -29,7 +29,7 @@ public class ${subTab.entityName} implements Serializable {
<#list subTab.originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -81,7 +81,7 @@ public class ${entityName}Controller {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
Page<${entityName}> page = new Page<${entityName}>(pageNo, pageSize);
IPage<${entityName}> pageList = ${entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}
/**
@ -97,7 +97,7 @@ public class ${entityName}Controller {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return Result.ok("添加成功!");
return Result.OK("添加成功!");
}
/**
@ -113,7 +113,7 @@ public class ${entityName}Controller {
${entityName} ${entityName?uncap_first} = new ${entityName}();
BeanUtils.copyProperties(${entityName?uncap_first}Page, ${entityName?uncap_first});
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return Result.ok("编辑成功!");
return Result.OK("编辑成功!");
}
/**
@ -127,7 +127,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.delMain(id);
return Result.ok("删除成功!");
return Result.OK("删除成功!");
}
/**
@ -141,7 +141,7 @@ public class ${entityName}Controller {
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
/**
@ -155,7 +155,7 @@ public class ${entityName}Controller {
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
return Result.ok(${entityName?uncap_first});
return Result.OK(${entityName?uncap_first});
}
//===========================以下是子表信息操作相关API====================================
@ -194,9 +194,9 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
QueryWrapper<${sub.entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${sub.entityName?uncap_first}, req.getParameterMap());
Page<${sub.entityName}> page = new Page<${sub.entityName}>(pageNo, pageSize);
IPage<${sub.entityName}> pageList = ${sub.entityName?uncap_first}Service.page(page, queryWrapper);
return Result.ok(pageList);
return Result.OK(pageList);
}else{
return Result.ok();
return Result.OK();
}
}
<#-- update-end--Author:kangxiaolin Date:20190905 for[442]主子表分开维护,生成的代码子表的分页改为真实的分页-------------------- -->
@ -212,7 +212,7 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
@PostMapping(value = "/add${sub.entityName}")
public Result<?> add${sub.entityName}(@RequestBody ${sub.entityName} ${sub.entityName?uncap_first}) {
${sub.entityName?uncap_first}Service.save(${sub.entityName?uncap_first});
return Result.ok("添加${sub.ftlDescription}成功!");
return Result.OK("添加${sub.ftlDescription}成功!");
}
/**
@ -226,7 +226,7 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
@PutMapping("/edit${sub.entityName}")
public Result<?> edit${sub.entityName}(@RequestBody ${sub.entityName} ${sub.entityName?uncap_first}) {
${sub.entityName?uncap_first}Service.updateById(${sub.entityName?uncap_first});
return Result.ok("编辑${sub.ftlDescription}成功!");
return Result.OK("编辑${sub.ftlDescription}成功!");
}
/**
@ -240,7 +240,7 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
@DeleteMapping(value = "/delete${sub.entityName}")
public Result<?> delete${sub.entityName}(@RequestParam(name = "id", required = true) String id) {
${sub.entityName?uncap_first}Service.removeById(id);
return Result.ok("删除${sub.ftlDescription}成功!");
return Result.OK("删除${sub.ftlDescription}成功!");
}
/**
@ -257,7 +257,7 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
return Result.error("参数不识别!");
}
this.${sub.entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
return Result.OK("批量删除成功!");
}
@ -320,7 +320,7 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
BeanUtils.copyProperties(page, po);
${entityName?uncap_first}Service.saveMain(po, <#list subTables as sub>page.get${sub.entityName}List()<#if sub_has_next>,</#if></#list>);
}
return Result.ok("文件导入成功!数据行数:" + list.size());
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -332,6 +332,6 @@ ${sub.entityName?uncap_first}.get${key}()!=null<#rt/>
}
}
}
return Result.ok("文件导入失败!");
return Result.OK("文件导入失败!");
}
}

View File

@ -26,7 +26,7 @@ public class ${entityName} implements Serializable {
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
</#if>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -28,7 +28,7 @@ public class ${subTab.entityName} implements Serializable {
<#list subTab.originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ID_WORKER_STR)
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldType =='java.util.Date'>
<#if po.fieldDbType =='date'>

View File

@ -1,7 +1,7 @@
#code_generate_project_path
project_path=E:\\eclipse2018-workspace\\jeecg-boot
project_path=E:\\workspace-ui\\jeecg-boot-framework\\jeecg-boot-module-demo
#bussi_package[User defined]
bussi_package=org.jeecg.modules.demo
bussi_package=org.jeecg.modules.demo3
#default code path
@ -26,5 +26,5 @@ db_filed_convert=true
page_search_filed_num=1
#page_filter_fields
page_filter_fields=create_time,create_by,update_time,update_by
#exclude table prefix
exclude_table=act_,ext_act_,design_,onl_,sys_,qrtz_,jmreport_,jimu_

View File

@ -1,6 +1,6 @@
#mysql
diver_name=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
diver_name=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username=root
password=root
database_name=jeecg-boot

View File

@ -6,9 +6,9 @@
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<withJansi>true</withJansi>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
</encoder>
</appender>
@ -20,7 +20,7 @@
<FileNamePattern>${LOG_HOME}/jeecgboot-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>20MB</maxFileSize>
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符 -->

View File

@ -1,66 +0,0 @@
body,html{width:100%;height:100%;margin:0px;padding:0px;font-size:12px;color:#555;background-color:#000;font-family:'微软雅黑'}
#main{width:4352px;height:1536px;display:inline-block; background:url(../images/screenbg_design1.jpg) left top no-repeat}
/*年月日文字*/
#currentYear{width:213px;height:107px;position:absolute;left:430px;top:100px;color:#FFF;font-size:36px; font-family:'微软雅黑';text-align:center}
#currentMonth{width:213px;height:107px;position:absolute;left:1504px;top:75px;color:#FFF;font-size:36px; font-family:'微软雅黑';text-align:center}
#currentDay{width:213px;height:107px;position:absolute;left:2574px;top:100px;color:#FFF;font-size:36px; font-family:'微软雅黑';text-align:center}
/*年的进度条*/
#y_gauge1{width:250px;height:250px;position:absolute;left:60px;top:200px;}
#y_gauge2{width:250px;height:250px;position:absolute;left:290px;top:200px;}
#y_gauge3{width:250px;height:250px;position:absolute;left:530px;top:200px;}
#y_gauge4{width:250px;height:250px;position:absolute;left:770px;top:200px;}
/*月的进度条*/
#m_gauge1{width:250px;height:250px;position:absolute;left:1140px;top:130px;}
#m_gauge2{width:250px;height:250px;position:absolute;left:1370px;top:130px;}
#m_gauge3{width:250px;height:250px;position:absolute;left:1610px;top:130px;}
#m_gauge4{width:250px;height:250px;position:absolute;left:1850px;top:130px;}
/*日的进度条*/
#d_gauge1{width:250px;height:250px;position:absolute;left:2210px;top:200px;}
#d_gauge2{width:250px;height:250px;position:absolute;left:2440px;top:200px;}
#d_gauge3{width:250px;height:250px;position:absolute;left:2680px;top:200px;}
#d_gauge4{width:250px;height:250px;position:absolute;left:2920px;top:200px;}
/*监控的仪表盘*/
#gauge1{width:250px;height:250px;position:absolute;left:2200px;top:1050px;}
#gauge2{width:250px;height:250px;position:absolute;left:2550px;top:1050px;}
#gauge3{width:250px;height:250px;position:absolute;left:2910px;top:1050px;}
#gauge4{width:250px;height:250px;position:absolute;left:2380px;top:1190px;}
#gauge5{width:250px;height:250px;position:absolute;left:2730px;top:1190px;}
/*仪表盘文字*/
.gaugeTitle{width:250px;height:40px;position:absolute;left:0px;top:200px;color:#B7E1FF;font-size:24px;display:inline-block;text-align:center;font-family:Arial;}
/*地图*/
#map{width:1100px;height:800px;position:absolute;left:0px;top:620px;display:inline-block;color:#E1E1E1;font-size:24px;}
#plan{width:900px;height:420px;position:absolute;left:1170px;top:520px;display:inline-block;color:#E1E1E1;font-size:24px;}
#quality{width:900px;height:420px;position:absolute;left:1170px;top:1030px;display:inline-block;color:#E1E1E1;font-size:24px;}
#orderTable{width:1000px;height:430px;position:absolute;left:2160px;top:930px;display:inline-block}
#orderTable table{width:100%;color:#666;font-size:24px}
#orderTable table td{text-align:center;}
#orderTable table .head{height:80px;font-size:24px;color:#FFF}
#orderTable table .row2{color:#000}
#orderTable table .row1{background-color:#CCC}
#orderMessage{width:800px;position:absolute;left:33px;top:1420px;display:inline-block;color:#E1E1E1;font-size:24px}
/*生产情况展示表*/
#produce{width:1000px;height:380px;position:absolute;left:2190px;top:600px;display:inline-block;color:#B7E2FF;font-size:24px;}
#produce table{width:100%;font-size:24px;}
#produce table td{text-align:center;border:1px solid #069}
#produce table .row1{}
#produce table .row2{}
/*视频*/
#video{width:960px;height:540px;position:absolute;left:3280px;top:140px;display:inline-block;}
/*监控视频*/
#Monitor{width:960px;height:540px;position:absolute;left:3280px;top:940px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*刷新时间*/
#refresh{width:800px;position:absolute;left:3350px;top:40px;display:inline-block;color:#FFF;font-size:24px;}

View File

@ -1,62 +0,0 @@
body,html{width:100%;height:100%;margin:0px;padding:0px;font-size:12px;color:#555;background-color:#000;font-family:'微软雅黑'}
#main{width:4352px;height:1536px;display:inline-block; background:url(../images/war_room_main.jpg) left top no-repeat}
/*下钻按钮*/
.contentButton{width:218px;height:100px;position:absolute;}
.contentButton a{width:218px;height:100px;display:inline-block; background:url(../images/content_comm.png) no-repeat top left}
.contentButton a:hover{width:218px;height:100px;display:inline-block; background:url(../images/content_down.png) no-repeat top left}
.contentButton .a1{width:218px;height:100px;display:inline-block; background:url(../images/content_comm1.png) no-repeat top left}
.contentButton .a1:hover{width:218px;height:100px;display:inline-block; background:url(../images/content_down1.png) no-repeat top left}
/*弹出窗口*/
#popWindow{width:2200px;height:1000px;display:inline-block;position:absolute;top:240px;left:1070px;background-color:#06274A;border:1px solid #09f}
/*年的进度条*/
#y_gauge1{width:250px;height:250px;position:absolute;left:60px;top:200px;}
#y_gauge2{width:250px;height:250px;position:absolute;left:290px;top:200px;}
#y_gauge3{width:250px;height:250px;position:absolute;left:530px;top:200px;}
#y_gauge4{width:250px;height:250px;position:absolute;left:770px;top:200px;}
/*螺旋DNA*/
#orderStatus{width:1000px;height:320px;position:absolute;left:80px;top:460px;}
/*监控的仪表盘*/
#gauge1{width:250px;height:250px;position:absolute;left:2200px;top:280px;}
#gauge2{width:250px;height:250px;position:absolute;left:2550px;top:280px;}
#gauge3{width:250px;height:250px;position:absolute;left:2910px;top:280px;}
#gauge4{width:250px;height:250px;position:absolute;left:2380px;top:550px;}
#gauge5{width:250px;height:250px;position:absolute;left:2730px;top:550px;}
/*仪表盘文字*/
.gaugeTitle{width:250px;height:40px;position:absolute;left:0px;top:200px;color:#B7E1FF;font-size:24px;display:inline-block;text-align:center;font-family:Arial;}
/*地图*/
#map{width:1100px;height:800px;position:absolute;left:1080px;top:170px;display:inline-block;color:#E1E1E1;font-size:24px;}
#productPie{width:1000px;height:680px;position:absolute;left:2210px;top:260px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*业务进展图*/
#businessProgress{width:1000px;height:640px;position:absolute;left:3330px;top:180px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*计划完成情况*/
#plan{width:1000px;height:400px;position:absolute;left:80px;top:1020px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*质量指标分析*/
#quality{width:1000px;height:400px;position:absolute;left:1170px;top:1020px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*舆情文字云*/
#wordCloud{width:900px;height:420px;position:absolute;left:3330px;top:1000px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*投诉情况展示表*/
#produce{width:900px;height:380px;position:absolute;left:2250px;top:1050px;display:inline-block;color:#B7E2FF;font-size:24px;}
#produce table{width:100%;font-size:24px;}
#produce table td{text-align:center;border:1px solid #069}
#produce table .row1{}
#produce table .row2{}
/*视频*/
#video{width:960px;height:540px;position:absolute;left:3280px;top:140px;display:inline-block;}
/*监控视频*/
#Monitor{width:960px;height:540px;position:absolute;left:3280px;top:940px;display:inline-block;color:#E1E1E1;font-size:24px;}
/*刷新时间*/
#refresh{width:800px;position:absolute;left:3350px;top:40px;display:inline-block;color:#FFF;font-size:24px;}

View File

@ -1,836 +0,0 @@
//计划完成表的当前所选
var indexnum = 0;
var color=['#F35331','#2499F8','#3DF098','#33B734'];
var fontColor='#FFF';
//定义进度条组件和属性
var y_gauge1 =null;
var y_gauge2 =null;
var y_gauge3 =null;
var y_gauge4 =null;
var m_gauge1 =null;
var m_gauge2 =null;
var m_gauge3 =null;
var m_gauge4 =null;
var d_gauge1 =null;
var d_gauge2 =null;
var d_gauge3 =null;
var d_gauge4 =null;
var option_Progress =null;
//定义仪表盘组件和属性
var gauge1 =null;
var gauge2 =null;
var gauge3 =null;
var gauge4 =null;
var gauge5 =null;
var option_gauge =null;
//生产质量堆积图组件和属性
var quality_chart = null;
var quality_option=null;
//生产计划折线图组件和属性
var plan_chart = null;
var plan_option=null;
//环形图的风格定义
var dataStyle = {
normal: {
label: {show:false},
labelLine: {show:false}
}
};
var placeHolderStyle = {
normal : {
color: 'rgba(0,0,0,0.1)',
label: {show:false},
labelLine: {show:false}
},
emphasis : {
color: 'rgba(0,0,0,0)'
}
};
//最大订单号
var lastOrderNumber=1;
$(document).ready(function ()
{
//环形进度条设置对象
option_Progress={
title : {
text: '目前进度',
subtext: '50%',
x: 'center',
y: 90,
itemGap: 10,
textStyle : {
color : '#B7E1FF',
fontWeight: 'normal',
fontFamily : '微软雅黑',
fontSize : 24
},
subtextStyle:{
color: '#B7E1FF',
fontWeight: 'bolder',
fontSize:24,
fontFamily : '微软雅黑'
}
},
series : [{
type : 'pie',
center : ['50%', '50%'],
radius : [75,90],
x: '0%',
tooltip:{show:false},
data : [{
name:'达成率',
value:79,
itemStyle:{color :'rgba(0,153,255,0.8)'},
hoverAnimation: false,
label : {
show : false,
position : 'center',
textStyle: {
fontFamily:'微软雅黑',
fontWeight: 'bolder',
color:'#B7E1FF',
fontSize:24
}
},
labelLine : {
show : false
}
},
{
name:'79%',
value:21,
itemStyle:{color: 'rgba(0,153,255,0.1)'},
hoverAnimation: false,
label : {
show : false,
position : 'center',
padding:20,
textStyle: {
fontFamily:'微软雅黑',
fontSize: 24,
color:'#B7E1FF'
}
},
labelLine : {
show : false
}
}]
},
{
type : 'pie',
center : ['50%', '50%'],
radius : [95,100],
x: '0%',
hoverAnimation: false,
data : [{
value:100,
itemStyle:{color :'rgba(0,153,255,0.3)'},
label : {show : false},
labelLine : {show : false}
}]
},
{
type : 'pie',
center : ['50%', '50%'],
radius : [69,70],
x: '0%',
hoverAnimation: false,
data : [{
value:100,
itemStyle:{color :'rgba(0,153,255,0.3)'},
label : {show : false},
labelLine : {show : false}
}]
}]
};
//年仪表盘
y_gauge1 = echarts.init(document.getElementById('y_gauge1'));
y_gauge2 = echarts.init(document.getElementById('y_gauge2'));
y_gauge3 = echarts.init(document.getElementById('y_gauge3'));
y_gauge4 = echarts.init(document.getElementById('y_gauge4'));
//月仪表盘
m_gauge1 = echarts.init(document.getElementById('m_gauge1'));
m_gauge2 = echarts.init(document.getElementById('m_gauge2'));
m_gauge3 = echarts.init(document.getElementById('m_gauge3'));
m_gauge4 = echarts.init(document.getElementById('m_gauge4'));
//日仪表盘
d_gauge1 = echarts.init(document.getElementById('d_gauge1'));
d_gauge2 = echarts.init(document.getElementById('d_gauge2'));
d_gauge3 = echarts.init(document.getElementById('d_gauge3'));
d_gauge4 = echarts.init(document.getElementById('d_gauge4'));
//监控仪表盘
option_gauge = {
title: {
text: '', //标题文本内容
},
toolbox: { //可视化的工具箱
show: false,
},
tooltip: { //弹窗组件
formatter: "{a} <br/>{b} : {c}%"
},
series: [{
type: 'gauge',
axisLine: {// 坐标轴线
lineStyle: { // 属性lineStyle控制线条样式
color: [
[0.2, color[0]],
[0.8, color[1]],
[1, color[2]]
],
width: 18
}
},
splitLine: { // 分隔线
show:true,
length: 18,
lineStyle: {
color: '#28292D',
width: 1
}
},
axisTick : { //刻度线样式(及短线样式)
show:false,
lineStyle: {
color: 'auto',
width: 1
},
length : 20
},
axisLabel : {
color:'#FFF',
fontSize:14,
fontFamily:'Verdana, Geneva, sans-serif'
},
title: {
textStyle: { // 其余属性默认使用全局文本样式详见TEXTSTYLE
fontWeight: 'bolder',
fontSize: 20,
color: '#FFF'
},
offsetCenter: [0, '30%']
},
pointer: {
width: 5,
color: '#F00',
shadowColor: '#FF0',
shadowBlur: 10
},
detail: {
show:false,
formatter:'{value}%',
textStyle:
{
fontFamily:'Arial',
color: '#000',
fontSize:'32px'
},
offsetCenter: [0, '90%']
},
data: [{value: 45, name: '水'}]
}]
};
gauge1 = echarts.init(document.getElementById('gauge1'));
gauge2 = echarts.init(document.getElementById('gauge2'));
gauge3 = echarts.init(document.getElementById('gauge3'));
gauge4 = echarts.init(document.getElementById('gauge4'));
gauge5 = echarts.init(document.getElementById('gauge5'));
option_gauge.series[0].axisLine.lineStyle.color=[[0.2, color[0]],[0.8, color[1]],[1, color[2]]];
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="";
$('#vg1').html(option_gauge.series[0].data[0].value);
gauge1.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="";
$('#vg2').html(option_gauge.series[0].data[0].value);
gauge2.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="天然气";
$('#vg3').html(option_gauge.series[0].data[0].value);
gauge3.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="压缩空气";
$('#vg4').html(option_gauge.series[0].data[0].value);
gauge4.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="蒸汽";
$('#vg5').html(option_gauge.series[0].data[0].value);
gauge5.setOption(option_gauge);
//生产质量堆积图
quality_chart = echarts.init(document.getElementById('quality'));
quality_option={
title: {
show:false,
text: 'AUDIT',
left: 'center',
textStyle: {
color: '#F00',
fontSize:32
}
},
xAxis: {
data: ['1月10日','2月10日','3月10日','4月10日','5月10日','6月10日'],
axisLabel: {
textStyle: {
color: '#B7E1FF',
fontSize:24
}
},
axisLine:{
lineStyle:{
color:'#09F'
}
},
axisTick:{
lineStyle:{
color:'#09F'
}
}
},
yAxis: {
inverse: false,
splitArea: {show: false},
axisLine: {show: false},
axisTick: {show: false},
axisLabel: {
textStyle: {
color: '#B7E1FF',
fontSize:24,
fontFamily:'Arial',
}
},
splitLine :{
lineStyle:{
color:'#09F'
}
}
},
grid: {
left: 100
},
tooltip: {
trigger: 'item',
textStyle: {
color: '#B7E1FF',
fontSize:24
}
},
legend:{
show:false,
top: 'bottom',
textStyle: {
color: '#F00',
fontSize:24,
fontFamily:'微软雅黑'
},
data:['AUDIT分数1','AUDIT分数']
},
series: [
{
name: 'AUDIT分数1',
type: 'bar',
stack: 'one',
itemStyle:
{
normal: {color: color[1]}
},
barWidth : 60,
data:[2200,2900,3680,2200,2900,3680]
},
{
name: 'AUDIT分数',
type: 'bar',
stack: 'one',
itemStyle: {
normal: {
color: '#F90',
label: {
show: true,
position: 'insideTop',
textStyle: {
color: '#000',
fontSize:24
}
}
}
},
barWidth : 50,
data: [1800,1100,320,1800,1100,320]
}
]
};
quality_chart.setOption(quality_option);
//生产计划折线图
var plan_data1=[];
var plan_data2=[];
var plan_xAxis=[];
for (var i = 1; i <= 7; i++) {
plan_xAxis.push("3月"+i+"");
plan_data1.push(Math.round(Math.random() * 100));
plan_data2.push(Math.round(Math.random() * 100));
}
plan_chart = echarts.init(document.getElementById('plan'));
plan_option={
xAxis: {
data:plan_xAxis,
axisLabel: {
textStyle: {
color: '#B7E1FF',
fontSize:24
}
},
axisLine:{
lineStyle:{
color:'#09F'
}
},
axisTick:{
lineStyle:{
color:'#09F'
}
}
},
yAxis: {
inverse: false,
splitArea: {show: false},
axisLine: {show: false},
axisTick: {show: false},
axisLabel: {
textStyle: {
color: '#B7E1FF',
fontSize:24,
fontFamily:'Arial',
}
},
splitLine :{
lineStyle:{
color:'#09F'
}
}
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#FFF',
fontSize:24
}
},
grid: {
left: 100
},
legend:{
show:false,
top: 'bottom',
textStyle: {
color: '#F00',
fontSize:24
},
data:['计划完成数','实际完成数']
},
series: [
{
name: '计划完成数',
type: 'bar',
itemStyle:
{
normal: {color: color[1]},
emphasis: {color: color[2]}
},
barWidth : 40,
data:plan_data1
},
{
name: '实际完成数',
type: 'line',
itemStyle: {
normal: {
color: '#F90',
label: {
show: true,
position: 'top',
textStyle: {
color: '#CCC',
fontSize:24
}
},
lineStyle:{
color:'#F90',
width:4
}
},
emphasis: {
color: '#FF0'
}
},
symbolSize: 24,
data: plan_data2
}
]
};
plan_chart.setOption(plan_option);
//轮番显示tips
function clock(){
showToolTip_highlight(plan_chart);
}
setInterval(clock, 5000);
//地图开始
var map_chart = echarts.init(document.getElementById('map'));
var CCData = [
[{name:'长春'}, {name:'上海',value:95}],
[{name:'长春'}, {name:'广州',value:90}],
[{name:'长春'}, {name:'大连',value:80}],
[{name:'长春'}, {name:'南宁',value:70}],
[{name:'长春'}, {name:'南昌',value:60}],
[{name:'长春'}, {name:'拉萨',value:50}],
[{name:'长春'}, {name:'长春',value:40}],
[{name:'长春'}, {name:'包头',value:30}],
[{name:'长春'}, {name:'重庆',value:20}],
[{name:'长春'}, {name:'北京',value:10}]
];
var series = [];
[['长春', CCData]].forEach(function (item, i) {
series.push({
name: '一汽汽车销售',
type: 'lines',
zlevel: 1,
effect: {
show: true,
period: 6,
trailLength: 0.7,
color: '#FF0',
symbolSize: 3
},
lineStyle: {
normal: {
color: '#000',
width: 0,
curveness: 0.2
}
},
data: convertData(item[1])
},
{
name: '一汽汽车销售',
type: 'lines',
zlevel: 2,
symbol: ['none', 'arrow'],
symbolSize: 10,
lineStyle: {
normal: {
color: '#FF0',
width: 1,
opacity: 0.6,
curveness: 0.2
}
},
data: convertData(item[1])
},
{
name: '一汽汽车销售',
type: 'effectScatter',
coordinateSystem: 'geo',
zlevel: 2,
rippleEffect: {
brushType: 'stroke'
},
label: {
normal: {
show: true,
position: 'right',
formatter: '{b}'
}
},
symbolSize: function (val) {
return 15;
},
itemStyle: {
normal: {
color: '#FFF',
label: {
show: true,
position: 'top',
textStyle: {
color: '#FFF',
fontSize:24
}
}
}
},
data: item[1].map(function (dataItem) {
return {
name: dataItem[1].name,
value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
};
})
});
});
map_option = {
backgroundColor: '',
title : {
show:false,
text: '一汽汽车销售地域分布示意图',
subtext: '截至2018年05月04日',
left: 'center',
top:10,
textStyle : {
color: '#09F',
fontSize:32
},
subtextStyle:{
color: '#09F',
fontSize:24
}
},
tooltip : {
trigger: 'item'
},
legend: {
show:false,
orient: 'vertical',
top: 'bottom',
left: 'right',
data:['一汽汽车销售'],
textStyle: {
color: '#000'
},
selectedMode: 'single'
},
geo: {
map: 'china',
label: {
emphasis: {
show: false
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#09F',
borderColor: '#09F',
opacity:0.5
},
emphasis: {
areaColor: '#09F',
borderColor: '#09F',
opacity:0.8
}
}
},
series: series
};
map_chart.setOption(map_option, true);
resresh();
//开始定时刷新
setInterval(resresh, 5*1000);
});
var convertData = function (data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var dataItem = data[i];
var fromCoord = geoCoordMap[dataItem[0].name];
var toCoord = geoCoordMap[dataItem[1].name];
if (fromCoord && toCoord) {
res.push({
fromName: dataItem[0].name,
toName: dataItem[1].name,
coords: [fromCoord, toCoord]
});
}
}
return res;
};
function showToolTip_highlight(mychart)
{
var echartObj = mychart;
// 高亮当前图形
var highlight =setInterval(function()
{
echartObj.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: indexnum
});
echartObj.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: indexnum
});
clearInterval(highlight);
indexnum = indexnum + 1;
if(indexnum>=7) indexnum=0;
},1000);
}
//定时刷新数据
function resresh()
{
var myDate = new Date();
// $('#refresh').html("<img src=\"images/wait.gif\" align=\"absmiddle\"><span>数据刷新中...</span>");
//年月日刷新
$('#currentYear').html(myDate.getFullYear()+"");
$('#currentMonth').html(insertZero(myDate.getMonth()+1)+"");
$('#currentDay').html(insertZero(myDate.getDate())+"");
$('#currentDate').html(myDate.getFullYear()+"/"+insertZero(myDate.getMonth()+1)+"/"+insertZero(myDate.getDate()));
option_gauge.series[0].axisLabel.show=true;
option_gauge.series[0].axisLine.lineStyle.color=[[0.2, color[0]],[0.8, color[1]],[1, color[2]]]
var maxg=Math.round(Math.random()*500)+400;
var n1=Math.round(Math.random()*(maxg-100))+100;
var n2=Math.round(Math.random()*(n1-50))+50;
var n3=(n2/maxg*100).toFixed(2);
//年进度条
option_Progress.title.text ="计划生产";
option_Progress.series[0].data[0].value = maxg;
option_Progress.title.subtext =maxg+"";
option_Progress.series[0].data[1].value =0;
y_gauge1.setOption(option_Progress);
option_Progress.title.text ="已接订单";
option_Progress.series[0].data[0].value = n1;
option_Progress.title.subtext =n1+"";
option_Progress.series[0].data[1].value =(maxg-n1);
y_gauge2.setOption(option_Progress);
option_Progress.title.text ="已经完成";
option_Progress.series[0].data[0].value = n2;
option_Progress.title.subtext =n2+"";
option_Progress.series[0].data[1].value =(maxg-n2);
y_gauge3.setOption(option_Progress);
option_Progress.title.text ="计划完成率";
option_Progress.series[0].data[0].value = n3;
option_Progress.title.subtext =n3+"%";
option_Progress.series[0].data[1].value =(100-n3);
y_gauge4.setOption(option_Progress);
//月进度条
maxg=Math.round(Math.random()*maxg)+1;
n1=Math.round(Math.random()*maxg)+1;
n2=Math.round(Math.random()*n1);
n3=(n2/maxg*100).toFixed(2);
option_Progress.title.text ="计划生产";
option_Progress.series[0].data[0].value = maxg;
option_Progress.title.subtext =maxg+"";
option_Progress.series[0].data[1].value =0;
m_gauge1.setOption(option_Progress);
option_Progress.title.text ="已接订单";
option_Progress.series[0].data[0].value = n1;
option_Progress.title.subtext =n1+"";
option_Progress.series[0].data[1].value =(maxg-n1);
m_gauge2.setOption(option_Progress);
option_Progress.title.text ="已经完成";
option_Progress.series[0].data[0].value = n2;
option_Progress.title.subtext =n2+"";
option_Progress.series[0].data[1].value =(maxg-n2);
m_gauge3.setOption(option_Progress);
option_Progress.title.text ="计划完成率";
option_Progress.series[0].data[0].value = n3;
option_Progress.title.subtext =n3+"%";
option_Progress.series[0].data[1].value =(100-n3);
m_gauge4.setOption(option_Progress);
//日进度条
maxg=Math.round(Math.random()*maxg)+1;
n1=Math.round(Math.random()*maxg)+1;
n2=Math.round(Math.random()*n1);
n3=(n2/maxg*100).toFixed(2);
option_Progress.title.text ="计划生产";
option_Progress.series[0].data[0].value = maxg;
option_Progress.title.subtext =maxg+"";
option_Progress.series[0].data[1].value =0;
d_gauge1.setOption(option_Progress);
option_Progress.title.text ="已接订单";
option_Progress.series[0].data[0].value = n1;
option_Progress.title.subtext =n1+"";
option_Progress.series[0].data[1].value =(maxg-n1);
d_gauge2.setOption(option_Progress);
option_Progress.title.text ="已经完成";
option_Progress.series[0].data[0].value = n2;
option_Progress.title.subtext =n2+"";
option_Progress.series[0].data[1].value =(maxg-n2);
d_gauge3.setOption(option_Progress);
option_Progress.title.text ="计划完成率";
option_Progress.series[0].data[0].value = n3;
option_Progress.title.subtext =n3+"%";
option_Progress.series[0].data[1].value =(100-n3);
d_gauge4.setOption(option_Progress);
//仪表盘刷新
option_gauge.series[0].axisLine.lineStyle.color=[[0.2, color[0]],[0.8, color[1]],[1, color[0]]];
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="";
$('#vg1').html(option_gauge.series[0].data[0].value);
gauge1.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="";
$('#vg2').html(option_gauge.series[0].data[0].value);
gauge2.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="天然气";
$('#vg3').html(option_gauge.series[0].data[0].value);
gauge3.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="压缩空气";
$('#vg4').html(option_gauge.series[0].data[0].value);
gauge4.setOption(option_gauge);
option_gauge.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
option_gauge.series[0].data[0].name ="蒸汽";
$('#vg5').html(option_gauge.series[0].data[0].value);
gauge5.setOption(option_gauge);
//显示最后更新时间
$('#refresh').html("<span id=\"refreshTime\">最后刷新时间:"+myDate.toLocaleDateString()+" "+myDate.toLocaleTimeString()+"</span>");
}
//生成订单号
function getOrderNumber(n)
{
var no="000000"+n.toString();
return no.substring(no.length-6);
}
//前面补0
function insertZero(n)
{
var no="000000"+n.toString();
return no.substring(no.length-2);
}

File diff suppressed because one or more lines are too long

View File

@ -1,116 +0,0 @@
var geoCoordMap = {
'上海': [121.4648,31.2891],
'东莞': [113.8953,22.901],
'东营': [118.7073,37.5513],
'中山': [113.4229,22.478],
'临汾': [111.4783,36.1615],
'临沂': [118.3118,35.2936],
'丹东': [124.541,40.4242],
'丽水': [119.5642,28.1854],
'乌鲁木齐': [87.9236,43.5883],
'佛山': [112.8955,23.1097],
'保定': [115.0488,39.0948],
'兰州': [103.5901,36.3043],
'包头': [110.3467,41.4899],
'北京': [116.4551,40.2539],
'北海': [109.314,21.6211],
'南京': [118.8062,31.9208],
'南宁': [108.479,23.1152],
'南昌': [116.0046,28.6633],
'南通': [121.1023,32.1625],
'厦门': [118.1689,24.6478],
'台州': [121.1353,28.6688],
'合肥': [117.29,32.0581],
'呼和浩特': [111.4124,40.4901],
'咸阳': [108.4131,34.8706],
'哈尔滨': [127.9688,45.368],
'唐山': [118.4766,39.6826],
'嘉兴': [120.9155,30.6354],
'大同': [113.7854,39.8035],
'大连': [122.2229,39.4409],
'天津': [117.4219,39.4189],
'太原': [112.3352,37.9413],
'威海': [121.9482,37.1393],
'宁波': [121.5967,29.6466],
'宝鸡': [107.1826,34.3433],
'宿迁': [118.5535,33.7775],
'常州': [119.4543,31.5582],
'广州': [113.5107,23.2196],
'廊坊': [116.521,39.0509],
'延安': [109.1052,36.4252],
'张家口': [115.1477,40.8527],
'徐州': [117.5208,34.3268],
'德州': [116.6858,37.2107],
'惠州': [114.6204,23.1647],
'成都': [103.9526,30.7617],
'扬州': [119.4653,32.8162],
'承德': [117.5757,41.4075],
'拉萨': [91.1865,30.1465],
'无锡': [120.3442,31.5527],
'日照': [119.2786,35.5023],
'昆明': [102.9199,25.4663],
'杭州': [119.5313,29.8773],
'枣庄': [117.323,34.8926],
'柳州': [109.3799,24.9774],
'株洲': [113.5327,27.0319],
'武汉': [114.3896,30.6628],
'汕头': [117.1692,23.3405],
'江门': [112.6318,22.1484],
'沈阳': [123.1238,42.1216],
'沧州': [116.8286,38.2104],
'河源': [114.917,23.9722],
'泉州': [118.3228,25.1147],
'泰安': [117.0264,36.0516],
'泰州': [120.0586,32.5525],
'济南': [117.1582,36.8701],
'济宁': [116.8286,35.3375],
'海口': [110.3893,19.8516],
'淄博': [118.0371,36.6064],
'淮安': [118.927,33.4039],
'深圳': [114.5435,22.5439],
'清远': [112.9175,24.3292],
'温州': [120.498,27.8119],
'渭南': [109.7864,35.0299],
'湖州': [119.8608,30.7782],
'湘潭': [112.5439,27.7075],
'滨州': [117.8174,37.4963],
'潍坊': [119.0918,36.524],
'烟台': [120.7397,37.5128],
'玉溪': [101.9312,23.8898],
'珠海': [113.7305,22.1155],
'盐城': [120.2234,33.5577],
'盘锦': [121.9482,41.0449],
'石家庄': [114.4995,38.1006],
'福州': [119.4543,25.9222],
'秦皇岛': [119.2126,40.0232],
'绍兴': [120.564,29.7565],
'聊城': [115.9167,36.4032],
'肇庆': [112.1265,23.5822],
'舟山': [122.2559,30.2234],
'苏州': [120.6519,31.3989],
'莱芜': [117.6526,36.2714],
'菏泽': [115.6201,35.2057],
'营口': [122.4316,40.4297],
'葫芦岛': [120.1575,40.578],
'衡水': [115.8838,37.7161],
'衢州': [118.6853,28.8666],
'西宁': [101.4038,36.8207],
'西安': [109.1162,34.2004],
'贵阳': [106.6992,26.7682],
'连云港': [119.1248,34.552],
'邢台': [114.8071,37.2821],
'邯郸': [114.4775,36.535],
'郑州': [113.4668,34.6234],
'鄂尔多斯': [108.9734,39.2487],
'重庆': [107.7539,30.1904],
'金华': [120.0037,29.1028],
'铜川': [109.0393,35.1947],
'银川': [106.3586,38.1775],
'镇江': [119.4763,31.9702],
'长春': [125.8154,44.2584],
'长沙': [113.0823,28.2568],
'长治': [112.8625,36.4746],
'阳泉': [113.4778,38.0951],
'青岛': [120.4651,36.3373],
'韶关': [113.7964,24.7028]
};

View File

@ -1,28 +0,0 @@
window.onresize = function() {
setAppScale();
};
function setAppScale() {
var ratioY = $(window).height()/1536;
var ratioX = $(window).width()/4352;
var screenWidth = window.screen.width;
var screenHeigth = window.screen.height;
if (screenWidth >= 960) {
ratioX = 0.62
}
if(screenHeigth <= 1080){
ratioY = 0.62
}
$("body").css({
transform: "scale("+ ratioX+","+ ratioY+")",
transformOrigin: "left top",
overflow:"visible"
});
}
$().ready(function(){
//初始化时调整大小
setAppScale();
});

Some files were not shown because too many files have changed in this diff Show More