<template>
  <el-dialog title="添加工序" v-model="visible" width="800px" height="600px"   @close="close" append-to-body draggable>
    <el-table
      ref="dialogTable"
      :data="processList"
      :row-key="getRowKey"
      size="small"
      v-loading="loading"
      border
      height="370px"
      header-row-class-name="list-header-row"
      row-class-name="list-row"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="index" label="行号" width="50" align="center" />
      <el-table-column label="工序步骤" align="center" prop="processStepNumber" />
      <el-table-column label="工序编码" align="center" prop="processCode" />
      <el-table-column label="工序简称" align="center" prop="processAlias" />
    </el-table>
  </el-dialog>
</template>
<script setup>
import { ref } from '@vue/reactivity'
import { getProcessDetail } from '@/api/business/daywork'
const { proxy } = getCurrentInstance()
/** 工序变量 */
const total = ref(0)
const processList = ref([])
const visible = ref(false)
const loading = ref(false)

/** 获取行 id */
function getRowKey(row) {
  return row.id
}

/**
 * 对话框打开 事件
 */
function open(data) {
  visible.value = true
  getList(data)
}

/**
 * 对话框关闭 事件
 */
function close() {
  visible.value = false
}

/**
 * 加载数据
 */
function getList(data) {
  loading.value = true
  getProcessDetail({isAmend:data.isAmend,isWasteRecycling:data.isWasteRecycling,technologicalProcessId:data.technologicalProcessId}).then((res) => {
    processList.value = res.data
    total.value = res.total
    loading.value = false
  })
}

/**
 * 列表checkbox列选择 事件
 */
function handleSelectionChange(selection) {
  selections.value = selection
}


/**  搜索 事件 */
function handleSearch(type) {
  if (type && type === 'clear') {
    queryParams.value = {
      processCode:'',
      processAlias: '',
      total: 0,
      pageSize: 10,
      pageNum: 1
    }
  }
  getList()
}
/** 多选事件 */
function handleMultipleSelected() {
  if (multipleSelected.value) {
    multipleSelected.value(selections.value)
  }
  close()
}

defineExpose({
  open
})
</script>
<style scoped></style>
