无人机管理后台前端(已迁走)
shuishen
2025-04-14 6c6f73db4de17e6e6607a0fbecd1af0a079f5e91
地图组件调整,增加添加线方法
调用地图组件调整,更换方法加载
2 files modified
3893 ■■■■ changed files
src/components/map-container/mapContainer.vue 177 ●●●●● patch | view | raw | blame | history
src/views/tickets/ticket.vue 3716 ●●●● patch | view | raw | blame | history
src/components/map-container/mapContainer.vue
@@ -2,8 +2,8 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:07:51
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2025-04-10 13:04:30
 * @FilePath: \drone-web-manage\src\components\map-container\MapContainer.vue
 * @LastEditTime: 2025-04-14 23:09:33
 * @FilePath: \drone-web-manage\src\components\map-container\mapContainer.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by shuishen, All Rights Reserved. 
@@ -20,10 +20,13 @@
<script setup>
import { nextTick, onMounted, onUnmounted } from 'vue'
import { read } from 'xlsx'
window.$viewer = null
window.$Cesium = null
let pointLayer = null
let polylineLayer = null
const { VITE_APP_BASE } = import.meta.env
// import * as Cesium from 'cesium'
// import 'cesium/Build/Cesium/Widgets/widgets.css'
@@ -36,80 +39,122 @@
})
watch(
    [() => isViewerReady.value, () => rowDetails],
    ([ready, detail]) => {
        if (ready && detail?.location) {
            const [lng, lat] = detail.location
            if (!lng || !lat) return
            let [newLng, newLat] = DC.CoordTransform.GCJ02ToWGS84(lng, lat)
            window.$viewer?.zoomToPosition(new DC.Position(
                newLng,
                newLat,
                1000,
                0,
                -90,
                0
            ), () => {
            })
            let point = new DC.Point(new DC.Position(newLng, newLat))
            pointLayer.addOverlay(point)
        }
    },
    { deep: true, immediate: true } // 初始化时立即执行
)
function initMap () {
async function initMap () {
    if (window.$viewer) return
    nextTick(() => {
        DC.ready({
            // Cesium: Cesium,
            baseUrl: `${VITE_APP_BASE}/libs/dc-sdk/resources/`,
        }).then(() => {
            window.$Cesium = DC.getLib('Cesium')
            // 天地图地图
            const imageryProvider_standZh = new window.$Cesium.UrlTemplateImageryProvider({
                url: 'https://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c',
                subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                maximumLevel: 18,
                credit: 'stand_zj',
            })
            const imageryProvider_stand = new window.$Cesium.UrlTemplateImageryProvider({
                url: 'https://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c',
                subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                // format: 'image/jpeg',
                // show: true,
                maximumLevel: 18,
                credit: 'stand_tc',
            })
            window.$viewer = new DC.Viewer('viewer-container')
            window.$viewer.locationBar.enable = false
            window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_stand)
            window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_standZh)
            pointLayer = new DC.VectorLayer('pointLayer')
            window.$viewer?.addLayer(pointLayer)
            isViewerReady.value = true
        })
    await DC.ready({
        // Cesium: Cesium,
        baseUrl: `${VITE_APP_BASE}/libs/dc-sdk/resources/`,
    })
    window.$Cesium = DC.getLib('Cesium')
    // 天地图地图
    const imageryProvider_standZh = new window.$Cesium.UrlTemplateImageryProvider({
        url: 'https://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c',
        subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
        maximumLevel: 18,
        credit: 'stand_zj',
    })
    const imageryProvider_stand = new window.$Cesium.UrlTemplateImageryProvider({
        url: 'https://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=e45274b0235bb913eceb393aabbf9c9c',
        subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
        // format: 'image/jpeg',
        // show: true,
        maximumLevel: 18,
        credit: 'stand_tc',
    })
    window.$viewer = new DC.Viewer('viewer-container')
    window.$viewer.locationBar.enable = false
    window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_stand)
    window.$viewer?.imageryLayers.addImageryProvider(imageryProvider_standZh)
    pointLayer = new DC.VectorLayer('pointLayer')
    window.$viewer?.addLayer(pointLayer)
    polylineLayer = new DC.VectorLayer('polylineLayer')
    window.$viewer?.addLayer(polylineLayer)
    isViewerReady.value = true
}
/**
 * 初始化标注添加
 * @param type 类型
 * @param data 数据
 */
const initAddEntity = (type, data) => {
    watch(() => isViewerReady.value,
        (ready) => {
            if (ready) {
                type === 'point' ? addPoint(data) : addPolyline(data)
            }
        },
        { deep: true, immediate: true } // 初始化时立即执行
    )
}
/**
 * 添加点标注
 * @param data 数据  数据格式 [lng, lat]
 */
function addPoint (data) {
    const [lng, lat] = data
    if (!lng || !lat) return
    let [newLng, newLat] = DC.CoordTransform.GCJ02ToWGS84(lng, lat)
    let point = new DC.Point(new DC.Position(newLng, newLat))
    pointLayer.addOverlay(point)
    window.$viewer?.zoomTo(pointLayer)
}
/**
 * 添加点标注
 * @param data 数据  数据格式 [[lng, lat], [lng, lat], [lng, lat]]
 */
function addPolyline (data) {
    if (data.length === 0) return
    const positionStr = data.map(item => {
        const [lng, lat] = item
        let [newLng, newLat] = DC.CoordTransform.GCJ02ToWGS84(lng, lat)
        return `${newLng}, ${newLat}`
    }).join(';')
    let polyline = new DC.Polyline(positionStr)
    polyline.setStyle({
        width: 20,
        material: new DC.PolylineLightingTrailMaterialProperty({
            color: DC.Color.BLUE,
            speed: 5.0
        }),
        clampToGround: true
    })
    polylineLayer.addOverlay(polyline)
    window.$viewer?.zoomTo(polylineLayer)
}
onMounted(() => {
    initMap()
    nextTick(() => {
        initMap()
    })
})
onUnmounted(() => {
    if (pointLayer) {
        window.$viewer?.removeLayer(pointLayer)
        pointLayer = null
    }
    if (polylineLayer) {
        window.$viewer?.removeLayer(polylineLayer)
        polylineLayer = null
    }
    window.$viewer?.entities.removeAll()
@@ -130,6 +175,10 @@
        cesiumContainer.remove() // 移除与地图相关的DOM元素
    }
})
defineExpose({
    initAddEntity
})
</script>
<script>
src/views/tickets/ticket.vue
@@ -1,197 +1,200 @@
<template>
  <basic-container>
    <el-tabs v-model="activeTab" @tab-click="handleTabChange">
      <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
        <div class="tab-content">
          <!-- 查询条件筛选栏 -->
          <div class="filter-bar">
            <el-input v-model="filters.keyword" placeholder="请输入关键字" class="filter-item" size="small" clearable
              @keyup.enter="handleSearch" />
            <el-select v-model="filters.department" placeholder="请选择所属单位" class="filter-item" size="small" clearable>
              <el-option v-for="item in departments" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
            <el-select v-model="filters.type" placeholder="请选择工单类型" class="filter-item" size="small" clearable>
              <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
            <el-date-picker v-model="filters.dateRange" type="daterange" class="filter-item" size="small"
              range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
            </el-date-picker>
            <el-select v-model="filters.status" placeholder="请选择状态" class="filter-item" size="small" clearable>
              <el-option v-for="item in statuses" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
            <el-select v-model="filters.algorithm" placeholder="请选择关联算法" class="filter-item" size="small" clearable>
              <el-option v-for="item in algorithms" :key="item.dict_key" :label="item.dict_value"
                :value="item.dict_key" />
            </el-select>
            <el-button type="primary" icon="el-icon-search" size="small" @click="handleSearch">查询</el-button>
            <el-button icon="el-icon-refresh" size="small" @click="handleReset">重置</el-button>
          </div>
    <basic-container>
        <el-tabs v-model="activeTab" @tab-click="handleTabChange">
            <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
                <div class="tab-content">
                    <!-- 查询条件筛选栏 -->
                    <div class="filter-bar">
                        <el-input v-model="filters.keyword" placeholder="请输入关键字" class="filter-item" size="small"
                            clearable @keyup.enter="handleSearch" />
                        <el-select v-model="filters.department" placeholder="请选择所属单位" class="filter-item" size="small"
                            clearable>
                            <el-option v-for="item in departments" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                        <el-select v-model="filters.type" placeholder="请选择工单类型" class="filter-item" size="small"
                            clearable>
                            <el-option v-for="item in types" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                        <el-date-picker v-model="filters.dateRange" type="daterange" class="filter-item" size="small"
                            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                        </el-date-picker>
                        <el-select v-model="filters.status" placeholder="请选择状态" class="filter-item" size="small"
                            clearable>
                            <el-option v-for="item in statuses" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                        <el-select v-model="filters.algorithm" placeholder="请选择关联算法" class="filter-item" size="small"
                            clearable>
                            <el-option v-for="item in algorithms" :key="item.dict_key" :label="item.dict_value"
                                :value="item.dict_key" />
                        </el-select>
                        <el-button type="primary" icon="el-icon-search" size="small"
                            @click="handleSearch">查询</el-button>
                        <el-button icon="el-icon-refresh" size="small" @click="handleReset">重置</el-button>
                    </div>
          <!-- 表格部分 -->
          <avue-crud v-model="tableData" :option="option" :data="tableData" v-model:page="page"
            @size-change="sizeChange" @current-change="handleCurrentChange" :table-loading="loading">
            <template #menu-left>
              <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建工单</el-button>
              <el-button type="success" plain icon="el-icon-download" @click="exportData">导出</el-button>
            </template>
            <template #menu="{ row }">
              <template v-if="row.status === -1">
                <el-button type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
                <el-button type="text" icon="el-icon-delete" class="danger-button"
                  @click="handleDelete(row)">删除</el-button>
              </template>
              <template v-else>
                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
              </template>
            </template>
            <template #status="{ row }">
              <el-tag :type="getStatusTagType(row.status)">{{ mapStatus(row.status) }}</el-tag>
            </template>
            <template #keyData="{ row }">
              <span>{{ row.address }}</span>
            </template>
          </avue-crud>
        </div>
      </el-tab-pane>
    </el-tabs>
    <!-- 新建工单对话框 -->
    <el-dialog v-model="dialogVisible" title="新建工单" width="70%" :close-on-click-modal="false" @close="resetForm">
      <el-form :model="form" :rules="rules" ref="form" label-width="90px" class="create-ticket-form">
        <div class="form-section">
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="工单名称" prop="name">
                <el-input v-model="form.name" placeholder="请输入工单名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工单类型" prop="type">
                <el-select v-model="form.type" placeholder="请选择工单类型" class="full-width">
                  <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="所属部门" prop="department">
                <el-select v-model="form.department" placeholder="请选择所属部门" @change="handleDepartmentChange" class="full-width">
                  <el-option v-for="dept in departments" :key="dept.value" :label="dept.label" :value="dept.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="处理人员" prop="handler">
                <el-select v-model="form.handler" placeholder="请选择处理人员" :disabled="!form.department" class="full-width">
                  <el-option v-for="user in availableHandlers" :key="user.id" :label="user.name" :value="user.id" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="关联算法" prop="algorithm">
                <el-select v-model="form.algorithm" placeholder="请选择关联算法" class="full-width">
                  <el-option v-for="item in algorithms" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="选择位置" prop="location">
                <div class="location-wrapper">
                  <avue-input-map v-model="form.location" :params="mapParams" @change="handleLocationChange" type="button">
                    <el-button type="primary" plain class="map-button">
                      <i class="el-icon-map-location"></i> 地图选点
                    </el-button>
                  </avue-input-map>
                  <div v-if="form.location?.length >= 2" class="location-text">{{ form.address || '获取地址中...' }}</div>
                    <!-- 表格部分 -->
                    <avue-crud v-model="tableData" :option="option" :data="tableData" v-model:page="page"
                        @size-change="sizeChange" @current-change="handleCurrentChange" :table-loading="loading">
                        <template #menu-left>
                            <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建工单</el-button>
                            <el-button type="success" plain icon="el-icon-download" @click="exportData">导出</el-button>
                        </template>
                        <template #menu="{ row }">
                            <template v-if="row.status === -1">
                                <el-button type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
                                <el-button type="text" icon="el-icon-delete" class="danger-button"
                                    @click="handleDelete(row)">删除</el-button>
                            </template>
                            <template v-else>
                                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
                            </template>
                        </template>
                        <template #status="{ row }">
                            <el-tag :type="getStatusTagType(row.status)">{{ mapStatus(row.status) }}</el-tag>
                        </template>
                        <template #keyData="{ row }">
                            <span>{{ row.address }}</span>
                        </template>
                    </avue-crud>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
            </el-tab-pane>
        </el-tabs>
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="工单内容" prop="content">
                <el-input type="textarea" v-model="form.content" :rows="4" placeholder="请输入工单内容描述"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="附件图片" prop="photos" class="upload-wrapper">
                <el-upload ref="upload"
                  :action="'#'"
                  :auto-upload="false"
                  list-type="picture-card"
                  :on-change="handleFileChange"
                  :on-remove="handleUploadRemove"
                  :before-upload="beforeUpload"
                  :file-list="form.photos"
                  :limit="1"
                  accept="image/*"
                  class="uploader"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
                <div class="upload-tip">支持jpg/png格式图片,单张不超过5MB</div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="danger" @click="submitForm">确认提交</el-button>
          <el-button type="infoprimary" plain @click="saveDraft">存草稿</el-button>
          <el-button @click="dialogVisible = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
        <!-- 新建工单对话框 -->
        <el-dialog v-model="dialogVisible" title="新建工单" width="70%" :close-on-click-modal="false" @close="resetForm">
            <el-form :model="form" :rules="rules" ref="form" label-width="90px" class="create-ticket-form">
                <div class="form-section">
                    <el-row :gutter="16">
                        <el-col :span="12">
                            <el-form-item label="工单名称" prop="name">
                                <el-input v-model="form.name" placeholder="请输入工单名称"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="工单类型" prop="type">
                                <el-select v-model="form.type" placeholder="请选择工单类型" class="full-width">
                                    <el-option v-for="item in types" :key="item.value" :label="item.label"
                                        :value="item.value" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
    <!-- 工单详情对话框 -->
    <el-dialog v-model="detailVisible" title="工单详情" width="80%" append-to-body>
      <div class="detail-container">
        <!-- 工单状态流程 -->
        <div class="custom-steps-container">
          <!-- 标题行 -->
          <div class="steps-titles">
            <div
              class="step-title"
              :class="{ active: true }"
            >
              发起任务
            </div>
            <div
              v-for="(status, index) in fixedStatuses"
              :key="index"
              :class="{ active: Number(currentDetail.status) >= Number(status) }"
              class="step-title"
            >
              {{ mapStatus(status) }}
            </div>
          </div>
                    <el-row :gutter="16">
                        <el-col :span="12">
                            <el-form-item label="所属部门" prop="department">
                                <el-select v-model="form.department" placeholder="请选择所属部门"
                                    @change="handleDepartmentChange" class="full-width">
                                    <el-option v-for="dept in departments" :key="dept.value" :label="dept.label"
                                        :value="dept.value" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="处理人员" prop="handler">
                                <el-select v-model="form.handler" placeholder="请选择处理人员" :disabled="!form.department"
                                    class="full-width">
                                    <el-option v-for="user in availableHandlers" :key="user.id" :label="user.name"
                                        :value="user.id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
          <!-- Element Steps 组件 -->
          <el-steps :active="getActiveStep()" align-center class="custom-steps">
            <el-step>
              <template #description>
                <span class="step-description">
                  {{ currentDetail.creator || '未知' }}
                </span>
                <div class="step-description">
                  {{ currentDetail.startTime || '未知时间' }}
                    <el-row :gutter="16">
                        <el-col :span="12">
                            <el-form-item label="关联算法" prop="algorithm">
                                <el-select v-model="form.algorithm" placeholder="请选择关联算法" class="full-width">
                                    <el-option v-for="item in algorithms" :key="item.value" :label="item.label"
                                        :value="item.value" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="选择位置" prop="location">
                                <div class="location-wrapper">
                                    <avue-input-map v-model="form.location" :params="mapParams"
                                        @change="handleLocationChange" type="button">
                                        <el-button type="primary" plain class="map-button">
                                            <i class="el-icon-map-location"></i> 地图选点
                                        </el-button>
                                    </avue-input-map>
                                    <div v-if="form.location?.length >= 2" class="location-text">{{ form.address ||
                                        '获取地址中...'
                                        }}</div>
                                </div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="16">
                        <el-col :span="12">
                            <el-form-item label="工单内容" prop="content">
                                <el-input type="textarea" v-model="form.content" :rows="4"
                                    placeholder="请输入工单内容描述"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="附件图片" prop="photos" class="upload-wrapper">
                                <el-upload ref="upload" :action="'#'" :auto-upload="false" list-type="picture-card"
                                    :on-change="handleFileChange" :on-remove="handleUploadRemove"
                                    :before-upload="beforeUpload" :file-list="form.photos" :limit="1" accept="image/*"
                                    class="uploader">
                                    <i class="el-icon-plus"></i>
                                </el-upload>
                                <div class="upload-tip">支持jpg/png格式图片,单张不超过5MB</div>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
              </template>
            </el-step>
            <el-step v-for="(status, index) in fixedStatuses" :key="index">
              <template #description>
                <span class="step-description">
                  {{ getStepHandler(status) }}
                </span>
                <div class="step-description" v-if="getStepTime(status)">
                 <span style="         position: absolute;
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="danger" @click="submitForm">确认提交</el-button>
                    <el-button type="infoprimary" plain @click="saveDraft">存草稿</el-button>
                    <el-button @click="dialogVisible = false">取 消</el-button>
                </div>
            </template>
        </el-dialog>
        <!-- 工单详情对话框 -->
        <el-dialog v-model="detailVisible" title="工单详情" width="80%" append-to-body>
            <div class="detail-container">
                <!-- 工单状态流程 -->
                <div class="custom-steps-container">
                    <!-- 标题行 -->
                    <div class="steps-titles">
                        <div class="step-title" :class="{ active: true }">
                            发起任务
                        </div>
                        <div v-for="(status, index) in fixedStatuses" :key="index"
                            :class="{ active: Number(currentDetail.status) >= Number(status) }" class="step-title">
                            {{ mapStatus(status) }}
                        </div>
                    </div>
                    <!-- Element Steps 组件 -->
                    <el-steps :active="getActiveStep()" align-center class="custom-steps">
                        <el-step>
                            <template #description>
                                <span class="step-description">
                                    {{ currentDetail.creator || '未知' }}
                                </span>
                                <div class="step-description">
                                    {{ currentDetail.startTime || '未知时间' }}
                                </div>
                            </template>
                        </el-step>
                        <el-step v-for="(status, index) in fixedStatuses" :key="index">
                            <template #description>
                                <span class="step-description">
                                    {{ getStepHandler(status) }}
                                </span>
                                <div class="step-description" v-if="getStepTime(status)">
                                    <span style="         position: absolute;
          right: 80%;  
          top: 50%;
          transform: translateY(-50%);
@@ -199,1857 +202,1870 @@
          margin-left: 4px;  
          color: #666;
          font-size: 10px;">耗时: {{ getStepTime(status) }}</span>
                                </div>
                                <div class="step-description">
                                    {{ getStepCreateTime(status) }}
                                </div>
                            </template>
                        </el-step>
                    </el-steps>
                </div>
                <div class="step-description" >
                  {{ getStepCreateTime(status) }}
                <!-- 基本信息表格 -->
                <el-table :data="formattedDetailFields" border style="width: 100%; margin-bottom: 20px;">
                    <el-table-column prop="label1" label="基本信息" width="150" />
                    <el-table-column>
                        <template #default="{ row }">
                            <!-- 修复工单名称可编辑 -->
                            <template v-if="currentDetail.status === 0 && row.label1 === '工单名称'">
                                <el-input v-model="currentDetail.orderName" placeholder="请输入工单名称" />
                            </template>
                            <!-- 修复任务接收单位为下拉框 -->
                            <template v-else-if="currentDetail.status === 0 && row.label1 === '任务接收单位'">
                                <el-select v-model="currentDetail.department" placeholder="请选择任务接收单位"
                                    @change="handleDepartmentChange">
                                    <el-option v-for="item in departments" :key="item.value" :label="item.label"
                                        :value="item.value" />
                                </el-select>
                            </template>
                            <template v-else>{{ row.value1 }}</template>
                        </template>
                    </el-table-column>
                    <el-table-column prop="label2" label="基本信息" width="150" />
                    <el-table-column>
                        <template #default="{ row }">
                            <!-- 修复工单内容可编辑 -->
                            <template v-if="currentDetail.status === 0 && row.label2 === '工单内容'">
                                <el-input type="textarea" v-model="currentDetail.content" placeholder="请输入工单内容" />
                            </template>
                            <!-- 修复工单类型为下拉框 -->
                            <template v-else-if="currentDetail.status === 0 && row.label2 === '工单类型'">
                                <el-select v-model="currentDetail.type" placeholder="请选择工单类型">
                                    <el-option v-for="item in types" :key="item.value" :label="item.label"
                                        :value="item.value" />
                                </el-select>
                            </template>
                            <!-- 修复任务处理人为下拉框 -->
                            <template v-else-if="currentDetail.status === 0 && row.label2 === '任务处理人'">
                                <el-select v-model="currentDetail.handler" placeholder="请选择任务处理人"
                                    @change="handleHandlerChange">
                                    <el-option v-for="user in departmentUsers[currentDetail.department] || []"
                                        :key="user.id" :label="user.name" :value="user.id" />
                                </el-select>
                            </template>
                            <template v-else>{{ row.value2 }}</template>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 事件处理详情 -->
                <div v-if="[3, 4, 5].includes(currentDetail.status)" class="form-section">
                    <div class="section-title">事件处理详情</div>
                    <!-- 处理中状态显示输入框 -->
                    <template v-if="currentDetail.status === 3">
                        <el-input type="textarea" v-model="currentDetail.processingDetail" placeholder="请输入事件处理详情"
                            :rows="4" style="width: 100%; margin-bottom: 10px;" />
                    </template>
                    <!-- 已完成和已完结状态显示只读文本 -->
                    <template v-else>
                        <div class="readonly-processing-detail">
                            {{ currentDetail.processingDetail }}
                        </div>
                    </template>
                </div>
              </template>
            </el-step>
          </el-steps>
        </div>
        <!-- 基本信息表格 -->
        <el-table :data="formattedDetailFields" border style="width: 100%; margin-bottom: 20px;">
          <el-table-column prop="label1" label="基本信息" width="150" />
          <el-table-column>
            <template #default="{ row }">
              <!-- 修复工单名称可编辑 -->
              <template v-if="currentDetail.status === 0 && row.label1 === '工单名称'">
                <el-input v-model="currentDetail.orderName" placeholder="请输入工单名称" />
              </template>
              <!-- 修复任务接收单位为下拉框 -->
              <template v-else-if="currentDetail.status === 0 && row.label1 === '任务接收单位'">
                <el-select v-model="currentDetail.department" placeholder="请选择任务接收单位" @change="handleDepartmentChange">
                  <el-option v-for="item in departments" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </template>
              <template v-else>{{ row.value1 }}</template>
            </template>
          </el-table-column>
          <el-table-column prop="label2" label="基本信息" width="150" />
          <el-table-column>
            <template #default="{ row }">
              <!-- 修复工单内容可编辑 -->
              <template v-if="currentDetail.status === 0 && row.label2 === '工单内容'">
                <el-input type="textarea" v-model="currentDetail.content" placeholder="请输入工单内容" />
              </template>
              <!-- 修复工单类型为下拉框 -->
              <template v-else-if="currentDetail.status === 0 && row.label2 === '工单类型'">
                <el-select v-model="currentDetail.type" placeholder="请选择工单类型">
                  <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
                </el-select>
              </template>
              <!-- 修复任务处理人为下拉框 -->
              <template v-else-if="currentDetail.status === 0 && row.label2 === '任务处理人'">
                <el-select v-model="currentDetail.handler" placeholder="请选择任务处理人" @change="handleHandlerChange">
                  <el-option v-for="user in departmentUsers[currentDetail.department] || []" :key="user.id"
                    :label="user.name" :value="user.id" />
                </el-select>
              </template>
              <template v-else>{{ row.value2 }}</template>
            </template>
          </el-table-column>
        </el-table>
                <!-- 上传图片 -->
                <div v-if="[3, 4].includes(currentDetail.status)" class="form-section">
                    <div class="section-title">上传图片</div>
                    <el-upload ref="upload" :action="'#'" :auto-upload="false" list-type="picture-card"
                        :on-change="handleFileChange" :on-remove="handleUploadRemove" :before-upload="beforeUpload"
                        :file-list="[]" accept="image/*">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <div class="el-upload__tip">支持 jpg/png 格式图片,最多 5 张,单张不超过 5MB</div>
                </div>
        <!-- 事件处理详情 -->
        <div v-if="[3, 4, 5].includes(currentDetail.status)" class="form-section">
          <div class="section-title">事件处理详情</div>
          <!-- 处理中状态显示输入框 -->
          <template v-if="currentDetail.status === 3">
            <el-input type="textarea" v-model="currentDetail.processingDetail" placeholder="请输入事件处理详情" :rows="4"
              style="width: 100%; margin-bottom: 10px;" />
          </template>
          <!-- 已完成和已完结状态显示只读文本 -->
          <template v-else>
            <div class="readonly-processing-detail">
              {{ currentDetail.processingDetail }}
                <!-- 图片和地图部分 -->
                <div class="media-section">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <div class="media-box">
                                <div class="media-title">事件图片/事件视频</div>
                                <div class="media-content">
                                    <el-image v-if="currentDetail.mediaUrl" :src="currentDetail.mediaUrl"
                                        :preview-src-list="[currentDetail.mediaUrl]" fit="cover"
                                        style="width: 100%; height: 300px;">
                                        <template #placeholder>
                                            <div class="image-placeholder">
                                                <i class="el-icon-picture-outline"></i>
                                                <span>加载中...</span>
                                            </div>
                                        </template>
                                        <template #error>
                                            <div class="image-error">
                                                <i class="el-icon-picture-outline"></i>
                                                <span>加载失败</span>
                                            </div>
                                        </template>
                                    </el-image>
                                    <div v-else class="no-media">暂无图片/视频</div>
                                </div>
                            </div>
                        </el-col>
                        <el-col :span="12">
                            <div class="media-box">
                                <!-- 根据状态显示不同的标题和内容 -->
                                <template v-if="currentDetail.status === 5">
                                    <div class="media-title">工单处理图片</div>
                                    <div class="media-content">
                                        <el-image v-if="currentDetail.updatePhotoUrl"
                                            :src="currentDetail.updatePhotoUrl"
                                            :preview-src-list="[currentDetail.updatePhotoUrl]" fit="cover"
                                            style="width: 100%; height: 300px;">
                                            <template #placeholder>
                                                <div class="image-placeholder">
                                                    <i class="el-icon-picture-outline"></i>
                                                    <span>加载中...</span>
                                                </div>
                                            </template>
                                            <template #error>
                                                <div class="image-error">
                                                    <i class="el-icon-picture-outline"></i>
                                                    <span>加载失败</span>
                                                </div>
                                            </template>
                                        </el-image>
                                        <div v-else class="no-media">暂无处理图片</div>
                                    </div>
                                </template>
                                <template v-else>
                                    <div class="media-title">地图标记事件点</div>
                                    <div class="media-content">
                                        <div id="map-container"
                                            style="width: 100%; height: 300px; background: #f5f5f5;">
                                            <map-container v-if='detailVisible' ref="MapContainer"></map-container>
                                        </div>
                                    </div>
                                </template>
                            </div>
                        </el-col>
                    </el-row>
                </div>
                <!-- 操作按钮 -->
                <div class="dialog-footer">
                    <template v-if="currentDetail.status === 2">
                        <!-- 待审核 -->
                        <el-button type="primary" @click="approveTicket">通过</el-button>
                        <el-button type="danger" @click="rejectTicket">不通过</el-button>
                        <el-button @click="detailVisible = false">取消</el-button>
                    </template>
                    <template v-else-if="currentDetail.status === 0">
                        <el-button type="primary" @click="approveAndDispatch">通过并派发</el-button>
                        <el-button type="danger" @click="rejectTicket">不通过</el-button>
                        <el-button @click="detailVisible = false">取消</el-button>
                    </template>
                    <template v-else-if="currentDetail.status === 3">
                        <!-- 处理中 -->
                        <el-button type="primary" @click="completeTicket">完成工单</el-button>
                        <el-button @click="detailVisible = false">取消</el-button>
                    </template>
                    <template v-else-if="currentDetail.status === 4">
                        <!-- 已完成 -->
                        <el-button type="primary" @click="finalizeTicket">完结工单</el-button>
                        <el-button @click="detailVisible = false">取消</el-button>
                    </template>
                    <template v-else-if="currentDetail.status === 5">
                        <!-- 已完结 -->
                        <el-button @click="detailVisible = false">关闭</el-button>
                    </template>
                </div>
            </div>
          </template>
        </div>
        </el-dialog>
        <!-- 上传图片 -->
        <div v-if="[3, 4].includes(currentDetail.status)" class="form-section">
          <div class="section-title">上传图片</div>
          <el-upload ref="upload" :action="'#'" :auto-upload="false" list-type="picture-card"
            :on-change="handleFileChange" :on-remove="handleUploadRemove" :before-upload="beforeUpload" :file-list="[]"
            accept="image/*">
            <i class="el-icon-plus"></i>
          </el-upload>
          <div class="el-upload__tip">支持 jpg/png 格式图片,最多 5 张,单张不超过 5MB</div>
        </div>
        <!-- 图片和地图部分 -->
        <div class="media-section">
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="media-box">
                <div class="media-title">事件图片/事件视频</div>
                <div class="media-content">
                  <el-image v-if="currentDetail.mediaUrl" :src="currentDetail.mediaUrl"
                    :preview-src-list="[currentDetail.mediaUrl]" fit="cover" style="width: 100%; height: 300px;">
                    <template #placeholder>
                      <div class="image-placeholder">
                        <i class="el-icon-picture-outline"></i>
                        <span>加载中...</span>
                      </div>
                    </template>
                    <template #error>
                      <div class="image-error">
                        <i class="el-icon-picture-outline"></i>
                        <span>加载失败</span>
                      </div>
                    </template>
                  </el-image>
                  <div v-else class="no-media">暂无图片/视频</div>
                </div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="media-box">
                <!-- 根据状态显示不同的标题和内容 -->
                <template v-if="currentDetail.status === 5">
                  <div class="media-title">工单处理图片</div>
                  <div class="media-content">
                    <el-image v-if="currentDetail.updatePhotoUrl" :src="currentDetail.updatePhotoUrl"
                      :preview-src-list="[currentDetail.updatePhotoUrl]" fit="cover"
                      style="width: 100%; height: 300px;">
                      <template #placeholder>
                        <div class="image-placeholder">
                          <i class="el-icon-picture-outline"></i>
                          <span>加载中...</span>
                        </div>
                      </template>
                      <template #error>
                        <div class="image-error">
                          <i class="el-icon-picture-outline"></i>
                          <span>加载失败</span>
                        </div>
                      </template>
                    </el-image>
                    <div v-else class="no-media">暂无处理图片</div>
                  </div>
                </template>
                <template v-else>
                  <div class="media-title">地图标记事件点</div>
                  <div class="media-content">
                    <div id="map-container" style="width: 100%; height: 300px; background: #f5f5f5;">
                      <map-container v-if='detailVisible' :rowDetails="currentDetail"></map-container>
                    </div>
                  </div>
                </template>
              </div>
            </el-col>
          </el-row>
        </div>
        <!-- 操作按钮 -->
        <div class="dialog-footer">
          <template v-if="currentDetail.status === 2">
            <!-- 待审核 -->
            <el-button type="primary" @click="approveTicket">通过</el-button>
            <el-button type="danger" @click="rejectTicket">不通过</el-button>
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 0">
            <el-button type="primary" @click="approveAndDispatch">通过并派发</el-button>
            <el-button type="danger" @click="rejectTicket">不通过</el-button>
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 3">
            <!-- 处理中 -->
            <el-button type="primary" @click="completeTicket">完成工单</el-button>
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 4">
            <!-- 已完成 -->
            <el-button type="primary" @click="finalizeTicket">完结工单</el-button>
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 5">
            <!-- 已完结 -->
            <el-button @click="detailVisible = false">关闭</el-button>
          </template>
        </div>
      </div>
    </el-dialog>
    <!-- 派发工单对话框 -->
    <el-dialog v-model="dispatchDialogVisible" title="派发工单" width="40%" :close-on-click-modal="false">
      <el-form :model="dispatchForm" :rules="dispatchRules" ref="dispatchForm" label-width="100px">
        <el-form-item label="选择部门" prop="department">
          <el-select v-model="dispatchForm.department" placeholder="请选择部门" @change="handleDispatchDepartmentChange">
            <el-option v-for="dept in departments" :key="dept.value" :label="dept.label" :value="dept.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="选择处理人" prop="handler">
          <el-select v-model="dispatchForm.handler" placeholder="请选择处理人" :disabled="!dispatchForm.department">
            <el-option v-for="user in availableDispatchHandlers" :key="user.id" :label="user.name" :value="user.id" />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dispatchDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitDispatch">确认派发</el-button>
      </template>
    </el-dialog>
  </basic-container>
        <!-- 派发工单对话框 -->
        <el-dialog v-model="dispatchDialogVisible" title="派发工单" width="40%" :close-on-click-modal="false">
            <el-form :model="dispatchForm" :rules="dispatchRules" ref="dispatchForm" label-width="100px">
                <el-form-item label="选择部门" prop="department">
                    <el-select v-model="dispatchForm.department" placeholder="请选择部门"
                        @change="handleDispatchDepartmentChange">
                        <el-option v-for="dept in departments" :key="dept.value" :label="dept.label"
                            :value="dept.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="选择处理人" prop="handler">
                    <el-select v-model="dispatchForm.handler" placeholder="请选择处理人" :disabled="!dispatchForm.department">
                        <el-option v-for="user in availableDispatchHandlers" :key="user.id" :label="user.name"
                            :value="user.id" />
                    </el-select>
                </el-form-item>
            </el-form>
            <template #footer>
                <el-button @click="dispatchDialogVisible = false">取消</el-button>
                <el-button type="primary" @click="submitDispatch">确认派发</el-button>
            </template>
        </el-dialog>
    </basic-container>
</template>
<script>
import { getList, createTicket, getTicketInfo, flowEvent, getstatusCount, getStepInfo } from '@/api/tickets/ticket';
import { export_json_to_excel } from '@/utils/exportExcel';
import { getList, createTicket, getTicketInfo, flowEvent, getstatusCount, getStepInfo } from '@/api/tickets/ticket'
import { export_json_to_excel } from '@/utils/exportExcel'
import geoJson from '@/assets/geoJson.json'
import { mapGetters } from 'vuex'
import { getAdcodeObj } from '@/utils/disposeData'
export default {
  name: "TicketPage",
  data() {
    return {
      activeTab: "all",
      tabs: [
        { label: "全部工单", name: "all", value: null, count: 0 },
        { label: "待审核", name: "pending", value: 2, count: 0 },
        { label: "待处理", name: "processing", value: 0, count: 0 },
        { label: "处理中", name: "inProgress", value: 3, count: 0 },
        { label: "已完成", name: "completed", value: 4, count: 0 },
        { label: "已完结", name: "closed", value: 5, count: 0 },
        { label: "我发起的", name: "myTickets", value: null, count: 0 },
      ],
      filters: {
        keyword: "",
        department: "",
        type: "",
        dateRange: [],
        status: "",
        algorithm: "", // 新增算法筛选字段
      },
      departments: [],
      types: [],
      handlers: [
        { label: "处理人A", value: "handlerA" },
        { label: "处理人B", value: "handlerB" },
      ],
    name: "TicketPage",
    data () {
        return {
            activeTab: "all",
            tabs: [
                { label: "全部工单", name: "all", value: null, count: 0 },
                { label: "待审核", name: "pending", value: 2, count: 0 },
                { label: "待处理", name: "processing", value: 0, count: 0 },
                { label: "处理中", name: "inProgress", value: 3, count: 0 },
                { label: "已完成", name: "completed", value: 4, count: 0 },
                { label: "已完结", name: "closed", value: 5, count: 0 },
                { label: "我发起的", name: "myTickets", value: null, count: 0 },
            ],
            filters: {
                keyword: "",
                department: "",
                type: "",
                dateRange: [],
                status: "",
                algorithm: "", // 新增算法筛选字段
            },
            departments: [],
            types: [],
            handlers: [
                { label: "处理人A", value: "handlerA" },
                { label: "处理人B", value: "handlerB" },
            ],
      algorithms: [],
      statuses: [
        { label: "待审核", value: "2" },
        { label: "待处理", value: "0" },
        { label: "处理中", value: "3" },
        { label: "已完成", value: "4" },
        { label: "已完结", value: "5" },
      ],
      tableData: [],
      option: {
        border: true,
        stripe: true,
        menuWidth: 150,
        searchMenuSpan: 6,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        menu: true,
        page: true,
        column: [
          { label: "序号", prop: "id", width: 70 },
          { label: "工单编号", prop: "orderNumber", width: 150 },
          { label: "工单名称", prop: "orderName", width: 150 },
          { label: "所属单位", prop: "department", width: 100 },
          { label: "发起时间", prop: "startTime", width: 160 },
          { label: "关联算法", prop: "aiType", width: 165 },
          { label: "工单类型", prop: "type", width: 108 },
          {
            label: "工单内容",
            prop: "content",
            slot: true,
            width: 250,
            overHidden: true
          },
          { label: "创建人", prop: "creator", width: 100 },
          { label: "处理人", prop: "handler", width: 100 },
          { label: "工单状态", prop: "status", slot: true, width: 100 }
        ],
      },
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        pageSizes: [10, 20, 30]
      },
      dialogVisible: false,
      detailVisible: false,
      currentDetail: {},
      form: {
        name: '',
        type: '',
        department: '',
        handler: '',
        algorithm: '',
        location: [],  // 将存储为[经度, 纬度, 地址]格式
        address: '',
        content: '',
        photos: [],
        content: '', // 新增字段,用于存储后端返回的 content
      },
      rules: {
        name: [{ required: true, message: '请输入工单名称', trigger: 'blur' }],
        type: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
        department: [{ required: true, message: '请选择所属部门', trigger: 'change' }],
        handler: [{ required: true, message: '请选择处理人员', trigger: 'change' }],
        content: [{ required: true, message: '请输入工单内容', trigger: 'blur' }],
        algorithm: [{ required: true, message: '请选择关联算法', trigger: 'change' }],
        location: [{
          validator: (rule, value, callback) => {
            if (!value || value.length < 2) {
              callback(new Error('请选择位置信息'));
            } else {
              callback();
            algorithms: [],
            statuses: [
                { label: "待审核", value: "2" },
                { label: "待处理", value: "0" },
                { label: "处理中", value: "3" },
                { label: "已完成", value: "4" },
                { label: "已完结", value: "5" },
            ],
            tableData: [],
            option: {
                border: true,
                stripe: true,
                menuWidth: 150,
                searchMenuSpan: 6,
                viewBtn: false,
                editBtn: false,
                delBtn: false,
                addBtn: false,
                menu: true,
                page: true,
                column: [
                    { label: "序号", prop: "id", width: 70 },
                    { label: "工单编号", prop: "orderNumber", width: 150 },
                    { label: "工单名称", prop: "orderName", width: 150 },
                    { label: "所属单位", prop: "department", width: 100 },
                    { label: "发起时间", prop: "startTime", width: 160 },
                    { label: "关联算法", prop: "aiType", width: 165 },
                    { label: "工单类型", prop: "type", width: 108 },
                    {
                        label: "工单内容",
                        prop: "content",
                        slot: true,
                        width: 250,
                        overHidden: true
                    },
                    { label: "创建人", prop: "creator", width: 100 },
                    { label: "处理人", prop: "handler", width: 100 },
                    { label: "工单状态", prop: "status", slot: true, width: 100 }
                ],
            },
            page: {
                total: 0,
                currentPage: 1,
                pageSize: 10,
                pageSizes: [10, 20, 30]
            },
            dialogVisible: false,
            detailVisible: false,
            currentDetail: {},
            form: {
                name: '',
                type: '',
                department: '',
                handler: '',
                algorithm: '',
                location: [],  // 将存储为[经度, 纬度, 地址]格式
                address: '',
                content: '',
                photos: [],
                content: '', // 新增字段,用于存储后端返回的 content
            },
            rules: {
                name: [{ required: true, message: '请输入工单名称', trigger: 'blur' }],
                type: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
                department: [{ required: true, message: '请选择所属部门', trigger: 'change' }],
                handler: [{ required: true, message: '请选择处理人员', trigger: 'change' }],
                content: [{ required: true, message: '请输入工单内容', trigger: 'blur' }],
                algorithm: [{ required: true, message: '请选择关联算法', trigger: 'change' }],
                location: [{
                    validator: (rule, value, callback) => {
                        if (!value || value.length < 2) {
                            callback(new Error('请选择位置信息'))
                        } else {
                            callback()
                        }
                    },
                    trigger: 'change'
                }],
                photos: [{
                    validator: (rule, value, callback) => {
                        if (!this.form.photos || this.form.photos.length === 0) {
                            callback(new Error('请上传工单图片'))
                        } else {
                            callback()
                        }
                    },
                    trigger: 'change'
                }],
            },
            departmentUsers: {},
            loading: false,
            globalCounts: {},
            mapLoaded: false,
            isFetching: false,
            mapParams: {
                zoom: 15,
                center: null, // 初始设为 null,等待动态设置
            },
            dispatchDepartment: '', // 新增:派发部门
            dispatchHandler: '', // 新增:派发处理人
            dispatchDialogVisible: false, // 新增:派发对话框可见性
            dispatchForm: {
                department: '',
                handler: '',
            }, // 新增:派发表单数据
            dispatchRules: {
                department: [{ required: true, message: '请选择部门', trigger: 'change' }],
                handler: [{ required: true, message: '请选择处理人', trigger: 'change' }],
            }, // 新增:派发表单验证规则
            stepInfos: [], // 新增:存储步骤信息
            fixedStatuses: ["2", "0", "3", "4", "5"], // 固定的五个状态
            userNameToIdMap: {}, // 新增用户名到ID的映射
        }
    },
    created () {
        this.loadAMapScripts()
        this.fetchDropdownData()
        this.fetchTabCounts() // 新增:初始化时获取 tab 数据
    },
    mounted () {
        this.fetchTableData()
    },
    computed: {
        availableHandlers () {
            return this.form.department ? (this.departmentUsers[this.form.department] || []) : []
        },
        availableDispatchHandlers () {
            return this.dispatchForm.department ? (this.departmentUsers[this.dispatchForm.department] || []) : []
        },
        detailTableData () {
            return [
                {
                    label: "工单名称",
                    value: this.currentDetail.orderName,
                    editable: this.currentDetail.status === 0,
                    type: "input",
                },
                {
                    label: "关键任务",
                    value: this.currentDetail.keyData,
                    editable: false,
                },
                {
                    label: "任务发起人",
                    value: this.currentDetail.creator,
                    editable: false,
                },
                {
                    label: "当前状态",
                    value: this.mapStatus(this.currentDetail.status),
                    editable: false,
                },
                {
                    label: "事件地址",
                    value: this.currentDetail.address,
                    editable: false,
                },
                {
                    label: "工单类型",
                    value: this.currentDetail.type,
                    editable: this.currentDetail.status === 0,
                    type: "select",
                    options: this.types,
                },
                {
                    label: "关联算法",
                    value: this.currentDetail.aiType,
                    editable: false,
                },
                {
                    label: "任务接收单位",
                    value: this.currentDetail.department,
                    editable: false,
                },
                {
                    label: "发起任务时间",
                    value: this.currentDetail.startTime,
                    editable: false,
                },
                {
                    label: "工单内容",
                    value: this.currentDetail.content,
                    editable: this.currentDetail.status === 0,
                    type: "textarea",
                },
            ]
        },
        detailFields () {
            return [
                { label: "工单名称", value: this.currentDetail.orderName, editable: this.currentDetail.status === 0, type: "input" },
                { label: "关键任务", value: this.currentDetail.keyData, editable: false },
                { label: "任务发起人", value: this.currentDetail.creator, editable: false },
                { label: "当前状态", value: this.mapStatus(this.currentDetail.status), editable: false },
                { label: "事件地址", value: this.currentDetail.address, editable: false },
                { label: "工单类型", value: this.currentDetail.type, editable: this.currentDetail.status === 0, type: "select", options: this.types },
                { label: "关联算法", value: this.currentDetail.aiType, editable: false },
                { label: "任务接收单位", value: this.currentDetail.department, editable: false },
                { label: "发起任务时间", value: this.currentDetail.startTime, editable: false },
                { label: "工单内容", value: this.currentDetail.content, editable: this.currentDetail.status === 0, type: "textarea" },
            ]
        },
        formattedDetailFields () {
            const fields = [
                { label: "工单名称", value: this.currentDetail.orderName },
                { label: "工单类型", value: this.currentDetail.type },
                { label: "任务处理人", value: this.currentDetail.handler || '未分配' }, // 显示处理人
                { label: "任务发起人", value: this.currentDetail.creator },
                { label: "当前状态", value: this.mapStatus(this.currentDetail.status) },
                { label: "事件地址", value: this.currentDetail.address }, // 包含经纬度信息
                { label: "关联算法", value: this.currentDetail.aiType },
                { label: "任务接收单位", value: this.currentDetail.department },
                { label: "发起任务时间", value: this.currentDetail.startTime },
                { label: "工单内容", value: this.currentDetail.content },
            ]
            // 将字段分成两列
            const formattedFields = []
            for (let i = 0; i < fields.length; i += 2) {
                formattedFields.push({
                    label1: fields[i]?.label || "",
                    value1: fields[i]?.value || "暂无数据",
                    label2: fields[i + 1]?.label || "",
                    value2: fields[i + 1]?.value || "暂无数据",
                })
            }
          },
          trigger: 'change'
        }],
        photos: [{
          validator: (rule, value, callback) => {
            if (!this.form.photos || this.form.photos.length === 0) {
              callback(new Error('请上传工单图片'));
            } else {
              callback();
            return formattedFields
        },
        ...mapGetters(['userInfo']),
    },
    methods: {
        async loadAMapScripts () {
            try {
                const areaCode = this.userInfo.detail.areaCode
                const subAreaCode = areaCode ? areaCode.substring(0, 6) : ''
                const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode)
                console.log('区域代码:', subAreaCode)
                // 直接从返回对象中获取正确的路径
                const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center
                console.log('获取到的中心点:', center)
                if (Array.isArray(center) && center.length === 2) {
                    this.mapParams.center = center
                    console.log('成功设置地图中心点:', center)
                } else {
                    // 如果找不到中心点,尝试使用 bbox 的中心点
                    const bbox = adcodeObj?.payload?.bbox
                    if (Array.isArray(bbox) && bbox.length === 4) {
                        const centerX = (bbox[0] + bbox[2]) / 2
                        const centerY = (bbox[1] + bbox[3]) / 2
                        this.mapParams.center = [centerX, centerY]
                        console.log('使用 bbox 计算的中心点:', this.mapParams.center)
                    } else {
                        console.warn('无法获取有效的中心点坐标,使用默认值')
                        this.mapParams.center = [115.861365, 28.621311]
                    }
                }
                this.mapLoaded = true
            } catch (error) {
                console.error('地图脚本加载失败:', error)
                this.$message.error('地图加载失败,请检查网络或API Key配置')
            }
          },
          trigger: 'change'
        }],
      },
      departmentUsers: {},
      loading: false,
      globalCounts: {},
      mapLoaded: false,
      isFetching: false,
      mapParams: {
        zoom: 15,
        center: null, // 初始设为 null,等待动态设置
      },
      dispatchDepartment: '', // 新增:派发部门
      dispatchHandler: '', // 新增:派发处理人
      dispatchDialogVisible: false, // 新增:派发对话框可见性
      dispatchForm: {
        department: '',
        handler: '',
      }, // 新增:派发表单数据
      dispatchRules: {
        department: [{ required: true, message: '请选择部门', trigger: 'change' }],
        handler: [{ required: true, message: '请选择处理人', trigger: 'change' }],
      }, // 新增:派发表单验证规则
      stepInfos: [], // 新增:存储步骤信息
      fixedStatuses: ["2", "0", "3", "4", "5"], // 固定的五个状态
      userNameToIdMap: {}, // 新增用户名到ID的映射
    };
  },
  created() {
    this.loadAMapScripts();
    this.fetchDropdownData();
    this.fetchTabCounts(); // 新增:初始化时获取 tab 数据
  },
  mounted() {
    this.fetchTableData();
  },
  computed: {
    availableHandlers() {
      return this.form.department ? (this.departmentUsers[this.form.department] || []) : [];
    },
    availableDispatchHandlers() {
      return this.dispatchForm.department ? (this.departmentUsers[this.dispatchForm.department] || []) : [];
    },
    detailTableData() {
      return [
        {
          label: "工单名称",
          value: this.currentDetail.orderName,
          editable: this.currentDetail.status === 0,
          type: "input",
        },
        {
          label: "关键任务",
          value: this.currentDetail.keyData,
          editable: false,
        },
        {
          label: "任务发起人",
          value: this.currentDetail.creator,
          editable: false,
        },
        {
          label: "当前状态",
          value: this.mapStatus(this.currentDetail.status),
          editable: false,
        },
        {
          label: "事件地址",
          value: this.currentDetail.address,
          editable: false,
        },
        {
          label: "工单类型",
          value: this.currentDetail.type,
          editable: this.currentDetail.status === 0,
          type: "select",
          options: this.types,
        },
        {
          label: "关联算法",
          value: this.currentDetail.aiType,
          editable: false,
        },
        {
          label: "任务接收单位",
          value: this.currentDetail.department,
          editable: false,
        },
        {
          label: "发起任务时间",
          value: this.currentDetail.startTime,
          editable: false,
        },
        {
          label: "工单内容",
          value: this.currentDetail.content,
          editable: this.currentDetail.status === 0,
          type: "textarea",
        },
      ];
    },
    detailFields() {
      return [
        { label: "工单名称", value: this.currentDetail.orderName, editable: this.currentDetail.status === 0, type: "input" },
        { label: "关键任务", value: this.currentDetail.keyData, editable: false },
        { label: "任务发起人", value: this.currentDetail.creator, editable: false },
        { label: "当前状态", value: this.mapStatus(this.currentDetail.status), editable: false },
        { label: "事件地址", value: this.currentDetail.address, editable: false },
        { label: "工单类型", value: this.currentDetail.type, editable: this.currentDetail.status === 0, type: "select", options: this.types },
        { label: "关联算法", value: this.currentDetail.aiType, editable: false },
        { label: "任务接收单位", value: this.currentDetail.department, editable: false },
        { label: "发起任务时间", value: this.currentDetail.startTime, editable: false },
        { label: "工单内容", value: this.currentDetail.content, editable: this.currentDetail.status === 0, type: "textarea" },
      ];
    },
    formattedDetailFields() {
      const fields = [
        { label: "工单名称", value: this.currentDetail.orderName },
        { label: "工单类型", value: this.currentDetail.type },
        { label: "任务处理人", value: this.currentDetail.handler || '未分配' }, // 显示处理人
        { label: "任务发起人", value: this.currentDetail.creator },
        { label: "当前状态", value: this.mapStatus(this.currentDetail.status) },
        { label: "事件地址", value: this.currentDetail.address }, // 包含经纬度信息
        { label: "关联算法", value: this.currentDetail.aiType },
        { label: "任务接收单位", value: this.currentDetail.department },
        { label: "发起任务时间", value: this.currentDetail.startTime },
        { label: "工单内容", value: this.currentDetail.content },
      ];
      // 将字段分成两列
      const formattedFields = [];
      for (let i = 0; i < fields.length; i += 2) {
        formattedFields.push({
          label1: fields[i]?.label || "",
          value1: fields[i]?.value || "暂无数据",
          label2: fields[i + 1]?.label || "",
          value2: fields[i + 1]?.value || "暂无数据",
        });
      }
      return formattedFields;
    },
    ...mapGetters(['userInfo']),
  },
  methods: {
    async loadAMapScripts() {
      try {
        const areaCode = this.userInfo.detail.areaCode;
        const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
        const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode);
        async fetchDropdownData () {
            try {
                const response = await getTicketInfo()
                const { dept_data, event_type, ai_type } = response.data.data
        console.log('区域代码:', subAreaCode);
                this.departments = dept_data.map(item => ({
                    label: item.dept_name,
                    value: item.id,
                }))
        // 直接从返回对象中获取正确的路径
        const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center;
                this.departmentUsers = dept_data.reduce((acc, dept) => {
                    acc[dept.id] = dept.user_data || []
                    return acc
                }, {})
        console.log('获取到的中心点:', center);
                this.types = Object.entries(event_type).map(([key, value]) => ({
                    label: value,
                    value: key,
                }))
        if (Array.isArray(center) && center.length === 2) {
          this.mapParams.center = center;
          console.log('成功设置地图中心点:', center);
        } else {
          // 如果找不到中心点,尝试使用 bbox 的中心点
          const bbox = adcodeObj?.payload?.bbox;
          if (Array.isArray(bbox) && bbox.length === 4) {
            const centerX = (bbox[0] + bbox[2]) / 2;
            const centerY = (bbox[1] + bbox[3]) / 2;
            this.mapParams.center = [centerX, centerY];
            console.log('使用 bbox 计算的中心点:', this.mapParams.center);
          } else {
            console.warn('无法获取有效的中心点坐标,使用默认值');
            this.mapParams.center = [115.861365, 28.621311];
          }
        }
                // 确保算法数据的映射一致
                this.algorithms = ai_type.map(item => ({
                    label: item.dict_value, // 修改为 label
                    value: item.dict_key,  // 修改为 value
                }))
        this.mapLoaded = true;
      } catch (error) {
        console.error('地图脚本加载失败:', error);
        this.$message.error('地图加载失败,请检查网络或API Key配置');
      }
    },
                // 构建用户ID和名称的映射关系
                this.userNameToIdMap = {}
                dept_data.forEach(dept => {
                    (dept.user_data || []).forEach(user => {
                        this.userNameToIdMap[user.name] = user.id
                    })
                })
    async fetchDropdownData() {
      try {
        const response = await getTicketInfo();
        const { dept_data, event_type, ai_type } = response.data.data;
        this.departments = dept_data.map(item => ({
          label: item.dept_name,
          value: item.id,
        }));
        this.departmentUsers = dept_data.reduce((acc, dept) => {
          acc[dept.id] = dept.user_data || [];
          return acc;
        }, {});
        this.types = Object.entries(event_type).map(([key, value]) => ({
          label: value,
          value: key,
        }));
        // 确保算法数据的映射一致
        this.algorithms = ai_type.map(item => ({
          label: item.dict_value, // 修改为 label
          value: item.dict_key,  // 修改为 value
        }));
        // 构建用户ID和名称的映射关系
        this.userNameToIdMap = {};
        dept_data.forEach(dept => {
          (dept.user_data || []).forEach(user => {
            this.userNameToIdMap[user.name] = user.id;
          });
        });
        console.log('用户名到ID的映射:', this.userNameToIdMap);
      } catch (error) {
        console.error('获取下拉框数据失败:', error);
        this.$message.error('加载下拉框数据失败');
      }
    },
    async fetchTableData() {
      if (this.isFetching) return;
      this.isFetching = true;
      this.loading = true;
      try {
        const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
        const params = {
          word_order_type: this.filters.type || undefined,
          status: currentTab?.name === 'myTickets' ? undefined :
            this.filters.status !== "" ? Number(this.filters.status) :
              currentTab?.value,
          event_name: this.filters.keyword || undefined,
          dept_id: this.filters.department || undefined,
          start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
          end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]).replace("00:00:00", "23:59:59") : undefined,
          current: Number(this.page.currentPage),  // 使用当前页码
          size: Number(this.page.pageSize),       // 使用每页条数
          ai_type: this.filters.algorithm || undefined, // 添加算法参数
        };
        const response = await getList(params);
        if (!response?.data?.data?.records) {
          throw new Error('接口返回数据格式不正确');
        }
        const { total, records } = response.data.data;
        let filteredRecords = records;
        // 如果是"我发起的"tab,过滤数据
        if (currentTab?.name === 'myTickets') {
          filteredRecords = records.filter(item =>
            String(item.create_user_id) === String(item.user_id)
          );
        }
        this.tableData = filteredRecords.map(item => {
          const longitude = Number(item.longitude) || 0;
          const latitude = Number(item.latitude) || 0;
          return {
            id: item.id,
            orderNumber: item.event_num, // 修改这里:优先使用 event_num
            orderName: item.event_name,
            department: this.departments.find(d => d.value === item.dept_id)?.label || item.dept_name,
            startTime: item.create_time,
            aiType: item.ai_types,
            content: item.content, // 将后端返回的 content 映射为 content
            type: this.types.find(t => t.value === item.event_dict_key)?.label,
            keyData: (!isNaN(longitude) && !isNaN(latitude))
              ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
              : '未知位置',
            address: item.address,
            creator: item.create_user,
            handler: item.update_user || '未分配',
            status: Number(item.status || 0),
            // 保存原始字段
            photo_url: item.photo_url || '',  // 保存原始 photo_url
            video_url: item.video_url || '',  // 保存原始 video_url
            location: (!isNaN(longitude) && !isNaN(latitude)) ? [longitude, latitude] : null,
            processing_details: item.processing_details || '', // 添加处理详情字段
            video_url: item.video_url || '',  // 保存原始 video_url
            location: (!isNaN(longitude) && !isNaN(latitude)) ? [longitude, latitude] : null,
            processing_details: item.processing_details || '', // 添加处理详情字段
            update_photo_url: item.update_photo_url || '', // 添加处理图片字段
          };
        });
        // 更新总数显示
        if (currentTab?.name === 'myTickets') {
          this.page.total = filteredRecords.length;
        } else {
          this.page.total = total || 0;
        }
        await this.fetchTabCounts();
      } catch (error) {
        console.error("获取数据失败:", error);
        this.$message.error(error.message || "获取数据失败");
        this.tableData = [];
        this.page.total = 0;
      } finally {
        this.loading = false;
        this.isFetching = false;
      }
    },
    async submitForm() {
      try {
        // 提交时需要完整验证
        await this.$refs.form.validate();
        // 验证位置信息
        if (!this.form.location || this.form.location.length < 2) {
          this.$message.warning('请在地图上选择位置');
          return;
        }
        // 验证图片上传
        if (!this.form.photos || this.form.photos.length === 0) {
          this.$message.warning('请上传工单图片');
          return;
        }
        const submitData = {
          eventName: this.form.name,
          content: this.form.content,
          workType: "1",
          longitude: String(this.form.location[0]),
          latitude: String(this.form.location[1]),
          address: this.form.address,
          eventDictKey: this.form.type,
          aiType: this.form.algorithm,
          updateUser: this.form.handler,
          createDept: this.form.department,
          isDraft: 0
        };
        if (this.form.id) {
          submitData.id = this.form.id;
        }
        // 获取文件对象
        const file = this.form.photos[0].raw;
        if (!file) {
          this.$message.warning('图片文件无效,请重新上传');
          return;
        }
        const response = await createTicket(submitData, file);
        if (response.data.code === 0) {
          this.$message.success('工单创建成功');
          this.dialogVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '创建失败');
        }
      } catch (error) {
        console.error('提交失败:', error);
        if (error.message.includes('验证未通过')) {
          this.$message.warning('请填写完整的工单信息');
        } else {
          this.$message.error(error.message || '工单创建失败,请稍后重试');
        }
      }
    },
    async saveDraft() {
      try {
        const submitData = {
          id: this.form.id,
          eventName: this.form.name || undefined,
          content: this.form.content || undefined,
          workType: "1",
          longitude: this.form.location?.[0] ? String(this.form.location[0]) : undefined,
          latitude: this.form.location?.[1] ? String(this.form.location[1]) : undefined,
          address: this.form.address || undefined,
          eventDictKey: this.form.type || undefined,
          aiType: this.form.algorithm || undefined,
          updateUser: this.form.handler || undefined,
          createDept: this.form.department || undefined,
          isDraft: 1
        };
        // 草稿时也至少需要工单名称
        if (!submitData.eventName) {
          this.$message.warning('请至少输入工单名称');
          return;
        }
        // 过滤掉所有 undefined 的字段
        Object.keys(submitData).forEach(key =>
          submitData[key] === undefined && delete submitData[key]
        );
        let file = null;
        if (this.form.photos && this.form.photos.length > 0) {
          file = this.form.photos[0].raw;
        }
        const response = await createTicket(submitData, file);
        if (response.data.code === 0) {
          this.$message.success('草稿保存成功');
          this.dialogVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '保存失败');
        }
      } catch (error) {
        console.error('保存草稿失败:', error);
        this.$message.error(error.message || '保存草稿失败,请稍后重试');
      }
    },
    async handleLocationChange(val) {
      console.log('地图选址返回值:', val);
      // 处理 Proxy 对象的值
      let locationValue = val.value;
      if (locationValue && locationValue.length >= 3) {
        // 确保我们获取到实际的数组值
        this.form.location = [locationValue[0], locationValue[1]];
        this.form.address = locationValue[2] || '';
        console.log('解析后的位置信息:', {
          经度: this.form.location[0],
          纬度: this.form.location[1],
          地址: this.form.address
        });
      } else {
        console.warn('无效的位置数据');
        this.form.location = [];
        this.form.address = '';
      }
    },
    formatDate(date) {
      if (!date) return undefined;
      const d = new Date(date);
      return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} 00:00:00`;
    },
    mapStatus(status) {
      const statusTextMap = {
        "-1": "草稿",  // 添加草稿状态
        "2": "待审核",
        "0": "待处理",
        "3": "处理中",
        "4": "已完成",
        "5": "已完结"
      };
      return statusTextMap[status] || "未知状态";
    },
    getStatusTagType(status) {
      const statusMap = {
        "-1": "info",    // 为草稿状态添加样式
        "2": "warning",
        "0": "danger",
        "3": "primary",
        "4": "success",
        "5": "danger",
      };
      return statusMap[status] || "info";
    },
    async fetchTabCounts() {
      try {
        const response = await getstatusCount();
        const { statusCount, totalCount, userCount } = response.data.data;
        console.log('接口返回的状态统计数据:', { statusCount, totalCount, userCount });
        this.tabs.forEach(tab => {
          if (tab.name === 'all') {
            tab.count = totalCount || 0; // 总工单数
          } else if (tab.name === 'myTickets') {
            tab.count = userCount || 0; // 我发起的工单数
          } else {
            tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
          }
        });
        console.log('更新后的 tabs 数据:', this.tabs);
      } catch (error) {
        console.error('获取 tab 数据失败:', error);
        this.$message.error('获取 tab 数据失败');
      }
    },
    handleTabChange(tab) {
      this.activeTab = tab.props?.name || tab.name;
      this.handleReset();
      this.page.currentPage = 1;
      this.fetchTableData();
      this.fetchTabCounts(); // 切换 tab 时重新获取数据
    },
    handleSearch() {
      this.page.currentPage = 1;
      this.fetchTableData();
    },
    handleReset() {
      this.filters = {
        keyword: "",
        department: "",
        type: "",
        dateRange: [],
        status: "",
        algorithm: "", // 重置时清空算法筛选
      };
      this.page.currentPage = 1;
      this.fetchTableData();
    },
    async handleCurrentChange(val) {
      console.log('当前页变更:', val);
      // 先更新页码
      this.page.currentPage = val;
      // 等待 DOM 更新后再请求数据
      await this.$nextTick();
      await this.fetchTableData();
    },
    async sizeChange(val) {
      console.log('每页条数变更:', val);
      this.page.pageSize = val;
      this.page.currentPage = 1; // 重置到第一页
      await this.$nextTick();
      await this.fetchTableData();
    },
    handleAdd() {
      this.dialogVisible = true;
    },
    resetForm() {
      this.form = {
        name: '',
        type: '',
        department: '',
        handler: '',
        algorithm: '',
        location: [],  // 将存储为[经度, 纬度, 地址]格式
        address: '',
        content: '',
        photos: [],
        content: '', // 新增字段,用于存储后端返回的 content
      };
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
    },
    formatLocation(location) {
      if (!Array.isArray(location)) {
        return '未知位置';
      }
      return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`;
    },
    async handleViewDetail(row) {
      console.log('查看详情数据:', row);
      // 重置上传组件的文件列表
      this.$nextTick(() => {
        if (this.$refs.upload) {
          if (Array.isArray(this.$refs.upload)) {
            this.$refs.upload.forEach(upload => upload.clearFiles());
          } else {
            this.$refs.upload.clearFiles();
          }
        }
      });
      const detailData = {
        ...row,
        processingDetail: row.processing_details || '',
        mediaUrl: row.photo_url || row.video_url || '',
        updatePhotoUrl: row.update_photo_url || '',
        photos: [],
      };
      try {
        const stepResponse = await getStepInfo(row.orderNumber);
        console.log('接口返回的步骤信息:', stepResponse.data.data);
        const steps = stepResponse.data.data || [];
        // 根据接口返回的步骤信息补充处理人和时间
        this.stepInfos = this.fixedStatuses.map(status => {
          const step = steps.find(s => String(s.status) === String(status));
          return {
            status,
            name: step ? step.name : '',
            time: step ? step.time : null,
            create_time: step ? step.create_time : null,
          };
        });
        console.log('处理后的步骤信息:', this.stepInfos);
        this.currentDetail.status = row.status; // 使用行数据中的状态
      } catch (error) {
        console.error('获取步骤信息失败:', error);
        // 如果接口调用失败,使用默认的固定状态
        this.stepInfos = this.fixedStatuses.map(status => ({
          status,
          name: status === row.status ? row.handler || '未分配' : '未处理',
          time: status === row.status ? row.startTime || '未知时间' : null,
        }));
      }
      this.currentDetail = detailData;
      console.log('当前详情数据:', this.currentDetail);
      this.detailVisible = true;
    },
    getStepHandler(status) {
      const step = this.stepInfos.find(step => step.status === status);
      return step ? step.name : '';
    },
    getStepTime(status) {
      const step = this.stepInfos.find(step => step.status === status);
      return step ? step.time : null;
    },
    getStepCreateTime(status) {
      const step = this.stepInfos.find(step => step.status === status);
      console.log('getStepCreateTime:', step);
      return step ? step.create_time : null;
    },
    getActiveStep() {
      // 由于新增了发起任务步骤,需要调整步骤索引
      const index = this.fixedStatuses.indexOf(String(this.currentDetail.status));
      return index !== -1 ? index + 1 : 1; // 加1是因为多了发起任务这一步
    },
    openMap() {
      const areaCode = this.userInfo.detail.areaCode;
      const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
      const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode);
      console.log('区域代码:', subAreaCode);
      console.log('getAdcodeObj返回值:', {
        完整对象: adcodeObj,
        级别: adcodeObj?.level,
        名称: adcodeObj?.name,
        代码: adcodeObj?.adcode,
        中心点: adcodeObj?.center,
        边界: adcodeObj?.polyline,
      });
      this.$message.info("地图选址功能暂未实现");
    },
    handlePreview(file) {
      this.$message.info(`预览图片:${file.name}`);
    },
    handleRemove(file) {
      this.$message.info(`移除图片:${file.name}`);
    },
    refreshChange() {
      if (this.isFetching) return;
      this.fetchTableData();
    },
    onLoad() {
      if (this.isFetching) return;
      this.fetchTableData();
    },
    async exportData() {
      try {
        this.loading = true;
        const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
        // 使用与查询列表相同的参数构造逻辑
        const params = {
          word_order_type: this.filters.type || undefined,
          status: currentTab?.name === 'myTickets' ? undefined :
            this.filters.status !== "" ? Number(this.filters.status) :
              currentTab?.value, // 使用当前tab的状态值
          keyword: this.filters.keyword || undefined,
          dept_id: this.filters.department || undefined,
          start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
          end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]) : undefined,
          current: 1,
          size: 10
        };
        const response = await getList(params);
        if (!response?.data?.data?.records) {
          throw new Error('接口返回数据格式不正确');
        }
        const { records } = response.data.data;
        // 使用与查询列表相同的过滤逻辑
        let filteredRecords = records;
        if (currentTab?.name === 'myTickets') {
          filteredRecords = records.filter(item =>
            String(item.create_user_id) === String(item.user_id)
          );
        }
        const exportData = filteredRecords.map(item => {
          const longitude = Number(item.longitude) || 0;
          const latitude = Number(item.latitude) || 0;
          return {
            工单编号: item.event_num || '',
            工单名称: item.event_name || '',
            所属单位: item.dept_name || '',
            发起时间: item.create_time || '',
            关联算法: item.ai_types || '',
            工单内容: item.address || '',
            工单类型: this.types.find(t => t.value === item.event_dict_key)?.label || '',
            经纬度: (!isNaN(longitude) && !isNaN(latitude)) ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` : '',
            创建人: item.create_user || '',
            处理人: item.update_user || '',
            工单状态: this.mapStatus(Number(item.status || 0))
          };
        });
        if (exportData.length === 0) {
          this.$message.warning('没有数据可供导出');
          return;
        }
        const headers = [
          '工单编号',
          '工单名称',
          '所属单位',
          '发起时间',
          '关联算法',
          '工单内容',
          '工单类型',
          '经纬度',
          '创建人',
          '处理人',
          '工单状态'
        ];
        export_json_to_excel(headers, exportData, '工单数据');
        this.$message.success('数据导出成功');
      } catch (error) {
        console.error('导出失败:', error);
        this.$message.error(error.message || '导出失败,请稍后重试');
      } finally {
        this.loading = false;
      }
    },
    handleDepartmentChange(deptId) {
      this.form.handler = '';
    },
    handleDispatchDepartmentChange(deptId) {
      this.dispatchForm.handler = ''; // 清空处理人选择
    },
    // 文件改变时的钩子
    handleFileChange(file, fileList) {
      this.form.photos = fileList;
      this.currentDetail.photos = fileList;
    },
    // 文件移除时的钩子
    handleUploadRemove(file, fileList) {
      this.form.photos = fileList;
      this.currentDetail.photos = fileList;
    },
    // 上传前的验证
    beforeUpload(file) {
      const isImage = file.type.includes('image');
      const isLt5M = file.size / 1024 / 1024 < 5;
      if (!isImage) {
        this.$message.error('只能上传图片文件!');
        return false;
      }
      if (!isLt5M) {
        this.$message.error('图片大小不能超过5MB!');
        return false;
      }
      return true;
    },
    async approveTicket() {
      try {
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          isPass: 0, // 0 表示通过
          eventNum: this.currentDetail.orderNumber,
          eventName: this.currentDetail.orderName, // 工单名称
          eventType: this.currentDetail.type, // 工单类型
          departmentId: this.dispatchForm.department, // 派发部门 ID
          handlerId: this.dispatchForm.handler, // 处理人 ID
        };
        const file = this.currentDetail.file || null; // 如果没有文件,则为 null
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('工单已通过');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('通过操作失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      }
    },
    async rejectTicket() {
      try {
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          isPass: 1, // 1 表示不通过
        };
        const response = await flowEvent(data);
        if (response.data.code === 0) {
          this.$message.success('工单未通过');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('不通过操作失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      }
    },
    async submitProcessing() {
      if (this.currentDetail.status !== 3) {
        this.$message.warning('只有处理中状态的工单可以提交处理详情');
        return;
      }
      try {
        const data = {
          id: this.currentDetail.id, // 当前工单 ID
          status: this.currentDetail.status, // 当前工单状态
          processing_details: this.currentDetail.processingDetail, // 事件处理详情
        };
        // 如果有图片,添加 file 参数
        const file = this.currentDetail.photos?.[0]?.raw || null;
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('处理详情提交成功');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '提交失败');
        }
      } catch (error) {
        console.error('处理详情提交失败:', error);
        this.$message.error(error.message || '提交失败,请稍后重试');
      }
    },
    markAsCompleted() {
      this.$message.success("工单已标记为完成");
    },
    async completeTicket() {
      try {
        if (!this.currentDetail.processingDetail) {
          this.$message.warning('请先填写事件处理详情');
          return;
        }
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          processingDetails: this.currentDetail.processingDetail,
          eventNum: this.currentDetail.orderNumber
        };
        // 如果有上传的图片,添加到请求中
        const file = this.currentDetail.photos?.[0]?.raw || null;
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('工单已完成');
          this.detailVisible = false;
          this.fetchTableData(); // 刷新列表数据
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('完成工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      }
    },
    async approveAndDispatch() {
      this.dispatchDialogVisible = true; // 打开派发对话框
    },
    async submitDispatch() {
      this.$refs.dispatchForm.validate(async (valid) => {
        if (valid) {
          try {
            const data = {
              id: this.currentDetail.id,
              status: this.currentDetail.status,
              isPass: 0, // 0 表示通过
              eventName: this.currentDetail.orderName, // 工单名称
              eventNum: this.currentDetail.orderNumber,
              eventType: this.currentDetail.type, // 工单类型
              content: this.currentDetail.content, // 使用 content 替代原来的 remark
              createDept: this.dispatchForm.department, // 派发部门 ID
              updateUser: this.dispatchForm.handler, // 处理人 ID
            };
            const file = this.currentDetail.file || null; // 如果没有文件,则为 null
            const response = await flowEvent(data, file);
            if (response.data.code === 0) {
              this.$message.success('工单已成功派发');
              this.dispatchDialogVisible = false;
              this.detailVisible = false;
              this.fetchTableData();
            } else {
              throw new Error(response.data.msg || '派发失败');
                console.log('用户名到ID的映射:', this.userNameToIdMap)
            } catch (error) {
                console.error('获取下拉框数据失败:', error)
                this.$message.error('加载下拉框数据失败')
            }
          } catch (error) {
            console.error('派发失败:', error);
            this.$message.error(error.message || '派发失败,请稍后重试');
          }
        }
      });
        },
        async fetchTableData () {
            if (this.isFetching) return
            this.isFetching = true
            this.loading = true
            try {
                const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
                const params = {
                    word_order_type: this.filters.type || undefined,
                    status: currentTab?.name === 'myTickets' ? undefined :
                        this.filters.status !== "" ? Number(this.filters.status) :
                            currentTab?.value,
                    event_name: this.filters.keyword || undefined,
                    dept_id: this.filters.department || undefined,
                    start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
                    end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]).replace("00:00:00", "23:59:59") : undefined,
                    current: Number(this.page.currentPage),  // 使用当前页码
                    size: Number(this.page.pageSize),       // 使用每页条数
                    ai_type: this.filters.algorithm || undefined, // 添加算法参数
                }
                const response = await getList(params)
                if (!response?.data?.data?.records) {
                    throw new Error('接口返回数据格式不正确')
                }
                const { total, records } = response.data.data
                let filteredRecords = records
                // 如果是"我发起的"tab,过滤数据
                if (currentTab?.name === 'myTickets') {
                    filteredRecords = records.filter(item =>
                        String(item.create_user_id) === String(item.user_id)
                    )
                }
                this.tableData = filteredRecords.map(item => {
                    const longitude = Number(item.longitude) || 0
                    const latitude = Number(item.latitude) || 0
                    return {
                        id: item.id,
                        orderNumber: item.event_num, // 修改这里:优先使用 event_num
                        orderName: item.event_name,
                        department: this.departments.find(d => d.value === item.dept_id)?.label || item.dept_name,
                        startTime: item.create_time,
                        aiType: item.ai_types,
                        content: item.content, // 将后端返回的 content 映射为 content
                        type: this.types.find(t => t.value === item.event_dict_key)?.label,
                        keyData: (!isNaN(longitude) && !isNaN(latitude))
                            ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
                            : '未知位置',
                        address: item.address,
                        creator: item.create_user,
                        handler: item.update_user || '未分配',
                        status: Number(item.status || 0),
                        // 保存原始字段
                        photo_url: item.photo_url || '',  // 保存原始 photo_url
                        video_url: item.video_url || '',  // 保存原始 video_url
                        location: (!isNaN(longitude) && !isNaN(latitude)) ? [longitude, latitude] : null,
                        processing_details: item.processing_details || '', // 添加处理详情字段
                        video_url: item.video_url || '',  // 保存原始 video_url
                        location: (!isNaN(longitude) && !isNaN(latitude)) ? [longitude, latitude] : null,
                        processing_details: item.processing_details || '', // 添加处理详情字段
                        update_photo_url: item.update_photo_url || '', // 添加处理图片字段
                    }
                })
                // 更新总数显示
                if (currentTab?.name === 'myTickets') {
                    this.page.total = filteredRecords.length
                } else {
                    this.page.total = total || 0
                }
                await this.fetchTabCounts()
            } catch (error) {
                console.error("获取数据失败:", error)
                this.$message.error(error.message || "获取数据失败")
                this.tableData = []
                this.page.total = 0
            } finally {
                this.loading = false
                this.isFetching = false
            }
        },
        async submitForm () {
            try {
                // 提交时需要完整验证
                await this.$refs.form.validate()
                // 验证位置信息
                if (!this.form.location || this.form.location.length < 2) {
                    this.$message.warning('请在地图上选择位置')
                    return
                }
                // 验证图片上传
                if (!this.form.photos || this.form.photos.length === 0) {
                    this.$message.warning('请上传工单图片')
                    return
                }
                const submitData = {
                    eventName: this.form.name,
                    content: this.form.content,
                    workType: "1",
                    longitude: String(this.form.location[0]),
                    latitude: String(this.form.location[1]),
                    address: this.form.address,
                    eventDictKey: this.form.type,
                    aiType: this.form.algorithm,
                    updateUser: this.form.handler,
                    createDept: this.form.department,
                    isDraft: 0
                }
                if (this.form.id) {
                    submitData.id = this.form.id
                }
                // 获取文件对象
                const file = this.form.photos[0].raw
                if (!file) {
                    this.$message.warning('图片文件无效,请重新上传')
                    return
                }
                const response = await createTicket(submitData, file)
                if (response.data.code === 0) {
                    this.$message.success('工单创建成功')
                    this.dialogVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '创建失败')
                }
            } catch (error) {
                console.error('提交失败:', error)
                if (error.message.includes('验证未通过')) {
                    this.$message.warning('请填写完整的工单信息')
                } else {
                    this.$message.error(error.message || '工单创建失败,请稍后重试')
                }
            }
        },
        async saveDraft () {
            try {
                const submitData = {
                    id: this.form.id,
                    eventName: this.form.name || undefined,
                    content: this.form.content || undefined,
                    workType: "1",
                    longitude: this.form.location?.[0] ? String(this.form.location[0]) : undefined,
                    latitude: this.form.location?.[1] ? String(this.form.location[1]) : undefined,
                    address: this.form.address || undefined,
                    eventDictKey: this.form.type || undefined,
                    aiType: this.form.algorithm || undefined,
                    updateUser: this.form.handler || undefined,
                    createDept: this.form.department || undefined,
                    isDraft: 1
                }
                // 草稿时也至少需要工单名称
                if (!submitData.eventName) {
                    this.$message.warning('请至少输入工单名称')
                    return
                }
                // 过滤掉所有 undefined 的字段
                Object.keys(submitData).forEach(key =>
                    submitData[key] === undefined && delete submitData[key]
                )
                let file = null
                if (this.form.photos && this.form.photos.length > 0) {
                    file = this.form.photos[0].raw
                }
                const response = await createTicket(submitData, file)
                if (response.data.code === 0) {
                    this.$message.success('草稿保存成功')
                    this.dialogVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '保存失败')
                }
            } catch (error) {
                console.error('保存草稿失败:', error)
                this.$message.error(error.message || '保存草稿失败,请稍后重试')
            }
        },
        async handleLocationChange (val) {
            console.log('地图选址返回值:', val)
            // 处理 Proxy 对象的值
            let locationValue = val.value
            if (locationValue && locationValue.length >= 3) {
                // 确保我们获取到实际的数组值
                this.form.location = [locationValue[0], locationValue[1]]
                this.form.address = locationValue[2] || ''
                console.log('解析后的位置信息:', {
                    经度: this.form.location[0],
                    纬度: this.form.location[1],
                    地址: this.form.address
                })
            } else {
                console.warn('无效的位置数据')
                this.form.location = []
                this.form.address = ''
            }
        },
        formatDate (date) {
            if (!date) return undefined
            const d = new Date(date)
            return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} 00:00:00`
        },
        mapStatus (status) {
            const statusTextMap = {
                "-1": "草稿",  // 添加草稿状态
                "2": "待审核",
                "0": "待处理",
                "3": "处理中",
                "4": "已完成",
                "5": "已完结"
            }
            return statusTextMap[status] || "未知状态"
        },
        getStatusTagType (status) {
            const statusMap = {
                "-1": "info",    // 为草稿状态添加样式
                "2": "warning",
                "0": "danger",
                "3": "primary",
                "4": "success",
                "5": "danger",
            }
            return statusMap[status] || "info"
        },
        async fetchTabCounts () {
            try {
                const response = await getstatusCount()
                const { statusCount, totalCount, userCount } = response.data.data
                console.log('接口返回的状态统计数据:', { statusCount, totalCount, userCount })
                this.tabs.forEach(tab => {
                    if (tab.name === 'all') {
                        tab.count = totalCount || 0 // 总工单数
                    } else if (tab.name === 'myTickets') {
                        tab.count = userCount || 0 // 我发起的工单数
                    } else {
                        tab.count = statusCount[String(tab.value)] || 0 // 根据状态值映射
                    }
                })
                console.log('更新后的 tabs 数据:', this.tabs)
            } catch (error) {
                console.error('获取 tab 数据失败:', error)
                this.$message.error('获取 tab 数据失败')
            }
        },
        handleTabChange (tab) {
            this.activeTab = tab.props?.name || tab.name
            this.handleReset()
            this.page.currentPage = 1
            this.fetchTableData()
            this.fetchTabCounts() // 切换 tab 时重新获取数据
        },
        handleSearch () {
            this.page.currentPage = 1
            this.fetchTableData()
        },
        handleReset () {
            this.filters = {
                keyword: "",
                department: "",
                type: "",
                dateRange: [],
                status: "",
                algorithm: "", // 重置时清空算法筛选
            }
            this.page.currentPage = 1
            this.fetchTableData()
        },
        async handleCurrentChange (val) {
            console.log('当前页变更:', val)
            // 先更新页码
            this.page.currentPage = val
            // 等待 DOM 更新后再请求数据
            await this.$nextTick()
            await this.fetchTableData()
        },
        async sizeChange (val) {
            console.log('每页条数变更:', val)
            this.page.pageSize = val
            this.page.currentPage = 1 // 重置到第一页
            await this.$nextTick()
            await this.fetchTableData()
        },
        handleAdd () {
            this.dialogVisible = true
        },
        resetForm () {
            this.form = {
                name: '',
                type: '',
                department: '',
                handler: '',
                algorithm: '',
                location: [],  // 将存储为[经度, 纬度, 地址]格式
                address: '',
                content: '',
                photos: [],
                content: '', // 新增字段,用于存储后端返回的 content
            }
            if (this.$refs.form) {
                this.$refs.form.resetFields()
            }
        },
        formatLocation (location) {
            if (!Array.isArray(location)) {
                return '未知位置'
            }
            return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`
        },
        async handleViewDetail (row) {
            console.log('查看详情数据:', row)
            // 重置上传组件的文件列表
            this.$nextTick(() => {
                if (this.$refs.upload) {
                    if (Array.isArray(this.$refs.upload)) {
                        this.$refs.upload.forEach(upload => upload.clearFiles())
                    } else {
                        this.$refs.upload.clearFiles()
                    }
                }
            })
            const detailData = {
                ...row,
                processingDetail: row.processing_details || '',
                mediaUrl: row.photo_url || row.video_url || '',
                updatePhotoUrl: row.update_photo_url || '',
                photos: [],
            }
            try {
                const stepResponse = await getStepInfo(row.orderNumber)
                console.log('接口返回的步骤信息:', stepResponse.data.data)
                const steps = stepResponse.data.data || []
                // 根据接口返回的步骤信息补充处理人和时间
                this.stepInfos = this.fixedStatuses.map(status => {
                    const step = steps.find(s => String(s.status) === String(status))
                    return {
                        status,
                        name: step ? step.name : '',
                        time: step ? step.time : null,
                        create_time: step ? step.create_time : null,
                    }
                })
                console.log('处理后的步骤信息:', this.stepInfos)
                this.currentDetail.status = row.status // 使用行数据中的状态
            } catch (error) {
                console.error('获取步骤信息失败:', error)
                // 如果接口调用失败,使用默认的固定状态
                this.stepInfos = this.fixedStatuses.map(status => ({
                    status,
                    name: status === row.status ? row.handler || '未分配' : '未处理',
                    time: status === row.status ? row.startTime || '未知时间' : null,
                }))
            }
            this.currentDetail = detailData
            console.log('当前详情数据:', this.currentDetail)
            this.detailVisible = true
            this.$nextTick(() => {
                this.$refs.MapContainer.initAddEntity('point', this.currentDetail.location)
            })
        },
        getStepHandler (status) {
            const step = this.stepInfos.find(step => step.status === status)
            return step ? step.name : ''
        },
        getStepTime (status) {
            const step = this.stepInfos.find(step => step.status === status)
            return step ? step.time : null
        },
        getStepCreateTime (status) {
            const step = this.stepInfos.find(step => step.status === status)
            console.log('getStepCreateTime:', step)
            return step ? step.create_time : null
        },
        getActiveStep () {
            // 由于新增了发起任务步骤,需要调整步骤索引
            const index = this.fixedStatuses.indexOf(String(this.currentDetail.status))
            return index !== -1 ? index + 1 : 1 // 加1是因为多了发起任务这一步
        },
        openMap () {
            const areaCode = this.userInfo.detail.areaCode
            const subAreaCode = areaCode ? areaCode.substring(0, 6) : ''
            const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode)
            console.log('区域代码:', subAreaCode)
            console.log('getAdcodeObj返回值:', {
                完整对象: adcodeObj,
                级别: adcodeObj?.level,
                名称: adcodeObj?.name,
                代码: adcodeObj?.adcode,
                中心点: adcodeObj?.center,
                边界: adcodeObj?.polyline,
            })
            this.$message.info("地图选址功能暂未实现")
        },
        handlePreview (file) {
            this.$message.info(`预览图片:${file.name}`)
        },
        handleRemove (file) {
            this.$message.info(`移除图片:${file.name}`)
        },
        refreshChange () {
            if (this.isFetching) return
            this.fetchTableData()
        },
        onLoad () {
            if (this.isFetching) return
            this.fetchTableData()
        },
        async exportData () {
            try {
                this.loading = true
                const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
                // 使用与查询列表相同的参数构造逻辑
                const params = {
                    word_order_type: this.filters.type || undefined,
                    status: currentTab?.name === 'myTickets' ? undefined :
                        this.filters.status !== "" ? Number(this.filters.status) :
                            currentTab?.value, // 使用当前tab的状态值
                    keyword: this.filters.keyword || undefined,
                    dept_id: this.filters.department || undefined,
                    start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
                    end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]) : undefined,
                    current: 1,
                    size: 10
                }
                const response = await getList(params)
                if (!response?.data?.data?.records) {
                    throw new Error('接口返回数据格式不正确')
                }
                const { records } = response.data.data
                // 使用与查询列表相同的过滤逻辑
                let filteredRecords = records
                if (currentTab?.name === 'myTickets') {
                    filteredRecords = records.filter(item =>
                        String(item.create_user_id) === String(item.user_id)
                    )
                }
                const exportData = filteredRecords.map(item => {
                    const longitude = Number(item.longitude) || 0
                    const latitude = Number(item.latitude) || 0
                    return {
                        工单编号: item.event_num || '',
                        工单名称: item.event_name || '',
                        所属单位: item.dept_name || '',
                        发起时间: item.create_time || '',
                        关联算法: item.ai_types || '',
                        工单内容: item.address || '',
                        工单类型: this.types.find(t => t.value === item.event_dict_key)?.label || '',
                        经纬度: (!isNaN(longitude) && !isNaN(latitude)) ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` : '',
                        创建人: item.create_user || '',
                        处理人: item.update_user || '',
                        工单状态: this.mapStatus(Number(item.status || 0))
                    }
                })
                if (exportData.length === 0) {
                    this.$message.warning('没有数据可供导出')
                    return
                }
                const headers = [
                    '工单编号',
                    '工单名称',
                    '所属单位',
                    '发起时间',
                    '关联算法',
                    '工单内容',
                    '工单类型',
                    '经纬度',
                    '创建人',
                    '处理人',
                    '工单状态'
                ]
                export_json_to_excel(headers, exportData, '工单数据')
                this.$message.success('数据导出成功')
            } catch (error) {
                console.error('导出失败:', error)
                this.$message.error(error.message || '导出失败,请稍后重试')
            } finally {
                this.loading = false
            }
        },
        handleDepartmentChange (deptId) {
            this.form.handler = ''
        },
        handleDispatchDepartmentChange (deptId) {
            this.dispatchForm.handler = '' // 清空处理人选择
        },
        // 文件改变时的钩子
        handleFileChange (file, fileList) {
            this.form.photos = fileList
            this.currentDetail.photos = fileList
        },
        // 文件移除时的钩子
        handleUploadRemove (file, fileList) {
            this.form.photos = fileList
            this.currentDetail.photos = fileList
        },
        // 上传前的验证
        beforeUpload (file) {
            const isImage = file.type.includes('image')
            const isLt5M = file.size / 1024 / 1024 < 5
            if (!isImage) {
                this.$message.error('只能上传图片文件!')
                return false
            }
            if (!isLt5M) {
                this.$message.error('图片大小不能超过5MB!')
                return false
            }
            return true
        },
        async approveTicket () {
            try {
                const data = {
                    id: this.currentDetail.id,
                    status: this.currentDetail.status,
                    isPass: 0, // 0 表示通过
                    eventNum: this.currentDetail.orderNumber,
                    eventName: this.currentDetail.orderName, // 工单名称
                    eventType: this.currentDetail.type, // 工单类型
                    departmentId: this.dispatchForm.department, // 派发部门 ID
                    handlerId: this.dispatchForm.handler, // 处理人 ID
                }
                const file = this.currentDetail.file || null // 如果没有文件,则为 null
                const response = await flowEvent(data, file)
                if (response.data.code === 0) {
                    this.$message.success('工单已通过')
                    this.detailVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '操作失败')
                }
            } catch (error) {
                console.error('通过操作失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
            }
        },
        async rejectTicket () {
            try {
                const data = {
                    id: this.currentDetail.id,
                    status: this.currentDetail.status,
                    isPass: 1, // 1 表示不通过
                }
                const response = await flowEvent(data)
                if (response.data.code === 0) {
                    this.$message.success('工单未通过')
                    this.detailVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '操作失败')
                }
            } catch (error) {
                console.error('不通过操作失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
            }
        },
        async submitProcessing () {
            if (this.currentDetail.status !== 3) {
                this.$message.warning('只有处理中状态的工单可以提交处理详情')
                return
            }
            try {
                const data = {
                    id: this.currentDetail.id, // 当前工单 ID
                    status: this.currentDetail.status, // 当前工单状态
                    processing_details: this.currentDetail.processingDetail, // 事件处理详情
                }
                // 如果有图片,添加 file 参数
                const file = this.currentDetail.photos?.[0]?.raw || null
                const response = await flowEvent(data, file)
                if (response.data.code === 0) {
                    this.$message.success('处理详情提交成功')
                    this.detailVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '提交失败')
                }
            } catch (error) {
                console.error('处理详情提交失败:', error)
                this.$message.error(error.message || '提交失败,请稍后重试')
            }
        },
        markAsCompleted () {
            this.$message.success("工单已标记为完成")
        },
        async completeTicket () {
            try {
                if (!this.currentDetail.processingDetail) {
                    this.$message.warning('请先填写事件处理详情')
                    return
                }
                const data = {
                    id: this.currentDetail.id,
                    status: this.currentDetail.status,
                    processingDetails: this.currentDetail.processingDetail,
                    eventNum: this.currentDetail.orderNumber
                }
                // 如果有上传的图片,添加到请求中
                const file = this.currentDetail.photos?.[0]?.raw || null
                const response = await flowEvent(data, file)
                if (response.data.code === 0) {
                    this.$message.success('工单已完成')
                    this.detailVisible = false
                    this.fetchTableData() // 刷新列表数据
                } else {
                    throw new Error(response.data.msg || '操作失败')
                }
            } catch (error) {
                console.error('完成工单失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
            }
        },
        async approveAndDispatch () {
            this.dispatchDialogVisible = true // 打开派发对话框
        },
        async submitDispatch () {
            this.$refs.dispatchForm.validate(async (valid) => {
                if (valid) {
                    try {
                        const data = {
                            id: this.currentDetail.id,
                            status: this.currentDetail.status,
                            isPass: 0, // 0 表示通过
                            eventName: this.currentDetail.orderName, // 工单名称
                            eventNum: this.currentDetail.orderNumber,
                            eventType: this.currentDetail.type, // 工单类型
                            content: this.currentDetail.content, // 使用 content 替代原来的 remark
                            createDept: this.dispatchForm.department, // 派发部门 ID
                            updateUser: this.dispatchForm.handler, // 处理人 ID
                        }
                        const file = this.currentDetail.file || null // 如果没有文件,则为 null
                        const response = await flowEvent(data, file)
                        if (response.data.code === 0) {
                            this.$message.success('工单已成功派发')
                            this.dispatchDialogVisible = false
                            this.detailVisible = false
                            this.fetchTableData()
                        } else {
                            throw new Error(response.data.msg || '派发失败')
                        }
                    } catch (error) {
                        console.error('派发失败:', error)
                        this.$message.error(error.message || '派发失败,请稍后重试')
                    }
                }
            })
        },
        async finalizeTicket () {
            try {
                // 检查是否上传了图片
                if (!this.currentDetail.photos || !this.currentDetail.photos.length) {
                    this.$message.warning('请上传处理图片')
                    return
                }
                const data = {
                    id: this.currentDetail.id,
                    status: this.currentDetail.status,
                    eventNum: this.currentDetail.orderNumber,
                }
                const file = this.currentDetail.photos[0].raw
                const response = await flowEvent(data, file)
                if (response.data.code === 0) {
                    this.$message.success('工单已完结')
                    this.detailVisible = false
                    this.fetchTableData()
                } else {
                    throw new Error(response.data.msg || '操作失败')
                }
            } catch (error) {
                console.error('完结工单失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
            }
        },
        // 添加编辑方法
        handleEdit (row) {
            console.log('编辑原始数据:', row)
            // 尝试从row.dept_id或通过部门名称查找对应的部门ID
            let deptId = row.dept_id  // 优先使用原始数据中的dept_id
            // 如果没有dept_id,则通过部门名称查找
            if (!deptId) {
                // 输出所有可用的部门数据用于调试
                console.log('可用部门列表:', this.departments)
                console.log('当前部门名称:', row.department)
                const deptInfo = this.departments.find(dept =>
                    dept.label && dept.label.trim() === row.department.trim()
                )
                deptId = deptInfo?.value
            }
            // 获取工单类型值 - 从types中找到匹配的值
            const typeValue = this.types.find(t => t.label === row.type)?.value || row.event_dict_key
            // 获取处理人ID - 使用userNameToIdMap映射
            const handlerId = this.userNameToIdMap[row.handler] || row.handler
            console.log('数据映射:', {
                部门名称: row.department,
                找到的部门ID: deptId,
                原始处理人: row.handler,
                处理人ID: handlerId,
                原始工单类型: row.type,
                映射后类型值: typeValue
            })
            this.form = {
                id: row.id,
                name: row.orderName,
                type: typeValue,
                department: deptId,
                handler: handlerId, // 使用映射后的处理人ID
                algorithm: row.aiType,
                location: row.location,
                address: row.address,
                content: row.content,
                photos: [],
            }
            // 如果有图片,添加到表单中
            if (row.photo_url) {
                this.form.photos = [{
                    name: 'existing-photo',
                    url: row.photo_url
                }]
            }
            this.dialogVisible = true
        },
        // 添加删除方法
        handleDelete (row) {
            this.$confirm('确认删除该工单?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                try {
                    const response = await flowEvent({
                        id: row.id,
                        status: 0,
                        isDelete: 1
                    })
                    if (response.data.code === 0) {
                        this.$message.success('删除成功')
                        this.fetchTableData()
                    } else {
                        throw new Error(response.data.msg || '删除失败')
                    }
                } catch (error) {
                    console.error('删除失败:', error)
                    this.$message.error(error.message || '删除失败,请稍后重试')
                }
            }).catch(() => { })
        },
    },
    async finalizeTicket() {
      try {
        // 检查是否上传了图片
        if (!this.currentDetail.photos || !this.currentDetail.photos.length) {
          this.$message.warning('请上传处理图片');
          return;
        }
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          eventNum: this.currentDetail.orderNumber,
        };
        const file = this.currentDetail.photos[0].raw;
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('工单已完结');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('完结工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      }
    },
    // 添加编辑方法
    handleEdit(row) {
      console.log('编辑原始数据:', row);
      // 尝试从row.dept_id或通过部门名称查找对应的部门ID
      let deptId = row.dept_id;  // 优先使用原始数据中的dept_id
      // 如果没有dept_id,则通过部门名称查找
      if (!deptId) {
        // 输出所有可用的部门数据用于调试
        console.log('可用部门列表:', this.departments);
        console.log('当前部门名称:', row.department);
        const deptInfo = this.departments.find(dept =>
          dept.label && dept.label.trim() === row.department.trim()
        );
        deptId = deptInfo?.value;
      }
      // 获取工单类型值 - 从types中找到匹配的值
      const typeValue = this.types.find(t => t.label === row.type)?.value || row.event_dict_key;
      // 获取处理人ID - 使用userNameToIdMap映射
      const handlerId = this.userNameToIdMap[row.handler] || row.handler;
      console.log('数据映射:', {
        部门名称: row.department,
        找到的部门ID: deptId,
        原始处理人: row.handler,
        处理人ID: handlerId,
        原始工单类型: row.type,
        映射后类型值: typeValue
      });
      this.form = {
        id: row.id,
        name: row.orderName,
        type: typeValue,
        department: deptId,
        handler: handlerId, // 使用映射后的处理人ID
        algorithm: row.aiType,
        location: row.location,
        address: row.address,
        content: row.content,
        photos: [],
      };
      // 如果有图片,添加到表单中
      if (row.photo_url) {
        this.form.photos = [{
          name: 'existing-photo',
          url: row.photo_url
        }];
      }
      this.dialogVisible = true;
    },
    // 添加删除方法
    handleDelete(row) {
      this.$confirm('确认删除该工单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        try {
          const response = await flowEvent({
            id: row.id,
            status: 0,
            isDelete: 1
          });
          if (response.data.code === 0) {
            this.$message.success('删除成功');
            this.fetchTableData();
          } else {
            throw new Error(response.data.msg || '删除失败');
          }
        } catch (error) {
          console.error('删除失败:', error);
          this.$message.error(error.message || '删除失败,请稍后重试');
        }
      }).catch(() => { });
    },
  },
};
}
</script>
<style lang="scss" scoped>
.tab-content {
  padding: 10px;
    padding: 10px;
}
.filter-bar {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 8px; // 使用 gap 统一设置间距
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 8px; // 使用 gap 统一设置间距
  .filter-item {
    width: 160px; // 减小宽度
  }
    .filter-item {
        width: 160px; // 减小宽度
    }
  .date-picker {
    width: 240px; // 日期选择器宽度适当调整
  }
    .date-picker {
        width: 240px; // 日期选择器宽度适当调整
    }
  .el-button {
    margin-left: 0; // 覆盖 element-ui 默认的按钮间距
  }
    .el-button {
        margin-left: 0; // 覆盖 element-ui 默认的按钮间距
    }
}
.action-bar {
  margin-bottom: 16px;
    margin-bottom: 16px;
}
.el-tabs {
  :deep(.el-tabs__content) {
    overflow: visible;
  }
    :deep(.el-tabs__content) {
        overflow: visible;
    }
}
.tab-content {
  min-height: 200px;
    min-height: 200px;
}
.detail-form {
  :deep(.el-form-item) {
    margin-bottom: 10px;
  }
    :deep(.el-form-item) {
        margin-bottom: 10px;
    }
  :deep(.el-form-item__label) {
    color: #606266;
    font-weight: normal;
  }
    :deep(.el-form-item__label) {
        color: #606266;
        font-weight: normal;
    }
  :deep(.el-form-item__content) {
    color: #303133;
  }
    :deep(.el-form-item__content) {
        color: #303133;
    }
}
.el-dialog {
  .el-form-item {
    margin-bottom: 20px;
  }
    .el-form-item {
        margin-bottom: 20px;
    }
}
.el-upload {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  :deep(.el-upload-list__item) {
    transition: all 0.3s ease;
  }
    :deep(.el-upload-list__item) {
        transition: all 0.3s ease;
    }
  :deep(.el-upload-list__item:hover) {
    background-color: #f5f7fa;
  }
    :deep(.el-upload-list__item:hover) {
        background-color: #f5f7fa;
    }
}
.el-upload__tip {
  font-size: 12px;
  color: #909399;
  margin-top: 7px;
    font-size: 12px;
    color: #909399;
    margin-top: 7px;
}
.create-ticket-form {
  padding: 20px 10px;
    padding: 20px 10px;
  .form-section {
    background-color: #fff;
    border-radius: 4px;
    .form-section {
        background-color: #fff;
        border-radius: 4px;
    .el-row {
      margin-bottom: 16px;
        .el-row {
            margin-bottom: 16px;
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
  .location-wrapper {
    .map-button {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      i {
        margin-right: 4px;
      }
            &:last-child {
                margin-bottom: 0;
            }
        }
    }
    .location-text {
      margin-top: 8px;
      padding: 8px 12px;
      background-color: #f5f7fa;
      border-radius: 4px;
      color: #606266;
      font-size: 13px;
      line-height: 1.4;
    }
  }
    .location-wrapper {
        .map-button {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
  .upload-wrapper {
    .uploader {
      :deep(.el-upload--picture-card) {
        width: 120px;
        height: 120px;
        line-height: 128px;
      }
            i {
                margin-right: 4px;
            }
        }
      :deep(.el-upload-list__item) {
        width: 120px;
        height: 120px;
      }
        .location-text {
            margin-top: 8px;
            padding: 8px 12px;
            background-color: #f5f7fa;
            border-radius: 4px;
            color: #606266;
            font-size: 13px;
            line-height: 1.4;
        }
    }
    .upload-tip {
      font-size: 12px;
      color: #909399;
      line-height: 1.4;
      margin-top: 8px;
    .upload-wrapper {
        .uploader {
            :deep(.el-upload--picture-card) {
                width: 120px;
                height: 120px;
                line-height: 128px;
            }
            :deep(.el-upload-list__item) {
                width: 120px;
                height: 120px;
            }
        }
        .upload-tip {
            font-size: 12px;
            color: #909399;
            line-height: 1.4;
            margin-top: 8px;
        }
    }
  }
  .el-form-item {
    margin-bottom: 18px;
    .el-form-item {
        margin-bottom: 18px;
    &:last-child {
      margin-bottom: 0;
        &:last-child {
            margin-bottom: 0;
        }
    }
  }
  :deep(.el-form-item__label) {
    font-weight: 500;
    color: #606266;
  }
    :deep(.el-form-item__label) {
        font-weight: 500;
        color: #606266;
    }
  :deep(.el-input__inner) {
    height: 36px;
    line-height: 36px;
  }
    :deep(.el-input__inner) {
        height: 36px;
        line-height: 36px;
    }
  :deep(.el-textarea__inner) {
    padding: 8px 12px;
  }
    :deep(.el-textarea__inner) {
        padding: 8px 12px;
    }
}
.dialog-footer {
  text-align: right;
  padding-top: 16px;
  border-top: 1px solid #ebeef5;
    text-align: right;
    padding-top: 16px;
    border-top: 1px solid #ebeef5;
  .el-button + .el-button {
    margin-left: 12px;
  }
  .el-button {
    padding: 9px 20px;
    &:last-child {
      margin-left: 12px;
    .el-button+.el-button {
        margin-left: 12px;
    }
  }
    .el-button {
        padding: 9px 20px;
        &:last-child {
            margin-left: 12px;
        }
    }
}
.map-container {
  width: 100%;
  height: 400px;
  margin-bottom: 15px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  overflow: hidden;
    width: 100%;
    height: 400px;
    margin-bottom: 15px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    overflow: hidden;
  :deep(.el-input-map) {
    height: 100%;
  }
    :deep(.el-input-map) {
        height: 100%;
    }
}
.location-info {
  margin-top: 10px;
  padding: 10px;
  background-color: #f5f7fa;
  border-radius: 4px;
  p {
    margin: 5px 0;
    color: #606266;
    font-size: 14px;
  }
}
.map-select {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  .selected-location {
    flex: 1;
    padding: 5px 10px;
    margin-top: 10px;
    padding: 10px;
    background-color: #f5f7fa;
    border-radius: 4px;
    p {
      margin: 5px 0;
      color: #606266;
      font-size: 14px;
        margin: 5px 0;
        color: #606266;
        font-size: 14px;
    }
  }
}
.map-select {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    .selected-location {
        flex: 1;
        padding: 5px 10px;
        background-color: #f5f7fa;
        border-radius: 4px;
        p {
            margin: 5px 0;
            color: #606266;
            font-size: 14px;
        }
    }
}
.preview-image {
  border-radius: 4px;
  overflow: hidden;
  background-color: #f5f7fa;
    border-radius: 4px;
    overflow: hidden;
    background-color: #f5f7fa;
}
.image-placeholder,
.image-error,
.no-media {
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #909399;
  background-color: #f5f7fa;
  border-radius: 4px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #909399;
    background-color: #f5f7fa;
    border-radius: 4px;
  i {
    font-size: 32px;
    margin-bottom: 8px;
  }
    i {
        font-size: 32px;
        margin-bottom: 8px;
    }
}
.no-media {
  border: 1px dashed #d9d9d9;
    border: 1px dashed #d9d9d9;
}
.detail-container {
  padding: 20px;
    padding: 20px;
}
.status-flow {
  margin-bottom: 20px;
    margin-bottom: 20px;
  .custom-steps {
    .el-step__description {
      position: relative;
      margin: 0;
      padding: 0;
    .custom-steps {
        .el-step__description {
            position: relative;
            margin: 0;
            padding: 0;
        }
        // 添加发起任务步骤的特殊样式
        .init-step-info {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            width: 130px;
            .creator-name {
                font-size: 14px;
                font-weight: bold;
                color: #303133;
                margin-bottom: 4px;
            }
            .create-time {
                font-size: 10px;
                color: #909399;
            }
        }
        // 保持其他步骤的原有样式
        .step-info {
            display: flex;
            margin: 0;
            padding: 0;
            justify-content: space-between;
            align-items: center;
            width: 200px;
            .process-time {
                font-size: 10px;
                color: #909399;
                text-align: left;
                margin-left: -50%;
                padding-left: 0%;
                flex: 1;
            }
            .handler-name {
                font-size: 14px;
                font-weight: bold;
                color: #303133;
                text-align: left;
                flex: 1;
            }
        }
    }
    // 添加发起任务步骤的特殊样式
    .init-step-info {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      width: 130px;
      .creator-name {
        font-size: 14px;
        font-weight: bold;
        color: #303133;
        margin-bottom: 4px;
      }
      .create-time {
        font-size: 10px;
        color: #909399;
      }
    }
    // 保持其他步骤的原有样式
    .step-info {
      display: flex;
      margin: 0;
      padding: 0;
      justify-content: space-between;
      align-items: center;
      width: 200px;
      .process-time {
        font-size: 10px;
        color: #909399;
        text-align: left;
        margin-left: -50%;
        padding-left: 0%;
        flex: 1;
      }
      .handler-name {
        font-size: 14px;
        font-weight: bold;
        color: #303133;
        text-align: left;
        flex: 1;
      }
    }
  }
}
.basic-info {
  margin-bottom: 20px;
    margin-bottom: 20px;
}
.media-section {
  margin-bottom: 20px;
    margin-bottom: 20px;
}
.media-box {
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 10px;
  background: #fff;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 10px;
    background: #fff;
}
.media-title {
  font-weight: bold;
  margin-bottom: 10px;
    font-weight: bold;
    margin-bottom: 10px;
}
.media-content {
  position: relative;
  height: 300px;
    position: relative;
    height: 300px;
}
.image-placeholder,
.image-error,
.no-media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #909399;
  background-color: #f5f7fa;
  border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #909399;
    background-color: #f5f7fa;
    border-radius: 4px;
}
.image-placeholder i,
.image-error i {
  font-size: 32px;
  margin-bottom: 8px;
    font-size: 32px;
    margin-bottom: 8px;
}
.info-table {
  margin-bottom: 20px;
    margin-bottom: 20px;
}
.info-item {
  display: flex;
  margin-bottom: 10px;
    display: flex;
    margin-bottom: 10px;
}
.info-label {
  font-weight: bold;
  width: 120px;
  color: #606266;
    font-weight: bold;
    width: 120px;
    color: #606266;
}
.info-value {
  flex: 1;
  color: #303133;
  word-break: break-word;
    flex: 1;
    color: #303133;
    word-break: break-word;
}
.readonly-processing-detail {
  background-color: #f5f7fa;
  padding: 12px;
  border-radius: 4px;
  min-height: 40px;
  color: #606266;
  line-height: 1.5;
  display: block;
  text-align: left;
  &:first-child {
    font-weight: bold;
    margin-bottom: 4px;
  }
    background-color: #f5f7fa;
    padding: 12px;
    border-radius: 4px;
    min-height: 40px;
    color: #606266;
    line-height: 1.5;
    display: block;
    text-align: left;
    &:first-child {
        font-weight: bold;
        margin-bottom: 4px;
    }
}
// 添加删除按钮样式
.danger-button {
  color: #F56C6C;
    color: #F56C6C;
}
.danger-button:hover {
  color: #f78989;
    color: #f78989;
}
.custom-steps-container {
  width: 100%;
  margin: 20px 0;
    width: 100%;
    margin: 20px 0;
}
.steps-titles {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  position: relative;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    position: relative;
}
.step-title {
  text-align: center;
  flex: 1;
  font-size: 16px;
  color: #999;
  position: relative;
  padding-bottom: 10px;
    text-align: center;
    flex: 1;
    font-size: 16px;
    color: #999;
    position: relative;
    padding-bottom: 10px;
}
.step-title.active {
  color: #409eff;
  font-weight: bold;
    color: #409eff;
    font-weight: bold;
}
.custom-steps {
  margin-top: -20px;
    margin-top: -20px;
  :deep(.el-step__description) {
    margin-top: 8px;
    padding: 0 20px;
  }
    :deep(.el-step__description) {
        margin-top: 8px;
        padding: 0 20px;
    }
}
.step-description {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  display: block;
  text-align: center;
  &:first-child {
    font-weight: bold;
    margin-bottom: 4px;
  }
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    display: block;
    text-align: center;
    &:first-child {
        font-weight: bold;
        margin-bottom: 4px;
    }
}
// 覆盖其他相关样式
.status-flow {
  .custom-steps {
    .el-step__description {
      position: relative;
      margin: 0;
      padding: 0;
    }
    .custom-steps {
        .el-step__description {
            position: relative;
            margin: 0;
            padding: 0;
        }
    // 移除之前的样式
    .init-step-info,
    .step-info {
      display: block;
      width: auto;
      text-align: center;
        // 移除之前的样式
        .init-step-info,
        .step-info {
            display: block;
            width: auto;
            text-align: center;
        }
    }
  }
}
</style>