| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import api from "../../utils/api";
- Page({
- data: {
- pageStatus: 2,
- notesInput: '',
- room_name: '--',
- hotel_name: '--',
- count: 0,
- normal: 0,
- abnormal: 0,
- abnormal_d_name: '--',
- room_id: 0,
- show1: false,
- show2: false,
- show2Text: '',
- roomInfo: {},
- logsInfo: {},
- deviceList: []
- },
- onLoad: function (options) {
- this.setData({
- room_id: options.room_id
- , room_name: options.room_name
- , hotel_name: options.hotel_name,
- pageStatus: 0
- })
- },
- bindNotesInput: function (e) {
- this.setData({
- notesInput: e.detail.value
- });
- console.log(this.data.notesInput)
- },
- onClose() {
- this.setData({
- show1: false, show2: false
- });
- },
- onShow() {
- this.setData({
- pageStatus: 0
- , notesInput: ''
- , deviceList: []
- , logsInfo: {}
- , roomInfo:{}
- });
- },
- onShow1() {
- this.setData({
- show1: true
- });
- },
- onShow2(text=null) {
- this.setData({
- show2: true,
- show2Text: text
- });
- },
- onStartInspection() {
- api.startCheck({
- params: {room_id: this.data.room_id},
- headers: {unionid: wx.getStorageSync("unionid")},
- })
- .then(data => {
- if (data.code === 1) {
- wx.showToast({
- icon: 'none',
- title: "开始巡检",
- });
- this.setData({
- deviceList:[],
- logsInfo: {},
- roomInfo:{}
- })
- this.getNucEquips()
- this.setData({pageStatus: 1});
- } else {
- this.onShow2(data.info|| "巡检异常请联系管理员")
- }
- })
- .catch(err => {
- this.onShow2("巡检异常请联系管理员")
- });
- }
- ,
- getNucEquips() {
- api.nucEquips({
- params: {room_id: this.data.room_id},
- headers: {unionid: wx.getStorageSync("unionid")}
- }).then(data => {
- if (data.code === 1) {
- var logs = data.data.logs|| {};
- this.setData({
- deviceList: logs.inspection || [],
- logsInfo:logs,
- roomInfo:data.data.room||{}
- })
- }else{
- this.onShow2(data.info|| "获取设备列表失败,请联系管理员!")
- }
- }).catch(err => {
- this.onShow2("获取设备列表失败,请联系管理员!")
- });
- },
- onConfirm() {
- api.confirm({
- body: {note: this.data.notesInput,id: this.data.logsInfo.id},
- headers: {unionid: wx.getStorageSync("unionid")}
- }).then(data => {
- if (data.code === 1) {
- this.setData({
- pageStatus: 0
- , notesInput: ''
- , deviceList: []
- , logsInfo: {}
- , roomInfo:{}
- });
- }else{
- this.onShow2(data.info|| "提交失败,请联系管理员!")
- }
- }).catch(err => {
- this.onShow2( "提交失败,请联系管理员!")
- });
- this.onClose()
- },
- onClosePage() {
- this.onConfirm()
- wx.navigateBack({
- delta: 1
- });
- },
- onSubmit() {
- api.inspect({
- body: {inspection: this.data.deviceList,id: this.data.logsInfo.id},
- headers: {unionid: wx.getStorageSync("unionid")}
- }).then(data => {
- if (data.code === 1) {
- let { count =0,normal=0,abnormal=0, inspection=[]} =data.data||{}
- wx.showToast({
- icon: 'none',
- title: data.info|| "提交成功!",
- });
- this.setData({
- pageStatus: 2,
- count,
- normal,
- abnormal,
- abnormal_d_name: inspection.map(item => item.entity_name).join(',') || '--'
- });
- }else{
- this.onShow2(data.info|| "提交失败,请联系管理员!")
- }
- }).catch(err => {
- this.onShow2("提交失败,请联系管理员!")
- });
- },
- setDeviceStats(e) {
- let {index, status} = e.currentTarget.dataset
- this.setData({
- [`deviceList[${index}].checked`]: status
- })
- }
- });
|