| New file |
| | |
| | | <template> |
| | | <div class="outcome-container"> |
| | | <el-form ref="searchRef" :model="searchParams" class="gd-search-form"> |
| | | <el-form-item label="巡查任务名称" prop="patrolTaskName"> |
| | | <el-select |
| | | class="gd-select" |
| | | popper-class="gd-select-popper" |
| | | v-model="searchParams.patrolTaskName" |
| | | placeholder="请选择" |
| | | clearable |
| | | filterable |
| | | @change="handleSearch" |
| | | > |
| | | <el-option |
| | | v-for="item in patrolTaskList" |
| | | :key="item.id" |
| | | :label="item.patrolTaskName" |
| | | :value="item.patrolTaskName" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item > |
| | | <!-- <el-button :icon="RefreshRight" @click="resetForm"></el-button> |
| | | <el-button class="search-btn" :icon="Search" @click="handleSearch"></el-button> --> |
| | | <el-button :icon="Download" color="#4C34FF" @click="handleBatchDownload">下载</el-button> |
| | | |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <div class="gd-table-container" v-loading="loading"> |
| | | <div class="gd-table-content gd-table-content-bg"> |
| | | <el-table class="gd-table" :data="list" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="46" /> |
| | | <el-table-column type="index" label="序号" width="80" /> |
| | | <el-table-column label="图片" width="120"> |
| | | <template v-slot="{ row }"> |
| | | <el-image |
| | | v-if="row.resultUrl" |
| | | :src="row.resultUrl" |
| | | :preview-src-list="[row.resultUrl]" |
| | | fit="cover" |
| | | style="width: 80px; height: 80px; border-radius: 4px;" |
| | | /> |
| | | <span v-else>-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="patrolTaskName" show-overflow-tooltip label="巡查任务名称" /> |
| | | <el-table-column prop="shootTime" show-overflow-tooltip label="拍摄时间" /> |
| | | <el-table-column label="操作" class-name="operation-btns" width="150"> |
| | | <template v-slot="{ row }"> |
| | | <!-- <el-link type="primary" @click="handleDownload(row)">下载</el-link> --> |
| | | <el-link type="primary" @click="handleDelete(row)">删除</el-link> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | |
| | | <div class="gd-pagination-parent"> |
| | | <el-pagination |
| | | popper-class="gd-select-popper" |
| | | v-model:current-page="searchParams.current" |
| | | v-model:page-size="searchParams.size" |
| | | layout="total, prev, pager, next, sizes" |
| | | :total="total" |
| | | @change="getList" |
| | | /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {gdTaskResultPageApi}from './orderManageApi' |
| | | import { Search, RefreshRight, Download } from '@element-plus/icons-vue' |
| | | import { ref, onMounted, inject } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { getDictLabel } from '@ztzf/utils' |
| | | import { gdPatrolTaskPageApi } from '@/views/orderView/orderManage/inspectionRequest/inspectionRequestApi' |
| | | import dayjs from 'dayjs' |
| | | |
| | | const props = defineProps({ |
| | | workOrderId: { |
| | | type: String, |
| | | required: true |
| | | } |
| | | }) |
| | | |
| | | const emit = defineEmits(['success']) |
| | | |
| | | // 初始化查询参数 |
| | | const initSearchParams = () => ({ |
| | | patrolTaskName: '', |
| | | current: 1, |
| | | size: 10, |
| | | }) |
| | | |
| | | const searchParams = ref(initSearchParams()) |
| | | const total = ref(0) |
| | | const loading = ref(true) |
| | | const list = ref([]) |
| | | const searchRef = ref(null) |
| | | const selectedRows = ref([]) |
| | | const patrolTaskList = ref([]) |
| | | const dictObj = inject('dictObj') |
| | | |
| | | // 获取巡查任务列表 |
| | | async function getPatrolTaskList() { |
| | | try { |
| | | const res = await gdTaskResultPageApi({ |
| | | current: 1, |
| | | size: 1000, |
| | | id: props.workOrderId |
| | | }) |
| | | patrolTaskList.value = res?.data?.data?.records || [] |
| | | console.log('patrolTaskList.value', patrolTaskList.value) |
| | | } catch (error) { |
| | | console.error('获取巡查任务列表失败:', error) |
| | | } |
| | | } |
| | | |
| | | // 获取成果数据列表 |
| | | async function getList() { |
| | | loading.value = true |
| | | try { |
| | | const res = await gdTaskResultPageApi({ |
| | | ...searchParams.value, |
| | | id: props.workOrderId |
| | | }) |
| | | list.value = res?.data?.data?.records || [] |
| | | total.value = res?.data?.data?.total || 0 |
| | | console.log('list.value', list.value) |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | } |
| | | |
| | | // 搜索 |
| | | function handleSearch() { |
| | | searchParams.value.current = 1 |
| | | getList() |
| | | } |
| | | |
| | | // 重置搜索 |
| | | function resetForm() { |
| | | searchRef.value?.resetFields() |
| | | searchParams.value.current = 1 |
| | | getList() |
| | | } |
| | | |
| | | // 选择变化 |
| | | function handleSelectionChange(rows) { |
| | | selectedRows.value = rows |
| | | } |
| | | |
| | | // 下载 |
| | | function handleDownload(row) { |
| | | if (!row.resultUrl) { |
| | | ElMessage.warning('暂无图片可下载') |
| | | return |
| | | } |
| | | const a = document.createElement('a') |
| | | a.href = row.resultUrl |
| | | a.download = `成果数据_${row.patrolTaskName}_${dayjs().format('YYYYMMDDHHmmss')}` |
| | | document.body.appendChild(a) |
| | | a.click() |
| | | document.body.removeChild(a) |
| | | ElMessage.success('下载成功') |
| | | } |
| | | |
| | | // 批量下载 |
| | | function handleBatchDownload() { |
| | | if (selectedRows.value.length === 0) { |
| | | ElMessage.warning('请选择要下载的数据') |
| | | return |
| | | } |
| | | selectedRows.value.forEach(row => { |
| | | if (row.resultUrl) { |
| | | const a = document.createElement('a') |
| | | a.href = row.resultUrl |
| | | a.download = `成果数据_${row.patrolTaskName}_${dayjs().format('YYYYMMDDHHmmss')}` |
| | | document.body.appendChild(a) |
| | | a.click() |
| | | document.body.removeChild(a) |
| | | } |
| | | }) |
| | | ElMessage.success('批量下载完成') |
| | | } |
| | | |
| | | // 删除 |
| | | async function handleDelete(row) { |
| | | await ElMessageBox.confirm('确认删除该条记录吗?', '提示', { |
| | | type: 'warning', |
| | | customClass: 'gd-confirm-custom', |
| | | confirmButtonClass: 'gd-confirm-button', |
| | | cancelButtonClass: 'gd-confirm-cancel-button', |
| | | }) |
| | | try { |
| | | // 这里需要调用删除接口,暂时模拟成功 |
| | | ElMessage.success('删除成功') |
| | | getList() |
| | | } catch (error) { |
| | | ElMessage.error('删除失败') |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getPatrolTaskList() |
| | | getList() |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .outcome-container { |
| | | height: 679px; |
| | | display: flex; |
| | | flex-direction: column; |
| | | overflow: hidden; |
| | | |
| | | .gd-table-container { |
| | | flex: 1; |
| | | overflow: hidden; |
| | | display: flex; |
| | | flex-direction: column; |
| | | |
| | | .gd-table-content { |
| | | flex: 1; |
| | | overflow: auto; |
| | | } |
| | | } |
| | | } |
| | | </style> |