<template>
  <div>
    <el-dialog
      :visible.sync="showModal"
      title="流程详情"
      fullscreen
      top="0"
    >
      <div>
        <!-- 执行顺序 -->
        <Alert class="equip_alert">
          <div>
            <table class="tableClass table1Class">
              <tbody>
                <tr>
                  <th colspan="6" style="text-align: center;font-size: 15px">
                    仪器采购申请单
                  </th>
                </tr>
                <tr>
                  <th>申请编号</th>
                  <td>{{ getOrder.num }}</td>
                  <th>申请人</th>
                  <td>{{ getOrder.applyName }}</td>
                </tr>
                <tr>
                  <th>申请原因</th>
                  <td>{{ getOrder.applyReason }}</td>
                  <th>申请时间</th>
                  <td>{{ this.$dateformat(getOrder.applyTime, "yyyy-mm-dd HH:MM") }}</td>
                </tr>
                <tr>
                  <th>备注</th>
                  <td colspan="3">
                    {{ getOrder.remark }}
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </Alert>
      </div>
      <!--内容-->
      <div>
        <element-table
          ref="pageTable"
          :table-height="500"
          :get-page="getPage"
          @on-result-change="_tableResultChange"
        >
          <el-table-column
            v-for="item in pageColumns"
            :key="item.key"
            show-overflow-tooltip
            sortable
            :prop="item.key"
            :label="item.title"
            :min-width="item.width"
            :fixed="item.fixed?item.fixed:undefined"
          >
            <template slot-scope="scope">
              <div>
                {{ scope.row[item.key] }}
              </div>
            </template>
          </el-table-column>
        </element-table>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { equipPurchaseDetail, equipPurchase } from '../../../../api'

export default {
  data() {
    return {
      id: '',
      showModal: false,
      getPage: {},
      pageColumns: [
        { title: '仪器名称', key: 'name', width: 200 },
        { title: '规格型号', key: 'spec', width: 200 },
        { title: '数量', key: 'counts', width: 160 },
        { title: '供应商', key: 'supplierName', width: 200 },
        { title: '制造厂商', key: 'productPlace', width: 200 },
        { title: '用途', key: 'uses', width: 160 },
        { title: '备注', key: 'remark', width: 160 }
      ],
      getOrder: {}
    }
  },
  methods: {
    _open(id) {
      this.showModal = true
      this.$nextTick(function() {
        this.id = id
        this._page()
        this._purchase()
      })
    },
    _page: async function() {
      const obj = Object.assign(
        { purchaseId: this.id },
        this.$refs.pageTable._searchParams()
      )
      const result = await equipPurchaseDetail.page(obj)
      if (result) {
        this.getPage = result
        this.$refs.pageTable._initTable()
      }
    },
    _tableResultChange(msg, data) {
      switch (msg) {
        case 'page':
          this._page()
          break
      }
    },
    _purchase: async function() {
      this.getOrder = await equipPurchase.getById(this.id)
    }
  }
}
</script>
