<script setup>
import { ref, watch, onMounted, computed } from "vue";
import { raiInterface } from "@/api/api.js";
import { ElMessageBox, ElMessage } from "element-plus";

const props = defineProps({
  detailData: {
    type: Object,
  },
  dialogVisible: {
    type: Boolean,
    default: false,
  },
});

const cities = ref([]); //
const checkedCities = ref([]);
const checkScaleList = ref([]);

watch(
  () => props.detailData,
  (newValue) => {
    if (Object.values(newValue).length > 0) {
      checkedCities.value = newValue.CustomerTypeIds ? newValue.CustomerTypeIds.split(",").map((item) => Number(item)) : [];
      checkScaleList.value = newValue.Scale ? newValue.Scale.split(",") : [];
    }
  },
  {
    deep: true,
  }
);

onMounted(() => {
  customerTypelist();
});

const $emit = defineEmits();

function clickBtn() {
  $emit("update:detailData", {});
  $emit("update:dialogVisible", false);
}
//获取多选的客户列表
function customerTypelist() {
  raiInterface.customerTypelist().then((res) => {
    if (res.Ret === 200) {
      cities.value = res.Data.List;
    }
  });
}
</script>

<template>
  <div class="container">
    <el-dialog :modal-append-to-body="false" draggable center top="5vh" v-model="props.dialogVisible" customClass="customParticulars" :before-close="clickBtn">
      <template #header>
        <div style="display: flex; align-items: center">
          <img :src="$icons.particulars" style="color: #fff; width: 16px; height: 16px; margin-right: 5px" />
          <span style="font-size: 16px">活动详情</span>
        </div>
      </template>
      <div class="dialog-box">
        <div v-if="props.detailData.ActivityName" class="dialog-title">{{ props.detailData.ActivityName }}</div>
        <div class="test" v-if="props.detailData.ActivityTypeName">
          <p>活动类型：</p>
          <div class="paragraph" v-html="props.detailData.ActivityTypeName"></div>
        </div>
        <div class="test" v-if="props.detailData.ChartPermissionName">
          <p>所属行业：</p>
          <div class="paragraph" v-html="props.detailData.ChartPermissionName"></div>
        </div>
        <div class="test" v-if="props.detailData.ActivityTimeText">
          <p>活动时间：</p>
          <div class="paragraph" v-html="props.detailData.ActivityTimeText"></div>
        </div>
        <div class="test" v-if="props.detailData.DistinguishedGuest">
          <p>嘉&nbsp;&nbsp; &nbsp; &nbsp;宾：</p>
          <div class="paragraph" v-html="props.detailData.DistinguishedGuest"></div>
        </div>
        <div class="test" v-if="props.detailData.Host">
          <p>主&nbsp; 持&nbsp; 人：</p>
          <div class="paragraph" v-html="props.detailData.Host"></div>
        </div>
        <div class="test" v-if="props.detailData.Speaker">
          <p>主&nbsp; 讲&nbsp; 人：</p>
          <div class="paragraph" v-html="props.detailData.Speaker"></div>
        </div>
        <div class="test" v-if="props.detailData.Expert">
          <p>专&nbsp;&nbsp; &nbsp; &nbsp;家：</p>
          <div class="paragraph" v-html="props.detailData.Expert"></div>
        </div>
        <div class="test" v-if="props.detailData.City">
          <p>城&nbsp;&nbsp; &nbsp; &nbsp;市：</p>
          <div class="paragraph" v-html="props.detailData.City"></div>
        </div>
        <div class="test" v-if="props.detailData.MainlandTell">
          <p>大陆拨入：</p>
          <div class="paragraph" v-html="props.detailData.MainlandTell"></div>
        </div>
        <div class="test" v-if="props.detailData.HongKongTell">
          <p>香港拨入：</p>
          <div class="paragraph" v-html="props.detailData.HongKongTell"></div>
        </div>
        <div class="test" v-if="props.detailData.TaiwanTell">
          <p>台湾拨入：</p>
          <div class="paragraph" v-html="props.detailData.TaiwanTell"></div>
        </div>
        <div class="test" v-if="props.detailData.AmericaTell">
          <p>美国拨入：</p>
          <div class="paragraph" v-html="props.detailData.AmericaTell"></div>
        </div>
        <div class="test" v-if="props.detailData.ParticipationCode">
          <p>参会密码：</p>
          <div class="paragraph" v-html="props.detailData.ParticipationCode"></div>
        </div>
        <div class="test" v-if="props.detailData.OnlineParticipation">
          <p>网络参会：</p>
          <div class="paragraph" v-html="props.detailData.OnlineParticipation"></div>
        </div>
        <div class="test" v-if="props.detailData.Address">
          <p>活动地址：</p>
          <div class="paragraph" v-html="props.detailData.Address"></div>
        </div>
        <div class="test" v-if="props.detailData.Highlights">
          <p>活动亮点：</p>
          <div class="paragraph" v-html="props.detailData.Highlights"></div>
        </div>
        <div class="test" v-if="props.detailData.ReportLink">
          <p>报告链接：</p>
          <div class="paragraph" v-html="props.detailData.ReportLink"></div>
        </div>
        <div class="test" v-if="props.detailData.Theme">
          <p>主&nbsp;&nbsp; &nbsp; &nbsp;题：</p>
          <div class="paragraph" v-html="props.detailData.Theme"></div>
        </div>
        <div class="test" v-if="props.detailData.TencentConferenceNumber">
          <p>腾讯会议号：</p>
          <div class="paragraph" v-html="props.detailData.TencentConferenceNumber"></div>
        </div>

        <div class="test" v-if="props.detailData.Remarks">
          <p>备&nbsp;&nbsp; &nbsp; &nbsp;注：</p>
          <div class="paragraph" v-html="props.detailData.Remarks"></div>
        </div>
      </div>
      <div class="type-scale" v-if="props.detailData.IsLimitPeople == 1">
        <div style="flex-shrink: 0; margin-right: 10px">活动可见：</div>
        <div>
          <div class="item" v-if="checkedCities.length">
            <span style="width: 70px; flex-shrink: 0" class="text-right"> 套餐类型：</span>
            <el-checkbox-group v-model="checkedCities">
              <span v-for="item in cities" :key="item.CustomerTypeId">
                <el-checkbox style="margin-right: 10px" :label="item.CustomerTypeId" disabled v-if="checkedCities.includes(item.CustomerTypeId)">
                  {{ item.CustomerName }}
                  <el-tooltip :content="item.Explain" placement="top-start" v-if="item.Explain">
                    <i class="el-icon-info" />
                  </el-tooltip>
                </el-checkbox>
              </span>
            </el-checkbox-group>
          </div>
          <div class="item" v-if="checkScaleList.length">
            <span class="text-right"> 管理规模： </span>
            <el-checkbox-group v-model="checkScaleList">
              <el-checkbox v-if="checkScaleList.includes('3')" disabled label="3">100亿以上</el-checkbox>
              <el-checkbox v-if="checkScaleList.includes('2')" disabled label="2">50～100亿</el-checkbox>
            </el-checkbox-group>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<style lang="scss">
.customParticulars {
  width: 550px !important;
  padding-bottom: 20px;
  .type-scale {
    margin-top: 20px;
    display: flex;
    .item {
      display: flex;
      margin-bottom: 20px;
    }
  }
}
.dialog-box {
  box-sizing: border-box;
  width: 501px;
  border: 1px solid #dcdfe6;
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #666666;
  .test {
    display: flex;
    padding: 13px 30px;
    border-top: 1px solid #dcdfe6;
    p {
      width: 104px !important;
      text-align: justify;
    }
    .paragraph {
      padding: 0;
      margin: 0;
      width: 100%;
      p {
        width: 100% !important;
        text-align: left;
      }
    }
  }
  .dialog-title {
    padding: 13px 30px;
    border-top: none;
    text-align: center;
    background: #f0f2f5;
  }
}
</style>
