| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- <template>
- <u-popup
- v-model="layerVisible"
- @close="layerClose"
- :round="8"
- :closeOnClickOverlay="false"
- @open="layerOpen"
- mode="bottom"
- >
- <view class="layer-popup">
- <view class="layer-popup__header">
- <view class="layer-popup__close">
- <u-icon
- name="close"
- size="36rpx"
- color="#4e6961"
- @click="layerClose"
- ></u-icon>
- </view>
- <view class="layer-popup__title">图层</view>
- </view>
- <view class="layer-popup__content">
- <view class="layer-panel" v-for="item in layerList" :key="item.id">
- <view class="layer-panel__header">{{ item.title }}</view>
- <view class="layer-panel__content">
- <u-row gutter="0">
- <u-col
- span="6"
- style="padding:0;width:calc(50% - 10rpx);margin-right:10rpx;flex:auto"
- v-for="checkItem in item.children"
- :key="checkItem.id"
- >
- <view
- class="check-item"
- :class="{ active: checkItem.isActive }"
- @click="checkItem.isActive = !checkItem.isActive"
- >
- <text>{{ checkItem.title }}</text>
- <view class="check-item__icon">
- <image
- src="../../assets/checkedSelect.png"
- class="icon"
- v-if="checkItem.isActive"
- />
- <image
- src="../../assets/checkedDisabled.png"
- class="icon"
- v-else
- />
- </view>
- </view>
- </u-col>
- </u-row>
- </view>
- </view>
- <view class="layer-panel">
- <view class="layer-panel__header">地图</view>
- <view class="layer-panel__content">
- <u-row gutter="0" customStyle="flex-wrap: wrap">
- <u-col span="3" customStyle="margin-bottom: 16px">
- <view
- class="map-check-item"
- @click="handleToggleMap(0)"
- :class="{ active: currentMapIndex === 0 }"
- >
- <image
- src="../../assets/map-01.png"
- class="map-check-item__img"
- />
- <view class="map-check-item__text">电子地图</view>
- </view>
- </u-col>
- <u-col span="3" customStyle="margin-bottom: 16px">
- <view
- class="map-check-item"
- @click="handleToggleMap(1)"
- :class="{ active: currentMapIndex === 1 }"
- >
- <image
- src="../../assets/map-02.png"
- class="map-check-item__img"
- />
- <view class="map-check-item__text">卫星地图</view>
- </view>
- </u-col>
- </u-row>
- </view>
- </view>
- </view>
- <view class="layer-popup__footer">
- <u-button
- type="primary"
- size="normal"
- customStyle="border-radius:16rpx"
- @click="handleConfirm"
- class="submit"
- >
- 确定
- </u-button>
- </view>
- </view>
- </u-popup>
- </template>
- <script>
- import { map } from 'lodash-es';
- export default {
- name: 'LayerPopup',
- props: {
- visible: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- layerVisible: false,
- layerList: [
- {
- id: '1',
- title: '图层管理',
- children: [
- {
- id: '1-1',
- title: '设备',
- value: 'device',
- isActive: true
- },
- {
- id: '1-2',
- title: '地块',
- value: 'block',
- isActive: true
- },
- {
- id: '1-3',
- title: '基地',
- value: 'land',
- isActive: true
- },
- // {
- // id: '1-4',
- // title: '水源',
- // isActive: false
- // },
- {
- id: '1-5',
- title: '种植作物',
- value: 'crop',
- isActive: true
- }
- ]
- }
- ],
- currentMapIndex: 1
- };
- },
- watch: {
- visible(newVal) {
- if (newVal !== this.layerVisible) {
- this.layerVisible = newVal;
- }
- }
- },
- methods: {
- layerClose() {
- this.$emit('update:visible', false);
- this.$emit('close');
- },
- layerOpen() {
- this.$emit('layerOpen');
- },
- handleToggleMap(index) {
- this.currentMapIndex = index;
- },
- handleConfirm() {
- const selectedLayers = this.layerList.reduce((acc, layer) => {
- const selectedChildren = layer.children.filter(
- (child) => child.isActive
- );
- if (selectedChildren.length) {
- acc.push(...selectedChildren);
- }
- return acc;
- }, []);
- this.layerClose();
- this.$emit('confirm', {
- renderTypes: map(selectedLayers, 'value'),
- isSatellite: this.currentMapIndex === 1
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .layer-popup {
- background-color: #fff;
- &__header {
- position: relative;
- height: 96rpx;
- color: #fff;
- border-bottom: 1rpx solid #e4e7ed;
- }
- &__title {
- text-align: center;
- font-size: 32rpx;
- line-height: 96rpx;
- color: #042118;
- }
- &__close {
- position: absolute;
- top: 0;
- right: 0;
- padding: 20rpx;
- color: #4e6961;
- }
- &__content {
- padding: 32rpx;
- background-color: #fff;
- }
- &__footer {
- display: flex;
- justify-content: center;
- padding: 16rpx 0rpx;
- background-color: #fff;
- box-shadow: 0 -2px 4px 0 #0000001a;
- }
- }
- .layer-panel {
- &__header {
- font-size: 32rpx;
- line-height: 46rpx;
- color: #042118;
- font-weight: 500;
- margin-bottom: 16rpx;
- }
- &__content {
- padding: 16rpx 0;
- }
- }
- .check-item {
- position: relative;
- display: flex;
- align-items: center;
- height: 70rpx;
- font-size: 32rpx;
- color: #042118;
- background: #f5f7fa;
- border-radius: 8rpx;
- padding: 4rpx 32rpx;
- margin:8rpx 0;
- border: 1rpx solid transparent;
- &.active {
- background: #fff;
- border-color: #14a478;
- }
- &__icon {
- position: absolute;
- right: 0;
- bottom: 0;
- width: 48rpx;
- height: 48rpx;
- .icon {
- width: 100%;
- height: 100%;
- }
- }
- }
- .map-check-item {
- position: relative;
- width: 136rpx;
- height: 126rpx;
- font-size: 32rpx;
- color: #fff;
- border-radius: 8rpx;
- border: 1rpx solid transparent;
- overflow: hidden;
- &.active {
- background: #fff;
- border-color: #14a478;
- .map-check-item__text {
- background-color: #14a478;
- }
- }
- &__img {
- width: 100%;
- height: 100%;
- }
- &__text {
- position: absolute;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 44rpx;
- font-size: 28rpx;
- line-height: 44rpx;
- text-align: center;
- color: #fff;
- background-color: rgba(0, 0, 0, 0.6);
- }
- }
- .submit{
- width: 100%;
- margin: 0 5%;
- display: flex;
- height: 40px;
- padding: 8px 12px;
- justify-content: center;
- align-items: center;
- gap: 4px;
- flex: 1 0 0;
- border-radius: 8px;
- background: #0BBC58;
- }
- </style>
|