Browse Source

🅰 修复Amap初始化上下文前使用他报错

master
wangxiang 3 years ago
parent
commit
f6f5152338
  1. 4
      src/components/AMap/src/AMapDesigner/index.vue
  2. 10
      src/views/common/mapLogistic/MapLogisticModal.vue
  3. 8
      src/views/common/mapLogistic/index.vue

4
src/components/AMap/src/AMapDesigner/index.vue

@ -504,7 +504,7 @@
if (!mapProps.toolbarControl) mapState.toggleOperatePanelClass.toolbarHeight = 0; if (!mapProps.toolbarControl) mapState.toggleOperatePanelClass.toolbarHeight = 0;
}); });
watch(toRefs(mapProps).options, (newValue: MapLogistic) => { watch(toRefs(mapProps).options, (newValue: MapLogistic) => {
setMapDataJson(newValue); nextTick(() => setMapDataJson(newValue));
}, { }, {
immediate: true, immediate: true,
deep: true deep: true
@ -547,7 +547,7 @@
mapState.mapData.mapTask = [...taskOrdinaryData, ...taskPresetData]; mapState.mapData.mapTask = [...taskOrdinaryData, ...taskPresetData];
} }
} }
handleMapPointGenerate(); nextTick(() => handleMapPointGenerate());
}); });
/** 处理切换操作面板 */ /** 处理切换操作面板 */

10
src/views/common/mapLogistic/MapLogisticModal.vue

@ -5,7 +5,7 @@
:showCancelBtn="false" :showCancelBtn="false"
@register="registerModal" @register="registerModal"
> >
<AMapDesigner @success="handleSubmit"/> <AMapDesigner :options="state.mapData" :isEdit="state.isEdit" @success="handleSubmit"/>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -25,12 +25,14 @@
interface WindowState { interface WindowState {
tag: string; tag: string;
mapData: Nullable<MapLogistic>; mapData: Nullable<MapLogistic>;
isEdit: boolean;
} }
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const state = reactive<WindowState>({ const state = reactive<WindowState>({
tag: '', tag: '',
mapData: null mapData: null,
isEdit: false
}); });
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ /** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
@ -43,10 +45,11 @@
// tag // tag
switch (state.tag) { switch (state.tag) {
case 'add': case 'add':
props.title = '新增科室'; state.isEdit = false;
break; break;
case 'edit': case 'edit':
props.title = '编辑科室'; props.title = '编辑科室';
state.isEdit = true;
state.mapData = await getMapDataByCourierUserId(courierUserId); state.mapData = await getMapDataByCourierUserId(courierUserId);
break; break;
} }
@ -54,7 +57,6 @@
setModalProps(props); setModalProps(props);
}); });
/** 处理弹出框提交 */ /** 处理弹出框提交 */
async function handleSubmit() { async function handleSubmit() {
closeModal(); closeModal();

8
src/views/common/mapLogistic/index.vue

@ -6,7 +6,7 @@
@click="() => {}" @click="() => {}"
>预览</a-button> >预览</a-button>
<a-button type="primary" <a-button type="primary"
@click="handleAdd()" @click="handleAdd"
>新增</a-button> >新增</a-button>
</template> </template>
<template #action="{ record }"> <template #action="{ record }">
@ -43,7 +43,7 @@
const { createConfirm, createMessage } = useMessage(); const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ const [registerTable, { reload }] = useTable({
title: '地图任务列表', title: '地图任务列表',
api: listMapLogistic, api: listMapLogistic,
rowKey: 'id', rowKey: 'id',
@ -73,13 +73,12 @@
/** 编辑按钮操作,行内编辑 */ /** 编辑按钮操作,行内编辑 */
function handleEdit(record?: Recordable) { function handleEdit(record?: Recordable) {
record = record || { id: getSelectRowKeys() };
openModal(true, { _tag: 'edit', record }); openModal(true, { _tag: 'edit', record });
} }
/** 删除按钮操作,行内删除 */ /** 删除按钮操作,行内删除 */
async function handleDel(record?: Recordable) { async function handleDel(record?: Recordable) {
const id = record?.id || getSelectRowKeys(); const id = record?.id;
createConfirm({ createConfirm({
iconType: 'warning', iconType: 'warning',
title: '警告', title: '警告',
@ -94,7 +93,6 @@
/** 处理表格刷新 */ /** 处理表格刷新 */
function handleRefreshTable() { function handleRefreshTable() {
clearSelectedRowKeys();
reload(); reload();
} }
</script> </script>

Loading…
Cancel
Save