<template>
  <div>
    <a-collapse v-model="activeKeys" expand-icon-position="right" :bordered="false">
      <a-collapse-panel key="1" header="保单信息">
        <a-row class="policy_line" :gutter="10">
          <a-col :span="6">保险卡号：{{policyData.cardNo}}</a-col>
          <a-col :span="6">保单号码：{{policyData.policyNo}}</a-col>
          <a-col :span="6">保险计划：{{policyData.planName}}</a-col>
          <a-col :span="6">客户公司名称：{{policyData.corpName}}</a-col>
          <a-col :span="6">首次入保日期：{{dateFormat(policyData.firstEnrollmentTime)}}</a-col>
          <a-col :span="6">保单生效日期：{{dateFormat(policyData.startDate)}}</a-col>
          <a-col :span="6">保单终止日期：{{dateFormat(policyData.endDate)}}</a-col>
          <a-col :span="6">是否承担既往症：{{policyData.isUndertakeAnamnesis | yesFilters }}</a-col>
          <a-col :span="6">保单直付区域：{{areaFilter(policyData.policyDircetArea)}}</a-col>
          <a-col :span="6">是否等待期: {{policyData.waitingPeriod  | yesFilters}}</a-col>
          <a-col :span="6">其他备注：{{policyData.remark}}</a-col>
        </a-row>
      </a-collapse-panel>
    </a-collapse>
  </div>
</template>

<script>
import moment from 'moment'

export default {
  props: {
    policyData: {
      default: {},
    },
  },
  data() {
    return {
      activeKeys: "1",
      areaCode: []
    };
  },
  filters: {
    yesFilters(value) {
      const data = {
        Y: '是',
        N: '否'
      };
      return data[value];
    }
  },
  created() {
    this.initCodeData();
  },
  methods: {
    areaFilter(value) {
      if (! value) {
          return '';
      }
      for (let i = 0; i < this.areaCode.length; i ++) {
        if (this.areaCode[i].refcd === value) {
          return this.areaCode[i].descCh
        }
      }
      return value
    },
    dateFormat(val) {
      return val && moment(val).format('YYYY-MM-DD')
    },
    initCodeData() {
      const params = {
        areaCode: {
          modid: "CI",
          refgrp: "POLICY_DIRECT_AREA"
        },
      }
      for (let i in params) {
        this._getRefcdByRefgrp(params[i], i)
      }
    },
    _getRefcdByRefgrp(data, prop) {
      if (this[prop] && this[prop].length) {
        return true
      }
      this.$apis.GETREFCDBYREFGRP(data).then((res) => {
        this[prop] = res.content || [];
      });
    },
  }
};
</script>

<style lang="less" scoped>
.policy_line {
  .pa(0, 30, 0, 30);
  line-height: 60px;
  .ant-col{
    border-bottom: 1px solid #f8fafb;
  }
}
</style>
