月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2023-10-17 25ad6779e118f2f01e9cda45c67f7b27d55a984a
src/views/layer/layerDetail.vue
@@ -1,20 +1,28 @@
<template>
  <div class="content" v-drag="true">
  <div class="content">
    <div class="title">
      <label>详细编辑</label>
      <el-icon @click="setSpatialClose" :size="20" style="cursor: pointer">
      <label> {{ layerData.cnName }}</label>
      <el-icon
        @click="setSpatialClose"
        :size="20"
        style="cursor: pointer"
      >
        <Close />
      </el-icon>
    </div>
    <div class="layer_box">
      <div class="check_box">
        <!-- <el-checkbox @change="handlCheckAllChange" v-model="layerState">{{
          layerName
        }}</el-checkbox> -->
        {{ layerData.cnName }}
        <img src="../../assets/img/layer.png" alt="" />
      </div>
      <div class="slider-demo-block" v-show="diaphaneityShow">
      <!--  <div class="check_box">
    {{ layerData.cnName }}
    <img
      src="../../assets/img/layer.png"
      alt=""
    />
  </div> -->
      <div
        class="slider-demo-block"
        v-show="diaphaneityShow"
      >
        <div class="demonstration">透明度</div>
        <el-slider
          v-model="transparence"
@@ -23,7 +31,10 @@
        />
        <div class="demonstration">{{ transparence }}%</div>
      </div>
      <div class="slider-demo-block" v-show="contrastShow">
      <div
        class="slider-demo-block"
        v-show="contrastShow"
      >
        <div class="demonstration">对比度</div>
        <el-slider
          v-model="contrast"
@@ -33,29 +44,71 @@
        />
        <div class="demonstration">{{ contrast }}</div>
      </div>
      <div class="selectBox" v-show="drawingModeShow">
      <div
        class="selectBox"
        v-show="drawingModeShow"
      >
        <div class="selectTile demonstration">拉伸方式</div>
        <div class="stretchSelect">
          <el-select
            :teleported="false"
            v-model="stretchValue"
            class="stretchSelect"
            :class="{ imgSelect: stretchNumShow }"
            placeholder="选择拉伸方式"
            size="small"
            clearable
            @change="stretchChange"
          >
            <el-option
              v-for="item in stretchOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <span v-show="stretchNumShow">-</span>
          <el-input-number
            class="stretchNum"
            v-show="stretchNumShow"
            :precision="2"
            :step="0.01"
            v-model="stretchNum"
            :min="stretchMin"
            :max="stretchMax"
            controls-position="right"
            size="small"
            @change="stretchNumChange"
          />
        </div>
      </div>
      <!-- <div
        class="selectBox"
        v-show="colorShow"
      >
        <div class="selectTile demonstration">颜色表类型</div>
        <el-select
          v-model="stretchValue"
          class="imgSelect"
          placeholder="选择拉伸方式"
          size="small"
          clearable
          placeholder="请选择颜色表"
          v-model="colorTableType"
        >
          <el-option
            v-for="item in stretchOptions"
            :key="item.value"
            v-for="(item, i) in colorTableOptions"
            :key="i"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
          ></el-option>
        </el-select>
      </div>
      <div class="selectBox">
      </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)"
@@ -65,7 +118,7 @@
          <el-option
            v-for="(item, i) in renderTypeOptions"
            :key="i"
            :label="item.data_id"
            :label="item.name"
            :value="item.name"
          >
            <div
@@ -77,15 +130,27 @@
                left: 50%;
                transform: translate(-50%, -50%);
              "
              :style="{
                'background-image': `linear-gradient(to right, ${item.domCss})`,
              }"
              :style="item.domCss"
            ></div>
            <!-- <img :src="item.url" style="height: 30px; width: 100%" /> -->
          </el-option>
        </el-select>
      </div> -->
      <div v-show="colorShow">
        <div class="selectBox">
          <el-button
            size="small"
            type="primary"
            @click="setColorLayerRelease"
          >确认</el-button>
          <el-button
            size="small"
            @click="setSpatialClose"
          >取消</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
@@ -100,28 +165,65 @@
  defineEmits,
} from "vue";
import server from "@/assets/js/Map/server";
import axios from "axios";
import {
  publish_selectSjColorTables,
  publish_updateSjService,
  publish_updateSjLayerStretch,
} from "@/api/api";
import { ElMessage } from "element-plus";
import store from "@/store";
import json from "@/assets/js/colorValue";
// const colorValue = "@/assets/js/colorValue.json";
// console.log(colorValue);
const stretchValue = ref("");
const transparence = ref(0);
const contrast = ref(1);
let layerName = ref("图层名称");
let layerState = ref(false);
const releaseLayer = ref(null);
let select = ref();
let renderType = ref("");
let renderTypeOptions = [];
let renderTypeOptions = ref([]);
let stretchOptions = [
  {
    value: "Option1",
    label: "Option1",
    value: 0,
    label: "不拉伸",
  },
  {
    value: "Option2",
    label: "Option2",
    value: 1,
    label: "线性拉伸",
  },
  {
    value: 2,
    label: "直方图均衡",
  },
  {
    value: 3,
    label: "标准差拉伸",
  },
  {
    value: 4,
    label: "伽马拉伸",
  },
];
let colorTableOptions = [
  {
    value: 2,
    label: "请选择颜色表",
  },
  {
    value: 0,
    label: "普通颜色表",
  },
  {
    value: 1,
    label: "直方图均衡",
  },
];
let stretchNum = ref(0);
let stretchMin = ref(0);
let stretchMax = ref(0);
let colorTableType = ref(colorTableOptions[0].value);
let stretchNumShow = ref(false);
const formatTooltip = (val: number) => {
  return val / 100;
};
@@ -137,17 +239,41 @@
const setSpatialClose = () => {
  emits("detailClose", false);
};
const getColorJson = async () => {
  renderTypeOptions = json.result.item_list;
  renderTypeOptions.forEach((e) => {
    let css = "";
    e.content.levels.forEach((v) => {
      css += `rgb(${v.r_start}, ${v.g_start}, ${v.b_start}),`;
    });
    e.domCss = css.slice(0, -1);
  const dt = await publish_selectSjColorTables({
    pageIndex: 1,
    pageSize: 100000,
  });
  console.log(renderTypeOptions);
  renderTypeOptions.value = dt.result.item_list;
  renderTypeOptions.value.forEach((e) => {
    let css = "";
    let css1 = "";
    e.content.levels.forEach((v) => {
      if ("r_start" in v) {
        css += `rgb(${v.r_start}, ${v.g_start}, ${v.b_start}),rgb(${v.r_end}, ${v.g_end}, ${v.b_end}),`;
      } else if ("r" in v) {
        css1 += `rgb(${v.r}, ${v.g}, ${v.b}),`;
      }
    });
    let cssColor = `${css1}${css}`;
    let cssStr = "";
    if (cssColor.length == 19) {
      cssStr = `background: ${cssColor.slice(0, -1)}`;
    } else {
      cssStr = `background-image:linear-gradient(to right, ${cssColor.slice(
        0,
        -1
      )})`;
    }
    e.domCss = cssStr;
  });
  // console.log(renderTypeOptions.value);
};
const changeSelection = (scope) => {
  if (scope == "") {
    select.value.$el.children[0].children[0].removeAttribute("style");
@@ -195,7 +321,7 @@
  //   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(" +
@@ -207,6 +333,7 @@
};
//滑块变动
const sliderChange = (val) => {
  server.layerList[layerLength.value].layerData.alpha = val / 100;
};
const contrastChange = (val) => {
@@ -237,11 +364,100 @@
    val.data == 6
  ) {
    contrastShow.value = true;
    drawingModeShow.value = true;
    // drawingModeShow.value = true;
  }
  if (val.data == 3 || val.data == 4) {
    colorShow.value = true;
  }
};
//拉伸选择
const stretchChange = (val) => {
  console.log(val);
  if (val == 0) {
    stretchNumShow.value = false;
    stretchNum.value = 0;
    stretchMin.value = 0;
    stretchMax.value = 0;
  } else if (val == 1) {
    stretchNumShow.value = true;
    //1 线性拉伸
    stretchNum.value = 0.02;
    stretchMin.value = 0;
    stretchMax.value = 0.05;
  } else if (val == 2) {
    stretchNumShow.value = false;
    //1 直方图均衡
    stretchNum.value = 0;
    stretchMin.value = 0;
    stretchMax.value = 0;
  } else if (val == 3) {
    stretchNumShow.value = true;
    //1 标准差拉伸
    stretchNum.value = 0.02;
    stretchMin.value = 0;
    stretchMax.value = 0.05;
  } else if (val == 4) {
    stretchNumShow.value = true;
    //1 伽马拉伸
    stretchNum.value = 0.6;
    stretchMin.value = 0.1;
    stretchMax.value = 1.6;
  }
};
const stretchNumChange = (val) => {};
const setColorLayerRelease = async () => {
  var color1 = null;
  var color2 = null;
  var level = null;
  var val_data = [];
  for (var i in renderTypeOptions.value) {
    if (renderTypeOptions.value[i].name == renderType.value) {
      val_data.push(renderTypeOptions.value[i].content.levels);
    }
  }
  if (val_data.length > 0) {
    level = val_data[0];
  }
  if (colorTableType.value == 0) {
    color1 = level;
  } else if (colorTableType.value == 1) {
    color2 = level;
  }
  var geom = "null";
  if (releaseLayer.value.geom) {
    geom = releaseLayer.value.geom;
  }
  var obj = {
    // colorTable: color1, // 普通颜色表,可不设
    // gradientColorTable: color2,
    enhanceType: stretchValue.value, // 拉伸方式 0:不拉伸,1 线性拉伸,2 直方图均衡,3 标准差拉伸,4 伽马拉伸
    enhanceFactor: stretchNum.value, // 拉伸因子 null 或 小数
    // dircode: "00", // 目录编码
    // epsg: 104903, // 104903-月球2000,4326-WGS84
    layerId: releaseLayer.value.id, // 不要设定
    // name: releaseLayer.value.cnName, // 当前服务名称
    // nodata: 0, // 黑色-0,白色-255
    // type: releaseLayer.value.type, // 影像-DOM,高程-
    // geom: geom,
    // pubid: releaseLayer.value.pubid,
  };
  store.state.loading = true;
  publish_updateSjLayerStretch(obj).then((res) => {
    if (res.code != 200) {
      return ElMessage(data.msg);
    }
    if (res.code == 200 && res.result > 0) {
      store.state.loading = false;
      store.state.restLayer = true;
      setSpatialClose();
    } else {
      store.state.loading = false;
    }
  });
  // const data = ;
  // console.log("1122223" + data.code);
};
onMounted(() => {
  typeDisplay(props.layerData);
@@ -251,22 +467,30 @@
      transparence.value = e.layerData.alpha * 100;
    }
  });
  releaseLayer.value = props.layerData;
  if (releaseLayer.value.pubid && releaseLayer.value.pubid > 0) {
    drawingModeShow.value = true;
    colorShow.value = true;
  }
});
getColorJson();
// getColorJson();
</script>
<style lang="less" scoped>
.content {
  background: #1e2a3d;
  padding: 20px;
  // height: 400px;
  margin-left: 20px;
  min-width: 300px;
  margin-left: 385px;
  margin-top: 40px;
  min-width: 200px;
  z-index: 40;
  position: absolute;
  background: rgba(7, 8, 14, 0.8);
  border: 1px solid #d6e4ff;
  box-shadow: inset 0px 10px 40px 10px rgba(38, 47, 71, 1);
  .title {
    font-size: 18px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
@@ -340,4 +564,23 @@
/deep/.el-select-dropdown__item {
  font-size: 12px !important;
}
.stretchSelect {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .stretchSelect {
    width: 100%;
  }
  .imgSelect {
    width: 60%;
  }
  span {
    color: #fff;
    margin: 0 10px;
  }
  .stretchNum {
    width: 30%;
  }
}
</style>