<template>
  <el-dialog
    title="工单更新记录"
    v-if="showFlag"
    :visible.sync="showFlag"
    :modal="true"
    width="80%"
    append-to-body
  >
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      inline
      v-show="showSearch"
      label-width="110px"
    >
    <el-form-item label="工单名称" prop="workorderName">
          <el-input
            v-model="queryParams.workorderName"
            placeholder="请输入工单名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="工单编码" prop="workorderCode">
          <el-input
          @keyup.enter.native="handleQuery"
            v-model="queryParams.workorderCode"
            placeholder="请输入工单编码"
            clearable
          />
        </el-form-item>
        <el-form-item label="请求类型" prop="actionType">
          <el-select v-model="queryParams.actionType" placeholder="请选择请求类型" clearable>
            <el-option
            v-for="dict in dict.type.sap_action_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          >
          </el-option>          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="processRoutesList"
    >
          <el-table-column label="工单名称" align="center" prop="workorderName" />
        <el-table-column label="工单编码" align="center" prop="workorderCode" />
        <el-table-column label="请求类型" align="center" prop="actionType" />
        <el-table-column label="更新时间" align="center" prop="createTime" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <div slot="footer" class="dialog-footer">
      <!-- <el-button type="primary" @click="confirmSelect">确 定</el-button> -->
      <el-button @click="showFlag = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { listRecord } from "@/api/mes/pro/workorderRecord";

export default {
  name: "workorderRecordSelect",
  dicts: ['sap_action_type'],
  components: {},
  props: {
    data: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      showFlag: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      processList: [],
      // 品牌表格数据
      processRoutesList: [],
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
    };
  },
  watch: {
    data: {
      handler() {
        this.getList()
        this.queryParams.pageNum = 1
      },
      deep: true,
      immediate:true
    }
  },
  created() {
    // this.getList();
  },
  methods: {
    /** 查询工厂列表 */
    getList() {
      this.queryParams.workorderId = this.data.workorderId
      this.loading = true;
      listRecord(this.queryParams).then((response) => {
        this.processRoutesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  },
};
</script>
