| | |
| | | <!-- |
| | | * @Author: husq 931347610@qq.com |
| | | * @Date: 2023-08-30 14:43:37 |
| | | * @LastEditors: husq 931347610@qq.com |
| | | * @LastEditTime: 2023-09-04 09:35:15 |
| | | * @FilePath: \Cloud-API-Demo-Web\src\pages\page-web\projects\project_list\add_page\add.vue |
| | | * @Description: |
| | | * |
| | | * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. |
| | | --> |
| | | <template> |
| | | <div class="project_add"> |
| | | <div class="side-header"> |
| | | <div class="side-option flex-display flex-align-center"> |
| | | <left-outlined class="point" @click="goBack" :style="{ fontSize: '18px', marginRight: '8px' }" /> |
| | | <h2 class="title point" @click="goBack">{{route.query.id ? '编辑项目' : '创建项目'}}</h2> |
| | | <h2 class="title point" @click="goBack">{{ route.query.id ? '编辑项目' : '创建项目' }}</h2> |
| | | </div> |
| | | <div class="border-bottom"></div> |
| | | </div> |
| | |
| | | <p>天气阻飞设置</p> |
| | | <div class="btn"> |
| | | <a-button type="text" @click="openDrawer('weatherDrawer')"> |
| | | <span class="button_name">{{ formState.projectBlocking.cloudBlockingConfigEnable == 1 ? |
| | | <span class="button_name">{{ formState.projectBlocking && |
| | | formState.projectBlocking.cloudBlockingConfigEnable == '1' ? |
| | | '已开启' |
| | | : '未开启' }}</span> |
| | | <template #icon><right-outlined |
| | |
| | | </template> |
| | | </a-table> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <a-form-item :name="FormProject.LATITUDE"> |
| | | <div class="application flex-display flex-align-center flex-justify-between"> |
| | | <p>项目作业中心点</p> |
| | | <div> |
| | | <a-button type="text"> |
| | | <a-button type="text" @click="configCenter"> |
| | | <span class="button_add">设置项目中心点</span> |
| | | <template #icon> |
| | | <AimOutlined :style="{ fontSize: '14px', color: '#2d8cf0' }" /> |
| | |
| | | </a-button> |
| | | </div> |
| | | </div> |
| | | <div class="latitude">经纬度:35.6761919°N 139.65031.6°E</div> |
| | | <div class="latitude" v-if="latitude && latitude != 0"> |
| | | 经纬度:{{ latitude }}°N {{ longitude }}°E</div> |
| | | </a-form-item> |
| | | </a-form> |
| | | <WeatherDrawer v-model:show="drawerConfig.weatherDrawer" title="以下设置仅在当前项目中生效"> |
| | |
| | | </div> |
| | | <div class="fix-button"> |
| | | <a-button @click="submit" style="width: 100%;height: 36px;justify-content: center;" |
| | | class="flex-display flex-align-center" type="primary">{{route.query.id ? '编辑项目' : '创建项目'}}</a-button> |
| | | class="flex-display flex-align-center" type="primary">{{ route.query.id ? '编辑项目' : '创建项目' }}</a-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | import ComWeather from './components/WeatherDrawer.vue' |
| | | import ComUser from './components/UserDrawer.vue' |
| | | import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface' |
| | | import { message } from 'ant-design-vue' |
| | | import { Form, message } from 'ant-design-vue' |
| | | import { cloneDeep } from 'lodash' |
| | | import { add, detail, edit as projectEdit } from '/@/api/project-page/index' |
| | | import { useMyStore } from '/@/store/index' |
| | | const router = useRouter() |
| | | const store = useMyStore() |
| | | const route = useRoute() |
| | | const dataSource = ref([]) |
| | | const deviceSource = ref([]) |
| | | const editableData: UnwrapRef<Record<string, ProjectUser>> = reactive({}) |
| | | const editDeviceData: UnwrapRef<Record<string, ProjectDevice>> = reactive({}) |
| | | const longitude = computed(() => { |
| | | return store.state.map.centerConfig.longitude |
| | | }) |
| | | const latitude = computed(() => { |
| | | return store.state.map.centerConfig.latitude |
| | | }) |
| | | const formState = ref<FormState>({ |
| | | [FormProject.PROJECT_NAME]: '', |
| | | [FormProject.PROJECT_STATUS]: '', |
| | | [FormProject.PROJCECT_INTRO]: '', |
| | | [FormProject.LONGITUDE]: 0, |
| | | [FormProject.LATITUDE]: 0, |
| | | [FormProject.LONGITUDE]: null, |
| | | [FormProject.LATITUDE]: null, |
| | | [FormProject.USERLIST]: [], |
| | | [FormProject.PROJECT_BLOCKING]: { |
| | | [blocking.CLOUDBLOCKINGCONFIGENABLE]: '1', |
| | |
| | | if (res.code !== 5000) return |
| | | message.success('修改成功') |
| | | router.go(-1) |
| | | store.commit('SET_CENTER_CONFIG_TYPE', false) |
| | | store.commit('SET_CENTER_CONFIG_LATITUDE', { latitude: null, longitude: null }) |
| | | } |
| | | // 新增项目 |
| | | const addProject = async () => { |
| | |
| | | if (res.code !== 5000) return |
| | | message.success('保存成功') |
| | | router.go(-1) |
| | | store.commit('SET_CENTER_CONFIG_TYPE', false) |
| | | store.commit('SET_CENTER_CONFIG_LATITUDE', { latitude: null, longitude: null }) |
| | | } |
| | | const goBack = () => { |
| | | router.go(-1) |
| | | store.commit('SET_CENTER_CONFIG_TYPE', false) |
| | | store.commit('SET_CENTER_CONFIG_LATITUDE', { latitude: null, longitude: null }) |
| | | } |
| | | // 天气组飞侧边栏 |
| | | const openDrawer = (name: string) => { |
| | | for (const key in drawerConfig.value) { |
| | | console.log(key) |
| | | if (key === name) { |
| | | drawerConfig.value[key] = true |
| | | } else { |
| | |
| | | } |
| | | // 表单验证提交 |
| | | const submit = () => { |
| | | formState.value[FormProject.LATITUDE] = latitude.value |
| | | formState.value[FormProject.LONGITUDE] = longitude.value |
| | | projectForm.value.validate().then(async () => { |
| | | if (route.query.id) { |
| | | editProject() |
| | |
| | | console.log(error) |
| | | }) |
| | | } |
| | | |
| | | // 设置项目中心点 |
| | | const configCenter = () => { |
| | | if (store.state.map.centerConfig.type === true) return |
| | | store.commit('SET_CENTER_CONFIG_TYPE', true) |
| | | } |
| | | onMounted(() => { |
| | | getDetail() |
| | | }) |