<style scoped>
  .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;
  }
</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="$parent.$parent.f_userinfo_code" />
              </div>
            </div>
            <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="$parent.$parent.f_user_name" />
              </div>
            </div>
            <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_meternumber" class="font text-left">用户表号：</label>
              </div>
              <div class="col-xs-8" >
                <input id="f_meternumber" class="search_input input-font" v-model="$parent.$parent.f_meternumber" />
              </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  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="float: left"><b>用户编号:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_userinfo_code }}</p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title col-xs-5 text-left font" style="float: left"><b>用户名称:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_user_name }}</p>
                </div>
                <div class="col-xs-12">
                  <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_user_type }}
                  </p>
                </div>
                <div class="col-xs-12">
                  <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_user_phone }}
                  </p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title text-left font" style="float: left"><b>用户地址:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" >{{ row.f_address }}</p>
                </div>
                <div class="col-xs-12">
                  <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_meternumber }}</p>
                </div>
                <div class="col-xs-12">
                  <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_aroundmeter }}</p>
                </div>
                <div class="col-xs-12">
                  <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_meter_brand }}</p>
                </div>
                <div class="col-xs-12">
                  <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_meter_type }}</p>
                </div>
                <div class="col-xs-12">
                  <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_table_state }}</p>
                </div>
                <div class="col-xs-6" >
                  <button class="btn  btn-font btn-color" type="button" style="width: 28%;padding: 2px 5px;" v-if="row.f_table_state === '停用'" @click="$parent.$parent.$parent.openvalve(row)">启用</button>
                  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
                  <button class="btn  btn-font btn-color" type="button" style="width: 28%;padding: 2px 5px;" v-if="row.f_table_state === '正常'" @click="$parent.$parent.$parent.clonevalve(row)">停用</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>
  </div>
</template>

<script>
  import LocalPagedList from '../../plugins/LocalPagedList'
  import Vue from 'vue'
  import { PagedList } from 'vue-client'
  import { HttpResetClass } from 'vue-client'
export default {
  title: '在线停启用',
  data () {
    return {
      model:new PagedList(`${this.$androidUtil.getProxyUrl()}/rs/sql/stopSeachUser`,9999),
      f_operator: Vue.user.name,
      filialeid: Vue.user.orgid,
      f_user_name:'',
      f_userinfo_code:'',
      f_meternumber:'',
    }
  },
  ready () {
  },
  methods: {
    selfSearch () {
      let condition =  ` 1=1 `
      condition += this.f_userinfo_code ? ` and  ui.f_userinfo_code like '${this.f_userinfo_code}%'` : ""
      condition += this.f_user_name ? `     and  ui.f_user_name like '${this.f_user_name}%'` : ""
      condition += this.f_meternumber ? `   and  uf.f_meternumber like '${this.f_meternumber}%'` : ""
      this.model.search(condition)
    },
    openvalve (val) {
      this.$showMessage('确认启用吗？', ['confirm', 'cancel']).then((res) => {
        if (res === 'confirm') {
          let http = new HttpResetClass()
          let  table = `update t_userfiles  set f_table_state='正常' where f_userfiles_id=${val.f_userfiles_id}`
          http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/runSQL`, {data: {sql: table}},
            {resolveMsg: null, rejectMsg: '启用失败'})

        }
        this.selfSearch()
      })
    },
    clonevalve (val) {
      this.$showMessage('确认停用吗？', ['confirm', 'cancel']).then((res) => {
        if (res === 'confirm') {
          let http = new HttpResetClass()
          let  table = `update t_userfiles  set f_table_state='停用' where f_userfiles_id=${val.f_userfiles_id}`
          http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/runSQL`, {data: {sql: table}},
            {resolveMsg: null, rejectMsg: '停用失败'})
        }
        this.selfSearch()
      })
    },
  },
  components: {
  }
}
</script>
