<template>
  <div class="info_logo">
    <div class="logo">
      <img :src="data.url" alt="" style="width:100%;" v-if="!data.isProcess" />
      <workflows-view :zoom="0.4" :id="data.workflows_id" :hideDetail="true" v-if="data.isProcess"></workflows-view>
      <map-view v-if="data.isMap" :id="data.portal_id"></map-view>
      <process-view v-if="data.isProcess" :id="data.workflows_id"></process-view>
    </div>
    <div class="info">
      <p class="info_title">
        <span>{{ data.name }}</span>
        <span
          class="info_fix"
          v-if="data.fixed_process"
          @click="goto_page(data.fixed_url)"
        >
          我要编辑
        </span>
        <span class="bs" v-if="data.aqdetail" @click="subevent(0)">
          一键部署
        </span>
        <span class="info_fix" v-if="data.fxdetail" @click="subevent(1)">
          我要编辑
        </span>
        <span class="info_fix" v-if="data.yydebugger" @click="subevent(5)">
          应用调试
        </span>
        <span
          class="right gap"
          v-if="data.yydetail || data.xxdetail || data.yydev||data.public||data.unpublic||data.undeploy||data.deploy"
        >
          |
        </span>
        <span
          class="right underline"
          v-if="data.xxdetail"
          @click="subevent(2, get_strd(data.xxdetail)[0])"
          :style="
            get_strd(data.xxdetail)[0]
              ? { backgroundColor: '#ccc', color: '#e6ebfe' }
              : ''
          "
          :title="
            get_strd(data.xxdetail)[1] == '申请下线'
              ? '申请下线至开发者应用'
              : '申请上线至平台应用'
          "
        >
          {{ get_strd(data.xxdetail)[1] }}
        </span>
        <span
          class="right undersell"
          v-if="data.yydetail"
          :style="
            get_strd(data.yydetail)[0]
              ? { backgroundColor: '#ccc', color: '#e6ebfe' }
              : ''
          "
          @click="subevent(3, get_strd(data.yydetail)[0])"
        >
          {{ get_strd(data.yydetail)[1] }}
        </span>
        <span
          class="right undersell undermy"
          v-if="data.bsdetail"
          @click="subevent(4)"
        >
          申请密钥
        </span>
        <span
          class="info_fix"
          v-if="data.fixed"
          @click="goto_page(data.fixedurl)"
        >
          我要修改
        </span>
        <span class="right undersell undersell2" v-if="data.deploy" @click="subevent(10)">
          部署
        </span>
        <span class="right undersell1" v-if="data.undeploy" @click="subevent(9)">
          取消部署
        </span>

        <span class="right undersell" v-if="data.public" @click="subevent(8)">
          发布
        </span>
        <span class="right undersell1" v-if="data.unpublic" @click="subevent(7)">
          取消发布
        </span>
        
        <span class="info_fix" v-if="data.yydev" @click="subevent(6)">
          应用开发
        </span>
      </p>
      <div class="info_detail">
        <p>
          <label v-for="(item, index) in data.first" :key="index + 2000">
            {{ item.name }}:
            <span :style="item.color ? { color: item.color } : {}">
              {{ item.text }}
            </span>
          </label>
        </p>
        <p>
          <label v-for="(item, index) in data.second" :key="index + 2500">
            {{ item.name }}:
            <a
              v-if="item.name.indexOf('地址') !== -1"
              style="color:#515fe7;text-decoration: none;"
              target="_blank"
              :href="item.text"
            >
              {{ item.text }}
            </a>
            <span v-else :style="item.color ? { color: item.color } : {}">
              {{ item.text }}
            </span>
          </label>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import MapView from "./service-info/map-view";
import processView from '@/components/service-info/process-view'
import workflowsView from '@/components/work-flow/workflows-view'

export default {
  props: ["data"],
  components: { MapView,processView,workflowsView },
  data() {
    return {};
  },
  watch: {},
  computed: {},
  created() {
    console.log(this.data);
  },
  mounted() {},
  methods: {
    get_strd(str) {
      if (str) {
        if (str.indexOf("d") !== -1) {
          return [true, str.substr(0, str.length - 1)];
        } else {
          return [false, str];
        }
      }
    },
    subevent(val, flag = false) {
      if (flag) {
        return;
      }
      if (val == 0) {
        // this.$emit('deploy',this.data)
        this.$router.push(
          `/yygl/${this.$route.params.level}/${this.$route.params.type}/deployment/${this.$route.params.id}?source=${this.$route.query.source}`
        );
        console.log(this.$route);
      } else if (val == 1) {
        this.$emit("editapp");
      } else if (val == 2) {
        this.$emit("unline", this.data);
      } else if (val == 3) {
        this.$emit("unsell", this.data);
      } else if (val == 4) {
        this.$emit("applymy");
      } else if (val == 5) {
        // /yygl/:level/:type/appdebugger/:deploy_id
        this.$emit("debuggerfunc");
      } else if (val == 6) {
        this.$emit("applymy");
      } else if (val == 7) {
        this.$emit("unpublic", this.data);
      } else if (val == 8) {
        this.$emit("public1", this.data);
      } else if (val == 9) {
        this.$emit("undeploy", this.data);
      } else if (val == 10) {
        this.$emit("deploy", this.data);
      }
    },
    goto_page(url) {
      this.$router.push(url);
    },
  },
};
</script>

<style scoped>
.info_logo {
  overflow: hidden;
  width: 100%;
  margin-bottom: 15px;
}
.logo {
  float: left;
  overflow: hidden;
  width: 144px;
  height: 144px;
  margin-right: 13px;
  background-size: cover;
  text-align: center;
  position: relative;
}
.logo img {
  width: 100%;
}
.logo > .map_view {
  position: absolute;
  right: 0;
  bottom: 0;
}
.info {
  float: left;
  width: calc(100% - 157px);
}
.info_title {
  font-size: 18px;
  font-weight: bold;
  color: #0d1847;
  padding-left: 10px;
  margin-bottom: 26px;
}
.info_fix {
  display: inline-block;
  width: 76px;
  height: 32px;
  background-color: #515fe7;
  border-radius: 8px;
  font-size: 14px;
  font-weight: normal;
  color: #e6ebfe;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  float: right;
}
.bs {
  display: inline-block;
  width: 76px;
  height: 32px;
  box-sizing: border-box;
  line-height: 28px;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  font-weight: 400;
  background-color: #d0d5e7;
  border-radius: 8px;
  border: solid 2px #a5afd6;
  color: #0f2683;
}
.gap {
  color: #b4c0f5;
  margin: 0 10px;
  line-height: 30px;
}
.underline {
  width: 76px;
  height: 32px;
  background-color: #f6f7fb;
  border-radius: 8px;
  font-size: 14px;
  font-weight: normal;
  color: #0f2683;
  line-height: 32px;
  cursor: pointer;
  text-align: center;
  margin-left: 10px;
}
.undersell,.undersell1 {
  width: 76px;
  height: 32px;
  background-color: #0f2683;
  border-radius: 8px;
  font-size: 14px;
  font-weight: normal;
  color: #f8f9fd;
  line-height: 32px;
  cursor: pointer;
  text-align: center;
}
.undersell1{
  color: #0f2683;
  background-color: #e6ebfe;
  margin-left: 10px;
}
.undersell2{
  margin-left: 10px;
}
.undermy {
  background-color: #515fe7;
  color: #e6ebfe;
}
.info_detail {
  width: 100%;
  height: 96px;
  background-color: #f6f7fb;
  border-radius: 8px;
  line-height: 40px;
  padding: 8px 20px;
}
.info_detail p {
  color: #8890a7;
}
.info_detail span,
.info_detail a {
  color: #242c43;
  font-weight: 600;
  margin-right: 48px;
}
.right {
  float: right;
}
</style>
