| | |
| | | <script setup lang="tsx"> |
| | | import { ref, onMounted, reactive } from 'vue' |
| | | import { useBoolean } from '@/hooks' |
| | | import { useScriptTag } from '@vueuse/core' |
| | | import { NButton, useMessage } from 'naive-ui' |
| | | import { useRouter, useRoute } from 'vue-router' |
| | |
| | | const message = useMessage() |
| | | const tabStore = useTabStore() |
| | | const dialog = useDialog() |
| | | const { bool: loading, setTrue: startLoading, setFalse: endLoading } = useBoolean(false) |
| | | |
| | | const { VITE_MAP_KEY } = import.meta.env |
| | | |
| | |
| | | } |
| | | // 如果是具体时间值,则验证不能早于当前时间 |
| | | if (typeof value === 'number') { |
| | | // 当处于编辑并且围栏状态是启用中不校验 |
| | | if (modalType.value === 'edit' && fenceDetail.value.status === 2) return true |
| | | // 计算当前时间加一分钟作为最小允许时间 |
| | | const now = new Date(); |
| | | const minAllowedDateTime = new Date( |
| | |
| | | operationStrategy: JSON.stringify(operationStrategy), |
| | | electronicFenceAreas: electronicFenceAreas, |
| | | } |
| | | startLoading() |
| | | if (modalType.value === 'add') { |
| | | addFence(params).then((res) => { |
| | | if (res.code === 200) { |
| | |
| | | tabStore.closeTab(route.fullPath) |
| | | router.back() |
| | | } |
| | | }) |
| | | }).finally(() => endLoading()) |
| | | } else if (modalType.value === 'edit') { |
| | | if (formModel.value.areaStatus !== fenceDetail.value.electronicFenceAreas.find((item: any) => item.areaType === 1)?.areaStatus) { |
| | | dialog.create({ |
| | |
| | | tabStore.closeTab(route.fullPath) |
| | | router.back() |
| | | } |
| | | }) |
| | | }).finally(() => endLoading()) |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | tabStore.closeTab(route.fullPath) |
| | | router.back() |
| | | } |
| | | }) |
| | | }).finally(() => endLoading()) |
| | | } |
| | | } |
| | | }) |
| | |
| | | |
| | | </div> |
| | | <div class="drawer-footer"> |
| | | <NButton strong secondary class="w-124px" @click="handleAddFence(0)" v-if="modalType === 'add' || (modalType === 'edit' && fenceDetail?.status === 0)"> |
| | | <NButton strong secondary :loading="loading" class="w-124px" @click="handleAddFence(0)" v-if="modalType === 'add' || (modalType === 'edit' && fenceDetail?.status === 0)"> |
| | | 保存草稿 |
| | | </NButton> |
| | | <NButton strong secondary class="w-124px" @click="onClose" v-if="modalType === 'edit' && fenceDetail?.status !== 0"> |
| | | 取消 |
| | | </NButton> |
| | | <NButton type="primary" class="w-124px" @click="handleAddFence(1)" v-if="modalType === 'add' || modalType === 'edit'"> |
| | | <NButton type="primary" :loading="loading" class="w-124px" @click="handleAddFence(1)" v-if="modalType === 'add' || modalType === 'edit'"> |
| | | 发布执行 |
| | | </NButton> |
| | | <NButton type="primary" class="w-full" @click="() => { |