<template>
  <!-- 中止报建 -->
    <criteria-paged :model="model" v-ref:cp>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate 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" style="width:60%" class="input_search" placeholder='报建编号' v-model="model.f_apply_num"
                     v-on:keyup.enter="search"
                     condition="f_apply_num = '{}'">
            </div>
            <div class="form-group col-sm-3">
              <label class="font_normal_body"><strong>客户名称：</strong></label>
              <input type="text" style="width:60%" class="input_search" 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">
              <label class="font_normal_body"><strong>电&emsp;&emsp;话：</strong></label>
              <input type="text" style="width:60%" class="input_search" v-model="model.f_phone"
                     v-on:keyup.enter="$parent.$parent.search()" condition="f_phone = '{}'" placeholder='电话'>
            </div>
            <div class="form-group col-sm-2 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>
              <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="model.f_apply_type"
                placeholder='报建类型'
                condition="f_apply_type like '%{}%'"
                :value.sync="model.f_apply_type"
                :options='$parent.$parent.applytype'
                class="select select_list"
                :value-single="true"
                @change="$parent.$parent.applyTypeChange()"
                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.defname"
                placeholder='办理环节'
                condition="defname = '{}'"
                :value.sync="model.defname"
                :options='$parent.$parent.defnames'
                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 HH:mm:ss'"
                          :show-reset-button="true"
                          condition="f_apply_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 HH:mm:ss'"
                          :show-reset-button="true"
                          condition="f_apply_date <= '{}'">
              </datepicker>
            </div>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid 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>
          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td style="text-align: center;">
              <nobr>{{$index+1}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_apply_num}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_user_name}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_phone}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_apply_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.defname}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_type}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_state}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stop_reason}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_stop_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_operator}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_cancel_reason}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_cancel_date}}</nobr>
            </td>
            <td style="text-align: center;">
              <nobr>{{row.f_cancel_operator}}</nobr>
            </td>
            <td style="text-align: center;">
              <dropdown v-if="row.f_state === '有效' && row.f_operatorid === $login.f.id">
                <button type="button" data-toggle="dropdown" style="border: 0px;background: none;">
                  <span class="glyphicon glyphicon-th-list" style="position: inherit;"></span>
                </button>
                <ul slot="dropdown-menu" class="dropdown-menu dropdown-menu-right">
                  <li>
                    <a href="#" @click="$parent.$parent.$parent.click(row)">撤销</a>
                  </li>
                </ul>
              </dropdown>
            </td>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>
import {HttpResetClass, PagedList} from 'vue-client'
import {isEmpty} from '../../Util'
export default {
  title: '勘探详情',
  data () {
    return {
      model: new PagedList('rs/sql/getStopApply', 20, null),
      curorgid: [this.$login.f.orgid],
      applytype: [{label: '全部', value: ''}, ...this.$appdata.getParam('报建类型')?this.$appdata.getParam('报建类型'):[]],
      defnames: [{label: '全部', value: ''}], // 流程节点
      criteriaShow: false
    }
  },
  ready () {
    // 调用查询
    this.search()
  },
  events: {
  },
  methods: {
    // 查询
    search () {
      this.$dispatch('search')
    },
    click (row) {
      this.$dispatch('cancelStopApply', row)
    },
    async applyTypeChange () {
      if (!isEmpty(this.$refs.cp.$refs.cri.model.f_apply_type)) {
        let http = new HttpResetClass()
        let res = await http.load('POST', 'rs/logic/getDefnameByType', {
            f_apply_type: this.$refs.cp.$refs.cri.model.f_apply_type},
          {resolveMsg: null, rejectMsg: '流程标识获取失败！！！'}
        )
        this.defnames = [{label: '全部', value: ''}, ...res.data]
      } else {
        this.defnames = [{label: '全部', value: ''}]
      }
    },
    clear () {
      Object.keys(this.$refs.cp.$refs.cri.model).forEach((key) => {
        this.$refs.cp.$refs.cri.model[key] = null
      })
    },
    getorg (val) {
      if (val.length <= 0) {
        return
      }
      this.model.params.data.orgid = val[0]
    }
  },
  computed: {
  }
}
</script>
<style scoped>
</style>
