<template>
  <el-dialog title="电子图纸操作记录" v-model="visible" :width="width" @close="close" append-to-body draggable>
    <template #header>
      <span style="color: #fff">电子图纸操作记录</span>
    </template>
    <div class="page-container column-container">
      <el-table ref="dialogTable" :data="list" height="460px" row-key="id" align="center">
        <el-table-column label="行号" type="index" width="50" align="center" />
        <el-table-column label="操作人" prop="userName" align="center" />
        <el-table-column label="操作图纸名称" prop="drawingName" align="center" />
        <el-table-column label="产品描述"  align="center" >
          <template #default="scope" >
            <span>{{ scope.row.productDescription }}</span>
          </template>
        </el-table-column>
        <el-table-column label="工艺版本" prop="type" align="center" >
          <template #default="scope" >
            <span>{{ scope.row.productVersion }}</span>
          </template>
        </el-table-column>
        <el-table-column label="工序编码" prop="type" align="center"  >
          <template #default="scope" >
            <span>{{ scope.row.processCode }}</span>
          </template>
        </el-table-column>
        <el-table-column label="工序简称" prop="type" align="center"  >
          <template #default="scope" >
            <span>{{ scope.row.processAlias }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作时间" prop="createTime" align="center" />
        <el-table-column label="操作类型" prop="type" align="center" />
      </el-table>
      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </div>
    
  </el-dialog>
</template>
<script setup>
import { ref } from '@vue/reactivity'
import { listRecords } from '@/api/business/drawingRecords'
const { proxy } = getCurrentInstance()
const visible = ref(false)
/**设备弹窗变量 */
const total = ref(0)
const props = defineProps({
  width: {
    type: String,
    default: '900px'
  }
})
const list = ref([])

/**查询对象 */
const data = reactive({
  queryParams: {
    name: '',
    pageSize: 10,
    pageNum: 1
  }
})
const { queryParams } = toRefs(data)
/***********************  方法区  ****************************/
/**
 * 对话框打开 事件
 */
function open(row) {
  reset();
  visible.value = true
  if (row) {
    console.log(row)
    queryParams.value.productId = row.productId
    queryParams.value.productVersion = row.productVersion
    getList()

  }
}

/**
 * 对话框关闭 事件
 */
function close() {
  // proxy.$refs.dialogForm.resetFields()
  proxy.$refs.dialogTable.clearSelection()
  // handleSearch('clear')
  visible.value = false
}

/** 表单重置 */
function reset() {
  queryParams.value = {
    pageNum: 1,
    pageSize: 10,
  };
  proxy.resetForm("formRef");
}

/**
 * 加载数据
 */
function getList() {
  listRecords(queryParams.value).then((res) => {
    list.value = res.rows
    total.value = res.total
  })
}

defineExpose({
  open
})
</script>
