<template>
  <div>
    <div>
      <el-tabs v-model="xiangTab">
        <el-tab-pane label="资源信息" name="first">
          <div style="margin-top: 30px;" class="editcss">
            <TitleWithCircle title="基础信息" />
            <div style="padding: 20px;">
              <el-form :model="editbgid" ref="formInline" label-width="100px" class="demo-ruleForm">
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="广告位名称" prop="advertisingName">
                      <div class="duiqi">{{editbgid.advertisingName}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告位编号" prop="advertisingSpaceNumber">
                      <div class="duiqi">{{editbgid.advertisingSpaceNumber}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告位类型" prop="advertisingType">
                      <div class="duiqi">{{editbgid.advertisingType}}</div>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">

                  <el-col :span="8">
                    <el-form-item label="所属端" prop="affiliation" v-if='leixing'>
                      <div class="duiqi">{{editbgid.affiliation}}</div>
                    </el-form-item>
                    <el-form-item label="详细位置" prop="detailedLocation" v-if='leixing == false'>
                      <div class="duiqi">{{editbgid.detailedLocation}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="轮播顺序" prop="rotationOrder" v-if='leixing'>
                      <div class="duiqi">{{editbgid.rotationOrder}}</div>

                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告尺寸" prop="dimensions" v-if='leixing'>
                      <div class="duiqi">{{editbgid.dimensions}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="24">
                    <el-form-item label="地图标点" prop="mapPunctuation" v-if='leixing == false'>
                      <div style="width: 100%;height: 300px;">
                        <MapXian :message="parentMessage"></MapXian>
                      </div>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="可上传大小" prop="size" v-if='leixing'>
                      <div class="duiqi">{{editbgid.size}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="上传格式" prop="uploadFormat" v-if='leixing'>
                      <div class="duiqi">{{editbgid.uploadFormat}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备类型" prop="deviceType" v-if='leixing == false'>
                      <div class="duiqi">{{editbgid.deviceType}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">

                  <el-col :span="12">
                    <el-form-item label="设备大小" prop="equipmentSize" v-if='leixing == false'>
                      <div style="display: flex;">
                        <div>
                          <span style="font-size: 14px;">长：</span>
                          <span>{{ editbgid.equipmentSizeH }}</span>
                          <span style="font-size: 14px;margin-right:5px;">mm</span>
                        </div>
                        <div>
                          <span style="font-size: 14px;">宽：</span>
                          <span>{{ editbgid.equipmentSizeK }}</span>
                          <span style="font-size: 14px;margin-right:5px;">mm</span>
                        </div>
                        <div>
                          <span style="font-size: 14px;">高：</span>
                          <span>{{ editbgid.equipmentSizeG }}</span>
                          <span style="font-size: 14px;margin-right:5px;">mm</span>
                        </div>
                      </div>

                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="广告尺寸" v-if='leixing == false'>
                      <div style="display: flex;">
                        <div>
                          <span style="font-size: 14px;">长：</span>
                          <span>{{ editbgid.dimensionsH }}</span>
                          <span style="font-size: 14px;margin-right:5px;">mm</span>
                        </div>
                        <div>
                          <span style="font-size: 14px;">宽：</span>
                          <span>{{ editbgid.dimensionsK }}</span>
                          <span style="font-size: 14px;margin-right:5px;">mm</span>
                        </div>
                      </div>
                    </el-form-item>
                  </el-col>

                </el-row>
                <el-row :gutter="20">


                  <el-col :span="8">
                    <el-form-item label="广告材质" prop="advertisingMaterial" v-if='leixing == false'>
                      <div class="duiqi">{{editbgid.advertisingMaterial}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>


                <el-row :gutter="20">
                  <el-col :span="12">
                    <el-form-item label="位置示意图" prop="locationDiagram">
                      <img :src="$baseURL+editbgid.locationDiagram" alt="" style="width:140px;height:140px;">
                    </el-form-item>
                  </el-col>

                </el-row>



              </el-form>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="招商方案信息" name="second">
          <div style="margin-top: 30px;" class="editcss">
            <!-- <TitleWithCircle title="招商方案信息" />
            <div style="padding: 20px;">
              <el-table :data="datalist1"
                :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
                tooltip-effect="dark custom-tooltip-effect">
                <el-table-column label="招商方案名称" prop="planName" min-width="200">
                </el-table-column>
                <el-table-column label="创建日期" prop="createTime" min-width="100">
                </el-table-column>
              </el-table>
            </div> -->
            <TitleWithCircle title="策略方案" />
            <div style="padding: 20px;">
              <el-table :data="datalist"
                :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
                tooltip-effect="dark custom-tooltip-effect">
                <el-table-column label="策略名称" prop="policyName" min-width="200">
                </el-table-column>
                <el-table-column label="适用资源" prop="applicableResources" min-width="100">
                </el-table-column>
                <el-table-column label="经营类型" prop="businessType" min-width="100">

                </el-table-column>
                <el-table-column label="租金价格" prop="rentalPrice" min-width="150">
                </el-table-column>
                <el-table-column label="租期" prop="leaseTerm" min-width="100">
                </el-table-column>
                <el-table-column label="是否出租" prop="isRental" min-width="100">
                  <template slot-scope="scope">
                    {{scope.row.isRental == '0'?'否':'是'}}
                  </template>
                </el-table-column>
                <el-table-column label="是否自营" prop="planningObjectives" min-width="100">
                  <template slot-scope="scope">
                    {{scope.row.isSelfOperated == '0'?'否':'是'}}
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div>
      <el-button class="buttonHover"
        style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;margin-top: 20px;"
        @click="changetype">返回</el-button>
    </div>
  </div>
</template>

<script>
  import MapXian from "@/components/MapContainer/MapXian";
  import TitleWithCircle from '@/components/top/index';
  import {
    cereResourceStrategylist,
    cereBusinessPlan
  } from '@/api/newly';
  export default {
    components: {
      TitleWithCircle,
      MapXian
    },
    props: {
      leixing: {
        type: Boolean,
        default: true
      },
      editbgid: {
        type: Object,
        default: function() {
          return {};
        },
      },
    },
    data() {
      return {
        xiangTab: 'first',
        list: [],
        parentMessage: {},
        datalist: [],
        datalist1:[]
      }
    },
    created() {
      if(this.editbgid.id) {
        let c1 = {
          pageNumber: 0,
          pageSize: 10,
          resourcesId: 'gg' + this.editbgid.id
        }
        cereResourceStrategylist(c1).then(res => {
          console.error(res)
          this.datalist = res.data
        })
        cereBusinessPlan(c1).then(res => {
          console.error(res)
          this.datalist1 = res.data
        })
        let dimensions_parts = this.editbgid.dimensions.split(" ")
        let dimensions = this.editbgid.equipmentSize.split(" ")

        dimensions_parts.forEach(part => {
          if (part.startsWith("长")) {
            this.editbgid.dimensionsH = part.split("：")[1];
          } else if (part.startsWith("宽")) {
            this.editbgid.dimensionsK = part.split("：")[1];
          }
        })
        dimensions.forEach(part => {
          if (part.startsWith("长")) {
            this.editbgid.equipmentSizeH = part.split("：")[1];
          } else if (part.startsWith("宽")) {
            this.editbgid.equipmentSizeK = part.split("：")[1];
          } else if (part.startsWith("高")) {
            this.editbgid.equipmentSizeG = part.split("：")[1];
          }
        })
        if (this.leixing == false) {
          this.parentMessage = JSON.parse(this.editbgid.mapPunctuation)
        }
      }


    },
    computed: {

    },
    methods: {
      changetype() {
        this.xiangTab = 'first'
        this.$emit('removeonaction', '1')
      },
    }
  }
</script>
<style>
  .el-form-item__label {
    color: #a2a2a2;
  }

  .greens {
    color: #3F9B6A;
  }
</style>
