From 40596bf475d33ce22c3526e00c8eb9fa9e567a0e Mon Sep 17 00:00:00 2001 From: shikeying <shikeying@163.com> Date: 星期一, 08 四月 2024 13:54:57 +0800 Subject: [PATCH] mybatis --- iplatform-support-mybatis/src/main/resources/vm/java/domain.java.vm | 45 iplatform-support-mybatis/src/main/resources/vm/java/vo.java.vm | 48 iplatform-support-mybatis/src/main/resources/vm/js/api.js.vm | 44 iplatform-support-mybatis/src/main/resources/vm/vue/index-tree.vue.vm | 505 +++++++++ iplatform-support-mybatis/src/main/resources/vm/vue/index.vue.vm | 602 +++++++++++ iplatform-support-mybatis/src/main/resources/generator.yml | 10 iplatform-support-mybatis/src/main/resources/vm/java/queryBo.java.vm | 57 + iplatform-support-mybatis/src/main/resources/vm/vue/v3/readme.txt | 1 iplatform-support-mybatis/src/main/resources/vm/java/bo.java.vm | 40 iplatform-support-mybatis/src/main/resources/vm/sql/sql.vm | 22 iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableMapper.xml | 206 +++ iplatform-support-mybatis/src/main/resources/vm/java/controller.java.vm | 118 ++ iplatform-support-mybatis/src/main/resources/vm/vue/v3/index.vue.vm | 590 +++++++++++ iplatform-support-mybatis/src/main/resources/vm/java/mapper.java.vm | 14 iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableColumnMapper.xml | 127 ++ iplatform-support-mybatis/src/main/resources/vm/java/serviceImpl.java.vm | 125 ++ iplatform-support-mybatis/src/main/resources/vm/java/sub-domain.java.vm | 74 + iplatform-support-mybatis/src/main/resources/vm/java/service.java.vm | 53 + iplatform-support-mybatis/src/main/resources/vm/vue/v3/index-tree.vue.vm | 474 ++++++++ iplatform-support-mybatis/src/main/resources/vm/xml/mapper.xml.vm | 15 20 files changed, 3,170 insertions(+), 0 deletions(-) diff --git a/iplatform-support-mybatis/src/main/resources/generator.yml b/iplatform-support-mybatis/src/main/resources/generator.yml new file mode 100644 index 0000000..b12ef6a --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/generator.yml @@ -0,0 +1,10 @@ +# 浠g爜鐢熸垚 +gen: + # 浣滆�� + author: admin + # 榛樿鐢熸垚鍖呰矾寰� system 闇�鏀规垚鑷繁鐨勬ā鍧楀悕绉� 濡� system monitor tool + packageName: com.iplatform.mybatis + # 鑷姩鍘婚櫎琛ㄥ墠缂�锛岄粯璁ゆ槸false + autoRemovePre: false + # 琛ㄥ墠缂�锛堢敓鎴愮被鍚嶄笉浼氬寘鍚〃鍓嶇紑锛屽涓敤閫楀彿鍒嗛殧锛� + tablePrefix: s_ diff --git a/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableColumnMapper.xml new file mode 100644 index 0000000..c369415 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -0,0 +1,127 @@ +<?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="com.iplatform.mybatis.mapper.GenTableColumnMapper"> + + <resultMap type="com.iplatform.mybatis.domain.GenTableColumn" id="GenTableColumnResult"> + <id property="columnId" column="column_id" /> + <result property="tableId" column="table_id" /> + <result property="columnName" column="column_name" /> + <result property="columnComment" column="column_comment" /> + <result property="columnType" column="column_type" /> + <result property="javaType" column="java_type" /> + <result property="javaField" column="java_field" /> + <result property="isPk" column="is_pk" /> + <result property="isIncrement" column="is_increment" /> + <result property="isRequired" column="is_required" /> + <result property="isInsert" column="is_insert" /> + <result property="isEdit" column="is_edit" /> + <result property="isList" column="is_list" /> + <result property="isQuery" column="is_query" /> + <result property="queryType" column="query_type" /> + <result property="htmlType" column="html_type" /> + <result property="dictType" column="dict_type" /> + <result property="sort" column="sort" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + </resultMap> + + <sql id="selectGenTableColumnVo"> + select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column + </sql> + + <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> + <include refid="selectGenTableColumnVo"/> + where table_id = #{tableId} + order by sort + </select> + + <select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult"> + select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type + from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName}) + order by ordinal_position + </select> + + <insert id="insertGenTableColumn" parameterType="com.iplatform.mybatis.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId"> + insert into gen_table_column ( + <if test="tableId != null and tableId != ''">table_id,</if> + <if test="columnName != null and columnName != ''">column_name,</if> + <if test="columnComment != null and columnComment != ''">column_comment,</if> + <if test="columnType != null and columnType != ''">column_type,</if> + <if test="javaType != null and javaType != ''">java_type,</if> + <if test="javaField != null and javaField != ''">java_field,</if> + <if test="isPk != null and isPk != ''">is_pk,</if> + <if test="isIncrement != null and isIncrement != ''">is_increment,</if> + <if test="isRequired != null and isRequired != ''">is_required,</if> + <if test="isInsert != null and isInsert != ''">is_insert,</if> + <if test="isEdit != null and isEdit != ''">is_edit,</if> + <if test="isList != null and isList != ''">is_list,</if> + <if test="isQuery != null and isQuery != ''">is_query,</if> + <if test="queryType != null and queryType != ''">query_type,</if> + <if test="htmlType != null and htmlType != ''">html_type,</if> + <if test="dictType != null and dictType != ''">dict_type,</if> + <if test="sort != null">sort,</if> + <if test="createBy != null and createBy != ''">create_by,</if> + create_time + )values( + <if test="tableId != null and tableId != ''">#{tableId},</if> + <if test="columnName != null and columnName != ''">#{columnName},</if> + <if test="columnComment != null and columnComment != ''">#{columnComment},</if> + <if test="columnType != null and columnType != ''">#{columnType},</if> + <if test="javaType != null and javaType != ''">#{javaType},</if> + <if test="javaField != null and javaField != ''">#{javaField},</if> + <if test="isPk != null and isPk != ''">#{isPk},</if> + <if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if> + <if test="isRequired != null and isRequired != ''">#{isRequired},</if> + <if test="isInsert != null and isInsert != ''">#{isInsert},</if> + <if test="isEdit != null and isEdit != ''">#{isEdit},</if> + <if test="isList != null and isList != ''">#{isList},</if> + <if test="isQuery != null and isQuery != ''">#{isQuery},</if> + <if test="queryType != null and queryType != ''">#{queryType},</if> + <if test="htmlType != null and htmlType != ''">#{htmlType},</if> + <if test="dictType != null and dictType != ''">#{dictType},</if> + <if test="sort != null">#{sort},</if> + <if test="createBy != null and createBy != ''">#{createBy},</if> + sysdate() + ) + </insert> + + <update id="updateGenTableColumn" parameterType="com.iplatform.mybatis.domain.GenTableColumn"> + update gen_table_column + <set> + <if test="columnComment != null">column_comment = #{columnComment},</if> + <if test="javaType != null">java_type = #{javaType},</if> + <if test="javaField != null">java_field = #{javaField},</if> + <if test="isInsert != null">is_insert = #{isInsert},</if> + <if test="isEdit != null">is_edit = #{isEdit},</if> + <if test="isList != null">is_list = #{isList},</if> + <if test="isQuery != null">is_query = #{isQuery},</if> + <if test="isRequired != null">is_required = #{isRequired},</if> + <if test="queryType != null">query_type = #{queryType},</if> + <if test="htmlType != null">html_type = #{htmlType},</if> + <if test="dictType != null">dict_type = #{dictType},</if> + <if test="sort != null">sort = #{sort},</if> + <if test="updateBy != null">update_by = #{updateBy},</if> + update_time = sysdate() + </set> + where column_id = #{columnId} + </update> + + <delete id="deleteGenTableColumnByIds" parameterType="Long"> + delete from gen_table_column where table_id in + <foreach collection="array" item="tableId" open="(" separator="," close=")"> + #{tableId} + </foreach> + </delete> + + <delete id="deleteGenTableColumns"> + delete from gen_table_column where column_id in + <foreach collection="list" item="item" open="(" separator="," close=")"> + #{item.columnId} + </foreach> + </delete> + +</mapper> diff --git a/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableMapper.xml b/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableMapper.xml new file mode 100644 index 0000000..5cee35d --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/mapper/generator/GenTableMapper.xml @@ -0,0 +1,206 @@ +<?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="com.iplatform.mybatis.mapper.GenTableMapper"> + + <resultMap type="com.iplatform.mybatis.domain.GenTable" id="GenTableResult"> + <id property="tableId" column="table_id" /> + <result property="tableName" column="table_name" /> + <result property="tableComment" column="table_comment" /> + <result property="subTableName" column="sub_table_name" /> + <result property="subTableFkName" column="sub_table_fk_name" /> + <result property="className" column="class_name" /> + <result property="tplCategory" column="tpl_category" /> + <result property="packageName" column="package_name" /> + <result property="moduleName" column="module_name" /> + <result property="businessName" column="business_name" /> + <result property="functionName" column="function_name" /> + <result property="functionAuthor" column="function_author" /> + <result property="genType" column="gen_type" /> + <result property="genPath" column="gen_path" /> + <result property="options" column="options" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + <result property="remark" column="remark" /> + <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" /> + </resultMap> + + <resultMap type="com.iplatform.mybatis.domain.GenTableColumn" id="GenTableColumnResult"> + <id property="columnId" column="column_id" /> + <result property="tableId" column="table_id" /> + <result property="columnName" column="column_name" /> + <result property="columnComment" column="column_comment" /> + <result property="columnType" column="column_type" /> + <result property="javaType" column="java_type" /> + <result property="javaField" column="java_field" /> + <result property="isPk" column="is_pk" /> + <result property="isIncrement" column="is_increment" /> + <result property="isRequired" column="is_required" /> + <result property="isInsert" column="is_insert" /> + <result property="isEdit" column="is_edit" /> + <result property="isList" column="is_list" /> + <result property="isQuery" column="is_query" /> + <result property="queryType" column="query_type" /> + <result property="htmlType" column="html_type" /> + <result property="dictType" column="dict_type" /> + <result property="sort" column="sort" /> + <result property="createBy" column="create_by" /> + <result property="createTime" column="create_time" /> + <result property="updateBy" column="update_by" /> + <result property="updateTime" column="update_time" /> + </resultMap> + + <sql id="selectGenTableVo"> + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table + </sql> + + <select id="selectGenTableList" parameterType="com.iplatform.mybatis.domain.GenTable" resultMap="GenTableResult"> + <include refid="selectGenTableVo"/> + <where> + <if test="tableName != null and tableName != ''"> + AND lower(table_name) like lower(concat('%', #{tableName}, '%')) + </if> + <if test="tableComment != null and tableComment != ''"> + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) + </if> + <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� --> + AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') + </if> + <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� --> + AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') + </if> + </where> + </select> + + <select id="selectDbTableList" parameterType="com.iplatform.mybatis.domain.GenTable" resultMap="GenTableResult"> + select table_name, table_comment, update_time from information_schema.tables + where table_schema = (select database()) + AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%' + AND table_name NOT IN (select table_name from gen_table) + <if test="tableName != null and tableName != ''"> + AND lower(table_name) like lower(concat('%', #{tableName}, '%')) + </if> + <if test="tableComment != null and tableComment != ''"> + AND lower(table_comment) like lower(concat('%', #{tableComment}, '%')) + </if> + <!-- 寮�濮嬫椂闂存绱� --> +<!-- <if test="params.beginTime != null and params.beginTime != ''">--> +<!-- AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')--> +<!-- </if>--> + <!-- 缁撴潫鏃堕棿妫�绱� --> +<!-- <if test="params.endTime != null and params.endTime != ''">--> +<!-- AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')--> +<!-- </if>--> +-- order by create_time desc + </select> + + <select id="selectDbTableListByNames" resultMap="GenTableResult"> + select table_name, table_comment, create_time, update_time from information_schema.tables + where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) + and table_name in + <foreach collection="array" item="name" open="(" separator="," close=")"> + #{name} + </foreach> + </select> + + <select id="selectTableByName" parameterType="String" resultMap="GenTableResult"> + select table_name, table_comment, create_time, update_time from information_schema.tables + where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database()) + and table_name = #{tableName} + </select> + + <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort + FROM gen_table t + LEFT JOIN gen_table_column c ON t.table_id = c.table_id + where t.table_id = #{tableId} order by c.sort + </select> + + <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort + FROM gen_table t + LEFT JOIN gen_table_column c ON t.table_id = c.table_id + where t.table_name = #{tableName} order by c.sort + </select> + + <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> + SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark, + c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort + FROM gen_table t + LEFT JOIN gen_table_column c ON t.table_id = c.table_id + order by c.sort + </select> + + <insert id="insertGenTable" parameterType="com.iplatform.mybatis.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId"> + insert into gen_table ( + <if test="tableName != null">table_name,</if> + <if test="tableComment != null and tableComment != ''">table_comment,</if> + <if test="className != null and className != ''">class_name,</if> + <if test="tplCategory != null and tplCategory != ''">tpl_category,</if> + <if test="packageName != null and packageName != ''">package_name,</if> + <if test="moduleName != null and moduleName != ''">module_name,</if> + <if test="businessName != null and businessName != ''">business_name,</if> + <if test="functionName != null and functionName != ''">function_name,</if> + <if test="functionAuthor != null and functionAuthor != ''">function_author,</if> + <if test="genType != null and genType != ''">gen_type,</if> + <if test="genPath != null and genPath != ''">gen_path,</if> + <if test="remark != null and remark != ''">remark,</if> + <if test="createBy != null and createBy != ''">create_by,</if> + create_time + )values( + <if test="tableName != null">#{tableName},</if> + <if test="tableComment != null and tableComment != ''">#{tableComment},</if> + <if test="className != null and className != ''">#{className},</if> + <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if> + <if test="packageName != null and packageName != ''">#{packageName},</if> + <if test="moduleName != null and moduleName != ''">#{moduleName},</if> + <if test="businessName != null and businessName != ''">#{businessName},</if> + <if test="functionName != null and functionName != ''">#{functionName},</if> + <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if> + <if test="genType != null and genType != ''">#{genType},</if> + <if test="genPath != null and genPath != ''">#{genPath},</if> + <if test="remark != null and remark != ''">#{remark},</if> + <if test="createBy != null and createBy != ''">#{createBy},</if> +-- sysdate() + 0 + ) + </insert> + + <update id="updateGenTable" parameterType="com.iplatform.mybatis.domain.GenTable"> + update gen_table + <set> + <if test="tableName != null">table_name = #{tableName},</if> + <if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if> + <if test="subTableName != null">sub_table_name = #{subTableName},</if> + <if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if> + <if test="className != null and className != ''">class_name = #{className},</if> + <if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if> + <if test="genType != null and genType != ''">gen_type = #{genType},</if> + <if test="genPath != null and genPath != ''">gen_path = #{genPath},</if> + <if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> + <if test="packageName != null and packageName != ''">package_name = #{packageName},</if> + <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if> + <if test="businessName != null and businessName != ''">business_name = #{businessName},</if> + <if test="functionName != null and functionName != ''">function_name = #{functionName},</if> + <if test="options != null and options != ''">options = #{options},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + <if test="remark != null">remark = #{remark},</if> +-- update_time = sysdate() + update_time = 0 + </set> + where table_id = #{tableId} + </update> + + <delete id="deleteGenTableByIds" parameterType="Long"> + delete from gen_table where table_id in + <foreach collection="array" item="tableId" open="(" separator="," close=")"> + #{tableId} + </foreach> + </delete> + +</mapper> diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/bo.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/bo.java.vm new file mode 100644 index 0000000..1deedc4 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/bo.java.vm @@ -0,0 +1,40 @@ +package ${packageName}.domain.bo; + +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import java.util.Date; + +#foreach ($import in $importList) +import ${import}; +#end + +/** + * ${functionName}缂栬緫瀵硅薄 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +@Data +//@ApiModel("${functionName}鎿嶄綔瀵硅薄") +public class ${ClassName}Bo { + +#foreach ($column in $columns) +#if($column.isEdit || $column.isPk==1) + + /** $column.columnComment */ + //@ApiModelProperty("$column.columnComment") +#if($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") +#end + private $column.javaType $column.javaField; +#end +#end +#if($table.sub) + + /** $table.subTable.functionName淇℃伅 */ + //@ApiModelProperty("$table.subTable.functionName") + private List<${subClassName}> ${subclassName}List; +#end +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/controller.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/controller.java.vm new file mode 100644 index 0000000..d58c52f --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/controller.java.vm @@ -0,0 +1,118 @@ +package ${packageName}.controller; + +import java.util.List; +import java.util.Arrays; + +import com.insurance.common.annotation.RepeatSubmit; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.insurance.common.annotation.Log; +import com.insurance.common.core.controller.BaseController; +import com.insurance.common.core.domain.AjaxResult; +import com.insurance.common.enums.BusinessType; +import ${packageName}.domain.vo.${ClassName}Vo; +import ${packageName}.domain.bo.${ClassName}Bo; +import ${packageName}.domain.bo.${ClassName}QueryBo; +import ${packageName}.service.I${ClassName}Service; +import com.insurance.common.utils.poi.ExcelUtil; +#if($table.crud || $table.sub) +import com.insurance.common.core.page.TableDataInfo; +#elseif($table.tree) +#end +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +/** + * ${functionName}Controller + * + * @author ${author} + * @date ${datetime} + */ +@Api(value = "${functionName}鎺у埗鍣�", tags = {"${functionName}绠$悊"}) +@RequiredArgsConstructor(onConstructor_ = @Autowired) +@RestController +@RequestMapping("/${moduleName}/${businessName}") +public class ${ClassName}Controller extends BaseController { + + private final I${ClassName}Service i${ClassName}Service; + + + @ApiOperation("鏌ヨ${functionName}鍒楄〃") + @GetMapping("/list") +#if($table.crud || $table.sub) + public TableDataInfo list(${ClassName}QueryBo bo) + { + startPage(); + List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); + return getDataTable(list); + } +#elseif($table.tree) + public AjaxResult list(${ClassName}QueryBo bo) + { + List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); + return AjaxResult.success(list); + } +#end + + + + @ApiOperation("瀵煎嚭${functionName}鍒楄〃") + //@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") + @Log(title = "${functionName}", businessType = BusinessType.EXPORT) + @GetMapping("/export") + @RepeatSubmit + public AjaxResult export(${ClassName}QueryBo bo) + { + List<${ClassName}Vo> list = i${ClassName}Service.queryList(bo); + ExcelUtil<${ClassName}Vo> util = new ExcelUtil<${ClassName}Vo>(${ClassName}Vo.class); + return util.exportExcel(list, "${functionName}"); + } + + + @ApiOperation("鑾峰彇${functionName}璇︾粏淇℃伅") + @GetMapping("/{${pkColumn.javaField}}") + public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) + { + return AjaxResult.success(i${ClassName}Service.queryById(${pkColumn.javaField})); + } + + + @ApiOperation("鏂板${functionName}") + //@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") + @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @PostMapping("/add") + @RepeatSubmit + public AjaxResult add(@RequestBody ${ClassName}Bo bo) + { + return toAjax(i${ClassName}Service.insertByBo(bo) ? 1 : 0); + } + + + @ApiOperation("淇敼${functionName}") + //@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") + @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @PostMapping("/upd") + @RepeatSubmit + public AjaxResult upd(@RequestBody ${ClassName}Bo bo) + { + return toAjax(i${ClassName}Service.updateByBo(bo) ? 1 : 0); + } + + + @ApiOperation("鍒犻櫎${functionName}") + //@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") + @Log(title = "${functionName}" , businessType = BusinessType.DELETE) + @DeleteMapping("/{${pkColumn.javaField}s}") + @RepeatSubmit + public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) + { + return toAjax(i${ClassName}Service.deleteByIds(Arrays.asList(${pkColumn.javaField}s)) ? 1 : 0); + } +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/domain.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/domain.java.vm new file mode 100644 index 0000000..acbf19e --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/domain.java.vm @@ -0,0 +1,45 @@ +package ${packageName}.domain; + +import com.baomidou.mybatisplus.annotation.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +/** + * ${functionName}瀵硅薄 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +@Data +@NoArgsConstructor +@Accessors(chain = true) +@TableName("${tableName}") +//@ApiModel("${functionName}瀹炰綋瀵硅薄") +public class ${ClassName} implements Serializable { + + private static final long serialVersionUID=1L; + +#foreach ($column in $columns) + +#if($column.javaField=="createBy"||$column.javaField=="createTime") +#end +#if($column.javaField=="updateBy"||$column.javaField=="updateTime") + @TableField(fill = FieldFill.INSERT_UPDATE) +#end +#if($column.javaField=='delFlag') + @TableLogic(value = "0",delval = "1") +#end +#if($column.isPk==1) + @TableId(value = "$column.columnName") +#end + @ApiModelProperty("$column.columnComment") + private $column.javaType $column.javaField; +#end + +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/mapper.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/mapper.java.vm new file mode 100644 index 0000000..bba2b15 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/mapper.java.vm @@ -0,0 +1,14 @@ +package ${packageName}.mapper; + +import ${packageName}.domain.${ClassName}; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * ${functionName}Mapper鎺ュ彛 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { + +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/queryBo.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/queryBo.java.vm new file mode 100644 index 0000000..820b04c --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/queryBo.java.vm @@ -0,0 +1,57 @@ +package ${packageName}.domain.bo; + +import com.insurance.common.core.domain.BaseQuery; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +#foreach ($import in $importList) +import ${import}; +#end +#if($table.crud || $table.sub) +#elseif($table.tree) +#end + +/** + * ${functionName}鍒嗛〉鏌ヨ瀵硅薄 ${tableName} + * + * @author ${author} + * @date ${datetime} + */ +#if($table.crud || $table.sub) +#set($Entity="BaseEntity") +#elseif($table.tree) +#set($Entity="TreeEntity") +#end +@EqualsAndHashCode(callSuper = true) +@Data +//@ApiModel("${functionName}鍒嗛〉鏌ヨ瀵硅薄") +public class ${ClassName}QueryBo extends BaseQuery{ + + /** 鍒嗛〉澶у皬 */ + @ApiModelProperty("鍒嗛〉澶у皬") + private Integer pageSize; + /** 褰撳墠椤垫暟 */ + @ApiModelProperty("褰撳墠椤垫暟") + private Integer pageNum; + /** 鎺掑簭鍒� */ + @ApiModelProperty("鎺掑簭鍒�") + private String orderByColumn; + /** 鎺掑簭鐨勬柟鍚慸esc鎴栬�卆sc */ + @ApiModelProperty(value = "鎺掑簭鐨勬柟鍚�", example = "asc,desc") + private String isAsc; + + +#foreach ($column in $columns) +#if(!$table.isSuperColumn($column.javaField) && $column.query) + /** $column.columnComment */ +#if($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") +#end + //@ApiModelProperty("$column.columnComment") + private $column.javaType $column.javaField; +#end +#end + +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/service.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/service.java.vm new file mode 100644 index 0000000..4b09c80 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/service.java.vm @@ -0,0 +1,53 @@ +package ${packageName}.service; + +import ${packageName}.domain.${ClassName}; +import ${packageName}.domain.vo.${ClassName}Vo; +import ${packageName}.domain.bo.${ClassName}Bo; +import ${packageName}.domain.bo.${ClassName}QueryBo; +import com.baomidou.mybatisplus.extension.service.IService; +import com.iplatform.mybatis.IBaseService; + +import java.util.Collection; +import java.util.List; + +/** + * ${functionName}Service鎺ュ彛 + * + * @author ${author} + * @date ${datetime} + */ +public interface I${ClassName}Service extends IBaseService<${ClassName}> { + + /** + * 鏌ヨ鍒楄〃 + */ + List<${ClassName}Vo> queryList(${ClassName}QueryBo bo); + + /** + * 鏌ヨ鍗曚釜 + * @return ${ClassName}Vo + */ + ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}); + + + /** + * 鏍规嵁鏂板涓氬姟瀵硅薄鎻掑叆${functionName} + * @param bo ${functionName}鏂板涓氬姟瀵硅薄 + * @return true鎴愬姛 false澶辫触 + */ + Boolean insertByBo(${ClassName}Bo bo); + + /** + * 鏍规嵁缂栬緫涓氬姟瀵硅薄淇敼${functionName} + * @param bo ${functionName}缂栬緫涓氬姟瀵硅薄 + * @return true鎴愬姛 false澶辫触 + */ + Boolean updateByBo(${ClassName}Bo bo); + + /** + * 鏍¢獙骞跺垹闄ゆ暟鎹� + * @param ids 涓婚敭闆嗗悎 + * @return true鎴愬姛 false澶辫触 + */ + Boolean deleteByIds(Collection<Long> ids); +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/serviceImpl.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/serviceImpl.java.vm new file mode 100644 index 0000000..eb73061 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/serviceImpl.java.vm @@ -0,0 +1,125 @@ +package ${packageName}.service.impl; + +import lombok.RequiredArgsConstructor; +import cn.hutool.core.convert.Convert; +import com.iplatform.core.util.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import ${packageName}.domain.vo.${ClassName}Vo; +import ${packageName}.domain.bo.${ClassName}Bo; +import ${packageName}.domain.bo.${ClassName}QueryBo; +import ${packageName}.domain.${ClassName}; +import ${packageName}.mapper.${ClassName}Mapper; +import ${packageName}.service.I${ClassName}Service; + +import java.util.Collection; +import java.util.List; + +/** + * ${functionName}Service涓氬姟灞傚鐞� + * + * @author ${author} + * @date ${datetime} + */ +@Service +@RequiredArgsConstructor(onConstructor_ = @Autowired) +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { + + @Override//鍒楄〃鏌ヨ + public List<${ClassName}Vo> queryList(${ClassName}QueryBo bo) + { + QueryWrapper<${ClassName}> qw = getQw(bo); + List<${ClassName}> list = this.list(qw); + return Convert.toList(${ClassName}Vo.class , list); + } + + @Override//id鏌ヨ + public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}) + { + ${ClassName} db = this.baseMapper.selectById(${pkColumn.javaField}); + return Convert.convert(${ClassName}Vo.class , db); + } + + + @Override//娣诲姞 + @Transactional + public Boolean insertByBo(${ClassName}Bo bo) + { + ${ClassName} add = Convert.convert(${ClassName}.class, bo); + validEntityBeforeSave(add); + return this.save(add); + } + + @Override//淇敼 + @Transactional + public Boolean updateByBo(${ClassName}Bo bo) + { + ${ClassName} update = Convert.convert(${ClassName}.class, bo); + validEntityBeforeSave(update); + return this.updateById(update); + } + + @Override//鍒犻櫎 + @Transactional + public Boolean deleteByIds(Collection<Long> ids) + { + + //鍋氫竴浜涗笟鍔′笂鐨勬牎楠�,鍒ゆ柇鏄惁闇�瑕佹牎楠� + + return this.removeByIds(ids); + } + + +//------------------------------------------------------------------------------------- + + //淇濆瓨鍓嶆牎楠� + private void validEntityBeforeSave(${ClassName} entity) + { + //鍋氫竴浜涙暟鎹牎楠�,濡傚敮涓�绾︽潫 + } + + //鑾峰彇鏌ヨ鍙傛暟 + private QueryWrapper<${ClassName}> getQw(${ClassName}QueryBo bo) + { + QueryWrapper<${ClassName}> qw = Wrappers.query(); + + #foreach($column in $columns) + #if($column.query) + #set($queryType=$column.queryType) + #set($javaField=$column.javaField) + #set($javaType=$column.javaType) + #set($columnName=$column.columnName) + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #set($mpMethod=$column.queryType.toLowerCase()) + #if($queryType != 'BETWEEN') + #if($javaType == 'String') + #set($condition='StringUtils.isNotEmpty(bo.get'+$AttrName+'())') + #else + #set($condition='bo.get'+$AttrName+'() != null') + #end + qw.$mpMethod($condition, "${columnName}", bo.get$AttrName()); + #else + Object dataScope = bo.getParams().get("dataScope"); + qw.apply(dataScope != null, dataScope != null ? dataScope.toString() : null); + Map<String, Object> params = bo.getParams(); + if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) { + qw.between(${columnName} ,params.get("begin$AttrName"), params.get("end$AttrName")); + } + #end + #end + #end + if (StringUtils.isNotEmpty(bo.getIsAsc()) && StringUtils.isNotEmpty(bo.getOrderByColumn())){ + if ("acs".equals(bo.getIsAsc())) { + qw.orderByAsc(bo.getOrderByColumn()); + } else if ("desc".equals(bo.getIsAsc())) { + qw.orderByDesc(bo.getOrderByColumn()); + } + } + return qw; + } +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/sub-domain.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/sub-domain.java.vm new file mode 100644 index 0000000..50459ac --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/sub-domain.java.vm @@ -0,0 +1,74 @@ +package ${packageName}.domain; + +#foreach ($import in $subImportList) +import ${import}; +#end +import com.iplatform.mybatis.domain.BaseEntity; +import com.iplatform.mybatis.Excel; + +/** + * ${subTable.functionName}瀵硅薄 ${subTableName} + * + * @author ${author} + * @date ${datetime} + */ +public class ${subClassName} extends BaseEntity +{ + private static final long serialVersionUID = 1L; + +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ +#if($column.list) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") +#else + @Excel(name = "${comment}") +#end +#end + private $column.javaType $column.javaField; + +#end +#end +#foreach ($column in $subTable.columns) +#if(!$table.isSuperColumn($column.javaField)) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + public void set${AttrName}($column.javaType $column.javaField) + { + this.$column.javaField = $column.javaField; + } + + public $column.javaType get${AttrName}() + { + return $column.javaField; + } +#end +#end + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) +#foreach ($column in $subTable.columns) +#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) +#set($AttrName=$column.javaField) +#else +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#end + .append("${column.javaField}", get${AttrName}()) +#end + .toString(); + } +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/java/vo.java.vm b/iplatform-support-mybatis/src/main/resources/vm/java/vo.java.vm new file mode 100644 index 0000000..06e8a63 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/java/vo.java.vm @@ -0,0 +1,48 @@ +package ${packageName}.domain.vo; + +import com.iplatform.mybatis.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +#foreach ($import in $importList) +import ${import}; +#end +//import io.swagger.annotations.ApiModel; +//import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * ${functionName}瑙嗗浘瀵硅薄 mall_package + * + * @author ${author} + * @date ${datetime} + */ +@Data +//@ApiModel("${functionName}瑙嗗浘瀵硅薄") +public class ${ClassName}Vo { + private static final long serialVersionUID = 1L; + + /** $pkColumn.columnComment */ + //@ApiModelProperty("$pkColumn.columnComment") + private ${pkColumn.javaType} ${pkColumn.javaField}; + +#foreach ($column in $columns) +#if($column.isList) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($parentheseIndex != -1) + @Excel(name = "${comment}" , readConverterExp = "$column.readConverterExp()") +#elseif($column.javaType == 'Date') + @Excel(name = "${comment}" , width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") +#else + @Excel(name = "${comment}") +#end + //@ApiModelProperty("$column.columnComment") + private $column.javaType $column.javaField; +#end +#end + +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/js/api.js.vm b/iplatform-support-mybatis/src/main/resources/vm/js/api.js.vm new file mode 100644 index 0000000..9295524 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/js/api.js.vm @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 鏌ヨ${functionName}鍒楄〃 +export function list${BusinessName}(query) { + return request({ + url: '/${moduleName}/${businessName}/list', + method: 'get', + params: query + }) +} + +// 鏌ヨ${functionName}璇︾粏 +export function get${BusinessName}(${pkColumn.javaField}) { + return request({ + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + method: 'get' + }) +} + +// 鏂板${functionName} +export function add${BusinessName}(data) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'post', + data: data + }) +} + +// 淇敼${functionName} +export function update${BusinessName}(data) { + return request({ + url: '/${moduleName}/${businessName}', + method: 'put', + data: data + }) +} + +// 鍒犻櫎${functionName} +export function del${BusinessName}(${pkColumn.javaField}) { + return request({ + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + method: 'delete' + }) +} diff --git a/iplatform-support-mybatis/src/main/resources/vm/sql/sql.vm b/iplatform-support-mybatis/src/main/resources/vm/sql/sql.vm new file mode 100644 index 0000000..0575583 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/sql/sql.vm @@ -0,0 +1,22 @@ +-- 鑿滃崟 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}鑿滃崟'); + +-- 鎸夐挳鐖惰彍鍗旾D +SELECT @parentId := LAST_INSERT_ID(); + +-- 鎸夐挳 SQL +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}鏌ヨ', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}鏂板', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}淇敼', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}鍒犻櫎', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) +values('${functionName}瀵煎嚭', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, ''); \ No newline at end of file diff --git a/iplatform-support-mybatis/src/main/resources/vm/vue/index-tree.vue.vm b/iplatform-support-mybatis/src/main/resources/vm/vue/index-tree.vue.vm new file mode 100644 index 0000000..a4c64a0 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/vue/index-tree.vue.vm @@ -0,0 +1,505 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> +#foreach($column in $columns) +#if($column.query) +#set($dictType=$column.dictType) +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-input + v-model="queryParams.${column.javaField}" + placeholder="璇疯緭鍏�${comment}" + clearable + @keyup.enter.native="handleQuery" + /> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> + </el-select> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-date-picker clearable + v-model="queryParams.${column.javaField}" + type="date" + value-format="yyyy-MM-dd" + placeholder="閫夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + <el-form-item label="${comment}"> + <el-date-picker + v-model="daterange${AttrName}" + style="width: 240px" + value-format="yyyy-MM-dd" + type="daterange" + range-separator="-" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + ></el-date-picker> + </el-form-item> +#end +#end +#end + <el-form-item> + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button> + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['${moduleName}:${businessName}:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="info" + plain + icon="el-icon-sort" + size="mini" + @click="toggleExpandAll" + >灞曞紑/鎶樺彔</el-button> + </el-col> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table + v-if="refreshTable" + v-loading="loading" + :data="${businessName}List" + row-key="${treeCode}" + :default-expand-all="isExpandAll" + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + > +#foreach($column in $columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk) +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "imageUpload") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> + <template slot-scope="scope"> + <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> + </template> + </el-table-column> +#elseif($column.list && "" != $column.dictType) + <el-table-column label="${comment}" align="center" prop="${javaField}"> + <template slot-scope="scope"> +#if($column.htmlType == "checkbox") + <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> +#else + <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> +#end + </template> + </el-table-column> +#elseif($column.list && "" != $javaField) +#if(${foreach.index} == 1) + <el-table-column label="${comment}" prop="${javaField}" /> +#else + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#end +#end +#end + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template slot-scope="scope"> + <el-button + size="mini" + type="text" + icon="el-icon-edit" + @click="handleUpdate(scope.row)" + v-hasPermi="['${moduleName}:${businessName}:edit']" + >淇敼</el-button> + <el-button + size="mini" + type="text" + icon="el-icon-plus" + @click="handleAdd(scope.row)" + v-hasPermi="['${moduleName}:${businessName}:add']" + >鏂板</el-button> + <el-button + size="mini" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['${moduleName}:${businessName}:remove']" + >鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <!-- 娣诲姞鎴栦慨鏀�${functionName}瀵硅瘽妗� --> + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> +#foreach($column in $columns) +#set($field=$column.javaField) +#if($column.insert && !$column.pk) +#if(($column.usableColumn) || (!$column.superColumn)) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#set($dictType=$column.dictType) +#if("" != $treeParentCode && $column.javaField == $treeParentCode) + <el-form-item label="${comment}" prop="${treeParentCode}"> + <treeselect v-model="form.${treeParentCode}" :options="${businessName}Options" :normalizer="normalizer" placeholder="璇烽�夋嫨${comment}" /> + </el-form-item> +#elseif($column.htmlType == "input") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" /> + </el-form-item> +#elseif($column.htmlType == "imageUpload") + <el-form-item label="${comment}" prop="${field}"> + <image-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "fileUpload") + <el-form-item label="${comment}" prop="${field}"> + <file-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "editor") + <el-form-item label="${comment}"> + <editor v-model="form.${field}" :min-height="192"/> + </el-form-item> +#elseif($column.htmlType == "select" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.label" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :value="parseInt(dict.value)" +#else + :value="dict.value" +#end + ></el-option> + </el-select> + </el-form-item> +#elseif($column.htmlType == "select" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "checkbox" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} + </el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "checkbox" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "radio" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio + v-for="dict in dict.type.${dictType}" + :key="dict.value" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :label="parseInt(dict.value)" +#else + :label="dict.value" +#end + >{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "radio" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio label="1">璇烽�夋嫨瀛楀吀鐢熸垚</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "datetime") + <el-form-item label="${comment}" prop="${field}"> + <el-date-picker clearable + v-model="form.${field}" + type="date" + value-format="yyyy-MM-dd" + placeholder="閫夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "textarea") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> +#end +#end +#end +#end + </el-form> + <div slot="footer" class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </el-dialog> + </div> +</template> + +<script> +import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; +import Treeselect from "@riophae/vue-treeselect"; +import "@riophae/vue-treeselect/dist/vue-treeselect.css"; + +export default { + name: "${BusinessName}", +#if(${dicts} != '') + dicts: [${dicts}], +#end + components: { + Treeselect + }, + data() { + return { + // 閬僵灞� + loading: true, + // 鏄剧ず鎼滅储鏉′欢 + showSearch: true, + // ${functionName}琛ㄦ牸鏁版嵁 + ${businessName}List: [], + // ${functionName}鏍戦�夐」 + ${businessName}Options: [], + // 寮瑰嚭灞傛爣棰� + title: "", + // 鏄惁鏄剧ず寮瑰嚭灞� + open: false, + // 鏄惁灞曞紑锛岄粯璁ゅ叏閮ㄥ睍寮� + isExpandAll: true, + // 閲嶆柊娓叉煋琛ㄦ牸鐘舵�� + refreshTable: true, +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + // $comment鏃堕棿鑼冨洿 + daterange${AttrName}: [], +#end +#end + // 鏌ヨ鍙傛暟 + queryParams: { +#foreach ($column in $columns) +#if($column.query) + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }, + // 琛ㄥ崟鍙傛暟 + form: {}, + // 琛ㄥ崟鏍¢獙 + rules: { +#foreach ($column in $columns) +#if($column.required) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end + $column.javaField: [ + { required: true, message: "$comment涓嶈兘涓虹┖", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } + ]#if($foreach.count != $columns.size()),#end +#end +#end + } + }; + }, + created() { + this.getList(); + }, + methods: { + /** 鏌ヨ${functionName}鍒楄〃 */ + getList() { + this.loading = true; +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + this.queryParams.params = {}; +#break +#end +#end +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { + this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; + this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1]; + } +#end +#end + list${BusinessName}(this.queryParams).then(response => { + this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}"); + this.loading = false; + }); + }, + /** 杞崲${functionName}鏁版嵁缁撴瀯 */ + normalizer(node) { + if (node.children && !node.children.length) { + delete node.children; + } + return { + id: node.${treeCode}, + label: node.${treeName}, + children: node.children + }; + }, + /** 鏌ヨ${functionName}涓嬫媺鏍戠粨鏋� */ + getTreeselect() { + list${BusinessName}().then(response => { + this.${businessName}Options = []; + const data = { ${treeCode}: 0, ${treeName}: '椤剁骇鑺傜偣', children: [] }; + data.children = this.handleTree(response.data, "${treeCode}", "${treeParentCode}"); + this.${businessName}Options.push(data); + }); + }, + // 鍙栨秷鎸夐挳 + cancel() { + this.open = false; + this.reset(); + }, + // 琛ㄥ崟閲嶇疆 + reset() { + this.form = { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + $column.javaField: []#if($foreach.count != $columns.size()),#end +#else + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }; + this.resetForm("form"); + }, + /** 鎼滅储鎸夐挳鎿嶄綔 */ + handleQuery() { + this.getList(); + }, + /** 閲嶇疆鎸夐挳鎿嶄綔 */ + resetQuery() { +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + this.daterange${AttrName} = []; +#end +#end + this.resetForm("queryForm"); + this.handleQuery(); + }, + /** 鏂板鎸夐挳鎿嶄綔 */ + handleAdd(row) { + this.reset(); + this.getTreeselect(); + if (row != null && row.${treeCode}) { + this.form.${treeParentCode} = row.${treeCode}; + } else { + this.form.${treeParentCode} = 0; + } + this.open = true; + this.title = "娣诲姞${functionName}"; + }, + /** 灞曞紑/鎶樺彔鎿嶄綔 */ + toggleExpandAll() { + this.refreshTable = false; + this.isExpandAll = !this.isExpandAll; + this.$nextTick(() => { + this.refreshTable = true; + }); + }, + /** 淇敼鎸夐挳鎿嶄綔 */ + handleUpdate(row) { + this.reset(); + this.getTreeselect(); + if (row != null) { + this.form.${treeParentCode} = row.${treeCode}; + } + get${BusinessName}(row.${pkColumn.javaField}).then(response => { + this.form = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.split(","); +#end +#end + this.open = true; + this.title = "淇敼${functionName}"; + }); + }, + /** 鎻愪氦鎸夐挳 */ + submitForm() { + this.#[[$]]#refs["form"].validate(valid => { + if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.join(","); +#end +#end + if (this.form.${pkColumn.javaField} != null) { + update${BusinessName}(this.form).then(response => { + this.#[[$modal]]#.msgSuccess("淇敼鎴愬姛"); + this.open = false; + this.getList(); + }); + } else { + add${BusinessName}(this.form).then(response => { + this.#[[$modal]]#.msgSuccess("鏂板鎴愬姛"); + this.open = false; + this.getList(); + }); + } + } + }); + }, + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ + handleDelete(row) { + this.#[[$modal]]#.confirm('鏄惁纭鍒犻櫎${functionName}缂栧彿涓�"' + row.${pkColumn.javaField} + '"鐨勬暟鎹」锛�').then(function() { + return del${BusinessName}(row.${pkColumn.javaField}); + }).then(() => { + this.getList(); + this.#[[$modal]]#.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); + } + } +}; +</script> diff --git a/iplatform-support-mybatis/src/main/resources/vm/vue/index.vue.vm b/iplatform-support-mybatis/src/main/resources/vm/vue/index.vue.vm new file mode 100644 index 0000000..6296014 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/vue/index.vue.vm @@ -0,0 +1,602 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> +#foreach($column in $columns) +#if($column.query) +#set($dictType=$column.dictType) +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-input + v-model="queryParams.${column.javaField}" + placeholder="璇疯緭鍏�${comment}" + clearable + @keyup.enter.native="handleQuery" + /> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> + </el-select> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-date-picker clearable + v-model="queryParams.${column.javaField}" + type="date" + value-format="yyyy-MM-dd" + placeholder="璇烽�夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + <el-form-item label="${comment}"> + <el-date-picker + v-model="daterange${AttrName}" + style="width: 240px" + value-format="yyyy-MM-dd" + type="daterange" + range-separator="-" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + ></el-date-picker> + </el-form-item> +#end +#end +#end + <el-form-item> + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button> + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="el-icon-plus" + size="mini" + @click="handleAdd" + v-hasPermi="['${moduleName}:${businessName}:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="success" + plain + icon="el-icon-edit" + size="mini" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['${moduleName}:${businessName}:edit']" + >淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="danger" + plain + icon="el-icon-delete" + size="mini" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['${moduleName}:${businessName}:remove']" + >鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="warning" + plain + icon="el-icon-download" + size="mini" + @click="handleExport" + v-hasPermi="['${moduleName}:${businessName}:export']" + >瀵煎嚭</el-button> + </el-col> + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> +#foreach($column in $columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk) + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> + <template slot-scope="scope"> + <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "imageUpload") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> + <template slot-scope="scope"> + <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> + </template> + </el-table-column> +#elseif($column.list && "" != $column.dictType) + <el-table-column label="${comment}" align="center" prop="${javaField}"> + <template slot-scope="scope"> +#if($column.htmlType == "checkbox") + <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> +#else + <dict-tag :options="dict.type.${column.dictType}" :value="scope.row.${javaField}"/> +#end + </template> + </el-table-column> +#elseif($column.list && "" != $javaField) + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#end +#end + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template slot-scope="scope"> + <el-button + size="mini" + type="text" + icon="el-icon-edit" + @click="handleUpdate(scope.row)" + v-hasPermi="['${moduleName}:${businessName}:edit']" + >淇敼</el-button> + <el-button + size="mini" + type="text" + icon="el-icon-delete" + @click="handleDelete(scope.row)" + v-hasPermi="['${moduleName}:${businessName}:remove']" + >鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total>0" + :total="total" + :page.sync="queryParams.pageNum" + :limit.sync="queryParams.pageSize" + @pagination="getList" + /> + + <!-- 娣诲姞鎴栦慨鏀�${functionName}瀵硅瘽妗� --> + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> +#foreach($column in $columns) +#set($field=$column.javaField) +#if($column.insert && !$column.pk) +#if(($column.usableColumn) || (!$column.superColumn)) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#set($dictType=$column.dictType) +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" /> + </el-form-item> +#elseif($column.htmlType == "imageUpload") + <el-form-item label="${comment}" prop="${field}"> + <image-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "fileUpload") + <el-form-item label="${comment}" prop="${field}"> + <file-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "editor") + <el-form-item label="${comment}"> + <editor v-model="form.${field}" :min-height="192"/> + </el-form-item> +#elseif($column.htmlType == "select" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.label" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :value="parseInt(dict.value)" +#else + :value="dict.value" +#end + ></el-option> + </el-select> + </el-form-item> +#elseif($column.htmlType == "select" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "checkbox" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox + v-for="dict in dict.type.${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} + </el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "checkbox" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "radio" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio + v-for="dict in dict.type.${dictType}" + :key="dict.value" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :label="parseInt(dict.value)" +#else + :label="dict.value" +#end + >{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "radio" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio label="1">璇烽�夋嫨瀛楀吀鐢熸垚</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "datetime") + <el-form-item label="${comment}" prop="${field}"> + <el-date-picker clearable + v-model="form.${field}" + type="date" + value-format="yyyy-MM-dd" + placeholder="璇烽�夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "textarea") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> +#end +#end +#end +#end +#if($table.sub) + <el-divider content-position="center">${subTable.functionName}淇℃伅</el-divider> + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd${subClassName}">娣诲姞</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDelete${subClassName}">鍒犻櫎</el-button> + </el-col> + </el-row> + <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}"> + <el-table-column type="selection" width="50" align="center" /> + <el-table-column label="搴忓彿" align="center" prop="index" width="50"/> +#foreach($column in $subTable.columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk || $javaField == ${subTableFkclassName}) +#elseif($column.list && $column.htmlType == "input") + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template slot-scope="scope"> + <el-input v-model="scope.row.$javaField" placeholder="璇疯緭鍏�$comment" /> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="$comment" prop="${javaField}" width="240"> + <template slot-scope="scope"> + <el-date-picker clearable v-model="scope.row.$javaField" type="date" value-format="yyyy-MM-dd" placeholder="璇烽�夋嫨$comment" /> + </template> + </el-table-column> +#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType) + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template slot-scope="scope"> + <el-select v-model="scope.row.$javaField" placeholder="璇烽�夋嫨$comment"> + <el-option + v-for="dict in dict.type.$column.dictType" + :key="dict.value" + :label="dict.label" + :value="dict.value" + ></el-option> + </el-select> + </template> + </el-table-column> +#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType) + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template slot-scope="scope"> + <el-select v-model="scope.row.$javaField" placeholder="璇烽�夋嫨$comment"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </template> + </el-table-column> +#end +#end + </el-table> +#end + </el-form> + <div slot="footer" class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </el-dialog> + </div> +</template> + +<script> +import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; + +export default { + name: "${BusinessName}", +#if(${dicts} != '') + dicts: [${dicts}], +#end + data() { + return { + // 閬僵灞� + loading: true, + // 閫変腑鏁扮粍 + ids: [], +#if($table.sub) + // 瀛愯〃閫変腑鏁版嵁 + checked${subClassName}: [], +#end + // 闈炲崟涓鐢� + single: true, + // 闈炲涓鐢� + multiple: true, + // 鏄剧ず鎼滅储鏉′欢 + showSearch: true, + // 鎬绘潯鏁� + total: 0, + // ${functionName}琛ㄦ牸鏁版嵁 + ${businessName}List: [], +#if($table.sub) + // ${subTable.functionName}琛ㄦ牸鏁版嵁 + ${subclassName}List: [], +#end + // 寮瑰嚭灞傛爣棰� + title: "", + // 鏄惁鏄剧ず寮瑰嚭灞� + open: false, +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + // $comment鏃堕棿鑼冨洿 + daterange${AttrName}: [], +#end +#end + // 鏌ヨ鍙傛暟 + queryParams: { + pageNum: 1, + pageSize: 10, +#foreach ($column in $columns) +#if($column.query) + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }, + // 琛ㄥ崟鍙傛暟 + form: {}, + // 琛ㄥ崟鏍¢獙 + rules: { +#foreach ($column in $columns) +#if($column.required) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end + $column.javaField: [ + { required: true, message: "$comment涓嶈兘涓虹┖", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } + ]#if($foreach.count != $columns.size()),#end +#end +#end + } + }; + }, + created() { + this.getList(); + }, + methods: { + /** 鏌ヨ${functionName}鍒楄〃 */ + getList() { + this.loading = true; +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + this.queryParams.params = {}; +#break +#end +#end +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) { + this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0]; + this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1]; + } +#end +#end + list${BusinessName}(this.queryParams).then(response => { + this.${businessName}List = response.rows; + this.total = response.total; + this.loading = false; + }); + }, + // 鍙栨秷鎸夐挳 + cancel() { + this.open = false; + this.reset(); + }, + // 琛ㄥ崟閲嶇疆 + reset() { + this.form = { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + $column.javaField: []#if($foreach.count != $columns.size()),#end +#else + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }; +#if($table.sub) + this.${subclassName}List = []; +#end + this.resetForm("form"); + }, + /** 鎼滅储鎸夐挳鎿嶄綔 */ + handleQuery() { + this.queryParams.pageNum = 1; + this.getList(); + }, + /** 閲嶇疆鎸夐挳鎿嶄綔 */ + resetQuery() { +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + this.daterange${AttrName} = []; +#end +#end + this.resetForm("queryForm"); + this.handleQuery(); + }, + // 澶氶�夋閫変腑鏁版嵁 + handleSelectionChange(selection) { + this.ids = selection.map(item => item.${pkColumn.javaField}) + this.single = selection.length!==1 + this.multiple = !selection.length + }, + /** 鏂板鎸夐挳鎿嶄綔 */ + handleAdd() { + this.reset(); + this.open = true; + this.title = "娣诲姞${functionName}"; + }, + /** 淇敼鎸夐挳鎿嶄綔 */ + handleUpdate(row) { + this.reset(); + const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids + get${BusinessName}(${pkColumn.javaField}).then(response => { + this.form = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.split(","); +#end +#end +#if($table.sub) + this.${subclassName}List = response.data.${subclassName}List; +#end + this.open = true; + this.title = "淇敼${functionName}"; + }); + }, + /** 鎻愪氦鎸夐挳 */ + submitForm() { + this.#[[$]]#refs["form"].validate(valid => { + if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + this.form.$column.javaField = this.form.${column.javaField}.join(","); +#end +#end +#if($table.sub) + this.form.${subclassName}List = this.${subclassName}List; +#end + if (this.form.${pkColumn.javaField} != null) { + update${BusinessName}(this.form).then(response => { + this.#[[$modal]]#.msgSuccess("淇敼鎴愬姛"); + this.open = false; + this.getList(); + }); + } else { + add${BusinessName}(this.form).then(response => { + this.#[[$modal]]#.msgSuccess("鏂板鎴愬姛"); + this.open = false; + this.getList(); + }); + } + } + }); + }, + /** 鍒犻櫎鎸夐挳鎿嶄綔 */ + handleDelete(row) { + const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids; + this.#[[$modal]]#.confirm('鏄惁纭鍒犻櫎${functionName}缂栧彿涓�"' + ${pkColumn.javaField}s + '"鐨勬暟鎹」锛�').then(function() { + return del${BusinessName}(${pkColumn.javaField}s); + }).then(() => { + this.getList(); + this.#[[$modal]]#.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); + }, +#if($table.sub) + /** ${subTable.functionName}搴忓彿 */ + row${subClassName}Index({ row, rowIndex }) { + row.index = rowIndex + 1; + }, + /** ${subTable.functionName}娣诲姞鎸夐挳鎿嶄綔 */ + handleAdd${subClassName}() { + let obj = {}; +#foreach($column in $subTable.columns) +#if($column.pk || $column.javaField == ${subTableFkclassName}) +#elseif($column.list && "" != $javaField) + obj.$column.javaField = ""; +#end +#end + this.${subclassName}List.push(obj); + }, + /** ${subTable.functionName}鍒犻櫎鎸夐挳鎿嶄綔 */ + handleDelete${subClassName}() { + if (this.checked${subClassName}.length == 0) { + this.#[[$modal]]#.msgError("璇峰厛閫夋嫨瑕佸垹闄ょ殑${subTable.functionName}鏁版嵁"); + } else { + const ${subclassName}List = this.${subclassName}List; + const checked${subClassName} = this.checked${subClassName}; + this.${subclassName}List = ${subclassName}List.filter(function(item) { + return checked${subClassName}.indexOf(item.index) == -1 + }); + } + }, + /** 澶嶉�夋閫変腑鏁版嵁 */ + handle${subClassName}SelectionChange(selection) { + this.checked${subClassName} = selection.map(item => item.index) + }, +#end + /** 瀵煎嚭鎸夐挳鎿嶄綔 */ + handleExport() { + this.download('${moduleName}/${businessName}/export', { + ...this.queryParams + }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) + } + } +}; +</script> diff --git a/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index-tree.vue.vm b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index-tree.vue.vm new file mode 100644 index 0000000..7bbd2fc --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index-tree.vue.vm @@ -0,0 +1,474 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> +#foreach($column in $columns) +#if($column.query) +#set($dictType=$column.dictType) +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-input + v-model="queryParams.${column.javaField}" + placeholder="璇疯緭鍏�${comment}" + clearable + @keyup.enter="handleQuery" + /> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> + </el-select> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-date-picker clearable + v-model="queryParams.${column.javaField}" + type="date" + value-format="YYYY-MM-DD" + placeholder="閫夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + <el-form-item label="${comment}" style="width: 308px"> + <el-date-picker + v-model="daterange${AttrName}" + value-format="YYYY-MM-DD" + type="daterange" + range-separator="-" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + ></el-date-picker> + </el-form-item> +#end +#end +#end + <el-form-item> + <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> + <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="Plus" + @click="handleAdd" + v-hasPermi="['${moduleName}:${businessName}:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="info" + plain + icon="Sort" + @click="toggleExpandAll" + >灞曞紑/鎶樺彔</el-button> + </el-col> + <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table + v-if="refreshTable" + v-loading="loading" + :data="${businessName}List" + row-key="${treeCode}" + :default-expand-all="isExpandAll" + :tree-props="{children: 'children', hasChildren: 'hasChildren'}" + > +#foreach($column in $columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk) +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> + <template #default="scope"> + <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "imageUpload") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> + <template #default="scope"> + <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> + </template> + </el-table-column> +#elseif($column.list && "" != $column.dictType) + <el-table-column label="${comment}" align="center" prop="${javaField}"> + <template #default="scope"> +#if($column.htmlType == "checkbox") + <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> +#else + <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> +#end + </template> + </el-table-column> +#elseif($column.list && "" != $javaField) +#if(${foreach.index} == 1) + <el-table-column label="${comment}" prop="${javaField}" /> +#else + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#end +#end +#end + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template #default="scope"> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">淇敼</el-button> + <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">鏂板</el-button> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <!-- 娣诲姞鎴栦慨鏀�${functionName}瀵硅瘽妗� --> + <el-dialog :title="title" v-model="open" width="500px" append-to-body> + <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> +#foreach($column in $columns) +#set($field=$column.javaField) +#if($column.insert && !$column.pk) +#if(($column.usableColumn) || (!$column.superColumn)) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#set($dictType=$column.dictType) +#if("" != $treeParentCode && $column.javaField == $treeParentCode) + <el-form-item label="${comment}" prop="${treeParentCode}"> + <el-tree-select + v-model="form.${treeParentCode}" + :data="${businessName}Options" + :props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }" + value-key="${treeCode}" + placeholder="璇烽�夋嫨${comment}" + check-strictly + /> + </el-form-item> +#elseif($column.htmlType == "input") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" /> + </el-form-item> +#elseif($column.htmlType == "imageUpload") + <el-form-item label="${comment}" prop="${field}"> + <image-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "fileUpload") + <el-form-item label="${comment}" prop="${field}"> + <file-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "editor") + <el-form-item label="${comment}"> + <editor v-model="form.${field}" :min-height="192"/> + </el-form-item> +#elseif($column.htmlType == "select" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.label" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :value="parseInt(dict.value)" +#else + :value="dict.value" +#end + ></el-option> + </el-select> + </el-form-item> +#elseif($column.htmlType == "select" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "checkbox" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} + </el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "checkbox" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "radio" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio + v-for="dict in ${dictType}" + :key="dict.value" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :label="parseInt(dict.value)" +#else + :label="dict.value" +#end + >{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "radio" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio label="1">璇烽�夋嫨瀛楀吀鐢熸垚</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "datetime") + <el-form-item label="${comment}" prop="${field}"> + <el-date-picker clearable + v-model="form.${field}" + type="date" + value-format="YYYY-MM-DD" + placeholder="閫夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "textarea") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> +#end +#end +#end +#end + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup name="${BusinessName}"> +import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; + +const { proxy } = getCurrentInstance(); +#if(${dicts} != '') +#set($dictsNoSymbol=$dicts.replace("'", "")) +const { ${dictsNoSymbol} } = proxy.useDict(${dicts}); +#end + +const ${businessName}List = ref([]); +const ${businessName}Options = ref([]); +const open = ref(false); +const loading = ref(true); +const showSearch = ref(true); +const title = ref(""); +const isExpandAll = ref(true); +const refreshTable = ref(true); +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +const daterange${AttrName} = ref([]); +#end +#end + +const data = reactive({ + form: {}, + queryParams: { + #foreach ($column in $columns) +#if($column.query) + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }, + rules: { + #foreach ($column in $columns) +#if($column.required) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end + $column.javaField: [ + { required: true, message: "$comment涓嶈兘涓虹┖", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } + ]#if($foreach.count != $columns.size()),#end +#end +#end + } +}); + +const { queryParams, form, rules } = toRefs(data); + +/** 鏌ヨ${functionName}鍒楄〃 */ +function getList() { + loading.value = true; +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + queryParams.value.params = {}; +#break +#end +#end +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + if (null != daterange${AttrName} && '' != daterange${AttrName}) { + queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; + queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; + } +#end +#end + list${BusinessName}(queryParams.value).then(response => { + ${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); + loading.value = false; + }); +} + +/** 鏌ヨ${functionName}涓嬫媺鏍戠粨鏋� */ +function getTreeselect() { + list${BusinessName}().then(response => { + ${businessName}Options.value = []; + const data = { ${treeCode}: 0, ${treeName}: '椤剁骇鑺傜偣', children: [] }; + data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}"); + ${businessName}Options.value.push(data); + }); +} + +// 鍙栨秷鎸夐挳 +function cancel() { + open.value = false; + reset(); +} + +// 琛ㄥ崟閲嶇疆 +function reset() { + form.value = { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + $column.javaField: []#if($foreach.count != $columns.size()),#end +#else + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }; + proxy.resetForm("${businessName}Ref"); +} + +/** 鎼滅储鎸夐挳鎿嶄綔 */ +function handleQuery() { + getList(); +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +function resetQuery() { +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + daterange${AttrName}.value = []; +#end +#end + proxy.resetForm("queryRef"); + handleQuery(); +} + +/** 鏂板鎸夐挳鎿嶄綔 */ +function handleAdd(row) { + reset(); + getTreeselect(); + if (row != null && row.${treeCode}) { + form.value.${treeParentCode} = row.${treeCode}; + } else { + form.value.${treeParentCode} = 0; + } + open.value = true; + title.value = "娣诲姞${functionName}"; +} + +/** 灞曞紑/鎶樺彔鎿嶄綔 */ +function toggleExpandAll() { + refreshTable.value = false; + isExpandAll.value = !isExpandAll.value; + nextTick(() => { + refreshTable.value = true; + }); +} + +/** 淇敼鎸夐挳鎿嶄綔 */ +async function handleUpdate(row) { + reset(); + await getTreeselect(); + if (row != null) { + form.value.${treeParentCode} = row.${treeCode}; + } + get${BusinessName}(row.${pkColumn.javaField}).then(response => { + form.value = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + form.value.$column.javaField = form.value.${column.javaField}.split(","); +#end +#end + open.value = true; + title.value = "淇敼${functionName}"; + }); +} + +/** 鎻愪氦鎸夐挳 */ +function submitForm() { + proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => { + if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + form.value.$column.javaField = form.value.${column.javaField}.join(","); +#end +#end + if (form.value.${pkColumn.javaField} != null) { + update${BusinessName}(form.value).then(response => { + proxy.#[[$modal]]#.msgSuccess("淇敼鎴愬姛"); + open.value = false; + getList(); + }); + } else { + add${BusinessName}(form.value).then(response => { + proxy.#[[$modal]]#.msgSuccess("鏂板鎴愬姛"); + open.value = false; + getList(); + }); + } + } + }); +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +function handleDelete(row) { + proxy.#[[$modal]]#.confirm('鏄惁纭鍒犻櫎${functionName}缂栧彿涓�"' + row.${pkColumn.javaField} + '"鐨勬暟鎹」锛�').then(function() { + return del${BusinessName}(row.${pkColumn.javaField}); + }).then(() => { + getList(); + proxy.#[[$modal]]#.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); +} + +getList(); +</script> diff --git a/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index.vue.vm b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index.vue.vm new file mode 100644 index 0000000..8b25665 --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/index.vue.vm @@ -0,0 +1,590 @@ +<template> + <div class="app-container"> + <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> +#foreach($column in $columns) +#if($column.query) +#set($dictType=$column.dictType) +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-input + v-model="queryParams.${column.javaField}" + placeholder="璇疯緭鍏�${comment}" + clearable + @keyup.enter="handleQuery" + /> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.label" + :value="dict.value" + /> + </el-select> + </el-form-item> +#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-select v-model="queryParams.${column.javaField}" placeholder="璇烽�夋嫨${comment}" clearable> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") + <el-form-item label="${comment}" prop="${column.javaField}"> + <el-date-picker clearable + v-model="queryParams.${column.javaField}" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + <el-form-item label="${comment}" style="width: 308px"> + <el-date-picker + v-model="daterange${AttrName}" + value-format="YYYY-MM-DD" + type="daterange" + range-separator="-" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + ></el-date-picker> + </el-form-item> +#end +#end +#end + <el-form-item> + <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> + <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button + type="primary" + plain + icon="Plus" + @click="handleAdd" + v-hasPermi="['${moduleName}:${businessName}:add']" + >鏂板</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="success" + plain + icon="Edit" + :disabled="single" + @click="handleUpdate" + v-hasPermi="['${moduleName}:${businessName}:edit']" + >淇敼</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="danger" + plain + icon="Delete" + :disabled="multiple" + @click="handleDelete" + v-hasPermi="['${moduleName}:${businessName}:remove']" + >鍒犻櫎</el-button> + </el-col> + <el-col :span="1.5"> + <el-button + type="warning" + plain + icon="Download" + @click="handleExport" + v-hasPermi="['${moduleName}:${businessName}:export']" + >瀵煎嚭</el-button> + </el-col> + <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> + </el-row> + + <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" align="center" /> +#foreach($column in $columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk) + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> + <template #default="scope"> + <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "imageUpload") + <el-table-column label="${comment}" align="center" prop="${javaField}" width="100"> + <template #default="scope"> + <image-preview :src="scope.row.${javaField}" :width="50" :height="50"/> + </template> + </el-table-column> +#elseif($column.list && "" != $column.dictType) + <el-table-column label="${comment}" align="center" prop="${javaField}"> + <template #default="scope"> +#if($column.htmlType == "checkbox") + <dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/> +#else + <dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/> +#end + </template> + </el-table-column> +#elseif($column.list && "" != $javaField) + <el-table-column label="${comment}" align="center" prop="${javaField}" /> +#end +#end + <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width"> + <template #default="scope"> + <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">淇敼</el-button> + <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">鍒犻櫎</el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total>0" + :total="total" + v-model:page="queryParams.pageNum" + v-model:limit="queryParams.pageSize" + @pagination="getList" + /> + + <!-- 娣诲姞鎴栦慨鏀�${functionName}瀵硅瘽妗� --> + <el-dialog :title="title" v-model="open" width="500px" append-to-body> + <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> +#foreach($column in $columns) +#set($field=$column.javaField) +#if($column.insert && !$column.pk) +#if(($column.usableColumn) || (!$column.superColumn)) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#set($dictType=$column.dictType) +#if($column.htmlType == "input") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" placeholder="璇疯緭鍏�${comment}" /> + </el-form-item> +#elseif($column.htmlType == "imageUpload") + <el-form-item label="${comment}" prop="${field}"> + <image-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "fileUpload") + <el-form-item label="${comment}" prop="${field}"> + <file-upload v-model="form.${field}"/> + </el-form-item> +#elseif($column.htmlType == "editor") + <el-form-item label="${comment}"> + <editor v-model="form.${field}" :min-height="192"/> + </el-form-item> +#elseif($column.htmlType == "select" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.label" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :value="parseInt(dict.value)" +#else + :value="dict.value" +#end + ></el-option> + </el-select> + </el-form-item> +#elseif($column.htmlType == "select" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-select v-model="form.${field}" placeholder="璇烽�夋嫨${comment}"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </el-form-item> +#elseif($column.htmlType == "checkbox" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox + v-for="dict in ${dictType}" + :key="dict.value" + :label="dict.value"> + {{dict.label}} + </el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "checkbox" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-checkbox-group v-model="form.${field}"> + <el-checkbox>璇烽�夋嫨瀛楀吀鐢熸垚</el-checkbox> + </el-checkbox-group> + </el-form-item> +#elseif($column.htmlType == "radio" && "" != $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio + v-for="dict in ${dictType}" + :key="dict.value" +#if($column.javaType == "Integer" || $column.javaType == "Long") + :label="parseInt(dict.value)" +#else + :label="dict.value" +#end + >{{dict.label}}</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "radio" && $dictType) + <el-form-item label="${comment}" prop="${field}"> + <el-radio-group v-model="form.${field}"> + <el-radio label="1">璇烽�夋嫨瀛楀吀鐢熸垚</el-radio> + </el-radio-group> + </el-form-item> +#elseif($column.htmlType == "datetime") + <el-form-item label="${comment}" prop="${field}"> + <el-date-picker clearable + v-model="form.${field}" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨${comment}"> + </el-date-picker> + </el-form-item> +#elseif($column.htmlType == "textarea") + <el-form-item label="${comment}" prop="${field}"> + <el-input v-model="form.${field}" type="textarea" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> +#end +#end +#end +#end +#if($table.sub) + <el-divider content-position="center">${subTable.functionName}淇℃伅</el-divider> + <el-row :gutter="10" class="mb8"> + <el-col :span="1.5"> + <el-button type="primary" icon="Plus" @click="handleAdd${subClassName}">娣诲姞</el-button> + </el-col> + <el-col :span="1.5"> + <el-button type="danger" icon="Delete" @click="handleDelete${subClassName}">鍒犻櫎</el-button> + </el-col> + </el-row> + <el-table :data="${subclassName}List" :row-class-name="row${subClassName}Index" @selection-change="handle${subClassName}SelectionChange" ref="${subclassName}"> + <el-table-column type="selection" width="50" align="center" /> + <el-table-column label="搴忓彿" align="center" prop="index" width="50"/> +#foreach($column in $subTable.columns) +#set($javaField=$column.javaField) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end +#if($column.pk || $javaField == ${subTableFkclassName}) +#elseif($column.list && $column.htmlType == "input") + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template #default="scope"> + <el-input v-model="scope.row.$javaField" placeholder="璇疯緭鍏�$comment" /> + </template> + </el-table-column> +#elseif($column.list && $column.htmlType == "datetime") + <el-table-column label="$comment" prop="${javaField}" width="240"> + <template #default="scope"> + <el-date-picker clearable + v-model="scope.row.$javaField" + type="date" + value-format="YYYY-MM-DD" + placeholder="璇烽�夋嫨$comment"> + </el-date-picker> + </template> + </el-table-column> +#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" != $column.dictType) + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template #default="scope"> + <el-select v-model="scope.row.$javaField" placeholder="璇烽�夋嫨$comment"> + <el-option + v-for="dict in $column.dictType" + :key="dict.value" + :label="dict.label" + :value="dict.value" + ></el-option> + </el-select> + </template> + </el-table-column> +#elseif($column.list && ($column.htmlType == "select" || $column.htmlType == "radio") && "" == $column.dictType) + <el-table-column label="$comment" prop="${javaField}" width="150"> + <template #default="scope"> + <el-select v-model="scope.row.$javaField" placeholder="璇烽�夋嫨$comment"> + <el-option label="璇烽�夋嫨瀛楀吀鐢熸垚" value="" /> + </el-select> + </template> + </el-table-column> +#end +#end + </el-table> +#end + </el-form> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitForm">纭� 瀹�</el-button> + <el-button @click="cancel">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup name="${BusinessName}"> +import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}"; + +const { proxy } = getCurrentInstance(); +#if(${dicts} != '') +#set($dictsNoSymbol=$dicts.replace("'", "")) +const { ${dictsNoSymbol} } = proxy.useDict(${dicts}); +#end + +const ${businessName}List = ref([]); +#if($table.sub) +const ${subclassName}List = ref([]); +#end +const open = ref(false); +const loading = ref(true); +const showSearch = ref(true); +const ids = ref([]); +#if($table.sub) +const checked${subClassName} = ref([]); +#end +const single = ref(true); +const multiple = ref(true); +const total = ref(0); +const title = ref(""); +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) +const daterange${AttrName} = ref([]); +#end +#end + +const data = reactive({ + form: {}, + queryParams: { + pageNum: 1, + pageSize: 10, + #foreach ($column in $columns) +#if($column.query) + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }, + rules: { + #foreach ($column in $columns) +#if($column.required) +#set($parentheseIndex=$column.columnComment.indexOf("锛�")) +#if($parentheseIndex != -1) +#set($comment=$column.columnComment.substring(0, $parentheseIndex)) +#else +#set($comment=$column.columnComment) +#end + $column.javaField: [ + { required: true, message: "$comment涓嶈兘涓虹┖", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } + ]#if($foreach.count != $columns.size()),#end +#end +#end + } +}); + +const { queryParams, form, rules } = toRefs(data); + +/** 鏌ヨ${functionName}鍒楄〃 */ +function getList() { + loading.value = true; +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") + queryParams.value.params = {}; +#break +#end +#end +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + if (null != daterange${AttrName} && '' != daterange${AttrName}) { + queryParams.value.params["begin${AttrName}"] = daterange${AttrName}.value[0]; + queryParams.value.params["end${AttrName}"] = daterange${AttrName}.value[1]; + } +#end +#end + list${BusinessName}(queryParams.value).then(response => { + ${businessName}List.value = response.rows; + total.value = response.total; + loading.value = false; + }); +} + +// 鍙栨秷鎸夐挳 +function cancel() { + open.value = false; + reset(); +} + +// 琛ㄥ崟閲嶇疆 +function reset() { + form.value = { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + $column.javaField: []#if($foreach.count != $columns.size()),#end +#else + $column.javaField: null#if($foreach.count != $columns.size()),#end +#end +#end + }; +#if($table.sub) + ${subclassName}List.value = []; +#end + proxy.resetForm("${businessName}Ref"); +} + +/** 鎼滅储鎸夐挳鎿嶄綔 */ +function handleQuery() { + queryParams.value.pageNum = 1; + getList(); +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +function resetQuery() { +#foreach ($column in $columns) +#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") +#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + daterange${AttrName}.value = []; +#end +#end + proxy.resetForm("queryRef"); + handleQuery(); +} + +// 澶氶�夋閫変腑鏁版嵁 +function handleSelectionChange(selection) { + ids.value = selection.map(item => item.${pkColumn.javaField}); + single.value = selection.length != 1; + multiple.value = !selection.length; +} + +/** 鏂板鎸夐挳鎿嶄綔 */ +function handleAdd() { + reset(); + open.value = true; + title.value = "娣诲姞${functionName}"; +} + +/** 淇敼鎸夐挳鎿嶄綔 */ +function handleUpdate(row) { + reset(); + const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value + get${BusinessName}(_${pkColumn.javaField}).then(response => { + form.value = response.data; +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + form.value.$column.javaField = form.value.${column.javaField}.split(","); +#end +#end +#if($table.sub) + ${subclassName}List.value = response.data.${subclassName}List; +#end + open.value = true; + title.value = "淇敼${functionName}"; + }); +} + +/** 鎻愪氦鎸夐挳 */ +function submitForm() { + proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => { + if (valid) { +#foreach ($column in $columns) +#if($column.htmlType == "checkbox") + form.value.$column.javaField = form.value.${column.javaField}.join(","); +#end +#end +#if($table.sub) + form.value.${subclassName}List = ${subclassName}List.value; +#end + if (form.value.${pkColumn.javaField} != null) { + update${BusinessName}(form.value).then(response => { + proxy.#[[$modal]]#.msgSuccess("淇敼鎴愬姛"); + open.value = false; + getList(); + }); + } else { + add${BusinessName}(form.value).then(response => { + proxy.#[[$modal]]#.msgSuccess("鏂板鎴愬姛"); + open.value = false; + getList(); + }); + } + } + }); +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +function handleDelete(row) { + const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value; + proxy.#[[$modal]]#.confirm('鏄惁纭鍒犻櫎${functionName}缂栧彿涓�"' + _${pkColumn.javaField}s + '"鐨勬暟鎹」锛�').then(function() { + return del${BusinessName}(_${pkColumn.javaField}s); + }).then(() => { + getList(); + proxy.#[[$modal]]#.msgSuccess("鍒犻櫎鎴愬姛"); + }).catch(() => {}); +} + +#if($table.sub) +/** ${subTable.functionName}搴忓彿 */ +function row${subClassName}Index({ row, rowIndex }) { + row.index = rowIndex + 1; +} + +/** ${subTable.functionName}娣诲姞鎸夐挳鎿嶄綔 */ +function handleAdd${subClassName}() { + let obj = {}; +#foreach($column in $subTable.columns) +#if($column.pk || $column.javaField == ${subTableFkclassName}) +#elseif($column.list && "" != $javaField) + obj.$column.javaField = ""; +#end +#end + ${subclassName}List.value.push(obj); +} + +/** ${subTable.functionName}鍒犻櫎鎸夐挳鎿嶄綔 */ +function handleDelete${subClassName}() { + if (checked${subClassName}.value.length == 0) { + proxy.#[[$modal]]#.msgError("璇峰厛閫夋嫨瑕佸垹闄ょ殑${subTable.functionName}鏁版嵁"); + } else { + const ${subclassName}s = ${subclassName}List.value; + const checked${subClassName}s = checked${subClassName}.value; + ${subclassName}List.value = ${subclassName}s.filter(function(item) { + return checked${subClassName}s.indexOf(item.index) == -1 + }); + } +} + +/** 澶嶉�夋閫変腑鏁版嵁 */ +function handle${subClassName}SelectionChange(selection) { + checked${subClassName}.value = selection.map(item => item.index) +} + +#end +/** 瀵煎嚭鎸夐挳鎿嶄綔 */ +function handleExport() { + proxy.download('${moduleName}/${businessName}/export', { + ...queryParams.value + }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) +} + +getList(); +</script> diff --git a/iplatform-support-mybatis/src/main/resources/vm/vue/v3/readme.txt b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/readme.txt new file mode 100644 index 0000000..54a85db --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/vue/v3/readme.txt @@ -0,0 +1 @@ +锟斤拷锟绞癸拷玫锟斤拷锟絤anton-Vue3前锟剿o拷锟斤拷么锟斤拷要锟斤拷锟斤拷一锟铰达拷目录锟斤拷模锟斤拷index.vue.vm锟斤拷index-tree.vue.vm锟侥硷拷锟斤拷锟较硷拷vue目录锟斤拷 \ No newline at end of file diff --git a/iplatform-support-mybatis/src/main/resources/vm/xml/mapper.xml.vm b/iplatform-support-mybatis/src/main/resources/vm/xml/mapper.xml.vm new file mode 100644 index 0000000..9b5526d --- /dev/null +++ b/iplatform-support-mybatis/src/main/resources/vm/xml/mapper.xml.vm @@ -0,0 +1,15 @@ +<?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="${packageName}.mapper.${ClassName}Mapper"> + + <resultMap type="${ClassName}" id="${ClassName}Result"> +#foreach ($column in $columns) + <result property="${column.javaField}" column="${column.columnName}" /> +#end + </resultMap> + + + +</mapper> \ No newline at end of file -- Gitblit v1.9.1