| | |
| | | <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" |
| | |
| | | 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(); |
| | | |
| | |
| | | }; |
| | | |
| | | 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({ |
| | |
| | | ] |
| | | }); |
| | | |
| | | // 创建 |
| | | 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; |