<template>
  <el-dialog
    :model-value="modelValue"
    title="工序产量核查"
    fullscreen
    :before-close="()=>{emits('update:modelValue', false )}"
  >
    <el-button
      type="primary"
      style="width:80px; height: 40px;margin-bottom: 20px"
      @click="emits('update:modelValue', false )"
    >退出</el-button>

    <el-form inline>
      <el-form-item label="工单编号">
        <el-input
          v-model="input"
          style="width: 100px"
          @keyup.enter="handleGetTable"
        />
        <el-input
          v-model="cpmc"
          class="cpmc"
          readonly
          style="width: 400px;margin-left: 3px"
        />
      </el-form-item>

      <el-table
        :data="tableData"
        border
        highlight-current-row
        show-overflow-tooltip
        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="250"
          prop="Gy0_yjno"
        />

        <el-table-column
          label="工序计划产量"
          width="120"
          prop="Gy0_计划接货数"
        />

        <el-table-column
          label="联数"
          width="80"
          prop="Gy0_ls"
        />

        <el-table-column
          label="折算车头产量"
          width="120"
          prop=""
        />

        <el-table-column
          label="实际上报产量"
          width="120"
          prop="Gy0_ls"
        />
        <el-table-column
          label="制程废品"
          width="120"
          prop=""
        />
        <el-table-column
          label="制程废品率"
          width="120"
          prop="制程废品率"
        />
        <el-table-column
          label="来料异常"
          width="120"
          prop="来料异常"
        />
        <el-table-column
          label="流程单数"
          width="120"
          prop="process_num"
        />
        <el-table-column
          label="当前设备"
          width="120"
          prop="Gy0_sbbh"
        />
        <el-table-column
          label="工序状态"
          width="120"
          prop="PD_WG"
        />
        <el-table-column
          label="首板生产日期"
          width="120"
          prop="sczl_rq"
        />

      </el-table>

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

</template>

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

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

const getGxMc = (params) => {
  return service({
    url: '/mes_server/packaging_count_document/getGxMc',
    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 cpmc = ref('')
const tableData = ref([])
const handleGetTable = async() => {
  const ret = await getGxMc({ gdbh: input.value })
  if (ret['code'] === 0) {
    cpmc.value = ret['data'][0]['Gd_cpmc']
    console.log(ret['data'])
  }
  const res = await getOrderProcessCount({ order: input.value })
  if (res['code'] === 0) {
    const { data } = res
    tableData.value = data.map(item => ({
      ...item,
      Gy0_yjno: `${item['Gy0_yjno']}-${item['Gy0_gxh']} ${item['Gy0_gxmc']} ${item['Add_gxmc']}`,
    }))
  }
}
handleGetTable()
</script>

<style scoped>
:deep(.cpmc .el-input__inner) {
  color: red !important;
}
</style>
