<template>
  <div>
    <!--1.技术主管审批-->
    <div>
      <!-- 执行顺序 -->
      <Alert class="equip_alert">
        <div>
          <table class="tableClass table1Class">
            <tbody>
              <tr>
                <th colspan="4" style="text-align: center;font-size: 15px">
                  仪器预约申请单
                </th>
              </tr>
              <tr>
                <th>设备id</th>
                <td>{{ getObj.name }}</td>
                <th>预约使用地点</th>
                <td>{{ getObj.orderLocation }}</td>
              </tr>
              <tr>
                <th>预约开始时间</th>
                <td>{{ this.$dateformat(getObj.orderStartTime, "yyyy-mm-dd HH:MM") }}</td>
                <th>预约结束时间</th>
                <td>{{ this.$dateformat(getObj.orderEndTime, "yyyy-mm-dd HH:MM") }}</td>
              </tr>
              <tr>
                <th>申请原因</th>
                <td>{{ getObj.applyReason }}</td>
                <th>申请人</th>
                <td>{{ getObj.applyName }}</td>
              </tr>
              <tr>
                <th>申请时间</th>
                <td>{{ this.$dateformat(getObj.applyTime, "yyyy-mm-dd HH:MM") }}</td>
                <th>备注</th>
                <td>{{ getObj.remark }}</td>
              </tr>
              <tr>
                <th>技术主管</th>
                <td>{{ getObj.firstStepId }}</td>
                <th>技术主管审批时间</th>
                <td>{{ this.$dateformat(getObj.firstStepTime, "yyyy-mm-dd HH:MM") }}</td>
              </tr>
              <tr>
                <th>技术主管意见</th>
                <td colspan="3">
                  {{ getObj.firstStepAdvice }}
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </Alert>
    </div>
    <!--操作-->
    <div slot="footer" align="center" style="margin-top:380px">
      <Button type="error" @click="_approve()">
        确定
      </Button>
    </div>
  </div>
</template>
<script>
import global from '../../../../api/config'
import { equipOrder } from '../../../../api'
export default {
  data() {
    return {
      id: {},
      getObj: {}
    }
  },
  mounted() {
    this.id = this.$route.query.id
    this._order()
  },
  methods: {
    _order: async function() {
      this.getObj = await equipOrder.getById(this.id)
    },
    _approve() {
      this.$Modal.confirm({
        title: '提示',
        content: '确认？',
        onOk: () => {
          const data = {}
          data.id = $('#flowFrame', parent.document).attr('data-tid')
          data.status = 'success' // 确认通知申请人
          this._approveOk(data)
        }
      })
    },
    _approveOk: async function(data) {
      const result = await equipOrder.approve(data)
      if (result) {
        this.$Message.success('审批成功！')
        setTimeout(() => {
          parent.location.replace(global.webURL + '/sys/workflow/flow_task')
        }, 200)
      }
    }
  }
}
</script>
