<template>
  <div>
    <van-sticky>
      <van-nav-bar title="工作计划" left-text="返回" left-arrow @click-left="$router.back()" />
    </van-sticky>
    <van-cell-group title="计划详情">
      <van-field
        v-model="device_info.name"
        label="计划名称"
        readonly
        input-align="right"
      />
      <van-field
        v-model="device_info.wind_name"
        label="风场名称"
        readonly
        input-align="right"
      />
      <van-field
        v-model="device_info.fan_number"
        label="风机机位号"
        readonly
        input-align="right"
      />
       <van-field
        v-model="device_info.work_sign_name"
        label="工作位置"
        readonly
        input-align="right"
      />
      <van-field
        v-model="device_info.parts_sign_name"
        label="所属部件"
        readonly
        input-align="right"
      />
      <van-field
        v-model="device_info.boit_type_sign_name"
        label="螺栓型号"
        readonly
        input-align="right"
      />
     
      <van-field
        v-model="device_info.status"
        label="状态"
        readonly
        input-align="right"
      />
       <van-field
        v-model="device_info.creat_name"
        label="创建人"
        readonly
        input-align="right"
      />
      <van-field
        v-model="device_info.created_at"
        label="创建时间"
        readonly
        input-align="right"
      />
    </van-cell-group>


    
    <van-form @submit="onSubmit">
     

   

      <div style="margin: 16px">
        <van-button
          round
          block
          type="info"
          size="small"
          native-type="submit"
        >下发计划</van-button
      >
      </div>
    </van-form>
  </div>
</template>

<script>
import Vue from "vue";
import {
  Form,
  Field,
  CellGroup,
  Button,
  Divider,
  RadioGroup,
  Radio,
  NavBar,
  Sticky,
} from "vant";

Vue.use(NavBar);
Vue.use(Form);
Vue.use(Field);
Vue.use(CellGroup);
Vue.use(Button);
Vue.use(Divider);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Sticky);

export default {
  data() {
    return {
      id: null, // 告警id
      rid: null, // 上报记录id
      alarm_info: {}, // 告警信息
      user_info: {}, // 设备用户信息
      device_info: {}, // 设备信息

      allowHandle: false,
      handleResult: "1",
      comment: "",
      handleTime: '',
      userid: null,
    };
  },
  created() {
    this.openid = localStorage.getItem("openid");
    this.userid = localStorage.getItem("yysUserid");

    this.id = this.$route.query.id;
    this.rid = this.$route.query.rid;
    this.getDetail();
  },
  methods: {
    // 获取告警详情
    getDetail() {
      let url = 'getAlarmDetail&openid='+this.openid+'&userid='+this.userid+'&id='+this.id+'&rid='+this.rid;
       let resp={
        status:200,
        data:{
          success:true,
          message:"获取成功",
          data: {"id":"79","name":"工作计划1","wind_name":"国家电投滨海北区H1海上风电场","fan_number":"A0005B","work_sign_name": "机座—主梁（中）","parts_sign_name": "轮毂","boit_type_sign_name":"M48","status":"启用","creat_name":"员工1","created_at":"2022-07-11 15:20:24"}
        }
      }
      // this.$http .get(url).then((resp) => {
          if (resp.status === 200 && resp.data && resp.data.success) {
            this.device_info = resp.data.data;

          }
        // }).catch((err) => {
        //   this.$notify({ type: "warning", message: "获取数据失败" });
        // });
    },
    onSubmit(vals) {
      let data = {
        id: this.id,
        result: vals.result,
        comment: vals.comment,
      };

      // this.$http.post('handleAlarm&openid='+this.openid+'&userid='+this.userid, JSON.stringify(data))
      //   .then((resp) => {
      //     if (resp.status === 200 && resp.data && resp.data.success) {
      //       this.$notify({ type: "success", message: resp.data.message });
      //       this.$router.back();
      //     } else {
      //       this.$notify({ message: resp.data.message });
      //     }
      //   })
      //   .catch((err) => {
      //     this.$notify({ type: "warning", message: "出错了" });
      //   });
    },
  },
};
</script>

<style scoped="less">
.van-cell-group__title {
  /* text-align: left; */
}
</style>