<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-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20" v-if="editbgid.advertisingType == '线上广告位'">
                  <el-col :span="8">
                    <el-form-item label="所属端" prop="affiliation" >
                      <div class="duiqi">{{editbgid.affiliation || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告位数量" prop="advertisingNumber" >
                      <div class="duiqi">{{editbgid.advertisingNumber || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告尺寸" prop="dimensions">
                      <div class="duiqi">{{editbgid.dimensions || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="可上传大小" prop="size">
                      <div class="duiqi">{{editbgid.size || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="播放时长" prop="playDuration">
                      <div class="duiqi">{{editbgid.playDuration || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="推送地址" prop="pushAddress">
                      <div class="duiqi">{{editbgid.pushAddress || '无'}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20" v-if="editbgid.advertisingType == '实体广告位'">
                  <el-col :span="8">
                    <el-form-item label="设备类型" prop="deviceType" >
                      <div class="duiqi">{{editbgid.deviceType || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备大小" prop="equipmentSize" >
                      <div class="duiqi">{{editbgid.equipmentSize || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告尺寸" prop="dimensions">
                      <div class="duiqi">{{editbgid.dimensions || '无'}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="广告材质" prop="advertisingMaterial">
                      <div class="duiqi">{{editbgid.advertisingMaterial || '无'}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="详细位置" prop="detailedLocation" v-if="editbgid.advertisingType == '实体广告位'">
                  <div class="duiqi">{{editbgid.detailedLocation || '无'}}</div>
                </el-form-item>
                <el-form-item label="地图标点" prop="mapPunctuation" v-if="editbgid.advertisingType == '实体广告位'">
                  <div style="width: 100%;height: 300px;">
                    <newmap :isx="false" :message="editbgid.mapPunctuation"></newmap>
                  </div>
                </el-form-item>
                <el-form-item label="位置示意图" prop="locationDiagram">
                  <img  v-for="item in editbgid.locationDiagram.split(',')" :src="$baseURL+item" alt="" style="width:140px;height:140px;margin-left: 15px;">
                </el-form-item>
                
                <el-form-item label="备注信息" prop="memo" v-if="editbgid.advertisingType == '线上广告位'">
                  <div class="duiqi">{{editbgid.memo || '无'}}</div>
                </el-form-item>
              </el-form>
              <TitleWithCircle title="历史发布/下架记录" />
              <div style="padding: 20px;">
                <el-table :data="datalistxsj"
                :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
                tooltip-effect="dark custom-tooltip-effect">
                  <el-table-column label="类型" prop="type" >
                  </el-table-column>
                  <el-table-column label="操作时间" prop="operationTime" >
                  </el-table-column>
                  <el-table-column label="操作人" prop="operator">
                  </el-table-column>
                </el-table>
                <div style="display: flex;justify-content: space-between;" class="bom">
                  <div style="font-size: 14px;">共 <span style="color: #3F9B6A;">{{totalsxj}}</span> 项数据</div>
                  <el-pagination :current-page="pagequerysxj.pageNumber+1" :page-sizes="[10, 20, 50, 100]" :page-size="pagequerysxj.pageSize"
                    background small layout="prev, pager, next" :total="totalsxj" @size-change="handleSizeChangesxj"
                    @current-change="handleCurrentChangesxj">
                  </el-pagination>
                </div>
              </div>
            </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 newmap from "@/components/newmap/index";
  import MapXian from "@/components/MapContainer/MapXian";
  import TitleWithCircle from '@/components/top/index';
  import {
    cereBusinessOperationqueryByPage,
    cereResourceStrategylist,
    cereBusinessPlan
  } from '@/api/newly';
  export default {
    components: {
      TitleWithCircle,
      MapXian,
      newmap
    },
    props: {
      leixing: {
        type: Boolean,
        default: true
      },
      editbgid: {
        type: Object,
        default: function() {
          return {};
        },
      },
    },
    data() {
      return {
        datalistxsj:[],
        totalsxj:0,
        pagequerysxj:{
          pageNumber: 0,
          pageSize: 10,
          resourcesId: 'sp' + this.editbgid.id
        },
        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)
          if (!Array.isArray(res.data)) {
            this.datalist = [];
            return;
          }
          this.datalist = res.data
        })
        cereBusinessPlan(c1).then(res => {
          console.error(res)
          if (!Array.isArray(res.data)) {
            this.datalist1 = [];
            return;
          }
          this.datalist1 = res.data
        })
        this.getAllxsj()
      }


    },
    computed: {

    },
    methods: {
      handleCurrentChangesxj(val) {
        this.pagequerysxj.pageNumber = val - 1
        this.getAllxsj()
      },
      handleSizeChangesxj(val) {
        this.pagequerysxj.pageSize = val
        this.pagequerysxj.pageNumber = 0
        this.getAllxsj()
      },
      getAllxsj() {
        cereBusinessOperationqueryByPage(this.pagequerysxj).then(res => {
          console.error(res)
          if (!Array.isArray(res.data.content)) {
            this.datalistxsj = [];
            return;
          }
          this.datalistxsj = res.data.content
          this.totalsxj = res.data.totalElements
        })
      },
      changetype() {
        this.xiangTab = 'first'
        this.$emit('removeonaction', '1')
      },
    }
  }
</script>
<style>
  .el-form-item__label {
    color: #a2a2a2;
  }

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