<template>
|
<el-row justify="space-between">
|
<el-space>
|
<el-button
|
v-if="closeable"
|
size="small"
|
circle
|
icon="ArrowRight"
|
@click="$emit('close')"
|
></el-button>
|
<el-text>{{ dateStr }}计划</el-text>
|
</el-space>
|
<div v-show="create && data && data.length > 0">
|
<el-button type="success" size="small" plain @click="handleInspectFileDownload">
|
<el-icon class="el-icon--left">
|
<Icon icon="solar:printer-minimalistic-line-duotone" />
|
</el-icon>
|
单据打印
|
</el-button>
|
<el-button type="success" size="small" @click="add" icon="Switch">任务调整</el-button>
|
<el-button type="primary" size="small" @click="openMap">
|
任务地图<el-icon class="el-icon--right"><Right /></el-icon>
|
</el-button>
|
</div>
|
</el-row>
|
<el-divider />
|
<div>
|
<el-scrollbar v-loading="loading" :height="height">
|
<el-space
|
v-if="data && data.length > 0"
|
fill
|
:fill-ratio="100"
|
direction="vertical"
|
style="width: 100%"
|
>
|
<ItemSubTask v-for="s in data" :key="s.guid" :item="s">
|
<template #default="{ item }">
|
<el-space direction="horizontal">
|
<el-button
|
:disabled="item.status != '未执行'"
|
plain
|
type="primary"
|
size="small"
|
icon="EditPen"
|
@click="edit(item)"
|
title="修改"
|
></el-button>
|
<el-button
|
:disabled="item.status != '未执行'"
|
type="danger"
|
size="small"
|
icon="Delete"
|
@click="remove(item)"
|
title="移除"
|
></el-button>
|
</el-space>
|
</template>
|
</ItemSubTask>
|
</el-space>
|
<div v-else>
|
<el-empty description="无任务记录" />
|
<el-row v-if="create" justify="center">
|
<el-button type="success" size="small" :loading="createLoading" icon="Plus" @click="add"
|
>添加任务</el-button
|
>
|
<el-button type="primary" size="small" @click="openMap">
|
任务地图<el-icon class="el-icon--right"><Right /></el-icon>
|
</el-button>
|
</el-row>
|
</div>
|
</el-scrollbar>
|
</div>
|
<!-- 编辑巡查子任务 -->
|
<el-dialog
|
v-model="dialogVisible"
|
width="600"
|
title="巡查任务编辑"
|
destroy-on-close
|
:close-on-click-modal="false"
|
:close-on-press-escape="false"
|
:show-close="false"
|
>
|
<CompSubTaskEdit
|
v-model="activeItem"
|
@submit="onEditSubmit"
|
@cancel="dialogVisible = false"
|
></CompSubTaskEdit>
|
</el-dialog>
|
<!-- 巡查单下载 -->
|
<SceneInspectFile v-model="downloadDialog" :value="downloadSceneList"></SceneInspectFile>
|
</template>
|
<script setup>
|
import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
|
import { ElMessageBox, ElNotification, ElMessage, dayjs } from 'element-plus'
|
import CompSubTaskEdit from './CompSubTaskEdit.vue'
|
import SceneInspectFile from '@/views/inspection/scene/SceneInspectFile.vue'
|
import subtaskApi from '@/api/fysp/subtaskApi'
|
import { Icon } from '@iconify/vue'
|
|
const props = defineProps({
|
modelValue: Array,
|
date: Date,
|
height: {
|
type: String,
|
default: '70vh',
|
},
|
// 场景类型
|
sceneType: Number,
|
// 是否显示添加任务按钮
|
create: Boolean,
|
loading: Boolean,
|
createLoading: Boolean,
|
closeable: Boolean,
|
})
|
|
const dialogVisible = ref(false)
|
const activeItem = ref(null)
|
const data = computed(() => {
|
return props.modelValue.filter(
|
(v) =>
|
props.sceneType == undefined ||
|
v.sceneTypeId == undefined ||
|
v.sceneTypeId == props.sceneType,
|
)
|
})
|
const downloadDialog = ref(false)
|
const downloadSceneList = ref([])
|
|
const emit = defineEmits(['submit', 'add', 'openMap', 'remove', 'update:modelValue', 'close'])
|
|
const dateStr = computed(() => dayjs(props.date).format('MM月DD日'))
|
|
function remove(item) {
|
if (item.status == '未执行') {
|
ElMessageBox.confirm('是否移除监管任务', `移除确认`, {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning',
|
}).then(() => {
|
return subtaskApi.deleteSubtask(item.stguid).then((res) => {
|
if (res == 1) {
|
const index = data.value.indexOf(item)
|
data.value.splice(index, 1)
|
|
emit('update:modelValue', data.value)
|
emit('remove', item)
|
} else {
|
Promise.reject('删除巡查任务失败')
|
}
|
})
|
})
|
}
|
}
|
|
function edit(item) {
|
activeItem.value = item
|
dialogVisible.value = true
|
}
|
|
function onEditSubmit(item) {
|
dialogVisible.value = false
|
const index = data.value.findIndex((v) => {
|
return item.stguid == v.stguid
|
})
|
data.value.splice(index, 1, item)
|
emit('update:modelValue', data.value)
|
emit('submit')
|
}
|
|
function add() {
|
emit('add')
|
}
|
|
/**
|
* 打开场景地图
|
*/
|
function openMap() {
|
emit('openMap')
|
}
|
|
onUnmounted(() => {
|
dialogVisible.value = false
|
})
|
|
function handleInspectFileDownload() {
|
downloadSceneList.value = data.value.map((v) => v.scenseid)
|
downloadDialog.value = true
|
}
|
</script>
|