<template>
  <div>
    <div style="flex: 1.5" class="flex">
      <div class="flex">
        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch"
                    v-show="$parent.searchshow">
            <div novalidate class="form-inline auto" partial>
              <div class="row">
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">组织机构</label>
                  <res-select :initresid='$parent.$parent.curorgid'
                              @res-select="$parent.$parent.getorg"
                              class="select select_list"
                              restype='organization'
                              style="width: 60%">
                  </res-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户编号</label>
                  <input type="text" class="input_search"  style="width: 60%" v-model="model.f_userinfo_code"
                         condition="f_userinfo_code = '{}'" placeholder='客户编号'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户姓名</label>
                  <input type="text" class="input_search"  style="width: 60%" v-model="model.f_user_name"
                         condition="f_user_name = '{}'" placeholder='客户姓名'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">有无附件</label>
                  <v-select :options='$parent.$parent.pj'
                            :value-single="true"
                            :value.sync="model.is_has_file"
                            close-on-select
                            placeholder='请选择'
                            v-model="model.is_has_file"
                            condition="is_has_file = '{}'"
                            search=fasle
                  >
                  </v-select>
                </div>
                <div class="span" style="float:right;">
                  <button class="button_search" @click="search()">查 询</button>
                  <!--<div-->
                    <!--:class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"-->
                    <!--@click="$parent.$parent.hidden()" class="button_spacing" style="float: right"></div>-->
                </div>
              </div>
            </div>
          </criteria>
          <data-grid :model="model" v-ref:grid class="list_area table_sy" partial='list'>
            <template partial='head'>
              <tr>
              <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>
                <th><nobr>附件</nobr></th>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align:center"><nobr>{{$index+1}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_bill_id}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_bill_number}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_userinfo_code}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_user_name}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_paid_money}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_type}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_bill_type}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_bill_state}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_operate_date}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_operator}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_orgname}}</nobr></td>
              <td style="text-align:center"><nobr>{{row.f_depname}}</nobr></td>
              <td style="text-align: center;"><nobr>
                <button v-if="row.is_has_file=='是'" class="btn btn-link" @click.stop="$parent.$parent.$parent.view(row)">查看</button>
              </nobr></td>
            </template>
          </data-grid>
        </criteria-paged>
      </div>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'

  export default {
    'title': '发票查询',
    data () {
      return {
        model: new PagedList('rs/sql/getBillList', 20),
        pj: this.$appdata.getParam('是否有附件') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('是否有附件')] : [],
        // 控制查询条件显示
        searchshow: true,
        // 公司下拉
        curorgid: [this.$login.f.orgid],
        f_orgid: '',
        priceSplit: false,
        criteriaShow: false,
        imgfilename: ''
      }
    },
    ready () {
      this.search()
      // this.getwarehouse()
    },
    props: ['showMessage'],
    methods: {
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
        this.f_filialeid = val[0]
      },
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },

      view (row) {
        this.$parent.showupload = true
        this.$parent.row = row
      },

      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorg([this.$login.f.orgid])
        }
        console.log('查询。。。', this.f_orgid)
        if (this.f_orgid) {
          args.condition = `${args.condition} and f_orgid  in ${this.f_orgid}`
        }
        this.model.search(args.condition, args.model)
      }
    },
    computed: {
    }
  }
</script>
<style>
  .datapanel {
    color: #333;
    background-color: white;
    padding: 10px 20px;
    border-radius: 15px;
  }
</style>

