<template>
  <el-dialog
    :title="$t('工单更新记录')"
    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="$t('工单名称')" prop="workorderName">
          <el-input
            v-model="queryParams.workorderName"
           
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item :label="$t('工单编码')" prop="workorderCode">
          <el-input
          @keyup.enter.native="handleQuery"
            v-model="queryParams.workorderCode"
           
            clearable
          />
        </el-form-item>
        <el-form-item :label="$t('请求类型')" prop="actionType">
          <el-select v-model="queryParams.actionType" 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">{{ $t('common.search') }}</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('common.reset') }}</el-button>
        </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="processRoutesList"
    >
          <el-table-column :label="$t('工单名称')" align="center" prop="workorderName" />
        <el-table-column :label="$t('工单编码')" align="center" prop="workorderCode" />
        <el-table-column :label="$t('请求类型')" align="center" prop="actionType" />
        <el-table-column :label="$t('更新时间')" 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">{{ $t('common.confirm') }}</el-button> -->
      <el-button @click="showFlag = false">{{ $t('common.cancel') }}</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>
