<template>
  <view class="ComCss">
    <cardMoudule :cardData="data1" :required="false" :title="fiscalYear+'财年市场开发目标'"></cardMoudule>
    <cardMoudule :cardData="data2" :required="true" title="市场开发对策"></cardMoudule>
  </view>
</template>

<script>
  import cardMoudule from "./cardMoudule.vue"
  export default {
    components: {
      cardMoudule
    },
    props: {
      reportData: {
        type: Object
      },
      fiscalYear:{
        type:String
      }
    },
    data() {
      return {
        data1: [{
            cardType: 1,
            required: true,
            title: `${this.fiscalYear}财年目标计划签约(户)`,
            value: "",
            key:"planSignHousehold"
          },
          {
            cardType: 1,
            required: true,
            title: `${this.fiscalYear}财年目标计划安装(户)`,
            value: "",
            key:"planInstallHousehold"
          },
          {
            cardType: 3,
            required: true,
            title: '新户(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"newUserPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"newUserPlan",
            id:"1"
          },

          {
            cardType: 3,
            required: true,
            title: '老户(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"oldUserPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"oldUserPlan",
            id:"1"
          },

          {
            cardType: 3,
            required: true,
            title: '乡镇(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"townsUserPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"townsUserPlan",
            id:"1"
          },

          {
            cardType: 3,
            required: true,
            title: '商福(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"commerceUserPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"commerceUserPlan",
            id:"1"
          },

          {
            cardType: 3,
            required: true,
            title: '工业(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"industryUserPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"industryUserPlan",
            id:"1"
          },

          {
            cardType: 3,
            required: true,
            title: '合计(户)',
          },
          {
            cardType: 1,
            required: true,
            title: '计划签约',
            value:"",
            key:"totalPlan",
            id:"0"
          },
          {
            cardType: 1,
            required: true,
            title: '计划安装',
            value:"",
            key:"totalPlan",
            id:"1"
          },

        ],
        data2: [
          {
            cardType: 3,
            required: true,
            title: '新建房地产',
          },
          {
            cardType: 2,
            required: true,
            value: "",
            key:"newBuildingIdea"
          },

          {
            cardType: 3,
            required: true,
            title: '城区老户',
          },
          {
            cardType: 2,
            required: true,
            value: "",
            key:"oldBuildingIdea"
          },

          {
            cardType: 3,
            required: true,
            title: '外围农村用户',
          },
          {
            cardType: 2,
            required: true,
            value: "",
            key:"villageBuildingIdea"
          },

          {
            cardType: 3,
            required: true,
            title: '工商业',
          },
          {
            cardType: 2,
            required: true,
            value: "",
            key:"commerceIdea"
          },

        ],
      }
    },
    computed: {

    },
    mounted() {
      this.initData()
    },
    methods: {
      initData() {
        this.data1.forEach(data => {
          if (data.key in this.reportData) {
            if(data.key != "planInstallHousehold" && data.key != "planSignHousehold"){
              let Arr = this.reportData[data.key].split(",");
              data.value = Arr[data.id];
            }else{
              data.value = this.reportData[data.key]
            }
          }
        });
        this.data2.forEach(data => {
          if (data.key in this.reportData) {
            data.value = this.reportData[data.key];
          }
        });
      }
    }
  }
</script>

<style lang="scss" scoped>

</style>
