<template>
  <div>
    <div class="utable" v-if="props.uitem.regular != undefined || props.uitem.escalation != undefined">
      <div class="utabletitle" v-if="props.uitem.regular.objects != null">{{ props.uitem.regular.objects.areaName }}商品住房购买对象分类表
      </div>
      <div class="utabletitle" v-else>{{ props.uitem.escalation.objects.areaName }}商品住房购买对象分类表</div>
      <div class="utabletop">
        <div>{{ props.uitem.regular.objects != null ? props.uitem.regular.objects.date : props.uitem.escalation.objects.date }}
        </div>
        <div>单位：元、平方米、元/平方米、套</div>
      </div>
      <el-card shadow="hover" class="layout-padding-auto mb10">
        <div class="ctitle">
          <div class="title">手动上传</div>
        </div>
        <div v-if="state.handitem != null">
          <handTemple :udata="state.handitem"></handTemple>
        </div>
        <div v-else class="errornone">
          <el-empty description="暂无手动上传数据"></el-empty>
        </div>
      </el-card>
      <el-card shadow="hover" class="layout-padding-auto mb10">
        <div class="ctitle">
          <div class="title">自动上传</div>
        </div>
        <div v-if="state.autoitem != null">
          <autoTemple :udata="state.autoitem"></autoTemple>
        </div>
        <div v-else class="errornone">
          <el-empty description="暂无自动上传数据"></el-empty>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import {
  defineAsyncComponent,
  reactive,
  watch,
} from "vue";
import { ElMessage } from "element-plus";
import { getCons } from "/@/api/report/provinces";

// 自动
const autoTemple = defineAsyncComponent(
  () => import("/@/views/report/provinces/components/tablecomponents/fivetable/auto.vue")
);

// 手动
const handTemple = defineAsyncComponent(
  () => import("/@/views/report/provinces/components/tablecomponents/fivetable/hand.vue")
);


const state = reactive({
  autoitem: {} as any,
  handitem: {} as any
})


const props = defineProps({
  uitem: {
    type: Object,
    default: {},
  }
});
watch(
  () => props.uitem,
  (newVal) => {
    let _regular = newVal.regular.objects;
    let _escalation = newVal.escalation.objects;
    if (_regular != null && _escalation != null) {
      for (const [key, value] of Object.entries(_regular)) {
        if (_escalation != null) {
          for (const [keys, values] of Object.entries(_escalation)) {
            if (keys == key) {
              !Object.is(value, values) ? _escalation[`${keys}tag`] = 1 : _escalation[`${keys}tag`] = 0
            }
          }
        }
      }
    }
    state.autoitem = _regular
    state.handitem = _escalation
  },
)
</script>
<style lang="scss" scoped></style>
