<template>
  <div class="flex-row">
    <div class="basic-main">
    <criteria-paged :model="model" v-ref:cp>
      <criteria partial='criteria' @condition-changed='search' 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="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="f_user_name like '%{}%'" placeholder='用户名称'>
            </div>

            <div class="form-group col-sm-3 button-range">
              <button class="button_search button_spacing" @click="search()" v-el:cx>查询</button>
              <button class="button_clear button_spacing"  @click="$parent.$parent.clear()">清空</button>
              <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>
        </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>
            <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_apply_type}}</font></nobr>
            </td>
            <td  style="text-align: center;">
              <div  v-if="!$parent.$parent.$parent.checkEquality(row.f_price) ">
                <nobr>调整前:<font>{{ $parent.$parent.$parent.getStarStr(row.f_price)}}</font></nobr><br>
                <nobr>调整后:<font>{{ $parent.$parent.$parent.getEndStr(row.f_price)}}</font></nobr>
              </div>
            </td>
            <td   style="text-align: center;">
              <div v-if="!$parent.$parent.$parent.checkEquality(row.f_due_money)">
                <nobr>调整前:<font>{{ $parent.$parent.$parent.getStarStr(row.f_due_money)}}</font></nobr><br>
                <nobr>调整后:<font>{{ $parent.$parent.$parent.getEndStr(row.f_due_money)}}</font></nobr>
              </div>
            </td>
            <td style="text-align: center;">
              <div v-if="!$parent.$parent.$parent.checkEquality(row.f_surplus_money)">
                <nobr>调整前:<font>{{ $parent.$parent.$parent.getStarStr(row.f_surplus_money)}}</font></nobr><br>
                <nnsp></nnsp>
                <nobr>调整后:<font>{{ $parent.$parent.$parent.getEndStr(row.f_surplus_money)}}</font></nobr>
              </div>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_revise_person}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_revise_reason}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_revise_data}}</font></nobr>
            </td>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>
    </div>
  </div>
</template>
<script>
import {HttpResetClass, PagedList} from 'vue-client'
import {getNowDate,isEmpty} from '../../../components/Util'
export default {
  title: '费用调整记录',
  data () {
    return {
      model: new PagedList('rs/sql/AdjustmentRecordList',20, {
      }),
      criteriaShow: false
    }
  },
  ready () {
    // 调用查询
    this.$refs.cp.$refs.cri.search()
  },
  methods: {
    checkEquality(str) {
      const index = str.indexOf("->");
      if (index !== -1) {
        const before = str.substring(0, index);
        const after = str.substring(index + 2);
          if (before === after) {
            return true;
          }else{
            return false;
          }
        }
      return false;
      },
    // 根据->截取字符串,获取->前的字符串
    getStarStr(str) {
      const index = str.indexOf("->");
      if (index !== -1) {
        return str.substring(0, index);
      }
      return str;
    },
    // 根据->截取字符串,获取->后的字符串
    getEndStr(str) {
      const index = str.indexOf("->");
      if (index !== -1) {
        return str.substring(index + 2);
      }
      return "";
    },
    // 清空
    clear () {
      Object.keys(this.$refs.cp.$refs.cri.model).forEach((key) => {
        this.$refs.cp.$refs.cri.model[key] = []
      })
    },
    // 查询
    search () {
      this.$refs.cp.$refs.cri.search()
    }
  },
  computed: {
  }
}
</script>

<style scoped>
</style>
