<template>
  <div style="flex: 1.5" class="flex">
    <div class="flex">
      <criteria-paged :model="model" v-ref:paged @sort="sort">
        <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':!$parent.$parent.editList,'col-sm-4':$parent.$parent.editList}"
                class="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>
                <input type="text" class="input_search"  style="width: 60%" v-model="model.f_address"
                       condition="f_address like '%{}%'" 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_operator"
                       condition="f_operator like '%{}%'" 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_state"
                       condition="f_state = '{}'" 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_serial_id"
                       condition="f_serial_id = '{}'" placeholder='支付流水号'>
              </div>
              <div
                :class="{'col-sm-2':!$parent.$parent.editList,'col-sm-4':$parent.$parent.editList}"
                class="form-group">
                <label class="font_normal_body">开始日期</label>
                <datepicker placeholder="开始日期" v-model="model.startDate" :value.sync="model.startDate" style="width:60%"
                            :format="'yyyy-MM-dd 00:00:00'" condition="f_operate_date >= '{}'">
                </datepicker>
              </div>
              <div
                :class="{'col-sm-2':!$parent.$parent.editList,'col-sm-4':$parent.$parent.editList}"
                class="form-group">
                <label class="font_normal_body">结束日期</label>
                <datepicker placeholder="结束日期" v-model="model.endDate" :value.sync="model.endDate" style="width:60%"
                            :format="'yyyy-MM-dd 23:59:59'" condition="f_operate_date <= '{}'">
                </datepicker>
              </div>
              <div class="span" style="float:right;">
                <import-excel template-name="其他收费导入模板" logic-name="otherImport" import-json="othercharge.json" ></import-excel>
                <button class="button_search" @click="search()">查 询</button>
                <export-excel v-if="$parent.$parent.authArr.includes('其他收费导出权限')"
                              :data="{condition: $parent.$parent.excelCondition}"
                              :field="$parent.$parent.fields"
                              sqlurl="rs/logic/saleExport" sql-name="querylists"
                              template-name='其他收费导出'
                              :choose-col="true">
                </export-excel>
                <!--<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>
              <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><data-order field="f_operate_date" name="收费时间"></data-order></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_userinfo_code}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_user_name}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_address}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_payment}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_collection}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_serial_id}}</nobr></td>
            <td style="text-align: center;"><nobr>{{row.f_bill_style}}</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>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
const myMap = new Map()
  export default {
    'title': '其他记录维护',
    data () {
      return {
        model: new PagedList('rs/sql/querylists', 20, {orderitem: '"f_operate_date DESC"'}),
        // pj:this.$appdata.getParam('是否有附件')?[{label: '全部', value: ''},...this.$appdata.getParam('是否有附件')] : [],
        // 排序
        orderitem: 'f_operate_date desc',
        orderFields: {
          f_operate_date: 'no'
        },
        // 控制查询条件显示
        searchshow: true,
        curorgid: [this.$login.f.orgid],
        f_orgid: '',
        // f_audit_state: [{label:'全部',value:''},{label:'已审核',value:`= '已审核'`},{label:'审核中',value:`= '审核中'`},{label:'其他',value:'is null'}],
        da: {
          rows: []
        },
        fields: {
          'f_userinfo_code': '用户编号',
          'f_user_name': '用户姓名',
          'f_user_phone': '用户电话',
          'f_address': '用户地址',
          'f_payment': '缴费类型',
          'f_collection': '缴费金额',
          'f_serial_id': '支付流水号',
          'f_bill_style': '收据类型',
          'f_operate_date': '收费时间',
          'f_operator': '操作人'
        },
        excelCondition: '',
        priceSplit: false,
        criteriaShow: false
        // imgshow:false,
        // imgfilename:''
      }
    },
    ready () {
      this.search()

      // this.getwarehouse()
    },
    props: ['showMessage'],
    methods: {
      fileterprice (row) {
        this.splitdata = row
        this.priceSplit = true
        console.log('row==>', row)
      },
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
        this.f_filialeid = val[0]
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderitem}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }

        this.search()
      },
      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorg([this.$login.f.orgid])
        }
        if (this.f_orgid) {
          args.condition = `${args.condition} and f_orgid  in ${this.f_orgid}`
        }
        console.log('查询。。。')
        this.excelCondition = args.condition
        this.model.search(args.condition, args.model)
      }
    },
    watch: {

    }
    /* computed: {
      ischecked () {
        return function (index, i) {
          // console.log("计算属性")
          if (!this.radio[index]) {
            return false
          }
          return this.radio[index][i]
        }
      },
      distributionstate () {
        return [{label: '全部', value: ''}, {label: '待分配', value: 'is null'}, {label: '已入库', value: 'is not null'}]
      }
    } */
  }
</script>
<style>
  .datapanel {
    color: #333;
    background-color: white;
    padding: 10px 20px;
    border-radius: 15px;
  }
</style>
