<template>
  <div>
    <!-- 一级标签 -->
    <div v-for="item in label" v-if="firstTagShow(item)">
      <h3 class="first-tag">{{item.firstTag}}</h3>
      <div v-for="i in item.details">
        <h4 class="second-tag">{{i.secondTag}}</h4>
        <template v-for="detail in i.details">
          <form-input
            v-if="itemShow(detail) && isCreated"
            :width="170"
            :type="detail.inputMode"
            :typeArr="detail.dataSource"
            :value="value.infos[detail.infoPointCode]"
            :unit="detail.unit"
            @change="changed"
            :keys="detail.infoPointCode"
            :label="detail.infoPointName"
            :isRule="false"
          ></form-input>
        </template>
      </div>
    </div>
  </div>
</template>
<script>
import formInput from "@/components/market/owner/formInput";
export default {
  name: "project",
  props: {
    label: {
      type: Array,
      default: function () {
        return []
      }
    },
    value: {
      type: Object
    },
    isCreate: {
      type: Boolean,
      default: true
    }
  },
  components: {
    formInput
  },
  data() {
    return {
      showInputMode: ["B1", "A1", "A2", "C5", "D1", "C1", "B2", "C6", "B1"],
      isCreated: false
    }
  },
  created() {
    console.log(this.label, this.value, "label")
    this.isCreated = true
  },
  mounted() { },
  methods: {
    changed(val, key) {
      let param = {
        id: this.value.id,
        infos: {
          [key]: val
        }
      }
      this.postJson(
        "/server/business-os/proprietor/project/update",
        param,
        res => {
          this.$message.success("修改成功");
        }
      );
    },
    //第一级tag是否显示
    firstTagShow(item) {
      let tagShow = false
      if (item.firstTag == "地理位置" || item.firstTag == "天气预报" || item.firstTag == "室外环境" || item.firstTag == "能耗信息") {
        tagShow = false
      } else {
        tagShow = true
      }
      return tagShow
    },
    //item是否显示
    itemShow(item) {
      if (item.infoPointName == "业主") {
        return false
      }
      if (this.showInputMode.indexOf(item.inputMode) > -1) {
        return true
      } else {
        return false
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.build-border {
  border: 1px solid #ccc;
  margin-top: 10px;
  padding-top: 10px;
  overflow: hidden;
  .font-right {
    float: right;
    margin-right: 30px;
  }
}
.first-tag {
  line-height: 40px;
  font-weight: 600;
  margin-left: 5px;
}
.second-tag {
  line-height: 40px;
  font-weight: 500;
  margin-left: 20px;
  color: #6bcae2;
}
</style>