all 4 роки тому
батько
коміт
a1d14ba2c5

+ 24 - 0
backend/src/dashoo.cn/mms_api/business/actions/actions.go

@@ -34,3 +34,27 @@ type Actions struct {
 	ModifiedBy        string    `xorm:"VARCHAR(50)"`
 	Remark            string    `xorm:"VARCHAR(255)"`
 }
+
+//报警历史
+type Record_History struct {
+	Id                 int
+	ProjectSourse      string
+	ProjectAccount     string
+	ProjectAccountName string
+	SendTo             string
+	ActionType         string
+	Message            string
+	IsRead             int
+	IsSend             int
+	SendErrorMsg       string
+	DeviceId           string
+	DeviceName         string
+	ChannelCode        string
+	ChannelName        string
+	CreateOn           time.Time
+	CreateUserId       int
+	CreateBy           string
+	ModifiedOn         time.Time
+	ModifiedUserId     int
+	ModifiedBy         string
+}

+ 26 - 0
backend/src/dashoo.cn/mms_api/business/equipment/equipment.go

@@ -22,6 +22,7 @@ type Trigger_Abnormal1 struct {
 	CreateOn time.Time `xorm:"DATETIME created"`
 	Serial   string    `xorm:"VARCHAR(500)"`
 	Time     time.Time `field:"time,f"`
+	Online   int       `xorm:"INT(10)"`
 }
 
 type EquipMent struct {
@@ -136,3 +137,28 @@ type Base_UserEquipments struct {
 	Modifieduserid int       `xorm:"INT(11)" form:"-" json:"-"`
 	Modifiedby     string    `xorm:"VARCHAR(50)" form:"-" json:"-"`
 }
+
+//报警历史
+type Record_History struct {
+	Id                 int
+	ProjectSourse      string
+	ProjectAccount     string
+	ProjectAccountName string
+	SendTo             string
+	ActionType         string
+	Message            string
+	IsRead             int
+	IsSend             int
+	SendErrorMsg       string
+	DeviceId           string
+	DeviceName         string
+	ChannelCode        string
+	ChannelName        string
+	CreateOn           time.Time
+	CreateUserId       int
+	CreateBy           string
+	ModifiedOn         time.Time
+	ModifiedUserId     int
+	ModifiedBy         string
+	CausePerson        string
+}

+ 10 - 3
backend/src/dashoo.cn/mms_api/business/equipment/equipmentService.go

@@ -87,7 +87,6 @@ func (s *EquipmentService) GetEquipmentList(pageIndex, itemsPerPage int64, orgid
 			break
 		}
 	}
-	fmt.Println("-----List--ListList2222------", List)
 	return total, List
 }
 
@@ -197,7 +196,6 @@ func (s *EquipmentService) BatchSetState(state, ids string) {
 //权限,根据id获取有权限的设备ids
 func (s *EquipmentService) GetEquipmentidsByUid(userid string) (ids string) {
 	var idmodel Id_Str
-
 	s.DBE.Sql(`select group_concat(EquipmentId) Id FROM Base_UserEquipments where UserId= ` + userid).Get(&idmodel)
 	if idmodel.Id == "" {
 		ids = "-1"
@@ -253,7 +251,7 @@ func (s *EquipmentService) GetEquipMentModelItems(uid string) (items string) {
 
 // 获取设备列表所有数据
 func (s *EquipmentService) GetEquipmentAl111l() []Trigger_Abnormal1 {
-	sql := `select CreateBy,CreateOn,Serial from device where CreateOn < "2018-01-01 16:22:33" `
+	sql := `select CreateBy,CreateOn,Serial from channels where CreateOn > "2018-03-01 00:22:33"  and CreateOn < "2018-06-30 23:22:33"  `
 	List := make([]Trigger_Abnormal1, 0)
 	utils.DBE.Sql(sql).Find(&List)
 	return List
@@ -267,3 +265,12 @@ func GetUserByWx(openid string) (uid int, usermodel Base_User) {
 	svcuser.GetEntityById(uid, &usermodel)
 	return uid, usermodel
 }
+
+// 获取设备列表历史数据
+func (s *EquipmentService) GetRecordHistory(searchstring string) []Record_History {
+	sql := `select * from record_history where ` + searchstring + `
+		order by CreateOn   limit 0,100`
+	List := make([]Record_History, 0)
+	utils.DBE.Sql(sql).Find(&List)
+	return List
+}

+ 29 - 22
backend/src/dashoo.cn/mms_api/controllers/channels.go

@@ -669,13 +669,14 @@ func (this *ChannelsController) ChannelManageview(client labsop.LabSopClient, co
 	queryCommand := ""
 	queryGroupCommand := ""
 
-	startstr := utils.ToStr(start)
-	endstr := utils.ToStr(end)
-	u, p := this.GetuAndp()
+	// startstr := utils.ToStr(start)
+	// endstr := utils.ToStr(end)
+	// u, p := this.GetuAndp()
 	var waringhistory Triggerwaringhistory
-	strUrlwaring := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys/?u=" + u + "&p=" + p + "&source=coldchain&account=" + this.GetAccode() + "&ccode=" + code + "&start=" + startstr + "&end=" + endstr
-	json.Unmarshal(Apiget(strUrlwaring), &waringhistory)
-	fmt.Println("----------------111---------------", strUrlwaring)
+	// strUrlwaring := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys/?u=" + u + "&p=" + p + "&source=coldchain&account=" + this.GetAccode() + "&ccode=" + code + "&start=" + startstr + "&end=" + endstr
+	// json.Unmarshal(Apiget(strUrlwaring), &waringhistory)
+	fmt.Println("----------------111---waringhistory------------", waringhistory)
+	fmt.Println("----------------111---waringhistory------------", dataitem)
 	switch dataitem {
 	case "0", "14", "16": //普通传感器 0:常温 14:外接设备1 16:常温带定位,
 		queryGroupCommand = fmt.Sprintf("select max(temperature),min(temperature),MEAN(temperature),max(humidity),min(humidity),MEAN(humidity) from %v where time > %vs and time < %vs", code, start, end)
@@ -707,22 +708,22 @@ func (this *ChannelsController) ChannelManageview(client labsop.LabSopClient, co
 		} else {
 			queryCommand = fmt.Sprintf("select MEDIAN(temperature) as temperature from %v where time > %vs and time < %vs group by time(%v) fill(none)", code, start, end, level)
 		}
-		for i := 0; i < len(waringhistory.Items); i++ {
-			var arr []float64
-			if waringhistory.Items[i].EventFiled == "temperature" {
-				arr = append(arr, float64(waringhistory.Items[i].AlarmOn.Unix()*1000))
-				arr = append(arr, float64(waringhistory.Items[i].Value))
-				arr = append(arr, -9999)
-				arr = append(arr, -9999)
-				arrvs = append(arrvs, arr)
-			} else if waringhistory.Items[i].EventFiled == "humidity" {
-				arr = append(arr, float64(waringhistory.Items[i].AlarmOn.Unix()*1000))
-				arr = append(arr, -9999)
-				arr = append(arr, float64(waringhistory.Items[i].Value))
-				arr = append(arr, -9999)
-				arrvs = append(arrvs, arr)
-			}
-		}
+		// for i := 0; i < len(waringhistory.Items); i++ {
+		// 	var arr []float64
+		// 	if waringhistory.Items[i].EventFiled == "temperature" {
+		// 		arr = append(arr, float64(waringhistory.Items[i].AlarmOn.Unix()*1000))
+		// 		arr = append(arr, float64(waringhistory.Items[i].Value))
+		// 		arr = append(arr, -9999)
+		// 		arr = append(arr, -9999)
+		// 		arrvs = append(arrvs, arr)
+		// 	} else if waringhistory.Items[i].EventFiled == "humidity" {
+		// 		arr = append(arr, float64(waringhistory.Items[i].AlarmOn.Unix()*1000))
+		// 		arr = append(arr, -9999)
+		// 		arr = append(arr, float64(waringhistory.Items[i].Value))
+		// 		arr = append(arr, -9999)
+		// 		arrvs = append(arrvs, arr)
+		// 	}
+		// }
 	case "7": //氧气
 		queryGroupCommand = fmt.Sprintf("select max(temperature),min(temperature),MEAN(temperature),max(humidity),min(humidity),MEAN(humidity),max(o2),min(o2),MEAN(o2) from %v where time > %vs and time < %vs", code, start, end)
 		if level == "0" {
@@ -1097,6 +1098,7 @@ func (this *ChannelsController) ChannelManageview(client labsop.LabSopClient, co
 					continue
 				}
 				valuef, _ := arrs[x][i].(json.Number).Float64()
+				valuef = Decimal(valuef)
 				if i == 0 {
 					arr = append(arr, valuef*1000)
 				} else {
@@ -1128,6 +1130,11 @@ func (this *ChannelsController) ChannelManageview(client labsop.LabSopClient, co
 	return arrvs, arrgroup
 }
 
+// func Decimal(value float64) float64 {
+// 	value, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", value), 64)
+// 	return value
+// }
+
 // @Title 历史采集数据
 // @Description 历史采集数据
 // @Param	serial		path 	string	true		"设备SN"

+ 2 - 1
backend/src/dashoo.cn/mms_api/controllers/equipment.go

@@ -773,8 +773,9 @@ func (this *EquipmentController) AllListaaaa() {
 	list := svc.GetEquipmentAl111l()
 	for i := 0; i < len(list); i++ {
 		lastdata, _ := GetChannelLast(list[i].Serial)
-		if lastdata.Time.Unix() > int64(1581070653) {
+		if lastdata.Time.Unix() > int64(1609487638) {
 			list[i].Time = lastdata.Time
+			list[i].Online = 1
 			fmt.Println("---list---", list[i].CreateBy, lastdata.Time)
 		}
 	}

+ 34 - 0
backend/src/dashoo.cn/mms_api/controllers/triggerinfos.go

@@ -27,6 +27,12 @@ type triggerhistoryData struct {
 	Items            []triggerhistory.Trigger_History `json:"items"`                      //数据列表
 }
 
+type triggercounthistoryData struct {
+	Status  int    `json:"status"`
+	Id      string `json:"id"`
+	Message string `json:"message"`
+}
+
 type TriggerinfoModel struct {
 	Remark       string    `json:"remark"`
 	AlarmOn      time.Time `json:"alarmon"`      //报警时间
@@ -356,3 +362,31 @@ func (this *TriggerinfosController) SaveXlsx(list []triggerhistory.Trigger_Histo
 	sheet.Cols[8].Width = 25
 	sheet.Cols[9].Width = 25
 }
+
+// @Title 报警历史列表
+// @Description 报警历史列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /countDistinct [get]
+func (this *TriggerinfosController) CountDistinct() {
+	var data triggercounthistoryData
+	var formmodel TriggerFormModel
+	this.ParseForm(&formmodel)
+
+	u, p := this.GetuAndp()
+	strUrl := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys/countDistinct?u=" + u + "&p=" + p + "&source=coldchain&account=" + this.GetAccode() + "&channelcode=c" + formmodel.Sendto
+	// strUrl := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys?u=" + u + "&p=" + p + "&ccode=" + svc.GetCIds(where)
+	strUrl = strUrl + "&start=" + utils.ToStr(formmodel.TimeStart/1000)
+	strUrl = strUrl + "&end=" + utils.ToStr(formmodel.TimeEnd/1000)
+
+	// 新增内容
+	strUrl = strUrl + "&page=1&itemsPerPage=100"
+	fmt.Println("-----strUrl---1111----", strUrl)
+	json.Unmarshal(Apiget(strUrl), &data)
+	fmt.Println("-----strUrl---1111-xx---", data)
+	var datainfo triggercounthistoryData
+	datainfo.Id = data.Id
+	datainfo.Message = data.Message
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}

+ 118 - 0
backend/src/dashoo.cn/mms_api_weixin/controllers/channels.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"strconv"
 	"time"
 
 	"dashoo.cn/mms_api/business/actions"
@@ -643,3 +644,120 @@ func (this *ChannelsController) Getwxconfig() {
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }
+
+// @Title 获取设备所有数据
+// @Description 获取设备所有数据
+// @Success 200 {object} business.device.DeviceChannels
+// @router /alllist [get]
+func (this *ChannelsController) AllList() {
+	svc := equipment.GetEquipmentService(utils.DBE)
+	uid, _ := equipment.GetUserByWx(this.GetString("openid"))
+	userid := strconv.Itoa(uid)
+	eids := svc.GetEquipmentidsByUid(userid)
+
+	where := " (a.CreateUserId = " + userid + " or a.Id in (" + eids + "))"
+
+	list := svc.GetEquipmentAll(userid, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 获取设备所有数据
+// @Description 获取设备所有数据
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getrecordhistory [get]
+func (this *ChannelsController) GetRecordHistory() {
+	page := this.GetPageInfoForm()
+	svcweixin := userweixin.GetUserWeixinService(utils.DBE)
+	uid := svcweixin.GetUserByWeixin(this.GetString("openid"))
+	svc := device.GetDeviceService(utils.DBE)
+
+	svceq := equipment.GetEquipmentService(utils.DBE)
+	eids := svceq.GetEquipmentidsByUid(utils.ToStr(uid))
+	where := " (a.CreateUserId=" + utils.ToStr(uid) + " or a.EquipMentId in (" + eids + ")) and a.DataItem in (" + "31" + ") "
+	_, devices := svc.GetPagingEntitiesWithOrderSearch(page.CurrentPage, page.Size, "c.sortcode, a.CreateOn desc", where, utils.ToStr(uid))
+	seriallist := "-1"
+	for i := 0; i < len(devices); i++ {
+		seriallist = seriallist + "," + devices[i].Serial
+	}
+	CreatOn := this.GetString("creaton")
+	fmt.Println("---CreatOn---", CreatOn)
+	unix := time.Now().Unix()
+	timeLayout := "2006-01-02 15:04:05"
+	timeStr := time.Unix(unix, 0).Format(timeLayout)
+	fmt.Println("---timeStr---", timeStr)
+	fmt.Println("----seriallist----", seriallist)
+	where1 := " 1 = 1 "
+	if CreatOn == "1" {
+		atime := unix - (60 * 60 * 24 * 7)
+		timec := time.Unix(atime, 0).Format(timeLayout)
+		where1 = where1 + "and CreateOn > '" + timec + "' "
+	} else if CreatOn == "2" {
+		atime := unix - (60 * 60 * 24 * 30)
+		timec := time.Unix(atime, 0).Format(timeLayout)
+		where1 = where1 + "and CreateOn >  '" + timec + "' "
+	}
+
+	where1 = where1 + " and  ChannelCode in (" + seriallist + ")"
+	list := svceq.GetRecordHistory(where1)
+	var datainfo DataInfo
+	datainfo.Items = list
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 报警历史列表
+// @Description 报警历史列表
+// @Success 200 {object} business.device.DeviceChannels
+// @router /triggerinforlist [get]
+func (this *ChannelsController) TriggerHistoryList() {
+	uid, usermodel := equipment.GetUserByWx(this.GetString("openid"))
+	fmt.Println("---------1111")
+	page := this.GetPageInfoForm()
+	svc := device.GetDeviceService(utils.DBE)
+
+	// svceq := equipment.GetEquipmentService(utils.DBE)
+	// eids := svceq.GetEquipmentidsByUid(this.User.Id)
+	where := " CreateUserId=" + strconv.Itoa(usermodel.Id) + " or EquipMentId in (" + strconv.Itoa(uid) + ") "
+
+	var data triggerhistoryData
+	var formmodel TriggerFormModel
+	this.ParseForm(&formmodel)
+
+	u, p := this.GetuAndp()
+	strUrl := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys?u=" + u + "&p=" + p + "&source=coldchain&account=" + usermodel.AccCode + "&ccode=" + svc.GetCIds(where)
+	// strUrl := utils.Cfg.MustValue("server", "apiurl") + "/triggerhistorys?u=" + u + "&p=" + p + "&ccode=" + svc.GetCIds(where)
+	// if if CreatOn == "1" {
+
+	// } else if CreatOn == "2"{
+
+	// }
+	strUrl = strUrl + "&start=" + utils.ToStr(formmodel.TimeStart/1000)
+	strUrl = strUrl + "&end=" + utils.ToStr(formmodel.TimeEnd/1000)
+	fmt.Println("----strUrl-----", strUrl)
+	if formmodel.Sendto != "" {
+		strUrl = strUrl + "&sendto=" + formmodel.Sendto
+	}
+	if formmodel.Remark != "" {
+		strUrl = strUrl + "&remark=" + formmodel.Remark
+	}
+	if formmodel.Type != "" && formmodel.Type != "-1" {
+		strUrl = strUrl + "&type=" + formmodel.Type
+	}
+	if formmodel.AbnType != "" && formmodel.AbnType != "-1" {
+		strUrl = strUrl + "&alarmitem=" + formmodel.AbnType
+	}
+
+	// 新增内容
+	strUrl = strUrl + "&page=" + utils.ToStr(page.CurrentPage) + "&itemsPerPage=" + utils.ToStr(page.Size)
+	fmt.Println("----strUrl-----", strUrl)
+	json.Unmarshal(Apiget(strUrl), &data)
+	var datainfo DataInfo
+	datainfo.Items = data.Items
+	datainfo.CurrentItemCount = data.CurrentItemCount
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}

+ 1 - 0
backend/src/dashoo.cn/mms_api_weixin/controllers/token.go

@@ -64,6 +64,7 @@ func (this *TokenController) Posts() {
 // @Failure 403 body is empty
 // @router / [post]
 func (this *TokenController) Post() {
+	fmt.Println("------this.Ctx.Input.RequestBody----", string(this.Ctx.Input.RequestBody))
 	var user4CreateToken models.User4CreateToken
 	json.Unmarshal(this.Ctx.Input.RequestBody, &user4CreateToken)
 	svc := auth.GetAuthServic(utils.DBE)

+ 93 - 0
backend/src/dashoo.cn/mms_api_weixin/controllers/user.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"strings"
 
 	"dashoo.cn/business/userRole"
 	"dashoo.cn/mms_api/business/equipment"
@@ -149,3 +150,95 @@ func (this *UserController) AddUser() {
 	}
 
 }
+
+// @Title 删除用户
+// @Description 删除用户
+// @Param	id		path 	string	true		"需要删除的用户编号"
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /delete/:id [delete]
+func (this *UserController) Delete() {
+	fmt.Println("---123---")
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var entity userRole.Base_User
+	svc := userRole.GetUserService(utils.DBE)
+	err := svc.DeleteEntityById(id, &entity)
+	if err == nil {
+		svc.ClearUserRole(id) //清除角色
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 创建用户
+// @Description 创建用户
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /permission/:id [put]
+func (this *UserController) SetPermission() {
+	id := this.Ctx.Input.Param(":id")
+	uid, _ := utils.StrTo(id).Int()
+	var errinfo ErrorInfo
+	if uid < 1 {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model UserModel
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	svc := equipment.GetEquipmentService(utils.DBE)
+
+	ids := strings.Split(model.ChannelIds, ",")
+	_, currentuser := equipment.GetUserByWx(this.GetString("openid"))
+	svc.ClearUserEquipmentByUid(uid)
+	var ue equipment.Base_UserEquipments
+	ue.UserId = uid
+	ue.AccCode = currentuser.AccCode
+	ue.Createuserid, _ = utils.StrTo(currentuser.Id).Int()
+	ue.Createby = currentuser.Realname
+	for i := 0; i < len(ids); i++ {
+		id, _ := utils.StrTo(ids[i]).Int()
+		if id != 0 {
+			ue.EquipmentId = id
+			svc.InsertEntity(&ue)
+		}
+	}
+
+	errinfo.Message = "权限调整成功"
+	errinfo.Code = 0
+	this.Data["json"] = &errinfo
+	this.ServeJSON()
+
+}
+
+// @Title 创建用户
+// @Description 创建用户
+// @Param	id	path	string	true		"需要修改的传感器编号"
+// @Param	body	body	business.device.DeviceChannels	"传感器信息"
+// @Success	200	{object} controllers.Request
+// @router /permission/:id [get]
+func (this *UserController) GetPermission() {
+	id := this.Ctx.Input.Param(":id")
+	svc := equipment.GetEquipmentService(utils.DBE)
+	this.Data["json"] = strings.Split(svc.GetEquipmentidsByUid(id), ",")
+	this.ServeJSON()
+}

+ 231 - 128
frontend_web/src/components/devices/trigger_dialog.vue

@@ -1,108 +1,211 @@
 <template>
-<div>
-  <el-dialog :title="title" :visible.sync="visible" top="5%">
-    <el-form :model="model" :rules="rules" ref="trigger-form">
-      <el-form-item :label="$t('message.abnormalsetting.Item')" label-width="120px" required>
-        <el-select v-model="model.column" :placeholder="$t('message.users.rolechange')" @change="triggerUiChange">
-          <el-option v-show="contains(havetemp,model.dataitem)" :label="$t('message.chartreport.temperature')" value="temperature"></el-option>
-          <el-option v-show="contains(havehum,model.dataitem)" :label="$t('message.chartreport.humidity')" value="humidity"></el-option>
-           <el-option v-show="contains(co2,model.dataitem)" :label="$t('message.chartreport.co2')" value="co2"></el-option>
-          <el-option v-show="contains(haveo2,model.dataitem)" :label="$t('message.chartreport.o2')" value="o2"></el-option>
-          <el-option v-show="contains(o2,model.dataitem)" :label="$t('message.chartreport.o2')" value="o2"></el-option>
-           <el-option v-show="contains(so2,model.dataitem)" :label="$t('message.chartreport.so2')" value="so2"></el-option>
-          <el-option v-show="contains(windspeed,model.dataitem)" :label="$t('message.management.wind')" value="windspeed"></el-option>
-          <el-option v-show="contains(pressure,model.dataitem)" :label="$t('message.triggerdia.Air')" value="pressure"></el-option>
-          <el-option v-show="contains(clo2,model.dataitem)" :label="$t('message.management.clo2')" value="clo2"></el-option>
-          <el-option v-show="contains(tvoc,model.dataitem)" label="TVOC" value="tvoc"></el-option>
-          <el-option v-show="contains(c2h4,model.dataitem)" :label="$t('message.management.c2h4')" value="c2h4"></el-option>
-           <el-option v-show="contains(c2h2,model.dataitem)" :label="$t('message.management.c2h2')" value="c2h2"></el-option>
-          <el-option v-show="contains(cl2,model.dataitem)" :label="$t('message.management.cl2')" value="cl2"></el-option>
-          <el-option v-show="contains(o3,model.dataitem)" :label="$t('message.management.o3')"  value="o3"></el-option>
-          <el-option v-show="contains(havevol,model.dataitem)" :label="$t('message.index.Voltage')" value="voltage"></el-option>
-          <el-option v-show="contains(havepower,model.dataitem)" :label="$t('message.users.power')" value="electricalpower"></el-option>
-          <el-option v-show="contains(havesupply,model.dataitem)" :label="$t('message.triggerdia.electrical')" value="electricalsupply"></el-option>
-          <el-option v-show="contains(haveliquidlevel,model.dataitem)"  :label="$t('message.triggerdia.level')" value="liquidlevel"></el-option>
-         <el-option v-show="contains(doorlock,model.dataitem)"  label="门禁" value="doorlock"></el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item :label="$t('message.triggerdia.Triggering')" label-width="120px" required prop="value">
-        <el-select v-model="model.item" placeholder="$t('message.users.rolechange')" :disabled="model.disabletriggeritem">
-          <el-option label=">" value="1"></el-option>
-          <el-option label="≥" value="2"></el-option>
-          <el-option label="<" value="3"></el-option>
-          <el-option label="≤" value="4"></el-option>
-          <el-option label="=" value="5"></el-option>
-        </el-select>
-        <el-input v-model="model.value" auto-complete="off" style="width:150px;" :disabled="model.disabletriggervalue"></el-input>
-      </el-form-item>
-      <el-form-item :label="$t('message.abnormalsetting.Item')" label-width="120px" prop="aid" required>
-        <el-select v-model="model.aid" :placeholder="$t('message.abnormalsetting.an')" multiple>
-          <el-option v-for="item in actions" :label="item.name" :value="item.Wdid">
-            <el-tag type="gray" v-if="item.item === 1">{{ $t('message.actions.e-mail') }}</el-tag>
-            <el-tag type="warning" v-if="item.item === 2">{{ $t('message.actions.URL') }}</el-tag>
-            <el-tag type="danger" v-if="item.item === 4">{{ $t('message.actions.Alarm') }}</el-tag>
-            <el-tag type="primary" v-if="item.item === 5">{{ $t('message.actions.SMS') }}</el-tag>
-            <el-tag type="success" v-if="item.item === 6">{{ $t('message.actions.voice') }}</el-tag>
-            <el-tag type="success" v-if="item.item === 7">{{ $t('message.actions.WeChat') }}</el-tag>
-            <el-tag type="success" v-if="item.item === 8">{{ $t('message.actions.Web') }}</el-tag>
-            <span>{{ item.name }}</span>
-          </el-option>
-        </el-select>
-       {{ $t('message.triggerdia.allowable') }}
-        <router-link to="/actions">
-      {{ $t('message.abnormalsetting.Item') }}
-        </router-link>
-       {{ $t('message.abnormalsetting.Management') }}
-      </el-form-item>
-      <el-form-item :label="$t('message.triggerdia.Alarm')" prop="count" required label-width="120px" style="margin-top:-5px;">
-        <el-radio-group v-model="model.etype">
-          <el-radio class="radio" label="1"> {{ $t('message.equipment.No') }}</el-radio>
-          <el-radio class="radio" label="2">
-          {{ $t('message.equipment.abnormality') }}
-            <el-input size="mini" style="width:50px" v-model="model.count"></el-input>
-            {{ $t('message.triggerdia.Number') }}
-          </el-radio>
-          <el-radio class="radio" label="3">{{ $t('message.triggerdia.first')}}</el-radio>
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item :label="$t('message.abnormalsetting.Alarm')" label-width="120px" required prop="rangeweek" style="margin-top:-10px;">
-        <el-checkbox-group v-model="model.rangeweek">
-          <el-checkbox label="1">{{ $t('message.triggerdia.Monday')}}</el-checkbox>
-          <el-checkbox label="2">{{ $t('message.triggerdia.Tuesday')}}</el-checkbox>
-          <el-checkbox label="3">{{ $t('message.triggerdia.Wednesday')}}</el-checkbox>
-          <el-checkbox label="4">{{ $t('message.triggerdia.Thursday')}}</el-checkbox>
-          <el-checkbox label="5">{{ $t('message.triggerdia.Friday')}}</el-checkbox>
-          <el-checkbox label="6">{{ $t('message.triggerdia.Saturday')}}</el-checkbox>
-          <el-checkbox label="7">{{ $t('message.triggerdia.Sunday')}}</el-checkbox>
-        </el-checkbox-group>
-        <el-row :gutter="15">
-          <el-col :span="16">
-            <el-slider v-model="model.rangetime" range show-stops :max="96" :format-tooltip="formatTooltip">
-            </el-slider>
-          </el-col>
-          <el-col :span="8">
-            <div style="color:#F6931F">{{gettimelab(model.rangetime[0])}} - {{gettimelab(model.rangetime[1])}}</div>
-          </el-col>
-        </el-row>
+  <div>
+    <el-dialog :title="title"
+               :visible.sync="visible"
+               top="5%">
+      <el-form :model="model"
+               :rules="rules"
+               ref="trigger-form">
+        <el-form-item :label="$t('message.abnormalsetting.Item')"
+                      label-width="120px"
+                      required>
+          <el-select v-model="model.column"
+                     :placeholder="$t('message.users.rolechange')"
+                     @change="triggerUiChange">
+            <el-option v-show="contains(havetemp,model.dataitem)"
+                       :label="$t('message.chartreport.temperature')"
+                       value="temperature"></el-option>
+            <el-option v-show="contains(havehum,model.dataitem)"
+                       :label="$t('message.chartreport.humidity')"
+                       value="humidity"></el-option>
+            <el-option v-show="contains(co2,model.dataitem)"
+                       :label="$t('message.chartreport.co2')"
+                       value="co2"></el-option>
+            <el-option v-show="contains(haveo2,model.dataitem)"
+                       :label="$t('message.chartreport.o2')"
+                       value="o2"></el-option>
+            <el-option v-show="contains(o2,model.dataitem)"
+                       :label="$t('message.chartreport.o2')"
+                       value="o2"></el-option>
+            <el-option v-show="contains(so2,model.dataitem)"
+                       :label="$t('message.chartreport.so2')"
+                       value="so2"></el-option>
+            <el-option v-show="contains(windspeed,model.dataitem)"
+                       :label="$t('message.management.wind')"
+                       value="windspeed"></el-option>
+            <el-option v-show="contains(pressure,model.dataitem)"
+                       :label="$t('message.triggerdia.Air')"
+                       value="pressure"></el-option>
+            <el-option v-show="contains(clo2,model.dataitem)"
+                       :label="$t('message.management.clo2')"
+                       value="clo2"></el-option>
+            <el-option v-show="contains(tvoc,model.dataitem)"
+                       label="TVOC"
+                       value="tvoc"></el-option>
+            <el-option v-show="contains(c2h4,model.dataitem)"
+                       :label="$t('message.management.c2h4')"
+                       value="c2h4"></el-option>
+            <el-option v-show="contains(c2h2,model.dataitem)"
+                       :label="$t('message.management.c2h2')"
+                       value="c2h2"></el-option>
+            <el-option v-show="contains(cl2,model.dataitem)"
+                       :label="$t('message.management.cl2')"
+                       value="cl2"></el-option>
+            <el-option v-show="contains(o3,model.dataitem)"
+                       :label="$t('message.management.o3')"
+                       value="o3"></el-option>
+            <el-option v-show="contains(havevol,model.dataitem)"
+                       :label="$t('message.index.Voltage')"
+                       value="voltage"></el-option>
+            <el-option v-show="contains(havepower,model.dataitem)"
+                       :label="$t('message.users.power')"
+                       value="electricalpower"></el-option>
+            <el-option v-show="contains(havesupply,model.dataitem)"
+                       :label="$t('message.triggerdia.electrical')"
+                       value="electricalsupply"></el-option>
+            <el-option v-show="contains(haveliquidlevel,model.dataitem)"
+                       :label="$t('message.triggerdia.level')"
+                       value="liquidlevel"></el-option>
+            <el-option v-show="contains(doorlock,model.dataitem)"
+                       label="门禁"
+                       value="doorlock"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item :label="$t('message.triggerdia.Triggering')"
+                      label-width="120px"
+                      required
+                      prop="value">
+          <el-select v-model="model.item"
+                     placeholder="$t('message.users.rolechange')"
+                     :disabled="model.disabletriggeritem">
+            <el-option label=">"
+                       value="1"></el-option>
+            <el-option label="≥"
+                       value="2"></el-option>
+            <el-option label="<"
+                       value="3"></el-option>
+            <el-option label="≤"
+                       value="4"></el-option>
+            <el-option label="="
+                       value="5"></el-option>
+          </el-select>
+          <el-input v-model="model.value"
+                    auto-complete="off"
+                    style="width:150px;"
+                    :disabled="model.disabletriggervalue"></el-input>
+        </el-form-item>
+        <el-form-item :label="$t('message.abnormalsetting.Item')"
+                      label-width="120px"
+                      prop="aid"
+                      required>
+          <el-select v-model="model.aid"
+                     :placeholder="$t('message.abnormalsetting.an')"
+                     multiple>
+            <el-option v-for="item in actions"
+                       :label="item.name"
+                       :value="item.Wdid">
+              <el-tag type="gray"
+                      v-if="item.item === 1">{{ $t('message.actions.e-mail') }}</el-tag>
+              <el-tag type="warning"
+                      v-if="item.item === 2">{{ $t('message.actions.URL') }}</el-tag>
+              <el-tag type="danger"
+                      v-if="item.item === 4">{{ $t('message.actions.Alarm') }}</el-tag>
+              <el-tag type="primary"
+                      v-if="item.item === 5">{{ $t('message.actions.SMS') }}</el-tag>
+              <el-tag type="success"
+                      v-if="item.item === 6">{{ $t('message.actions.voice') }}</el-tag>
+              <el-tag type="success"
+                      v-if="item.item === 7">{{ $t('message.actions.WeChat') }}</el-tag>
+              <el-tag type="success"
+                      v-if="item.item === 8">{{ $t('message.actions.Web') }}</el-tag>
+              <span>{{ item.name }}</span>
+            </el-option>
+          </el-select>
+          {{ $t('message.triggerdia.allowable') }}
+          <router-link to="/actions">
+            {{ $t('message.abnormalsetting.Item') }}
+          </router-link>
+          {{ $t('message.abnormalsetting.Management') }}
+        </el-form-item>
+        <el-form-item :label="$t('message.triggerdia.Alarm')"
+                      prop="count"
+                      required
+                      label-width="120px"
+                      style="margin-top:-5px;">
+          <el-radio-group v-model="model.etype">
+            <el-radio class="radio"
+                      label="1"> {{ $t('message.equipment.No') }}</el-radio>
+            <el-radio class="radio"
+                      label="2">
+              {{ $t('message.equipment.abnormality') }}
+              <el-input size="mini"
+                        style="width:50px"
+                        v-model="model.count"></el-input>
+              {{ $t('message.triggerdia.Number') }}
+            </el-radio>
+            <el-radio class="radio"
+                      label="3">{{ $t('message.triggerdia.first')}}</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item :label="$t('message.abnormalsetting.Alarm')"
+                      label-width="120px"
+                      required
+                      prop="rangeweek"
+                      style="margin-top:-10px;">
+          <el-checkbox-group v-model="model.rangeweek">
+            <el-checkbox label="1">{{ $t('message.triggerdia.Monday')}}</el-checkbox>
+            <el-checkbox label="2">{{ $t('message.triggerdia.Tuesday')}}</el-checkbox>
+            <el-checkbox label="3">{{ $t('message.triggerdia.Wednesday')}}</el-checkbox>
+            <el-checkbox label="4">{{ $t('message.triggerdia.Thursday')}}</el-checkbox>
+            <el-checkbox label="5">{{ $t('message.triggerdia.Friday')}}</el-checkbox>
+            <el-checkbox label="6">{{ $t('message.triggerdia.Saturday')}}</el-checkbox>
+            <el-checkbox label="7">{{ $t('message.triggerdia.Sunday')}}</el-checkbox>
+          </el-checkbox-group>
+          <el-row :gutter="15">
+            <el-col :span="16">
+              <el-slider v-model="model.rangetime"
+                         range
+                         show-stops
+                         :max="96"
+                         :format-tooltip="formatTooltip">
+              </el-slider>
+            </el-col>
+            <el-col :span="8">
+              <div style="color:#F6931F">{{gettimelab(model.rangetime[0])}} - {{gettimelab(model.rangetime[1])}}</div>
+            </el-col>
+          </el-row>
 
-      </el-form-item>
-      <el-form-item :label="$t('message.triggerdia.Alarma')" label-width="120px" required style="margin-top:-5px;">
-        <el-radio-group v-model="model.enabled">
-          <el-radio class="radio" label="1">{{ $t('message.equipment.Enable')}}</el-radio>
-          <el-radio class="radio" label="0">{{ $t('message.channeldia.Disable')}}</el-radio>
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item :label="$t('message.triggerdia.Message')" label-width="120px" prop="content" required>
-        <el-input type="textarea" v-model="model.content" auto-complete="off"></el-input>
-        {{$t('message.triggerdia.MESS')}}
-      </el-form-item>
-    </el-form>
-    <div slot="footer" class="dialog-footer" style="margin-top:-50px;">
-      <el-button @click="selfVisible = false">{{ $t('message.cancel') }}</el-button>
-      <el-button type="primary" @click="handleOk">{{ $t('message.confirm') }}</el-button>
-    </div>
-  </el-dialog>
-</div>
+        </el-form-item>
+        <el-form-item :label="$t('message.triggerdia.Alarma')"
+                      label-width="120px"
+                      required
+                      style="margin-top:-5px;">
+          <el-radio-group v-model="model.enabled">
+            <el-radio class="radio"
+                      label="1">{{ $t('message.equipment.Enable')}}</el-radio>
+            <el-radio class="radio"
+                      label="0">{{ $t('message.channeldia.Disable')}}</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item :label="$t('message.triggerdia.Message')"
+                      label-width="120px"
+                      prop="content"
+                      required>
+          <el-input type="textarea"
+                    v-model="model.content"
+                    auto-complete="off"></el-input>
+          {{$t('message.triggerdia.MESS')}}
+        </el-form-item>
+      </el-form>
+      <div slot="footer"
+           class="dialog-footer"
+           style="margin-top:-50px;">
+        <el-button @click="selfVisible = false">{{ $t('message.cancel') }}</el-button>
+        <el-button type="primary"
+                   @click="handleOk">{{ $t('message.confirm') }}</el-button>
+      </div>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
@@ -126,7 +229,7 @@ export default {
       // visible: 'dialogVisible',
       model: 'triggerModel'
     }),
-    title() {
+    title () {
       if (this.act === 'new') {
         return this.$t('message.triggerinfos.settings') + `(${this.model.title})`
       } else {
@@ -135,14 +238,14 @@ export default {
     }
   },
   watch: {
-    visible(val) {
+    visible (val) {
       this.selfVisible = val
     },
-    selfVisible(val) {
+    selfVisible (val) {
       this.$emit('update:visible', val)
     }
   },
-  data() {
+  data () {
     var checkTriggerCount = (rule, value, callback) => {
       if (this.model.etype === '2') {
         if (!value) {
@@ -175,8 +278,8 @@ export default {
         serial: this.$store.state.devices.triggerDeviceModel.serial
       }
       this.$services.channel.get('validalert', {
-          params
-        })
+        params
+      })
         .then(res => {
           if (res.data.code === 0) {
             callback()
@@ -199,15 +302,15 @@ export default {
       c2h4: '21',
       tvoc: '24',
       c2h2: '25',
-       co2: '26',
-       so2: '28',
+      co2: '26',
+      so2: '28',
       cl2: '22',
       o3: '23',
       havepower: '13',
       havesupply: '13',
       havevol: '0,6,7,9,10,16',
       haveliquidlevel: '15',
-       doorlock: '31',
+      doorlock: '31',
       rules: {
         value: [{
           required: true,
@@ -244,11 +347,11 @@ export default {
       }
     }
   },
-  created() {
+  created () {
     this.getactions()
   },
   methods: {
-    handleOk() {
+    handleOk () {
       let _this = this
       this.$refs['trigger-form'].validate((valid) => {
         if (valid) {
@@ -284,8 +387,8 @@ export default {
                     message: res.data.message
                   })
                   _this.selfVisible = false
-                    // 更新界面
-                    // _this.opentriggerlist()
+                  // 更新界面
+                  // _this.opentriggerlist()
                   _this.$emit('close', 'edit')
                 } else {
                   _this.$message({
@@ -294,21 +397,21 @@ export default {
                   })
                 }
               })
-              .catch(() => {})
+              .catch(() => { })
           }
         } else {
           return false
         }
       })
     },
-    contains(strs, str) {
+    contains (strs, str) {
       let arrs = strs.split(',')
       for (let v in arrs) {
         if (arrs[v] === (str + '')) return true
       }
       return false
     },
-    gettimelab(i) {
+    gettimelab (i) {
       let daytag = ''
       if (i > 48) {
         i = i - 48
@@ -328,23 +431,23 @@ export default {
         return (daytag + tstr + ':30:00')
       }
     },
-    formatTooltip(val) {
+    formatTooltip (val) {
       return this.gettimelab(val)
     },
-    getactions() {
+    getactions () {
       const params = {
-          _currentPage: -1
-        }
-        // request
+        _currentPage: -1
+      }
+      // request
       this.$services.action.get('list', {
-          params
-        })
+        params
+      })
         .then(res => {
           this.actions = res.data.items
         })
-        .catch(() => {})
+        .catch(() => { })
     },
-    triggerUiChange(val) {
+    triggerUiChange (val) {
       this.model.disabletriggeritem = false
       this.model.disabletriggervalue = false
       if (val === 'temperature') {

+ 6 - 0
frontend_web/src/libraries/router/main-routes.js

@@ -45,6 +45,12 @@ export default [
     meta: { requiresAuth: true },
     component: resolve => require.ensure([], () => resolve(require('views/main/devicechart')), 'deviceschart')
   },
+  {
+    name: 'channelschart',
+    path: 'channels/chart/:serial',
+    meta: { requiresAuth: true },
+    component: resolve => require.ensure([], () => resolve(require('views/main/channelschart')), 'channelschart')
+  },
   {
     name: 'devicesgps',
     path: 'devices/gps/:serial',

+ 2 - 2
frontend_web/src/libraries/utils/axios.js

@@ -13,8 +13,8 @@ import axios from 'axios'
 
 const instance = axios.create({
   // // TODO: full base url
-       baseURL: '//localhost:8081/api/', // 本地测试
-        // baseURL: '//47.92.238.200:8081/api/', // labsop 发布
+      //  baseURL: '//localhost:8081/api/', // 本地测试
+        baseURL: '//47.92.238.200:8081/api/', // labsop 发布
         // baseURL: '//47.105.138.102:8081/api/', // xiaowei 发布
     // baseURL: '//47.92.238.200:8081/api/', // labsop 老服务器发布
   // baseURL: '//47.92.238.200:18015/api/', // 369yun 发布

+ 639 - 0
frontend_web/src/views/main/channelschart.vue

@@ -0,0 +1,639 @@
+<template>
+  <div>
+    <div style="margin-bottom:10px;">
+      <el-row>
+        <el-col :span="20">
+          <div>
+            {{ $t('message.devicechart.Time') }}:
+            <el-date-picker v-model="timerange"
+                            type="datetimerange"
+                            clearable
+                            :placeholder="$t('message.devicechart.choose')">
+            </el-date-picker>
+          </div>
+        </el-col>
+        <el-col :span="4"
+                style="padding-top:3px;">
+          <el-button type="primary"
+                     size="small"
+                     icon="search"
+                     @click="seachdata">{{ $t('message.search') }}</el-button>
+          <el-button type="primary"
+                     size="small"
+                     @click="printdata"
+                     style="margin-left:0px;">
+            <i class="icon icon-printer"></i>{{ $t('message.chartreport.print')}}
+          </el-button>
+        </el-col>
+      </el-row>
+    </div>
+    <div id="table"
+         style="width:800px">
+      <div id="header">
+        <div style="text-align:center;">
+          <!-- <tr>
+            <th rowspan="2"> <img src="../../assets/images/deviceschart.jpeg"
+                   style="width:80px;" /></th>
+          </tr> -->
+          <p style="font-size:32px">数据报表</p>
+          <p>时间范围:{{renderTime(timerange[0])}}-{{renderTime(timerange[1])}} </p>
+          <p>签字:__________ &nbsp; &nbsp;日期:__________</p>
+          <!-- <p>{{this.jstimehandle(timerange[0])}}</p> -->
+        </div>
+      </div>
+
+      <h2>设备信息</h2>
+      <hr />
+      <table style="border-spacing: 10px;  padding-top:5px;">
+        <tr>
+          <th style="width:100px">设备ID</th>
+          <td style="width:180px">{{serial}}</td>
+          <th style="width:100px">传感器名称</th>
+          <td style="width:180px">{{this.$route.query.xn}}</td>
+          <th style="width:100px">设备名称</th>
+          <td style="width:180px">{{this.$route.query.code}}</td>
+        </tr>
+        <tr style="padding-top:5px;">
+          <th style="width:100px">校准证书:</th>
+          <td style="width:180px">{{certificate}}</td>
+          <th style="width:100px">设备类型</th>
+          <td style="width:180px">{{devicestype}}</td>
+          <th style="width:100px"></th>
+          <td style="width:180px"></td>
+        </tr>
+      </table>
+      <h2>数据摘要</h2>
+      <hr />
+      <table style="border-spacing: 10px;  padding-top:5px;">
+        <tr>
+          <th style="width:100px">最高温度</th>
+          <td style="width:180px">{{maxnum}}℃</td>
+          <th style="width:100px">最低温度</th>
+          <td style="width:180px">{{minnum}}℃</td>
+          <th style="width:100px">平均温度</th>
+          <td style="width:180px">{{averagevalue}}℃</td>
+        </tr>
+      </table>
+
+      <h2>报警信息</h2>
+      <hr />
+      <table style="border-spacing: 10px;  padding:5px 0px 5px 0px;">
+        <tr>
+          <th style="width:100px">报警参数</th>
+          <td style="width:180px">{{alarm}}</td>
+          <th style="width:100px">报警数量</th>
+          <td style="width:180px">{{triggercount}}</td>
+        </tr>
+      </table>
+      <h2>曲线报表</h2>
+      <hr />
+    </div>
+    <div id="content">
+      <div style="text-align:center;margin-bottom:15px;font-size: 14px;color: #636363;margin-top:25px;width:800px">
+        {{titel}} {{ $t('message.devicechart.Latest') }}: {{lastdata}}
+      </div>
+      <time-line-chart :series="seriesData"
+                       ref="historychart"
+                       style="height:400px;width:800px"></time-line-chart>
+    </div>
+
+    <div id="data"
+         style="padding-top:5px;width:800px;">
+      <h2>详细数据</h2>
+      <hr />
+      <div v-for="n in 5"
+           class="col"
+           style="width:20%;float:left;border:0px #000;font-size:12px;">
+        <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+          时间:
+        </div>
+        <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+          温度
+        </div>
+        <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+          湿度
+        </div>
+      </div>
+
+      <div v-for="(v, index) in list2"
+           style="font-size:5px"
+           :key="index">
+        <div class="col"
+             style="width:20%;float:left;border:0px #000;font-size:1px">
+          <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.rowid}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.stid}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.name}}
+          </div>
+        </div>
+        <div class="col"
+             style="width:20%;float:left;border:0px #000;font-size:1px">
+          <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.rowid1}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.stid1}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.name1}}
+          </div>
+        </div>
+        <div class="col"
+             style="width:20%;float:left;border:0px #000;font-size:1px">
+          <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.rowid2}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.stid2}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.name2}}
+          </div>
+        </div>
+        <div class="col"
+             style="width:20%;float:left;border:0px #000;font-size:1px">
+          <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.rowid3}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.stid3}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.name3}}
+          </div>
+        </div>
+        <div class="col"
+             style="width:20%;float:left;border:0px #000;font-size:1px">
+          <div style="width:59%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.rowid4}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.stid4}}
+          </div>
+          <div style="width:20%;float:left;border:0px #000;white-space: nowrap;transform:scale(0.8)">
+            {{v.name4}}
+          </div>
+        </div>
+
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import TimeLineChart from '../../components/timelinechart.vue'
+export default {
+  name: 'triggerinfos',
+  components: {
+    TimeLineChart
+  },
+  data () {
+    return {
+      serial: '',
+      dataitem: '0',
+      timerange: [new Date(new Date() - 3600 * 1000 * 24), new Date()],
+      seriesData: [],
+      items1: '0,14,16',
+      triggercount: '',
+      items2: '6,10',
+      itemo2: '7',
+      itemco2: '9',
+      itemswindspeed: '18',
+      itemspressure: '19',
+      itemsclo2: '20',
+      itemsc2h4: '21',
+      itemsco2: '26',
+      itemsc2h2: '25',
+      itemsctvoc: '24',
+      itemscl2: '22',
+      itemso3: '23',
+      itempower: '13',
+      itemliquidLevel: '15',
+      itemo2_17: '17',
+      lastdata: '--',
+      titel: '',
+      certificate: '',
+      devicestype: '',
+      list: [],
+      list2: [],
+      TemperatureArr: [],
+      maxnum: 0,
+      minnum: 0,
+      averagevalue: 0,
+      alarm: ''
+    }
+  },
+
+  created () {
+    let paramarr = this.$route.params.serial.split('_')
+    if (paramarr.length === 2) {
+      this.serial = paramarr[0]
+      this.dataitem = paramarr[1]
+      if (this.dataitem === '0') {
+        this.devicestype = 'GT-TH'
+      } else if (this.dataitem === '6') {
+        this.devicestype = 'GT-T'
+      } else {
+        this.devicestype = '其他传感器'
+      }
+      if (this.contains(this.items1, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.equipment.Temperature'),
+          unit: '℃'
+        }, {
+          name: this.$t('message.equipment.Humidity'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.items2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.equipment.Temperature'),
+          unit: '℃'
+        }]
+      } else if (this.contains(this.itemo2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.equipment.Temperature'),
+          unit: '℃'
+        }, {
+          name: this.$t('message.equipment.Humidity'),
+          unit: '%'
+        }, {
+          name: this.$t('message.devicechart.oxygen'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemco2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.equipment.Temperature'),
+          unit: '℃'
+        }, {
+          name: this.$t('message.equipment.Humidity'),
+          unit: '%'
+        }, {
+          name: this.$t('message.devicechart.Carbon'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itempower, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.management.Sensor'),
+          unit: 'W'
+        }]
+      } else if (this.contains(this.itemliquidLevel, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.equipment.Temperature'),
+          unit: '℃'
+        }, {
+          name: this.$t('message.triggerdia.level'),
+          unit: 'mm'
+        }]
+      } else if (this.contains(this.itemo2_17, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.oxygen'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemswindspeed, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.Wind'),
+          unit: 'm/s'
+        }]
+      } else if (this.contains(this.itemspressure, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.Air'),
+          unit: 'hpa'
+        }]
+      } else if (this.contains(this.itemsclo2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.Chlorine'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemsc2h4, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.ethylene'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemsc2h2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.acetylene'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemsco2, this.dataitem)) {
+        this.seriesData = [{
+          name: '二氧化碳',
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemsctvoc, this.dataitem)) {
+        this.seriesData = [{
+          name: 'TVOC',
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemscl2, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.chlorine'),
+          unit: '%'
+        }]
+      } else if (this.contains(this.itemso3, this.dataitem)) {
+        this.seriesData = [{
+          name: this.$t('message.devicechart.ozone'),
+          unit: '%'
+        }]
+      }
+      this.$services.channel.get('datavalue/' + this.serial, null)
+        .then(res => {
+          if (this.contains(this.items1, this.dataitem)) {
+            this.a = this.$t('message.equipment.Temperature')
+            this.b = this.$t('message.equipment.Humidity')
+            this.lastdata = this.a + `【${res.data.Temp} ℃ 】` + this.b + ` ${res.data.Hum} ` + ` % 】 `
+            // this.lastdata = `温度 【${res.data.Temp} ℃ 】 湿度  ${res.data.Hum} % 】`
+          } else if (this.contains(this.items2, this.dataitem)) {
+            this.a = this.$t('message.equipment.Temperature')
+            this.lastdata = this.a + `【${res.data.Temp} ℃ 】`
+            // this.lastdata = `温度 【${res.data.Temp} ℃ 】`
+          } else if (this.contains(this.itemo2, this.dataitem)) {
+            this.a = this.$t('message.equipment.Temperature')
+            this.lastdata = this.a + `【${res.data.Temp} ℃ 】` + this.b + ` ${res.data.Hum} ` + ` % 】 O2  【 ` + ` ${res.data.O2} %` + ` % `
+            // this.lastdata = `温度 【${res.data.Temp} ℃ 】 湿度  【${res.data.Hum} % 】  O2  【${res.data.O2} % 】`
+          } else if (this.contains(this.itemco2, this.dataitem)) {
+            this.a = this.$t('message.equipment.Temperature')
+            this.lastdata = this.a + `【${res.data.Temp} ℃ 】` + this.b + `【${res.data.Hum} % 】` + `CO2 ` + `【${res.data.Co2} % 】`
+            // this.lastdata = `温度 【${res.data.Temp} ℃ 】 湿度  【${res.data.Hum} % 】  CO2  【${res.data.Co2} % 】`
+          } else if (this.contains(this.itempower, this.dataitem)) {
+            this.c = this.$t('message.management.power')
+            this.d = this.$t('message.index.Voltage')
+            this.lastdata = this.c + `【${res.data.Power} W 】` + this.d + `【${res.data.Supply} V 】`
+            // this.lastdata = `功率 【${res.data.Power} ℃ 】 电量  【${res.data.Supply} % 】`
+          } else if (this.contains(this.itemliquidLevel, this.dataitem)) {
+            this.a = this.$t('message.equipment.Temperature')
+            this.e = this.$t('message.management.level')
+            this.lastdata = this.a + `【${res.data.Temp} ℃ 】` + this.e + `【${res.data.LiquidLevel} mm 】`
+            // this.lastdata = `温度 【${res.data.Temp} ℃ 】 液位  【${res.data.LiquidLevel} mm 】`
+          } else if (this.contains(this.itemo2_17, this.dataitem)) {
+            this.lastdata = `O2  【${res.data.O2} % 】`
+          } else if (this.contains(this.itemswindspeed, this.dataitem)) {
+            this.f = this.$t('message.devicechart.Wind')
+            this.lastdata = this.f + `【${res.data.WindSpeed} m/s 】`
+            // this.lastdata = `风速  【${res.data.WindSpeed} m/s 】`
+          } else if (this.contains(this.itemspressure, this.dataitem)) {
+            this.g = this.$t('message.triggerdia.Air')
+            this.lastdata = this.g + `【${res.data.Pressure} hpa 】`
+            // this.lastdata = `气压  【${res.data.Pressure} hpa 】`
+          } else if (this.contains(this.itemsclo2, this.dataitem)) {
+            this.lastdata = `ClO2  【${res.data.ClO2} % 】`
+          } else if (this.contains(this.itemsc2h4, this.dataitem)) {
+            this.lastdata = `C2H4  【${res.data.C2H4} % 】`
+          } else if (this.contains(this.itemsc2h2, this.dataitem)) {
+            this.lastdata = `乙炔  【${res.data.C2H2} % 】`
+          } else if (this.contains(this.itemsco2, this.dataitem)) {
+            this.lastdata = `二氧化碳  【${res.data.Co2} % 】`
+          } else if (this.contains(this.itemsctvoc, this.dataitem)) {
+            this.lastdata = `TVOC  【${res.data.TVOC} % 】`
+          } else if (this.contains(this.itemscl2, this.dataitem)) {
+            this.lastdata = `Cl2  【${res.data.Cl2} % 】`
+          } else if (this.contains(this.itemso3, this.dataitem)) {
+            this.lastdata = `O3  【${res.data.O3} % 】`
+          }
+          this.timerange = [new Date(new Date(res.data.Time) - 3600 * 1000 * 24), new Date(res.data.Time)]
+          this.initData()
+          this.opentriggerlist()
+        })
+    }
+    this.countDistinct()
+    this.titel = this.$route.query.xn + '(' + this.serial + ') '
+    this.certificate = this.$route.query.certificate
+    if (this.$route.query.certificate === 'undefined') {
+      this.certificate = ''
+    }
+  },
+  methods: {
+    countDistinct () {
+      // let _this = this
+      // paginate
+      const params = {
+        _currentPage: this.currentPage,
+        _size: this.size,
+        timestart: this.timerange[0].getTime(),
+        timeend: this.timerange[1].getTime(),
+        sendto: this.serial
+      }
+      // Object.assign(params, this.seachform)
+      // request
+      this.$services.triggerinfo.get('countDistinct', {
+        params
+      })
+        .then(res => {
+          // response
+          // _this.list = res.data.items
+          this.triggercount = res.data.message
+          // _this.currentItemCount = res.data.currentItemCount
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    opentriggerlist () {
+      // this.triggerlistdialogtitle = `报警设置列表(${this.triggerform.title})`
+      this.$services.trigger.get('list/' + this.serial, null)
+        .then(res => {
+          // response
+          this.alarm = ''
+          let list = res.data.items
+          for (var i = 0; i < list.length; i++) {
+            this.alarm = this.alarm + list[i].Trigger.itemname + list[i].Trigger.value + '℃,'
+          }
+          this.alarm = this.alarm.substring(0, this.alarm.length - 1)
+          // this.triggerlist = res.data.items
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+          this.loading = false
+        })
+    },
+    formatDate (value) {
+      let date = new Date(value)
+      let y = date.getFullYear()
+      y = y - 2000
+      let MM = date.getMonth() + 1
+      MM = MM < 10 ? ('0' + MM) : MM
+      let d = date.getDate()
+      d = d < 10 ? ('0' + d) : d
+      let h = date.getHours()
+      h = h < 10 ? ('0' + h) : h
+      let m = date.getMinutes()
+      m = m < 10 ? ('0' + m) : m
+      let s = date.getSeconds()
+      s = s < 10 ? ('0' + s) : s
+      return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
+    },
+    initData () {
+      // request
+      let params = {
+        _start: this.timerange[0].getTime(),
+        _end: this.timerange[1].getTime(),
+        _dataitem: this.dataitem
+      }
+      this.$services.channel.get('historydatavalue/' + this.serial, {
+        params
+      })
+        .then(res => {
+          this.list = res.data.Value
+          // response
+          var row = []
+          this.list2 = []
+          var split = parseInt(this.list.length / 5)
+          if (this.list.length % 5 > 0) {
+            split++
+          }
+          console.log('----split-----', split)
+          for (var j = 0; j < split - 1; j++) {
+            var sturow = {}
+            for (var x = 0; x < 5; x++) {
+              var index = x * split + j
+              console.log('--------', index)
+              var crow = this.list[index]
+              if (crow) {
+                switch (x) {
+                  case 0:
+                    sturow.rowid = this.formatDate(crow[0])
+                    sturow.stid = crow[1]
+                    sturow.name = crow[2]
+                    break
+                  case 1:
+                    sturow.rowid1 = this.formatDate(crow[0])
+                    sturow.stid1 = crow[1]
+                    sturow.name1 = crow[2]
+                    break
+                  case 2:
+                    sturow.rowid2 = this.formatDate(crow[0])
+                    sturow.stid2 = crow[1]
+                    sturow.name2 = crow[2]
+                    break
+                  case 3:
+                    sturow.rowid3 = this.formatDate(crow[0])
+                    sturow.stid3 = crow[1]
+                    sturow.name3 = crow[2]
+                    break
+                  case 4:
+                    sturow.rowid4 = this.formatDate(crow[0])
+                    sturow.stid4 = crow[1]
+                    sturow.name4 = crow[2]
+                    break
+                }
+              }
+            }
+            this.list2.push(sturow)
+          }
+          console.log('----res-1--', this.list2)
+          console.log('----res---', row)
+
+          var data = res.data.Value
+          data.sort(function (a, b) {
+            return a[0] - b[0]
+          })
+          var arrlength = data.length
+          if (data && data.length > 0 && data[0] && data[0].length > 1) {
+            for (var i = 1; i < data[0].length; i++) {
+              let arr = []
+              let arr2 = []
+              for (var k = 0; k < arrlength; k++) {
+                if (data[k][i] !== -9999) {
+                  arr.push([data[k][0], data[k][i]])
+                  arr2.push(data[k][1])
+                }
+              }
+              this.maxnum = res.data.GroupValue[1]
+              this.minnum = res.data.GroupValue[2]
+              this.averagevalue = res.data.GroupValue[3]
+
+              // this.maxnum = Math.max.apply(null, arr2).toFixed(2)
+              // this.minnum = Math.min.apply(null, arr2).toFixed(2)
+              // this.averagevalue = parseFloat(this.avg123(arr2)).toFixed(2)
+              this.$refs.historychart.target.series[i - 1].setData(arr)
+            }
+          }
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    avg123 (arr) {
+      var len = arr.length
+      var sum = 0
+      for (var i = 0; i < len; i++) {
+        sum += arr[i]
+      }
+      return sum / len
+    },
+    contains (strs, str) {
+      let arrs = strs.split(',')
+      for (let v in arrs) {
+        if (arrs[v] === (str + '')) return true
+      }
+      return false
+    },
+    seachdata () {
+      let value = this.timerange
+      if (value) {
+        if (value.length === 2 && value[0] !== null) {
+          this.initData()
+          this.countDistinct()
+          return
+        }
+      }
+      this.$message({
+        type: 'warning',
+        message: this.$t('message.devicechart.choose')
+      })
+    },
+    printdata () {
+      var mywindow = window.open('', 'PRINT')
+      mywindow.document.write('<html>')
+      mywindow.document.write('<body >')
+      mywindow.document.write(document.getElementById('table').innerHTML)
+      mywindow.document.write(document.getElementById('content').innerHTML)
+      mywindow.document.write(document.getElementById('data').innerHTML)
+      mywindow.document.write('</body></html>')
+      mywindow.document.close()
+      mywindow.focus()
+      mywindow.print()
+      mywindow.close()
+      return true
+    },
+    renderTime (date) {
+      var dateee = new Date(date).toJSON()
+      return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
+    }
+  },
+
+  // https://router.vuejs.org/zh-cn/essentials/dynamic-matching.html#响应路由参数的变化
+  // https://router.vuejs.org/zh-cn/advanced/data-fetching.html
+  watch: {
+    $route () {
+      this.initData()
+    }
+  },
+  computed: {}
+}
+
+</script>
+
+<style lang="scss">
+.el-pagination {
+  margin: 1rem 0 2rem;
+  text-align: right;
+}
+
+.triggerone {
+  font-size: 13px;
+  margin-left: 80px;
+}
+
+.plab {
+  font-size: 13px;
+  color: #999;
+}
+</style>
+

+ 34 - 177
frontend_web/src/views/main/devicechart.vue

@@ -7,7 +7,7 @@
             {{ $t('message.devicechart.Time') }}:
             <el-date-picker v-model="timerange"
                             type="datetimerange"
-                            clearable
+                            clearable="true"
                             :placeholder="$t('message.devicechart.choose')">
             </el-date-picker>
           </div>
@@ -24,137 +24,23 @@
                      style="margin-left:0px;">
             <i class="icon icon-printer"></i>{{ $t('message.chartreport.print')}}
           </el-button>
+          <el-button type="primary"
+                     v-if="this.dataitem === '6' || this.dataitem === '0'"
+                     size="small"
+                     icon="search"
+                     style="margin-left:0px;"
+                     @click="channelschart">{{ '数据报表' }}</el-button>
         </el-col>
       </el-row>
     </div>
-    <div id="table"
-         style="width:800px">
-      <div id="header">
-        <div style="text-align:center;">
-          <!-- <tr>
-            <th rowspan="2"> <img src="../../assets/images/deviceschart.jpeg"
-                   style="width:80px;" /></th>
-          </tr> -->
-          <p style="font-size:32px">数据报表</p>
-          <p>时间范围:{{renderTime(timerange[0])}}-{{renderTime(timerange[1])}} </p>
-          <p>签字:__________ &nbsp; &nbsp;日期:__________</p>
-          <!-- <p>{{this.jstimehandle(timerange[0])}}</p> -->
-        </div>
-      </div>
-
-      <h2>设备信息</h2>
-      <hr />
-      <table style="border-spacing: 10px;  padding-top:5px;">
-        <tr>
-          <th style="width:80px">设备ID</th>
-          <td style="width:180px">{{serial}}</td>
-          <th style="width:80px">传感器名称</th>
-          <td style="width:180px">{{this.$route.query.xn}}</td>
-          <th style="width:80px">设备名称</th>
-          <td style="width:180px">{{this.$route.query.code}}</td>
-        </tr>
-        <tr style="padding-top:5px;">
-          <th style="width:80px">校准证书:</th>
-          <td style="width:180px">{{certificate}}</td>
-          <th style="width:80px"></th>
-          <td style="width:180px"></td>
-          <th style="width:80px">设备类型</th>
-          <td style="width:180px">{{devicestype}}</td>
-        </tr>
-      </table>
-
-      <h2>数据摘要</h2>
-      <hr />
-      <table style="border-spacing: 10px;  padding-top:5px;">
-        <tr>
-          <th style="width:80px">最高温度</th>
-          <td style="width:180px">28.71℃</td>
-          <th style="width:80px">最低温度</th>
-          <td style="width:180px">24.67℃</td>
-          <th style="width:80px">平均温度</th>
-          <td style="width:180px">25.7℃</td>
-        </tr>
-      </table>
-
-      <h2>报警信息</h2>
-      <hr />
-      <table style="border-spacing: 10px;  padding:5px 0px 5px 0px;">
-        <tr>
-          <th style="width:80px">报警参数</th>
-          <td style="width:180px">&gt;0℃,&lt;30℃</td>
-          <th style="width:80px">报警数量</th>
-          <td style="width:180px">0</td>
-        </tr>
-      </table>
-      <h2>曲线报表</h2>
-      <hr />
-    </div>
     <div id="content">
-      <div style="text-align:center;margin-bottom:15px;font-size: 14px;color: #636363;margin-top:25px;">
+      <div style="text-align:center;margin-bottom:15px;font-size: 14px;color: #636363;">
         {{titel}} {{ $t('message.devicechart.Latest') }}: {{lastdata}}
       </div>
       <time-line-chart :series="seriesData"
                        ref="historychart"
-                       style="height:440px;width:800px"></time-line-chart>
-    </div>
-
-    <div id="data"
-         style="padding-top:5px;width:800px;">
-      <h2>详细数据</h2>
-      <hr />
-      <div class="col"
-           style="width:33%;float:left;border:0px #000">
-        <div style="width:55%;float:left;border:0px #000">
-          时间:
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          温度℃
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          湿度℃
-        </div>
-      </div>
-      <div class="col"
-           style="width:33%;float:left;border:0px #000">
-        <div style="width:55%;float:left;border:0px #000">
-          时间:
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          温度℃
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          湿度℃
-        </div>
-      </div>
-      <div class="col"
-           style="width:33%;float:left;border:0px #000">
-        <div style="width:55%;float:left;border:0px #000">
-          时间:
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          温度℃
-        </div>
-        <div style="width:22%;float:left;border:0px #000">
-          湿度℃
-        </div>
-      </div>
-      <div v-for="(v, index) in list"
-           style="font-size:10px">
-        <div class="col"
-             style="width:33%;float:left;border:0px #000">
-          <div style="width:55%;float:left;border:0px #000">
-            {{formatDate(v[0])}}
-          </div>
-          <div style="width:22%;float:left;border:0px #000">
-            {{v[1]}}
-          </div>
-          <div style="width:22%;float:left;border:0px #000">
-            {{v[2]}}
-          </div>
-        </div>
-      </div>
+                       style="height:480px"></time-line-chart>
     </div>
-
   </div>
 </template>
 
@@ -169,7 +55,7 @@ export default {
     return {
       serial: '',
       dataitem: '0',
-      timerange: [new Date(new Date() - 3600 * 1000 * 24), new Date()],
+      timerange: [new Date(new Date() - 3600 * 1000), new Date()],
       seriesData: [],
       items1: '0,14,16',
       items2: '6,10',
@@ -189,25 +75,17 @@ export default {
       itemo2_17: '17',
       lastdata: '--',
       titel: '',
-      certificate: '',
-      devicestype: '',
-      list: [],
-      TemperatureArr: []
+      channelchart: ''
     }
   },
 
   created () {
     let paramarr = this.$route.params.serial.split('_')
+    this.channelchart = this.$route.params.serial + '?xn=' + this.$route.query.xn + '&certificate=' + this.$route.query.certificate + '&code=' + this.$route.query.code
     if (paramarr.length === 2) {
       this.serial = paramarr[0]
       this.dataitem = paramarr[1]
-      if (this.dataitem === '0') {
-        this.devicestype = 'GT-TH'
-      } else if (this.dataitem === '6') {
-        this.devicestype = 'GT-T'
-      } else {
-        this.devicestype = '其他传感器'
-      }
+
       console.log('---------this.dataitem--------', this.dataitem)
       if (this.contains(this.items1, this.dataitem)) {
         this.seriesData = [{
@@ -216,11 +94,17 @@ export default {
         }, {
           name: this.$t('message.equipment.Humidity'),
           unit: '%'
+        }, {
+          name: this.$t('message.equipment.Voltage'),
+          unit: 'V'
         }]
       } else if (this.contains(this.items2, this.dataitem)) {
         this.seriesData = [{
           name: this.$t('message.equipment.Temperature'),
           unit: '℃'
+        }, {
+          name: this.$t('message.equipment.Voltage'),
+          unit: 'V'
         }]
       } else if (this.contains(this.itemo2, this.dataitem)) {
         this.seriesData = [{
@@ -232,6 +116,9 @@ export default {
         }, {
           name: this.$t('message.devicechart.oxygen'),
           unit: '%'
+        }, {
+          name: this.$t('message.equipment.Voltage'),
+          unit: 'V'
         }]
       } else if (this.contains(this.itemco2, this.dataitem)) {
         this.seriesData = [{
@@ -243,11 +130,17 @@ export default {
         }, {
           name: this.$t('message.devicechart.Carbon'),
           unit: '%'
+        }, {
+          name: this.$t('message.equipment.Voltage'),
+          unit: 'V'
         }]
       } else if (this.contains(this.itempower, this.dataitem)) {
         this.seriesData = [{
           name: this.$t('message.management.Sensor'),
           unit: 'W'
+        }, {
+          name: this.$t('message.equipment.Voltage'),
+          unit: 'V'
         }]
       } else if (this.contains(this.itemliquidLevel, this.dataitem)) {
         this.seriesData = [{
@@ -330,8 +223,8 @@ export default {
           } else if (this.contains(this.itempower, this.dataitem)) {
             this.c = this.$t('message.management.power')
             this.d = this.$t('message.index.Voltage')
-            this.lastdata = this.c + `【${res.data.Power} W 】` + this.d + `【${res.data.Supply} V 】`
-            // this.lastdata = `功率 【${res.data.Power} ℃ 】 电  【${res.data.Supply} % 】`
+            this.lastdata = this.c + `【${res.data.Power} ℃ 】` + this.d + `【${res.data.Supply} % 】`
+            // this.lastdata = `功率 【${res.data.Power} ℃ 】 电  【${res.data.Supply} % 】`
           } else if (this.contains(this.itemliquidLevel, this.dataitem)) {
             this.a = this.$t('message.equipment.Temperature')
             this.e = this.$t('message.management.level')
@@ -362,44 +255,13 @@ export default {
           } else if (this.contains(this.itemso3, this.dataitem)) {
             this.lastdata = `O3  【${res.data.O3} % 】`
           }
-          this.timerange = [new Date(new Date(res.data.Time) - 3600 * 1000 * 24), new Date(res.data.Time)]
+          this.timerange = [new Date(new Date(res.data.Time) - 3600 * 1000), new Date(res.data.Time)]
           this.initData()
-          this.opentriggerlist()
         })
     }
     this.titel = this.$route.query.xn + '(' + this.serial + ') '
-    this.certificate = this.$route.query.certificate
   },
   methods: {
-    opentriggerlist () {
-      // this.triggerlistdialogtitle = `报警设置列表(${this.triggerform.title})`
-      this.$services.trigger.get('list/' + this.triggerform.serial, null)
-        .then(res => {
-          // response
-          console.log('===res.data.items====', res.data.items)
-          // this.triggerlist = res.data.items
-        })
-        .catch(err => {
-          // handle error
-          console.error(err)
-          this.loading = false
-        })
-    },
-    formatDate (value) {
-      let date = new Date(value)
-      let y = date.getFullYear()
-      let MM = date.getMonth() + 1
-      MM = MM < 10 ? ('0' + MM) : MM
-      let d = date.getDate()
-      d = d < 10 ? ('0' + d) : d
-      let h = date.getHours()
-      h = h < 10 ? ('0' + h) : h
-      let m = date.getMinutes()
-      m = m < 10 ? ('0' + m) : m
-      let s = date.getSeconds()
-      s = s < 10 ? ('0' + s) : s
-      return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
-    },
     initData () {
       // request
       let params = {
@@ -407,13 +269,12 @@ export default {
         _end: this.timerange[1].getTime(),
         _dataitem: this.dataitem
       }
+      console.log('------this.serial---------', this.serial)
       this.$services.channel.get('historydatavalue/' + this.serial, {
         params
       })
         .then(res => {
           // response
-          console.log('----res---', res.data)
-          this.list = res.data.Value
           var data = res.data.Value
           data.sort(function (a, b) {
             return a[0] - b[0]
@@ -422,7 +283,6 @@ export default {
           if (data && data.length > 0 && data[0] && data[0].length > 1) {
             for (var i = 1; i < data[0].length; i++) {
               let arr = []
-
               for (var k = 0; k < arrlength; k++) {
                 if (data[k][i] !== -9999) {
                   arr.push([data[k][0], data[k][i]])
@@ -461,9 +321,7 @@ export default {
       var mywindow = window.open('', 'PRINT')
       mywindow.document.write('<html>')
       mywindow.document.write('<body >')
-      mywindow.document.write(document.getElementById('table').innerHTML)
       mywindow.document.write(document.getElementById('content').innerHTML)
-      mywindow.document.write(document.getElementById('data').innerHTML)
       mywindow.document.write('</body></html>')
       mywindow.document.close()
       mywindow.focus()
@@ -471,9 +329,8 @@ export default {
       mywindow.close()
       return true
     },
-    renderTime (date) {
-      var dateee = new Date(date).toJSON()
-      return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
+    channelschart () {
+      this.$router.push('/channels/chart/' + this.channelchart)
     }
   },
 

+ 522 - 451
frontend_web/src/views/main/users.vue

@@ -1,97 +1,158 @@
 <template>
-  <div v-loading="downloading" :element-loading-text="$t('message.Load')">
+  <div v-loading="downloading"
+       :element-loading-text="$t('message.Load')">
     <div class="heading">
       <div class="search icon-before icon-search">
-        <input type="text" v-model="keyword" :placeholder="$t('message.users.search')">
+        <input type="text"
+               v-model="keyword"
+               :placeholder="$t('message.users.search')">
       </div>
-      <el-button type="primary" size="small" icon="search" @click="seachdata">{{ $t('message.users.search') }}</el-button>
-      <el-button type="primary" size="small" icon="plus" @click="opendatadialog(1,null,-1);resetForm('userform')">{{ $t('message.users.plus') }}</el-button>
+      <el-button type="primary"
+                 size="small"
+                 icon="search"
+                 @click="seachdata">{{ $t('message.users.search') }}</el-button>
+      <el-button type="primary"
+                 size="small"
+                 icon="plus"
+                 @click="opendatadialog(1,null,-1);resetForm('userform')">{{ $t('message.users.plus') }}</el-button>
     </div>
     <el-table :data="list">
-      <el-table-column prop="Username"  align="center" :label="$t('message.users.Username')"  show-overflow-tooltip></el-table-column>
-      <el-table-column :label="$t('message.users.Realname')" prop="Realname"  width="150"></el-table-column>
-      <el-table-column prop="Telephone" :label="$t('message.users.Telephone')" show-overflow-tooltip></el-table-column>
-      <el-table-column :label="$t('message.users.Mobile')" prop="Mobile" show-overflow-tooltip></el-table-column>
-      <el-table-column :label="$t('message.users.role')"  show-overflow-tooltip>
+      <el-table-column prop="Username"
+                       align="center"
+                       :label="$t('message.users.Username')"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column :label="$t('message.users.Realname')"
+                       prop="Realname"
+                       width="150"></el-table-column>
+      <el-table-column prop="Telephone"
+                       :label="$t('message.users.Telephone')"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column :label="$t('message.users.Mobile')"
+                       prop="Mobile"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column :label="$t('message.users.role')"
+                       show-overflow-tooltip>
         <template scope="scope">
-          <el-tag type="success" v-if="scope.row.Roleid === 10000123">{{ $t('message.users.Ordinary') }}</el-tag>
-          <el-tag type="danger" v-if="scope.row.Roleid === 10000119">{{ $t('message.users.manager') }}</el-tag>
+          <el-tag type="success"
+                  v-if="scope.row.Roleid === 10000123">{{ $t('message.users.Ordinary') }}</el-tag>
+          <el-tag type="danger"
+                  v-if="scope.row.Roleid === 10000119">{{ $t('message.users.manager') }}</el-tag>
         </template>
       </el-table-column>
-      <el-table-column prop="Description" :label="$t('message.users.Remarks')" show-overflow-tooltip></el-table-column>
-      <el-table-column prop="Departmentname" :label="$t('message.users.organization')"></el-table-column>
-      <el-table-column :label="$t('message.users.operation')"  align="center" width="280">
+      <el-table-column prop="Description"
+                       :label="$t('message.users.Remarks')"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column prop="Departmentname"
+                       :label="$t('message.users.organization')"></el-table-column>
+      <el-table-column :label="$t('message.users.operation')"
+                       align="center"
+                       width="280">
         <template scope="scope">
-          <el-button
-            size="small"
-            @click="opendatadialog(2,scope.row,scope.$index);resetForm('userform')">{{ $t('message.users.edit') }}</el-button>
-          <el-button
-            size="small"
-            type="warning"
-            @click="deletedata(scope.row)">{{ $t('message.users.delete') }}</el-button>
-            <el-button
-            size="small"
-            type="success"
-            @click="permission(scope.row)">{{ $t('message.users.Permission') }}</el-button>
-          <el-button
-            size="small"
-            type="info"
-            @click="resetpwd(scope.row)">{{ $t('message.users.reset') }}</el-button>
+          <el-button size="small"
+                     @click="opendatadialog(2,scope.row,scope.$index);resetForm('userform')">{{ $t('message.users.edit') }}</el-button>
+          <el-button size="small"
+                     type="warning"
+                     @click="deletedata(scope.row)">{{ $t('message.users.delete') }}</el-button>
+          <el-button size="small"
+                     type="success"
+                     @click="permission(scope.row)">{{ $t('message.users.Permission') }}</el-button>
+          <el-button size="small"
+                     type="info"
+                     @click="resetpwd(scope.row)">{{ $t('message.users.reset') }}</el-button>
         </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 @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>
-    
-    <el-dialog :title="dialogtitle" :visible.sync="datadialogVisible" top="5%">
-      <el-form :model="userform" :rules="rulesuser" ref="userform">
-        <el-form-item :label="$t('message.users.Username')" prop="username" required label-width="120px">
-          <el-input v-model="userform.username" auto-complete="off" :disabled="disabledserial"></el-input>
+
+    <el-dialog :title="dialogtitle"
+               :visible.sync="datadialogVisible"
+               top="5%">
+      <el-form :model="userform"
+               :rules="rulesuser"
+               ref="userform">
+        <el-form-item :label="$t('message.users.Username')"
+                      prop="username"
+                      required
+                      label-width="120px">
+          <el-input v-model="userform.username"
+                    auto-complete="off"
+                    :disabled="disabledserial"></el-input>
         </el-form-item>
-        <el-form-item :label="$t('message.users.Realname')" label-width="120px" required prop="realname">
+        <el-form-item :label="$t('message.users.Realname')"
+                      label-width="120px"
+                      required
+                      prop="realname">
           <el-input v-model="userform.realname"></el-input>
         </el-form-item>
-        <el-form-item :label="$t('message.users.role')" label-width="120px" required>
-          <el-select v-model="userform.role" :placeholder="$t('message.users.rolechange')">
-            <el-option :label="$t('message.users.Ordinary')" value="10000123"></el-option>
-            <el-option :label="$t('message.users.manager')" value="10000119"></el-option>
+        <el-form-item :label="$t('message.users.role')"
+                      label-width="120px"
+                      required>
+          <el-select v-model="userform.role"
+                     :placeholder="$t('message.users.rolechange')">
+            <el-option :label="$t('message.users.Ordinary')"
+                       value="10000123"></el-option>
+            <el-option :label="$t('message.users.manager')"
+                       value="10000119"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item :label="$t('message.users.organization')" label-width="120px" required>
-          <el-cascader :options="orgtreelist" :props="orgtreeprops" change-on-select :show-all-levels="false" v-model="selectedorg" placeholder="请选择组织"></el-cascader>
+        <el-form-item :label="$t('message.users.organization')"
+                      label-width="120px"
+                      required>
+          <el-cascader :options="orgtreelist"
+                       :props="orgtreeprops"
+                       change-on-select
+                       :show-all-levels="false"
+                       v-model="selectedorg"
+                       placeholder="请选择组织"></el-cascader>
         </el-form-item>
-        <el-form-item :label="$t('message.users.Telephone')" label-width="120px" prop="telephone">
-          <el-input v-model="userform.telephone" auto-complete="off"></el-input>
+        <el-form-item :label="$t('message.users.Telephone')"
+                      label-width="120px"
+                      prop="telephone">
+          <el-input v-model="userform.telephone"
+                    auto-complete="off"></el-input>
         </el-form-item>
-        <el-form-item :label="$t('message.users.Mobile')" label-width="120px" prop="mobile">
-          <el-input v-model="userform.mobile" auto-complete="off"></el-input>
+        <el-form-item :label="$t('message.users.Mobile')"
+                      label-width="120px"
+                      prop="mobile">
+          <el-input v-model="userform.mobile"
+                    auto-complete="off"></el-input>
         </el-form-item>
-        <el-form-item :label="$t('message.users.Remarks')" label-width="120px">
-          <el-input type="textarea" v-model="userform.description" auto-complete="off"></el-input>
+        <el-form-item :label="$t('message.users.Remarks')"
+                      label-width="120px">
+          <el-input type="textarea"
+                    v-model="userform.description"
+                    auto-complete="off"></el-input>
         </el-form-item>
       </el-form>
-      <div slot="footer" class="dialog-footer">
+      <div slot="footer"
+           class="dialog-footer">
         <el-button @click="datadialogVisible = false">{{ $t('message.users.cancel') }}</el-button>
-        <el-button type="primary" @click="savedata('userform')">{{ $t('message.users.confirm') }}</el-button>
+        <el-button type="primary"
+                   @click="savedata('userform')">{{ $t('message.users.confirm') }}</el-button>
       </div>
     </el-dialog>
 
-    <el-dialog :title="permissiondialogtitle" :visible.sync="permissiondatadialogVisible" top="5%">
-      <el-col :span="6" style="margin-right: 10px">
+    <el-dialog :title="permissiondialogtitle"
+               :visible.sync="permissiondatadialogVisible"
+               top="5%">
+      <el-col :span="6"
+              style="margin-right: 10px">
         <div class="userpermisstreediv">
-          <el-tree style="border: 0" node-key="id" show-checkbox
-            :data="orgtreelist"
-            :props="orgtreeprops"
-            :default-expanded-keys="userdepartment"
-            @check-change="userpermissorgcheckedchange"
-            ref="userpermisstree">
+          <el-tree style="border: 0"
+                   node-key="id"
+                   show-checkbox
+                   :data="orgtreelist"
+                   :props="orgtreeprops"
+                   :default-expanded-keys="userdepartment"
+                   @check-change="userpermissorgcheckedchange"
+                   ref="userpermisstree">
           </el-tree>
         </div>
       </el-col>
@@ -100,15 +161,19 @@
           <el-form-item>
             <div class="userpermissdiv">
               <el-checkbox-group v-model="userpermissdevicesselects">
-                <el-checkbox v-for="item in equipdeviceslist" :label="item.Id+''">{{item.Code}}</el-checkbox>
+                <el-checkbox v-for="item in equipdeviceslist"
+                             :label="item.Id+''">{{item.Code}}</el-checkbox>
               </el-checkbox-group>
             </div>
           </el-form-item>
         </el-form>
       </el-col>
-      <div slot="footer" class="dialog-footer" style="margin-top:-35px;">
+      <div slot="footer"
+           class="dialog-footer"
+           style="margin-top:-35px;">
         <el-button @click="permissiondatadialogVisible = false">{{ $t('message.users.cancel') }}</el-button>
-        <el-button type="primary" @click="savepermission()">{{ $t('message.users.confirm') }}</el-button>
+        <el-button type="primary"
+                   @click="savepermission()">{{ $t('message.users.confirm') }}</el-button>
       </div>
     </el-dialog>
 
@@ -116,153 +181,153 @@
 </template>
 
 <script>
-  import {
-    mapGetters
-  } from 'vuex'
-  export default {
-    name: 'users',
+import {
+  mapGetters
+} from 'vuex'
+export default {
+  name: 'users',
 
-    data () {
-      var checkusername = (rule, value, callback) => {
-        if (!value) {
-          callback(new Error(this.$t('message.users.Please')))
+  data () {
+    var checkusername = (rule, value, callback) => {
+      if (!value) {
+        callback(new Error(this.$t('message.users.Please')))
+      } else {
+        let re = /^([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/
+        if (!re.test(value)) {
+          callback(new Error(this.$t('message.users.email')))
         } else {
-          let re = /^([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|-|.|-]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/
-          if (!re.test(value)) {
-              callback(new Error(this.$t('message.users.email')))
-          } else {
-            callback()
-          }
+          callback()
         }
       }
-      return {
-        organdialogVisible: false,
-        currentItemCount: 0,
-        currentItemCount2: 0,
-        currentItemCount3: 0,
-        currentPage: 1,
-        size: 10,
-        list: [],
-        keyword: '',
-        datadialogVisible: false,
-        dialogtitle: '',
-        disabledserial: false,
-        userform: {
-          username: '',
-          realname: '',
-          telephone: '',
-          mobile: '',
-          description: '',
-          role: '10000123',
-          id: 0,
-          departmentid: '',
-          departmentname: ''
-        },
-        rulesuser: {
-          username: [
-            { validator: checkusername, trigger: 'blur' }
-          ],
-          realname: [
-            { required: true, message: this.$t('message.users.Realname'), trigger: 'blur' }
-          ]
-        },
-        operatingitem: 0,
-        permissiondialogtitle: '',
-        permissiondatadialogVisible: false,
-        isfristchecked: false, // 过滤点击树时出现的多次触发选择事件
-        userpermisstreedata: [], // 组织tree 数据
-        userpermissdevicesselects: [], // 设备批量设置所选设备
-        equipdeviceslist: [], // 批量设置设备设备所有数据
-        equipalllist: [], // 设备所有数据
-        checkedarr: [], // 树形控件多选框
-        orgtreelist: [],
-        orgtreeprops: {
-          value: 'id',
-          label: 'Fullname',
-          children: 'children'
-        },
-        selectedorg: [],
-        userdepartment: [],
-        ischeckbj: false // 过滤字段勾选时触发的选中事件
-      }
-    },
-    computed: mapGetters({
-      session: 'session'
-    }),
-    created () {
-      this.getorgtreelist()
-      // initial data
-      this.initData()
-      this.loadequipsall()
-      this.userdepartment.push(parseInt(this.session.user.Profile.DepartmentId))
-      this.selectedorg = [parseInt(this.session.user.Profile.DepartmentId)]
-    },
-    methods: {
-      initData () {
-        let _this = this
-        // paginate
-        const params = { _currentPage: this.currentPage, _size: this.size, keyword: this.keyword }
-        // request
-        this.$services.user.get('list', { params })
-          .then(res => {
-            // response
-            _this.list = res.data.items
-            // toggle loading
-            // _this.loading = false
-            _this.currentItemCount = res.data.currentItemCount
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-      loadequipsall () {
-        // toggle loading
-        let _this = this
-        // request
-        this.$services.equipment.get('alllist', null)
-          .then(res => {
-            // response
-            _this.equipalllist = res.data.items
-            _this.equipdeviceslist = res.data.items
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-            this.loading = false
-          })
-      },
-      seachdata () {
-        this.currentPage = 1
-        this.initData()
-      },
-      handleSizeChange (value) {
-        this.size = value
-        this.currentPage = 1
-        this.initData()
+    }
+    return {
+      organdialogVisible: false,
+      currentItemCount: 0,
+      currentItemCount2: 0,
+      currentItemCount3: 0,
+      currentPage: 1,
+      size: 10,
+      list: [],
+      keyword: '',
+      datadialogVisible: false,
+      dialogtitle: '',
+      disabledserial: false,
+      userform: {
+        username: '',
+        realname: '',
+        telephone: '',
+        mobile: '',
+        description: '',
+        role: '10000123',
+        id: 0,
+        departmentid: '',
+        departmentname: ''
       },
-      handleCurrentChange (value) {
-        this.currentPage = value
-        this.initData()
+      rulesuser: {
+        username: [
+          { validator: checkusername, trigger: 'blur' }
+        ],
+        realname: [
+          { required: true, message: this.$t('message.users.Realname'), trigger: 'blur' }
+        ]
       },
-      jstimehandle (val) {
-        val = val.replace('T', ' ')
-        return val.substring(0, 19)
+      operatingitem: 0,
+      permissiondialogtitle: '',
+      permissiondatadialogVisible: false,
+      isfristchecked: false, // 过滤点击树时出现的多次触发选择事件
+      userpermisstreedata: [], // 组织tree 数据
+      userpermissdevicesselects: [], // 设备批量设置所选设备
+      equipdeviceslist: [], // 批量设置设备设备所有数据
+      equipalllist: [], // 设备所有数据
+      checkedarr: [], // 树形控件多选框
+      orgtreelist: [],
+      orgtreeprops: {
+        value: 'id',
+        label: 'Fullname',
+        children: 'children'
       },
-      opendatadialog (item, v, index) {
-        let _this = this
-        this.operatingitem = item
-        this.datadialogVisible = true
-        this.clearuserForm()
-        if (item === 1) {
-          this.dialogtitle = this.$t('message.users.plus')
-          this.disabledserial = false
-        } else if (item === 2) {
-          this.$services.organizes.get('parentlist/' + v.Departmentid, {})
+      selectedorg: [],
+      userdepartment: [],
+      ischeckbj: false // 过滤字段勾选时触发的选中事件
+    }
+  },
+  computed: mapGetters({
+    session: 'session'
+  }),
+  created () {
+    this.getorgtreelist()
+    // initial data
+    this.initData()
+    this.loadequipsall()
+    this.userdepartment.push(parseInt(this.session.user.Profile.DepartmentId))
+    this.selectedorg = [parseInt(this.session.user.Profile.DepartmentId)]
+  },
+  methods: {
+    initData () {
+      let _this = this
+      // paginate
+      const params = { _currentPage: this.currentPage, _size: this.size, keyword: this.keyword }
+      // request
+      this.$services.user.get('list', { params })
+        .then(res => {
+          // response
+          _this.list = res.data.items
+          // toggle loading
+          // _this.loading = false
+          _this.currentItemCount = res.data.currentItemCount
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    loadequipsall () {
+      // toggle loading
+      let _this = this
+      // request
+      this.$services.equipment.get('alllist', null)
+        .then(res => {
+          // response
+          _this.equipalllist = res.data.items
+          _this.equipdeviceslist = res.data.items
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+          this.loading = false
+        })
+    },
+    seachdata () {
+      this.currentPage = 1
+      this.initData()
+    },
+    handleSizeChange (value) {
+      this.size = value
+      this.currentPage = 1
+      this.initData()
+    },
+    handleCurrentChange (value) {
+      this.currentPage = value
+      this.initData()
+    },
+    jstimehandle (val) {
+      val = val.replace('T', ' ')
+      return val.substring(0, 19)
+    },
+    opendatadialog (item, v, index) {
+      let _this = this
+      this.operatingitem = item
+      this.datadialogVisible = true
+      this.clearuserForm()
+      if (item === 1) {
+        this.dialogtitle = this.$t('message.users.plus')
+        this.disabledserial = false
+      } else if (item === 2) {
+        this.$services.organizes.get('parentlist/' + v.Departmentid, {})
           .then(res => {
             if (res.data.code === 0) {
-             _this.aa = this.$t('message.users.user')
-          _this.dialogtitle = _this.aa + `(${v.Realname})`
+              _this.aa = this.$t('message.users.user')
+              _this.dialogtitle = _this.aa + `(${v.Realname})`
               _this.disabledserial = true
               _this.userform.username = v.Username
               _this.userform.realname = v.Realname + ''
@@ -291,150 +356,175 @@
             // handle error
             console.error(err)
           })
-        }
-      },
-      savedata (formName) {
-        let _this = this
-        if (this.selectedorg.length === 0) {
-          _this.$message({
-            type: 'warning',
-            message: this.$t('message.users.mess')
-          })
-          return
-        }
-        this.$refs[formName].validate((valid) => {
-          if (valid) {
-            this.userform.departmentid = this.selectedorg[this.selectedorg.length - 1] + ''
-            if (_this.operatingitem === 1) {
-              _this.$services.user.post(_this.userform)
-                .then(res => {
-                  // response
-                  if (res.data.code === 0) {
-                    _this.$message({
-                      type: 'success',
-                      message: res.data.message
-                    })
-                    _this.datadialogVisible = false
-                    this.initData()
-                  } else {
-                    _this.$message({
-                      type: 'warning',
-                      message: res.data.message
-                    })
-                  }
-                })
-                .catch(err => {
-                  // handle error
-                  console.error(err)
-                })
-            } else if (_this.operatingitem === 2) {
-              _this.$services.user.put(_this.userform.id, _this.userform)
-                .then(res => {
-                  // response
-                  if (res.data.code === 0) {
-                    _this.$message({
-                      type: 'success',
-                      message: res.data.message
-                    })
-                    _this.datadialogVisible = false
-                    // 更新界面
-                    this.initData()
-                  } else {
-                    _this.$message({
-                      type: 'warning',
-                      message: res.data.message
-                    })
-                  }
-                })
-                .catch(() => {})
-            }
-          } else {
-            return false
-          }
+      }
+    },
+    savedata (formName) {
+      let _this = this
+      if (this.selectedorg.length === 0) {
+        _this.$message({
+          type: 'warning',
+          message: this.$t('message.users.mess')
         })
-      },
-      deletedata (val) {
-        let _this = this
-        _this.$confirm(this.$t('message.users.warn'), this.$t('message.users.tip'), {
-          confirmButtonText: this.$t('message.users.confirm'),
-          cancelButtonText: this.$t('message.users.cancel'),
-          type: 'warning'
-        }).then(() => {
-          _this.$services.user.delete(val.Id, null)
-            .then(res => {
-              // response
-              if (res.data.code === 0) {
-                _this.$message({
-                  type: 'success',
-                  message: res.data.message
-                })
-                // 更新界面
-                this.initData()
-              } else {
-                _this.$message({
-                  type: 'warning',
-                  message: res.data.message
-                })
-              }
-            })
-            .catch(() => {})
-        }).catch(() => {})
-      },
-      resetForm (formName) {
-        this.$refs[formName].resetFields()
-      },
-      clearuserForm () {
-        this.userform = {
-          username: '',
-          realname: '',
-          telephone: '',
-          mobile: '',
-          description: '',
-          role: '10000123'
+        return
+      }
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.userform.departmentid = this.selectedorg[this.selectedorg.length - 1] + ''
+          if (_this.operatingitem === 1) {
+            _this.$services.user.post(_this.userform)
+              .then(res => {
+                // response
+                if (res.data.code === 0) {
+                  _this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  _this.datadialogVisible = false
+                  this.initData()
+                } else {
+                  _this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+              })
+              .catch(err => {
+                // handle error
+                console.error(err)
+              })
+          } else if (_this.operatingitem === 2) {
+            _this.$services.user.put(_this.userform.id, _this.userform)
+              .then(res => {
+                // response
+                if (res.data.code === 0) {
+                  _this.$message({
+                    type: 'success',
+                    message: res.data.message
+                  })
+                  _this.datadialogVisible = false
+                  // 更新界面
+                  this.initData()
+                } else {
+                  _this.$message({
+                    type: 'warning',
+                    message: res.data.message
+                  })
+                }
+              })
+              .catch(() => { })
+          }
+        } else {
+          return false
         }
-      },
-      permission (v) {
-        let _this = this
-        _this.ischeckbj = true // 过滤字段勾选时触发的选中事件
-        this.userpermissdevicesselects = []
-        this.bb = this.$t('message.users.settings')
-        this.permissiondialogtitle = this.bb + `(${v.Realname})`
-        this.permissiondatadialogVisible = true
-        this.userform.id = v.Id
-        this.$services.user.get('permission/' + v.Id, null)
-          .then(res => {
-            // response
-            res.data.forEach((item, k) => {
-              this.userpermissdevicesselects.push(item)
-            })
-            _this.getorgbyeid(res.data + '')
-          })
-          .catch(err => {
-            // handle error
-            console.error(err)
-          })
-      },
-      getorgbyeid(v) {
-        let _this = this
-        this.$services.equipment.put('getorgidsbyeqids', {EquipmentIds: v})
+      })
+    },
+    deletedata (val) {
+      let _this = this
+      _this.$confirm(this.$t('message.users.warn'), this.$t('message.users.tip'), {
+        confirmButtonText: this.$t('message.users.confirm'),
+        cancelButtonText: this.$t('message.users.cancel'),
+        type: 'warning'
+      }).then(() => {
+        _this.$services.user.delete(val.Id, null)
           .then(res => {
             // response
-            setTimeout(function() {
-              setTimeout(function() {
-                _this.ischeckbj = false
-              }, 300)
-              // 清空树选择框
-              _this.$refs.userpermisstree.setCheckedKeys(res.data)
-            }, 100)
+            if (res.data.code === 0) {
+              _this.$message({
+                type: 'success',
+                message: res.data.message
+              })
+              // 更新界面
+              this.initData()
+            } else {
+              _this.$message({
+                type: 'warning',
+                message: res.data.message
+              })
+            }
           })
-          .catch(err => {
-            // handle error
-            console.error(err)
+          .catch(() => { })
+      }).catch(() => { })
+    },
+    resetForm (formName) {
+      this.$refs[formName].resetFields()
+    },
+    clearuserForm () {
+      this.userform = {
+        username: '',
+        realname: '',
+        telephone: '',
+        mobile: '',
+        description: '',
+        role: '10000123'
+      }
+    },
+    permission (v) {
+      let _this = this
+      _this.ischeckbj = true // 过滤字段勾选时触发的选中事件
+      this.userpermissdevicesselects = []
+      this.bb = this.$t('message.users.settings')
+      this.permissiondialogtitle = this.bb + `(${v.Realname})`
+      this.permissiondatadialogVisible = true
+      this.userform.id = v.Id
+      this.$services.user.get('permission/' + v.Id, null)
+        .then(res => {
+          // response
+          res.data.forEach((item, k) => {
+            this.userpermissdevicesselects.push(item)
           })
-      },
-      savepermission() {
-        let _this = this
-        _this.$services.user.put('permission/' + this.userform.id, {channelids: this.userpermissdevicesselects + ''})
+          _this.getorgbyeid(res.data + '')
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    getorgbyeid (v) {
+      let _this = this
+      this.$services.equipment.put('getorgidsbyeqids', { EquipmentIds: v })
+        .then(res => {
+          // response
+          setTimeout(function () {
+            setTimeout(function () {
+              _this.ischeckbj = false
+            }, 300)
+            // 清空树选择框
+            _this.$refs.userpermisstree.setCheckedKeys(res.data)
+          }, 100)
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
+    },
+    savepermission () {
+      let _this = this
+      _this.$services.user.put('permission/' + this.userform.id, { channelids: this.userpermissdevicesselects + '' })
+        .then(res => {
+          // response
+          if (res.data.code === 0) {
+            _this.$message({
+              type: 'success',
+              message: res.data.message
+            })
+            _this.permissiondatadialogVisible = false
+          } else {
+            _this.$message({
+              type: 'warning',
+              message: res.data.message
+            })
+          }
+        })
+        .catch(() => { })
+    },
+    resetpwd (val) {
+      let _this = this
+      _this.$confirm(`(${val.Realname})` + this.$t('message.users.dewarn'), this.$t('message.users.tip'), {
+        confirmButtonText: this.$t('message.users.confirm'),
+        cancelButtonText: this.$t('message.users.cancel'),
+        type: 'warning'
+      }).then(() => {
+        _this.$services.user.put('resetpwd/' + val.Id, null)
           .then(res => {
             // response
             if (res.data.code === 0) {
@@ -442,7 +532,6 @@
                 type: 'success',
                 message: res.data.message
               })
-              _this.permissiondatadialogVisible = false
             } else {
               _this.$message({
                 type: 'warning',
@@ -450,47 +539,23 @@
               })
             }
           })
-          .catch(() => {})
-      },
-      resetpwd (val) {
-        let _this = this
-        _this.$confirm(`(${val.Realname})` + this.$t('message.users.dewarn'), this.$t('message.users.tip'), {
-          confirmButtonText: this.$t('message.users.confirm'),
-          cancelButtonText: this.$t('message.users.cancel'),
-          type: 'warning'
-        }).then(() => {
-          _this.$services.user.put('resetpwd/' + val.Id, null)
-            .then(res => {
-              // response
-              if (res.data.code === 0) {
-                _this.$message({
-                  type: 'success',
-                  message: res.data.message
-                })
-              } else {
-                _this.$message({
-                  type: 'warning',
-                  message: res.data.message
-                })
-              }
-            })
-            .catch(() => {})
-        }).catch(() => {})
-      },
+          .catch(() => { })
+      }).catch(() => { })
+    },
     // 选择组织树时触发
-    userpermissorgcheckedchange(data, checked, indeterminate) {
+    userpermissorgcheckedchange (data, checked, indeterminate) {
       let _this = this
       if (!_this.ischeckbj) {
         if (!_this.isfristchecked) {
           _this.isfristchecked = true
-          setTimeout(function() {
+          setTimeout(function () {
             _this.isfristchecked = false
             _this.checkorgusermanage()
           }, 100)
         }
       }
     },
-    checkorgusermanage() {
+    checkorgusermanage () {
       let orgids = []
       let selectnodes = this.$refs.userpermisstree.getCheckedNodes()
       selectnodes.forEach(row => {
@@ -498,7 +563,7 @@
       })
       const params = { orgids: orgids }
       let _this = this
-      this.$services.equipment.get('getidsbyoid', {params})
+      this.$services.equipment.get('getidsbyoid', { params })
         .then(res => {
           // response
           _this.userpermissdevicesselects = []
@@ -517,100 +582,106 @@
           this.loading = false
         })
     },
-    getorgtreelist() {
-    let _this = this
-    // request
-    _this.$services.organizes.get('list', {})
-      .then(res => {
-        _this.orgtreelist = _this.toolfun_gettreejson(res.data.items, 'Id', 'Parentid', 'Id,Fullname')
-      })
-      .catch(err => {
-        // handle error
-        console.error(err)
-      })
+    getorgtreelist () {
+      let _this = this
+      // request
+      _this.$services.organizes.get('list', {})
+        .then(res => {
+          _this.orgtreelist = _this.toolfun_gettreejson(res.data.items, 'Id', 'Parentid', 'Id,Fullname')
+        })
+        .catch(err => {
+          // handle error
+          console.error(err)
+        })
     },
-      toolfun_gettreejson(rows, idFieldName, pidFieldName, fileds) { // 工具方法,将扁平数据转化成tree格式数据
-        function nodejsonexists(rows, ParentId) {
-          for (var i = 0; i < rows.length; i++) {
-            if (rows[i][idFieldName] === ParentId) {
-              return true
+    toolfun_gettreejson (rows, idFieldName, pidFieldName, fileds) { // 工具方法,将扁平数据转化成tree格式数据
+      function nodejsonexists (rows, ParentId) {
+        for (var i = 0; i < rows.length; i++) {
+          if (rows[i][idFieldName] === ParentId) {
+            return true
+          }
+        }
+        return false
+      }
+      let nodes = []
+      // get the top level nodes
+      for (let i = 0; i < rows.length; i++) {
+        let row = rows[i]
+        if (!nodejsonexists(rows, row[pidFieldName])) {
+          var data = {
+            id: row[idFieldName]
+          }
+          let arrFiled = fileds.split(',')
+          for (var j = 0; j < arrFiled.length; j++) {
+            if (arrFiled[j] !== idFieldName) {
+              data[arrFiled[j]] = row[arrFiled[j]]
             }
           }
-          return false
+          nodes.push(data)
         }
-        let nodes = []
-        // get the top level nodes
+      }
+      let toDo = []
+      for (let i = 0; i < nodes.length; i++) {
+        toDo.push(nodes[i])
+      }
+      while (toDo.length) {
+        let node = toDo.shift() // the parent node
+        // get the children nodes
         for (let i = 0; i < rows.length; i++) {
           let row = rows[i]
-          if (!nodejsonexists(rows, row[pidFieldName])) {
-            var data = {
+          if (row[pidFieldName] === node.id) {
+            let child = {
               id: row[idFieldName]
             }
             let arrFiled = fileds.split(',')
-            for (var j = 0; j < arrFiled.length; j++) {
+            for (let j = 0; j < arrFiled.length; j++) {
               if (arrFiled[j] !== idFieldName) {
-                data[arrFiled[j]] = row[arrFiled[j]]
+                child[arrFiled[j]] = row[arrFiled[j]]
               }
             }
-            nodes.push(data)
-          }
-        }
-        let toDo = []
-        for (let i = 0; i < nodes.length; i++) {
-          toDo.push(nodes[i])
-        }
-        while (toDo.length) {
-          let node = toDo.shift() // the parent node
-          // get the children nodes
-          for (let i = 0; i < rows.length; i++) {
-            let row = rows[i]
-            if (row[pidFieldName] === node.id) {
-              let child = {
-                id: row[idFieldName]
-              }
-              let arrFiled = fileds.split(',')
-              for (let j = 0; j < arrFiled.length; j++) {
-                if (arrFiled[j] !== idFieldName) {
-                  child[arrFiled[j]] = row[arrFiled[j]]
-                }
-              }
-              if (node.children) {
-                node.children.push(child)
-              } else {
-                node.children = [child]
-              }
-              toDo.push(child)
+            if (node.children) {
+              node.children.push(child)
+            } else {
+              node.children = [child]
             }
+            toDo.push(child)
           }
         }
-        return nodes
       }
+      return nodes
     }
   }
+}
 </script>
 
 <style lang="scss">
- .el-pagination {
-    margin: 1rem 0 2rem;
-    text-align: right;
-  }
-  .triggerone {
-    font-size: 13px;
-    margin-left: 80px;
-  }
-  .plab {
-    font-size: 13px;
-    color: #999;
-  }
-  .userpermisstreediv {
-    border:1px #CCCCCC solid;overflow:auto;height:328px;
-    margin-right: 5px;
-  }
-  .userpermissdiv {
-    margin-left:1px;border:1px #CCCCCC solid;overflow:auto;height:320px;padding:4px;
-  }
-  .userpermissdiv .el-checkbox{
-    margin-top:5px;
-    margin-left: 15px;
-  }
+.el-pagination {
+  margin: 1rem 0 2rem;
+  text-align: right;
+}
+.triggerone {
+  font-size: 13px;
+  margin-left: 80px;
+}
+.plab {
+  font-size: 13px;
+  color: #999;
+}
+.userpermisstreediv {
+  border: 1px #cccccc solid;
+  overflow: auto;
+  height: 328px;
+  margin-right: 5px;
+}
+.userpermissdiv {
+  margin-left: 1px;
+  border: 1px #cccccc solid;
+  overflow: auto;
+  height: 320px;
+  padding: 4px;
+}
+.userpermissdiv .el-checkbox {
+  margin-top: 5px;
+  margin-left: 15px;
+}
 </style>