<template>
<van-nav-bar
      fixed
      title="其他有害信息情况"
      left-text=""
      left-arrow
      @click-left="onClickLeft"
      :style="{ 'background-color': selectColor }"
    />
    <van-loading size="16px" v-show="isLoading">加载中...</van-loading>

    <div class="main" v-show="!isLoading">
      <div class="banner">
        <img src="../../../../public/loginbg/banner.jpg" alt="" />
      </div>
      <div class="info">
        <p class="miniTitle">基础信息</p>
        
        <van-cell-group>
          <van-field
            v-model="info.name"
            readonly
            label="人员姓名:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.sexname"
            center
            readonly
            label="性别:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.idcard"
            center
            readonly
            label="身份证号:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.phone"
            center
            readonly
            label="手机号码:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.reportingTime"
            center
            readonly
            label="时间:"
            input-align="right"
          />
        </van-cell-group>
        
        <van-cell-group>
          <van-field
            v-model="info.placeSelectName"
            center
            readonly
            label="地点:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.placeDetailed"
            center
            readonly
            label="详细地址:"
            input-align="right"
          />
        </van-cell-group>
        <van-cell-group>
          <van-field
            v-model="info.eventOverview"
            center
            readonly
            label="事件概述:"
            input-align="right"
          />
        </van-cell-group>
        
        <!-- <p class="miniTitle">事件内容：</p>
          <div v-html="info.eventContent" class="showhtml"> </div> -->
      </div>
      <van-button
        v-if="info.assessment == 0"
        type="primary"
        class="btn-sub"
        @click="update"
        >审核</van-button
      >
    </div>
  </template>
    
    <script>
  import { ref, onMounted } from "vue";
  import nonReligiousInformationService from "@/api/nonReligiousInformation/nonReligiousInformationService";
  import UserManage from "@/api/user/UserManage";
  import { useRoute } from "vue-router";
  import $base from "@/utils/config";
  export default {
    setup() {
      // 导航栏颜色
      const selectColor = ref(window.localStorage.getItem("MZ_COLOR"));
      const onClickLeft = () => {
        history.back();
      };
      // 加载
      let isLoading = ref(true);
      // 活动信息
      const info = ref({      
        siteName:{id:"",organizationName:""},
      });
      // 文件
      let fileList = ref([]);
      let route = useRoute();
      onMounted(() => {
        new nonReligiousInformationService().queryById(route.query.id).then((data) => {
          if(data.sex=="1"){
            data.sexname="男"
          }else{
            data.sexname="女"
          }
          info.value = data;  
          //info.value.nonReligiousCategoriesName=getCategories(info.value.nonReligiousCategories)

          isLoading.value = false;
        });
      });
      // 审核通过
      const update = () => {
        isLoading.value = true;
        info.value.assessment = 1;
        new nonReligiousInformationService().save(info.value).then((res) => {

          isLoading.value = false;
          window.xm.showToast({
             message:"审核成功!"
          })
          history.back();
        });
      };

        //字典配置
        const getCategories= (key ) => {
            let re="";
            switch(key){
            case "1":
                re="宗教组织";
                break;
            case "10":
                re="邪教组织";
                break;
            case "11":
                re="地下神学院";
                break;
            case "2":
                re="地下教会";
                break;
            case "3":
                re="韩美境外渗透组织";
                break;
            case "4":
                re="本地精神控制类有害培训机构";
                break;      
            case "5":
                re="“呼喊派”骨干组织";
                break;
            case "6":
                re="“改革宗”地下教会组织";
                break;
            case "7":
                re="藏传佛教本地组织";
                break;
            case "8":
                re="学生传教组织";
                break;
            case "9":
                re="“义诊医疗”地下教会组织";
                break;
            case "91":
                re="“亚文化”传教组织";
                break;
            case "92":
                re="重点公司组织";
                break;          
            }
            return re;
        };

        

      return {
        // 导航栏颜色
        selectColor,
        onClickLeft,
        info,
        fileList,
        isLoading,
        update,
        getCategories,
      };
    },
  };
  </script>
    
<style lang="less">
    .van-cell__value .van-field__right-icon .van-icon-location {
    color: #36a7f3 !important;
  }
  .btn-sub {
    width: 90%;
    border-radius: 20px;
    margin-left: 5%;
    margin-bottom: 40px;
    margin-top: -100px;
  }
  .van-loading {
    text-align: center;
    margin-top: 80px;
  }
  .van-popup--center {
    width: 98% !important;
  }
  .showhtml{
    width: 94%;
    border: 2px solid #ccc;
    border-radius: 10px;
    padding: 10px;
  }
  </style>