Jeecg-Boot 2.2.0 版本发布 | 重磅升级

This commit is contained in:
zhangdaiscott
2020-05-03 12:43:53 +08:00
parent c4ac8d716b
commit b87ac50420
335 changed files with 12894 additions and 27387 deletions

View File

@ -0,0 +1,73 @@
<#---->
<#-- freemarker 的一些工具方法 -->
<#---->
<#-- 驼峰转其他字符 -->
<#-- @param str 待转换的文本 -->
<#-- @param character 要转换成的字符 -->
<#-- @param case 转换大小写normal 不转换lower 小写upper 大写) -->
<#function camelToChar(str, character, case='normal')>
<#assign text=str?replace("([a-z])([A-Z]+)","$1${character}$2","r")/>
<#if case=="upper">
<#return text?upper_case>
<#elseif case=="lower">
<#return text?lower_case>
<#else>
<#return text>
</#if>
</#function>
<#---->
<#-- 驼峰转下划线 -->
<#function camelToDashed(str, case='normal')>
<#return camelToChar(str, "_", case)>
</#function>
<#---->
<#-- 驼峰转横线 -->
<#function camelToHorizontal(str, case='normal')>
<#return camelToChar(str, "-", case)>
</#function>
<#---->
<#-- 获取 v-model 属性 -->
<#function getVModel po,suffix="">
<#return "v-model=\"queryParam.${po.fieldName}${suffix}\"">
</#function>
<#-- 获取 placeholder 属性 -->
<#function getPlaceholder po,prefix,fillComment=true>
<#if fillComment>
<#return "placeholder=\"${prefix}${po.filedComment}\"">
<#else>
<#return "placeholder=\"${prefix}\"">
</#if>
</#function>
<#-- ** 判断某字段是否配置了校验 * -->
<#function poHasCheck po>
<#if (po.fieldValidType!'')?trim?length gt 0 || po.nullable == 'N'>
<#if po.fieldName != 'id'>
<#if po.nullable == 'N'
|| po.fieldValidType == '*'
|| po.fieldValidType == 'only'
|| po.fieldValidType == 'n6-16'
|| po.fieldValidType == '*6-16'
|| po.fieldValidType == 's6-18'
|| po.fieldValidType == 'url'
|| po.fieldValidType == 'e'
|| po.fieldValidType == 'm'
|| po.fieldValidType == 'p'
|| po.fieldValidType == 's'
|| po.fieldValidType == 'n'
|| po.fieldValidType == 'z'
|| po.fieldValidType == 'money'
>
<#return true>
</#if>
</#if>
</#if>
<#return false>
</#function>
<#-- ** 如果配置了校验就显示 validatorRules * -->
<#function autoWriteRules po>
<#if poHasCheck(po)>
<#return ", validatorRules.${po.fieldName}">
<#else>
<#return "">
</#if>
</#function>

View File

@ -1,55 +0,0 @@
validatorRules: {
<#list columns as po>
<#if po.isShow == 'Y'>
<#if po.fieldName != 'id'>
${po.fieldName}: {rules: [
<#assign fieldValidType = po.fieldValidType!''>
<#-- 非空校验 -->
<#if po.nullable == 'N' || fieldValidType == '*'>
{required: true, message: '请输入${po.filedComment}!'},
</#if>
<#-- 唯一校验 -->
<#if fieldValidType == 'only'>
{ validator: (rule, value, callback) => validateDuplicateValue('${tableName}', '${po.fieldDbName}', value, this.model.id, callback)},
<#-- 6到16位数字 -->
<#elseif fieldValidType == 'n6-16'>
{pattern:/\d{6,18}/, message: '请输入6到16位数字!'},
<#-- 6到16位任意字符 -->
<#elseif fieldValidType == '*6-16'>
{pattern:/^.{6,16}$/, message: '请输入6到16位任意字符!'},
<#-- 6到18位字符串 -->
<#elseif fieldValidType == 's6-18'>
{pattern:/^.{6,18}$/, message: '请输入6到18位任意字符!'},
<#-- 网址 -->
<#elseif fieldValidType == 'url'>
{pattern:/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/, message: '请输入正确的网址!'},
<#-- 电子邮件 -->
<#elseif fieldValidType == 'e'>
{pattern:/^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
<#-- 手机号码 -->
<#elseif fieldValidType == 'm'>
{pattern:/^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
<#-- 邮政编码 -->
<#elseif fieldValidType == 'p'>
{pattern:/^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'},
<#-- 字母 -->
<#elseif fieldValidType == 's'>
{pattern:/^[A-Z|a-z]+$/, message: '请输入字母!'},
<#-- 数字 -->
<#elseif fieldValidType == 'n'>
{pattern:/^-?\d+\.?\d*$/, message: '请输入数字!'},
<#-- 整数 -->
<#elseif fieldValidType == 'z'>
{pattern:/^-?\d+$/, message: '请输入整数!'},
<#-- 金额 -->
<#elseif fieldValidType == 'money'>
{pattern:/^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
<#-- 无校验 -->
<#else>
<#t>
</#if>
]},
</#if>
</#if>
</#list>
},

View File

@ -0,0 +1,54 @@
<#include "../utils.ftl">
<#if po.isShow == 'Y' && poHasCheck(po)>
<#if po.fieldName != 'id'>
${po.fieldName}: {
rules: [
<#assign fieldValidType = po.fieldValidType!''>
<#-- 非空校验 -->
<#if po.nullable == 'N' || fieldValidType == '*'>
{ required: true, message: '请输入${po.filedComment}!'},
</#if>
<#-- 唯一校验 -->
<#if fieldValidType == 'only'>
{ validator: (rule, value, callback) => validateDuplicateValue('${tableName}', '${po.fieldDbName}', value, this.model.id, callback)},
<#-- 6到16位数字 -->
<#elseif fieldValidType == 'n6-16'>
{ pattern: /\d{6,18}/, message: '请输入6到16位数字!'},
<#-- 6到16位任意字符 -->
<#elseif fieldValidType == '*6-16'>
{ pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'},
<#-- 6到18位字符串 -->
<#elseif fieldValidType == 's6-18'>
{ pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'},
<#-- 网址 -->
<#elseif fieldValidType == 'url'>
{ pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/, message: '请输入正确的网址!'},
<#-- 电子邮件 -->
<#elseif fieldValidType == 'e'>
{ pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
<#-- 手机号码 -->
<#elseif fieldValidType == 'm'>
{ pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
<#-- 邮政编码 -->
<#elseif fieldValidType == 'p'>
{ pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'},
<#-- 字母 -->
<#elseif fieldValidType == 's'>
{ pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'},
<#-- 数字 -->
<#elseif fieldValidType == 'n'>
{ pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
<#-- 整数 -->
<#elseif fieldValidType == 'z'>
{ pattern: /^-?\d+$/, message: '请输入整数!'},
<#-- 金额 -->
<#elseif fieldValidType == 'money'>
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
<#-- 无校验 -->
<#else>
<#t>
</#if>
]
},
</#if>
</#if>

View File

@ -0,0 +1,5 @@
validatorRules: {
<#list columns as po>
<#include "core.ftl">
</#list>
},

View File

@ -0,0 +1,5 @@
validatorRules: {
<#list sub.colums as po>
<#include "core.ftl">
</#list>
},

View File

@ -31,6 +31,7 @@ import lombok.experimental.Accessors;
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="">
@ -51,16 +52,22 @@ public class ${entityName} implements Serializable {
<#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)})

View File

@ -9,7 +9,16 @@
<#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'>
@ -17,15 +26,41 @@
<#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=='date'>
<#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>
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
@ -70,6 +105,9 @@
<#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>
@ -88,7 +126,6 @@
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
@ -125,19 +162,24 @@
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
<#if tableVo.extendParams.scroll=='1'>:scroll="tableScroll"</#if>
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
class="j-table-force-nowrap"
@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;"/>
<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>
<#if list_need_pca>
<template slot="pcaSlot" slot-scope="text">
<div>{{ getPcaText(text) }}</div>
</template>
</#if>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
@ -174,6 +216,8 @@
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ${entityName}Modal from './modules/${entityName}Modal'
<#if query_field_select>
@ -188,10 +232,34 @@
<#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>
export default {
name: "${entityName}List",
mixins:[JeecgListMixin],
mixins:[JeecgListMixin, mixinDevice],
components: {
<#if query_field_select>
JDictSelectTag,
@ -199,6 +267,27 @@
<#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 () {
@ -218,7 +307,7 @@
},
<#assign showColNum=0>
<#list columns as po>
<#if po.isShowList =='Y'>
<#if po.isShowList =='Y' && po.fieldName !='id'>
<#assign showColNum=showColNum+1>
{
title:'${po.filedComment}',
@ -233,6 +322,9 @@
<#elseif po.classType=='umeditor'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'htmlSlot'}
<#elseif po.classType=='pca'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'pcaSlot'}
<#elseif po.classType=='file'>
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'fileSlot'}
@ -260,7 +352,7 @@
dataIndex: 'action',
align:"center",
<#if tableVo.extendParams.scroll=='1'>
fixed:"right",
// fixed:"right",
width:147,
</#if>
scopedSlots: { customRender: 'action' }
@ -274,22 +366,32 @@
importExcelUrl: "${entityPackage}/${entityName?uncap_first}/importExcel",
},
dictOptions:{},
<#if tableVo.extendParams.scroll=='1'>
tableScroll:{x :${showColNum}*147+50}
<#if list_need_pca>
pcaData:''
</#if>
}
},
<#if list_need_pca>
created() {
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}"}).then((res) => {
loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => {
if (res.success) {
this.$set(this.dictOptions, '${po.fieldName}', res.result)
}

View File

@ -1,9 +1,12 @@
<#--<#include "../../../../../../../common/utils.ftl">-->
<#include "/common/utils.ftl">
<template>
<a-modal
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
@ -17,12 +20,15 @@
<#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>
<#list columns as po>
<#if po.isShow =='Y'>
<#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}">
@ -32,67 +38,78 @@
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
dest-fields="${Format.underlineToHump(po.dictText)}"
code="${po.dictTable}"
@callback="popupCallback"/>
<#elseif po.classType =='sel_depart'>
<#elseif po.classType =='sel_depart'>
<#assign form_sel_depart=true>
<j-select-depart v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" multi/>
<#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}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" rows="4" placeholder="请输入${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" dict="${form_field_dictCode}" />
<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}', validatorRules.${po.fieldName}]" pcode="${po.dictField}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<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}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true"></j-upload>
<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', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</#if>
</#list>
<#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-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-form>
</a-spin>
</a-modal>
</j-modal>
</template>
<script>
@ -106,6 +123,9 @@
<#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>
@ -127,6 +147,14 @@
<#if form_cat_tree>
import JCategorySelect from '@/components/jeecg/JCategorySelect'
</#if>
<#if form_pca>
import JAreaLinkage from '@comp/jeecg/JAreaLinkage'
</#if>
<#if form_pca>
import JMarkdownEditor from '@/components/jeecg/JMarkdownEditor/index'
</#if>
export default {
name: "${entityName}Modal",
@ -137,6 +165,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -155,8 +186,14 @@
<#if form_editor>
JEditor,
</#if>
<#if form_pca>
JAreaLinkage,
</#if>
<#if form_cat_tree>
JCategorySelect
JCategorySelect,
</#if>
<#if form_pca>
JMarkdownEditor,
</#if>
},
data () {
@ -175,7 +212,7 @@
sm: { span: 16 },
},
confirmLoading: false,
<#include "/common/validatorRulesTemplate.ftl">
<#include "/common/validatorRulesTemplate/main.ftl">
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",

View File

@ -1,3 +1,4 @@
<#include "/common/utils.ftl">
<template>
<a-drawer
:title="title"
@ -16,9 +17,10 @@
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#list columns as po>
<#if po.isShow =='Y'>
<#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}">
@ -28,40 +30,43 @@
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
org-fields="${po.dictField?default("")}"
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}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" rows="4" placeholder="请输入${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true"></j-upload>
<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>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</#if>
@ -85,6 +90,9 @@
<#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>
@ -107,6 +115,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -136,7 +147,7 @@
sm: { span: 16 },
},
confirmLoading: false,
<#include "/common/validatorRulesTemplate.ftl">
<#include "/common/validatorRulesTemplate/main.ftl">
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",

View File

@ -175,8 +175,8 @@ public class ${entityName}Controller {
* @param id
* @return
*/
@AutoLog(value = "${sub.ftlDescription}集合-通过id查询")
@ApiOperation(value="${sub.ftlDescription}集合-通过id查询", notes="${sub.ftlDescription}-通过id查询")
@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);

View File

@ -25,6 +25,7 @@ import io.swagger.annotations.ApiModelProperty;
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="">
@ -45,16 +46,22 @@ public class ${entityName} implements Serializable {
<#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)})

View File

@ -26,6 +26,7 @@ import io.swagger.annotations.ApiModelProperty;
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="">
@ -46,16 +47,22 @@ public class ${subTab.entityName} implements Serializable {
<#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}")

View File

@ -24,23 +24,30 @@ import io.swagger.annotations.ApiModelProperty;
@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>
/**${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)
</#if>
</#if>
</#if>
@ApiModelProperty(value = "${po.filedComment}")

View File

@ -9,7 +9,16 @@
<#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'>
@ -17,15 +26,41 @@
<#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=='date'>
<#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>
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
@ -70,6 +105,9 @@
<#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>
@ -88,7 +126,6 @@
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
@ -121,6 +158,7 @@
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
@ -132,11 +170,11 @@
<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;"/>
<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>
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
@ -181,12 +219,37 @@
<#if query_field_date>
import JDate from '@/components/jeecg/JDate.vue'
</#if>
<#if list_need_dict>
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#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",
@ -198,6 +261,27 @@
<#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 () {
@ -281,7 +365,7 @@
<#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}"}).then((res) => {
loadCategoryData({code:"${po.dictField?default('')}"}).then((res) => {
if (res.success) {
this.$set(this.dictOptions, '${po.fieldName}', res.result)
}

View File

@ -1,10 +1,12 @@
<#include "/common/utils.ftl">
<template>
<a-modal
<j-modal
:title="title"
:width="1200"
:visible="visible"
:maskClosable="false"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel">
<a-spin :spinning="confirmLoading">
@ -19,6 +21,7 @@
<#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 = "">
@ -35,64 +38,67 @@
<a-col :span="24">
<a-form-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
<#else>
<a-col :span="12">
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
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}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" rows="4" placeholder="请输入${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" dict="${form_field_dictCode}" />
<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}', validatorRules.${po.fieldName}]" pcode="${po.dictField}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<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}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true"></j-upload>
<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', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<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-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-col>
@ -128,7 +134,7 @@
</a-tabs>
</a-spin>
</a-modal>
</j-modal>
</template>
<script>
@ -148,6 +154,9 @@
<#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>
@ -185,6 +194,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -210,22 +222,27 @@
data() {
return {
labelCol: {
span: 6
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
span: 16
xs: { span: 24 },
sm: { span: 16 },
},
labelCol2: {
span: 3
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol2: {
span: 20
xs: { span: 24 },
sm: { span: 20 },
},
// 新增时子表默认添加几行空数据
addDefaultRowNum: 1,
<#include "/common/validatorRulesTemplate.ftl">
<#include "/common/validatorRulesTemplate/main.ftl">
refKeys: [<#list subTables as sub>'${sub.entityName?uncap_first}', </#list>],
tableKeys:[<#list subTables as sub><#if sub.foreignRelationType =='0'>'${sub.entityName?uncap_first}', </#if></#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}
@ -286,8 +303,8 @@
</#if>
type: FormTypes.popup,
popupCode:"${col.dictTable}",
destFields:"${col.dictText}",
orgFieldse:"${col.dictField}",
destFields:"${Format.underlineToHump(col.dictText)}",
orgFields:"${col.dictField}",
<#else>
type: FormTypes.input,
</#if>
@ -359,8 +376,14 @@
},
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() {
@ -386,12 +409,13 @@
/** 整理成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[${sub_index}].values,
${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>

View File

@ -1,3 +1,4 @@
<#include "/common/utils.ftl">
<#list subTables as sub>
<#if sub.foreignRelationType=='1'>
#segment#${sub.entityName}Form.vue
@ -12,6 +13,7 @@
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#list sub.colums as po>
<#if po.isShow =='Y'>
@ -25,45 +27,48 @@
<a-col :span="24">
<a-form-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
<#else>
<a-col :span="12">
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}']"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
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}']" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}']" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}']" rows="4" placeholder="请输入${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}']" :trigger-change="true"></j-upload>
<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>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</a-col>
@ -76,12 +81,16 @@
<script>
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
<#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>
@ -104,6 +113,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -122,32 +134,23 @@
form: this.$form.createForm(this),
model: {},
labelCol: {
span: 6
xs: { span: 24 },
sm: { span: 6 },
},
wrapperCol: {
span: 16
xs: { span: 24 },
sm: { span: 16 },
},
labelCol2: {
span: 3
xs: { span: 24 },
sm: { span: 3 },
},
wrapperCol2: {
span: 20
xs: { span: 24 },
sm: { span: 20 },
},
<#include "/common/validatorRulesTemplate/sub.ftl">
confirmLoading: false,
validatorRules:{
<#list sub.colums as po>
<#if po.fieldName !='id'>
<#if po.isShow =='Y'>
<#if po.nullable =='N'>
${po.fieldName}:{rules: [{ required: true, message: '请输入${po.filedComment}!' }]},
<#else>
${po.fieldName}:{},
</#if>
</#if>
</#if>
</#list>
},
}
},
methods:{

View File

@ -32,6 +32,9 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
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}
@ -45,6 +48,7 @@ import com.alibaba.fastjson.JSON;
<#assign pidFieldName = po.fieldName>
</#if>
</#list>
@Api(tags="${tableVo.ftlDescription}")
@RestController
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
@Slf4j
@ -61,6 +65,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param req
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")
@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
@GetMapping(value = "/rootList")
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@ -73,7 +79,7 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
${entityName?uncap_first}.set${pidFieldName?cap_first}(null);
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
// 使用 eq 防止模糊查询
queryWrapper.eq("${pidFieldName}", parentId);
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);
@ -85,6 +91,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param req
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-获取子数据")
@ApiOperation(value="${tableVo.ftlDescription}-获取子数据", notes="${tableVo.ftlDescription}-获取子数据")
@GetMapping(value = "/childList")
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},HttpServletRequest req) {
QueryWrapper<${entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${entityName?uncap_first}, req.getParameterMap());
@ -99,6 +107,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${entityName?uncap_first}
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-添加")
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.add${entityName}(${entityName?uncap_first});
@ -111,6 +121,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${entityName?uncap_first}
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.update${entityName}(${entityName?uncap_first});
@ -123,6 +135,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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.delete${entityName}(id);
@ -135,6 +149,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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.removeByIds(Arrays.asList(ids.split(",")));
@ -147,6 +163,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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);

View File

@ -11,6 +11,8 @@ 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}
@ -20,9 +22,11 @@ import org.jeecg.common.aspect.annotation.Dict;
*/
@Data
@TableName("${tableName}")
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
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="">
@ -43,16 +47,22 @@ public class ${entityName} implements Serializable {
<#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 po.classType!='popup'>
<#if po.dictTable?default("")?trim?length gt 1>
@ -65,6 +75,7 @@ public class ${entityName} implements Serializable {
@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>
}

View File

@ -47,11 +47,11 @@
v-bind="tableProps">
<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;"/>
<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>
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
@ -71,7 +71,10 @@
<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 @click="handleAddChild(record)">添加下级</a>
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
@ -88,7 +91,7 @@
<script>
import { getAction } from '@/api/manage'
import { getAction, deleteAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ${entityName}Modal from './modules/${entityName}Modal'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
@ -157,7 +160,8 @@
expandedRowKeys:[],
hasChildrenField:"${hasChildrenField}",
pidField:"${pidFieldName}",
dictOptions: {}
dictOptions: {},
loadParent: false
}
},
computed: {
@ -274,9 +278,14 @@
if(!formData[this.pidField]){
this.loadData()
}else{
this.expandedRowKeys=[]
for(let i of arr){
await this.expandTreeNode(i)
if(this.loadParent===true){
this.expandTreeNode(formData[this.pidField])
this.loadParent = false
}else{
this.expandedRowKeys=[]
for(let i of arr){
await this.expandTreeNode(i)
}
}
}
},
@ -291,11 +300,11 @@
if(res.success){
if(res.result && res.result.length>0){
row.children = this.getDataByResult(res.result)
this.dataSource = [...this.dataSource]
resolve()
}else{
reject()
row.children=''
}
this.dataSource = [...this.dataSource]
resolve()
}else{
reject()
}
@ -313,8 +322,32 @@
}
}
},
handleAddChild(record){
this.loadParent = true
let obj = {}
obj[this.pidField] = record['id']
this.$refs.modalForm.add(obj);
},
handleDeleteNode(record) {
if(!this.url.delete){
this.$message.error("请设置url.delete属性!")
return
}
var that = this;
deleteAction(that.url.delete, {id: record.id}).then((res) => {
if (res.success) {
if(!record[this.pidField] || record[this.pidField] =='0' || record[this.pidField].length==0){
that.loadData(1)
}else{
that.$message.success(res.message);
that.expandTreeNode(record[this.pidField]);
}
} else {
that.$message.warning(res.message);
}
});
}
}
}
</script>

View File

@ -1,9 +1,11 @@
<#include "/common/utils.ftl">
<template>
<a-modal
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
:destroyOnClose="true"
@ -17,6 +19,7 @@
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#assign form_tree_select = false>
<#assign pidFieldName = "">
@ -35,7 +38,7 @@
<j-tree-select
ref="treeSelect"
placeholder="请选择${po.filedComment}"
v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
dict="${tableVo.tableName},${tableVo.extendParams.textField},id"
pidField="${tableVo.extendParams.pidField}"
pidValue="0"
@ -43,40 +46,43 @@
</j-tree-select>
<#elseif po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
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}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}', validatorRules.${po.fieldName}]" rows="4" placeholder="请输入${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
<a-input-number v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true"></j-upload>
<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>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</#if>
@ -84,7 +90,7 @@
</a-form>
</a-spin>
</a-modal>
</j-modal>
</template>
<script>
@ -98,6 +104,9 @@
<#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>
@ -123,6 +132,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -156,7 +168,7 @@
},
confirmLoading: false,
<#include "/common/validatorRulesTemplate.ftl">
<#include "/common/validatorRulesTemplate/main.ftl">
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",
@ -169,8 +181,8 @@
created () {
},
methods: {
add () {
this.edit({});
add (obj) {
this.edit(obj);
},
edit (record) {
this.form.resetFields();

View File

@ -22,7 +22,22 @@ import ${bussiPackage}.${entityPackage}.service.I${entityName}Service;
<#list subTables as sub>
import ${bussiPackage}.${entityPackage}.service.I${sub.entityName}Service;
</#list>
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
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.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: ${tableVo.ftlDescription}
@ -30,6 +45,7 @@ import ${bussiPackage}.${entityPackage}.service.I${sub.entityName}Service;
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Api(tags="${tableVo.ftlDescription}")
@RestController
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
@Slf4j
@ -54,6 +70,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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,
@ -70,6 +88,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${entityName?uncap_first}
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-添加")
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first});
@ -81,6 +101,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${entityName?uncap_first}
* @return
*/
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
@ -92,6 +114,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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);
@ -103,6 +127,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @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(",")));
@ -132,9 +158,11 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
/*--------------------------------子表处理-${sub.ftlDescription}-begin----------------------------------------------*/
/**
* 查询子表信息 会传入主表ID
* 通过主表ID查询
* @return
*/
@AutoLog(value = "${sub.ftlDescription}-通过主表ID查询")
@ApiOperation(value="${sub.ftlDescription}-通过主表ID查询", notes="${sub.ftlDescription}-通过主表ID查询")
@GetMapping(value = "/list${sub.entityName}ByMainId")
public Result<?> list${sub.entityName}ByMainId(${sub.entityName} ${sub.entityName?uncap_first},
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@ -151,6 +179,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${sub.entityName?uncap_first}
* @return
*/
@AutoLog(value = "${sub.ftlDescription}-添加")
@ApiOperation(value="${sub.ftlDescription}-添加", notes="${sub.ftlDescription}-添加")
@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});
@ -162,6 +192,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ${sub.entityName?uncap_first}
* @return
*/
@AutoLog(value = "${sub.ftlDescription}-编辑")
@ApiOperation(value="${sub.ftlDescription}-编辑", notes="${sub.ftlDescription}-编辑")
@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});
@ -173,6 +205,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param id
* @return
*/
@AutoLog(value = "${sub.ftlDescription}-通过id删除")
@ApiOperation(value="${sub.ftlDescription}-通过id删除", notes="${sub.ftlDescription}-通过id删除")
@DeleteMapping(value = "/delete${sub.entityName}")
public Result<?> delete${sub.entityName}(@RequestParam(name="id",required=true) String id) {
${sub.entityName?uncap_first}Service.removeById(id);
@ -184,12 +218,85 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
* @param ids
* @return
*/
@AutoLog(value = "${sub.ftlDescription}-批量删除")
@ApiOperation(value="${sub.ftlDescription}-批量删除", notes="${sub.ftlDescription}-批量删除")
@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(",")));
this.${sub.entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return Result.ok("批量删除成功!");
}
/**
* 导出
* @return
*/
@RequestMapping(value = "/export${sub.entityName}")
public ModelAndView export${sub.entityName}(HttpServletRequest request, ${sub.entityName} ${sub.entityName?uncap_first}) {
// Step.1 组装查询条件
QueryWrapper<${sub.entityName}> queryWrapper = QueryGenerator.initQueryWrapper(${sub.entityName?uncap_first}, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 获取导出数据
List<${sub.entityName}> pageList = ${sub.entityName?uncap_first}Service.list(queryWrapper);
List<${sub.entityName}> exportList = null;
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
} else {
exportList = pageList;
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "${sub.ftlDescription}"); //此处设置的filename无效 ,前端会重更新设置一下
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);
return mv;
}
/**
* 导入
* @return
*/
@RequestMapping(value = "/import${sub.entityName}/{mainId}")
public Result<?> import${sub.entityName}(HttpServletRequest request, HttpServletResponse response, @PathVariable("mainId") String mainId) {
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<${sub.entityName}> list = ExcelImportUtil.importExcel(file.getInputStream(), ${sub.entityName}.class, params);
for (${sub.entityName} temp : list) {
<#list sub.foreignKeys as key>
temp.set${key?cap_first}(mainId);
</#list>
}
long start = System.currentTimeMillis();
${sub.entityName?uncap_first}Service.saveBatch(list);
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
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.error("文件导入失败!");
}
/*--------------------------------子表处理-${sub.ftlDescription}-end----------------------------------------------*/
</#list>

View File

@ -9,6 +9,8 @@ import org.jeecgframework.poi.excel.annotation.Excel;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @Description: ${tableVo.ftlDescription}
@ -18,9 +20,11 @@ import org.springframework.format.annotation.DateTimeFormat;
*/
@Data
@TableName("${tableName}")
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
public class ${entityName} implements Serializable {
private static final long serialVersionUID = 1L;
<#assign excel_ignore_arr=['createBy','createTime','updateBy','updateTime','sysOrgCode']>
<#list originalColumns as po>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@ -28,16 +32,22 @@ public class ${entityName} implements Serializable {
<#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)
</#if>
</#if>
</#if>
<#if po.fieldDbType=='Blob'>
@ -69,6 +79,7 @@ public class ${entityName} implements Serializable {
return "";
}
<#else>
@ApiModelProperty(value = "${po.filedComment}")
private ${po.fieldType} ${po.fieldName};
</#if>
</#list>

View File

@ -12,6 +12,8 @@ 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}
@ -21,9 +23,11 @@ import java.util.Date;
*/
@Data
@TableName("${subTab.tableName}")
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
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>
/**${po.filedComment}*/
<#if po.fieldName == primaryKeyField>
@ -31,17 +35,23 @@ public class ${subTab.entityName} implements Serializable {
<#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>
<#elseif !subTab.foreignKeys?seq_contains(po.fieldName?cap_first)>
<#if !excel_ignore_arr?seq_contains("${po.fieldName}")>
@Excel(name = "${po.filedComment}", width = 15)
</#if>
</#if>
</#if>
<#if po.classType =='list' || po.classType =='radio' || po.classType =='list_multi' || po.classType =='checkbox' || po.classType =='sel_search'>
<#if po.dictTable?default("")?trim?length gt 1>
@ -56,6 +66,7 @@ public class ${subTab.entityName} implements Serializable {
<#if po.classType =='sel_depart'>
@Dict(dicCode = "id",dicText = "depart_name",dictTable = "sys_depart")
</#if>
@ApiModelProperty(value = "${po.filedComment}")
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
</#list>
}

View File

@ -9,7 +9,16 @@
<#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'>
@ -17,15 +26,41 @@
<#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=='date'>
<#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>
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
@ -69,7 +104,9 @@
</#if>
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
<#assign list_need_category=true>
<#assign list_need_dict=true>
</#if>
<#if po.classType=='pca'>
<#assign list_need_pca=true>
</#if>
</#list>
<#-- 结束循环 -->
@ -89,7 +126,6 @@
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
@ -116,6 +152,7 @@
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
@ -128,11 +165,11 @@
<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;"/>
<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>
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
@ -167,7 +204,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.tableName?replace("_","-")}-list :mainId="selectedMainId" />
<${sub.entityName}List :mainId="selectedMainId" />
</a-tab-pane>
<#assign sub_seq=sub_seq+1>
</#list>
@ -191,12 +228,37 @@
<#if query_field_date>
import JDate from '@/components/jeecg/JDate.vue'
</#if>
<#if list_need_dict>
import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#if>
<#if list_need_category>
import { loadCategoryData } from '@/api/api'
</#if>
<#if list_need_dict>
import {initDictOptions,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",
@ -208,6 +270,27 @@
<#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>
<#list subTables as sub>
${sub.entityName}List,
</#list>
@ -242,14 +325,7 @@
dataIndex: '${po.fieldName}',
scopedSlots: {customRender: 'imgSlot'}
<#elseif po.classType=='sel_search' || po.classType=='list_multi' || po.classType=='list' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart'>
dataIndex: '${po.fieldName}',
customRender:(text)=>{
if(!text){
return ''
}else{
return filterMultiDictText(this.dictOptions['${po.fieldName}'], text+"")
}
}
dataIndex: '${po.fieldName}_dictText',
<#elseif po.classType=='cat_tree'>
<#if list_need_category>
dataIndex: '${po.fieldName}',

View File

@ -3,8 +3,18 @@
<template>
<a-card :bordered="false" :class="'cust-erp-sub-tab'">
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button v-if="mainId" @click="handleAdd" type="primary" icon="plus">新增</a-button>
<div class="table-operator" v-if="mainId">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('${sub.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>
@ -36,11 +46,11 @@
<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;"/>
<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>
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
@ -157,7 +167,9 @@
url: {
list: "/${entityPackage}/${entityName?uncap_first}/list${sub.entityName}ByMainId",
delete: "/${entityPackage}/${entityName?uncap_first}/delete${sub.entityName}",
deleteBatch: "/${entityPackage}/${entityName?uncap_first}/deleteBatch${sub.entityName}"
deleteBatch: "/${entityPackage}/${entityName?uncap_first}/deleteBatch${sub.entityName}",
exportXlsUrl: "/${entityPackage}/${entityName?uncap_first}/export${sub.entityName}",
importUrl: "/${entityPackage}/${entityName?uncap_first}/import${sub.entityName}",
},
dictOptions:{
<#list columns as po>
@ -171,6 +183,11 @@
}
},
computed: {
importExcelUrl(){
return `${'$'}{window._CONFIG['domianURL']}/${'$'}{this.url.importUrl}/${'$'}{this.mainId}`;
}
},
methods: {
clearList(){
this.dataSource=[]

View File

@ -1,9 +1,11 @@
<#include "/common/utils.ftl">
<template>
<a-modal
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
@ -17,6 +19,7 @@
<#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 = "">
@ -32,79 +35,86 @@
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}']"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
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}']" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}']" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}']" rows="4" placeholder="请输入${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}']" dict="${form_field_dictCode}" />
<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}']" <#if po.dictField?default("")?trim?length gt 1>pcode="${po.dictField}"<#else>pcode="0"</#if> placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<j-category-select v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" <#if po.dictField?default("")?trim?length gt 1>pcode="${po.dictField}"<#else>pcode="0"</#if> 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}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}']" :trigger-change="true"></j-upload>
<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', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</#if>
</#list>
<#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-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-form>
</a-spin>
</a-modal>
</j-modal>
</template>
<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import { validateDuplicateValue } from '@/utils/util'
<#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>
@ -136,6 +146,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -175,19 +188,7 @@
},
confirmLoading: false,
validatorRules:{
<#list columns as po>
<#if po.isShow =='Y'>
<#if po.fieldName !='id'>
<#if po.nullable =='N'>
${po.fieldName}:{rules: [{ required: true, message: '请输入${po.filedComment}!' }]},
<#else>
${po.fieldName}:{},
</#if>
</#if>
</#if>
</#list>
},
<#include "/common/validatorRulesTemplate/main.ftl">
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add",
edit: "/${entityPackage}/${entityName?uncap_first}/edit",

View File

@ -1,11 +1,13 @@
<#include "/common/utils.ftl">
<#list subTables as sub>
#segment#${sub.entityName}Modal.vue
<template>
<a-modal
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
@ -19,6 +21,7 @@
<#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 = "">
@ -34,79 +37,86 @@
<a-form-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol">
<#if po.classType =='date'>
<#assign form_date=true>
<j-date placeholder="请选择${po.filedComment}" v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" :trigger-change="true" style="width: 100%"/>
<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}', validatorRules.${po.fieldName}]" :trigger-change="true" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
<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}']"
v-decorator="['${po.fieldName}'${autoWriteRules(po)}]"
:trigger-change="true"
org-fields="${po.dictField}"
dest-fields="${po.dictText}"
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}']" :trigger-change="true"/>
<j-select-depart v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}']" :trigger-change="true"/>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#elseif po.classType =='textarea'>
<a-textarea v-decorator="['${po.fieldName}']" rows="4" placeholder="请输入${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}']" :trigger-change="true" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
<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}']" dict="${form_field_dictCode}" />
<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}']" <#if po.dictField?default("")?trim?length gt 1>pcode="${po.dictField}"<#else>pcode="0"</#if> placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${po.dictText}" @change="handleCategoryChange"</#if>/>
<j-category-select v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" <#if po.dictField?default("")?trim?length gt 1>pcode="${po.dictField}"<#else>pcode="0"</#if> 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}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}" style="width: 100%"/>
<#elseif po.classType=='file' || po.classType=='image'>
<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}']" :trigger-change="true"></j-upload>
<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', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}String'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
<#else>
<a-input v-decorator="[ '${po.fieldName}', validatorRules.${po.fieldName}]" placeholder="请输入${po.filedComment}"></a-input>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</#if>
</#list>
<#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-input v-decorator="['${form_cat_back}']"></a-input>
</a-form-item>
</#if>
</a-form>
</a-spin>
</a-modal>
</j-modal>
</template>
<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import { validateDuplicateValue } from '@/utils/util'
<#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>
@ -138,6 +148,9 @@
<#if form_file>
JUpload,
</#if>
<#if form_image>
JImageUpload,
</#if>
<#if form_sel_depart>
JSelectDepart,
</#if>
@ -184,19 +197,7 @@
},
confirmLoading: false,
validatorRules:{
<#list sub.originalColumns as po>
<#if po.isShow =='Y'>
<#if po.fieldName !='id'>
<#if po.nullable =='N'>
${po.fieldName}:{rules: [{ required: true, message: '请输入${po.filedComment}!' }]},
<#else>
${po.fieldName}:{},
</#if>
</#if>
</#if>
</#list>
},
<#include "/common/validatorRulesTemplate/sub.ftl">
url: {
add: "/${entityPackage}/${entityName?uncap_first}/add${sub.entityName}",
edit: "/${entityPackage}/${entityName?uncap_first}/edit${sub.entityName}",

View File

@ -0,0 +1,275 @@
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);
<#-- 包裹分页对象,用于翻译注解 -->
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);
}
</#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,76 @@
<#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 org.jeecg.common.aspect.annotation.Dict;
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>
<#if list_field_dictCode?length gt 1>
@Dict(${list_field_dictCode?substring(2)})
</#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,63 @@
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 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>
/**${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)
</#if>
</#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,375 @@
<#-- noinspection JSDuplicatedDeclaration,RequiredAttributes,NpmUsedModulesInstalled -->
<#-- ** 引入全局工具方法 ** -->
<#--<#include "/common/utils.ftl">-->
<#include "../../../../../../common/utils.ftl">
<#-- ** 定义全局使用的变量 ** -->
<#-- 是否有查询条件 -->
<#assign query_flag=false>
<#-- 是否有下拉查询条件 -->
<#assign query_field_select=false>
<#-- 是否有日期查询条件 -->
<#assign query_field_date=false>
<#-- 是否有字典 -->
<#assign list_need_dict=false>
<#-- 是否有分类字典 -->
<#assign list_need_category=false>
<template>
<a-card class="j-inner-table-wrapper" :bordered="false">
<!-- 查询区域 begin -->
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-row :gutter="24">
<#-- 查询区域 开始循环 -->
<#assign query_field_index=0>
<#list columns as po>
<#if po.isQuery=='Y'>
<#assign query_flag=true>
<#-- 定义组件可能会需要的属性 -->
<#assign attr_showTime="show-time date-format=\"YYYY-MM-DD HH:mm:ss\"">
<#assign indent="">
<#-- 将index>=2的查询条件隐藏起来 -->
<#if query_field_index==2>
<#-- 由于多了一层标签,所以需要多一层缩进 -->
<#assign indent=" ">
<template v-if="toggleSearchStatus">
</#if>
${indent}<a-col :xl="6" :lg="7" :md="8" :sm="24">
${indent}<a-form-item label="${po.filedComment}">
<#-- 普通查询 -->
<#if po.queryMode=='single'>
<#-- 日期组件 -->
<#if po.classType=='date'>
<#assign query_field_date=true>
${indent}<j-date ${getVModel(po)} ${getPlaceholder(po,"请选择")}/>
<#-- 日期时间组件 -->
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
${indent}<j-date ${getVModel(po)} ${getPlaceholder(po,"请选择")} ${attr_showTime}/>
<#-- 下拉组件 -->
<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
<#assign query_field_select=true>
<#-- 下拉或是单选,判断数据字典是表字典还是普通字典 -->
<#if (po.dictTable!"")?trim?length gt 1>
${indent}<j-dict-select-tag ${getVModel(po)} ${getPlaceholder(po,"请选择")} dictCode="${po.dictTable},${po.dictText},${po.dictField}"/>
<#elseif (po.dictField!"")?trim?length gt 1>
${indent}<j-dict-select-tag ${getVModel(po)} ${getPlaceholder(po,"请选择")} dictCode="${po.dictField}"/>
<#else>
${indent}<a-input ${getVModel(po)} ${getPlaceholder(po,"请输入")}/>
</#if>
<#-- 其他都归为输入框组件 -->
<#else>
${indent}<a-input ${getVModel(po)} ${getPlaceholder(po,"请输入")}/>
</#if>
<#-- 范围查询 -->
<#else>
<#-- 范围日期组件 -->
<#if po.classType=='date'>
<#assign query_field_date=true>
${indent}<j-date class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请选择开始日期",false)}/>
${indent}<span class="query-group-split-cust"></span>
${indent}<j-date class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请选择结束日期",false)}/>
<#-- 范围日期时间组件 -->
<#elseif po.classType=='datetime'>
<#assign query_field_date=true>
${indent}<j-date class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请选择开始时间",false)} ${attr_showTime}/>
${indent}<span class="query-group-split-cust"></span>
${indent}<j-date class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请选择结束时间",false)} ${attr_showTime}/>
<#-- 其他都归为范围输入框组件 -->
<#else>
${indent}<a-input class="query-group-cust" ${getVModel(po, "_begin")} ${getPlaceholder(po, "请输入最开始值",false)}/>
${indent}<span class="query-group-split-cust"></span>
${indent}<a-input class="query-group-cust" ${getVModel(po, "_end")} ${getPlaceholder(po, "请输入最结束值",false)}/>
</#if>
</#if>
${indent}</a-form-item>
${indent}</a-col>
<#assign query_field_index=query_field_index+1>
</#if>
<#-- 判断是否需要字典 -->
<#if !list_need_dict && po.fieldShowType != 'popup' && (po.dictField!"")?trim?length gt 1>
<#assign list_need_dict=true>
</#if>
<#-- 判断是否需要分类字典 -->
<#if po.classType == 'cat_tree' && (po.dictText!"")?trim?length == 0>
<#assign list_need_category=true>
</#if>
</#list>
<#-- 查询区域-结束循环 -->
<#if query_field_index gt 2>
</template>
</#if>
<#if query_flag>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span class="table-page-search-submitButtons table-operator">
<a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
<a-button type="primary" icon="reload" @click="searchReset">重置</a-button>
<a @click="handleToggleSearch" style="margin-left: 8px">
<span>{{ toggleSearchStatus ? '收起' : '展开' }}</span>
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
</span>
</a-col>
</#if>
</a-row>
</a-form>
</div>
<!-- 查询区域 end -->
<!-- 操作按钮区域 begin -->
<div class="table-operator">
<a-button type="primary" icon="plus" @click="handleAdd">新增</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"/>
<span>删除</span>
</a-menu-item>
</a-menu>
<a-button>
<span>批量操作</span>
<a-icon type="down"/>
</a-button>
</a-dropdown>
</div>
<!-- 操作按钮区域 end -->
<!-- table区域 begin -->
<div>
<a-alert type="info" showIcon style="margin-bottom: 16px;">
<template slot="message">
<span>已选择</span>
<a style="font-weight: 600;padding: 0 4px;">{{ selectedRowKeys.length }}</a>
<span>项</span>
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</template>
</a-alert>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
class="j-table-force-nowrap"
:loading="loading"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:expandedRowKeys="expandedRowKeys"
:rowSelection="{selectedRowKeys, onChange: onSelectChange}"
@expand="handleExpand"
@change="handleTableChange"
>
<!-- 内嵌table区域 begin -->
<template slot="expandedRowRender" slot-scope="record">
<a-tabs tabPosition="top">
<#list subTables as sub>
<a-tab-pane tab="${sub.ftlDescription}" key="${sub.entityName?uncap_first}" forceRender>
<#assign subTableCompName=camelToHorizontal("${sub.entityName?uncap_first}", "lower")/>
<${subTableCompName}-sub-table :record="record"/>
</a-tab-pane>
</#list>
</a-tabs>
</template>
<!-- 内嵌table区域 end -->
<template slot="htmlSlot" slot-scope="text">
<div v-html="text"></div>
</template>
<template slot="imgSlot" slot-scope="text">
<div style="font-size: 12px;font-style: italic;">
<span v-if="!text">无图片</span>
<img v-else :src="getImgView(text)" alt="" style="max-width:80px;height:25px;"/>
</div>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
ghost
type="primary"
icon="download"
size="small"
@click="uploadFile(text)"
>
<span>下载</span>
</a-button>
</template>
<template slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical"/>
<a-dropdown>
<a class="ant-dropdown-link">
<span>更多 <a-icon type="down"/></span>
</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>
</template>
</a-table>
</div>
<!-- table区域 end -->
<!-- 表单区域 -->
<#assign modalForm=camelToHorizontal("${entityName?uncap_first}", "lower")/>
<${modalForm}-modal ref="modalForm" @ok="modalFormOk"/>
</a-card>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ${entityName}Modal from './modules/${entityName}Modal'
<#list subTables as sub>
import ${sub.entityName}SubTable from './subTables/${sub.entityName}SubTable'
</#list>
<#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_dict>
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
</#if>
<#if list_need_category>
import { loadCategoryData } from '@/api/api'
</#if>
import '@/assets/less/TableExpand.less'
export default {
name: '${entityName}List',
mixins: [JeecgListMixin],
components: {
${entityName}Modal,
<#list subTables as sub>
${sub.entityName}SubTable,
</#list>
<#if query_field_date>
JDate,
</#if>
<#if query_field_select>
JDictSelectTag,
</#if>
},
data() {
return {
description: '${tableVo.ftlDescription}列表管理页面',
// 表头
columns: [
{
title: '#',
key: 'rowIndex',
width: 60,
align: 'center',
customRender: (t, r, index) => parseInt(index) + 1
},
<#-- begin 遍历表头 -->
<#list columns as po>
<#if po.isShowList == 'Y'>
{
title: '${po.filedComment}',
align: 'center',
<#if po.classType == 'date'>
dataIndex: '${po.fieldName}',
<#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=='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>
<#-- end 遍历表头 -->
{
title: '操作',
dataIndex: 'action',
align: 'center',
scopedSlots: { customRender: 'action' },
},
],
// 字典选项
dictOptions: {},
// 展开的行
expandedRowKeys: [],
<#assign urlPrefix="/${entityPackage}/${entityName?uncap_first}">
url: {
list: '${urlPrefix}/list',
delete: '${urlPrefix}/delete',
deleteBatch: '${urlPrefix}/deleteBatch',
exportXlsUrl: '${urlPrefix}/exportXls',
importExcelUrl: '${urlPrefix}/importExcel',
},
}
},
computed: {
importExcelUrl() {
return window._CONFIG['domianURL'] + this.url.importExcelUrl
}
},
methods: {
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>
},
handleExpand(expanded, record) {
this.expandedRowKeys = []
if (expanded === true) {
this.expandedRowKeys.push(record.id)
}
},
}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
</style>

View File

@ -0,0 +1,436 @@
<#include "/common/utils.ftl">
<template>
<j-modal
:title="title"
:width="1200"
:visible="visible"
:maskClosable="false"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel">
<a-spin :spinning="confirmLoading">
<!-- 主表单区域 -->
<a-form :form="form">
<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 = "">
<#list columns as po>
<#if po.isShow =='Y'>
<#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="${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)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#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-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"></${Format.humpToShortbar(sub.entityName)}-form>
</a-tab-pane>
<#else>
<a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true">
<j-editable-table
: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"
: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'
<#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>
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_cat_tree>
JCategorySelect
</#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>],
tableKeys:[<#list subTables as sub><#if sub.foreignRelationType =='0'>'${sub.entityName?uncap_first}', </#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: 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:"${col.dictText}",
orgFields:"${col.dictField}",
<#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",
<#list subTables as sub><#rt/>
${sub.entityName?uncap_first}: {
list: '/${entityPackage}/${entityName?uncap_first}/query${sub.entityName}ByMainId'
},
</#list>
}
}
},
methods: {
getAllTable() {
let values = this.tableKeys.map(key => getRefPromise(this, key))
return Promise.all(values)
},
/** 调用完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>
}
},
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,213 @@
<#include "/common/utils.ftl">
<#list subTables as sub>
<#if sub.foreignRelationType=='1'>
#segment#${sub.entityName}Form.vue
<template>
<div>
<a-form :form="form">
<a-row>
<#assign form_date = false>
<#assign form_select = false>
<#assign form_select_multi = false>
<#assign form_popup = false>
<#assign form_sel_depart = false>
<#assign form_sel_user = false>
<#assign form_file = false>
<#assign form_image = false>
<#list sub.colums as po>
<#if po.isShow =='Y'>
<#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)}]" :trigger-change="true"/>
<#elseif po.classType =='sel_user'>
<#assign form_sel_user = true>
<j-select-user-by-dep v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" :trigger-change="true"/>
<#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.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>
<#else>
<a-input v-decorator="['${po.fieldName}'${autoWriteRules(po)}]" placeholder="请输入${po.filedComment}"></a-input>
</#if>
</a-form-item>
</a-col>
</#if>
</#list>
</a-row>
</a-form>
</div>
</template>
<script>
import pick from 'lodash.pick'
import { getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
<#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>
export default {
name: '${sub.entityName}Form',
components: {
<#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>
},
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.records
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={}
}
}
}
</script>
</#if>
</#list>

View File

@ -0,0 +1,139 @@
<#--noinspection JSDuplicatedDeclaration-->
<#list subTables as sub>
#segment#${sub.entityName}SubTable.vue
<template>
<a-table
rowKey="id"
size="middle"
bordered
:loading="loading"
:columns="columns"
:dataSource="dataSource"
:pagination="false"
>
<template slot="htmlSlot" slot-scope="text">
<div v-html="text"></div>
</template>
<template slot="imgSlot" slot-scope="text">
<div style="font-size: 12px;font-style: italic;">
<span v-if="!text">无图片</span>
<img v-else :src="getImgView(text)" alt="" style="max-width:80px;height:25px;"/>
</div>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
ghost
type="primary"
icon="download"
size="small"
@click="uploadFile(text)"
>
<span>下载</span>
</a-button>
</template>
</a-table>
</template>
<script>
import { getAction } from '@api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
name: '${sub.entityName}SubTable',
mixins: [JeecgListMixin],
props: {
record: {
type: Object,
default: null,
}
},
data() {
return {
description: '${sub.ftlDescription}内嵌列表',
disableMixinCreated: true,
loading: false,
dataSource: [],
columns: [
<#-- begin 遍历表头 -->
<#list sub.originalColumns as po>
<#if po.isShowList == 'Y'>
{
title: '${po.filedComment}',
align: 'center',
<#if po.classType == 'date'>
dataIndex: '${po.fieldName}',
<#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=='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>
<#-- end 遍历表头 -->
],
<#assign urlPrefix="/${entityPackage}/${entityName?uncap_first}">
url: {
listByMainId: '${urlPrefix}/query${sub.entityName}ByMainId',
},
}
},
watch: {
record: {
immediate: true,
handler() {
if (this.record != null) {
this.loadData(this.record)
}
}
}
},
methods: {
loadData(record) {
this.loading = true
this.dataSource = []
getAction(this.url.listByMainId, {
id: record.id
}).then((res) => {
if (res.success) {
this.dataSource = res.result.records
}
}).finally(() => {
this.loading = false
})
},
},
}
</script>
<style scoped>
</style>
</#list>