无人机管理后台前端(已迁走)
rain
2025-04-15 52fa27225a66bfc5a802647e07d11171fed718eb
tab标签页对草稿状态进行优化
1 files modified
758 ■■■■ changed files
src/views/tickets/ticket.vue 758 ●●●● patch | view | raw | blame | history
src/views/tickets/ticket.vue
@@ -5,33 +5,25 @@
                <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-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 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 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-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 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>
@@ -76,8 +68,7 @@
                        <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-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
                                </el-select>
                            </el-form-item>
                        </el-col>
@@ -86,19 +77,15 @@
                    <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 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 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>
@@ -108,23 +95,19 @@
                        <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-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">
                  <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 v-if="form.location?.length >= 2" class="location-text">{{ form.address || '获取地址中...' }}</div>
                                </div>
                            </el-form-item>
                        </el-col>
@@ -133,16 +116,23 @@
                    <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-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">
                <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>
@@ -153,7 +143,7 @@
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="danger" @click="submitForm">确认提交</el-button>
          <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>
@@ -167,11 +157,18 @@
                <div class="custom-steps-container">
                    <!-- 标题行 -->
                    <div class="steps-titles">
                        <div class="step-title" :class="{ active: true }">
            <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">
            <div
              v-for="(status, index) in fixedStatuses"
              :key="index"
              :class="{ active: Number(currentDetail.status) >= Number(status) }"
              class="step-title"
            >
                            {{ mapStatus(status) }}
                        </div>
                    </div>
@@ -222,10 +219,8 @@
                            </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 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>
@@ -241,16 +236,14 @@
                            <!-- 修复工单类型为下拉框 -->
                            <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-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 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>
@@ -263,8 +256,8 @@
                    <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;" />
            <el-input type="textarea" v-model="currentDetail.processingDetail" placeholder="请输入事件处理详情" :rows="4"
              style="width: 100%; margin-bottom: 10px;" />
                    </template>
                    <!-- 已完成和已完结状态显示只读文本 -->
                    <template v-else>
@@ -278,8 +271,8 @@
                <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/*">
            :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>
@@ -293,8 +286,7 @@
                                <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;">
                    :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>
@@ -318,8 +310,7 @@
                                <template v-if="currentDetail.status === 5">
                                    <div class="media-title">工单处理图片</div>
                                    <div class="media-content">
                                        <el-image v-if="currentDetail.updatePhotoUrl"
                                            :src="currentDetail.updatePhotoUrl"
                    <el-image v-if="currentDetail.updatePhotoUrl" :src="currentDetail.updatePhotoUrl"
                                            :preview-src-list="[currentDetail.updatePhotoUrl]" fit="cover"
                                            style="width: 100%; height: 300px;">
                                            <template #placeholder>
@@ -341,8 +332,7 @@
                                <template v-else>
                                    <div class="media-title">地图标记事件点</div>
                                    <div class="media-content">
                                        <div id="map-container"
                                            style="width: 100%; height: 300px; background: #f5f5f5;">
                    <div id="map-container" style="width: 100%; height: 300px; background: #f5f5f5;">
                                            <map-container v-if='detailVisible' ref="MapContainer"></map-container>
                                        </div>
                                    </div>
@@ -388,16 +378,13 @@
        <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 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-option v-for="user in availableDispatchHandlers" :key="user.id" :label="user.name" :value="user.id" />
                    </el-select>
                </el-form-item>
            </el-form>
@@ -410,8 +397,8 @@
</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'
@@ -516,9 +503,9 @@
                location: [{
                    validator: (rule, value, callback) => {
                        if (!value || value.length < 2) {
                            callback(new Error('请选择位置信息'))
              callback(new Error('请选择位置信息'));
                        } else {
                            callback()
              callback();
                        }
                    },
                    trigger: 'change'
@@ -526,9 +513,9 @@
                photos: [{
                    validator: (rule, value, callback) => {
                        if (!this.form.photos || this.form.photos.length === 0) {
                            callback(new Error('请上传工单图片'))
              callback(new Error('请上传工单图片'));
                        } else {
                            callback()
              callback();
                        }
                    },
                    trigger: 'change'
@@ -557,22 +544,22 @@
            stepInfos: [], // 新增:存储步骤信息
            fixedStatuses: ["2", "0", "3", "4", "5"], // 固定的五个状态
            userNameToIdMap: {}, // 新增用户名到ID的映射
        }
    };
    },
    created () {
        this.loadAMapScripts()
        this.fetchDropdownData()
        this.fetchTabCounts() // 新增:初始化时获取 tab 数据
    this.loadAMapScripts();
    this.fetchDropdownData();
    this.fetchTabCounts(); // 新增:初始化时获取 tab 数据
    },
    mounted () {
        this.fetchTableData()
    this.fetchTableData();
    },
    computed: {
        availableHandlers () {
            return this.form.department ? (this.departmentUsers[this.form.department] || []) : []
      return this.form.department ? (this.departmentUsers[this.form.department] || []) : [];
        },
        availableDispatchHandlers () {
            return this.dispatchForm.department ? (this.departmentUsers[this.dispatchForm.department] || []) : []
      return this.dispatchForm.department ? (this.departmentUsers[this.dispatchForm.department] || []) : [];
        },
        detailTableData () {
            return [
@@ -630,7 +617,7 @@
                    editable: this.currentDetail.status === 0,
                    type: "textarea",
                },
            ]
      ];
        },
        detailFields () {
            return [
@@ -644,7 +631,7 @@
                { 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 = [
@@ -658,107 +645,107 @@
                { label: "任务接收单位", value: this.currentDetail.department },
                { label: "发起任务时间", value: this.currentDetail.startTime },
                { label: "工单内容", value: this.currentDetail.content },
            ]
      ];
            // 将字段分成两列
            const formattedFields = []
      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
      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)
        const areaCode = this.userInfo.detail.areaCode;
        const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
        const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode);
                console.log('区域代码:', subAreaCode)
        console.log('区域代码:', subAreaCode);
                // 直接从返回对象中获取正确的路径
                const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center
        const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center;
                console.log('获取到的中心点:', center)
        console.log('获取到的中心点:', center);
                if (Array.isArray(center) && center.length === 2) {
                    this.mapParams.center = center
                    console.log('成功设置地图中心点:', center)
          this.mapParams.center = center;
          console.log('成功设置地图中心点:', center);
                } else {
                    // 如果找不到中心点,尝试使用 bbox 的中心点
                    const bbox = adcodeObj?.payload?.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)
            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]
            console.warn('无法获取有效的中心点坐标,使用默认值');
            this.mapParams.center = [115.861365, 28.621311];
                    }
                }
                this.mapLoaded = true
        this.mapLoaded = true;
            } catch (error) {
                console.error('地图脚本加载失败:', error)
                this.$message.error('地图加载失败,请检查网络或API Key配置')
        console.error('地图脚本加载失败:', error);
        this.$message.error('地图加载失败,请检查网络或API Key配置');
            }
        },
        async fetchDropdownData () {
            try {
                const response = await getTicketInfo()
                const { dept_data, event_type, ai_type } = response.data.data
        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
                }, {})
          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 = {}
        this.userNameToIdMap = {};
                dept_data.forEach(dept => {
                    (dept.user_data || []).forEach(user => {
                        this.userNameToIdMap[user.name] = user.id
                    })
                })
            this.userNameToIdMap[user.name] = user.id;
          });
        });
                console.log('用户名到ID的映射:', this.userNameToIdMap)
        console.log('用户名到ID的映射:', this.userNameToIdMap);
            } catch (error) {
                console.error('获取下拉框数据失败:', error)
                this.$message.error('加载下拉框数据失败')
        console.error('获取下拉框数据失败:', error);
        this.$message.error('加载下拉框数据失败');
            }
        },
        async fetchTableData () {
            if (this.isFetching) return
            this.isFetching = true
            this.loading = true
      if (this.isFetching) return;
      this.isFetching = true;
      this.loading = true;
            try {
                const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
        const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
                const params = {
                    word_order_type: this.filters.type || undefined,
                    status: currentTab?.name === 'myTickets' ? undefined :
@@ -771,26 +758,28 @@
                    current: Number(this.page.currentPage),  // 使用当前页码
                    size: Number(this.page.pageSize),       // 使用每页条数
                    ai_type: this.filters.algorithm || undefined, // 添加算法参数
                }
          // 添加 is_draft 参数,仅在"我发起的"标签页时设置为1
          is_draft: currentTab?.name === 'myTickets' ? 1 : undefined
        };
                const response = await getList(params)
        const response = await getList(params);
                if (!response?.data?.data?.records) {
                    throw new Error('接口返回数据格式不正确')
          throw new Error('接口返回数据格式不正确');
                }
                const { total, records } = response.data.data
                let filteredRecords = records
        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
          const longitude = Number(item.longitude) || 0;
          const latitude = Number(item.latitude) || 0;
                    return {
                        id: item.id,
                        orderNumber: item.event_num, // 修改这里:优先使用 event_num
@@ -817,43 +806,43 @@
                        processing_details: item.processing_details || '', // 添加处理详情字段
                        update_photo_url: item.update_photo_url || '', // 添加处理图片字段
                    }
                })
          };
        });
                // 更新总数显示
                if (currentTab?.name === 'myTickets') {
                    this.page.total = filteredRecords.length
          this.page.total = filteredRecords.length;
                } else {
                    this.page.total = total || 0
          this.page.total = total || 0;
                }
                await this.fetchTabCounts()
        await this.fetchTabCounts();
            } catch (error) {
                console.error("获取数据失败:", error)
                this.$message.error(error.message || "获取数据失败")
                this.tableData = []
                this.page.total = 0
        console.error("获取数据失败:", error);
        this.$message.error(error.message || "获取数据失败");
        this.tableData = [];
        this.page.total = 0;
            } finally {
                this.loading = false
                this.isFetching = false
        this.loading = false;
        this.isFetching = false;
            }
        },
        async submitForm () {
            try {
                // 提交时需要完整验证
                await this.$refs.form.validate()
        await this.$refs.form.validate();
                // 验证位置信息
                if (!this.form.location || this.form.location.length < 2) {
                    this.$message.warning('请在地图上选择位置')
                    return
          this.$message.warning('请在地图上选择位置');
          return;
                }
                // 验证图片上传
                if (!this.form.photos || this.form.photos.length === 0) {
                    this.$message.warning('请上传工单图片')
                    return
          this.$message.warning('请上传工单图片');
          return;
                }
                const submitData = {
@@ -868,33 +857,33 @@
                    updateUser: this.form.handler,
                    createDept: this.form.department,
                    isDraft: 0
                }
        };
                if (this.form.id) {
                    submitData.id = this.form.id
          submitData.id = this.form.id;
                }
                // 获取文件对象
                const file = this.form.photos[0].raw
        const file = this.form.photos[0].raw;
                if (!file) {
                    this.$message.warning('图片文件无效,请重新上传')
                    return
          this.$message.warning('图片文件无效,请重新上传');
          return;
                }
                const response = await createTicket(submitData, file)
        const response = await createTicket(submitData, file);
                if (response.data.code === 0) {
                    this.$message.success('工单创建成功')
                    this.dialogVisible = false
                    this.fetchTableData()
          this.$message.success('工单创建成功');
          this.dialogVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '创建失败')
          throw new Error(response.data.msg || '创建失败');
                }
            } catch (error) {
                console.error('提交失败:', error)
        console.error('提交失败:', error);
                if (error.message.includes('验证未通过')) {
                    this.$message.warning('请填写完整的工单信息')
          this.$message.warning('请填写完整的工单信息');
                } else {
                    this.$message.error(error.message || '工单创建失败,请稍后重试')
          this.$message.error(error.message || '工单创建失败,请稍后重试');
                }
            }
        },
@@ -914,64 +903,64 @@
                    updateUser: this.form.handler || undefined,
                    createDept: this.form.department || undefined,
                    isDraft: 1
                }
        };
                // 草稿时也至少需要工单名称
                if (!submitData.eventName) {
                    this.$message.warning('请至少输入工单名称')
                    return
          this.$message.warning('请至少输入工单名称');
          return;
                }
                // 过滤掉所有 undefined 的字段
                Object.keys(submitData).forEach(key =>
                    submitData[key] === undefined && delete submitData[key]
                )
        );
                let file = null
        let file = null;
                if (this.form.photos && this.form.photos.length > 0) {
                    file = this.form.photos[0].raw
          file = this.form.photos[0].raw;
                }
                const response = await createTicket(submitData, file)
        const response = await createTicket(submitData, file);
                if (response.data.code === 0) {
                    this.$message.success('草稿保存成功')
                    this.dialogVisible = false
                    this.fetchTableData()
          this.$message.success('草稿保存成功');
          this.dialogVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '保存失败')
          throw new Error(response.data.msg || '保存失败');
                }
            } catch (error) {
                console.error('保存草稿失败:', error)
                this.$message.error(error.message || '保存草稿失败,请稍后重试')
        console.error('保存草稿失败:', error);
        this.$message.error(error.message || '保存草稿失败,请稍后重试');
            }
        },
        async handleLocationChange (val) {
            console.log('地图选址返回值:', val)
      console.log('地图选址返回值:', val);
            // 处理 Proxy 对象的值
            let locationValue = val.value
      let locationValue = val.value;
            if (locationValue && locationValue.length >= 3) {
                // 确保我们获取到实际的数组值
                this.form.location = [locationValue[0], locationValue[1]]
                this.form.address = locationValue[2] || ''
        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 = ''
        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`
      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) {
@@ -982,8 +971,8 @@
                "3": "处理中",
                "4": "已完成",
                "5": "已完结"
            }
            return statusTextMap[status] || "未知状态"
      };
      return statusTextMap[status] || "未知状态";
        },
        getStatusTagType (status) {
@@ -994,45 +983,45 @@
                "3": "primary",
                "4": "success",
                "5": "danger",
            }
            return statusMap[status] || "info"
      };
      return statusMap[status] || "info";
        },
        async fetchTabCounts () {
            try {
                const response = await getstatusCount()
                const { statusCount, totalCount, userCount } = response.data.data
        const response = await getstatusCount();
        const { statusCount, totalCount, userCount } = response.data.data;
                console.log('接口返回的状态统计数据:', { statusCount, totalCount, userCount })
        console.log('接口返回的状态统计数据:', { statusCount, totalCount, userCount });
                this.tabs.forEach(tab => {
                    if (tab.name === 'all') {
                        tab.count = totalCount || 0 // 总工单数
            tab.count = totalCount || 0; // 总工单数
                    } else if (tab.name === 'myTickets') {
                        tab.count = userCount || 0 // 我发起的工单数
            tab.count = userCount || 0; // 我发起的工单数
                    } else {
                        tab.count = statusCount[String(tab.value)] || 0 // 根据状态值映射
            tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
                    }
                })
        });
                console.log('更新后的 tabs 数据:', this.tabs)
        console.log('更新后的 tabs 数据:', this.tabs);
            } catch (error) {
                console.error('获取 tab 数据失败:', error)
                this.$message.error('获取 tab 数据失败')
        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 时重新获取数据
      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()
      this.page.currentPage = 1;
      this.fetchTableData();
        },
        handleReset () {
@@ -1043,30 +1032,30 @@
                dateRange: [],
                status: "",
                algorithm: "", // 重置时清空算法筛选
            }
            this.page.currentPage = 1
            this.fetchTableData()
      };
      this.page.currentPage = 1;
      this.fetchTableData();
        },
        async handleCurrentChange (val) {
            console.log('当前页变更:', val)
      console.log('当前页变更:', val);
            // 先更新页码
            this.page.currentPage = val
      this.page.currentPage = val;
            // 等待 DOM 更新后再请求数据
            await this.$nextTick()
            await this.fetchTableData()
      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()
      console.log('每页条数变更:', val);
      this.page.pageSize = val;
      this.page.currentPage = 1; // 重置到第一页
      await this.$nextTick();
      await this.fetchTableData();
        },
        handleAdd () {
            this.dialogVisible = true
      this.dialogVisible = true;
        },
        resetForm () {
@@ -1081,31 +1070,25 @@
                content: '',
                photos: [],
                content: '', // 新增字段,用于存储后端返回的 content
            }
      };
            if (this.$refs.form) {
                this.$refs.form.resetFields()
        this.$refs.form.resetFields();
            }
        },
        formatLocation (location) {
            if (!Array.isArray(location)) {
                return '未知位置'
        return '未知位置';
            }
            return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`
      return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`;
        },
        async handleViewDetail (row) {
            console.log('查看详情数据:', 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()
                    }
                }
            })
        this.$refs.MapContainer.initAddEntity('point',this.currentDetail.location);
      });
            const detailData = {
                ...row,
@@ -1113,72 +1096,72 @@
                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 stepResponse = await getStepInfo(row.orderNumber);
        console.log('接口返回的步骤信息:', stepResponse.data.data);
                const steps = stepResponse.data.data || []
        const steps = stepResponse.data.data || [];
                // 根据接口返回的步骤信息补充处理人和时间
                this.stepInfos = this.fixedStatuses.map(status => {
                    const step = steps.find(s => String(s.status) === String(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)
        console.log('处理后的步骤信息:', this.stepInfos);
                this.currentDetail.status = row.status // 使用行数据中的状态
        this.currentDetail.status = row.status; // 使用行数据中的状态
            } catch (error) {
                console.error('获取步骤信息失败:', 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.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 : ''
      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
      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
      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是因为多了发起任务这一步
      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)
      const areaCode = this.userInfo.detail.areaCode;
      const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
      const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode);
            console.log('区域代码:', subAreaCode)
      console.log('区域代码:', subAreaCode);
            console.log('getAdcodeObj返回值:', {
                完整对象: adcodeObj,
                级别: adcodeObj?.level,
@@ -1186,33 +1169,33 @@
                代码: adcodeObj?.adcode,
                中心点: adcodeObj?.center,
                边界: adcodeObj?.polyline,
            })
      });
            this.$message.info("地图选址功能暂未实现")
      this.$message.info("地图选址功能暂未实现");
        },
        handlePreview (file) {
            this.$message.info(`预览图片:${file.name}`)
      this.$message.info(`预览图片:${file.name}`);
        },
        handleRemove (file) {
            this.$message.info(`移除图片:${file.name}`)
      this.$message.info(`移除图片:${file.name}`);
        },
        refreshChange () {
            if (this.isFetching) return
            this.fetchTableData()
      if (this.isFetching) return;
      this.fetchTableData();
        },
        onLoad () {
            if (this.isFetching) return
            this.fetchTableData()
      if (this.isFetching) return;
      this.fetchTableData();
        },
        async exportData () {
            try {
                this.loading = true
                const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
        this.loading = true;
        const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
                // 使用与查询列表相同的参数构造逻辑
                const params = {
@@ -1226,26 +1209,26 @@
                    end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]) : undefined,
                    current: 1,
                    size: 10
                }
        };
                const response = await getList(params)
        const response = await getList(params);
                if (!response?.data?.data?.records) {
                    throw new Error('接口返回数据格式不正确')
          throw new Error('接口返回数据格式不正确');
                }
                const { records } = response.data.data
        const { records } = response.data.data;
                // 使用与查询列表相同的过滤逻辑
                let filteredRecords = records
        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
          const longitude = Number(item.longitude) || 0;
          const latitude = Number(item.latitude) || 0;
                    return {
                        工单编号: item.event_num || '',
                        工单名称: item.event_name || '',
@@ -1258,12 +1241,12 @@
                        创建人: item.create_user || '',
                        处理人: item.update_user || '',
                        工单状态: this.mapStatus(Number(item.status || 0))
                    }
                })
          };
        });
                if (exportData.length === 0) {
                    this.$message.warning('没有数据可供导出')
                    return
          this.$message.warning('没有数据可供导出');
          return;
                }
                const headers = [
@@ -1278,52 +1261,52 @@
                    '创建人',
                    '处理人',
                    '工单状态'
                ]
        ];
                export_json_to_excel(headers, exportData, '工单数据')
                this.$message.success('数据导出成功')
        export_json_to_excel(headers, exportData, '工单数据');
        this.$message.success('数据导出成功');
            } catch (error) {
                console.error('导出失败:', error)
                this.$message.error(error.message || '导出失败,请稍后重试')
        console.error('导出失败:', error);
        this.$message.error(error.message || '导出失败,请稍后重试');
            } finally {
                this.loading = false
        this.loading = false;
            }
        },
        handleDepartmentChange (deptId) {
            this.form.handler = ''
      this.form.handler = '';
        },
        handleDispatchDepartmentChange (deptId) {
            this.dispatchForm.handler = '' // 清空处理人选择
      this.dispatchForm.handler = ''; // 清空处理人选择
        },
        // 文件改变时的钩子
        handleFileChange (file, fileList) {
            this.form.photos = fileList
            this.currentDetail.photos = fileList
      this.form.photos = fileList;
      this.currentDetail.photos = fileList;
        },
        // 文件移除时的钩子
        handleUploadRemove (file, fileList) {
            this.form.photos = fileList
            this.currentDetail.photos = fileList
      this.form.photos = fileList;
      this.currentDetail.photos = fileList;
        },
        // 上传前的验证
        beforeUpload (file) {
            const isImage = file.type.includes('image')
            const isLt5M = file.size / 1024 / 1024 < 5
      const isImage = file.type.includes('image');
      const isLt5M = file.size / 1024 / 1024 < 5;
            if (!isImage) {
                this.$message.error('只能上传图片文件!')
                return false
        this.$message.error('只能上传图片文件!');
        return false;
            }
            if (!isLt5M) {
                this.$message.error('图片大小不能超过5MB!')
                return false
        this.$message.error('图片大小不能超过5MB!');
        return false;
            }
            return true
      return true;
        },
        async approveTicket () {
@@ -1337,21 +1320,21 @@
                    eventType: this.currentDetail.type, // 工单类型
                    departmentId: this.dispatchForm.department, // 派发部门 ID
                    handlerId: this.dispatchForm.handler, // 处理人 ID
                }
        };
                const file = this.currentDetail.file || null // 如果没有文件,则为 null
        const file = this.currentDetail.file || null; // 如果没有文件,则为 null
                const response = await flowEvent(data, file)
        const response = await flowEvent(data, file);
                if (response.data.code === 0) {
                    this.$message.success('工单已通过')
                    this.detailVisible = false
                    this.fetchTableData()
          this.$message.success('工单已通过');
          this.detailVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '操作失败')
          throw new Error(response.data.msg || '操作失败');
                }
            } catch (error) {
                console.error('通过操作失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
        console.error('通过操作失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
            }
        },
        async rejectTicket () {
@@ -1360,25 +1343,25 @@
                    id: this.currentDetail.id,
                    status: this.currentDetail.status,
                    isPass: 1, // 1 表示不通过
                }
        };
                const response = await flowEvent(data)
        const response = await flowEvent(data);
                if (response.data.code === 0) {
                    this.$message.success('工单未通过')
                    this.detailVisible = false
                    this.fetchTableData()
          this.$message.success('工单未通过');
          this.detailVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '操作失败')
          throw new Error(response.data.msg || '操作失败');
                }
            } catch (error) {
                console.error('不通过操作失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
        console.error('不通过操作失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
            }
        },
        async submitProcessing () {
            if (this.currentDetail.status !== 3) {
                this.$message.warning('只有处理中状态的工单可以提交处理详情')
                return
        this.$message.warning('只有处理中状态的工单可以提交处理详情');
        return;
            }
@@ -1387,32 +1370,32 @@
                    id: this.currentDetail.id, // 当前工单 ID
                    status: this.currentDetail.status, // 当前工单状态
                    processing_details: this.currentDetail.processingDetail, // 事件处理详情
                }
        };
                // 如果有图片,添加 file 参数
                const file = this.currentDetail.photos?.[0]?.raw || null
        const file = this.currentDetail.photos?.[0]?.raw || null;
                const response = await flowEvent(data, file)
        const response = await flowEvent(data, file);
                if (response.data.code === 0) {
                    this.$message.success('处理详情提交成功')
                    this.detailVisible = false
                    this.fetchTableData()
          this.$message.success('处理详情提交成功');
          this.detailVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '提交失败')
          throw new Error(response.data.msg || '提交失败');
                }
            } catch (error) {
                console.error('处理详情提交失败:', error)
                this.$message.error(error.message || '提交失败,请稍后重试')
        console.error('处理详情提交失败:', error);
        this.$message.error(error.message || '提交失败,请稍后重试');
            }
        },
        markAsCompleted () {
            this.$message.success("工单已标记为完成")
      this.$message.success("工单已标记为完成");
        },
        async completeTicket () {
            try {
                if (!this.currentDetail.processingDetail) {
                    this.$message.warning('请先填写事件处理详情')
                    return
          this.$message.warning('请先填写事件处理详情');
          return;
                }
                const data = {
@@ -1420,27 +1403,27 @@
                    status: this.currentDetail.status,
                    processingDetails: this.currentDetail.processingDetail,
                    eventNum: this.currentDetail.orderNumber
                }
        };
                // 如果有上传的图片,添加到请求中
                const file = this.currentDetail.photos?.[0]?.raw || null
        const file = this.currentDetail.photos?.[0]?.raw || null;
                const response = await flowEvent(data, file)
        const response = await flowEvent(data, file);
                if (response.data.code === 0) {
                    this.$message.success('工单已完成')
                    this.detailVisible = false
                    this.fetchTableData() // 刷新列表数据
          this.$message.success('工单已完成');
          this.detailVisible = false;
          this.fetchTableData(); // 刷新列表数据
                } else {
                    throw new Error(response.data.msg || '操作失败')
          throw new Error(response.data.msg || '操作失败');
                }
            } catch (error) {
                console.error('完成工单失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
        console.error('完成工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
            }
        },
        async approveAndDispatch () {
            this.dispatchDialogVisible = true // 打开派发对话框
      this.dispatchDialogVisible = true; // 打开派发对话框
        },
        async submitDispatch () {
            this.$refs.dispatchForm.validate(async (valid) => {
@@ -1456,81 +1439,81 @@
                            content: this.currentDetail.content, // 使用 content 替代原来的 remark
                            createDept: this.dispatchForm.department, // 派发部门 ID
                            updateUser: this.dispatchForm.handler, // 处理人 ID
                        }
            };
                        const file = this.currentDetail.file || null // 如果没有文件,则为 null
            const file = this.currentDetail.file || null; // 如果没有文件,则为 null
                        const response = await flowEvent(data, file)
            const response = await flowEvent(data, file);
                        if (response.data.code === 0) {
                            this.$message.success('工单已成功派发')
                            this.dispatchDialogVisible = false
                            this.detailVisible = false
                            this.fetchTableData()
              this.$message.success('工单已成功派发');
              this.dispatchDialogVisible = false;
              this.detailVisible = false;
              this.fetchTableData();
                        } else {
                            throw new Error(response.data.msg || '派发失败')
              throw new Error(response.data.msg || '派发失败');
                        }
                    } catch (error) {
                        console.error('派发失败:', error)
                        this.$message.error(error.message || '派发失败,请稍后重试')
            console.error('派发失败:', error);
            this.$message.error(error.message || '派发失败,请稍后重试');
                    }
                }
            })
      });
        },
        async finalizeTicket () {
            try {
                // 检查是否上传了图片
                if (!this.currentDetail.photos || !this.currentDetail.photos.length) {
                    this.$message.warning('请上传处理图片')
                    return
          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 file = this.currentDetail.photos[0].raw;
                const response = await flowEvent(data, file)
        const response = await flowEvent(data, file);
                if (response.data.code === 0) {
                    this.$message.success('工单已完结')
                    this.detailVisible = false
                    this.fetchTableData()
          this.$message.success('工单已完结');
          this.detailVisible = false;
          this.fetchTableData();
                } else {
                    throw new Error(response.data.msg || '操作失败')
          throw new Error(response.data.msg || '操作失败');
                }
            } catch (error) {
                console.error('完结工单失败:', error)
                this.$message.error(error.message || '操作失败,请稍后重试')
        console.error('完结工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
            }
        },
        // 添加编辑方法
        handleEdit (row) {
            console.log('编辑原始数据:', row)
      console.log('编辑原始数据:', row);
            // 尝试从row.dept_id或通过部门名称查找对应的部门ID
            let deptId = row.dept_id  // 优先使用原始数据中的dept_id
      let deptId = row.dept_id;  // 优先使用原始数据中的dept_id
            // 如果没有dept_id,则通过部门名称查找
            if (!deptId) {
                // 输出所有可用的部门数据用于调试
                console.log('可用部门列表:', this.departments)
                console.log('当前部门名称:', row.department)
        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
        );
        deptId = deptInfo?.value;
            }
            // 获取工单类型值 - 从types中找到匹配的值
            const typeValue = this.types.find(t => t.label === row.type)?.value || row.event_dict_key
      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
      const handlerId = this.userNameToIdMap[row.handler] || row.handler;
            console.log('数据映射:', {
                部门名称: row.department,
@@ -1539,7 +1522,7 @@
                处理人ID: handlerId,
                原始工单类型: row.type,
                映射后类型值: typeValue
            })
      });
            this.form = {
                id: row.id,
@@ -1552,17 +1535,17 @@
                address: row.address,
                content: row.content,
                photos: [],
            }
      };
            // 如果有图片,添加到表单中
            if (row.photo_url) {
                this.form.photos = [{
                    name: 'existing-photo',
                    url: row.photo_url
                }]
        }];
            }
            this.dialogVisible = true
      this.dialogVisible = true;
        },
        // 添加删除方法
        handleDelete (row) {
@@ -1576,22 +1559,22 @@
                        id: row.id,
                        status: 0,
                        isDelete: 1
                    })
          });
                    if (response.data.code === 0) {
                        this.$message.success('删除成功')
                        this.fetchTableData()
            this.$message.success('删除成功');
            this.fetchTableData();
                    } else {
                        throw new Error(response.data.msg || '删除失败')
            throw new Error(response.data.msg || '删除失败');
                    }
                } catch (error) {
                    console.error('删除失败:', error)
                    this.$message.error(error.message || '删除失败,请稍后重试')
          console.error('删除失败:', error);
          this.$message.error(error.message || '删除失败,请稍后重试');
                }
            }).catch(() => { })
      }).catch(() => { });
        },
    },
}
};
</script>
<style lang="scss" scoped>
@@ -1691,8 +1674,9 @@
    }
    .location-wrapper {
    width: 550px;
    height: 30px;
        .map-button {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;