月球大数据地理空间分析展示平台-【前端】-月球2期前端
WX
2023-09-13 513e1bdf4b2703409d9e4dbb776e67ffa0c134a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
<template>
  <div class="content">
    <div class="title">
      <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">
        
    {{ 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"
          @change="sliderChange"
          :format-tooltip="formatTooltip"
        />
        <div class="demonstration">{{ transparence }}%</div>
      </div>
      <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>
        <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
          size="small"
          placeholder="请选择颜色表"
          v-model="colorTableType"
        >
          <el-option
            v-for="(item, i) in colorTableOptions"
            :key="i"
            :label="item.label"
            :value="item.value"
          ></el-option>
 
        </el-select>
      </div>
      <div
        class="selectBox"
        v-show="colorShow "
      >
        <div class="selectTile demonstration">渲染类型</div>
        <el-select
          v-model="renderType"
          placeholder="选择渲染类型"
          size="small"
          @change="changeSelection(renderType)"
          ref="select"
          clearable
        >
          <el-option
            v-for="(item, i) in renderTypeOptions"
            :key="i"
            :label="item.name"
            :value="item.name"
          >
            <div
              style="
                height: 30px;
                width: 100%;
                position: relative;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
              "
              :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>
 
<script lang="ts" setup>
import {
  ref,
  onMounted,
  onBeforeUnmount,
  reactive,
  defineProps,
  defineEmits,
} from "vue";
import server from "@/assets/js/Map/server";
import {
  publish_selectSjColorTables,
  publish_updateSjService,
} from "@/api/api";
import { ElMessage } from "element-plus";
import store from "@/store";
import json from "@/assets/js/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 = ref([]);
let stretchOptions = [
  {
    value: 0,
    label: "不拉伸",
  },
  {
    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;
};
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 getColorJson = async () => {
  const dt = await publish_selectSjColorTables({
    pageIndex: 1,
    pageSize: 100000,
  });
  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");
    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.name == scope) {
      // select.value.$el.children[0].children[0].setAttribute(
      //   "style",
      //   `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].setAttribute(
        "style",
        `background-image: linear-gradient(to right,${obj.domCss});
            width: 100%; height: 100%;
            border: none;
            height: 33px;`
      );
      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) {
 
  //     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;
  }
};
//拉伸选择
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
    ids: null, // 不要设定
    name: releaseLayer.value.cnName, // 当前服务名称
    nodata: 0, // 黑色-0,白色-255
    type: releaseLayer.value.type, // 影像-DOM,高程-
    geom: geom,
    pubid: releaseLayer.value.pubid,
  };
  publish_updateSjService(obj).then((res) => {
    if (res.code != 200) {
      return ElMessage(data.msg);
    }
    store.state.restLayer = true;
    setSpatialClose();
  });
  // const data = ;
  // console.log("1122223" + data.code);
};
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;
    }
  });
  releaseLayer.value = props.layerData;
  if (releaseLayer.value.pubid && releaseLayer.value.pubid > 0) {
    drawingModeShow.value = true;
    colorShow.value = true;
  }
});
getColorJson();
</script>
 
<style lang="less" scoped>
.content {
  padding: 20px;
  // height: 400px;
  min-width: 300px;
  margin-left: 385px;
  margin-top: 40px;
 
  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: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .layer_box {
    margin-top: 10px;
  }
}
.check_box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 50px;
  padding-top: 10px;
  font-size: 16px;
  color: #ffffff;
  img {
    width: 22px;
    height: 19px;
  }
}
.check_box .el-checkbox {
  font-size: 16px;
  color: #ffffff;
}
.check_box /deep/ .el-checkbox__input.is-checked .el-checkbox__inner {
  background-color: rgba(13, 255, 0, 1);
  border-color: rgba(41, 109, 255, 1);
}
.check_box /deep/ .el-checkbox__input.is-checked + .el-checkbox__label {
  color: #fff;
}
.slider-demo-block {
  margin-top: 22px;
}
.demonstration {
  font-size: 12px;
  font-weight: 300;
  color: #d6e4ff;
}
/deep/ .el-slider__runway {
  height: 2px;
 
  background: #73a1fa;
}
/deep/ .el-slider__bar {
  height: 2px;
 
  background: #73a1fa;
}
/deep/ .el-slider__button {
  width: 17px;
  height: 18px;
  border: 0;
  background: url("../../assets/img/DBX.png") no-repeat center;
  background-size: 100% 100%;
  border-radius: 0;
}
.selectBox {
  margin-top: 24px;
  .selectTile {
    padding-bottom: 6px;
  }
  .el-select {
    width: 100%;
  }
}
/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>