<template>
  <div class="auto">
    <criteria-paged :model="model"  v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div partial>
          <form>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">计划名称：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font"  v-model="model.f_plan_name" condition="f_plan_name like '%{}%'" placeholder="请输入计划名称（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">计划送气员：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font"  v-model="model.f_checker" condition="f_checker like '%{}%'" placeholder="请输入计划送气员（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户电话.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">计划年份：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font"  v-model="model.f_plan_year" condition="f_plan_year = '{}'" placeholder="请输入计划年份">
              </div>
            </div>
            <div class="row text-center" style="margin-top: 20px;">
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 45%;" @click="search">查询</button>
            </div>
            <div style="height:30px;"></div>
          </form>
        </div>
      </criteria>

      <list :model="model" partial='list'>
        <div partial>
          <div @click="$parent.$parent.$parent.inspect(row)" class="auto app-text" style="margin-top: 5px;">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self">
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">计划名称</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_plan_name }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">计划类型</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_plan_type }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">计划年份</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_plan_year }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">创建时间</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_create_time }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">计划数量</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.plan_count }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">计划送气员</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_checker }}</p>
                </div>
                <div class="row" v-if="row.f_back_remark">
                  <p class="panel-title col-xs-4 text-left font">退回备注</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_back_remark }}</p>
                </div>
                <div class="row">
                  <button type="button" name="button" class="btn btn-primary" style="background-color:#499edf;float: right" @click="$parent.$parent.$parent.sendCheckPlan(row)">领取</button>
                </div>
              </div>
            </div>

          </div>
        </div>
      </list>
    </criteria-paged>
    <back-page :need-back='true'   @flag="$back()"></back-page>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  import Vue from 'vue'

  export default {
    title: '安检员B',
    data () {
      let model = new PagedList(`${this.$androidUtil.getProxyUrl()}/rs/sql/getAirNoDistribute`, 20, {})
      model.f_sign = ['']
      model.f_user_type = ''
      model.f_user_state =['']
      model.f_check_type =['']
      model.myCycle = 0
      model.fyCycle = 0
      model.f_filialeid = Vue.user.orgid
      return {
        model: model,
        showModal:false,
        signs: [
          {label:'请选择录入状态', value:''},
          {label:'录入', value:'1'},
          {label:'非录入', value:'0'},
        ],
        plan_type: [
          {label: '请选择用户类型', value: ''},
          {label: '民用', value: '民用'},
          {label: '非民用', value: '非民用'},
        ],
        f_user_states: [
          {label:'请选择档案状态', value:''},
          {label:'正常', value:'正常'},
          {label:'点火', value:'点火'},
        ],
        f_check_types: [
          {label:'请选择安检类型', value:''},
          {label:'应检', value:'应检'},
          {label:'超期', value:'超期'},
        ],
      }
    },
    ready () {
    },
    computed: {
      reload(){
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
      },
      selected () {
        return this.$refs.paged.$refs.grid.selected
      }
    },
    methods:{
      async sendCheckPlan(f){
        //
        let checks=[]
        checks[0]=f.id
        let res = this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/NewBespeakCheckPlan`, {
          data:{
            f_issued:'是',
            f_issue_time:this.getNowFormatDate(),
            f_send_operator:Vue.user.name,
            f_check_id:Vue.user.id,
            param:checks,
          }
        }, {resolveMsg: null, rejectMsg: null}).then((res)=>{
          //
          console.log('打印res',res.data.code)
          if(res.data.code==200){
            //Vue.showMessage("下发成功！其中有"+res.data.repet+"个计划己经是下发状态")
            Vue.showMessage("下发成功！")
          }else{
            Vue.showMessage("下发失败！")
          }
        })
      },
      //获取当前时间
      getNowFormatDate() {
        let date = new Date();
        let seperator1 = "-";
        let seperator2 = ":";
        let month = date.getMonth() + 1;
        let strDate = date.getDate();
        let hour = date.getHours();
        let min = date.getMinutes();
        let second = date.getSeconds();
        if (month >= 1 && month <= 9) {
          month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
          strDate = "0" + strDate;
        }
        if (hour >= 0 && hour <= 9) {
          hour = "0" + hour;
        }
        if (min >= 0 && min <= 9) {
          min = "0" + min;
        }
        if (second >= 0 && second <= 9) {
          second = "0" + second;
        }
        let currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
          + " " + hour + seperator2 + min
          + seperator2 + second;
        return currentdate;
      }
    }
  }
</script>
<style>
  .app-row {
    background-color: white;
    padding: 10px 10px 0 10px;
    border-bottom: 1px solid rgba(235, 235, 235, 0.5);
  }
  .search_input {
    border: 0;
    outline: none;
  }
  .font{
    font: 15px PingFang-SC-Medium;
    color: #666666;
  }
  .input-font{
    font: 15px PingFang-SC-Medium;
    color: #333333;
  }
  .btn-font{
    font:600 16px PingFang-SC-Bold;
    color: #499EDF;
  }
  .btn-color{
    background-color: #FFFFFF;
    border-radius: 10px ;
    border: 1px solid #499EDF;
  }
  .app-text {
    font-size: 12px;
  }
  .panel-self{
    border-radius: 10px;
    border:1px solid #499EDF;
    background-color: #F8F8F8;
  }
  .yybtn-color{
    border-radius: 4px ;
    border: 1px solid #499EDF;
  }
  .qxbtn-color{
    background-color: #FFFFFF;
    border-radius: 4px ;
    border: 1px solid #499EDF;
  }
</style>
