|
|
@ -1,110 +1,103 @@ |
|
|
|
|
|
|
|
<template> |
|
|
|
|
|
|
|
<BasicModal v-bind="$attrs" |
|
|
|
|
|
|
|
defaultFullscreen |
|
|
|
|
|
|
|
@register="registerModal" |
|
|
|
|
|
|
|
@ok="handleSubmit" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div class="pointBody"> |
|
|
|
|
|
|
|
<div class="leftLayout"> |
|
|
|
|
|
|
|
<AMapDesigner ref="AMapDesignerEl" |
|
|
|
|
|
|
|
:options="state.mapData" |
|
|
|
|
|
|
|
:sidebarControl="false" |
|
|
|
|
|
|
|
:toolbarControl="false" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="rightLayout"> |
|
|
|
|
|
|
|
<vxe-grid ref="VxeGridEl" v-bind="state.gridOptions"/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</BasicModal> |
|
|
|
|
|
|
|
</template> |
|
|
|
<script lang="tsx" setup> |
|
|
|
<script lang="tsx" setup> |
|
|
|
import { reactive, nextTick, ref, h } from 'vue'; |
|
|
|
import { reactive, nextTick, ref } from 'vue'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
|
|
|
import { Form, Select, Row, Col } from 'ant-design-vue'; |
|
|
|
|
|
|
|
import { AMapDesigner } from '/@/components/AMap'; |
|
|
|
import { AMapDesigner } from '/@/components/AMap'; |
|
|
|
import Sortable from 'sortablejs'; |
|
|
|
import Sortable from 'sortablejs'; |
|
|
|
import { VxeGridProps } from 'vxe-table'; |
|
|
|
import { VxeGridProps } from 'vxe-table'; |
|
|
|
|
|
|
|
import { MapData, mapPointColumns } from '../amap.data'; |
|
|
|
|
|
|
|
import { defaultMapData } from '/@/enums/amapEnum'; |
|
|
|
|
|
|
|
import { cloneDeep } from 'lodash-es'; |
|
|
|
|
|
|
|
|
|
|
|
const VxeGridEl = ref(); |
|
|
|
/** 类型规范统一声明定义区域 */ |
|
|
|
const mapSettingsState = reactive({ |
|
|
|
interface WindowState { |
|
|
|
sortable: {} |
|
|
|
sortable: Nullable<object>; |
|
|
|
}); |
|
|
|
gridOptions: VxeGridProps; |
|
|
|
const gridOptions = reactive({ |
|
|
|
mapData: MapData; |
|
|
|
data: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 10001, |
|
|
|
|
|
|
|
name: 'Test1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 10002, |
|
|
|
|
|
|
|
name: 'Test2' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: 10003, |
|
|
|
|
|
|
|
name: 'Test3' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
columns: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
width: '50px', |
|
|
|
|
|
|
|
align: 'center', |
|
|
|
|
|
|
|
slots: { |
|
|
|
|
|
|
|
default ({ row }) { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<span class="drag-btn"> |
|
|
|
|
|
|
|
<i class="vxe-icon--menu"/> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
header ({ row }) { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<vxe-tooltip content="按住后可以上下拖动排序!"> |
|
|
|
|
|
|
|
<i class="vxe-icon--question"/> |
|
|
|
|
|
|
|
</vxe-tooltip> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
{ field: 'name', title: '名称' } |
|
|
|
const VxeGridEl = ref(); |
|
|
|
], |
|
|
|
const AMapDesignerEl = ref(); |
|
|
|
|
|
|
|
const state = reactive<WindowState>({ |
|
|
|
|
|
|
|
sortable: null, |
|
|
|
|
|
|
|
gridOptions: { |
|
|
|
|
|
|
|
columns: mapPointColumns, |
|
|
|
rowConfig: { |
|
|
|
rowConfig: { |
|
|
|
useKey: true, |
|
|
|
useKey: true, |
|
|
|
isHover: true |
|
|
|
isHover: true, |
|
|
|
|
|
|
|
keyField: 'id' |
|
|
|
}, |
|
|
|
}, |
|
|
|
border: true, |
|
|
|
border: true, |
|
|
|
height: 'auto', |
|
|
|
height: 'auto', |
|
|
|
stripe: true |
|
|
|
stripe: true |
|
|
|
} as VxeGridProps); |
|
|
|
}, |
|
|
|
const AForm = Form; |
|
|
|
mapData: defaultMapData() |
|
|
|
const AFormItem = Form.Item; |
|
|
|
}); |
|
|
|
const ASelect = Select; |
|
|
|
|
|
|
|
const ARow = Row; |
|
|
|
|
|
|
|
const ACol = Col; |
|
|
|
|
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const emit = defineEmits(['success', 'register']); |
|
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(data => { |
|
|
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(data => { |
|
|
|
|
|
|
|
// 处理设置数据 |
|
|
|
|
|
|
|
state.mapData = cloneDeep(data.mapData); |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
const props: Partial<ModalProps> = { confirmLoading: false }; |
|
|
|
props.title = '标记点配置'; |
|
|
|
props.title = '标记点配置'; |
|
|
|
|
|
|
|
|
|
|
|
nextTick(()=> { |
|
|
|
nextTick(()=> { |
|
|
|
mapSettingsState.sortable = Sortable.create(VxeGridEl.value!.$el.querySelector('.body--wrapper>.vxe-table--body tbody'), { |
|
|
|
state.sortable = Sortable.create(VxeGridEl.value!.$el.querySelector('.body--wrapper>.vxe-table--body tbody'), { |
|
|
|
handle: '.drag-btn', |
|
|
|
handle: '.drag-btn', |
|
|
|
onEnd: ({ newIndex, oldIndex }) => { |
|
|
|
onEnd: ({ newIndex, oldIndex }) => { |
|
|
|
const currRow = gridOptions.data?.splice(oldIndex!, 1)[0]; |
|
|
|
const currRow = state.mapData.mapLogisticPoint?.splice(oldIndex!, 1)[0]; |
|
|
|
gridOptions.data?.splice(newIndex!, 0, currRow); |
|
|
|
state.mapData.mapLogisticPoint?.splice(newIndex!, 0, currRow); |
|
|
|
|
|
|
|
AMapDesignerEl.value?.drawMapNavigate(state.mapData.mapLogisticPoint); |
|
|
|
}, |
|
|
|
}, |
|
|
|
ghostClass: 'ghostGrid' |
|
|
|
ghostClass: 'ghostGrid' |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
VxeGridEl.value.reloadData(state.mapData.mapLogisticPoint); |
|
|
|
// 尾部:设置处理后的最终配置数据 |
|
|
|
// 尾部:设置处理后的最终配置数据 |
|
|
|
setModalProps(props); |
|
|
|
setModalProps(props); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 处理弹出框提交 */ |
|
|
|
function handleSubmit() { |
|
|
|
function handleSubmit() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 处理提交之前逻辑 |
|
|
|
|
|
|
|
setModalProps({ confirmLoading: true }); |
|
|
|
|
|
|
|
// 处理重新排序 |
|
|
|
|
|
|
|
const mapLogisticPoint = state.mapData.mapLogisticPoint.map((item, index)=> ({ sort: index, ...item })); |
|
|
|
|
|
|
|
// 处理提交完成之后逻辑 |
|
|
|
|
|
|
|
closeModal(); |
|
|
|
|
|
|
|
emit('success', mapLogisticPoint); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
setModalProps({ confirmLoading: false }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
<template> |
|
|
|
|
|
|
|
<BasicModal v-bind="$attrs" |
|
|
|
|
|
|
|
defaultFullscreen |
|
|
|
|
|
|
|
@register="registerModal" |
|
|
|
|
|
|
|
@ok="handleSubmit" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<ARow> |
|
|
|
|
|
|
|
<ACol :span="12"> |
|
|
|
|
|
|
|
<AMapDesigner :sidebarControl="false"/> |
|
|
|
|
|
|
|
</ACol> |
|
|
|
|
|
|
|
<ACol :span="12"> |
|
|
|
|
|
|
|
<vxe-grid ref="VxeGridEl" v-bind="gridOptions"/> |
|
|
|
|
|
|
|
</ACol> |
|
|
|
|
|
|
|
</ARow> |
|
|
|
|
|
|
|
</BasicModal> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<style> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.ghostGrid { |
|
|
|
<style lang="less" scoped> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 标记点样式 |
|
|
|
|
|
|
|
.pointBody { |
|
|
|
|
|
|
|
// 拖拽轨迹样式 |
|
|
|
|
|
|
|
:deep(.ghostGrid) { |
|
|
|
background: white; |
|
|
|
background: white; |
|
|
|
border: 2px solid #67C23A; |
|
|
|
border: 2px solid #67C23A; |
|
|
|
box-sizing: border-box; |
|
|
|
box-sizing: border-box; |
|
|
@ -120,5 +113,26 @@ |
|
|
|
margin: 0 2px 0 2px; |
|
|
|
margin: 0 2px 0 2px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.leftLayout { |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
top: 0; |
|
|
|
|
|
|
|
left: 0; |
|
|
|
|
|
|
|
right: 50%; |
|
|
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.rightLayout { |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
top: 0; |
|
|
|
|
|
|
|
left: 50%; |
|
|
|
|
|
|
|
right: 0; |
|
|
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style> |
|
|
|
</style> |
|
|
|
|
|
|
|
|
|
|
|