<template>
  <div class="page" v-loading="loading">
    <el-row :gutter="40" class="panel-group">
      <el-col v-if="showButtons.tiftojpg" class="card-panel-col">
        <div class="card-panel" @click="edit(1)">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="wj" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              tif文件转jpg文件
            </div>
          </div>
        </div>
      </el-col>
      <el-col v-if="showButtons.bbsjq" class="card-panel-col">
        <div class="card-panel" @click="bbClick">
          <div class="card-panel-icon-wrapper icon-message">
            <svg-icon icon-class="wzjgl" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text message-text">
              报表设计器
            </div>
          </div>
        </div>
      </el-col>
      <el-col v-if="showButtons.zdcxsz" class="card-panel-col">
        <div class="card-panel" @click="editEsSearchSet()">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="wj" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              修改ES最大查询设置
            </div>
          </div>
        </div>
      </el-col>
      <el-col v-if="showButtons.xtcspz" class="card-panel-col">
        <div class="card-panel" @click="sysParamsSet()">
          <div class="card-panel-icon-wrapper icon-message">
            <svg-icon icon-class="wzjgl" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text message-text">
              系统参数配置
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <bath ref="bath" :bathFlag='bathFlage' @cancel='cancel' />
    <!-- 系统参数配置 -->
    <sys-params ref="sysParamsRef" :visible="isShowSysParams" :form="sysForm" @clickSubmit="clickSubmit" @cancel="cancel"></sys-params>
  </div>
</template>
<script>
  import {
    URL_PREFIX
  } from "@/utils/url-prefix";
  import { message} from "@/utils/common";
  import {getconfig,updateConfig} from "@/api/login";
  import bath from "./components/bathEditDIa.vue"
  import {elasticArchiveMaxResult} from "@/api/archiveUtilize/archivesRetrieval/fullTextSearch";
  import SysParams from "./components/sysParams.vue"
  import { mapState } from "vuex";
  export default {
    data() {
      return {

        bathFlage: false,
        loading:false, // 
        isShowSysParams:false,
        sysForm:{
          loginName:'',
          loginBg:'',
          sysName:'',
        }
      }
    },
    computed:{
      ...mapState({
        showButtons:(state) =>state.tools.showButtons,
      })
    },
    components: {
      bath,
      SysParams
    },
    methods: {
      clickSubmit(params){
        this.loading = true;
        let _params = {
          backgroundImage:params.loginBg,
          backgroundName:params.loginName,
          id:params.id,
          systemName:params.sysName
        }
        updateConfig(_params).then((res)=>{
          if(res.code == 100){
            message('success','操作成功，请退出系统，再验证!',3000);
            this.isShowSysParams = false;
          }
        }).finally(()=>{
          this.loading = false;
          this.$refs.sysParamsRef.fileList = [];
        })
      },
      // 获取系统参数数据
      getconfig(){
        this.loading = true;
        getconfig().then((res)=>{
          if(res.code == 100){
            let data = res.body.list || [];
            this.sysForm = {
              loginName:data[0].backgroundName,
              loginBg:data[0].backgroundImage,
              sysName:data[0].systemName,
              id:data[0].id
            }
          }
        }).finally(()=>{
          this.loading = false;
        })
      },
      // 系统参数配置
      sysParamsSet(){
        this.getconfig();
        this.isShowSysParams = true;
      },
      edit(val) {
        this.$refs.bath.ruleForm.path = "";
        this.bathFlage = true
      },
      cancel() {
        this.bathFlage = false;
        this.isShowSysParams = false;
      },
      bbClick() {
        let str = URL_PREFIX + "/point-strategy/ureport/designer"
        window.open(str)
      },
      editEsSearchSet(){
        elasticArchiveMaxResult().then((res)=>{
          if(res.code == 100){
            message('success',res.msg,3000);
          }
        })
      }
    },
    created(){
      let btnData = {
        menuid: this.$getMenuId(sessionStorage.getItem("routerIdList"), this.$route.path),
        roleid: sessionStorage.getItem("roleid")
      }
      this.$store.dispatch("tools/getButtonList", btnData);
    }
  }

</script>
<style lang="scss" scoped>
  .page {
    padding: 20px 30px;
    background-color: rgb(240, 242, 245);
  }

  .panel-group {

    // padding-top: 18px;
    .card-panel-col {
      width: 325px;
      margin-bottom: 20px;
    }

    .card-panel:hover {
      box-shadow: 8px 8px 40px rgba(0, 0, 0, .2);
    }

    .card-panel {
      border-radius: 8px;
      height: 108px;
      cursor: pointer;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      color: #666;
      background: #fff;
      box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);

      &:hover {

        .card-panel-icon-wrapper {
          color: #fff;
        }

        .icon-people {
          background: #40c9c6;
        }

        .icon-message {
          background: #36a3f7;
        }

        .icon-money {
          background: #f4516c;
        }

        .icon-shopping {
          background: #34bfa3
        }
      }

      .icon-people {
        color: #40c9c6;
      }

      .icon-message {
        color: #36a3f7;
      }

      .icon-money {
        color: #f4516c;
      }

      .icon-shopping {
        color: #34bfa3
      }

      .card-panel-icon-wrapper {
        float: left;
        margin: 14px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }

      .card-panel-icon {
        float: left;
        font-size: 48px;
      }

      .card-panel-description {
        float: right;
        font-weight: bold;
        // margin: 26px;
        margin-left: 0px;

        .card-panel-text {
          letter-spacing: 2px;
          height: 108px;
          line-height: 108px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 16px;
          margin-right: 12px;
        }

        .card-panel-num {
          font-size: 20px;
        }
      }
    }
  }

  @media (max-width:550px) {
    .card-panel-description {
      display: none;
    }

    .card-panel-icon-wrapper {
      float: none !important;
      width: 100%;
      height: 100%;
      margin: 0 !important;

      .svg-icon {
        display: block;
        margin: 14px auto !important;
        float: none !important;
      }
    }
  }

</style>
