| | |
| | | <dispatch-dialog |
| | | v-model="dispatchDialogVisible" |
| | | :current-detail="currentDetail" |
| | | :departments="departments" |
| | | :department-users="departmentUsers" |
| | | :algorithms="algorithms" |
| | | :types="types" |
| | |
| | | @dispatch-error="handleDispatchError" |
| | | /> |
| | | |
| | | <!-- 添加在其他 dialog 组件之后 --> |
| | | <!-- 批量审核对话框 --> |
| | | <el-dialog |
| | | v-model="reviewDialogVisible" |
| | | title="批量审核" |
| | |
| | | function validData(value, defaultValue) { |
| | | return value !== undefined ? value : defaultValue |
| | | } |
| | | // 获取表格数据 |
| | | async function fetchTableData() { |
| | | if (isFetching.value) return |
| | | isFetching.value = true |
| | | loading.value = true |
| | | const statusListVal = statusList.value; |
| | | try { |
| | | const currentTab = tabs.value.find(tab => tab.name === activeTab.value) |
| | | const params = { |
| | | ai_types: filters.type || undefined, |
| | | status: currentTab?.name === 'myTickets' |
| | | ? undefined |
| | | : filters.status !== '' |
| | | ? Number(filters.status) |
| | | : currentTab?.value, |
| | | event_name: filters.keyword || undefined, |
| | | dept_id: filters.department || undefined, |
| | | start_date: filters.dateRange?.[0] |
| | | ? formatDate(filters.dateRange[0]) |
| | | : undefined, |
| | | end_date: filters.dateRange?.[1] |
| | | ? formatDate(filters.dateRange[1]).replace('00:00:00', '23:59:59') |
| | | : undefined, |
| | | current: Number(page.currentPage), |
| | | size: Number(page.pageSize), |
| | | ai_type: filters.algorithm || undefined, |
| | | is_draft: currentTab?.name === 'myTickets' ? 1 : undefined, |
| | | user_id: currentTab?.name === 'myTickets' ? userInfo.value.user_id : undefined, |
| | | is_review: filters.isReview === '' ? undefined : filters.isReview, |
| | | source: 1, |
| | | status_list: statusListVal |
| | | } |
| | | |
| | | const response = await getList(params) |
| | | if (!response?.data?.data?.records) { |
| | | throw new Error('接口返回数据格式不正确') |
| | | } |
| | | const { total, records } = response.data.data |
| | | let filteredRecords = records |
| | | tableData.value = filteredRecords.map(item => { |
| | | const longitude = Number(item.longitude) || 0 |
| | | const latitude = Number(item.latitude) || 0 |
| | | return { |
| | | id: item.id, |
| | | orderNumber: item.event_num, |
| | | orderName: item.event_name, |
| | | department: departments.value.find(d => d.value === item.dept_id)?.label || item.dept_name, |
| | | startTime: item.job_create_time || '/', |
| | | aiType: item.ai_types, |
| | | content: item.content, |
| | | type: item.work_order_type_dict_key, |
| | | keyData: !isNaN(longitude) && !isNaN(latitude) |
| | | ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` |
| | | : '未知位置', |
| | | address: item.address, |
| | | creator: item.event_num?.slice(0, 2) === 'AI' ? '智飞agent' : item.create_user, |
| | | handler: item.update_user || '未分配', |
| | | status: Number(item.status || 0), |
| | | photo_url: item.photo_url || '', |
| | | video_url: item.video_url || '', |
| | | location: !isNaN(longitude) && !isNaN(latitude) ? [longitude, latitude] : null, |
| | | processing_details: item.processing_details || '', |
| | | update_photo_url: item.update_photo_url || '', |
| | | work_type: item.work_type !== undefined ? Number(item.work_type) : 0, |
| | | job_name: item.job_name || '', |
| | | job_create_time: item.job_create_time || '', |
| | | isReview: item.is_review, |
| | | handle_user_id:item.handle_user_id |
| | | |
| | | } |
| | | }) |
| | | |
| | | page.total = total || 0 |
| | | if (isShowInfo.value) { |
| | | handleViewDetail(firstRowData.value) |
| | | isShowInfo.value = false |
| | | } |
| | | await fetchTabCounts() |
| | | } catch (error) { |
| | | console.error('获取数据失败:', error) |
| | | tableData.value = [] |
| | | page.total = 0 |
| | | } finally { |
| | | loading.value = false |
| | | isFetching.value = false |
| | | } |
| | | } |
| | | // 获取工单类型标签 |
| | | function getTypeLabel(typeValue) { |
| | | const typeObj = types.value.find(item => item.value === typeValue) |
| | |
| | | try { |
| | | const response = await getTicketInfo() |
| | | const { dept_data, event_type, ai_type, info } = response.data.data |
| | | |
| | | departments.value = dept_data.map(item => ({ |
| | | label: item.dept_name, |
| | | value: item.id, |
| | |
| | | console.error('加载下拉框数据失败:', error) |
| | | } |
| | | } |
| | | // 获取表格数据 |
| | | async function fetchTableData() { |
| | | if (isFetching.value) return |
| | | isFetching.value = true |
| | | loading.value = true |
| | | const statusListVal = statusList.value; |
| | | try { |
| | | const currentTab = tabs.value.find(tab => tab.name === activeTab.value) |
| | | const params = { |
| | | ai_types: filters.type || undefined, |
| | | status: currentTab?.name === 'myTickets' |
| | | ? undefined |
| | | : filters.status !== '' |
| | | ? Number(filters.status) |
| | | : currentTab?.value, |
| | | event_name: filters.keyword || undefined, |
| | | dept_id: filters.department || undefined, |
| | | start_date: filters.dateRange?.[0] |
| | | ? formatDate(filters.dateRange[0]) |
| | | : undefined, |
| | | end_date: filters.dateRange?.[1] |
| | | ? formatDate(filters.dateRange[1]).replace('00:00:00', '23:59:59') |
| | | : undefined, |
| | | current: Number(page.currentPage), |
| | | size: Number(page.pageSize), |
| | | ai_type: filters.algorithm || undefined, |
| | | is_draft: currentTab?.name === 'myTickets' ? 1 : undefined, |
| | | user_id: currentTab?.name === 'myTickets' ? userInfo.value.user_id : undefined, |
| | | is_review: filters.isReview === '' ? undefined : filters.isReview, |
| | | source: 1, |
| | | status_list: statusListVal |
| | | } |
| | | |
| | | const response = await getList(params) |
| | | if (!response?.data?.data?.records) { |
| | | throw new Error('接口返回数据格式不正确') |
| | | } |
| | | const { total, records } = response.data.data |
| | | let filteredRecords = records |
| | | tableData.value = filteredRecords.map(item => { |
| | | const longitude = Number(item.longitude) || 0 |
| | | const latitude = Number(item.latitude) || 0 |
| | | return { |
| | | id: item.id, |
| | | orderNumber: item.event_num, |
| | | orderName: item.event_name, |
| | | department: departments.value.find(d => d.value === item.dept_id)?.label || item.dept_name, |
| | | startTime: item.job_create_time || '/', |
| | | aiType: item.ai_types, |
| | | content: item.content, |
| | | type: item.work_order_type_dict_key, |
| | | keyData: !isNaN(longitude) && !isNaN(latitude) |
| | | ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` |
| | | : '未知位置', |
| | | address: item.address, |
| | | creator: item.event_num?.slice(0, 2) === 'AI' ? '智飞agent' : item.create_user, |
| | | handler: item.update_user || '未分配', |
| | | status: Number(item.status || 0), |
| | | photo_url: item.photo_url || '', |
| | | video_url: item.video_url || '', |
| | | location: !isNaN(longitude) && !isNaN(latitude) ? [longitude, latitude] : null, |
| | | processing_details: item.processing_details || '', |
| | | update_photo_url: item.update_photo_url || '', |
| | | work_type: item.work_type !== undefined ? Number(item.work_type) : 0, |
| | | job_name: item.job_name || '', |
| | | job_create_time: item.job_create_time || '', |
| | | isReview: item.is_review, |
| | | handle_user_id:item.handle_user_id |
| | | |
| | | } |
| | | }) |
| | | |
| | | page.total = total || 0 |
| | | if (isShowInfo.value) { |
| | | handleViewDetail(firstRowData.value) |
| | | isShowInfo.value = false |
| | | } |
| | | await fetchTabCounts() |
| | | } catch (error) { |
| | | console.error('获取数据失败:', error) |
| | | tableData.value = [] |
| | | page.total = 0 |
| | | } finally { |
| | | loading.value = false |
| | | isFetching.value = false |
| | | } |
| | | } |
| | | function handleTypeChange(typeValue) { |
| | | if (!typeValue) { |
| | | algorithms2.value = [] |
| | | return |
| | | } |
| | | |
| | | const matchedCategory = allAlgorithms.value.find(category => category.dict_key === typeValue) |
| | | |
| | | if (!matchedCategory || !matchedCategory.algorithms || matchedCategory.algorithms.length === 0) { |
| | | algorithms2.value = [] |
| | | return |
| | | } |
| | | |
| | | algorithms2.value = matchedCategory.algorithms.map(algo => ({ |
| | | label: algo.dict_value, |
| | | value: algo.dict_key, |
| | |
| | | dict_value: algo.dict_value, |
| | | })) |
| | | } |
| | | |
| | | function formatDate(date) { |
| | | if (!date) return undefined |
| | | const d = new Date(date) |
| | |
| | | } |
| | | return statusTextMap[status] || '未知状态' |
| | | } |
| | | |
| | | function getStatusTagType(status) { |
| | | if (status === -1 || status === '-1') return '' |
| | | const colorMap = { |
| | |
| | | } |
| | | return colorMap[String(status)] || '' |
| | | } |
| | | |
| | | // 获取tab数据 |
| | | async function fetchTabCounts() { |
| | | const statusListVal = statusList.value; |
| | | const params = { |
| | |
| | | try { |
| | | const response = await getstatusCount(params) |
| | | const statusCount = response.data.data || {} |
| | | // console.log('数据',statusCount); |
| | | const totalCount = Object.values(statusCount).reduce((sum, count) => sum + (count || 0), 0) |
| | | tabs.value.forEach(tab => { |
| | | if (tab.name === 'all') { |
| | |
| | | |
| | | function handleTabChange(tab) { |
| | | activeTab.value = tab.props?.name || tab.name |
| | | |
| | | fetchTabCounts() |
| | | handleReset() |
| | | page.currentPage = 1 |
| | |
| | | return false |
| | | } |
| | | } |
| | | |
| | | // 详情 |
| | | async function handleViewDetail(row) { |
| | | currentIndex.value = tableData.value.findIndex(item => item.id === row.id) |
| | | workType.value = row.work_type !== undefined ? Number(row.work_type) : 0 |
| | |
| | | showQR: false, |
| | | latAndLon: _.round(detailData.location[0], 6) + ',' + _.round(detailData.location[1], 6), |
| | | } |
| | | console.log('currentDetail.value',currentDetail.value); |
| | | // console.log('currentDetail.value',currentDetail.value); |
| | | |
| | | detailVisible.value = true |
| | | handleTypeChange(currentDetail.value.type) |
| | |
| | | if (isFetching.value) return |
| | | fetchTableData() |
| | | } |
| | | |
| | | // 导出数据 |
| | | async function exportData() { |
| | | try { |
| | | loading.value = true |
| | |
| | | ] |
| | | |
| | | export_json_to_excel(headers, exportData, '工单数据') |
| | | console.log('数据导出成功') |
| | | } catch (error) { |
| | | console.error('导出失败:', error) |
| | | } finally { |
| | |
| | | // 删除方法 |
| | | function handleDelete(row) { |
| | | |
| | | console.log('删除工单:', row) |
| | | } |
| | | |
| | | // 添加选择变化处理方法 |
| | |
| | | |
| | | const response = await flowEvent(data) |
| | | if (response.data.code === 0) { |
| | | console.log('工单审核通过') |
| | | |
| | | |
| | | const newSelections = [...selections.value] |
| | | newSelections.splice(currentImageIndex.value - 1, 1) |
| | |
| | | |
| | | const response = await flowEvent(data) |
| | | if (response.data.code === 0) { |
| | | console.log('工单审核不通过') |
| | | |
| | | |
| | | const newSelections = [...selections.value] |
| | | newSelections.splice(currentImageIndex.value - 1, 1) |
| | |
| | | elink.click() |
| | | document.body.removeChild(elink) |
| | | }) |
| | | console.log('数据导出成功') |
| | | |
| | | } |
| | | |
| | | // 生命周期 |