<template>
  <div class="population-drawer">
    <m-card title="相关案件">
      <div
        v-for="(item, i) in caseList"
        :key="i"
        class="case-item"
        :class="{ done: item.status === 1 }"
      >
        <div>
          <p>
            <span>{{ item.type }}</span>
            {{ item.address }}
          </p>
          <p>{{ item.date }}</p>
        </div>
        <div>{{ item.content }}</div>
        <div v-if="item.status === 1" class="flag">已结案</div>
        <div v-else class="flag">处置中</div>
      </div>
    </m-card>
    <m-card title="人口详情">
      <Tabs class="tabs" :list="tabs" horizontal />
      <SubTitle>基本信息</SubTitle>
      <m-form :layout="layout1" :model="data1" :label-width="1.1" />
      <SubTitle>房主信息</SubTitle>
      <m-form :layout="layout2" :model="data2" :label-width="1.1" />
      <Tabs class="tabs" :list="tabs2" horizontal />
      <m-form :layout="layout3" :model="data3" :label-width="1.1" />
    </m-card>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import Tabs, { TabsProp } from '../components/tabs.vue'
import SubTitle from '../components/sub-title.vue'

export default defineComponent({
  name: 'PopulationDrawer',
  components: { Tabs, SubTitle },
  setup() {
    const caseList = ref([
      {
        address: 'XX区XX路XX弄XX号',
        date: '2021-01-23 ~ 2021-01-24',
        type: '案件分类',
        status: 1,
        content:
          '案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述',
      },
      {
        address: 'XX区XX路XX弄XX号',
        date: '2021-01-23 ~ 2021-01-24',
        type: '案件分类',
        status: 0,
        content:
          '案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述',
      },
      {
        address: 'XX区XX路XX弄XX号',
        date: '2021-01-23 ~ 2021-01-24',
        type: '案件分类',
        status: 0,
        content:
          '案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述案件内容及描述',
      },
    ])
    const tabs = ref<TabsProp[]>([
      {
        key: 'person',
        name: '实住人',
      },
      {
        key: 'house',
        name: '房屋信息',
      },
    ])
    const tabs2 = ref<TabsProp[]>([
      {
        key: 'community',
        name: '小区信息',
      },
      {
        key: 'room',
        name: '门牌户室',
      },
      {
        key: 'property',
        name: '物业信息',
      },
      {
        key: 'committee',
        name: '业委会',
      },
      {
        key: 'device',
        name: '设施设备',
      },
      {
        key: 'public',
        name: '公共设施',
      },
    ])
    const layout1 = ref([
      {
        community: {
          label: '所属小区',
          width: 12,
        },
        building: {
          label: '门牌幢',
          width: 12,
        },
      },
      {
        communityType: {
          label: '小区类型',
          width: 12,
        },
        roomNo: {
          label: '室号',
          width: 12,
        },
      },
      {
        company: {
          label: '物业公司',
          width: 12,
        },
        manager: {
          label: '物业经理',
          width: 12,
        },
      },
      {
        manageOffice: {
          label: '管理处',
          width: 12,
        },
        hasElev: {
          label: '有无电梯',
          width: 12,
        },
      },
      {
        yewei: {
          label: '业委会',
          width: 12,
        },
        juwei: {
          label: '居委会',
          width: 12,
        },
      },
    ])
    const data1 = ref({
      community: '测试文字',
      building: '测试文字',
      communityType: '测试文字',
      roomNo: '测试文字',
      company: '测试文字',
      manager: '测试文字',
      manageOffice: '测试文字',
      hasElev: '测试文字',
      yewei: '测试文字',
      juwei: '测试文字',
    })
    const layout2 = ref([
      {
        name: {
          label: '姓名',
          width: 12,
        },
        phone: {
          label: '手机号码',
          width: 12,
        },
      },
      {
        household: {
          label: '户籍',
          width: 12,
        },
      },
    ])
    const data2 = ref({
      name: '暂无',
      phone: '暂无',
      household: '暂无',
    })
    const layout3 = ref([
      {
        name: {
          label: '小区名称',
          width: 24,
        },
      },
      {
        address: {
          label: '小区地址',
          width: 12,
        },
        belong: {
          label: '所属居委会',
          width: 12,
        },
      },
      {
        buildingNum: {
          label: '总门牌幢数',
          width: 12,
        },
        roomNum: {
          label: '总户数',
          width: 12,
        },
      },
      {
        buidlingArea: {
          label: '总建筑面积',
          width: 12,
        },
        area: {
          label: '占地面积',
          width: 12,
        },
      },
      {
        rang: {
          label: '小区四至范围',
          width: 12,
        },
        excludeRang: {
          label: '小区四至范围不包括',
          width: 12,
        },
      },
    ])
    const data3 = ref({
      name: '测试文字',
      address: '测试文字',
      belong: '测试文字',
      buildingNum: '测试文字',
      roomNum: '测试文字',
      buidlingArea: '测试文字',
      area: '测试文字',
      rang: '测试文字',
      excludeRang: '测试文字',
    })
    return {
      caseList,
      tabs,
      tabs2,
      layout1,
      data1,
      layout2,
      data2,
      layout3,
      data3,
    }
  },
})
</script>

<style lang="stylus" scoped>
@import '../../components/MyComponent/main.styl'
$border = .01rem solid rgba(91,213,255,.3)

.population-drawer
  display flex
  justify-content space-between
  >div
    width 35%
    &:last-child
      width 64%
  .tabs
    margin .1rem 0
  .case-item
    position relative
    border $border
    border-left .02rem solid $secondary-color
    margin .1rem 0
    padding .05rem .1rem
    overflow hidden
    background rgba(51,145,255,.1)
    &.done
      border-left-color #27C5A2
      .flag
        background #27C5A2
    >div
      &:nth-of-type(1)
        border-bottom $border
        padding-bottom .05rem
        margin-bottom .05rem
        p
          span
            display inline-block
            color orange
            border .01rem solid orange
            border-radius .02rem
            margin-right .1rem
            padding 0 .03rem
            font-size .08rem
          &:last-child
            color #aaa
            font-size .08rem
            margin-top .05rem
    .flag
      background $secondary-color
      position absolute
      top -0.08rem
      right -0.28rem
      transform rotate(45deg)
      height .4rem
      width .8rem
      display flex
      align-items flex-end
      justify-content center
      font-weight bold
      padding-bottom .02rem
</style>
