<template>
  <div class="flex-row" v-if="!showdetail">
    <div id='app1' class="basic-main" v-show="(!echarts)&&(!isActiveTotalForm)">
      <criteria-paged :model="model" :pager='true' v-ref:paged>
        <criteria partial='criteria' @condition-changed='$parent.search' v-ref:cri>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" novalidate partial>
            <div class="row">
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">客户编号</label>
                <input @keyup.enter="search" style="width:60%" type="text" class="input_search"
                       v-model="model.f_userinfo_code" placeholder='客户编号'
                       condition="f_userinfo_code like '%{}%'" v-el:xq v-next-el='userinfocode' v-el:username
                >
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">客户名称</label>
                <input @keyup.enter="search" style="width:60%" type="text" class="input_search"
                       v-model="model.f_user_name" placeholder='客户名称'
                       condition="f_user_name like '%{}%'" v-el:xq v-next-el='username' v-el:username
                >
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">表号</label>
                <input @keyup.enter="search" style="width:60%" type="text" class="input_search" v-model="model.f_meternumber"
                       placeholder='表号'
                       condition="f_meternumber like '%{}%'" v-el:xq v-next-el='address' v-el:area
                >
              </div>
              <div style="float:right">
                <button class="button_search button_spacing" @click="search()">查询</button>
                <button class="button_clear button_spacing" @click="$parent.$parent.clearmsg">清空</button>
                <export-excel :data="$parent.$parent.getCondition" class="button_export button_spacing"
                              :field="$parent.$parent.getfield"
                              sqlurl="rs/logic/exportfile" sql-name="warningexcerption" template-name='黑名单分析'
                              :choose-col="true"></export-excel>
    <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
              </div>
            </div>
            <div class="row" v-show="$parent.$parent.criteriaShow">
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">&nbsp;&nbsp;&nbsp;公司&nbsp;&nbsp;&nbsp;</label>
                <right-tree @re-res="$parent.$parent.getorg"
                            :initresid='$parent.$parent.org'></right-tree>
              </div>

              <div class="col-sm-2 form-group">
                <label class="font_normal_body">开始录入时间</label>
                <datepicker style="width:60%" id="startdate" placeholder="开始时间"
                            v-model="model.startDate"
                            :value.sync="model.startDate"
                            :disabled-days-of-Week="[]"
                            :format="'yyyy-MM-dd HH:mm:ss'"
                            :show-reset-button="reset">
                </datepicker>
              </div>

              <div class="col-sm-2 form-group">
                <label class="font_normal_body">结束录入时间</label>
                <datepicker style="width:60%" id="endate" placeholder="开始时间"
                            v-model="model.endDate"
                            :value.sync="model.endDate"
                            :disabled-days-of-Week="[]"
                            :format="'yyyy-MM-dd HH:mm:ss'"
                            :show-reset-button="reset">
                </datepicker>
              </div>

            </div>

          </div>
        </criteria>
        <data-grid id="lostuserlist" :model="model" partial='list' v-ref:grid class="list_area table_sy">
          <template partial='head'>
            <tr>
              <th style="text-align:center">
                <nobr>序号</nobr>
              </th>
              <th style="text-align:center">
                <nobr>客户编号</nobr>
              </th>
              <th style="text-align:center">
                <nobr>客户名称</nobr>
              </th>
              <th style="text-align:center">
                <nobr>表号</nobr>
              </th>
              <th style="text-align:center">
                <nobr>异常类型</nobr>
              </th>
              <th style="text-align:center">
                <nobr>异常级别</nobr>
              </th>
              <th style="text-align:center">
                <nobr>异常说明</nobr>
              </th>
              <th style="text-align:center">
                <nobr>录入时间</nobr>
              </th>
            </tr>

          </template>
          <template partial='body'>
            <td style="text-align:center">{{$index+1}}</td>
            <td style="text-align: center;"><nobr>
              <span @click="$parent.$parent.$parent.showmsg(row)"><a>{{row.f_userinfo_code}}</a></span>
            </nobr> </td>
            <td style="text-align:center"><nobr>{{row.f_user_name}}</nobr></td>
            <td style="text-align:center"><nobr>{{row.f_meternumber}}</nobr></td>
            <td style="text-align:center"><nobr>{{row.f_error_type}}</nobr></td>
            <td style="text-align:center"><nobr>{{row.f_error_level}}</nobr></td>
            <td style="text-align:center"><nobr>{{row.f_error_msg}}</nobr></td>
            <td style="text-align:center"><nobr>{{row.f_insert_date}}</nobr></td>

          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  import UserGasEcharts from './UserGasEcharts'
  import * as Util from '../../../Util'
  import plugin from 'system-clients/src/plugins/GetLoginInfoService'

  let readySomething = async function (self) {

    await self.$MagLoadParams.loadParam()
    let year = new Date().getFullYear()
    self.$refs.paged.$refs.cri.model.startDate =Util.toStandardDateString() + ' 00:00:00'
    // self.$refs.paged.$refs.cri.model.startDate = Util.toStandardDateString() + ' 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate  = Util.toStandardDateString() + ' 23:59:59'
    self.$refs.paged.$refs.cri.search()
  }
  export default {
    title: '黑名单分析',
    props: ['data'],
    components: {UserGasEcharts},
    data() {
      return {
        model: new PagedList('rs/sql/warningexcerption', 20, {
          startDate: 'this.model.startDate',
          endDate: 'this.model.endDate'
        }),
        getfield:{
          "f_userinfo_code":"客户编号","f_user_name":"客户名称",
          "f_meternumber":"表号","f_error_type":"异常类型","f_error_level":"异常级别",
          "f_error_msg":"异常说明","f_insert_date":"录入时间"},
        reportStr: null,
        show: false,
        startDate: '',
        endDate: '',
        criteriaShow:false,
        outlets: [],
        meterbrands:[],
        filename: '',
        orgCondtionStr: `and ex.F_ERROR_TYPE = \'拆表报警\' and ex.f_orgid = ${this.$login.f.orgid}`,
        echarts: false,
        orgid:[this.$login.f.orgid],
        searchshow: false,
        isActiveTotalForm: false,
        condition: '1=1',
        groupname: ['max_days_type'],
        org:[this.$login.f.orgid]

      }
    },
    ready() {
      readySomething(this)
    },
    methods: {
      hidden(){
        this.criteriaShow = !this.criteriaShow
      },
      search(args) {
        this.startDate = this.$refs.paged.$refs.cri.model.startDate
        this.endDate = this.$refs.paged.$refs.cri.model.endDate
        args.condition = this.$refs.paged.$refs.cri.condition + `${this.orgCondtionStr}`
        this.model.search(args.condition, args.model)
      },
      getorg(obj) {
        console.log('obj====>',obj)
          this.orgCondtionStr = "and ex.F_ERROR_TYPE = \'拆表报警\'  and ex.f_orgid = " + obj.resids
      },
      clearmsg() {
        this.$refs.paged.$refs.cri.model = {}
      }
    },
    watch: {
      'data'(val) {
        if (val.f_files_path) {
          this.getFileContent(val.f_files_path)
        } else {
          this.reportStr = null
        }
      }
    },
    computed: {

      getCondition() {
        let condition=this.$refs.paged.$refs.cri.condition + this.orgCondtionStr
        return {
          condition: condition  ,
          startDate:`${this.$refs.paged.$refs.cri.model.startDate}`,
          endDate:`${this.$refs.paged.$refs.cri.model.endDate}`
        }

      }
    }
  }
</script>
<style>
  .form-input-group label {
    text-align: right;
    width: auto;
  }

  .mystyle {
    float: right;
    padding-right: 10%;
  }

  .mystyle1 {
    padding-top: 10px;

  }

  .mystyle2 {
    width: 100%;
    height: 35px;
    /*background: #00A3F0;*/
    padding-left: 15px;
    float: left;
  }

  .datapanel {
    color: #333;
    background-color: white;
    box-shadow: darkgrey 0.5px 0.5px 0.5px 0.5px;
    padding: 10px 30px 10px 30px;
    border-radius: 15px;
  }
</style>
