suochencheng před 7 roky
rodič
revize
d8b4406745

+ 10 - 0
src/main/java/com/izouma/awesomeadmin/model/GenCode.java

@@ -109,6 +109,8 @@ public class GenCode {
 
     private List<Subtable> subtables;
 
+    private List<SortField> tableSortFields;
+
 
     public List<TableField> getFields() {
         return fields;
@@ -301,5 +303,13 @@ public class GenCode {
     public void setModules(String modules) {
         this.modules = modules;
     }
+
+    public List<SortField> getTableSortFields() {
+        return tableSortFields;
+    }
+
+    public void setTableSortFields(List<SortField> tableSortFields) {
+        this.tableSortFields = tableSortFields;
+    }
 }
 

+ 35 - 0
src/main/java/com/izouma/awesomeadmin/model/SortField.java

@@ -0,0 +1,35 @@
+package com.izouma.awesomeadmin.model;
+
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * SortField 实体类
+ * Fri May 04 13:38:24 CST 2018  Suo Chen Cheng
+ */
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SortField {
+
+    private String name;
+
+    private String order;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getOrder() {
+        return order;
+    }
+
+    public void setOrder(String order) {
+        this.order = order;
+    }
+}
+

+ 46 - 35
src/main/resources/templates/ListTemplate.vm

@@ -289,7 +289,16 @@
                 showAdvancedQueryDialog: false,
                 advancedQueryFields: [],
                 showTableSortDialog: false,
-                tableSortFields: [],
+                tableSortFields: [
+                #foreach($sortField in $model.tableSortFields)
+                    #if(${sortField.name})
+                        {
+                            name: '${sortField.name}',
+                            order: '${sortField.order}'
+                        },
+                    #end
+                #end
+            ],
                 searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
                 advancedQueryColumns: [
                     #foreach($field in $model.fields)
@@ -332,6 +341,42 @@
             },
             getData() {
 
+                if (this.advancedQueryFields.length > 0) {
+
+                    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);
+                    }
+                })
+
+                    if (templist.length > 0) {
+
+                        this.advancedQuerySearchKey = templist.join('_;');
+                    }
+                }
+
+
+                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('_;');
+                    }
+                }
+
+
                 var data = {
                     currentPage: this.currentPage,
                     pageNumber: this.pageSize,
@@ -442,23 +487,6 @@
 
                 this.advancedQuerySearchKey = '';
 
-                if (this.advancedQueryFields.length > 0) {
-
-                    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);
-                        }
-                    })
-
-                    if (templist.length > 0) {
-
-                        this.advancedQuerySearchKey = templist.join('_;');
-                    }
-                }
-
                 this.getData();
                 this.showAdvancedQueryDialog = false;
             },
@@ -477,23 +505,6 @@
 
                 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;
             },

+ 65 - 21
src/main/vue/src/pages/GenCode.vue

@@ -46,23 +46,23 @@
 			</el-form-item>
 
 			<el-form-item prop="modules" label="功能">
-                <el-select placeholder="modules" size="small" multiple v-model="formData.modules" class="filter-item">
-                    <el-option label="搜索" value="search">
-                    </el-option>
-                    <el-option label="高级搜索" value="query">
-                    </el-option>
+				<el-select placeholder="modules" size="small" multiple v-model="formData.modules" class="filter-item">
+					<el-option label="搜索" value="search">
+					</el-option>
+					<el-option label="高级搜索" value="query">
+					</el-option>
 					<el-option label="排序" value="orders">
-                    </el-option>
+					</el-option>
 					<el-option label="导出Excel" value="excel">
-                    </el-option>
-                    <el-option label="添加" value="add">
-                    </el-option>
-                    <el-option label="编辑" value="edit">
-                    </el-option>
-                    <el-option label="删除" value="del">
-                    </el-option>
-                </el-select>
-            </el-form-item>
+					</el-option>
+					<el-option label="添加" value="add">
+					</el-option>
+					<el-option label="编辑" value="edit">
+					</el-option>
+					<el-option label="删除" value="del">
+					</el-option>
+				</el-select>
+			</el-form-item>
 
 			<el-form-item prop="genCode" label="生成">
 				<el-checkbox v-model="formData.genTable" label="表"></el-checkbox>
@@ -274,6 +274,35 @@
 						</el-table>
 						<el-button @click="addSubtable" type="text" icon="el-icon-plus">添加</el-button>
 					</el-tab-pane>
+					<el-tab-pane label="排序" name="5">
+						<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 fields" :label="item.name" :value="item.name" :key="item.name"></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>
+						<el-button @click="addSortField" type="text" icon="el-icon-plus">添加</el-button>
+					</el-tab-pane>
 				</el-tabs>
 
 			</el-form-item>
@@ -370,19 +399,20 @@ export default {
 				this.loading = false;
 				if (res.success) {
 
-					
+
 
 					this.formData = {
 						...this.formData,
 						...JSON.parse(res.data.genJson)
 					};
-					
+
 					this.formData.modules = this.formData.modules ? this.formData.modules.split(',').map(i => String(i)) : [];
 
 					this.fields = this.formData.fields;
 					this.formData.id = res.data.id;
 					this.formData.genRouter = false;
 					this.subtables = this.formData.subtables;
+					this.tableSortFields = this.formData.tableSortFields;
 				}
 			}).catch(e => this.loading = false)
 		}
@@ -449,7 +479,7 @@ export default {
 			fieldTypes: ['char', 'varchar', 'int', 'text', 'timestamp', 'datetime', 'decimal', 'float', 'vue'],
 			searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'between', 'like', 'left like', 'right like'],
 			formTypes: [
-				
+
 				{ label: '单行文本', value: 'singleLineText' },
 				{ label: '数字', value: 'number' },
 				{ label: '日期选择', value: 'date' },
@@ -511,9 +541,9 @@ export default {
 				dataBaseType: [{ required: true, message: '请选择数据库类型', trigger: 'blur' }],
 				dataSourceCode: [{ required: true, message: '请填选择数据库', trigger: 'blur' }],
 				typeFlag: [{ required: true, message: '请填填写分类', trigger: 'blur' }],
-				 modules: [
-                    { required: true, message: '请选择功能', trigger: 'blur' },
-                ],
+				modules: [
+					{ required: true, message: '请选择功能', trigger: 'blur' },
+				],
 			},
 			formData: {
 				tableName: '',
@@ -532,6 +562,7 @@ export default {
 				className: '',
 				subtables: [],
 				modules: [],
+				tableSortFields: [],
 
 			},
 			fields: [
@@ -582,6 +613,7 @@ export default {
 			optionsDatasourceInfoList: [],
 			optionsTableList: [],
 			optionsFields: [],
+			tableSortFields: [],
 		}
 	},
 	computed: {
@@ -606,6 +638,7 @@ export default {
 
 			this.formData.fields = this.fields;
 			this.formData.subtables = this.subtables;
+			this.formData.tableSortFields = this.tableSortFields;
 			this.formData.javaPath = this.formData.rootPath + this.formData.javaPathRelative;
 			this.formData.viewPath = this.formData.rootPath + this.formData.viewPathRelative;
 			this.formData.routerPath = this.formData.rootPath + this.formData.routerPathRelative;
@@ -837,6 +870,17 @@ export default {
 
 
 		},
+		addSortField() {
+			this.tableSortFields.push({
+				name: '',
+				order: 'asc',
+			});
+		},
+		removeSortField(i) {
+			if (this.tableSortFields.length > 0) {
+				this.tableSortFields.splice(i, 1);
+			}
+		},
 
 
 	}

+ 46 - 35
src/main/vue/src/pages/TestAaas.vue

@@ -355,7 +355,16 @@
                 showAdvancedQueryDialog: false,
                 advancedQueryFields: [],
                 showTableSortDialog: false,
-                tableSortFields: [],
+                tableSortFields: [
+                                                            {
+                            name: 'remark',
+                            order: 'asc'
+                        },
+                                                                                {
+                            name: 'test_time',
+                            order: 'desc'
+                        },
+                                                ],
                 searchMethods: ['=', '!=', '>', '>=', '<', '<=', 'like'],
                 advancedQueryColumns: [
                                                                         {
@@ -434,6 +443,42 @@
             },
             getData() {
 
+                if (this.advancedQueryFields.length > 0) {
+
+                    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);
+                    }
+                })
+
+                    if (templist.length > 0) {
+
+                        this.advancedQuerySearchKey = templist.join('_;');
+                    }
+                }
+
+
+                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('_;');
+                    }
+                }
+
+
                 var data = {
                     currentPage: this.currentPage,
                     pageNumber: this.pageSize,
@@ -530,23 +575,6 @@
 
                 this.advancedQuerySearchKey = '';
 
-                if (this.advancedQueryFields.length > 0) {
-
-                    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);
-                        }
-                    })
-
-                    if (templist.length > 0) {
-
-                        this.advancedQuerySearchKey = templist.join('_;');
-                    }
-                }
-
                 this.getData();
                 this.showAdvancedQueryDialog = false;
             },
@@ -565,23 +593,6 @@
 
                 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;
             },