<template>
  <div>
    <el-table v-loading="loading" :data="orderList">
      <el-table-column align="center" type="index" label="#"></el-table-column>
      <el-table-column align="center" label="订单编号" width="200" prop="orderNo"></el-table-column>
      <el-table-column align="center" label="运维用户" prop="adminName"></el-table-column>
      <el-table-column align="center" label="手机号" prop="phone"></el-table-column>
      <el-table-column align="center" label="故障部位" prop="faultTypeStr"></el-table-column>
      <el-table-column prop="status" label="工单状态" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.et_admin_order_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column align="center" label="完成时间" prop="createTime"></el-table-column>
    </el-table>

    <pagination
      :auto-scroll="false"
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getOrderList"
    />
  </div>
</template>

<script>
import { listOrder } from "@/api/system/adminOrder";

export default {
  name: 'repairRecord',
  dicts: ['et_admin_order_status'],
  props: {
    // 设备id
    sn: {
      type: String,
      default: null
    }
  },
  data() {
    return {
      orderList: [], // 充值记录列表
      loading: false,
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type: 1,
        sn: null,
      }
    }
  },
  watch: {
    sn(nv, ov) {
      this.getOrderList(nv);
    }
  },
  created() {
    this.getOrderList(this.sn);
  },
  methods: {
    // 获取充值记录
    getOrderList(sn) {
      if(sn == null) {
        this.recordList = [];
        this.total = 0;
        return;
      }
      this.loading = true;
      this.queryParams.sn = sn | this.sn;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
      }).finally(() => {
        this.loading = false;
      });
    }
  }
}
</script>
