<template>
<el-dialog
  :modal="true"
  :close-on-click-modal="false"
  :close-on-press-escape="false"
  destroy-on-close
  width="70%"

  title="清洗记录详情"
  :model-value="dialogVisible"

  :before-close="handleClose"

>
  <my-table
    :headers="headerArr"
    :table-data="tableData"
  :page-size="8"
  ></my-table>
</el-dialog>
</template>

<script>
import {onBeforeMount, ref} from "vue";
import {getDialogTableData} from "@/service/clear-record";
import MyTable from "@/components/common/MyTable.vue";
import {formatDateFun} from "@/unit/time";

export default {
  name: "ClearRecordDialog",
  components: {MyTable},
  props:{
    dialogVisible:{

    },
    currentDialogOpObj:{

    }
  },
  setup(props,{emit}){
    const tableData = ref([])
    const headerArr = ref([])
    onBeforeMount(() => {
      getDialogTableData(props.currentDialogOpObj.CID,formatDateFun(+new Date(props.currentDialogOpObj.RUN_TIME),'yyyy-MM-dd'),props.currentDialogOpObj.TYPE_CODE).then(res => {
        let header = []
        try {
          if (res.msg[0]?.Rows ){
            headerArr.value  = Object.keys(res.msg[0].Rows[0]).map(key => ({
              label:key,
              prop:key
            }))
          }
        }catch {
          headerArr.value = []
        }

        tableData.value = res.msg[0]?.Rows||[]
      })
    })
    function handleClose() {
      emit('update:dialogVisible',false)
    }
    return {
      handleClose,
      headerArr,
      tableData
    }
  }
}
</script>

<style scoped lang="scss">

</style>
