罗广辉
2025-06-19 f27ca082eb0a839449dd50c49007b58e5ed6946f
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
<!--
 * @Author: GuLiMmo 2820890765@qq.com
 * @Date: 2024-03-27 15:15:50
 * @LastEditors: GuLiMmo 2820890765@qq.com
 * @LastEditTime: 2024-04-02 11:15:06
 * @FilePath: /drone-web/src/components/waylinetool/component/interval-shoot.vue
 * @Description: 航点事件-等距拍摄
 * Copyright (c) 2024 by GuLiMmo, All Rights Reserved.
-->
 
<template>
  <div class="container">
    <div :class="['fileSuffix', isInputShow && 'no-select']">
      <span>DJI_YYYYMMDDhhmm_XXX_</span>
      <span class="icon" @click="isInputShow = !isInputShow"><EditOutlined /></span>
    </div>
    <div class="fileSuffix-input" v-if="isInputShow">
      <a-input v-model:value="fileSuffix" placeholder="请输入文件后缀名称" size="small"></a-input>
      <a-button type="primary" shape="circle" size="small" @click="confirmInput">
        <template #icon>
          <CheckOutlined />
        </template>
      </a-button>
      <a-button type="danger" shape="circle" size="small" @click="cencalInput">
        <template #icon>
          <CloseOutlined />
        </template>
      </a-button>
    </div>
    <ul class="btn-group">
      <li
        :class="[
          'btn',
          isGlobalPhotoFormat && 'disabled-btn',
          !defaultParams.payloadLensIndex?.['#text'].includes('wide') && 'no-btn-selected',
        ]"
        @click="!isGlobalPhotoFormat && addFormatEvent('wide')">
        广角照片
      </li>
      <li
        :class="[
          'btn',
          isGlobalPhotoFormat && 'disabled-btn',
          !defaultParams.payloadLensIndex?.['#text'].includes('zoom') && 'no-btn-selected',
        ]"
        @click="!isGlobalPhotoFormat && addFormatEvent('zoom')">
        变焦照片
      </li>
      <li :class="['btn', !isGlobalPhotoFormat && 'no-btn-selected']" @click="addFormatEvent('global')">跟随全局</li>
    </ul>
  </div>
</template>
 
<script lang="ts" setup>
import _ from 'lodash'
import { defineProps, ref } from 'vue'
import { template as xmlJson } from '/@/utils/cesium/use-kmz-tsa'
import { EditOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
 
interface serialProp {
  placemark: number
  action: number
}
 
interface text {
  '#text': any
}
 
interface takePhoto {
  fileSuffix?: text
  payloadLensIndex: text
  payloadPositionIndex: text
  useGlobalPayloadLensIndex: text
}
 
const isInputShow = ref<boolean>(false)
 
const fileSuffix = ref<string>('')
 
const defaultParams = ref<takePhoto | any>({
  fileSuffix: { '#text': null },
  payloadLensIndex: { '#text': null },
  payloadPositionIndex: { '#text': null },
  useGlobalPayloadLensIndex: { '#text': null },
})
 
const confirmInput = () => {
  defaultParams.value.fileSuffix['#text'] = fileSuffix.value
  message.success('修改拍摄照片文件后缀成功!!')
}
 
const cencalInput = () => {
  fileSuffix.value = defaultFileSuffix.value
  defaultParams.value.fileSuffix['#text'] = defaultFileSuffix.value
  message.success('恢复初始拍摄照片文件后缀成功!!')
}
 
const props = defineProps<{
  serial: serialProp
}>()
 
const defaultFileSuffix = ref<string>('')
const getDefaultParams = (serial: serialProp) => {
  const placemarkJson = xmlJson.value.Folder.Placemark[serial.placemark]
  let action = placemarkJson.actionGroup.action
  if (Array.isArray(action)) {
    action = action[serial.action]
  }
  const actionActuatorFuncParam = action.actionActuatorFuncParam
  defaultParams.value = actionActuatorFuncParam
  fileSuffix.value = actionActuatorFuncParam.fileSuffix?.['#text'] || ''
  defaultFileSuffix.value = _.cloneDeep(fileSuffix.value)
  isInputShow.value = !!defaultParams.value.fileSuffix
}
 
// 判断当前是否使用全局照片设置
const isGlobalPhotoFormat = computed(() => Number(defaultParams.value.useGlobalPayloadLensIndex['#text']))
 
// 照片格式
const addFormatEvent = (value: string) => {
  if (value === 'global') {
    defaultParams.value.useGlobalPayloadLensIndex['#text'] = Number(!isGlobalPhotoFormat.value)
    if (!isGlobalPhotoFormat.value) {
      defaultParams.value.payloadLensIndex = { '#text': 'zoom,wide' }
    } else {
      delete defaultParams.value.payloadLensIndex
    }
  } else {
    if (!defaultParams.value.payloadLensIndex) {
      defaultParams.value.payloadLensIndex = { '#text': '' }
    }
    const payloadLensIndex = defaultParams.value.payloadLensIndex['#text']
    const payloadLensIndexArr = payloadLensIndex.split(',')
    if (!payloadLensIndex) {
      defaultParams.value.payloadLensIndex['#text'] = value
    } else {
      const index = payloadLensIndexArr.findIndex((item: string) => item === value)
      if (index === -1) {
        payloadLensIndexArr.push(value)
      } else {
        payloadLensIndexArr.splice(index, 1)
      }
      defaultParams.value.payloadLensIndex['#text'] = payloadLensIndexArr.join(',')
    }
  }
}
 
// 最新值
watch(
  () => defaultParams.value,
  (newParams) => {
    console.log(xmlJson.value)
  },
  {
    deep: true,
  },
)
 
// 默认值
watch(
  () => props.serial,
  (newVal: serialProp) => {
    getDefaultParams(newVal)
  },
  {
    deep: true,
    immediate: true,
  },
)
</script>
 
<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  .fileSuffix {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .icon {
      cursor: pointer;
      &:hover {
        color: #409eff;
      }
    }
  }
  .fileSuffix-input {
    margin-top: 10px;
    display: flex;
    input {
      background-color: transparent;
      color: #fff;
    }
    .ant-btn {
      margin-left: 10px;
    }
  }
  .btn-group {
    list-style-type: none;
    margin: 15px 0 0 0;
    padding: 0;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    .btn {
      font-size: 13px;
      padding: 2px 10px;
      background-color: #409eff;
      border-radius: 999px;
      cursor: pointer;
      font-weight: bold;
      &:last-child {
        margin-left: auto;
      }
    }
  }
}
 
.no-select {
  color: hsla(0, 0%, 100%, 0.45);
}
 
.no-btn-selected {
  background-color: hsla(0, 0%, 100%, 0.45) !important;
  border: hsla(0, 0%, 100%, 0.45) !important;
}
.disabled-btn {
  cursor: not-allowed !important;
  background-color: #314768 !important;
  border: #314768 !important;
  color: #ccc;
}
</style>