<template>
  <div class="flex-row">
    <div class="basic-main">
    <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_userinfo_id"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_userinfo_id ='{}'" 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 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="getGaiXianViewList"
                            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>
              <input type="text" class="input_search" style="width: 60%" v-model="model.f_contact"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_contact 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">
              <label class="font_normal_body"><strong>详细地址：</strong></label>
              <input type="text" class="input_search" style="width: 60%" v-model="model.f_address"
                     v-on:keyup.enter="$parent.$parent.search()" condition="ap.f_address like '%{}%'" placeholder='详细地址'>
            </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>
            <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>
            <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.person}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_apply_date}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_contact}}</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_charge_date}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_gaixian_number}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_userinfo_id}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_gasproperties}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_address}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_user_classification}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_due_money}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_capitalized_amount?row.f_capitalized_amount:$parent.$parent.$parent.smalltoBIG(row.f_due_money)}}</font></nobr>
            </td>

            <td style="text-align: center;">
              <nobr><font>{{row.f_cause}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_modify_plan}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_construction_name}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_high_work}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_engineering_operator}}</font></nobr>
            </td>
            <td style="text-align: center;">
              <nobr><font>{{row.f_check_operator}}</font></nobr>
            </td>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>
    </div>
  </div>
</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/getGaiXianViewList', 30, {
      }),
      criteriaShow: false,
      showStatus: true,
      getfield: {
        'f_apply_num': '报建编号',
        'f_apply_date': '报建申请时间',
        'person': '核算费用',
        'f_user_name': '工程名称',
        'f_contact': '用户名称',
        'f_phone': '电话',
        'f_charge_date': '收费日期',
        'f_gaixian_number': '改线类型',
        'f_userinfo_id': '用户编号',
        'f_gasproperties': '用气性质',
        'f_address': '详细地址',
        'f_user_classification': '用户分类',
        'f_due_money': '整改费用',
        'f_cause': '改线原因',
        'f_modify_plan': '整改方案',
        'f_construction_name': '安装单位',
        'f_high_work': '高空作业',
        'f_engineering_operator': '土建单位',
        'f_check_operator': '检测单位'
      }
    }
  },
  ready () {
    // 调用查询
    this.search()
  },
  methods: {
    clear () {
      Object.keys(this.$refs.cp.$refs.cri.model).forEach((key) => {
        this.$refs.cp.$refs.cri.model[key] = []
      })
    },
    searchCondition (args) {
      this.model.search(args.condition, args.model)
    },
    // 查询
    search () {
      this.$refs.cp.$refs.cri.search()
    },
    // 金额转大写
    smalltoBIG(n) {
      let fraction = ['角', '分'];
      let digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
      let unit = [['元', '万', '亿'], ['', '拾', '佰', '仟']];
      let head = n < 0 ? '欠' : '';
      n = Math.abs(n);

      let s = '';

      for (var i = 0; i < fraction.length; i++) {
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
      }
      s = s || '整';
      n = Math.floor(n);

      for (var i = 0; i < unit[0].length && n > 0; i++) {
        let p = '';
        for (var j = 0; j < unit[1].length && n > 0; j++) {
          p = digit[n % 10] + unit[1][j] + p;
          n = Math.floor(n / 10);
        }
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
      }
      return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整')
    },
  },
  computed: {
    getCondition () {
      return {
        condition: this.$refs.cp.$refs.cri.condition
      }
    }
  }
}
</script>

<style scoped>
</style>
