1
0
suochencheng 7 лет назад
Родитель
Сommit
725f20c2ca

+ 160 - 142
src/main/java/com/izouma/awesomeadmin/dao/TestAaaMapper.xml

@@ -1,16 +1,16 @@
 <?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.izouma.awesomeadmin.dao.TestAaaMapper">
-    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.TestAaa">
-        <id column="id" property="id" jdbcType="INTEGER"/>
-        <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
-        <result column="test_name" property="testName" jdbcType="VARCHAR"/>
-        <result column="remark" property="remark" jdbcType="VARCHAR"/>
-        <result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
-        <result column="test_time" property="testTime" jdbcType="TIMESTAMP"/>
-    </resultMap>
-    <sql id="Base_Column_List">
-        <trim suffixOverrides=",">
+<mapper namespace="com.izouma.awesomeadmin.dao.TestAaaMapper" >
+    <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.TestAaa" >
+                <id column="id" property="id" jdbcType="INTEGER" />
+                                        <result column="del_flag" property="delFlag" jdbcType="CHAR" />
+                                <result column="test_name" property="testName" jdbcType="VARCHAR" />
+                                <result column="remark" property="remark" jdbcType="VARCHAR" />
+                                <result column="image_url" property="imageUrl" jdbcType="VARCHAR" />
+                                <result column="test_time" property="testTime" jdbcType="TIMESTAMP" />
+            </resultMap>
+    <sql id="Base_Column_List" >
+        <trim  suffixOverrides="," >
             id,
 
             del_flag,
@@ -23,118 +23,114 @@
 
             test_time,
 
-        </trim>
+            </trim>
     </sql>
-    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
+    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
         select
-        <include refid="Base_Column_List"/>
+        <include refid="Base_Column_List" />
         from test_aaa
         where id = #{id,jdbcType=INTEGER}
     </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
         delete from test_aaa
         where id = #{id,jdbcType=INTEGER}
     </delete>
-    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TestAaa" useGeneratedKeys="true"
-            keyProperty="id">
+    <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.TestAaa" useGeneratedKeys="true" keyProperty="id">
         insert into test_aaa
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id!= null">
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+                <if test="id!= null" >
                 id,
             </if>
-            <if test="delFlag!= null">
+                <if test="delFlag!= null" >
                 del_flag,
             </if>
-            <if test="testName!= null">
+                <if test="testName!= null" >
                 test_name,
             </if>
-            <if test="remark!= null">
+                <if test="remark!= null" >
                 remark,
             </if>
-            <if test="imageUrl!= null">
+                <if test="imageUrl!= null" >
                 image_url,
             </if>
-            <if test="testTime!= null">
+                <if test="testTime!= null" >
                 test_time,
             </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="id != null">
+            </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+                    <if test="id != null" >
                 #{id,jdbcType=INTEGER},
             </if>
-            <if test="delFlag != null">
+                    <if test="delFlag != null" >
                 #{delFlag,jdbcType=CHAR},
             </if>
-            <if test="testName != null">
+                    <if test="testName != null" >
                 #{testName,jdbcType=VARCHAR},
             </if>
-            <if test="remark != null">
+                    <if test="remark != null" >
                 #{remark,jdbcType=VARCHAR},
             </if>
-            <if test="imageUrl != null">
+                    <if test="imageUrl != null" >
                 #{imageUrl,jdbcType=VARCHAR},
             </if>
-            <if test="testTime != null">
+                    <if test="testTime != null" >
                 #{testTime,jdbcType=TIMESTAMP},
             </if>
-        </trim>
+                </trim>
     </insert>
-    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TestAaa">
+    <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.TestAaa" >
         update test_aaa
-        <set>
-            <if test="id != null">
-                id= #{id,jdbcType=INTEGER},
+        <set >
+                    <if test="id != null" >
+               id= #{id,jdbcType=INTEGER},
             </if>
-            <if test="delFlag != null">
-                del_flag= #{delFlag,jdbcType=CHAR},
+                     <if test="delFlag != null" >
+               del_flag= #{delFlag,jdbcType=CHAR},
             </if>
-            <if test="testName != null">
-                test_name= #{testName,jdbcType=VARCHAR},
+                     <if test="testName != null" >
+               test_name= #{testName,jdbcType=VARCHAR},
             </if>
-            <if test="remark != null">
-                remark= #{remark,jdbcType=VARCHAR},
+                     <if test="remark != null" >
+               remark= #{remark,jdbcType=VARCHAR},
             </if>
-            <if test="imageUrl != null">
-                image_url= #{imageUrl,jdbcType=VARCHAR},
+                     <if test="imageUrl != null" >
+               image_url= #{imageUrl,jdbcType=VARCHAR},
             </if>
-            <if test="testTime != null">
-                test_time= #{testTime,jdbcType=TIMESTAMP},
+                     <if test="testTime != null" >
+               test_time= #{testTime,jdbcType=TIMESTAMP},
             </if>
-        </set>
+                 </set>
         where id = #{id,jdbcType=INTEGER}
     </update>
     <select id="queryTestAaaByPage" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
-        select
-        <include refid="Base_Column_List"/>
-        from test_aaa
+        select <include refid="Base_Column_List"/> from test_aaa
         <where>
             and del_flag = 'N'
-            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
-                and id = #{record.id}
-            </if>
-            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
-                and del_flag = #{record.delFlag}
+                    <if test="record.id != null and !&quot;&quot;.equals(record.id)">
+                and  id = #{record.id}
             </if>
-            <if test="record.testName != null and !&quot;&quot;.equals(record.testName)">
-                and test_name = #{record.testName}
+                     <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
+                and  del_flag = #{record.delFlag}
             </if>
-            <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
-                and remark = #{record.remark}
+                     <if test="record.testName != null and !&quot;&quot;.equals(record.testName)">
+                and  test_name = #{record.testName}
             </if>
-            <if test="record.imageUrl != null and !&quot;&quot;.equals(record.imageUrl)">
-                and image_url = #{record.imageUrl}
+                     <if test="record.remark != null and !&quot;&quot;.equals(record.remark)">
+                and  remark = #{record.remark}
             </if>
-            <if test="record.testTime != null and !&quot;&quot;.equals(record.testTime)">
-                and test_time = #{record.testTime}
+                     <if test="record.imageUrl != null and !&quot;&quot;.equals(record.imageUrl)">
+                and  image_url = #{record.imageUrl}
             </if>
-            <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
-                <trim prefix="and (" suffix=")" prefixOverrides="OR">
-                    OR del_flag LIKE concat('%',#{record.searchKey},'%')
-                    OR test_name LIKE concat('%',#{record.searchKey},'%')
-                    OR remark LIKE concat('%',#{record.searchKey},'%')
-                    OR image_url LIKE concat('%',#{record.searchKey},'%')
-                </trim>
+                     <if test="record.testTime != null and !&quot;&quot;.equals(record.testTime)">
+                and  test_time = #{record.testTime}
             </if>
+                  <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
+             <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                OR  test_name LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  remark LIKE concat('%',#{record.searchKey},'%')
+                                                                                                    OR  image_url LIKE concat('%',#{record.searchKey},'%')
+                                                                                                                              </trim>
+         </if>
 
             <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
                 <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
@@ -172,102 +168,126 @@
             </if>
 
         </where>
-        order by id desc
+        order by
+
+        <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">
+
+
+            <trim suffixOverrides=",">
+                <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
+                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                        ${itemDetail}
+                    </foreach>
+                </foreach>
+            </trim>
+            ,
+        </if>
+        id desc
     </select>
     <select id="queryAllTestAaa" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
-        select
-        <include refid="Base_Column_List"/>
-        from test_aaa
+        select <include refid="Base_Column_List"/> from test_aaa
         <where>
             and del_flag = 'N'
-            <if test="id != null and !&quot;&quot;.equals(id)">
-                and id = #{id}
-            </if>
-            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
-                and del_flag = #{delFlag}
-            </if>
-            <if test="testName != null and !&quot;&quot;.equals(testName)">
-                and test_name = #{testName}
-            </if>
-            <if test="remark != null and !&quot;&quot;.equals(remark)">
-                and remark = #{remark}
-            </if>
-            <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
-                and image_url = #{imageUrl}
-            </if>
-            <if test="testTime != null and !&quot;&quot;.equals(testTime)">
-                and test_time = #{testTime}
-            </if>
-            <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
-                <trim prefix="and (" suffix=")" prefixOverrides="OR">
-                    OR del_flag LIKE concat('%',#{searchKey},'%')
-                    OR test_name LIKE concat('%',#{searchKey},'%')
-                    OR remark LIKE concat('%',#{searchKey},'%')
-                    OR image_url LIKE concat('%',#{searchKey},'%')
-                </trim>
-            </if>
-            <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
-                <foreach item="item" index="index" collection="advancedQuery.split('_;')">
-                    <choose>
-                        <when test="item.indexOf('like') != -1">
-                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
-                                <if test="detailIndex == 3">
-                                    concat('%',#{itemDetail},'%')
-                                </if>
+                    <if test="id != null and !&quot;&quot;.equals(id)">
+                and  id = #{id}
+            </if>
+                    <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                and  del_flag = #{delFlag}
+            </if>
+                    <if test="testName != null and !&quot;&quot;.equals(testName)">
+                and  test_name = #{testName}
+            </if>
+                    <if test="remark != null and !&quot;&quot;.equals(remark)">
+                and  remark = #{remark}
+            </if>
+                    <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
+                and  image_url = #{imageUrl}
+            </if>
+                    <if test="testTime != null and !&quot;&quot;.equals(testTime)">
+                and  test_time = #{testTime}
+            </if>
+                    <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
+                <trim prefix="and (" suffix=")" prefixOverrides="OR" >
+                                                                                                                                                                                                                                                OR  test_name LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  remark LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                        OR  image_url LIKE concat('%',#{searchKey},'%')
+                                                                                                                                                                                        </trim>
+            </if>
+<if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
+    <foreach item="item" index="index" collection="advancedQuery.split('_;')">
+        <choose>
+            <when test="item.indexOf('like') != -1">
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        concat('%',#{itemDetail},'%')
+                    </if>
 
-                                <if test="detailIndex &lt; 3">
-                                    ${itemDetail}
-                                </if>
+                    <if test="detailIndex &lt; 3">
+                        ${itemDetail}
+                    </if>
 
-                            </foreach>
-                        </when>
-                        <otherwise>
-                            <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
-                                <if test="detailIndex == 3">
-                                    #{itemDetail}
-                                </if>
+                </foreach>
+            </when>
+            <otherwise>
+                <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                    <if test="detailIndex == 3">
+                        #{itemDetail}
+                    </if>
 
-                                <if test="detailIndex &lt; 3">
-                                    ${itemDetail}
-                                </if>
+                    <if test="detailIndex &lt; 3">
+                        ${itemDetail}
+                    </if>
 
-                            </foreach>
-                        </otherwise>
-                    </choose>
+                </foreach>
+            </otherwise>
+        </choose>
 
 
-                </foreach>
+    </foreach>
 
 
-            </if>
+</if>
         </where>
-        order by id desc
+        order by
+
+        <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">
+
+
+            <trim suffixOverrides=",">
+                <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
+                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                        ${itemDetail}
+                    </foreach>
+                </foreach>
+            </trim>
+            ,
+        </if>
+
+        id desc
     </select>
     <select id="queryTestAaa" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
-        select
-        <include refid="Base_Column_List"/>
-        from test_aaa
+        select <include refid="Base_Column_List"/> from test_aaa
         <where>
             and del_flag = 'N'
-            <if test="id != null and !&quot;&quot;.equals(id)">
+                    <if test="id != null and !&quot;&quot;.equals(id)">
                 and id = #{id}
             </if>
-            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                     <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
                 and del_flag = #{delFlag}
             </if>
-            <if test="testName != null and !&quot;&quot;.equals(testName)">
+                     <if test="testName != null and !&quot;&quot;.equals(testName)">
                 and test_name = #{testName}
             </if>
-            <if test="remark != null and !&quot;&quot;.equals(remark)">
+                     <if test="remark != null and !&quot;&quot;.equals(remark)">
                 and remark = #{remark}
             </if>
-            <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
+                     <if test="imageUrl != null and !&quot;&quot;.equals(imageUrl)">
                 and image_url = #{imageUrl}
             </if>
-            <if test="testTime != null and !&quot;&quot;.equals(testTime)">
+                     <if test="testTime != null and !&quot;&quot;.equals(testTime)">
                 and test_time = #{testTime}
             </if>
-
+         
         </where>
         LIMIT 1
     </select>
@@ -278,12 +298,10 @@
         </where>
     </update>
     <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.TestAaa">
-        select
-        <include refid="Base_Column_List"/>
-        from test_aaa
+        select <include refid="Base_Column_List"/> from test_aaa
         <where>
             and del_flag = 'N'
-        </where>
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </where>
         order by id desc
     </select>
 </mapper>

+ 12 - 0
src/main/java/com/izouma/awesomeadmin/model/TableField.java

@@ -87,6 +87,11 @@ public class TableField {
      */
     private Boolean searchable;
 
+    /**
+     * 可以排序
+     */
+    private Boolean sortable;
+
     /**
      * 表单类型
      */
@@ -338,5 +343,12 @@ public class TableField {
         this.modelName = modelName;
     }
 
+    public Boolean getSortable() {
+        return sortable;
+    }
+
+    public void setSortable(Boolean sortable) {
+        this.sortable = sortable;
+    }
 }
 

+ 19 - 6
src/main/java/com/izouma/awesomeadmin/model/TestAaa.java

@@ -8,12 +8,12 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 @JsonAutoDetect
 @JsonInclude(JsonInclude.Include.NON_NULL)
 public class TestAaa{
-    private String id;
+    private Integer id;
     private String delFlag;
     private String testName;
     private String remark;
     private String imageUrl;
-    private String testTime;
+    private Date testTime;
 
 private String searchKey;
 
@@ -22,11 +22,16 @@ private String searchKey;
 */
 private String advancedQuery;
 
-    public String getId(){
+/**
+* column_name_,desc_;column_name_,asc
+*/
+private String orderByStr;
+
+    public Integer getId(){
         return this.id;
     }
 
-    public void setId(String id){
+    public void setId(Integer id){
         this.id = id;
     }
     public String getDelFlag(){
@@ -57,11 +62,11 @@ private String advancedQuery;
     public void setImageUrl(String imageUrl){
         this.imageUrl = imageUrl;
     }
-    public String getTestTime(){
+    public Date getTestTime(){
         return this.testTime;
     }
 
-    public void setTestTime(String testTime){
+    public void setTestTime(Date testTime){
         this.testTime = testTime;
     }
 
@@ -81,5 +86,13 @@ public void setAdvancedQuery(String advancedQuery) {
     this.advancedQuery = advancedQuery;
 }
 
+public String getOrderByStr() {
+    return orderByStr;
+}
+
+public void setOrderByStr(String orderByStr) {
+    this.orderByStr = orderByStr;
+}
+
 }
 

+ 4 - 1
src/main/java/com/izouma/awesomeadmin/util/DatabaseUtil.java

@@ -126,9 +126,10 @@ public class DatabaseUtil {
                     tableField.setNotNull("NO".equals(rs.getString("IS_NULLABLE")) ? true : false);
                     tableField.setPrimaryKey("PRI".equals(rs.getString("COLUMN_KEY")) ? true : false);
                     tableField.setAutoIncrease("auto_increment".equals(rs.getString("EXTRA")) ? true : false);
-                    tableField.setRemark(rs.getString("COLUMN_COMMENT"));
+                    tableField.setRemark(StringUtils.isNotEmpty(rs.getString("COLUMN_COMMENT")) ? rs.getString("COLUMN_COMMENT") : rs.getString("COLUMN_NAME"));
                     tableField.setShowInForm(true);
                     tableField.setShowInList(true);
+                    tableField.setSortable(true);
                     tableField.setSearchable("varchar".equalsIgnoreCase(tableField.getJdbcType()) ? true : false);
                     tableField.setFormType("singleLineText");
 
@@ -137,8 +138,10 @@ public class DatabaseUtil {
                     tableField.setJdbcType(GeneratorTool.SqlServerJdbcType2Mysql(rs.getString("TYPE_NAME")));
                     tableField.setLength(rs.getInt("PRECISION"));
                     tableField.setNotNull("NO".equals(rs.getString("IS_NULLABLE")) ? true : false);
+                    tableField.setRemark(rs.getString("COLUMN_NAME"));
                     tableField.setShowInForm(true);
                     tableField.setShowInList(true);
+                    tableField.setSortable(true);
                     tableField.setSearchable("varchar".equalsIgnoreCase(tableField.getJdbcType()) ? true : false);
                     tableField.setFormType("singleLineText");
                 }

+ 0 - 1
src/main/java/com/izouma/awesomeadmin/web/GenCodeController.java

@@ -150,7 +150,6 @@ public class GenCodeController extends BaseController {
 
         GeneratorTool.getImports(record);
 
-        ControllerGenerator.GenController(record);
         if (record.getGenTable() && !record.getReadTable()) {
             TableGenerator.GenTable(record);
         }

+ 30 - 3
src/main/resources/templates/FormTemplate.vm

@@ -25,13 +25,28 @@
                     <div class="block">
                         <el-date-picker
                                 v-model="formData.${field.modelName}"
-                                type="datetime"
+                                type="date"
+                                value-format="timestamp"
                                 placeholder="选择日期">
                         </el-date-picker>
                     </div>
                 </template>
             </el-form-item>
                     #end
+                    #if(${field.formType}=="datetime")
+                        <el-form-item prop="${field.modelName}" label="${field.remark}">
+                            <template>
+                                <div class="block">
+                                    <el-date-picker
+                                            v-model="formData.${field.modelName}"
+                                            type="datetime"
+                                            value-format="timestamp"
+                                            placeholder="选择日期">
+                                    </el-date-picker>
+                                </div>
+                            </template>
+                        </el-form-item>
+                    #end
                     #if(${field.formType}=="select")
             <el-form-item prop="${field.modelName}" label="${field.remark}">
                 <template>
@@ -136,16 +151,28 @@
                 formData: {},
                 rules: {
             #foreach($field in $model.fields)
-                #if(${field.required})
+                #if(${field.required}||${field.validate})
                     ${field.modelName}:
                     [
+                        #if(${field.required})
                         {required: true, message: '请输入 $display.alt(${field.remark},${field.modelName})', trigger: 'blur'},
+                        #end
                         #if(${field.validate})
                         #if(${field.maxLength}&&${field.minLength})
                         { min: ${field.minLength}, max: ${field.maxLength}, message: '长度在 ${field.minLength} 到 ${field.maxLength} 个字符', trigger: 'blur' },
                         #end
                         #if(${field.min}&&${field.max})
-                        { minValue: ${field.min}, maxValue: ${field.max}, message: '值在 ${field.min} 到 ${field.max} 之间', trigger: 'blur' },
+                            {
+                                validator: (rule, value, callback) => {
+                                    if (value) {
+                                        if (value <= ${field.max} && value >= ${field.min}) {
+                                            callback();
+                                        } else {
+                                            callback(new Error('值在 ${field.min} 到 ${field.max} 之间'));
+                                        }
+                                    }
+                                }, trigger: 'blur'
+                            },
                         #end
                         #if(${field.validatorType}=="phone")
                          formValidator.phone,

+ 174 - 38
src/main/resources/templates/ListTemplate.vm

@@ -1,18 +1,22 @@
 <template>
     <div>
         <div class="filters-container">
-          #* #foreach($field in $model.fields)
-             #if(${field.searchable})
-             <el-input placeholder="${field.remark}" size="small" v-model="${field.name}" clearable class="filter-item"></el-input>
-             #end
-             #end*#
+        #* #foreach($field in $model.fields)
+           #if(${field.searchable})
+           <el-input placeholder="${field.remark}" size="small" v-model="${field.name}" clearable class="filter-item"></el-input>
+           #end
+           #end*#
             <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
-              <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
-              </el-button>
-            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
+            <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
             </el-button>
-
-            <el-button @click="${esc.d}router.push('/${display.uncapitalize($model.className)}')" type="primary" size="small" icon="el-icon-edit"
+            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small"
+                       icon="el-icon-search" class="filter-item">高级查询
+            </el-button>
+            <el-button @click="showTableSortDialog = !showTableSortDialog" type="primary" size="small"
+                       icon="el-icon-sort" class="filter-item">排序
+            </el-button>
+            <el-button @click="${esc.d}router.push('/${display.uncapitalize($model.className)}')" type="primary"
+                       size="small" icon="el-icon-edit"
                        class="filter-item">添加
             </el-button>
             <el-button @click="exportExcel" type="primary" size="small" icon="el-icon-share" class="filter-item">导出EXCEL
@@ -45,12 +49,42 @@
             </el-table-column>
             #foreach($field in $model.fields)
                 #if(${field.showInList})
-            <el-table-column
-                    v-if="isColumnShow('${field.modelName}')"
-                    prop="${field.modelName}"
-                    label="$display.alt(${field.remark},${field.modelName})"
-                    min-width="100">
-            </el-table-column>
+
+                    #if(${field.formType}=="date")
+                        <el-table-column
+                                v-if="isColumnShow('${field.modelName}')"
+                                prop="${field.modelName}"
+                                label="$display.alt(${field.remark},${field.modelName})"
+                                :formatter="DateFormatter"
+                                min-width="100">
+                        </el-table-column>
+                    #elseif(${field.formType}=="datetime")
+                        <el-table-column
+                                v-if="isColumnShow('${field.modelName}')"
+                                prop="${field.modelName}"
+                                label="$display.alt(${field.remark},${field.modelName})"
+                                :formatter="DateTimeFormatter"
+                                min-width="100">
+                        </el-table-column>
+                    #elseif(${field.formType}=="singleImage")
+                        <el-table-column
+                                v-if="isColumnShow('${field.modelName}')"
+                                prop="${field.modelName}"
+                                label="$display.alt(${field.remark},${field.modelName})"
+                                min-width="100">
+                            <template slot-scope="{row}">
+                                <img :src="row.${field.modelName}" @click="showImg(row.${field.modelName})" style="width: 100px;height: 100px;vertical-align: middle;" />
+                            </template>
+
+                        </el-table-column>
+                        #else
+                        <el-table-column
+                                v-if="isColumnShow('${field.modelName}')"
+                                prop="${field.modelName}"
+                                label="$display.alt(${field.remark},${field.modelName})"
+                                min-width="100">
+                        </el-table-column>
+                    #end
                 #end
             #end
             <el-table-column
@@ -103,14 +137,16 @@
                     <template slot-scope="{row}">
                         <el-select v-model="row.name">
 
-                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value" :key="item.value"></el-option>
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value"
+                                       :key="item.value"></el-option>
                         </el-select>
                     </template>
                 </el-table-column>
                 <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
                     <template slot-scope="{row}">
                         <el-select v-model="row.searchMethod">
-                            <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
+                            <el-option v-for="item in searchMethods" :label="item" :value="item"
+                                       :key="item"></el-option>
                         </el-select>
                     </template>
                 </el-table-column>
@@ -132,10 +168,52 @@
             </span>
         </el-dialog>
 
+        <el-dialog title="排序" :visible.sync="showTableSortDialog">
+            <el-button @click="addSortField" type="text" icon="el-icon-plus">添加</el-button>
+            <el-table :data="tableSortFields">
+
+                <el-table-column prop="name" label="字段" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.name">
+
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value"
+                                       :key="item.value"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="order" label="排序" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.order">
+                            <el-option label="降序" value="desc">
+                            </el-option>
+                            <el-option label="升序" value="asc">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column width="60" align="center">
+                    <template slot-scope="{ row, column, ${esc.d}index }">
+                        <el-button @click="removeSortField(${esc.d}index)" size="small" type="text">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+
+            <span slot="footer" class="dialog-footer">
+
+                <el-button @click="tableSortQuery" :loading="${esc.d}store.state.fetchingData">确定</el-button>
+            </span>
+        </el-dialog>
+
+        <el-dialog title="查看图片" :visible.sync="imageDialogVisible" size="small">
+            <img width="100%" :src="imgSrc" alt="">
+        </el-dialog>
+
     </div>
 </template>
 <script>
     import {mapState} from 'vuex'
+    import {format} from 'date-fns'
+    import zh from 'date-fns/locale/zh_cn'
 
     export default {
         created() {
@@ -151,19 +229,21 @@
                 filter1: '',
                 filter2: '',
                 tableColumns: [
-        #foreach($field in $model.fields)
-            #if(${field.showInList})
-                    {
-                        label: '$display.alt(${field.remark},${field.modelName})',
-                        value: '${field.modelName}',
-                        show: true
-                    },
-            #end
-        #end
+                    #foreach($field in $model.fields)
+                        #if(${field.showInList})
+                            {
+                                label: '$display.alt(${field.remark},${field.modelName})',
+                                value: '${field.modelName}',
+                                show: true
+                            },
+                        #end
+                    #end
                 ],
                 multipleMode: false,
                 showAdvancedQueryDialog: false,
                 advancedQueryFields: [],
+                showTableSortDialog: false,
+                tableSortFields: [],
                 searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
                 advancedQueryColumns: [
                     #foreach($field in $model.fields)
@@ -176,6 +256,9 @@
                     #end
                 ],
                 advancedQuerySearchKey: '',
+                orderByStr: '',
+                imgSrc: '',
+                imageDialogVisible: false,
             }
         },
         computed: {
@@ -196,13 +279,14 @@
             },
             getData() {
                 this.${esc.d}http.get({
-                url: '/${display.uncapitalize($model.className)}/page',
-                data: {
-                    currentPage: this.currentPage,
-                    pageNumber: this.pageSize,
-                    searchKey: this.filter1,
-                    advancedQuery: this.advancedQuerySearchKey,
-                }
+                    url: '/${display.uncapitalize($model.className)}/page',
+                    data: {
+                        currentPage: this.currentPage,
+                        pageNumber: this.pageSize,
+                        searchKey: this.filter1,
+                        advancedQuery: this.advancedQuerySearchKey,
+                        orderByStr: this.orderByStr,
+                    }
                 }).then(res => {
                     if (res.success) {
                         this.totalNumber = res.data.page.totalNumber;
@@ -274,18 +358,54 @@
                 this.getData();
                 this.showAdvancedQueryDialog = false;
             },
+            addSortField() {
+                this.tableSortFields.push({
+                    name: '',
+                    order: 'asc',
+                });
+            },
+            removeSortField(i) {
+                if (this.tableSortFields.length > 0) {
+                    this.tableSortFields.splice(i, 1);
+                }
+            },
+            tableSortQuery() {
+
+                this.orderByStr = '';
+
+                if (this.tableSortFields.length > 0) {
+
+                    var templist = [];
+
+                    this.tableSortFields.forEach(item => {
+                        if (item.name && item.order) {
+                            var tempItem = item.name + '_,' + item.order;
+                            templist.push(tempItem);
+                        }
+                    })
+
+                    if (templist.length > 0) {
+
+                        this.orderByStr = templist.join('_;');
+                    }
+                }
+
+                this.getData();
+                this.showTableSortDialog = false;
+            },
             exportExcel() {
-                window.location.href = this.${esc.d}baseUrl + "/${display.uncapitalize($model.className)}/exportExcel?searchKey=" + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey
+                window.location.href = this.${esc.d}baseUrl + "/${display.uncapitalize($model.className)}/exportExcel?searchKey="
+                        + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey+"&orderByStr=" + this.orderByStr;
             },
             searchData() {
                 this.currentPage = 1;
                 this.getData();
             },
             deleteRow(row) {
-                this.${esc.d}alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
+                this.${esc.d}alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
                     return this.${esc.d}http.post({
-                    url: '/${display.uncapitalize($model.className)}/del',
-                    data: { id: row.id }
+                        url: '/${display.uncapitalize($model.className)}/del',
+                        data: {id: row.id}
                     })
                 }).then(() => {
                     this.${esc.d}message.success('删除成功');
@@ -298,6 +418,22 @@
                     }
                 })
             },
+            DateTimeFormatter(row, column, cellValue) {
+                if (cellValue) {
+                    return format(cellValue, 'YYYY/MM/DD HH:mm', {locale: zh})
+                }
+
+            },
+            DateFormatter(row, column, cellValue) {
+                if (cellValue) {
+                    return format(cellValue, 'YYYY/MM/DD', {locale: zh})
+                }
+
+            },
+            showImg(img) {
+                this.imgSrc = img;
+                this.imageDialogVisible = true;
+            },
 
         }
     }

+ 31 - 2
src/main/resources/templates/MapperXmlTemplate.vm

@@ -114,7 +114,21 @@
             </if>
 
         </where>
-        order by id desc
+        order by
+
+        <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">
+
+
+            <trim suffixOverrides=",">
+                <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
+                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                        ${esc.d}{itemDetail}
+                    </foreach>
+                </foreach>
+            </trim>
+            ,
+        </if>
+        id desc
     </select>
     <select id="queryAll${model.className}" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
         select <include refid="Base_Column_List"/> from ${model.tableName}
@@ -171,7 +185,22 @@
 
 </if>
         </where>
-        order by id desc
+        order by
+
+        <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">
+
+
+            <trim suffixOverrides=",">
+                <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
+                    <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
+                        ${esc.d}{itemDetail}
+                    </foreach>
+                </foreach>
+            </trim>
+            ,
+        </if>
+
+        id desc
     </select>
     <select id="query${model.className}" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.${model.className}">
         select <include refid="Base_Column_List"/> from ${model.tableName}

+ 13 - 0
src/main/resources/templates/ModelTemplate.vm

@@ -22,6 +22,11 @@ private String searchKey;
 */
 private String advancedQuery;
 
+/**
+* column_name_,desc_;column_name_,asc
+*/
+private String orderByStr;
+
 #foreach($field in $model.fields)
     public $field.javaType get${display.capitalize($field.modelName)}(){
         return this.$field.modelName;
@@ -48,5 +53,13 @@ public void setAdvancedQuery(String advancedQuery) {
     this.advancedQuery = advancedQuery;
 }
 
+public String getOrderByStr() {
+    return orderByStr;
+}
+
+public void setOrderByStr(String orderByStr) {
+    this.orderByStr = orderByStr;
+}
+
 }
 

+ 16 - 7
src/main/vue/src/pages/GenCode.vue

@@ -23,7 +23,7 @@
                     </el-option>
                 </el-select>
             </el-form-item>
-            <el-form-item prop="datasourceInfo" label="数据库">
+            <el-form-item prop="dataSourceCode" label="数据库">
 
                 <el-select placeholder="数据库" size="small" v-model="formData.dataSourceCode" @change="changeDataSourceCode" class="filter-item">
                     <el-option v-for="item in datasourceInfoList" :label="item.databaseName" :value="item.code" :key="item.code"></el-option>
@@ -130,6 +130,11 @@
                                     <el-checkbox v-model="row.searchable"></el-checkbox>
                                 </template>
                             </el-table-column>
+                            <!-- <el-table-column prop="sortable" label="排序" width="50" align="center">
+                                <template slot-scope="{row}">
+                                    <el-checkbox v-model="row.sortable"></el-checkbox>
+                                </template>
+                            </el-table-column> -->
                             <el-table-column prop="formType" label="表单类型" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.formType">
@@ -183,7 +188,7 @@
                             <el-table-column prop="validatorType" label="校验类型" width="150" align="center">
                                 <template slot-scope="{row}">
                                     <el-select v-model="row.validatorType">
-                                        <el-option v-for="item in validatorTypes" :label="item.label" :value="item.label" :key="item.label"></el-option>
+                                        <el-option v-for="item in validatorTypes" :label="item.label" :value="item.value" :key="item.value"></el-option>
                                     </el-select>
                                 </template>
                             </el-table-column>
@@ -271,6 +276,7 @@ export default {
                 { label: '富文本', value: 'richText' },
                 { label: '数字', value: 'number' },
                 { label: '日期选择', value: 'date' },
+                { label: '日期时间选择', value: 'datetime' },
                 { label: '单选下拉框', value: 'select' },
                 { label: '多选下拉框', value: 'multiSelect' },
                 { label: '单图上传', value: 'singleImage' },
@@ -348,7 +354,8 @@ export default {
                     remark: '',
                     showInList: false,
                     showInForm: false,
-                    searchable: false
+                    searchable: false,
+                    sortable: true
                 },
                 {
                     name: 'del_flag',
@@ -361,7 +368,8 @@ export default {
                     showInForm: false,
                     searchable: false,
                     defaultValue: 'N',
-                    length: 1
+                    length: 1,
+                    sortable: false
                 },
             ],
             MysqlDataSourceInfos: [],
@@ -428,7 +436,8 @@ export default {
                 showInList: true,
                 showInForm: true,
                 searchable: true,
-                formType: 'singleLineText'
+                formType: 'singleLineText',
+                sortable: true
             });
         },
         removeField(i) {
@@ -451,7 +460,7 @@ export default {
             }
         },
         getDatabaseTables(code) {
-            this.tableList=[];
+            this.tableList = [];
             this.$http.get({
                 url: '/genCode/tables',
                 data: {
@@ -485,7 +494,7 @@ export default {
                 data: {
                     code: this.formData.dataSourceCode,
                     tableName: tableName,
-                    databaseType:this.formData.dataBaseType,
+                    databaseType: this.formData.dataBaseType,
                 }
             }).then(res => {
                 if (res.success) {

+ 94 - 73
src/main/vue/src/pages/TestAaa.vue

@@ -1,23 +1,24 @@
 <template>
     <div>
-        <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small"
-                 style="max-width: 500px;">
-                                                                                        <el-form-item prop="delFlag" label="删除标识">
-                <el-input v-model="formData.delFlag"></el-input>
-            </el-form-item>
-                                                                                                                                                                                                                                                                                                        <el-form-item prop="testName" label="名字">
+        <el-form :model="formData" :rules="rules" ref="form" label-width="80px" label-position="right" size="small" style="max-width: 500px;">
+            <el-form-item prop="testName" label="名字">
                 <el-input v-model="formData.testName"></el-input>
             </el-form-item>
-                                                                                                                                                                                                                                                                                                        <el-form-item prop="remark" label="备注">
+            <el-form-item prop="remark" label="备注">
                 <el-input v-model="formData.remark"></el-input>
             </el-form-item>
-                                                                                                                                                                                                                                                                                                        <el-form-item prop="imageUrl" label="image_url">
-                <el-input v-model="formData.imageUrl"></el-input>
+            <el-form-item prop="imageUrl" label="图片">
+                <single-upload v-model="formData.imageUrl"></single-upload>
             </el-form-item>
-                                                                                                                                                                                                                                                                                                        <el-form-item prop="testTime" label="test_time">
-                <el-input v-model="formData.testTime"></el-input>
+            <el-form-item prop="testTime" label="时间">
+                <template>
+                    <div class="block">
+                        <el-date-picker v-model="formData.testTime" type="date" value-format="timestamp" placeholder="选择日期">
+                        </el-date-picker>
+                    </div>
+                </template>
             </el-form-item>
-                                                                                                                                                                                                                                                                    <el-form-item>
+            <el-form-item>
                 <el-button @click="onSave" :loading="$store.state.fetchingData" type="primary">保存</el-button>
                 <el-button @click="onDelete" v-if="formData.id" type="danger">删除</el-button>
                 <el-button @click="$router.go(-1)">取消</el-button>
@@ -26,74 +27,94 @@
     </div>
 </template>
 <script>
-    import formValidator from '../formValidator'
+import formValidator from '../formValidator'
 
-    export default {
-        created() {
-            if (this.$route.query.id) {
-                this.$http.get({
-                    url: '/testAaa/getOne',
-                    data: {
-                        id: this.$route.query.id
-                    }
-                }).then(res => {
-                    if (res.success) {
-                        this.formData = res.data;
-                    }
-                })
-            }
-        },
-        data() {
-            return {
-                saving: false,
-                formData: {},
-                rules: {
-                                                                                                                                                                                            },
+export default {
+    created() {
+        if (this.$route.query.id) {
+            this.$http.get({
+                url: '/testAaa/getOne',
+                data: {
+                    id: this.$route.query.id
+                }
+            }).then(res => {
+                if (res.success) {
+                    this.formData = res.data;
+                }
+            })
         }
-        },
-        methods: {
-            onSave() {
-                this.$refs.form.validate((valid) => {
-                    if (valid) {
-                        this.submit();
-                    } else {
-                        return false;
-                    }
-                });
+    },
+    data() {
+        return {
+            saving: false,
+            formData: {},
+            rules: {
+                testName:
+                    [
+                        { required: true, message: '请输入 名字', trigger: 'blur' },
+                        { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' },
+                    ],
+                remark:
+                    [
+                        {
+                            validator: (rule, value, callback) => {
+                                if (value) {
+                                    if (value <= 100 && value >= 0) {
+                                        callback();
+                                    } else {
+                                        callback(new Error('值在 0 到 100 之间'));
+                                    }
+                                }
+                            }, trigger: 'blur'
+                        },
+                        formValidator.phone,
+                    ],
             },
-            submit() {
-                var data = JSON.parse(JSON.stringify(this.formData));
-                this.$http.post({
-                    url: this.formData.id ? '/testAaa/update' : '/testAaa/save',
-                    data: data
-                }).then(res => {
-                    if (res.success) {
-                        this.$message.success('成功');
-                        this.$router.go(-1);
-                    } else {
-                        this.$message.warning('失败')
-                    }
-                });
-            },
-            onDelete() {
-                this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
-                    return this.$http.post({
+        }
+    },
+    methods: {
+        onSave() {
+            this.$refs.form.validate((valid) => {
+                if (valid) {
+                    this.submit();
+                } else {
+                    return false;
+                }
+            });
+        },
+        submit() {
+            var data = JSON.parse(JSON.stringify(this.formData));
+            this.$http.post({
+                url: this.formData.id ? '/testAaa/update' : '/testAaa/save',
+                data: data
+            }).then(res => {
+                if (res.success) {
+                    this.$message.success('成功');
+                    this.$router.go(-1);
+                } else {
+                    this.$message.warning('失败')
+                }
+            });
+        },
+        onDelete() {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
+                return this.$http.post({
                     url: '/testAaa/del',
                     data: { id: this.formData.id }
-                    })
-                }).then(() => {
-                    this.$message.success('删除成功');
-                    this.$router.go(-1);
-                }).catch(action => {
-                    if (action === 'cancel') {
-                        this.$message.info('删除取消');
-                    } else {
-                        this.$message.error('删除失败');
-                    }
                 })
-            },
-        }
+            }).then(() => {
+                this.$message.success('删除成功');
+                this.$router.go(-1);
+            }).catch(action => {
+                if (action === 'cancel') {
+                    this.$message.info('删除取消');
+                } else {
+                    this.$message.error('删除失败');
+                }
+            })
+        },
     }
+}
 </script>
 <style lang="less" scoped>
 </style>

+ 211 - 100
src/main/vue/src/pages/TestAaas.vue

@@ -1,23 +1,18 @@
 <template>
     <div>
         <div class="filters-container">
-          
+        
             <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
-              <!--<el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
-                <el-option
-                        label="女"
-                        value="item1">
-                </el-option>
-                <el-option
-                        label="男"
-                        value="item2">
-                </el-option>
-            </el-select>-->
-            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
-            </el-button>
             <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
             </el-button>
-            <el-button @click="$router.push('/testAaa')" type="primary" size="small" icon="el-icon-edit"
+            <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small"
+                       icon="el-icon-search" class="filter-item">高级查询
+            </el-button>
+            <el-button @click="showTableSortDialog = !showTableSortDialog" type="primary" size="small"
+                       icon="el-icon-sort" class="filter-item">排序
+            </el-button>
+            <el-button @click="$router.push('/testAaa')" type="primary"
+                       size="small" icon="el-icon-edit"
                        class="filter-item">添加
             </el-button>
             <el-button @click="exportExcel" type="primary" size="small" icon="el-icon-share" class="filter-item">导出EXCEL
@@ -48,48 +43,55 @@
                     min-width="50"
                     align="center">
             </el-table-column>
-                                        <el-table-column
-                    v-if="isColumnShow('id')"
-                    prop="id"
-                    label="id"
-                    min-width="100">
-            </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('delFlag')"
-                    prop="delFlag"
-                    label="删除标识"
-                    min-width="100">
-            </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('testName')"
-                    prop="testName"
-                    label="名字"
-                    min-width="100">
-            </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('remark')"
-                    prop="remark"
-                    label="备注"
-                    min-width="100">
-            </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('imageUrl')"
-                    prop="imageUrl"
-                    label="image_url"
-                    min-width="100">
-            </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('testTime')"
-                    prop="testTime"
-                    label="test_time"
-                    min-width="100">
-            </el-table-column>
-                                        <el-table-column
+                            
+                                            <el-table-column
+                                v-if="isColumnShow('id')"
+                                prop="id"
+                                label="id"
+                                min-width="100">
+                        </el-table-column>
+                                                                                            
+                                            <el-table-column
+                                v-if="isColumnShow('testName')"
+                                prop="testName"
+                                label="名字"
+                                min-width="100">
+                        </el-table-column>
+                                                                
+                                            <el-table-column
+                                v-if="isColumnShow('remark')"
+                                prop="remark"
+                                label="备注"
+                                min-width="100">
+                        </el-table-column>
+                                                                
+                                            <el-table-column
+                                v-if="isColumnShow('imageUrl')"
+                                prop="imageUrl"
+                                label="图片"
+                                min-width="100">
+                            <template slot-scope="{row}">
+                                <img :src="row.imageUrl" @click="showImg(row.imageUrl)" style="width: 100px;height: 100px;vertical-align: middle;" />
+                            </template>
+
+                        </el-table-column>
+                                                                    
+                                            <el-table-column
+                                v-if="isColumnShow('testTime')"
+                                prop="testTime"
+                                label="时间"
+                                :formatter="DateFormatter"
+                                min-width="100">
+                        </el-table-column>
+                                                            <el-table-column
                     label="操作"
                     align="center"
-                    fixed="right">
+                    fixed="right"
+                    min-width="150"
+            >
                 <template slot-scope="scope">
                     <el-button @click="editRow(scope.row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(scope.row)" type="danger" size="mini" plain>删除</el-button>
                 </template>
             </el-table-column>
         </el-table>
@@ -131,14 +133,16 @@
                     <template slot-scope="{row}">
                         <el-select v-model="row.name">
 
-                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value" :key="item.value"></el-option>
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value"
+                                       :key="item.value"></el-option>
                         </el-select>
                     </template>
                 </el-table-column>
                 <el-table-column prop="searchMethod" label="搜索方式" width="150" align="center">
                     <template slot-scope="{row}">
                         <el-select v-model="row.searchMethod">
-                            <el-option v-for="item in searchMethods" :label="item" :value="item" :key="item"></el-option>
+                            <el-option v-for="item in searchMethods" :label="item" :value="item"
+                                       :key="item"></el-option>
                         </el-select>
                     </template>
                 </el-table-column>
@@ -160,10 +164,52 @@
             </span>
         </el-dialog>
 
+        <el-dialog title="排序" :visible.sync="showTableSortDialog">
+            <el-button @click="addSortField" type="text" icon="el-icon-plus">添加</el-button>
+            <el-table :data="tableSortFields">
+
+                <el-table-column prop="name" label="字段" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.name">
+
+                            <el-option v-for="item in advancedQueryColumns" :label="item.label" :value="item.value"
+                                       :key="item.value"></el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column prop="order" label="排序" align="center">
+                    <template slot-scope="{row}">
+                        <el-select v-model="row.order">
+                            <el-option label="降序" value="desc">
+                            </el-option>
+                            <el-option label="升序" value="asc">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
+                <el-table-column width="60" align="center">
+                    <template slot-scope="{ row, column, $index }">
+                        <el-button @click="removeSortField($index)" size="small" type="text">删除</el-button>
+                    </template>
+                </el-table-column>
+            </el-table>
+
+            <span slot="footer" class="dialog-footer">
+
+                <el-button @click="tableSortQuery" :loading="$store.state.fetchingData">确定</el-button>
+            </span>
+        </el-dialog>
+
+        <el-dialog title="查看图片" :visible.sync="imageDialogVisible" size="small">
+            <img width="100%" :src="imgSrc" alt="">
+        </el-dialog>
+
     </div>
 </template>
 <script>
     import {mapState} from 'vuex'
+    import {format} from 'date-fns'
+    import zh from 'date-fns/locale/zh_cn'
 
     export default {
         created() {
@@ -179,51 +225,44 @@
                 filter1: '',
                 filter2: '',
                 tableColumns: [
-                                        {
-                        label: 'id',
-                        value: 'id',
-                        show: true
-                    },
-                                                    {
-                        label: '删除标识',
-                        value: 'delFlag',
-                        show: true
-                    },
-                                                    {
-                        label: '名字',
-                        value: 'testName',
-                        show: true
-                    },
-                                                    {
-                        label: '备注',
-                        value: 'remark',
-                        show: true
-                    },
-                                                    {
-                        label: 'image_url',
-                        value: 'imageUrl',
-                        show: true
-                    },
-                                                    {
-                        label: 'test_time',
-                        value: 'testTime',
-                        show: true
-                    },
-                                    ],
+                                                                        {
+                                label: 'id',
+                                value: 'id',
+                                show: true
+                            },
+                                                                                                                                            {
+                                label: '名字',
+                                value: 'testName',
+                                show: true
+                            },
+                                                                                                {
+                                label: '备注',
+                                value: 'remark',
+                                show: true
+                            },
+                                                                                                {
+                                label: '图片',
+                                value: 'imageUrl',
+                                show: true
+                            },
+                                                                                                {
+                                label: '时间',
+                                value: 'testTime',
+                                show: true
+                            },
+                                                            ],
                 multipleMode: false,
                 showAdvancedQueryDialog: false,
                 advancedQueryFields: [],
+                showTableSortDialog: false,
+                tableSortFields: [],
                 searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
                 advancedQueryColumns: [
                                                                         {
                                 label: 'id',
                                 value: 'id'
                             },
-                                                                                                {
-                                label: '删除标识',
-                                value: 'del_flag'
-                            },
-                                                                                                {
+                                                                                                                                            {
                                 label: '名字',
                                 value: 'test_name'
                             },
@@ -232,15 +271,18 @@
                                 value: 'remark'
                             },
                                                                                                 {
-                                label: 'image_url',
+                                label: '图片',
                                 value: 'image_url'
                             },
                                                                                                 {
-                                label: 'test_time',
+                                label: '时间',
                                 value: 'test_time'
                             },
                                                             ],
                 advancedQuerySearchKey: '',
+                orderByStr: '',
+                imgSrc: '',
+                imageDialogVisible: false,
             }
         },
         computed: {
@@ -261,13 +303,14 @@
             },
             getData() {
                 this.$http.get({
-                url: '/testAaa/page',
-                data: {
-                    currentPage: this.currentPage,
-                    pageNumber: this.pageSize,
-                    searchKey: this.filter1,
-                    advancedQuery: this.advancedQuerySearchKey,
-                }
+                    url: '/testAaa/page',
+                    data: {
+                        currentPage: this.currentPage,
+                        pageNumber: this.pageSize,
+                        searchKey: this.filter1,
+                        advancedQuery: this.advancedQuerySearchKey,
+                        orderByStr: this.orderByStr,
+                    }
                 }).then(res => {
                     if (res.success) {
                         this.totalNumber = res.data.page.totalNumber;
@@ -339,13 +382,81 @@
                 this.getData();
                 this.showAdvancedQueryDialog = false;
             },
+            addSortField() {
+                this.tableSortFields.push({
+                    name: '',
+                    order: 'asc',
+                });
+            },
+            removeSortField(i) {
+                if (this.tableSortFields.length > 0) {
+                    this.tableSortFields.splice(i, 1);
+                }
+            },
+            tableSortQuery() {
+
+                this.orderByStr = '';
+
+                if (this.tableSortFields.length > 0) {
+
+                    var templist = [];
+
+                    this.tableSortFields.forEach(item => {
+                        if (item.name && item.order) {
+                            var tempItem = item.name + '_,' + item.order;
+                            templist.push(tempItem);
+                        }
+                    })
+
+                    if (templist.length > 0) {
+
+                        this.orderByStr = templist.join('_;');
+                    }
+                }
+
+                this.getData();
+                this.showTableSortDialog = false;
+            },
             exportExcel() {
                 window.location.href = this.$baseUrl + "/testAaa/exportExcel?searchKey=" + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey
             },
             searchData() {
                 this.currentPage = 1;
                 this.getData();
-            }
+            },
+            deleteRow(row) {
+                this.$alert('删除将无法恢复,确认要删除么?', '警告', {type: 'error'}).then(() => {
+                    return this.$http.post({
+                        url: '/testAaa/del',
+                        data: {id: row.id}
+                    })
+                }).then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                }).catch(action => {
+                    if (action === 'cancel') {
+                        this.$message.info('删除取消');
+                    } else {
+                        this.$message.error('删除失败');
+                    }
+                })
+            },
+            DateTimeFormatter(row, column, cellValue) {
+                if (cellValue) {
+                    return format(cellValue, 'YYYY/MM/DD HH:mm', {locale: zh})
+                }
+
+            },
+            DateFormatter(row, column, cellValue) {
+                if (cellValue) {
+                    return format(cellValue, 'YYYY/MM/DD', {locale: zh})
+                }
+
+            },
+            showImg(img) {
+                this.imgSrc = img;
+                this.imageDialogVisible = true;
+            },
 
         }
     }

+ 175 - 216
src/main/vue/src/pages/TestBbbs.vue

@@ -1,9 +1,9 @@
 <template>
     <div>
         <div class="filters-container">
-          
+
             <el-input placeholder="关键字" size="small" v-model="filter1" clearable class="filter-item"></el-input>
-              <!--<el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
+            <!--<el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
                 <el-option
                         label="女"
                         value="item1">
@@ -13,19 +13,19 @@
                         value="item2">
                 </el-option>
             </el-select>-->
-              <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
-              </el-button>
+            <el-button @click="searchData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
+            </el-button>
             <el-button @click="showAdvancedQueryDialog = !showAdvancedQueryDialog" type="primary" size="small" icon="el-icon-search" class="filter-item">高级查询
             </el-button>
 
-            <el-button @click="$router.push('/testBbb')" type="primary" size="small" icon="el-icon-edit"
-                       class="filter-item">添加
+            <el-button @click="$router.push('/testBbb')" type="primary" size="small" icon="el-icon-edit" class="filter-item">添加
             </el-button>
             <el-button @click="exportExcel" type="primary" size="small" icon="el-icon-share" class="filter-item">导出EXCEL
             </el-button>
             <el-dropdown trigger="click" size="medium" class="table-column-filter">
                 <span>
-                  筛选数据<i class="el-icon-arrow-down el-icon--right"></i>
+                    筛选数据
+                    <i class="el-icon-arrow-down el-icon--right"></i>
                 </span>
                 <el-dropdown-menu slot="dropdown" class="table-column-filter-wrapper">
                     <el-checkbox v-for="item in tableColumns" :key="item.value" v-model="item.show">{{item.label}}
@@ -33,52 +33,20 @@
                 </el-dropdown-menu>
             </el-dropdown>
         </div>
-        <el-table
-                :data="tableData"
-                :height="tableHeight"
-                row-key="id"
-                ref="table">
-            <el-table-column
-                    v-if="multipleMode"
-                    align="center"
-                    type="selection"
-                    width="50">
+        <el-table :data="tableData" :height="tableHeight" row-key="id" ref="table">
+            <el-table-column v-if="multipleMode" align="center" type="selection" width="50">
             </el-table-column>
-            <el-table-column
-                    type="index"
-                    min-width="50"
-                    align="center">
+            <el-table-column type="index" min-width="50" align="center">
             </el-table-column>
-                                                                                                <el-table-column
-                    v-if="isColumnShow('nameAaa')"
-                    prop="nameAaa"
-                    label="名称1"
-                    min-width="100">
+            <el-table-column v-if="isColumnShow('nameAaa')" prop="nameAaa" label="名称1" min-width="100">
             </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('nameBbb')"
-                    prop="nameBbb"
-                    label="名称2"
-                    min-width="100">
+            <el-table-column v-if="isColumnShow('nameBbb')" prop="nameBbb" label="名称2" min-width="100">
             </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('nameCcc')"
-                    prop="nameCcc"
-                    label="名称3"
-                    min-width="100">
+            <el-table-column v-if="isColumnShow('nameCcc')" prop="nameCcc" label="名称3" min-width="100">
             </el-table-column>
-                                                        <el-table-column
-                    v-if="isColumnShow('nameDdd')"
-                    prop="nameDdd"
-                    label="名称4"
-                    min-width="100">
+            <el-table-column v-if="isColumnShow('nameDdd')" prop="nameDdd" label="名称4" min-width="100">
             </el-table-column>
-                                        <el-table-column
-                    label="操作"
-                    align="center"
-                    fixed="right"
-                    min-width="150"
-            >
+            <el-table-column label="操作" align="center" fixed="right" min-width="150">
                 <template slot-scope="scope">
                     <el-button @click="editRow(scope.row)" type="primary" size="mini" plain>编辑</el-button>
                     <el-button @click="deleteRow(scope.row)" type="danger" size="mini" plain>删除</el-button>
@@ -94,15 +62,7 @@
                     <el-button size="small" @click="toggleMultipleMode(false)">取消</el-button>
                 </el-button-group>
             </div>
-            <el-pagination
-                    background
-                    @size-change="pageSizeChange"
-                    @current-change="currentPageChange"
-                    :current-page="currentPage"
-                    :page-sizes="[10, 20, 30, 40, 50]"
-                    :page-size="pageSize"
-                    layout="total, sizes, prev, pager, next, jumper"
-                    :total="totalNumber">
+            <el-pagination background @size-change="pageSizeChange" @current-change="currentPageChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalNumber">
             </el-pagination>
         </div>
         <el-dialog title="高级查询" :visible.sync="showAdvancedQueryDialog">
@@ -155,86 +115,86 @@
     </div>
 </template>
 <script>
-    import {mapState} from 'vuex'
+import { mapState } from 'vuex'
 
-    export default {
-        created() {
+export default {
+    created() {
+        this.getData();
+    },
+    data() {
+        return {
+            totalNumber: 0,
+            totalPage: 10,
+            currentPage: 1,
+            pageSize: 20,
+            tableData: [],
+            filter1: '',
+            filter2: '',
+            tableColumns: [
+                {
+                    label: '名称1',
+                    value: 'nameAaa',
+                    show: true
+                },
+                {
+                    label: '名称2',
+                    value: 'nameBbb',
+                    show: true
+                },
+                {
+                    label: '名称3',
+                    value: 'nameCcc',
+                    show: true
+                },
+                {
+                    label: '名称4',
+                    value: 'nameDdd',
+                    show: true
+                },
+            ],
+            multipleMode: false,
+            showAdvancedQueryDialog: false,
+            advancedQueryFields: [],
+            searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
+            advancedQueryColumns: [
+                {
+                    label: '名称1',
+                    value: 'name_aaa'
+                },
+                {
+                    label: '名称2',
+                    value: 'name_bbb'
+                },
+                {
+                    label: '名称3',
+                    value: 'name_ccc'
+                },
+                {
+                    label: '名称4',
+                    value: 'name_ddd'
+                },
+            ],
+            advancedQuerySearchKey: '',
+        }
+    },
+    computed: {
+        ...mapState(['tableHeight']),
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        }
+    },
+    methods: {
+        pageSizeChange(size) {
+            this.currentPage = 1;
+            this.pageSize = size;
             this.getData();
         },
-        data() {
-            return {
-                totalNumber: 0,
-                totalPage: 10,
-                currentPage: 1,
-                pageSize: 20,
-                tableData: [],
-                filter1: '',
-                filter2: '',
-                tableColumns: [
-                                                                                {
-                        label: '名称1',
-                        value: 'nameAaa',
-                        show: true
-                    },
-                                                    {
-                        label: '名称2',
-                        value: 'nameBbb',
-                        show: true
-                    },
-                                                    {
-                        label: '名称3',
-                        value: 'nameCcc',
-                        show: true
-                    },
-                                                    {
-                        label: '名称4',
-                        value: 'nameDdd',
-                        show: true
-                    },
-                                    ],
-                multipleMode: false,
-                showAdvancedQueryDialog: false,
-                advancedQueryFields: [],
-                searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
-                advancedQueryColumns: [
-                                                                                                                                                                {
-                                label: '名称1',
-                                value: 'name_aaa'
-                            },
-                                                                                                {
-                                label: '名称2',
-                                value: 'name_bbb'
-                            },
-                                                                                                {
-                                label: '名称3',
-                                value: 'name_ccc'
-                            },
-                                                                                                {
-                                label: '名称4',
-                                value: 'name_ddd'
-                            },
-                                                            ],
-                advancedQuerySearchKey: '',
-            }
-        },
-        computed: {
-            ...mapState(['tableHeight']),
-            selection() {
-                return this.$refs.table.selection.map(i => i.id);
-            }
+        currentPageChange(page) {
+            this.currentPage = page;
+            this.getData();
         },
-        methods: {
-            pageSizeChange(size) {
-                this.currentPage = 1;
-                this.pageSize = size;
-                this.getData();
-            },
-            currentPageChange(page) {
-                this.currentPage = page;
-                this.getData();
-            },
-            getData() {
-                this.$http.get({
+        getData() {
+            this.$http.get({
                 url: '/testBbb/page',
                 data: {
                     currentPage: this.currentPage,
@@ -242,105 +202,104 @@
                     searchKey: this.filter1,
                     advancedQuery: this.advancedQuerySearchKey,
                 }
-                }).then(res => {
-                    if (res.success) {
-                        this.totalNumber = res.data.page.totalNumber;
-                        this.tableData = res.data.pp;
-                    }
-                })
-            },
-            isColumnShow(column) {
-                var row = this.tableColumns.find(i => i.value === column);
-                return row ? row.show : false;
-            },
-            toggleMultipleMode(multipleMode) {
-                this.multipleMode = multipleMode;
-                if (!multipleMode) {
-                    this.$refs.table.clearSelection();
+            }).then(res => {
+                if (res.success) {
+                    this.totalNumber = res.data.page.totalNumber;
+                    this.tableData = res.data.pp;
                 }
-            },
-            editRow(row) {
-                this.$router.push({
-                    path: '/testBbb',
-                    query: {
-                        id: row.id
-                    }
-                })
-            },
-            operation1() {
-                this.$notify({
-                    title: '提示',
-                    message: this.selection
-                });
-            },
-            operation2() {
-                this.$message('操作2');
-            },
-            addField() {
-                this.advancedQueryFields.push({
-                    link: 'AND',
-                    name: '',
-                    searchMethod: '=',
-                    value: '',
-                });
-            },
-            removeField(i) {
-                if (this.advancedQueryFields.length > 0) {
-                    this.advancedQueryFields.splice(i, 1);
+            })
+        },
+        isColumnShow(column) {
+            var row = this.tableColumns.find(i => i.value === column);
+            return row ? row.show : false;
+        },
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
+            }
+        },
+        editRow(row) {
+            this.$router.push({
+                path: '/testBbb',
+                query: {
+                    id: row.id
                 }
-            },
-            advancedQuery() {
+            })
+        },
+        operation1() {
+            this.$notify({
+                title: '提示',
+                message: this.selection
+            });
+        },
+        operation2() {
+            this.$message('操作2');
+        },
+        addField() {
+            this.advancedQueryFields.push({
+                link: 'AND',
+                name: '',
+                searchMethod: '=',
+                value: '',
+            });
+        },
+        removeField(i) {
+            if (this.advancedQueryFields.length > 0) {
+                this.advancedQueryFields.splice(i, 1);
+            }
+        },
+        advancedQuery() {
 
-                this.advancedQuerySearchKey = '';
+            this.advancedQuerySearchKey = '';
 
-                if (this.advancedQueryFields.length > 0) {
+            if (this.advancedQueryFields.length > 0) {
 
-                    var templist = [];
+                var templist = [];
 
-                    this.advancedQueryFields.forEach(item => {
-                        if (item.link && item.name && item.searchMethod && item.value) {
-                            var tempItem = item.link + '_,' + item.name + '_,' + item.searchMethod + '_,' + item.value;
-                            templist.push(tempItem);
-                        }
-                    })
+                this.advancedQueryFields.forEach(item => {
+                    if (item.link && item.name && item.searchMethod && item.value) {
+                        var tempItem = item.link + '_,' + item.name + '_,' + item.searchMethod + '_,' + item.value;
+                        templist.push(tempItem);
+                    }
+                })
 
-                    if (templist.length > 0) {
+                if (templist.length > 0) {
 
-                        this.advancedQuerySearchKey = templist.join('_;');
-                    }
+                    this.advancedQuerySearchKey = templist.join('_;');
                 }
+            }
 
-                this.getData();
-                this.showAdvancedQueryDialog = false;
-            },
-            exportExcel() {
-                window.location.href = this.$baseUrl + "/testBbb/exportExcel?searchKey=" + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey
-            },
-            searchData() {
-                this.currentPage = 1;
-                this.getData();
-            },
-            deleteRow(row) {
-                this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
-                    return this.$http.post({
+            this.getData();
+            this.showAdvancedQueryDialog = false;
+        },
+        exportExcel() {
+            window.location.href = this.$baseUrl + "/testBbb/exportExcel?searchKey=" + this.filter1 + "&advancedQuery=" + this.advancedQuerySearchKey
+        },
+        searchData() {
+            this.currentPage = 1;
+            this.getData();
+        },
+        deleteRow(row) {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' }).then(() => {
+                return this.$http.post({
                     url: '/testBbb/del',
                     data: { id: row.id }
-                    })
-                }).then(() => {
-                    this.$message.success('删除成功');
-                    this.getData();
-                }).catch(action => {
-                    if (action === 'cancel') {
-                        this.$message.info('删除取消');
-                    } else {
-                        this.$message.error('删除失败');
-                    }
                 })
-            },
+            }).then(() => {
+                this.$message.success('删除成功');
+                this.getData();
+            }).catch(action => {
+                if (action === 'cancel') {
+                    this.$message.info('删除取消');
+                } else {
+                    this.$message.error('删除失败');
+                }
+            })
+        },
 
-        }
     }
+}
 </script>
 <style lang="less" scoped>
-
 </style>

+ 9 - 1
src/main/vue/src/pages/Testaaaone.vue

@@ -42,7 +42,15 @@
                 saving: false,
                 formData: {},
                 rules: {
-                                                                                                                                    },
+                                                                                                        testName:
+                    [
+                        {required: true, message: '请输入 名字', trigger: 'blur'},
+                                            ],
+                                                                remark:
+                    [
+                        {required: true, message: '请输入 备注', trigger: 'blur'},
+                                            ],
+                                    },
         }
         },
         methods: {