修改vue3、vue2模板问题

代码规范化补充对应注释和修正规范写法
pull/3685/head^2
zhangdaiscott 2022-05-07 20:48:34 +08:00
parent bbf85093d5
commit fa70a83391
46 changed files with 392 additions and 82 deletions

View File

@ -52,7 +52,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -47,7 +47,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -44,7 +44,7 @@ public class ${entityName}Page {
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.system.vo.SelectTreeModel;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
@ -55,7 +56,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
public class ${entityName}Controller extends JeecgController<${entityName}, I${entityName}Service>{
@Autowired
private I${entityName}Service ${entityName?uncap_first}Service;
/**
* 分页列表查询
*
@ -94,6 +95,67 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
}
}
/**
* 【vue3专用】加载节点的子数据
*
* @param pid
* @return
*/
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = ${entityName?uncap_first}Service.queryListByPid(pid);
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* 【vue3专用】加载一级节点/如果是同步 则所有数据
*
* @param async
* @param pcode
* @return
*/
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = ${entityName?uncap_first}Service.queryListByCode(pcode);
if (!async) {
loadAllChildren(ls);
}
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* 【vue3专用】递归求子节点 同步加载用到
*
* @param ls
*/
private void loadAllChildren(List<SelectTreeModel> ls) {
for (SelectTreeModel tsm : ls) {
List<SelectTreeModel> temp = ${entityName?uncap_first}Service.queryListByPid(tsm.getKey());
if (temp != null && temp.size() > 0) {
tsm.setChildren(temp);
loadAllChildren(temp);
}
}
}
/**
* 获取子数据
* @param ${entityName?uncap_first}

View File

@ -48,7 +48,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -1,8 +1,12 @@
package ${bussiPackage}.${entityPackage}.mapper;
import org.apache.ibatis.annotations.Param;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.system.vo.SelectTreeModel;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import java.util.List;
import java.util.Map;
/**
* @Description: ${tableVo.ftlDescription}
@ -19,4 +23,13 @@ public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
*/
void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status);
/**
* 【vue3专用】根据父级ID查询树节点数据
*
* @param pid
* @param query
* @return
*/
List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query);
}

View File

@ -1,8 +1,18 @@
<#assign hasChildrenField = "">
<#assign pidFieldName = "">
<#assign textFieldName = "">
<#list originalColumns as po>
<#if po.fieldDbName == tableVo.extendParams.hasChildren>
<#assign hasChildrenField = po.fieldName>
</#if>
<#if po.fieldDbName == tableVo.extendParams.hasChildren>
<#assign hasChildrenField = po.fieldName>
</#if>
<#-- begin 【vue3专用】 -->
<#if po.fieldDbName == tableVo.extendParams.pidField>
<#assign pidFieldName = po.fieldName>
</#if>
<#if po.fieldDbName == tableVo.extendParams.textField>
<#assign textFieldName = po.fieldName>
</#if>
<#-- end 【vue3专用】 -->
</#list>
<?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">
@ -12,4 +22,20 @@
update ${tableName} set ${Format.humpToUnderline(hasChildrenField)} = ${r'#'}{status} where id = ${r'#'}{id}
</update>
<!-- 【vue3专用】 -->
<select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel">
select
id as "key",
${textFieldName} as "title",
(case when ${Format.humpToUnderline(hasChildrenField)} = '1' then 0 else 1 end) as isLeaf,
${pidFieldName} as parentId
from ${tableName}
where ${pidFieldName} = ${r'#'}{pid}
<if test="query != null">
<foreach collection="query.entrySet()" item="value" index="key">
and ${r'$'}{key} = ${r'#'}{value}
</foreach>
</if>
</select>
</mapper>

View File

@ -1,5 +1,6 @@
package ${bussiPackage}.${entityPackage}.service;
import org.jeecg.common.system.vo.SelectTreeModel;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.exception.JeecgBootException;
@ -23,16 +24,51 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**树节点无子节点状态值*/
public static final String NOCHILD = "0";
/**新增节点*/
/**
* 新增节点
*
* @param ${entityName?uncap_first}
*/
void add${entityName}(${entityName} ${entityName?uncap_first});
/**修改节点*/
/**
* 修改节点
*
* @param ${entityName?uncap_first}
* @throws JeecgBootException
*/
void update${entityName}(${entityName} ${entityName?uncap_first}) throws JeecgBootException;
/**删除节点*/
/**
* 删除节点
*
* @param id
* @throws JeecgBootException
*/
void delete${entityName}(String id) throws JeecgBootException;
/**查询所有数据,无分页*/
/**
* 查询所有数据,无分页
*
* @param queryWrapper
* @return List<${entityName}>
*/
List<${entityName}> queryTreeListNoPage(QueryWrapper<${entityName}> queryWrapper);
/**
* 【vue3专用】根据父级编码加载分类字典的数据
*
* @param parentCode
* @return
*/
List<SelectTreeModel> queryListByCode(String parentCode);
/**
* 【vue3专用】根据pid查询子节点集合
*
* @param pid
* @return
*/
List<SelectTreeModel> queryListByPid(String pid);
}

View File

@ -1,7 +1,9 @@
package ${bussiPackage}.${entityPackage}.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.system.vo.SelectTreeModel;
import ${bussiPackage}.${entityPackage}.entity.${entityName};
import ${bussiPackage}.${entityPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
@ -84,8 +86,8 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
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)){
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal);
if(flag){
//如果当前节点原本有子节点 现在木有了,更新状态
sb.append(pidVal).append(",");
}
@ -115,7 +117,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
for(${entityName} data : dataList){
String pidVal = data.get${pidFieldName?cap_first}();
//递归查询子节点的根节点
if(pidVal != null && !"0".equals(pidVal)){
if(pidVal != null && !I${entityName}Service.NOCHILD.equals(pidVal)){
${entityName} rootVal = this.getTreeRoot(pidVal);
if(rootVal != null && !mapList.contains(rootVal)){
mapList.add(rootVal);
@ -128,7 +130,33 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
}
return mapList;
}
@Override
public List<SelectTreeModel> queryListByCode(String parentCode) {
String pid = ROOT_PID_VALUE;
if (oConvertUtils.isNotEmpty(parentCode)) {
LambdaQueryWrapper<${entityName}> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(${entityName}::get${pidFieldName?cap_first}, parentCode);
List<${entityName}> list = baseMapper.selectList(queryWrapper);
if (list == null || list.size() == 0) {
throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
}
if (list.size() > 1) {
throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
}
pid = list.get(0).getId();
}
return baseMapper.queryListByPid(pid, null);
}
@Override
public List<SelectTreeModel> queryListByPid(String pid) {
if (oConvertUtils.isEmpty(pid)) {
pid = ROOT_PID_VALUE;
}
return baseMapper.queryListByPid(pid, null);
}
/**
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值
* @param pid
@ -149,7 +177,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
*/
private ${entityName} getTreeRoot(String pidVal){
${entityName} data = baseMapper.selectById(pidVal);
if(data != null && !"0".equals(data.get${pidFieldName?cap_first}())){
if(data != null && !I${entityName}Service.ROOT_PID_VALUE.equals(data.get${pidFieldName?cap_first}())){
return this.getTreeRoot(data.get${pidFieldName?cap_first}());
}else{
return data;

View File

@ -1,3 +1,13 @@
<#assign pidFieldName = "">
<#assign hasChildrenField = "">
<#list originalColumns as po>
<#if po.fieldDbName == tableVo.extendParams.pidField>
<#assign pidFieldName = po.fieldName>
</#if>
<#if po.fieldDbName == tableVo.extendParams.hasChildren>
<#assign hasChildrenField = po.fieldName>
</#if>
</#list>
<template>
<div class="p-4">
<!--引用表格-->
@ -35,8 +45,8 @@
<script lang="ts" name="${entityPackage}-${entityName?uncap_first}" setup>
//ts语法
import {ref, computed, unref, toRaw, nextTick} from 'vue';
import {BasicTable, useTable, TableAction} from '/src/components/Table';
import {useModal} from '/src/components/Modal';
import {BasicTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import ${entityName}Modal from './components/${entityName}Modal.vue';
import {columns} from './${entityName}.data';
@ -48,12 +58,13 @@
//注册table数据
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
api: list,
title: '${tableVo.ftlDescription}',
columns,
canResize:false,
actionColumn: {
width: 120,
},
width: 240,
},
},
exportConfig: {
name:"${tableVo.ftlDescription}",
@ -134,7 +145,7 @@
//编辑回调
updateTableDataRecord(values.id, values);
} else {
if(!values['pid']){
if(!values['${pidFieldName}']){
//新增根节点
reload();
}else{
@ -164,7 +175,7 @@
let records = res.result.records
const listMap = new Map();
for (let item of records) {
let pid = item['pid'];
let pid = item['${pidFieldName}'];
if (unref(expandedRowKeys).includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
@ -212,7 +223,7 @@
if (expanded) {
expandedRowKeys.value.push(record.id)
if (record.children.length > 0 && !!record.children[0].isLoading) {
let result = await getChildList({pid: record.id});
let result = await getChildList({${pidFieldName}: record.id});
result=result.records?result.records:result;
if (result && result.length > 0) {
record.children = getDataByResult(result);
@ -234,7 +245,7 @@
async function expandTreeNode(key) {
let record = findTableDataRecord(key)
expandedRowKeys.value.push(key);
let result = await getChildList({pid: key});
let result = await getChildList({${pidFieldName}: key});
if (result && result.length > 0) {
record.children = getDataByResult(result);
} else {
@ -261,7 +272,7 @@
},
{
label: '添加下级',
onClick: handleAddSub.bind(null, {pid: record.id}),
onClick: handleAddSub.bind(null, {${pidFieldName}: record.id}),
}
]
}

View File

@ -5,7 +5,7 @@ enum Api {
list = '/${entityPackage}/${entityName?uncap_first}/rootList',
save='/${entityPackage}/${entityName?uncap_first}/add',
edit='/${entityPackage}/${entityName?uncap_first}/edit',
delete${entityName} = '/sys/${entityName?uncap_first}/delete',
delete${entityName} = '/${entityPackage}/${entityName?uncap_first}/delete',
deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch',
importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel',
exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls',
@ -13,6 +13,7 @@ enum Api {
getChildList = '/${entityPackage}/${entityName?uncap_first}/childList',
getChildListBatch = '/${entityPackage}/${entityName?uncap_first}/getChildListBatch',
}
/**
* 导出api
* @param params

View File

@ -8,7 +8,11 @@ export const columns: BasicColumn[] = [
<#if po.isShowList =='Y' && po.fieldName !='id'>
{
title: '${po.filedComment}',
align:"center",
<#if po.fieldDbName == tableVo.extendParams.textField>
align: 'left',
<#else>
align: 'center',
</#if>
<#if po.sort=='Y'>
sorter: true,
</#if>
@ -277,13 +281,15 @@ export const formSchema: FormSchema[] = [
component: 'JTreeSelect',
componentProps:{
<#if po.dictText??>
<#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??>
<#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??>
dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}",
<#elseif po.dictText?split(',')[1]??>
</#if>
<#if po.dictText?split(',')[1]??>
pidField:"${po.dictText?split(',')[1]}",
<#elseif po.dictText?split(',')[3]??>
</#if>
<#if po.dictText?split(',')[3]??>
hasChildField:"${po.dictText?split(',')[3]}",
</#if>
</#if>
</#if>
pidValue:"${po.dictField}",
},

View File

@ -1,3 +1,13 @@
<#assign pidFieldName = "">
<#assign hasChildrenField = "">
<#list originalColumns as po>
<#if po.fieldDbName == tableVo.extendParams.pidField>
<#assign pidFieldName = po.fieldName>
</#if>
<#if po.fieldDbName == tableVo.extendParams.hasChildren>
<#assign hasChildrenField = po.fieldName>
</#if>
</#list>
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicForm @register="registerForm"/>
@ -5,8 +15,8 @@
</template>
<script lang="ts" setup>
import {ref, computed, unref} from 'vue';
import {BasicModal, useModalInner} from '/src/components/Modal';
import {BasicForm, useForm} from '/src/components/Form';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form';
import {formSchema} from '../${entityName}.data';
import {loadTreeData, saveOrUpdateDict} from '../${entityName}.api';
// 获取emit
@ -42,13 +52,9 @@
}
//父级节点树信息
treeData.value = await loadTreeData({'async': false,'pcode':''});
updateSchema({
field: 'pid',
componentProps: {treeData},
});
});
//设置标题
const getTitle = computed(() => (!unref(isUpdate) ? '新增字典' : '编辑字典'));
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
/**
* 根据pid获取展开的节点
@ -77,7 +83,7 @@
//关闭弹窗
closeModal();
//展开的节点信息
await getExpandKeysByPid(values['pid'],unref(treeData))
await getExpandKeysByPid(values['${pidFieldName}'],unref(treeData))
//刷新列表(isUpdate:是否编辑;values:表单信息;expandedArr:展开的节点信息)
emit('success', {isUpdate: unref(isUpdate), values:{...values},expandedArr: unref(expandedRowKeys).reverse()});
} finally {

View File

@ -251,7 +251,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "${sub.ftlDescription}"); //此处设置的filename无效 ,前端会重更新设置一下
//此处设置的filename无效,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, "${sub.ftlDescription}");
mv.addObject(NormalExcelConstants.CLASS, ${sub.entityName}.class);
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("${sub.ftlDescription}报表", "导出人:" + sysUser.getRealname(), "${sub.ftlDescription}"));
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
@ -267,7 +268,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);

View File

@ -47,7 +47,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -34,7 +34,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param;
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}

View File

@ -20,11 +20,15 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);

View File

@ -14,6 +14,12 @@ import java.util.List;
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
/**
* 通过主表id查询子表数据
*
* @param mainId
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -193,7 +193,7 @@
<#assign sub_seq=1>
<#list subTables as sub>
<a-tab-pane tab="${sub.ftlDescription}" key="${sub_seq}" <#if sub_seq gt 1>forceRender</#if>>
<${sub.entityName}List :mainId="${sub.entityName?uncap_first}MainId" />
<${sub.entityName}List :mainId="selectedMainId" />
</a-tab-pane>
<#assign sub_seq=sub_seq+1>
</#list>
@ -340,7 +340,7 @@
selectedMainId:'',
superFieldList:[],
<#list subTables as sub>
<#if sub != null>
<#if sub?? && (sub.foreignMainKeys)??>
<#list sub.foreignMainKeys as key>
<#assign subMainFieldMap += {"${sub.entityName?uncap_first}MainId": "${dashedToCamel(key)}"}>
</#list>

View File

@ -245,7 +245,8 @@ public class ${entityName}Controller {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);

View File

@ -47,7 +47,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -49,7 +49,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param;
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}
</#list>

View File

@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**
* 添加一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#list>
*/
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>) ;
/**
* 修改一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#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>);
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);

View File

@ -14,6 +14,12 @@ import java.util.List;
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -44,7 +44,7 @@ public class ${entityName}Page {
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -4,17 +4,18 @@
<!-- 子表单区域 -->
<a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs">
<#list subTables as sub><#rt/>
<#assign refKey = sub.entityName?uncap_first/>
<#if sub.foreignRelationType =='1'>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<JVxeTable
keep-source
resizable
:ref="refKeys[${sub_index}]"
ref="${refKey}"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"

View File

@ -250,7 +250,8 @@ public class ${entityName}Controller {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);

View File

@ -47,7 +47,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param;
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}
</#list>

View File

@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**
* 添加一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#list>
*/
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>) ;
/**
* 修改一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#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>);
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);

View File

@ -14,6 +14,12 @@ import java.util.List;
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -44,7 +44,7 @@ public class ${entityName}Page {
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -4,17 +4,18 @@
<!-- 子表单区域 -->
<a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs">
<#list subTables as sub><#rt/>
<#assign refKey = sub.entityName?uncap_first/>
<#if sub.foreignRelationType =='1'>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<JVxeTable
keep-source
resizable
:ref="refKeys[${sub_index}]"
ref="${refKey}"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"

View File

@ -241,7 +241,8 @@ public class ${entityName}Controller {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
params.setTitleRows(2);
params.setHeadRows(1);

View File

@ -47,7 +47,7 @@ public class ${entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -48,7 +48,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.fieldName == primaryKeyField>
@TableId(type = IdType.ASSIGN_ID)
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -15,8 +15,20 @@ import org.apache.ibatis.annotations.Param;
*/
public interface ${subTab.entityName}Mapper extends BaseMapper<${subTab.entityName}> {
/**
* 通过主表id删除子表数据
*
* @param mainId 主表id
* @return boolean
*/
public boolean deleteByMainId(@Param("mainId") String mainId);
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(@Param("mainId") String mainId);
}
</#list>

View File

@ -19,23 +19,35 @@ public interface I${entityName}Service extends IService<${entityName}> {
/**
* 添加一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#list>
*/
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>) ;
/**
* 修改一对多
*
*
* @param ${entityName?uncap_first}
<#list subTables as sub>
* @param ${sub.entityName?uncap_first}List
</#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>);
/**
* 删除一对多
*
* @param id
*/
public void delMain (String id);
/**
* 批量删除一对多
*
* @param idList
*/
public void delBatchMain (Collection<? extends Serializable> idList);

View File

@ -14,6 +14,12 @@ import java.util.List;
*/
public interface I${subTab.entityName}Service extends IService<${subTab.entityName}> {
/**
* 通过主表id查询子表数据
*
* @param mainId 主表id
* @return List<${subTab.entityName}>
*/
public List<${subTab.entityName}> selectByMainId(String mainId);
}
</#list>

View File

@ -44,7 +44,7 @@ public class ${entityName}Page {
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
<#else>
<#if po.fieldDbType =='Date'>
<#if po.fieldDbType =='Date' || po.fieldDbType =='Datetime'>
<#if po.classType=='date'>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")

View File

@ -8,17 +8,18 @@
</a-tab-pane>
<!--子表单区域 -->
<#list subTables as sub><#rt/>
<#assign refKey = sub.entityName?uncap_first/>
<#if sub.foreignRelationType =='1'>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index+1}]" :forceRender="true">
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<JVxeTable
keep-source
resizable
:ref="refKeys[${sub_index+1}]"
ref="${refKey}"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"

View File

@ -4,11 +4,12 @@
<!-- 子表单区域 -->
<a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs">
<#list subTables as sub><#rt/>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<#assign refKey = sub.entityName?uncap_first/>
<a-tab-pane tab="${sub.ftlDescription}" key="${refKey}" :forceRender="true">
<JVxeTable
keep-source
resizable
:ref="refKeys[${sub_index}]"
ref="${refKey}"
:loading="${sub.entityName?uncap_first}Table.loading"
:columns="${sub.entityName?uncap_first}Table.columns"
:dataSource="${sub.entityName?uncap_first}Table.dataSource"