From 2d3d56ff801b73afdb779267004d740f9beafe57 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期二, 31 十月 2023 16:09:44 +0800 Subject: [PATCH] 2023.10.31 --- src/views/overlay-grid/components/GridCreate.vue | 96 ++++++++++++++++++++++-------------------------- 1 files changed, 44 insertions(+), 52 deletions(-) diff --git a/src/views/overlay-grid/components/GridCreate.vue b/src/views/overlay-grid/components/GridCreate.vue index 45f2caa..6152df0 100644 --- a/src/views/overlay-grid/components/GridCreate.vue +++ b/src/views/overlay-grid/components/GridCreate.vue @@ -1,8 +1,19 @@ <template> <div> - <el-button type="primary" @click="createGrid">鏂板缓缃戞牸</el-button> + <el-button + :disabled="!gridStore.hasScheme" + type="primary" + @click="createGrid" + >鏂板缓缃戞牸</el-button + > </div> - <el-dialog v-model="dialogVisible" title="Tips" width="30%"> + <el-dialog + v-model="dialogVisible" + title="鏂板缓缃戞牸" + width="600px" + :close-on-click-modal="false" + :close-on-press-escape="false" + > <el-form :inline="false" :model="formObj" @@ -39,6 +50,8 @@ import { useGridStore } from '@/stores/grid'; import mapGrid from '@/components/map/mapGrid'; import baseMapUtil from '@/components/map/baseMapUtil'; +import gridInfoApi from '@/api/grid/gridInfoApi'; +import { getGridRecord } from '@/model/gridRecord'; const gridStore = useGridStore(); @@ -56,15 +69,11 @@ }; const props = defineProps({ - //鍩烘湰淇℃伅 - formInfo: Object, - //鏄垱寤烘垨鑰呮洿鏂� - isCreate: Boolean, + //缃戞牸鏂规id + schemeId: String, // isActive: Boolean }); - -const emit = defineEmits(['onSubmit', 'onCancel']); const { formObj, formRef, edit, active, onSubmit, onCancel } = useFormConfirm({ @@ -88,60 +97,43 @@ ] }); -// 鍒涘缓 -async function create() { - // loading.value = true; - // return sceneApi - // .createScene(formObj.value) - // .then((res) => { - // console.log(res); - // }) - // .finally(() => { - // loading.value = false; - // }); -} - -// 鏇存柊 -async function update() { - // loading.value = true; - // return sceneApi - // .updateScene(formObj.value) - // .then((res) => { - // console.log(res); - // }) - // .finally(() => { - // loading.value = false; - // }); -} - function submit() { - const newRecord = { - gId: '1', - gType: 0, - gName: formObj.value.gName, - gSide: tempOverlays.getPath(), - overlays: tempOverlays + const gridInfo = { + gsId: props.schemeId, + giName: formObj.value.gName, + giSide: tempOverlays.getPath().join(';') }; - gridStore.addGrid(newRecord); - emit('onSubmit', newRecord); - dialogVisible.value = false; + loading.value = true; + return gridInfoApi + .createGrid(gridInfo) + .then((res) => { + const newRecord = { + ...res, + overlays: tempOverlays + }; - return props.isCreate ? create() : update(); + gridStore.addGrid(getGridRecord(newRecord)); + dialogVisible.value = false; + }) + // .catch((err) => { + // return err; + // }) + .finally(() => (loading.value = false)); } + function cancel() { - emit('onCancel'); baseMapUtil.removeView(tempOverlays); dialogVisible.value = false; } -watch( - () => props.formInfo, - (nValue) => { - formObj.value = nValue; - }, - { immediate: false } -); +// watch( +// () => props.formInfo, +// (nValue) => { +// formObj.value = nValue; +// }, +// { immediate: false } +// ); watch(dialogVisible, (nValue) => { active.value = nValue; -- Gitblit v1.9.3