<template>
  <div :style="{'height':needRepair?'60%':'100%'}">

    <criteria-paged :model="model" v-ref:paged>
      <data-grid :model="$parent.model" partial='list' class="table_sy">

        <template partial='head'>
          <tr>
            <th>
              <nobr>维修人</nobr>
            </th>
            <th>
              <nobr>维修地址</nobr>
            </th>
            <th>
              <nobr>维修时间</nobr>
            </th>
            <th>
              <nobr>维修人电话</nobr>
            </th>
            <th>
              <nobr>操作</nobr>
            </th>
          </tr>
        </template>

        <template partial='body'>
          <td style="text-align: center">
            <nobr>{{row.f_order_man}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_address}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_created_date}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_contact_phone}}</nobr>
          </td>
          <td style="text-align: center">
            <button class="button_spacing button_search-1" @click="$parent.$parent.$parent.repairlist(row)">查看</button>
          </td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>

</template>

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

export default {
  title: '维修记录',
props:['check'],
  data(){
    return{
      service: null,
      // 是否显示详情modal
      repaierShow: false,
      isshow: false,
      show: false,
      takeshow:false,   // 操作面板显示
      repair: {},
      rowOne:{},
      evaluate: {},
      curActivity:{},
      num: 14,
      wavflie : '',
      model: new PagedList('api/af-safecheck/sql/safe_singleTable_OrderBy', 20, {items: '"a.*"', tablename: '"t_serviceworkorder a with (nolock)  left join t_servicework b with (nolock)  on a.id = b.serviceid"', orderitem: '"1"'}),
    }
  },
  watch: {
    'check'() {
      if (!this.check.f_userinfo_code) {
        return this.$showMessage("报修单获取用户ID错误！！！")
      }
      this.model.search(`a.f_workorder_type = '报修单' and a.f_userinfo_code = '${this.check.f_userinfo_code}' and b.id is not null`)
    }
  },
  ready(){
    this.model.search(`a.f_workorder_type = '报修单' and a.f_userinfo_code = '${this.check.f_userinfo_code}' and b.id is not null`)
  },
  methods:{
     async repairlist(row) {
       let serviceWork  = await new HttpResetClass().load('POST', `api/af-apply/logic/getService`, {data: {id: row.id}}, {
         resolveMsg: null,
         rejectMsg: null
       })
       if (!serviceWork){
         this.$showMessage("维修单数据异常")
         return
       }
       const targetIndex = serviceWork.data[0].serviceacitivity.findIndex(item => item.type === "t_servicework");

       this.$goto('new-repair-paper', {service: serviceWork.data[0], row: row, cur_activity: serviceWork.data[0].serviceacitivity[targetIndex]}, 'self')
    }
  }
}


</script>


<style lang="less" scoped>
.select-error {
  button {
    border-bottom: 1px solid #a94442 !important;
  }
}
</style>


