<style scoped>
.bg {
  background-color: blue;
  height: 1px;
  border: 0;
}
.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{
  background-color:#499edf;
  border-radius: 4px ;
  border: 1px solid #499EDF;
  color: #FFFFFF;
  font: 14px PingFang-SC-Bold;
}
.qxbtn-color{
  background-color: #FFFFFF;
  border-radius: 4px ;
  color: #499edf;
  font: 14px PingFang-SC-Bold;
  border: 1px solid #499EDF;
}
.button_shrink_top {width: 35px; height: 35px; background-size:100%;background-image: url("../../../static/newStyle/stretch_top.png")}
.button_shrink_bottom {width: 35px; height: 35px;  background-size:100%;background-image: url("../../../static/newStyle/stretch_bottom.png")}
.button_shrink_left {width: 35px; height: 35px;  background-size:100%;background-image: url("../../../static/newStyle/stretch_left.png")}
.button_shrink_right {width: 35px; height: 35px; background-size:100%;background-image: url("../../../static/newStyle/stretch_right.png")}

</style>
<template>
  <div class="auto">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div partial>
          <form>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_userinfo_code" class="font text-left">用户编号：</label>
              </div>
              <div class="col-xs-8" >
                <input id="f_userinfo_code" class="search_input input-font"
                       v-model=model.f_userinfo_code condition="f_userinfo_code like '%{}%'" />
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_user_name" class="font text-left">用户姓名：</label>
              </div>
              <div class="col-xs-8" >
                <input id="f_user_name" class="search_input input-font"
                       v-model=model.f_user_name condition="f_user_name like '%{}%'" />
              </div>
            </div>
            <div class="row app-row" v-show="$parent.$parent.criteriaShow">
              <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_address condition="f_address like '%{}%'" />
              </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 style="float: right;margin-right: 3% " class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"  @click="$parent.$parent.hidden()"></div>
            </div>
            <div style="height:30px;"></div>
          </form>
        </div>
      </criteria>
      <list :model="model" partial='list'>
        <div partial>
          <div @click="$parent.$parent.$parent.inspectBefore(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="col-xs-12">
                  <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户编号:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" style="width: 79%">{{ row.f_userinfo_code }}</p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户名称:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" style="width: 79%">{{ row.f_user_name }}</p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>用户类型:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_check_type }}
                  </p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title text-left font" style="width: 23%;float: left"><b>用户电话:</b></p>
                  <p class="panel-title text-left input-font" style="width: 77%">{{ row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone }}
                    <img src="../../assets/phone.png" style="width: 6%" v-on:click.stop.prevent='$parent.$parent.$parent.makeAPhoneCall(row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone)'></img>
                  </p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title text-left font" style="width: 21%;float: left"><b>用户地址:</b></p>
                  <p class="panel-title text-left input-font" style="width: 79%">{{ row.f_address }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font"><b>有无计划</b></p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_no_checkplan }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_approved == '不通过'">
                  <p class="panel-title col-xs-5 text-left font" style="color: red;"><b>未通过原因:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_approved_note }}</p>
                </div>
                <div class="col-xs-12" v-show="row.f_approved == '不通过'">
                  <p class="panel-title col-xs-5 text-left font" style="color: red;"><b>审核时间:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_approved_time }}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>
  </div>
</template>
<script>
import Vue from 'vue'
import { PagedList } from 'vue-client'
import * as Util from '../Util'
export default {
  title: '安检计划项',
  data() {
    let model = new PagedList(`${this.$androidUtil.getProxyUrl()}/rs/sql/getCheckPaper`, 20)
    return {
      model: model,
      showModal: false,
      param: null,
      criteriaShow: false,
      f_preset_dt : Util.to3339TimeString(),
      approveds:[
        {label: '不通过', value: '不通过'}
      ],
      flow_direction:[
        {label: '全部', value: ''},
        {label: '左表', value: '左表'},
        {label: '右表', value: '右表'}
      ],
      isends: [
        {label: '请选择完成状态', value: ''},
        {label: '未完成', value: '( tcp.f_check_version = 1 or tcp.f_check_version = 2 )'},
        {label: '已完成', value: 'tcp.f_check_version is null'},
      ],
      check_states: [
        {label: '请选择安检状态', value: ''},
        {label: '未检', value: '未检'},
        {label: '已检', value: '已检'},
      ],
      last_check_states: Vue.$appdata.getParam('安检状态'),
      upload_states: [
        {label: '请选择上传状态', value: ''},
        {label: '未传', value: '未传'},
        {label: '已传', value: '已传'}
      ],
      user_types: [
        {label: '请选择用户类型', value: ''},
        {label: '民用', value: '民用'},
        {label: '非民用', value: '非民用'},
      ],
      verify_state: [
        {label: '请选择审核状态', value: ''},
        {label: '未审核', value: '未审核'},
        {label: '打回', value: '打回'}
      ],
      planstates:[
        {label: '请选择有无安检计划', value: ''},
        {label: '有计划安检', value: '有计划安检'},
        {label: '无计划安检', value: '无计划安检'},
      ],
      defectcontents:[
        {label: '请选择有无安检隐患', value: ''},
        {label: '有隐患', value: '有隐患'},
        {label: '正常', value: '正常'},
      ]
    }
  },
  ready(){
    this.$refs.paged.$refs.cri.model.f_state = '已检'
  },
  methods: {
    refresh() {
      this.$refs.paged.$refs.cri.search()
    },
    reload(){
      this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
    },
    inspectBefore(row) {
      //查询本地f_check_item_id
      if(Vue.android) {
        let result =  this.$androidUtil.bzLogic('getLocalCheckPaper', {id: row.f_check_item_id})
        if(result.data.length > 0){
          this.inspect(result.data[0])
        }else {
          this.$showMessage("安检数据获取失败,数据已被清除")
        }
      }
    },
    inspect(row) {
      this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/sql/查询计划项表信息`, {data: {f_userid: row.f_userinfoid}},{resolveMsg: null,rejectMsg: null}).then((response) => {
        row['f_plan_meters'] = response.data
        var pardate = {
          _this:this,
          tittle:'安检已办',
          safe:true
        }
        this.$dispatch('gotoson',pardate)
        this.$goto('safecheck-order-v', {f_plan_id: row.f_plan_id, item: row, role: 'inspect'}, 'self', this.reload)
      }).catch((err)=>{
        //网络异常调用本地数据
        let criteria = {
          items: '*',
          tablename: 't_plan_item_meter',
          condition: `f_plan_item_id = '${row.id}'`,
          groupitem: 'f_plan_item_id'
        }
        let result = HostApp._executeTask({'type':'sql', 'data':{'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}})
        if(result.code == 200){
          row['f_plan_meters'] = result.data.rows
          var pardate = {
            _this:this,
            tittle:'安检已办',
            safe:true
          }
          this.$dispatch('gotoson',pardate)
          this.$goto('safecheck-order-v', {f_plan_id: row.f_plan_id, item: row, role: 'inspect'}, 'self', this.reload)
        }
      })

    },
    makeAPhoneCall(phoneNumber) {
      this.$androidUtil.makeAPhoneCall(phoneNumber)
    },
    reserve (idx) {
      this.param = idx
      this.showModal = true
    },
    selfSearch (args) {
      args.condition += ` and  f_checker_id='${Vue.user.id}'`
      this.model.search(args.condition,args.model)
    },
    hidden() {
      this.criteriaShow = !this.criteriaShow
    }
  }
}
</script>
