<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 style="height: auto;width: 100%">
    <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 '%{}%'" />
              </div>
            </div>
            <div class="row text-center" style="margin-top: 20px;">
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%;" @click="$parent.$parent.selfSearch">查询</button>
              <img style="float: right;margin-right: 3% " @click="$parent.$parent.getNewOrder" src="../../assets/shuaxindaiban1.png" style="width: 40px;padding: 5px; float:right">
              <!--              <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  class="auto app-text" style="margin-top: 5px;">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self" @click="$parent.$parent.$parent.toPlanItem(row.f_plan_name)">
                <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: 74%">{{ row.f_plan_name }}</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_create_time }}</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.checked }}
                  </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.no_check }}</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.checked + row.no_check }}</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.checked / (row.checked + row.no_check))) * 100).toFixed(0) + '%' }}
                  </p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>
  </div>
</template>

<script>

import Vue from 'vue'
import LocalPagedList from "./LocalPagedList";

export default {
  title: '安检计划列表',
  data() {
    return {
      f_orgid: Vue.user.orgid,
      model:new LocalPagedList( `androidCheckPlanList`,20, {condition:'this.condition'}),
      criteriaShow: false
    }
  },
  ready(){
  },
  methods: {
    search(args) {
      // args.condition += ` and tu.f_orgid in ${Vue.user.orgid}`
      this.model.search(args.condition, args.model)
    },
    selfSearch () {
      let condition = "1=1 "
      if(this.$refs.paged.$refs.cri.model.f_plan_name){
        if(this.$refs.paged.$refs.cri.model.f_plan_name.toString().trim()){
          condition += " and f_plan_name like '%"+this.$refs.paged.$refs.cri.model.f_plan_name+"%'"
        }
      }
      console.log('condition ===> '+ condition)
      this.model.search(condition)
    },
    toPlanItem(planName) {
      this.$dispatch('gotoson', {
        _this: this,
        title: '计划列表',
        safe: false
      })
      this.$goto('current-create', {planName})
    },
    getNewOrder(){
      HostApp.__this__ = this
      HostApp.logicWithHint({
        // logic别名，key必须为logic
        'logic': 'SafeCheckServiceTimeOut',
        // 回调执行方法名，key必须为callback
        'callback': 'javascript:HostApp.__this__.getNewOrderCallBack()',
        // logic执行需要的业务参数
        'data': {params: ''},
        // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
        // 执行回调方法传入key为backresult
        // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
        'backresult': 1
      })
    },
    getNewOrderCallBack() {
      this.selfSearch()
    },
    hidden() {
      this.criteriaShow = !this.criteriaShow
    }
  }
}
</script>
