<template>
|
<CardDialog
|
v-bind="$attrs"
|
title="走航融合管理"
|
:model-value="modelValue"
|
@update:modelValue="handleDialogChange"
|
>
|
<el-row class="mission-table">
|
<el-col :span="24">
|
<el-table
|
:data="missionStore.missionList"
|
table-layout="fixed"
|
size="small"
|
:show-overflow-tooltip="true"
|
border
|
height="64vh"
|
row-class-name="t-row-normal"
|
cell-class-name="t-cell"
|
header-row-class-name="t-header-row"
|
header-cell-class-name="t-header-cell"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
align="center"
|
width="50"
|
/>
|
<el-table-column prop="missionCode" label="任务编号" align="center" />
|
<el-table-column
|
prop="startTime"
|
label="开始时间"
|
align="center"
|
:formatter="timeFormatter"
|
width="150"
|
/>
|
<el-table-column
|
prop="endTime"
|
label="结束时间"
|
align="center"
|
:formatter="timeFormatter"
|
width="150"
|
/>
|
<el-table-column label="融合记录" align="center" width="50">
|
<template #default="{ row }">
|
{{ row.fusionData ? '有' : '无' }}
|
</template>
|
</el-table-column>
|
<el-table-column label="管理" width="160" align="center">
|
<template #default="{ row }">
|
<el-button
|
v-if="row.fusionData"
|
type="primary"
|
size="small"
|
icon="EditPen"
|
class="el-button-custom-light"
|
:loading="row.loading"
|
@click="updateFusionRecord(row)"
|
>更新记录</el-button
|
>
|
<el-button
|
v-else
|
type="primary"
|
size="small"
|
icon="Plus"
|
class="el-button-custom"
|
:loading="row.loading"
|
@click="createFusionRecord(row)"
|
>融合生成</el-button
|
>
|
<el-button
|
v-if="row.fusionData"
|
type="primary"
|
size="small"
|
icon="Delete"
|
class="el-button-custom"
|
:disabled="row.loading"
|
@click="deleteFusionRecord(row)"
|
></el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-col>
|
</el-row>
|
</CardDialog>
|
<MessageBox
|
v-model="msgBoxVisible"
|
:on-confirm="onConfirm"
|
title="删除走航融合"
|
msg="确认是否删除该走航融合"
|
confirmText="删除"
|
></MessageBox>
|
<UnderwayMixEdit
|
v-model="dialogVisible"
|
width="30%"
|
:group-id="groupId"
|
:mode="editMode"
|
:record="selectedFusionRecord"
|
@on-submit="refreshFusionRecord"
|
></UnderwayMixEdit>
|
</template>
|
<script setup>
|
import { ref, watch, onMounted } from 'vue';
|
import moment from 'moment';
|
import gridApi from '@/api/gridApi';
|
import { useMissionStore } from '@/stores/mission';
|
import { useFetchData } from '@/composables/fetchData';
|
|
import UnderwayMixEdit from './UnderwayMixEdit.vue';
|
|
const props = defineProps({
|
modelValue: Boolean,
|
groupId: {
|
type: Number,
|
default: 2
|
}
|
});
|
|
const emits = defineEmits(['update:modelValue', 'onUpdated']);
|
|
const { loading, fetchData } = useFetchData();
|
const missionStore = useMissionStore();
|
|
const isEdited = ref(false);
|
const editMode = ref('create');
|
const selectedFusionRecord = ref(undefined);
|
const dialogVisible = ref(false);
|
const msgBoxVisible = ref(false);
|
const onConfirm = ref(undefined);
|
|
// eslint-disable-next-line no-unused-vars
|
function timeFormatter(row, col, cellValue, index) {
|
return moment(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
}
|
|
// 查询走航融合记录
|
function fetchFusionRecord(row) {
|
row.loading = true;
|
gridApi
|
.fetchGridData2({ type: 3, missionCode: row.missionCode })
|
.then((res) => {
|
// 走航网格融合,单个走航在在单个网格组中只有唯一记录
|
if (res.data.length > 0) {
|
row.fusionData = res.data[0];
|
} else {
|
row.fusionData = undefined;
|
}
|
})
|
.finally(() => (row.loading = false));
|
}
|
|
function createFusionRecord(row) {
|
editMode.value = 'create';
|
selectedFusionRecord.value = row;
|
dialogVisible.value = true;
|
// row.loading = true;
|
// setTimeout(() => {
|
// row.loading = false;
|
// }, 1000);
|
}
|
|
function updateFusionRecord(row) {
|
editMode.value = 'update';
|
selectedFusionRecord.value = row;
|
dialogVisible.value = true;
|
}
|
|
function deleteFusionRecord(row) {
|
this.onConfirm = () => {
|
gridApi.deleteGridData(row.fusionData.id).then((res) => {
|
if (res.data) {
|
refreshFusionRecord(row.missionCode);
|
}
|
});
|
};
|
this.msgBoxVisible = true;
|
}
|
|
function refreshFusionRecord(missionCode) {
|
const m = missionStore.missionList.find((v) => v.missionCode == missionCode);
|
fetchFusionRecord(m);
|
isEdited.value = true;
|
}
|
|
function handleDialogChange(e) {
|
emits('update:modelValue', e);
|
if (isEdited.value) {
|
emits('onUpdated');
|
}
|
}
|
|
watch(
|
() => props.modelValue,
|
(nV, oV) => {
|
if (nV) {
|
isEdited.value = false;
|
missionStore.missionList.forEach((v) => {
|
fetchFusionRecord(v);
|
});
|
}
|
}
|
);
|
</script>
|
<style scoped>
|
.flex-col {
|
display: flex;
|
flex-direction: column;
|
gap: 4px;
|
align-items: flex-end;
|
}
|
|
:deep(.t-row-normal) {
|
background-color: transparent !important;
|
}
|
</style>
|