Browse Source

待办已办按时间查询

lining 6 năm trước cách đây
mục cha
commit
582b0ad4d2

+ 52 - 13
src/dashoo.cn/backend/api/controllers/oilsupplier/todolist.go

@@ -10,9 +10,11 @@ import (
 	"dashoo.cn/backend/api/business/workflow"
 	. "dashoo.cn/backend/api/controllers"
 	"dashoo.cn/utils"
+	"fmt"
 	"sort"
 	"strconv"
 	"strings"
+	"time"
 )
 
 type TodoListController struct {
@@ -45,7 +47,7 @@ func (this *TodoListController) GetMyTaskEntityList() {
 		wfNames = workflow.OIL_SUPPLIER_INSTORE
 	}
 
-	var todolists []todolist.TodoList
+	var todoliststemp []todolist.TodoList
 
 	var pagingResult workflow.ActiMyPagingResultVM
 	var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
@@ -79,7 +81,7 @@ func (this *TodoListController) GetMyTaskEntityList() {
 				if wfName == workflow.OIL_SUPPLIER_INSTORE {
 					todo.Type = todolist.STORAGE
 				}
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY {
@@ -94,7 +96,7 @@ func (this *TodoListController) GetMyTaskEntityList() {
 				todo.TaskName = item.TaskName
 				todo.UserName = this.User.Realname
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_AUDIT_APPLY {
@@ -115,7 +117,7 @@ func (this *TodoListController) GetMyTaskEntityList() {
 				todo.Status = listannu.Status
 				todo.CertId = strconv.Itoa(listannu.CerId)
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_INFO_CHANGE {
@@ -134,7 +136,7 @@ func (this *TodoListController) GetMyTaskEntityList() {
 				todo.SupplierTypeCode = listInfo.SupplierTypeName
 				todo.Status = listInfo.Status
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 		} else if wfName == workflow.OIL_REGISTER_APPLY {
 			//企业用户注册
@@ -150,11 +152,31 @@ func (this *TodoListController) GetMyTaskEntityList() {
 				todo.TaskName = item.TaskName
 				todo.Status = strconv.Itoa(listinfo.CheckStatus)
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 		}
 	}
 
+	var todolists []todolist.TodoList
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		var minDate time.Time
+		var maxDate time.Time
+		if len(dates) == 2 {
+			minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
+			maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
+		}
+		for i := 0; i < len(todoliststemp); i++ {
+			fmt.Println(minDate.Unix()*1000, "==",maxDate.Unix()*1000)
+			fmt.Println(todoliststemp[i].CreateTime, "==",todoliststemp[i].CreateTime)
+			if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
+				todolists = append(todolists, todoliststemp[i])
+			}
+		}
+	} else {
+		todolists = todoliststemp
+	}
 	sort.Slice(todolists, func(i, j int) bool {
 		return todolists[i].CreateTime > todolists[j].CreateTime
 	})
@@ -193,7 +215,7 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 		wfNames = workflow.OIL_SUPPLIER_INSTORE
 	}
 
-	var todolists []todolist.TodoList
+	var todoliststemp []todolist.TodoList
 
 	var pagingResult workflow.ActiMyPagingResultVM
 	var myTasksRetWithTimes []workflow.ActiMyTasksRetWithTimeVM
@@ -224,7 +246,7 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 				todo.UserName = this.User.Realname
 				todo.CreateTime = item.CreateTime
 				todo.TaskName = item.TaskName
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_ENUSER_APPEND_APPLY || wfName == workflow.OIL_FIRST_ENUSER_APPEND_APPLY || wfName == workflow.OIL_SECOND_ENUSER_APPEND_APPLY {
@@ -239,7 +261,7 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 				todo.Type = todolist.CERTAPPEND
 				todo.UserName = this.User.Realname
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_AUDIT_APPLY {
@@ -262,7 +284,7 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 				todo.Status = listannu.Status
 				todo.CertId = strconv.Itoa(listannu.CerId)
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 
 		} else if wfName == workflow.OIL_INFO_CHANGE {
@@ -283,7 +305,7 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 				todo.SupplierTypeCode = listInfo.SupplierTypeName
 				todo.Status = listInfo.Status
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 		} else if wfName == workflow.OIL_REGISTER_APPLY {
 			//企业用户注册
@@ -299,12 +321,29 @@ func (this *TodoListController) GetMyTaskFinishedList() {
 				todo.TaskName = item.TaskName
 				todo.Status = strconv.Itoa(listinfo.CheckStatus)
 				todo.CreateTime = item.CreateTime
-				todolists = append(todolists, todo)
+				todoliststemp = append(todoliststemp, todo)
 			}
 		}
 
 	}
-
+	var todolists []todolist.TodoList
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		var minDate time.Time
+		var maxDate time.Time
+		if len(dates) == 2 {
+			minDate,_ = utils.TimeParse(dates[0], "2006-01-02 15:04")
+			maxDate,_ = utils.TimeParse(dates[1], "2006-01-02 15:04")
+		}
+		for i := 0; i < len(todoliststemp); i++ {
+			if todoliststemp[i].CreateTime > minDate.Unix()*1000 && todoliststemp[i].CreateTime < maxDate.Unix()*1000 {
+				todolists = append(todolists, todoliststemp[i])
+			}
+		}
+	} else {
+		todolists = todoliststemp
+	}
 	sort.Slice(todolists, func(i, j int) bool {
 		return todolists[i].CreateTime > todolists[j].CreateTime
 	})

+ 34 - 18
src/dashoo.cn/frontend_web/src/pages/index.vue

@@ -6,6 +6,10 @@
           <i class="icon icon-table2"></i> 待办/已办
         </span>
         <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
+          <el-form-item label="提交时间">
+            <el-date-picker size="mini" style="width: 220px" v-model="CreateOn" type="daterange" range-separator="至"
+                            start-placeholder="提交日期" end-placeholder="提交日期"></el-date-picker>
+          </el-form-item>
           <el-form-item label="类型">
             <el-select size="mini" style="width:100px" v-model="searchForm.Type" placeholder="准入类别">
               <el-option label="全部" value=""></el-option>
@@ -306,7 +310,7 @@
         activeName: 'first',
         currentDate: new Date(),
         // 查询时间
-        CreateOn: [],
+        CreateOn: null,
         // 分页参数
         size: 10,
         currentPage: 1,
@@ -336,7 +340,6 @@
           SupplierTypeCode: '',
           SupplierName: '',
           IsPay: '1',
-          CreateOn: '',
           CreateUserId: '',
           CreateBy: '',
           ModifiedOn: '',
@@ -416,21 +419,22 @@
     methods: {
       initDatas () {
         // 分页及列表条件
-        let params = {
-          _currentPage: this.currentPage,
-          _size: this.size,
-          Order: this.Column.Order,
-          Prop: this.Column.Prop
-        }
         let myCreateOn = []
         // 解析时间
-        if (this.CreateOn.length === 2) {
+        if (this.CreateOn != null && this.CreateOn.length === 2) {
           this.CreateOn[1].setHours(23)
           this.CreateOn[1].setMinutes(59)
           this.CreateOn[1].setSeconds(59)
           myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
           myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
         }
+        let params = {
+          _currentPage: this.currentPage,
+          _size: this.size,
+          Order: this.Column.Order,
+          Prop: this.Column.Prop,
+          CreateOn: myCreateOn.join(',')
+        }
         // 查询条件
         Object.assign(params, this.searchForm)
         // 访问接口
@@ -459,7 +463,6 @@
         }
       },
       rowClick (val) {
-        console.log(val)
         let SupplierType = ''
         if (val.Type === '1') {
           if (val.SupplierTypeCode === '01') {
@@ -611,22 +614,23 @@
       },
 
       finishedData () {
-        // 分页及列表条件
-        let params = {
-          _currentPage: this.currentPageFinished,
-          _size: this.sizeFinished,
-          Order: this.ColumnFinished.Order,
-          Prop: this.ColumnFinished.Prop
-        }
         let myCreateOn = []
         // 解析时间
-        if (this.CreateOn.length === 2) {
+        if (this.CreateOn != null && this.CreateOn.length === 2) {
           this.CreateOn[1].setHours(23)
           this.CreateOn[1].setMinutes(59)
           this.CreateOn[1].setSeconds(59)
           myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
           myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
         }
+        // 分页及列表条件
+        let params = {
+          _currentPage: this.currentPageFinished,
+          _size: this.sizeFinished,
+          Order: this.ColumnFinished.Order,
+          Prop: this.ColumnFinished.Prop,
+          CreateOn: myCreateOn.join(',')
+        }
         // 查询条件
         Object.assign(params, this.searchForm)
         api.getMyTaskFinished(params, this.$axios).then(res => {
@@ -722,6 +726,18 @@
           return val.substring(0, 19)
         }
       },
+      formatDateTime (date) {
+        var y = date.getFullYear()
+        var m = date.getMonth() + 1
+        m = m < 10 ? ('0' + m) : m
+        var d = date.getDate()
+        d = d < 10 ? ('0' + d) : d
+        var h = date.getHours()
+        h = h < 10 ? ('0' + h) : h
+        var minute = date.getMinutes()
+        minute = minute < 10 ? ('0' + minute) : minute
+        return y + '-' + m + '-' + d + ' ' + h + ':' + minute
+      },
       handleCurrentChangeFinished (value) {
         this.currentPageFinished = value
         this.finishedData()