<template>
  <div class="flex binary-left" style="flex: 1; width:100%">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' v-ref:criteria @condition-changed='$parent.selfSearch'>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <!--          <div class="col-sm-4 form-group">-->
            <!--            <label class="font_normal_body">处理状态</label>-->
            <!--            <v-select v-model="model.f_orderstate" style="width:60%"-->
            <!--                      placeholder='处理状态'-->
            <!--                      :value.sync="model.f_orderstate"-->
            <!--                      :options='$parent.$parent.getState'-->
            <!--                      condition="f_orderstate {}"-->
            <!--                      close-on-select value-single>-->
            <!--            </v-select>-->
            <!--          </div>-->
            <!--          <div class="col-sm-4 form-group">-->
            <!--            <label class="font_normal_body">用户姓名</label>-->
            <!--            <input type="text" class="input_search"-->
            <!--                   style="width:60%"-->
            <!--                   v-model="model.f_user_name"-->
            <!--                   condition="f_user_name = '{}'"-->
            <!--                   placeholder="用户姓名"/>-->
            <!--          </div>-->
            <div class="span col-sm-2 form-group button-range" style="float: right">
              <button class="button_search button_spacing" @click="search()" v-el:cx>查询</button>
              <button class="button_clear button_spacing" @click="clear">清空</button>
              <!--            <div style="float: right" class="button_spacing"-->
              <!--                 :class="{'button_shrink_top': criteriaShow,'button_shrink_bottom': !criteriaShow}"-->
              <!--                 @click="criteriaShow = !criteriaShow"></div>-->
            </div>
            <!--          <div class="row" v-show="criteriaShow">-->
            <div class="col-sm-4 form-group">
              <label class="font_normal_body">联系人员</label>
              <input type="text" class="input_search"
                    style="width:60%"
                    v-model="model.f_user_name"
                    condition="f_user_name = '{}'"
                    placeholder="联&ensp;系&ensp;人"/>
            </div>
            <!--            <div class="col-sm-4 form-group">-->
            <!--              <label class="font_normal_body">用户编号</label>-->
            <!--              <input type="text" class="input_search"-->
            <!--                     style="width:60%"-->
            <!--                     v-model="model.f_userinfo_code"-->
            <!--                     condition="f_userinfo_code = '{}'"-->
            <!--                     placeholder="用户编号"/>-->
            <!--            </div>-->
            <!--<div class="col-sm-3 form-group">-->
            <!--<label class="font_normal_body">用户表号</label>-->
            <!--<input type="text" class="input_search"-->
            <!--v-model="model.f_meternumber"-->
            <!--style="width:60%"-->
            <!--condition="f_meternumber = '{}'"-->
            <!--placeholder="用户表号"/>-->
            <!--</div>-->
            <div class="col-sm-4 form-group">
              <label class="font_normal_body">联系电话</label>
              <input type="text" class="input_search"
                    style="width:60%"
                    v-model="model.f_phone"
                    condition="f_phone = '{}'"
                    placeholder="联系电话"/>
            </div>
            <br>
            <!--            <div class="col-sm-4 form-group">-->
            <!--              <label class="font_normal_body">起始时间</label>-->
            <!--              <datepicker placeholder='预约时间' style="width:60%"-->
            <!--                          v-model="model.f_orderdate_start"-->
            <!--                          :value.sync="model.f_orderdate_start"-->
            <!--                          :format="'yyyy-MM-dd'"-->
            <!--                          :show-reset-button="true"-->
            <!--                          condition="f_orderdate >= '{} 00:00:00'">-->
            <!--              </datepicker>-->
            <!--            </div>-->
            <!--            <div class="col-sm-4 form-group">-->
            <!--              <label class="font_normal_body">结束时间</label>-->
            <!--              <datepicker placeholder='结束时间' style="width:60%"-->
            <!--                          v-model="model.f_orderdate_end"-->
            <!--                          :value.sync="model.f_orderdate_end"-->
            <!--                          :format="'yyyy-MM-dd'"-->
            <!--                          :show-reset-button="true"-->
            <!--                          condition="f_orderdate <= '{} 00:00:00'">-->
            <!--              </datepicker>-->
            <!--            </div>-->
          </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>
            <th>
              <nobr>报装时间</nobr>
            </th>
            <th>
              <nobr>当前节点</nobr>
            </th>
            <th>
              <nobr>处理状态</nobr>
            </th>
            <th>
              <nobr>处理时间</nobr>
            </th>
            <th>
              <nobr>处&ensp;理&ensp;人</nobr>
            </th>
            <th>
              <nobr>处理意见</nobr>
            </th>
            <th>
              <nobr>操&emsp;&emsp;作</nobr>
            </th>
          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td style="text-align:center">{{ row.f_type }}</td>
            <td style="text-align:center">{{ row.f_user_name }}</td>
            <td style="text-align:center">{{ row.f_phone }}</td>
            <td style="text-align:center">{{ row.f_unit }}</td>
            <td style="text-align:center">{{ row.f_address }}</td>
            <td style="text-align:center">{{ row.f_orderremark }}</td>
            <td style="text-align:center">{{ row.f_orderdate }}</td>
            <td style="text-align:center">{{ row.f_apply_type ? row.f_apply_type : '待处理' }}</td>
            <td style="text-align:center">{{ row.f_apply_state ? row.f_apply_state : '待处理' }}</td>
            <td style="text-align:center">{{ row.f_apply_date ? row.f_apply_date : '待处理' }}</td>
            <td style="text-align:center">{{ row.f_person ? row.f_person : '待处理' }}</td>
            <td style="text-align:center;cursor: pointer;">
              <button type="button" name="button" class="btn btn-link"
                      @click="$parent.$parent.$parent.showSuggest(row.f_apply_msg)">点击查看
              </button>
            </td>
            <td style="text-align:center">
              <button type="button" name="button" class="btn btn-link" @click="$parent.$parent.$parent.dispose(row)">去处理
              </button>
            </td>
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>

    <modal :show.sync="suggetsShow" v-ref:model width="30%">
      <header slot="modal-header" class="modal-header">
        <h4 class="modal-title">处理意见</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="form-group">
          <p>{{ f_suggest }}</p>
        </div>
      </article>
      <div slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-default" @click="close()">关闭</button>
      </div>
    </modal>
  </div>

</template>

<script>
import {PagedList} from 'vue-client'

//   select oc.id
//   , oc.f_ordertype
//   , oc.f_user_name
//   , oc.f_phone
//   , oc.f_address
//   , oc.f_orderremark
//   , oc.f_orderdate
//   , replace(f_imageurl, 'xytrqfw.com', '222.16.16.161') as f_imageurl
//   , f_imagename
//   , replace(f_fileurl, 'xytrqfw.com', '222.16.16.161')  as f_fileurl
//   , f_filename
//   , info.f_apply_date
//   , info.f_apply_msg
//   , info.f_apply_state
//   , info.f_apply_type
//   , info.f_person
//   , ofa.f_type
//   ,ofa.f_unit
// from t_order_center oc
// left join t_order_for_apply ofa on ofa.id = oc.id
// left join (select max(id) id, F_ORDER_ID from T_APPLY_INFO group by F_ORDER_ID) maxinfo
// on maxinfo.F_ORDER_ID = oc.ID
// left join T_APPLY_INFO info on info.id = maxinfo.id
// where { condition }
// and oc.f_ordertype = '报装登记'
// order by oc.f_orderdate desc
export default {
  data () {
    return {
      model: new PagedList('/rs/sql/getOrderList', 20),
      f_orgids: this.$login.f.orgid,
      // f_orgids: '1522.255', //测试使用
      suggetsShow: false,
      f_suggest: ''
    }
  },

  ready () {
    // 默认查询待处理状态预约
    this.$refs.paged.$refs.criteria.model.f_orderstate = 'is null'
    this.search()
  },
  methods: {
    search () {
      this.$refs.paged.$refs.criteria.search()
    },
    selfSearch (args) {
      this.model.search(args.condition, args.model)
      this.dispose(null)
    },
    dispose (row) {
      this.$dispatch('dispose', row)
    },
    // 显示处理意见
    showSuggest (f_suggest) {
      this.f_suggest = f_suggest
      this.suggetsShow = true
    },
    close () {
      this.suggetsShow = false
    }
  },
  computed: {
    getState () {
      return [{label: '全部', value: ''}, {label: '待处理', value: 'is null'}, {
        label: '预约成功',
        value: '= \'预约成功\''
      }, {label: '预约失败', value: '= \'预约失败\''}]
    },
    orderType () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('预约类型')]
    }
  }
}
</script>
<style lang="less">
</style>
