<template>
  <!-- 改线记录 -->
    <criteria-paged :model="model" v-ref:cp>
      <criteria partial='criteria' @condition-changed='$parent.searchCondition' v-ref:cri>
        <div class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>报建编号：</strong></label>
              <input type="text" class="input_search" style="width: 60%" v-model="model.f_apply_num"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_apply_num like '%{}%'" placeholder='报建编号'>
            </div>
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>用户名称：</strong></label>
              <input type="text" class="input_search" style="width: 60%" v-model="model.f_user_name"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_user_name like '%{}%'" placeholder='用户名称'>
            </div>
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>电&emsp;&emsp;话：</strong></label>
              <input type="text" class="input_search" style="width: 60%" v-model="model.f_phone"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_phone like '%{}%'" placeholder='电话'>
            </div>
            <div class="form-group col-sm-3 button-range">
              <button class="button_search button_spacing" @click="$parent.$parent.search()" v-el:cx>查询</button>
              <button class="button_clear button_spacing"  @click="$parent.$parent.clear()">清空</button>
              <export-excel :data="$parent.$parent.getCondition"
                            :field="$parent.$parent.getfield"
                            sqlurl="rs/logic/applyExportfile"
                            sql-name="getGaiXianList"
                            template-name='改线记录信息导出'
                            :choose-col="true"></export-excel>
              <div
                :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                @click="$parent.$parent.criteriaShow = !$parent.$parent.criteriaShow"
                class="button_spacing"
                style="float: right">
              </div>
            </div>
          </div>
          <div class="row" v-show="$parent.$parent.criteriaShow">
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>改线状态：</strong></label>
              <v-select
                v-model="$parent.$parent.showStatus"
                placeholder='请选择'
                :value.sync="$parent.$parent.showStatus"
                :options='$parent.$parent.applytype'
                class="select select_list"
                :value-single="true"
                close-on-select ></v-select>
            </div>
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>派工类型：</strong></label>
              <v-select
                v-model="model.f_dispatching_type"
                placeholder='工队/维修'
                condition="ap.f_dispatching_type = '{}'"
                :value.sync="model.f_dispatching_type"
                :options='$parent.$parent.dispatching'
                class="select select_list"
                :value-single="true"
                close-on-select ></v-select>
            </div>
            <div class="form-group col-sm-3">
              <label  for="startDate" class="font_normal_body"><strong>缴费时间：</strong></label>
              <datepicker id="startDate" placeholder="开始日期"
                          style="width: 60%!important;"
                          v-model="model.startDate"
                          :value.sync="model.startDate"
                          :format="'yyyy-MM-dd 00:00:00'"
                          :show-reset-button="true"
                          condition="cr.f_charge_date >= '{}'">
              </datepicker>
            </div>
            <div class="form-group col-sm-3">
              <label for="endDate" class="font_normal_body"><strong>缴费时间：</strong></label>
              <datepicker id="endDate" placeholder="结束日期"
                          style="width: 60%!important;"
                          v-model="model.endDate"
                          :value.sync="model.endDate"
                          :format="'yyyy-MM-dd 23:59:59'"
                           :show-reset-button="true"
                          condition="cr.f_charge_date <= '{}'">
              </datepicker>
            </div>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid style="overflow: auto" class="list_area table_sy">
        <template partial='head'>
          <tr>
            <th style="white-space: nowrap;">序号</th>
            <th style="white-space: nowrap;">报建编号</th>
            <th style="white-space: nowrap;">用户名称</th>
            <th style="white-space: nowrap;">电话</th>
            <th style="white-space: nowrap;">报建类型</th>
            <th style="white-space: nowrap;">报建性质</th>
            <th style="white-space: nowrap;">收费金额</th>
            <th style="white-space: nowrap;">收费日期</th>
          </tr>
        </template>
        <template partial='body'>
          <tr >
            <td style="text-align: center;">
              <nobr><font>{{$index+1}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_apply_num}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_user_name}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_phone}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_apply_type}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_apply_nature}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_charge_money}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_charge_date}}</font></nobr>
            </td>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>

</template>

<script>
import {PagedList} from 'vue-client'
import {HttpResetClass} from 'vue-client'
import {isEmpty} from '../../Util'
import Vue from "vue";
export default {
  title: '改线记录列表',
  data () {
    return {
      model: new PagedList('rs/sql/getGaiXianList', 30, null, {
        f_charge_money: 0
      }),
      applytype: [{label: '全部', value: ''},{label: '已完工', value: false}, {label: '已缴费', value: true}],
      dispatching:  [{label: '全部', value: ''}, {label: '施工工队', value: '施工工队'}, {label: '安检维修中心', value: '安检维修中心'}],
      criteriaShow: false,
      showStatus: true,
      getfield: {
        'f_apply_num': '报建编号',
        'f_user_name': '用户名称',
        'f_phone': '电话',
        'f_apply_type': '报建类型',
        'f_apply_nature': '报建性质',
        'f_charge_money': '收费金额',
        'f_charge_date': '收费日期'
      }
    }
  },
  ready () {
    // 调用查询
    this.search()
  },
  methods: {
    clear () {
      Object.keys(this.$refs.cp.$refs.cri.model).forEach((key) => {
        this.$refs.cp.$refs.cri.model[key] = []
      })
    },
    searchCondition (args) {
      if(isEmpty(this.showStatus)){
        args.condition = args.condition + ` and act.defname in ('工程派工','完工')`
      }else{
        if (this.showStatus){
          args.condition = args.condition + ` and act.defname = '工程派工'`
        }else {
          args.condition = args.condition + ` and act.defname = '完工'`
        }
      }

      console.log("args.condition",args.condition)
      this.model.search(args.condition, args.model)
    },
    // 查询
    search () {
      this.$refs.cp.$refs.cri.search()
    }
  },
  computed: {
    getCondition () {
      if (this.showStatus===true){
        this.$refs.cp.$refs.cri.condition +=  ` and act.defname = '工程派工'`
      }else if (this.showStatus===false) {
        this.$refs.cp.$refs.cri.condition+=  ` and act.defname = '完工'`
      }else {
        this.$refs.cp.$refs.cri.condition +=  ` and act.defname in ('工程派工','完工')`
      }
      return {
        condition: this.$refs.cp.$refs.cri.condition,
        data: {
          orgid: this.$login.f.orgid
        }
      }
    }
  }
}
</script>

<style scoped>
</style>
