<script setup lang="ts">

import { removeRecord} from "@/api/fault";
import ShowVue from "@/views/quality/reject/components/show.vue";



const props = defineProps({
  row: {
    type: Object,
    required: true,
  },
});
const row=ref(null);
onMounted(async () => {
  removeRecord(props.row.businessId).then(
       (data)=>{
         row.value=data.data;
       }
   );
});
const tableData=ref();
const showState=ref(false);
const toShow = () => {
  tableData.value = setJson(row.value);
  showState.value = true;
};
const setJson = (row1) => {
  const row = JSON.parse(JSON.stringify(row1));
  //处理初始值
  let obj = {
    content: "",
    user1: "",
    user2: "",
    user3: "",
    user4: "",
    user5: "",
    user6: "",
    user7: "",
    time: "",
    state: "-1",
  };
  if (row.remark1 == "") {
    row.remark1 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark1)).length == 0) {
      row.remark1 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark1 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark1),
      };
    }
  }
  if (row.remark2 == "") {
    row.remark2 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark2)).length == 0) {
      row.remark2 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark2 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark2),
      };
    }
  }
  if (row.remark3 == "") {
    row.remark3 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark3)).length == 0) {
      row.remark3 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark3 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark3),
      };
    }
  }
  if (row.remark4 == "") {
    row.remark4 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark4)).length == 0) {
      row.remark4 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark4 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark4),
      };
    }
  }
  if (row.remark5 == "") {
    row.remark5 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark5)).length == 0) {
      row.remark5 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark5 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark5),
      };
    }
  }
  if (row.remark6 == "") {
    row.remark6 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark6)).length == 0) {
      row.remark6 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark6 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark6),
      };
    }
  }
  if (row.remark7 == "") {
    row.remark7 = JSON.parse(JSON.stringify(obj));
  } else {
    if (Object.keys(JSON.parse(row.remark7)).length == 0) {
      row.remark7 = JSON.parse(JSON.stringify(obj));
    } else {
      row.remark7 = {
        ...JSON.parse(JSON.stringify(obj)),
        ...JSON.parse(row.remark7),
      };
    }
  }
  return row;
};


</script>

<template>
  <div class="box">

    <el-button
        type="success"
        style="margin-bottom: 10px"
        @click="toShow()"
    >查看剔除信息</el-button
    >
  </div>
  <ShowVue v-model="showState" :tableData="tableData" />

</template>

<style>
.cell-item {
  display: flex;
  align-items: center;
}
</style>
