<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 col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input class="search_input input-font"
                       v-model=model.f_card_id condition="f_card_id = '{}'" placeholder="请输入卡号" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input class="search_input input-font"
                       v-model=model.f_meternumber condition="f_meternumber = '{}'" placeholder="请输入卡号" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户名称：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input class="search_input input-font" v-model="model.f_username" condition="f_user_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" >-->
<!--                <v-select :value.sync="$parent.$parent.model.f_user_type" class="input-font"-->
<!--                          :options='$parent.$parent.user_types' placeholder='请选择用户类型' :value-single="true"-->
<!--                          v-model="$parent.$parent.model.f_user_type" close-on-select clear-button></v-select>-->
<!--              </div>-->
<!--            </div>-->
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">小区名称：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_residential_area"
                       condition="ud.f_residential_area like '%{}%'" placeholder="请输入用户小区（可模糊查询）">
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_building"
                       condition="ud.f_building like '%{}%'" placeholder="请输入用户楼号">
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_unit"
                       condition="ud.f_unit like '%{}%'" placeholder="请输入用户单元">
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户地址：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_address"
                       condition="ud.f_address like '%{}%'" placeholder="请输入用户地址（可模糊查询）">
              </div>
            </div>
            <!--<div class="row col-xs-12 col-sm-6 col-md-6 app-row">-->
              <!--<div class="col-xs-4 col-sm-4 col-md-4">-->
                <!--<img src="../../assets/安检状态.png" style="width: 20px;margin-bottom: 5px" alt="">-->
                <!--<label class="font text-left">用户状态：</label>-->
              <!--</div>-->
              <!--<div class="col-xs-8 col-sm-8 col-md-8-8" >-->
                <!--<v-select class="input-font"-->
                          <!--placeholder='请选择用户状态'-->
                          <!--:value.sync="model.f_table_state"-->
                          <!--:options='$parent.$parent.f_table_states'-->
                          <!--v-model="model.f_table_state"-->
                          <!--close-on-select clear-button></v-select>-->
              <!--</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" >-->
                <!--<v-select class="input-font"-->
                          <!--placeholder='请选择安检类型'-->
                          <!--:value.sync="$parent.$parent.model.f_check_type"-->
                          <!--:options='$parent.$parent.f_check_types'-->
                          <!--close-on-select clear-button></v-select>-->
              <!--</div>-->
            <!--</div>-->

            <div class="row col-xs-12 col-sm-12 col-md-6 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 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 col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_card_id }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">用户名称</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_user_name }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">用户类型</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8-8 text-left input-font">{{ row.f_user_type }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">用户状态</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8-8 text-left input-font">{{ row.f_table_state }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">开户状态</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8-8 text-left input-font">{{ row.archives_state }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">用户电话</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone }}</p>
                </div>

                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">小区名称</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_residential_area }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4-4 text-left font">用户地址</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_address }}</p>
                </div>
                <div class="row col-xs-12 col-sm-12 col-md-6 text-right">
                  <button type="button" class="btn scbtn-color" v-on:click.stop.prevent='$parent.$parent.$parent.creatPlan(row)'>生成计划</button>&nbsp;
                </div>
                <!--<div class="row col-xs-12 col-sm-6 col-md-6">-->
                  <!--<p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">最后安检日期</p>-->
                  <!--<p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_last_check_date }}</p>-->
                <!--</div>-->
                <!--<div class="row col-xs-12 col-sm-6 col-md-6">-->
                  <!--<p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">最后安检状态</p>-->
                  <!--<p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_last_check_state }}</p>-->
                <!--</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/FetchOpenUser`, 20, {})
      // model.f_filialeids = Vue.user.f_orgids
      return {
        model: model,
        showModal:false,
        user_types: [
          {label: '请选择用户类型', value: ''},
          {label: '民用', value: '民用'},
          {label: '非民用', value: '非民用'},
        ],
        f_table_states: [
          {label:'请选择档案状态', value:''},
          {label:'正常', value:'正常'},
          {label:'停用', value:'停用'},
        ],

      }        // f_check_types: [
      //   {label:'请选择安检类型', value:''},
      //   {label:'应检', value:'应检'},
      //   {label:'超期', value:'超期'},
      // ],
    },
    ready () {
    //   this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/getSafeCheckCycle`,{},{resolveMsg: null, rejectMsg: null}).then((res) => {
    //     console.log(JSON.stringify(res))
    //   if(res.data.code == 200){
    //     this.model.myCycle = res.data.civil.value
    //     this.model.fyCycle = res.data.civilian.value
    //   }else{
    //     self.$showMessage(res.data.msg)
    //   }
    // })
    },
    computed: {
      reload(){
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
      },
      selected () {
        return this.$refs.paged.$refs.grid.selected
      }
    },
    methods:{
      inspect (info){
        info.id = ''
        info.f_state = '未检'
        info.f_no_checkplan = '无计划安检'
        console.log(info)
        if(info.f_user_type == '民用') {
          this.$goto('paper-set', {item: info, role: 'inspect'}, 'self', this.reload)
        } else {
          this.$goto('paper-set-noncivil', { item: info, role: 'inspect'}, 'self', this.reload)
        }
      },
      creatPlan(row){
        this.$showMessage('确定生成预约开户计划吗？生成后无法撤销',['confirm', 'cancel']).then((res)=>{
          if(res === 'confirm'){
            let data = {
              f_plan_type:'预约开户计划',
              f_address:row.f_address,
              f_user_name:row.f_user_name,
              f_user_phone:row.f_user_phone,
              f_card_id:row.f_card_id,
              f_is_phone:'是',
              f_checker:Vue.user.name,
              f_address:row.f_address
            }
            this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/orderPlan`,{data:data}).then((res)=>{
              console.log('res====>'+JSON.stringify(res))
              if(res.data.code == 200){
                this.$showMessage('预约开户计划生成成功！')
              }else{
                this.$showMessage('预约开户计划生成失败！')
              }
            })
          }
        })
      }
    },
  }
</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;
  }
  .scbtn-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 ;
    border: 1px solid #499EDF;
  }
</style>
