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

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

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

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

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

Loading…
Cancel
Save