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

Loading…
Cancel
Save