月球大数据地理空间分析展示平台-【前端】-月球2期前端
src/views/layer/layerDetail.vue
@@ -1,8 +1,15 @@
<template>
  <div class="content">
  <div
    class="content"
    v-drag="true"
  >
    <div class="title">
      <label>详细编辑</label>
      <el-icon @click="setSpatialClose" :size="20" style="cursor: pointer">
      <el-icon
        @click="setSpatialClose"
        :size="20"
        style="cursor: pointer"
      >
        <Close />
      </el-icon>
    </div>
@@ -11,23 +18,48 @@
        <!-- <el-checkbox @change="handlCheckAllChange" v-model="layerState">{{
          layerName
        }}</el-checkbox> -->
        {{ layerData.name }}
        <img src="../../assets/img/layer.png" alt="" />
        {{ layerData.cnName }}
        <img
          src="../../assets/img/layer.png"
          alt=""
        />
      </div>
      <div class="slider-demo-block">
      <div
        class="slider-demo-block"
        v-show="diaphaneityShow"
      >
        <div class="demonstration">透明度</div>
        <el-slider v-model="transparence" />
        <el-slider
          v-model="transparence"
          @change="sliderChange"
          :format-tooltip="formatTooltip"
        />
        <div class="demonstration">{{ transparence }}%</div>
      </div>
      <div class="selectBox">
      <div
        class="slider-demo-block"
        v-show="contrastShow"
      >
        <div class="demonstration">对比度</div>
        <el-slider
          v-model="contrast"
          @change="contrastChange"
          :max="3"
          :step="0.1"
        />
        <div class="demonstration">{{ contrast }}</div>
      </div>
      <div
        class="selectBox"
        v-show="drawingModeShow"
      >
        <div class="selectTile demonstration">拉伸方式</div>
        <el-select
          v-model="stretchValue"
          class="m-2"
          placeholder="Select"
          class="imgSelect"
          placeholder="选择拉伸方式"
          size="small"
          @change="changeSelection(stretchValue)"
          ref="select"
          clearable
        >
          <el-option
            v-for="item in stretchOptions"
@@ -35,8 +67,36 @@
            :label="item.label"
            :value="item.value"
          >
            <img :src="item.url" style="height: 30px; margin-right: 10px" />
            <span>{{ item.label }}</span>
          </el-option>
        </el-select>
      </div>
      <div
        class="selectBox"
        v-show="colorShow"
      >
        <div class="selectTile demonstration">渲染类型</div>
        <el-select
          v-model="renderType"
          class="imgSelect"
          placeholder="选择渲染类型"
          size="small"
          @change="changeSelection(renderType)"
          ref="select"
          clearable
        >
          <el-option
            v-for="item in renderTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
            <!-- <img :src="item.url" style="height: 30px; margin-right: 10px" />
            <span>{{ item.label }}</span> -->
            <img
              :src="item.url"
              style="height: 30px; width: 100%"
            />
          </el-option>
        </el-select>
      </div>
@@ -53,12 +113,15 @@
  defineProps,
  defineEmits,
} from "vue";
import server from "@/assets/js/Map/server";
const stretchValue = ref("");
const transparence = ref(0);
const contrast = ref(1);
let layerName = ref("图层名称");
let layerState = ref(false);
let select = ref();
const stretchOptions = [
let renderType = ref("");
const renderTypeOptions = [
  {
    value: "Option1",
    label: "Option1",
@@ -70,40 +133,141 @@
    url: "https://img1.baidu.com/it/u=3226786080,888437008&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200",
  },
];
const stretchOptions = [
  {
    value: "Option1",
    label: "Option1",
  },
  {
    value: "Option2",
    label: "Option2",
  },
];
const formatTooltip = (val: number) => {
  return val / 100;
};
const contrastFormatTooltip = (val: number) => {
  return val / 100;
};
const emits = defineEmits(["detailClose"]);
//defineProps 来接收组件的传值
const props = defineProps({
  layerData: Object,
});
const layerLength = ref();
const setSpatialClose = () => {
  emits("detailClose", false);
};
const handlCheckAllChange = (res) => {};
const changeSelection = (scope) => {
  let brand = scope;
  for (let index in stretchOptions) {
    let aa = stretchOptions[index];
    let value = aa.value;
    if (brand === value) {
      console.log(select.value.$el.children);
  if (scope == "") {
    select.value.$el.children[0].children[0].removeAttribute("style");
    select.value.$el.children[0].children[0].children[0].removeAttribute(
      "style"
    );
    select.value.$el.children[0].children[0].children[0].children[0].removeAttribute(
      "style"
    );
    return;
  }
  for (let index in renderTypeOptions) {
    let obj = renderTypeOptions[index];
    if (obj.value == scope) {
      select.value.$el.children[0].children[0].setAttribute(
        "style",
        "background:url(" +
          aa.url +
          ") no-repeat 10px;background-size: 30px 30px;color:#333;padding-left: 50px;"
        `background: url(${obj.url}) no-repeat;
            width: 100%; height: 100%;
            border: none;
            height: 33px;
            background-size:100% 100%`
      );
      select.value.$el.children[0].children[0].children[0].setAttribute(
        "style",
        `display: flex;
        justify-content: flex-end;
        background:transparent;`
      );
      select.value.$el.children[0].children[0].children[0].children[0].setAttribute(
        "style",
        `display: none;`
      );
    }
  }
  // let brand = scope;
  // for (let index in stretchOptions) {
  //   let aa = stretchOptions[index];
  //   let value = aa.value;
  //   if (brand === value) {
  //     console.log(select.value.$el.children);
  //     select.value.$el.children[0].children[0].setAttribute(
  //       "style",
  //       "background:url(" +
  //         aa.url +
  //         ") no-repeat 10px;background-size: 30px 30px;color:#333;padding-left: 50px;"
  //     );
  //   }
  // }
};
//滑块变动
const sliderChange = (val) => {
  server.layerList[layerLength.value].layerData.alpha = val / 100;
};
const contrastChange = (val) => {
  server.layerList[layerLength.value].layerData.contrast = val;
};
let diaphaneityShow = ref(false);
let contrastShow = ref(false);
let drawingModeShow = ref(false);
let colorShow = ref(false);
//判断类型显示
const typeDisplay = (val) => {
  if (
    val.data == 1 ||
    val.data == 3 ||
    val.data == 4 ||
    val.data == 5 ||
    val.data == 6 ||
    val.data == 7 ||
    val.data == 8
  ) {
    diaphaneityShow.value = true;
  }
  if (
    val.data == 1 ||
    val.data == 3 ||
    val.data == 4 ||
    val.data == 5 ||
    val.data == 6
  ) {
    contrastShow.value = true;
    drawingModeShow.value = true;
  }
  if (val.data == 3 || val.data == 4) {
    colorShow.value = true;
  }
};
onMounted(() => {
  typeDisplay(props.layerData);
  server.layerList.forEach((e, i) => {
    if (props.layerData.id == e.id && e.layerData) {
      layerLength.value = i;
      transparence.value = e.layerData.alpha * 100;
    }
  });
});
</script>
<style lang="less" scoped>
.content {
  background: #1e2a3d;
  padding: 20px;
  height: 400px;
  // height: 400px;
  margin-left: 20px;
  margin-top: 40px;
  min-width: 200px;
  z-index: 40;
  position: absolute;
  .title {
    font-size: 18px;
    font-family: Source Han Sans CN;