<template>
  <el-dialog
    :model-value="modelValue"
    title="修正工单印件质量考核设置"
    fullscreen
    :before-close="()=>{emits('update:modelValue', false )}"
  >
    <el-button
      type="primary"
      disabled
      style="width:80px; height: 40px;margin-bottom: 20px"
      @click=""
    >更新</el-button>
    <el-button
      type="primary"
      style="width:80px; height: 40px;margin-bottom: 20px"
      @click="emits('update:modelValue', false )"
    >退出</el-button>

    <el-form
      inline
      @submit.native.prevent
    >
      <el-form-item label="工单编号">
        <el-input
          v-model="input"
          autocomplete="off"
          style="width: 100px"
          @keyup.enter="handleGetTable"
        />
      </el-form-item>

      <el-table
        :data="tableData"
        border
        height="70vh"
        :row-style="{ height: '20px' }"
        :cell-style="{ padding: '0px' }"
        :header-row-style="{ height: '20px' }"
        :header-cell-style="{ padding: '0px' }"
      >
        <el-table-column
          label="工单编号"
          width="100"
          prop="Yj_gdbh"
        />

        <el-table-column
          label="印件编码"
          width="100"
          prop="yj_Yjdh"
        />

        <el-table-column
          label="印件号"
          width="100"
          prop="yj_Yjno"
        />

        <el-table-column
          label="印件名称"
          width="400"
          prop="yj_yjmc"
        />

        <el-table-column
          label="当前考核设置"
          width="150"
          prop="当前考核设置"
        />
        <el-table-column
          label="新考核设置"
          width="150"
        >

          <template #default="{ row }">
            <!-- 使用 el-select 来创建选择框 -->
            <el-select
              v-model="row.新考核设置"
              placeholder="请选择"
            >
              <el-option
                label="参与"
                value="参与"
              />
              <el-option
                label="剔除"
                value="剔除"
              />
            </el-select>
          </template>

        </el-table-column>

      </el-table>

    </el-form>
  </el-dialog>

</template>

<script>
export default {
  name: 'Khsz',
}

// 4.1考核设置-获取工单印件资料
import service from '@/utils/request'
export const getOrderYj = (params) => {
  return service({
    url: '/mes_server/order_super_loss/getOrderYj',
    method: 'get',
    params
  })
}

</script>

<script setup>
import { watch, ref, reactive, defineProps, defineEmits, onBeforeUnmount } from 'vue'

const props = defineProps(['modelValue', 'gdbh'])
const emits = defineEmits(['update:modelValue'])
const input = ref(props.gdbh)
const tableData = ref([])
const handleGetTable = async() => {
  const res = await getOrderYj({ order: input.value })
  if (res['code'] === 0) {
    const { data } = res
    data['当前考核设置'] = data['质量考核'] === 0 ? '参与' : '剔除'
    data['新考核设置'] = data['当前考核设置']
    const arr = [data]
    console.log(arr)
    tableData.value = arr
  }
}
</script>

<style scoped>

</style>
