From 3667807a7b7418efc090ee3fa6a6b734bc3080bf Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Wed, 13 Sep 2023 20:36:29 +0800
Subject: [PATCH] Merge branch 'develop' of http://s16s652780.51mypc.cn:49896/r/yskj/iot_drone_web into develop
---
src/pages/page-web/projects/project_list/add_page/add.vue | 142 ++++++++++++++++++++++++++++++++++++-----------
1 files changed, 109 insertions(+), 33 deletions(-)
diff --git a/src/pages/page-web/projects/project_list/add_page/add.vue b/src/pages/page-web/projects/project_list/add_page/add.vue
index c79df66..3ddab6b 100644
--- a/src/pages/page-web/projects/project_list/add_page/add.vue
+++ b/src/pages/page-web/projects/project_list/add_page/add.vue
@@ -3,7 +3,7 @@
<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">创建项目</h2>
+ <h2 class="title point" @click="goBack">{{ route.query.id ? '编辑项目' : '创建项目' }}</h2>
</div>
<div class="border-bottom"></div>
</div>
@@ -32,8 +32,11 @@
<div class="application flex-display flex-align-center flex-justify-between">
<p>天气阻飞设置</p>
<div class="btn">
- <a-button type="text" @click="openWeatherDrawer">
- <span class="button_name">{{formState.projectBlocking.cloudBlockingConfigEnable == 1 ? '已开启' : '未开启' }}</span>
+ <a-button type="text" @click="openDrawer('weatherDrawer')">
+ <span class="button_name">{{ formState.projectBlocking &&
+ formState.projectBlocking.cloudBlockingConfigEnable == '1' ?
+ '已开启'
+ : '未开启' }}</span>
<template #icon><right-outlined
:style="{ fontSize: '14px', color: '#fff', marginLeft: '8px' }" /></template>
</a-button>
@@ -44,7 +47,7 @@
<div class="application flex-display flex-align-center flex-justify-between">
<p>项目成员</p>
<div>
- <a-button type="text">
+ <a-button type="text" @click="openDrawer('userDrawer')">
<span class="button_add">添加成员</span>
<template #icon><plus-outlined :style="{ fontSize: '14px', color: '#2d8cf0' }" /></template>
</a-button>
@@ -130,11 +133,11 @@
</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' }" />
@@ -142,16 +145,20 @@
</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="weatherDrawer" title="以下设置仅在当前项目中生效" >
+ <WeatherDrawer v-model:show="drawerConfig.weatherDrawer" title="以下设置仅在当前项目中生效">
<ComWeather v-model="formState" />
+ </WeatherDrawer>
+ <WeatherDrawer v-model:show="drawerConfig.userDrawer" title="添加成员">
+ <ComUser v-model="formState" />
</WeatherDrawer>
</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">创建项目</a-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>
</div>
</div>
</template>
@@ -162,28 +169,46 @@
import { UnwrapRef } from 'vue'
import WeatherDrawer from '/@/components/Drawer/Drawer.vue'
import ComWeather from './components/WeatherDrawer.vue'
+import ComUser from './components/UserDrawer.vue'
import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface'
+import { Form, message } from 'ant-design-vue'
import { cloneDeep } from 'lodash'
-import router from '/@/router'
+import { add, detail, edit as projectEdit } from '/@/api/project-page/index'
+import { addPoint } from '/@/hooks/use-center-point'
+import { useMyStore } from '/@/store/index'
+const { appContext } = getCurrentInstance()
+const global = appContext.config.globalProperties
+const router = useRouter()
+const store = useMyStore()
+const route = useRoute()
const dataSource = ref([])
const deviceSource = ref([])
-const weatherDrawer = ref(false)
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]: 'projectName',
+ [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,
- [blocking.WEATHERREPORTENABLE]: 1,
+ [blocking.CLOUDBLOCKINGCONFIGENABLE]: '1',
+ [blocking.WEATHERREPORTENABLE]: '1',
[blocking.WINDSPEED]: 12,
[blocking.WINDSPEEDREPORT]: 15,
[blocking.RAIN]: 3
}
+})
+const drawerConfig = ref({
+ userDrawer: false,
+ weatherDrawer: false,
})
const projectForm = ref()
// 表格操作方法
@@ -213,21 +238,72 @@
const del = (key: string, type: string) => {
console.log(key)
}
+// 获取项目详情
+const getDetail = async () => {
+ if (!route.query.id) return
+ const id = route.query.id
+ const res = await detail(id)
+ if (res.code !== 5000) return
+ formState.value = res.data
+ addPoint(global.$viewer, res.data.id, res.data.latitude, res.data.latitude)
+ store.commit('SET_CENTER_CONFIG_LATITUDE', { latitude: formState.value.latitude, longitude: formState.value.longitude })
+}
+// 编辑项目
+const editProject = async () => {
+ const res = await projectEdit(formState.value)
+ 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 () => {
+ const res = await add(formState.value)
+ 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 openWeatherDrawer = () => {
- weatherDrawer.value = true
+const openDrawer = (name: string) => {
+ for (const key in drawerConfig.value) {
+ if (key === name) {
+ drawerConfig.value[key] = true
+ } else {
+ drawerConfig.value[key] = false
+ }
+ }
}
// 表单验证提交
const submit = () => {
- projectForm.value.validate().then(() => {
- console.log('验证通过', formState)
- }).catch((error:ValidateErrorEntity<FormState>) => {
+ formState.value[FormProject.LATITUDE] = latitude.value
+ formState.value[FormProject.LONGITUDE] = longitude.value
+ projectForm.value.validate().then(async () => {
+ if (route.query.id) {
+ editProject()
+ } else {
+ addProject()
+ }
+ }).catch((error: ValidateErrorEntity<FormState>) => {
console.log(error)
})
}
+
+// 设置项目中心点
+const configCenter = () => {
+ if (store.state.map.centerConfig.type === true) return
+ store.commit('SET_CENTER_CONFIG_TYPE', true)
+}
+onMounted(() => {
+ getDetail()
+})
</script>
<style scoped lang="scss">
@@ -297,36 +373,36 @@
}
.ant-table-project :deep(.project_dark) td {
- background-color: #232323;
- color: #fff;
- border: none;
+ background-color: #232323 !important;
+ color: #fff !important;
+ border: none !important;
border-bottom: 1px solid #4f4f4f;
padding: 10px;
}
.ant-table-project :deep(.ant-table-placeholder) {
- background: #434343;
+ background: #434343 !important;
border: none !important;
}
.ant-table-project :deep(.ant-table-thead) th {
- background: #3c3c3c;
- color: #fff;
- border: 1px solid #4f4f4f;
+ background: #3c3c3c !important;
+ color: #fff !important;
+ border: 1px solid #4f4f4f !important;
padding: 10px;
}
.ant-table-project :deep(.ant-table-body) table {
- border: 1px solid #4f4f4f;
- border-right: 1px solid #4f4f4f;
+ border: 1px solid #4f4f4f !important;
+ border-right: 1px solid #4f4f4f !important;
}
.ant-table-project :deep(.ant-table-body) {
- background: #434343;
+ background: #434343 !important;
}
.ant-table-project :deep(.ant-empty-description) {
- color: #fff;
+ color: #fff !important;
}
}
--
Gitblit v1.9.3