<template >
  <div id="stand-work-list" class="flex">
    <div class="span">
      <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_state"
                          style="width:60%"
                          v-model="model.f_state"
                          :options='$parent.$parent.chargeState' placeholder='状态'
                          condition="f_state = '{}'"
                          close-on-select></v-select>
              </div>
              <div class="col-sm-3">
                <label for="startDate" class="font_normal_body">收费日期</label>
                <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                            v-model="model.startDate"
                            :value.sync="model.startDate"
                            :format="'yyyy-MM-dd'"
                            :show-reset-button="true"
                            condition="f_operate_date >= '{} 00:00:00'">
                </datepicker>
              </div>
              <div class="col-sm-3">
                <label for="endDate" class="font_normal_body">至</label>
                <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                            v-model="model.endDate"
                            :value.sync="model.endDate"
                            :format="'yyyy-MM-dd'"
                            :show-reset-button="true"
                            condition="f_operate_date <= '{} 23:59:59'">
                </datepicker>
              </div>

              <div class="span" style = "float:right;">
                <button class="button_search button_spacing" @click="search()">查询</button>
              </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>
              <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_brand_spec}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_unitprice}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_number}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_collection}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_payment}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_state}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_operate_date}}</nobr>
            </td>

            <td style="text-align: center;">
              <nobr>{{row.f_comments}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_operator}}</nobr>
            </td>

          </template>
          <template partial='foot'>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>合计：</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_number}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_collection}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>

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

<script>
  import {PagedList} from 'vue-client'
  let readySomething = async function (self) {
    await self.$refs.paged.$refs.cri.search()
  }
  export default {
    title: '抄表',
    data () {
      return {
        condition: '1=1',
        model: new PagedList('api/af-revenue/sql/otherChargeQuery', 20,{},{
          f_number:0,
          f_collection:0
        }),
        orgCondtionStr: ''
        // row: null

      }
    },
    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)
      }
    },
    watch: {
      // args(val){
      //   this.search()
      // }
    },
    computed: {
      getCondition() {
        return {condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr}
      },
      chargeState() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('收费状态')]
      },
    }

    }
</script>
