<template >
  <div class="flex">
    <div class="height:auto">
      <criteria-paged :model="model" v-ref:paged  >
        <criteria partial='criteria' v-ref:cri  @condition-changed='$parent.selfSearch'>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <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="col-sm-3">-->
<!--                <label class="font_normal_body">状态</label>-->
<!--                <v-select :value.sync="model.f_hand_state"-->
<!--                          style="width:60%"-->
<!--                          v-model="model.f_hand_state"-->
<!--                          :options='$parent.$parent.handstate' placeholder='状态'-->
<!--                          condition="f_hand_state = '{}'"-->
<!--                          close-on-select></v-select>-->
<!--              </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>

            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center;">
              <nobr>{{row.f_user_name}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_newuser_phone}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_user_phone}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_transfer_fees}}</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>
          <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></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.f_transfer_fees}}</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/transferQuery', 20,{},{
          f_transfer_fees:0
        }),
        orgCondtionStr:''
      }
    },
    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: {
      getCondition(){
        return {condition: `${this.$refs.paged.$refs.cri.condition}`+this.orgCondtionStr}
      }
    }
  }
</script>

