<template style="position: absolute;">
    <div >
        <criteria-paged :model="model" v-ref:paged>
            <criteria partial='criteria' v-ref:criteria  @condition-changed='$parent.selfSearch'>
                <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
                    <div class="row" width="100%">
                        <div class="row">
                            <div class="col-sm-2 form-group">
                                <label class="font_normal_body">组织机构</label>
                                <res-select restype='organization'
                                            :is-mul="false"
                                            :initresid="$parent.$parent.curorgid"
                                            @res-select="$parent.$parent.getorgCur">
                                </res-select>
                            </div>

                            <div style="float:right">
                                <button class="button_search"  @click="search()" v-el:cba>查询</button>
                                <button class="button_export" @click="$parent.$parent.importFile">导入</button>
                                <button class="button_search" @click="$parent.$parent.clearmsg">清空</button>
                            </div>
                        </div>
                    </div>
                </div>
            </criteria>
            <data-grid id="webmeterinfo" :model="model"  class="list_area table_sy"  partial='list'  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>
                        <th><nobr>补差气量</nobr></th>
                        <!--              <th><nobr>设备号</nobr></th>-->
                        <th><nobr>补差金额</nobr></th>
                        <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;" >{{$index+1}}</td>
                    <td style="text-align: center" >{{row.f_user_name}}</td>
                    <td style="text-align: center" >{{row.f_change_price}}</td>
                    <td style="text-align: center" >{{row.f_old_price}}</td>
                    <td style="text-align: center" >{{row.f_new_price}}</td>
                    <!--            <td style="text-align: center" >{{row.f_device_id}}</td>-->
                    <td style="text-align: center" >{{row.f_real_amount}}</td>
                    <td style="text-align: center" >{{row.f_surplus_fee}}</td>
                    <td style="text-align: center" >{{row.f_start_date}}</td>
                    <td style="text-align: center" >{{row.f_end_date}}</td>
                    <td style="text-align: center" >{{row.f_type}}</td>
                    <!--            <td style="text-align: center" >{{row.f_vender}}</td>-->

                    <td style="text-align: center" >{{row.f_state}}</td>
                </template>
            </data-grid>
        </criteria-paged>
    </div>
    <modal :show.sync="show" width="500px" title="文件导入" v-ref:modal large backdrop="false">
        <article slot="modal-body" class="modal-body">
            <file-upload class="my-file-uploader " name="UploadFile" class="btn btn-success" style="border-radius: 2px;"
                         action="rs/file/uploadFile" tagname="导入表计" v-ref:file :headers="headers" multiple></file-upload>
        </article>
        <footer slot="modal-footer" class="modal-footer">
        </footer>
    </modal>
</template>
<script>
  import { PagedList } from 'vue-client'
  import vue from 'vue'

  export default {
    title: '调价导入',
    data () {
      return {
        model: new PagedList('rs/sql/getsurplus', 20, {items: '"*"', tablename: '"t_meterinfo"', orderitem: '"id"'}),

        headers: {'username': vue.$login.f.name},
        show: false
      }
    },
    ready () {
      this.search()
    },

    methods: {
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorgCur([this.$login.f.orgid])
        }
        if (this.f_orgid) {
          args.condition = `${args.condition} and f_orgid  in ${this.f_orgid}`
        }
        this.model.search(args.condition, args.model)
      },

      getorgCur (val) {
        console.log('组织事件返回。。', val[0])
        this.f_orgid = this.$login.convertToIn(val)
        this.f_filialeids = val[0]
        this.$parent.f_filialeid = val[0]
        this.search()
      },
      importFile () {
        this.show = true
      }

    },
    events: {
      onFileUpload: function (file, res) {
        console.log(this.$login.f, '======')
        console.log(res)

        let data = {
          filepath: res.f_downloadpath,
          f_operator: this.$login.f.name,
          f_operatorid: this.$login.f.id,
          f_orgid: this.$login.f.orgid,
          f_orgname: this.$login.f.orgs,
          f_depid: this.$login.f.depids,
          f_depname: this.$login.f.deps
        }

        console.log(data, '++++++++++++++++++++++++++')
        this.$resetpost('rs/logic/thirdSurplus', {data: data}, {resolveMsg: '上传成功', rejectMsg: '上传失败'}).then((res) => {
          // window.location.href = '/excel/表具导入异常信息.txt';
          this.show = false
          this.search()
        })
      }
    }
  }
</script>
<style>
    .form-input-group label {
        text-align: right;
        width: auto;
    }
    .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>

