<template>
  <a-modal
    v-model:visible="modeVisible"
    class="custom-class"
    :title="typeData.title"
    placement="right"
    width="1800px"
    :closable="false"
    @ok="submit">
    <normalTable v-if="modeVisible" rowKey="w_areaid" ref="list" size="small" :param="param" :columns="utils.TBLayout(typeData.Table)">
      <template #tb_cell="{data}">
        <div v-if="data.column.dataIndex == 'issend'">
          {{ data.record.issend == 0 ? '未发送' : '已发送' }}
        </div>
        <div v-else-if="data.column.dataIndex == 'content'">
          <div v-if="typeData.title == '上传日志'">
            {{ data.record.content }}
          </div>
          <div style="width: 200px;display: flex;flex-wrap: wrap;" v-else>
            <a-tag v-for="item in data.record.content">{{ item.title }} : {{ item.value }}</a-tag>
          </div>
        </div>
        <div v-else-if="data.column.dataIndex == 'isreceive'">
          {{ data.record.isreceive ? '已接收' : '未接收' }}
        </div>
        <div v-else-if="data.column.dataIndex == 'invalid'">
          {{ data.record.isreceive ? '已失效' : '未失效' }}
        </div>
        
      </template>
    </normalTable>
  </a-modal>
</template>

<script setup>
import normalTable from '@/template/normalTable/index.vue'
import {ref, defineProps, defineEmits, computed, watch} from 'vue'
import Api from '@/api/api'
import utils from '@/utils/utils'
import {useRouter} from 'vue-router'
let router = useRouter()
let emit = defineEmits([''])
let props = defineProps({})
let modeVisible = ref(false)
let type = ref(0)
let param = ref({
  id:20230701132202,
  content: {
    w_deviceid:router.currentRoute.value.query.id,
    'type': 0
  }
})

let list = ref()

watch(() => modeVisible.value,(val) => {
  if (!val) param.value.content.pageNumber = 1
})

let typeData = computed(() => {
  let data
  switch (type.value) {
    case 0:
      data = {
        title:'操作记录',
        Table:'historyTable'
      }
      break;
    case 1:
      console.log('触发1111');
      data = {
        title:'上传日志',
        Table:'uploadHistory'
      }
      break;
    default:
      data = {
        title:'操作队列',
        Table:'handleQueue'
      }
      break;
  }
  return data
})

let listData = () => {
  list.value.listData()
}

defineExpose({
  type,
  param,
  modeVisible,
  param,
  listData
})
</script>

<style scoped>

</style>
