<template>
  <div id="unit" class="flex">

    <div class="height:auto">
          <criteria-paged :model="model" v-ref:paged>
            <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
              <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
<!--               <div class="row">-->
<!--                 <div class="col-sm-3" >-->
<!--                   <label class="font_normal_body">类型</label>-->
<!--                   <v-select :value.sync="model.f_devices_type"-->
<!--                             style="width:60%"-->
<!--                             v-model="model.f_devices_type"-->
<!--                             :options='$parent.$parent.deviceTypes' placeholder='设备类型'-->
<!--                             condition="f_devices_type = '{}'"-->
<!--                             close-on-select></v-select>-->

<!--                 </div>-->
<!--                  <div class="col-sm-3" >-->
<!--                    <label class="font_normal_body">品牌</label>-->
<!--                    <input  type="text" style="width:60%" class="input_search" v-model="model.f_brand"-->
<!--                            condition="f_brand like '%{}%'" placeholder='设备品牌'>-->
<!--                  </div>-->
<!--                 <div class="col-sm-3"  >-->
<!--                    <label class="font_normal_body">型号</label>-->
<!--                    <input  type="text" style="width:60%" class="input_search" v-model="model.f_devices_model"-->
<!--                            condition="f_devices_model like '%{}%'" placeholder='设备型号'>-->
<!--                  </div>-->

<!--                  <div class="span" style = "float:right;">-->
<!--                    <button class="button_search button_spacing" @click="search()">查询</button>-->
<!--&lt;!&ndash;                    <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>&ndash;&gt;-->
<!--                    </div>-->

<!--               </div>-->

              </div>
            </criteria>

            <data-grid  :model="model" partial='list' class="list_area table_sy"  v-ref:grid>
              <template partial='head'>
                <tr>
                  <th><nobr>设备类型</nobr></th>
                  <th><nobr>设备编号</nobr></th>
                  <th><nobr>设备品牌</nobr></th>
                  <th><nobr>设备型号</nobr></th>
                  <th><nobr>录入日期</nobr></th>
                </tr>
              </template>
              <template partial='body'>
                <td style="text-align: center;"><nobr>{{row.f_devices_type}}</nobr></td>
                <td style="text-align: center;"><nobr>{{row.f_devices_no}}</nobr></td>
                <td style="text-align: center;"><nobr>{{row.f_brand}}</nobr></td>
                <td style="text-align: center;"><nobr>{{row.f_devices_model}}</nobr></td>
                <td style="text-align: center;"><nobr>{{row.f_operate_date}}</nobr></td>
              </template>
              <template partial='foot'>

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




        </div>
      </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  // import defaultPrint from '../../config/DefaultPrint'
  // import exportConfig from '../../config/exportConfig'

  let readySomething = async function (self) {

    await self.$refs.paged.$refs.cri.search()
  }
  export default {
    data() {
      return {
        model: new PagedList('api/af-revenue/sql/deviceQuery', 20),
        criteriaShow: false,
        orgCondtionStr:'',

        // 下拉框参数
        deviceTypes: this.$appdata.getParam('设备类型') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('设备类型')] : [],
        brand: this.$appdata.getParam('设备品牌') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('设备品牌')] : [],

        // 合计数据
        // sumsmodel: {}
      }
    },
    props:
      {
        f_userinfo_id: ''
      },
    ready(){
      readySomething(this)
    },
    methods: {
      selfSearch (args) {
        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + " and f_orgid = " + this.$login.f.orgid + " and f_userinfo_id = " + this.f_userinfo_id
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }

        this.model.search(args.condition, args.model)
        // this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
        // console.log('合计字段',this.sumsmodel)
      },
      clear(){
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = []
        })
      }

    },
    computed:{
      getCondition(){
        return {condition: `${this.$refs.paged.$refs.cri.condition}`+this.orgCondtionStr}
      }
    }
  }
</script>
