Browse Source

bug
Signed-off-by: lijunqing <lijunqing@dashoo.cn>

lijunqing 6 years ago
parent
commit
e5b5e40e50

+ 1 - 0
src/dashoo.cn/backend/api/business/limscheckequipmentlist/limscheckequipmentlist.go

@@ -22,6 +22,7 @@ type LimsCheckEquipmentList struct {
 	Manufacturer    string    `json:"Manufacturer" xorm:"comment('制造厂家') VARCHAR(255) 'Manufacturer'"`
 	Status          string    `json:"Status" xorm:"comment('产品状态') VARCHAR(255) 'Status'"`
 	LastCheckDate   time.Time `json:"LastCheckDate" xorm:"comment('最后一次检测时间') DATETIME 'LastCheckDate'"`
+	NextCheckDate   time.Time `json:"NextCheckDate" xorm:"comment('下一次检测时间') DATETIME 'NextCheckDate'"`
 	Cycle           float32   `json:"Cycle" xorm:"comment('检测周期') FLOAT(10,2) 'Cycle'"`
 	CycleUnit       string    `json:"CycleUnit" xorm:"comment('检测周期单位') VARCHAR(255) 'CycleUnit'"`
 	Remark          string    `xorm:VARCHAR(255)`       //描述

+ 34 - 1
src/dashoo.cn/backend/api/controllers/lims/limscheckequipmentlist.go

@@ -56,6 +56,7 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
 	TemplateTypeId := this.GetString("TemplateTypeId")
 	PositionAllTypeId := this.GetString("PositionAllTypeId")
 	QueryCheckDate := this.GetString("QueryCheckDate")
+	statusValue:=this.GetString("statusValue")
 
 	if Id != "" {
 		where = where + " and Id like '%" + Id + "%'"
@@ -116,6 +117,16 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
 	if QueryCheckDate != "" {
 		where = where + " and  date_add(LastCheckDate, interval " + QueryCheckDate + " month) >= now()"
 	}
+
+	if statusValue!=""{
+		if statusValue=="-2"{
+			where = where + " and  NextCheckDate < DATE_FORMAT(NOW(),'%Y-%m-%d') "
+		}else if statusValue=="-1"{
+			where = where + " and  NextCheckDate >= DATE_FORMAT(NOW(),'%Y-%m-%d') and NextCheckDate <= DATE_FORMAT(date_add(NOW(), interval 1 month),'%Y-%m-%d') "
+		}else{
+			where = where + " and  NextCheckDate > DATE_FORMAT(date_add(NOW(), interval 1 month),'%Y-%m-%d') "
+		}
+	}
 	// 把安装位置取出来
 	strPositionList := ""
 	orgSvc := organize.GetOrganizeService(utils.DBE)
@@ -144,7 +155,7 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
 	}
 
 	if len(strPositionList) > 0 {
-		where = where + " and PositionCheckId in ('" + strPositionList + "')"
+		where = where + " and PositionCheckId in (" + strPositionList + ")"
 	}
 
 	svc := limscheckequipmentlist.GetLimsCheckEquipmentListService(utils.DBE)
@@ -218,6 +229,16 @@ func (this *LimsCheckEquipmentListController) AddEntity() {
 	orgsrv.GetEntityById(this.User.DepartmentId, &organizeEntity)
 	model.Departmentname = organizeEntity.Fullname
 
+	//计算下次检测日期
+	if model.CycleUnit=="天"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(0,0,int(model.Cycle))
+	}else if  model.CycleUnit=="月"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(0,int(model.Cycle),0)
+	}else if  model.CycleUnit=="年"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(int(model.Cycle),0,0)
+	}else{
+		model.NextCheckDate=model.LastCheckDate
+	}
 	_, err := svc.InsertEntityBytbl(this.User.AccCode+LimsCheckEquipmentListName, &model)
 
 	var errinfo ErrorDataInfo
@@ -261,6 +282,17 @@ func (this *LimsCheckEquipmentListController) UpdateEntity() {
 	model.ModifiedBy = this.User.Realname
 	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
 
+	//计算下次检测日期
+	if model.CycleUnit=="天"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(0,0,int(model.Cycle))
+	}else if  model.CycleUnit=="月"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(0,int(model.Cycle),0)
+	}else if  model.CycleUnit=="年"{
+		model.NextCheckDate=model.LastCheckDate.AddDate(int(model.Cycle),0,0)
+	}else{
+		model.NextCheckDate=model.LastCheckDate
+	}
+
 	cols := []string{
 
 		"Id",
@@ -291,6 +323,7 @@ func (this *LimsCheckEquipmentListController) UpdateEntity() {
 		"Status",
 
 		"LastCheckDate",
+		"NextCheckDate",
 
 		"Cycle",
 

+ 101 - 45
src/dashoo.cn/frontend_web/src/pages/lims/checkequipmentlist/index.vue

@@ -6,7 +6,7 @@
     </el-breadcrumb>-->
     <el-row :gutter="5">
       <el-col :span="6">
-        <el-tree style="height: calc(100vh - 243px); overflow: auto;" draggable highlight-current :expand-on-click-node="true" node-key="id" :data="customerTreeList" :props="orgtreeprops"
+        <el-tree style="height: calc(100vh - 75px); overflow: auto;" draggable highlight-current :expand-on-click-node="true" node-key="id" :data="customerTreeList" :props="orgtreeprops"
                  @node-click="orgtreeNodeClick" ref="orgmanagetree">
         </el-tree>
       </el-col>
@@ -16,13 +16,17 @@
             <span>
               <i class="icon icon-table2"></i>
             </span>
-            <span style="float: right;">
-              <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="NewEntity">添加</el-button>
-            </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 label="状态">
+                 <el-select v-model="statusValue" clearable  @change="ProjectTypeChangeHandler" @clear="ProjectTypeClearHandler" placeholder="请选择" size="mini">
+                  <el-option
+                    v-for="item in statusOptions"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value">
+                  </el-option>
+                </el-select>
               </el-form-item>
 
               <el-form-item label="设备分类">
@@ -40,11 +44,14 @@
                   </el-dropdown-menu>
                 </el-dropdown>
               </el-form-item>
+              <el-form-item>
+              <el-button type="primary" size="mini" style="" @click="NewEntity">添加</el-button>
+              </el-form-item> 
             </el-form>
           </div>
-          <el-alert title="提示: 已过期为【红色】, 当月到期为【黄色】" type="warning" :closable="false">
+          <el-alert title="提示: 已过期为【红色】, 一个月内到期为【黄色】,正常为【绿色】" type="warning" :closable="false">
           </el-alert>
-          <el-table :data="entityList" border style="width: 100%" @sort-change="orderby" :row-class-name="tableRowClassName" size="mini">
+          <el-table :height="437" :data="entityList" border style="width: 100%;" @sort-change="orderby" :cell-class-name="tableRowClassName" size="mini">
             <el-table-column label="操作" width="160px" align="center" fixed>
               <template slot-scope="scope">
                 <el-button type="primary" title="编辑" size="small" plain @click="ShowEntityDialog(scope.row.Id)">编辑</el-button>
@@ -52,10 +59,13 @@
               </template>
             </el-table-column>
 
-            <el-table-column v-for="column in tableColumns" :key="column.Id"
-                             v-if="column.prop != 'CreateOn'" :prop="column.prop" sortable min-width="100" :label="column.label" align="center" show-overflow-tooltip></el-table-column>
+             <el-table-column label="状态" width="80px" align="center" >
+              <i class="el-icon-s-opportunity"></i>
+            </el-table-column>
+
+            <el-table-column v-for="column in tableColumns" :key="column.Id" :prop="column.prop" sortable min-width="100" :label="column.label" align="center" show-overflow-tooltip></el-table-column>
 
-            <el-table-column prop="CreateOn" sortable min-width="150" label="上次检测日期" align="center" show-overflow-tooltip>
+            <el-table-column prop="LastCheckDate" sortable min-width="150" label="上次检测日期" align="center" show-overflow-tooltip>
               <template slot-scope="scope">
                 {{ jstimehandle(scope.row.LastCheckDate+'') }}
               </template>
@@ -66,10 +76,19 @@
                 {{ scope.row.Cycle + ' ' + scope.row.CycleUnit }}
               </template>
             </el-table-column>
+
+              <el-table-column prop="NextCheckDate" sortable min-width="150" label="下次检测日期" align="center" show-overflow-tooltip>
+              <template slot-scope="scope">
+                {{ jstimehandle(scope.row.NextCheckDate+'') }}
+              </template>
+            </el-table-column>
+            
           </el-table>
-          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
-                         :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount">
-          </el-pagination>
+          <div class="bottom clearfix">
+            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
+                          :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="currentItemCount">
+            </el-pagination>
+          </div>
         </el-card>
       </el-col>
     </el-row>
@@ -78,14 +97,14 @@
       <el-form ref="advancedsearchForm" label-width="110px">
         <el-row>
 
-          <el-col :span="12">
+          <!-- <el-col :span="12">
             <el-form-item label="生成时间">
               <el-date-picker size="mini" v-model="CreateOn" type="daterange" style="width:100%" range-separator="至"
                               start-placeholder="生成日期" end-placeholder="结束日期"></el-date-picker>
             </el-form-item>
-          </el-col>
+          </el-col> -->
 
-          <el-col :span="12">
+          <!-- <el-col :span="12">
             <el-form-item label="序号">
               <el-input v-model="searchForm.OrderNo" style="width:100%" placeholder="请输入"></el-input>
             </el-form-item>
@@ -95,7 +114,7 @@
             <el-form-item label="编号">
               <el-input size="mini" v-model="searchForm.CustNo" style="width:100%" placeholder="请输入"></el-input>
             </el-form-item>
-          </el-col>
+          </el-col> -->
 
           <el-col :span="12">
             <el-form-item label="检测地点">
@@ -129,18 +148,19 @@
       </span>
     </el-dialog>
 
-    <el-dialog title="编辑" :visible.sync="dialogFormVisible">
+    <el-dialog :title="addoredittitle" :visible.sync="dialogFormVisible">
       <el-form :model="formData" ref="EntityForm">
-        <el-form-item label="序号" :label-width="formLabelWidth">
+        <!-- <el-form-item label="序号" :label-width="formLabelWidth">
           <el-input-number v-model="formData.OrderNo" :min="1" style="width:100%" placeholder="请输入"></el-input-number>
         </el-form-item>
 
-        <el-form-item label="编号" :label-width="formLabelWidth">
-          <el-input v-model="formData.CustNo" style="width:100%" placeholder="请输入"></el-input>
-        </el-form-item>
+      
 
         <el-form-item label="设备名称" :label-width="formLabelWidth">
           <el-input v-model="formData.DeviceName" autocomplete="off"></el-input>
+        </el-form-item> -->
+          <el-form-item label="编号" :label-width="formLabelWidth">
+          <el-input v-model="formData.CustNo" style="width:100%" placeholder="请输入"></el-input>
         </el-form-item>
         <el-form-item label="设备类型" :label-width="formLabelWidth" prop="TemplateTypeId" required>
           <el-select ref="refProjectTypeId" v-model="formData.TemplateTypeId" style="width:100%" filterable placeholder="请选择">
@@ -204,6 +224,18 @@
 
     data () {
       return {
+        statusOptions: [{
+          value: '-2',
+          label: '已过期'
+        }, {
+          value: '-1',
+          label: '一个月内到期'
+        }, {
+          value: '0',
+          label: '正常'
+        }],
+        statusValue: '',
+        addoredittitle: '添加',
         QueryProjectTypeId: '',
         dialogVisible: false,
         dialogFormVisible: false,
@@ -251,19 +283,19 @@
             sort: true
           },
 
-          {
-            prop: 'OrderNo',
-            label: '序号',
-            width: 100,
-            sort: true
-          },
+          // {
+          //   prop: 'OrderNo',
+          //   label: '序号',
+          //   width: 100,
+          //   sort: true
+          // },
 
-          {
-            prop: 'CustNo',
-            label: '编号',
-            width: 100,
-            sort: true
-          },
+          // {
+          //   prop: 'CustNo',
+          //   label: '编号',
+          //   width: 100,
+          //   sort: true
+          // },
 
           {
             prop: 'Spec',
@@ -356,7 +388,7 @@
         this.initDatas()
       },
 
-      tableRowClassName ({row}) {
+      tableRowClassName ({row, column, rowIndex, columnIndex}) {
         let lastDate = new Date(row.LastCheckDate)
         let cycleDate = new Date()
         if (row.CycleUnit === '年') {
@@ -368,12 +400,13 @@
         }
         let curDate = new Date()
         let nearCycleDate = new Date(curDate.getFullYear(), (curDate.getMonth() + 1), curDate.getDate())
-        if (cycleDate <= new Date()) {
+        if (cycleDate < new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && columnIndex === 1) {
           return 'error-row'
-        } else if (cycleDate <= nearCycleDate) {
+        } else if (cycleDate >= new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate()) && cycleDate <= nearCycleDate && columnIndex === 1) {
           return 'warning-row'
+        } else if (cycleDate > nearCycleDate && columnIndex === 1) {
+          return 'normal-row'
         }
-        return ''
       },
 
       CheckCycleDate () {
@@ -395,7 +428,8 @@
           Order: this.Column.Order,
           Prop: this.Column.Prop,
           TemplateTypeId: this.QueryProjectTypeId + '',
-          PositionAllTypeId: this.selectNodeId + ''
+          PositionAllTypeId: this.selectNodeId + '',
+          statusValue: this.statusValue
         }
         let myCreateOn = []
         // 解析时间
@@ -565,6 +599,7 @@
       },
 
       NewEntity () {
+        this.addoredittitle = '添加'
         this.dialogFormVisible = true
         this.PositionList = []
         this.formData.Id = 0
@@ -577,7 +612,7 @@
         this.formData.Position = ''
         this.formData.CustNo = ''
         this.formData.DeviceName = ''
-        this.formData.TemplateTypeId = ''
+        this.formData.TemplateTypeId = this.projectTypeList[0].Id
         this.formData.TemplateTypeName = ''
         this.formData.Spec = ''
         this.formData.SpecId = 0
@@ -597,6 +632,7 @@
         this.formData.PositionID = value[1]
       },
       ShowEntityDialog (entityId) {
+        this.addoredittitle = '编辑'
         this.initEntity(entityId)
         this.dialogFormVisible = true
       },
@@ -620,7 +656,8 @@
           })
           return
         }
-        if (this.PositionList.length <= 0) {
+  
+        if (this.PositionList.length !== 2) {
           this.$message({
             type: 'warning',
             message: '请选择安装位置'
@@ -700,10 +737,29 @@
   }
 
   .el-table .warning-row {
-    background: burlywood;
+    color: yellow;
   }
 
   .el-table .error-row {
-    background: indianred;
+    color: red;
+  }
+
+   .el-table .normal-row {
+    color: green;
+  }
+
+  .bottom {
+    // margin-top: 13px;
+    line-height: 12px;
+  }
+
+  .clearfix:before,
+  .clearfix:after {
+      display: table;
+      content: "";
+  }
+  
+  .clearfix:after {
+      clear: both
   }
 </style>