<template>
  <div id='app' class="basic-main" style="height: 100%">
    <criteria-paged :model="model" :pager='false'>
      <criteria partial='criteria' @condition-changed='search' class="search_area">
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="col-sm-4 form-group">
              <role-selector-safe
                role-name="安检员"
                role-lable="安&ensp;检&ensp;员"
                @re-res="$parent.$parent.getRes"
                :value.sync="model.f_checker_id"
                v-model="model.f_checker_id"
                condition="f_checker_name like '%{}%'">
              </role-selector-safe>
            </div>
            <div class="col-sm-2 form-group">
              <label for="startDate" class="font_normal_body">开始日期:</label>
              <datepicker id="startDate" placeholder="开始日期"
                          v-model="model.startDate"
                          :value.sync="model.startDate"
                          style="width: 60%;"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd 00:00:00'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2 form-group">
              <label for="endDate" class="font_normal_body">结束日期:</label>
              <datepicker id="endDate" placeholder="结束日期"
                          v-model="model.endDate"
                          :value.sync="model.endDate"
                          :disabled-days-of-Week="[]"
                          style="width: 60%;"
                          :format="'yyyy-MM-dd 23:59:59'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-4 form-group" style="margin-top: 8px">
              <button class="button_search button_spacing" @click="search()">查询</button>
              <report-print class="button_export button_spacing" style="width:28%" id='shexian'></report-print>
              <report-excel class="button_export button_spacing" style="width:28%" id='shexian'></report-excel>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-2 form-group" >
              <label class="font_normal_body">用气性质</label>
              <v-select
                class="select_list select"
                placeholder='用气性质' style="width: 60%"
                v-model='model.userType'
                :value.sync="model.userType"
                :options='$parent.$parent.userTypes'
                condition="tuf.f_gasproperties in {} "
                :multiple="true"
               ></v-select>
            </div>
            <div class="col-sm-2 form-group" >
              <label class="font_normal_body">客户类型</label>
              <v-select :value.sync="model.aaa" v-model="model.aaa"
                        :value-single="false" clear-button :options='$parent.$parent.user_types' placeholder='客户类型'
                        condition="tuf.f_user_type = '{}' "></v-select>
            </div>
            <div class="col-sm-2 form-group" >
              <label class="font_normal_body">气表类型</label>
              <v-select
                class="select_list select"
                placeholder='气表类型' style="width: 60%"
                v-model='model.tableType'
                :value.sync="model.tableType"
                :options='$parent.$parent.tableTypes'
                condition="tuf.f_meter_classify = '{}'"
                :value-single="true"
                close-on-select clear-button></v-select>
            </div>
            <div class="col-sm-2 form-group" >
              <label class="font_normal_body">气表品牌</label>
              <v-select
                class="select_list select"
                placeholder='气表类型' style="width: 60%"
                v-model='model.tableBrand'
                :value.sync="model.tableBrand"
                :options='$parent.$parent.tableBrands'
                condition="gb.f_meter_brand = '{}'"
                :value-single="true"
                close-on-select clear-button></v-select>
            </div>
          </div>
        </div>
      </criteria>
      <div partial='list' id='shexian' class="list_area" style="overflow-y: scroll">
        <table class='tableprint' style="margin: 0px auto">
          <thead>
          <tr>
            <th colspan='5' style="font-weight: normal; text-align: left;">
              <h3 style="text-align: center">隐患报表</h3>
            </th>
          </tr>
          <tr>
            <th colspan='5' style="font-weight: normal; text-align: center;">
              开始时间：{{model.model.startDate}}&nbsp;&nbsp;&nbsp;
              结束时间：{{ model.model.endDate }}
            </th>
          </tr>
          </thead>
          <tr>
            <th colspan='5' style="font-weight: normal;">
              {{{ model.data.substring(26,model.data.length-8) }}}
            </th>
          </tr>
        </table>
      </div>
    </criteria-paged>
  </div>

</template>

<script>
  import {DataModel, HttpResetClass} from 'vue-client'

  export default {
    title: '隐患报表',
    data () {

      let model = new DataModel('rs/report/hiddensituation', {
        startDate: 'this.model.startDate',
        endDate: 'this.model.endDate',
        f_filialeid: 'this.f_filialeid'
      })
      model.f_filialeid = '(' + this.$login.f.orgid + ')'
      return {
        userTypes: [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')],
        user_types: [{ label: '全部', value: '' }, { label: '民用', value: '民用' }, { label: '非民用', value: '非民用' }],
        tableTypes: [{label: '全部', value: ''}, ...this.$appdata.getParam('气表类型')],
        tableBrands: [{label: '全部', value: ''}],
        filialeNameStr: '',
        filialeCodeStr: '',
        userid: this.$login.f.id,
        source: `tool.getFullTree(this.getRights().where(row.getType() != $zone$).where(row.getType() == $organization$))`,
        model: model
      }
    },
    methods: {
      getRes (obj) {
        this.model.f_filialeid = this.$login.convertToIn(obj.resids)
      },
      getTableBrands() {
        new HttpResetClass().load("POST", `/rs/sql/safe_singleTable_OrderBy`,
          {data: {items: "*", tablename: "t_gasbrand", orderitem: "id", condition: ` 1=1 `}},
          {resolveMsg: null, rejectMsg: null}).then((resp) => {
          resp.data.forEach((result) => {
            this.tableBrands.push({label: result.f_meter_brand, value: result.f_meter_brand})
          })
        })
      },
    },
    ready () {
      this.getTableBrands()
    },
    computed: {
      selected () {
        return this.$refs.grid.selected
      }
      // outlets () {
      //   return [{label: '全部', value: ''}, ...AppData.getParam('营业网点')]
      // },
      // operator () {
      //   return [{label: '全部', value: ''}, ...AppData.getParam('操作员')]
      // }
    }
  }
</script>
