Browse Source

调整地图设计器数据结构

master
wangxiang 3 years ago
parent
commit
6ce0533e1e
  1. 30
      src/components/AMap/src/components/MapTaskPresetModal.vue

30
src/components/AMap/src/components/MapTaskPresetModal.vue

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
<BasicModal v-bind="$attrs"
:width="1050"
:minHeight="400"
@visible-change="handleModalVisibleChange"
@register="registerModal"
@ok="handleSubmit"
>
@ -52,7 +53,7 @@ @@ -52,7 +53,7 @@
/** 类型规范统一声明定义区域 */
interface WindowState {
currentEditKeyRef: string;
currentEditRowRef: Nullable<Recordable>;
taskPresetRow: Recordable;
courierUserId: string;
modelRef: Recordable;
@ -61,7 +62,7 @@ @@ -61,7 +62,7 @@
/** 通用变量统一声明区域 */
const state = reactive<WindowState>({
currentEditKeyRef: '',
currentEditRowRef: null,
taskPresetRow: {},
courierUserId: '',
orgList: [],
@ -176,7 +177,7 @@ @@ -176,7 +177,7 @@
return [
{
label: '编辑',
disabled: state.currentEditKeyRef ? state.currentEditKeyRef !== record.key : false,
disabled: state.currentEditRowRef ? state.currentEditRowRef.key !== record.key : false,
onClick: handleTaskTurnToDoEdit.bind(null, record),
}
];
@ -198,13 +199,13 @@ @@ -198,13 +199,13 @@
/** 处理转办任务表格编辑 */
function handleTaskTurnToDoEdit(record: EditRecordRow) {
state.currentEditKeyRef = record.key;
state.currentEditRowRef = record;
record.onEdit?.(true);
}
/** 处理转办任务表格编辑取消 */
function handleTaskTurnToDoCancel(record: EditRecordRow) {
state.currentEditKeyRef = '';
state.currentEditRowRef = null;
record.onEdit?.(false, false);
}
@ -213,17 +214,26 @@ @@ -213,17 +214,26 @@
const valid = await record.onValid?.();
if (valid) {
const pass = await record.onEdit?.(false, true);
pass && (state.currentEditKeyRef = '');
pass && (state.currentEditRowRef = null);
}
}
/** 处理模态框状态修改 */
function handleModalVisibleChange (visible: boolean) {
if (!visible && state.currentEditRowRef) {
handleTaskTurnToDoCancel(state.currentEditRowRef);
}
}
/** 处理弹出框提交 */
async function handleSubmit() {
try {
setModalProps({ confirmLoading: true });
//
const formData = await formElRef.value.validate();
setModalProps({ confirmLoading: true });
const mapTaskPresetData = toRaw(getDataSource());
if (state.currentEditRowRef) return createMessage.error('表格行未保存,请检查!');
if (mapTaskPresetData.length === 0) return createMessage.error('表格数据不能为空!');
const formData = await formElRef.value.validate();
const validateData:Promise<boolean>[] = [];
//
mapTaskPresetData.forEach(item => {
@ -236,11 +246,11 @@ @@ -236,11 +246,11 @@
}
});
const validateResult = await Promise.all(validateData);
if (!validateResult.every(item => item)) return createMessage.error('表格校验未通过,请检查!');
if (!validateResult.every(item => item)) return createMessage.error('表格校验未通过,请检查!');
//
const lastElement = mapTaskPresetData[mapTaskPresetData.length - 1];
const option = state.orgList.find(item => item.value == formData.destinationPresetId);
if (option) {
if (option && lastElement) {
lastElement.destinationPresetId = option.value;
lastElement.destinationPresetName = option.label;
lastElement.destinationPresetlng = option.mapLng;

Loading…
Cancel
Save