无人机管理后台前端(已迁走)
shuishen
2025-04-15 7d384f8f946dd081962bd76fc8873ec6f26d2c9e
地图航线显示相关处理
3 files modified
1 files added
909 ■■■■■ changed files
.env.development 2 ●●●●● patch | view | raw | blame | history
src/components/map-container/mapContainer.vue 6 ●●●● patch | view | raw | blame | history
src/utils/cesium/kmz.js 238 ●●●●● patch | view | raw | blame | history
src/views/tickets/orderLog.vue 663 ●●●●● patch | view | raw | blame | history
.env.development
@@ -14,3 +14,5 @@
# 域名
VITE_APP_AREA_NAME =  wss://wrj.shuixiongit.com
# 航线文件地址
VITE_APP_AIRLINE_URL = https://wrj.shuixiongit.com/minio/cloud-bucket
src/components/map-container/mapContainer.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:07:51
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2025-04-14 23:09:33
 * @LastEditTime: 2025-04-15 21:54:01
 * @FilePath: \drone-web-manage\src\components\map-container\mapContainer.vue
 * @Description: 
 * 
@@ -100,6 +100,8 @@
 * @param data 数据  数据格式 [lng, lat]
 */
function addPoint (data) {
    if (pointLayer) pointLayer.clear()
    const [lng, lat] = data
    if (!lng || !lat) return
@@ -117,6 +119,8 @@
 * @param data 数据  数据格式 [[lng, lat], [lng, lat], [lng, lat]]
 */
function addPolyline (data) {
    if (polylineLayer) polylineLayer.clear()
    if (data.length === 0) return
    const positionStr = data.map(item => {
src/utils/cesium/kmz.js
New file
@@ -0,0 +1,238 @@
import axios from 'axios'
import JsZip from 'jszip'
const noWmpl = ['Folder', 'Placemark', 'Point', 'coordinates']
/**
 * @description: 读取kmz文件解析出kml文件
 * @param {string} filePath 文件地址
 * @return {*}
 */
export const analyzeKmzFile = filePath => {
    return (
        axios({
            url: filePath,
            method: 'get',
            responseType: 'arraybuffer',
            authorization: false,
        })
            // .get(filePath, { responseType: 'arraybuffer' },)
            .then(fileRes => fileRes.data)
            .then(kmzData => JsZip.loadAsync(kmzData)) // 解压kmz文件
            .then(zipFile => {
                const files = {}
                Object.keys(zipFile.files).forEach(key => {
                    files[key] = zipFile.files[key].async('text')
                })
                return {
                    zip: zipFile,
                    fileInfoObj: files,
                }
            })
    )
}
export const getKmlParams = (source, isWpml, params) => {
    let regx = null
    if (isWpml) {
        if (params.mode) {
            regx = new RegExp(
                `<wpml:${params.name}>${params.findRegx}<\\/wpml:${params.name}>`,
                params.mode
            )
        } else {
            regx = new RegExp(`<wpml:${params.name}>${params.findRegx}<\\/wpml:${params.name}>`)
        }
    } else {
        if (params.mode) {
            regx = new RegExp(`<${params.name}>${params.findRegx}<\\/${params.name}>`, params.mode)
        } else {
            regx = new RegExp(`<${params.name}>${params.findRegx}<\\/${params.name}>`)
        }
    }
    return source?.match(regx)
}
export const generateKmlFormat = settingParmas => {
    let paramGroup = ''
    Object.keys(settingParmas).forEach(key => {
        if (Object.prototype.toString.call(settingParmas[key]) === '[object Object]') {
            let parmaStr = ''
            Object.keys(settingParmas[key]).forEach(v => {
                const xml = noWmpl.includes(key)
                    ? `<${v}>${settingParmas[key][v]}</${v}>`
                    : `<wpml:${v}>${settingParmas[key][v]}</wpml:${v}>`
                parmaStr += xml
            })
            const xml = noWmpl.includes(key)
                ? `<${key}>${parmaStr}</${key}>`
                : `<wpml:${key}>${parmaStr}</wpml:${key}>`
            paramGroup += xml
        } else {
            const xml = noWmpl.includes(key)
                ? `<${key}>${settingParmas[key]}</${key}>`
                : `<wpml:${key}>${settingParmas[key]}</wpml:${key}>`
            paramGroup += xml
        }
    })
    return paramGroup
}
/**
 * @description: JSON转XML
 * @param {any} obj 要转换的对象
 * @param {string} rootName xml根节点名称
 * @return {*} string
 */
export const JSONToXML = (obj, rootName, isEnd) => {
    let xml = ''
    const buildXml = (obj, rootName) => {
        let xml = ''
        if (Array.isArray(obj)) {
            obj.forEach(item => {
                const str = !noWmpl.includes(rootName) && isEnd ? 'wpml:' : ''
                xml += `<${str}${rootName}>${buildXml(item)}</${str}${rootName}>`
            })
        } else if (typeof obj === 'object') {
            Object.keys(obj).forEach(key => {
                if (key === '#text') {
                    xml += obj[key]
                } else {
                    const str = !noWmpl.includes(key) && isEnd ? 'wpml:' : ''
                    if (key === 'Placemark') {
                        xml += `${buildXml(obj[key], key)}`
                    } else if (key === 'action') {
                        if (Array.isArray(obj[key])) {
                            xml += `${buildXml(obj[key], key)}`
                        } else {
                            xml += `<${str}${key}>${buildXml(obj[key], key)}</${str}${key}>`
                        }
                    } else {
                        xml += `<${str}${key}>${buildXml(obj[key], key)}</${str}${key}>`
                    }
                }
            })
        } else {
            xml += obj
        }
        return xml
    }
    const header = isEnd ? '<?xml version="1.0" encoding="UTF-8"?>' : ''
    xml += `${header}
  <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:wpml="http://www.dji.com/wpmz/1.0.5">
    <Document>
      ${buildXml(obj, rootName)}
    </Document>
  </kml>`
    return xml
}
export const getTagNameFromXml = xmlString => {
    const parser = new DOMParser()
    const xmlDoc = parser.parseFromString(xmlString, 'text/xml')
    const element = xmlDoc.documentElement
    if (element && element.tagName) {
        return element.tagName // 返回的是类似 "WPML:USEGLOBALHEADINGPARAM" 的全大写形式
    }
    return null
}
// 将xml转为json
const deepParse = xml => {
    let obj = {}
    // 如果是文档节点,遍历其子节点
    if (xml.nodeType === 1) {
        // element node
        // 处理子节点
        if (xml.childNodes.length > 0) {
            for (let i = 0; i < xml.childNodes.length; i++) {
                const item = xml.childNodes[i]
                const nodeName = item.nodeName.replace('wpml:', '')
                // 检查是否是文本节点
                if (item.nodeType === 3) {
                    // text node
                    // 处理文本节点的内容
                    if (item.nodeValue.trim() !== '') {
                        obj[nodeName] = item.nodeValue.trim()
                    }
                } else if (item.nodeType === 1) {
                    // element node
                    // 递归调用处理子节点
                    if (obj[nodeName] === undefined) {
                        const nodeValue = deepParse(item)
                        if (nodeValue[nodeName] === undefined) {
                            obj[nodeName] = nodeValue
                        } else {
                            obj[nodeName] = nodeValue[nodeName]
                        }
                    } else {
                        if (!obj[nodeName].push) {
                            const old = obj[nodeName]
                            obj[nodeName] = []
                            obj[nodeName].push(old)
                        }
                        const nodeValue = deepParse(item)
                        if (nodeValue[nodeName] === undefined) {
                            obj[nodeName].push(nodeValue)
                        }
                    }
                }
            }
        }
    } else if (xml.nodeType === 3) {
        // text node
        // 处理文本节点的内容
        obj = xml.nodeValue.trim()
    }
    return obj
}
/**
 * @description: XML转JSON
 * @param {string} xmlStr xml字符串
 * @return {*} string
 */
export const XMLToJSON = xmlStr => {
    const parser = new DOMParser()
    const xmlDoc = parser.parseFromString(xmlStr, 'text/xml')
    const xmlObj = deepParse(xmlDoc.documentElement)
    if (Reflect.has(xmlObj, 'Document')) {
        return xmlObj
    } else {
        return {
            Document: xmlObj,
        }
    }
}
export function removeTextKey(obj) {
    if (typeof obj !== 'object' || obj === null) {
        // 如果是数值字符串,转换为数值
        if (typeof obj === 'string' && /^-?\d+(\.\d+)?$/.test(obj)) {
            return Number(obj);
        }
        return obj;
    }
    if (Array.isArray(obj)) {
        return obj.map(item => removeTextKey(item));
    }
    if (Object.prototype.hasOwnProperty.call(obj, '#text')) {
        // 如果 #text 的值是数值字符串,转换为数值
        const textValue = obj['#text'];
        return typeof textValue === 'string' && /^-?\d+(\.\d+)?$/.test(textValue) ? Number(textValue) : textValue;
    }
    const newObj = {};
    for (const key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
            newObj[key] = Object.keys(obj[key]).length === 0 ? '' : removeTextKey(obj[key]);
        }
    }
    return newObj;
}
src/views/tickets/orderLog.vue
@@ -1,125 +1,61 @@
<!--
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2025-04-15 20:02:29
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2025-04-15 21:56:14
 * @FilePath: \drone-web-manage\src\views\tickets\orderLog.vue
 * @Description:
 *
 * Copyright (c) 2025 by shuishen, All Rights Reserved.
-->
<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"
      >
            <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.key_word"
              placeholder="输入工单编号/名称/内容/姓名"
              class="filter-item"
              clearable
              @keyup.enter="handleSearch"
            />
                        <el-input v-model="filters.key_word" placeholder="输入工单编号/名称/内容/姓名" class="filter-item" clearable
                            @keyup.enter="handleSearch" />
            <el-select
              placeholder="请选择所属单位"
              v-model="filters.create_dept"
              @change="handleDepartmentChange"
              class="filter-item"
              clearable
            >
              <el-option
                v-for="dept in departments"
                :key="dept.value"
                :label="dept.label"
                :value="dept.value"
              />
                        <el-select placeholder="请选择所属单位" v-model="filters.create_dept" @change="handleDepartmentChange"
                            class="filter-item" clearable>
                            <el-option v-for="dept in departments" :key="dept.value" :label="dept.label"
                                :value="dept.value" />
            </el-select>
            <el-date-picker
              v-model="filters.dateRange"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              class="filter-item"
              style="width: 100px"
            />
            <el-select
              v-model="filters.file_id"
              placeholder="请选择关联航线"
              class="filter-item"
              clearable
            >
              <el-option
                v-for="item in wayLineList"
                :key="item.wayline_id"
                :label="item.name"
                :value="item.wayline_id"
              />
                        <el-date-picker v-model="filters.dateRange" type="datetimerange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期" class="filter-item" style="width: 100px" />
                        <el-select v-model="filters.file_id" placeholder="请选择关联航线" class="filter-item" clearable>
                            <el-option v-for="item in wayLineList" :key="item.wayline_id" :label="item.name"
                                :value="item.wayline_id" />
            </el-select>
            <el-select
              v-model="filters.ai_types"
              placeholder="关联算法"
              class="filter-item"
              clearable
            >
              <el-option
                v-for="item in ai_types"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="item.dictKey"
              />
                        <el-select v-model="filters.ai_types" placeholder="关联算法" class="filter-item" clearable>
                            <el-option v-for="item in ai_types" :key="item.dictKey" :label="item.dictValue"
                                :value="item.dictKey" />
            </el-select>
            <el-select
              v-model="filters.type"
              placeholder="请选择工单类型"
              class="filter-item"
              clearable
            >
              <el-option
                v-for="item in types"
                :key="item.dictValue"
                :label="item.dictValue"
                :value="item.dictKey"
              />
                        <el-select v-model="filters.type" placeholder="请选择工单类型" class="filter-item" clearable>
                            <el-option v-for="item in types" :key="item.dictValue" :label="item.dictValue"
                                :value="item.dictKey" />
            </el-select>
            <el-select
              v-model="filters.status"
              placeholder="请选择工单状态"
              class="filter-item"
              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" clearable>
                            <el-option v-for="item in statuses" :key="item.value" :label="item.label"
                                :value="item.value" />
       
           </el-select>
              <el-date-picker
              v-model="filters.cycleDateRange"
              type="datetimerange"
              range-separator="至"
              start-placeholder="工单周期开始日期"
              end-placeholder="工单周期结束时间日期"
              class="filter-item"
              style="width: 240px !important"
            />
                        <el-date-picker v-model="filters.cycleDateRange" type="datetimerange" range-separator="至"
                            start-placeholder="工单周期开始日期" end-placeholder="工单周期结束时间日期" class="filter-item"
                            style="width: 240px !important" />
              <el-select v-model="filters.rep_fre_type" placeholder="请选择频次"  class="filter-item">
              <el-option v-for="item in cycles" :key="item" :label="item" :value="item" />
            </el-select>
            <el-time-picker
              style="width: 100px"
              v-model="filters.deal_time"
              placeholder="请选择执行时间"
              prop="deal_time"
              value-format="HH:mm"
              :picker-options="{
                        <el-time-picker style="width: 100px" v-model="filters.deal_time" placeholder="请选择执行时间"
                            prop="deal_time" value-format="HH:mm" :picker-options="{
                selectableRange: '00:00 - 23:59',
              }"
            />
                            }" />
              <el-col :span="8">
              </el-col>
            <el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
@@ -127,48 +63,31 @@
          </div>
          <!-- 表格部分 -->
          <avue-crud
            :data="tableData"
            :option="option"
            v-model:page="page"
            ref="crud"
            :table-loading="loading"
            @current-change="currentChange"
            @refresh-change="refreshChange"
            @on-load="onLoad"
            @search-change="searchChange"
            @size-change="sizeChange"
          >
                    <avue-crud :data="tableData" :option="option" v-model:page="page" ref="crud"
                        :table-loading="loading" @current-change="currentChange" @refresh-change="refreshChange"
                        @on-load="onLoad" @search-change="searchChange" @size-change="sizeChange">
            <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
              >
                            <el-button type="success" plain icon="el-icon-download" @click="exportData">导出</el-button>
            </template>
            <template #menu="{ row }">
              <div v-if="row.status == 1 && userInfo.user_id != row.create_user">
                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)"
                  >审核</el-button
                >
                                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">审核</el-button>
              </div>
              <div v-if="userInfo.user_id == row.create_user">
                <!--待审核状态-->
                <div v-if="row.status == 1">
                  <el-button type="text" icon="el-icon-view" @click="orderLogRecall(row.id)"
                    >撤回</el-button
                  >
                                    <el-button type="text" icon="el-icon-view"
                                        @click="orderLogRecall(row.id)">撤回</el-button>
                </div>
                <!--已驳回-->
                <div v-if="row.status == 2">
                  <el-button type="text" icon="el-icon-view" @click="rejectDetail(row.id)"
                    >驳回原因</el-button
                  >
                                    <el-button type="text" icon="el-icon-view"
                                        @click="rejectDetail(row.id)">驳回原因</el-button>
                </div>
                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)"
                  >详情</el-button
                >
                                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
              </div>
            </template>
            <template #status="{ row }">
@@ -185,13 +104,7 @@
    </el-tabs>
    <!-- 新建工单对话框 -->
    <el-dialog
      v-model="dialogVisible"
      title="新建工单"
      width="70%"
      :close-on-click-modal="false"
      @close="resetForm"
    >
        <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="100px">
        <el-row :gutter="20">
          <el-col :span="12">
@@ -202,12 +115,8 @@
          <el-col :span="12">
            <el-form-item label="关联航线" prop="file_id">
              <el-select v-model="form.file_id" placeholder="请选择航线" @change="getFlyingNestBy">
                <el-option
                  v-for="item in wayLineList"
                  :key="item.wayline_id"
                  :label="item.name"
                  :value="item.wayline_id"
                />
                                <el-option v-for="item in wayLineList" :key="item.wayline_id" :label="item.name"
                                    :value="item.wayline_id" />
              </el-select>
            </el-form-item>
          </el-col>
@@ -216,24 +125,16 @@
          <el-col :span="12">
            <el-form-item label="关联机巢" prop="device_sns">
              <el-select v-model="form.device_sns" placeholder="请选择机巢" multiple>
                <el-option
                  v-for="item in device_sns"
                  :key="item.device_sn"
                  :label="item.nickname"
                  :value="item.device_sn"
                />
                                <el-option v-for="item in device_sns" :key="item.device_sn" :label="item.nickname"
                                    :value="item.device_sn" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关联算法" prop="ai_types">
              <el-select v-model="form.ai_types" placeholder="请选择关联算法" multiple>
                <el-option
                  v-for="item in ai_types"
                  :key="item.dictKey"
                  :label="item.dictValue"
                  :value="item.dictKey"
                />
                                <el-option v-for="item in ai_types" :key="item.dictKey" :label="item.dictValue"
                                    :value="item.dictKey" />
              </el-select>
            </el-form-item>
          </el-col>
@@ -242,25 +143,14 @@
        <el-row :gutter="20">
          <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="6">
            <el-form-item label="周期频次" prop="date_range">
              <el-date-picker
                v-model="form.date_range"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                class="date-picker"
              />
                            <el-date-picker v-model="form.date_range" type="daterange" range-separator="至"
                                start-placeholder="开始日期" end-placeholder="结束日期" class="date-picker" />
            </el-form-item>
            <el-button type="danger" @click="submitForm(1)">发布</el-button>
@@ -273,22 +163,17 @@
          </el-col>
          <el-col :span="3">
            <el-time-picker
              style="width: 100px"
              v-model="form.deal_time"
              prop="deal_time"
              value-format="HH:mm"
              :picker-options="{
                        <el-time-picker style="width: 100px" v-model="form.deal_time" prop="deal_time"
                            value-format="HH:mm" :picker-options="{
                selectableRange: '00:00 - 23:59',
              }"
            />
                            }" />
          </el-col>
        </el-row>
          <el-row :gutter="20" style="height: 400px">
          <el-col :span="24">
              这里放地图
                        <map-container v-if='dialogVisible' ref="MapContainer"></map-container>
          </el-col>
          
          </el-row>
@@ -296,23 +181,13 @@
    </el-dialog>
    <!-- 工单详情对话框 -->
    <el-dialog
      v-model="detailVisible"
      title="工单详情"
      width="70%"
      :close-on-click-modal="false"
      @close="resetForm"
    >
        <el-dialog v-model="detailVisible" title="工单详情" width="70%" :close-on-click-modal="false" @close="resetForm">
      <el-form :model="form" ref="form" label-width="100px">
        <div class="custom-steps-container">
          <!-- 标题行 -->
          <div class="steps-titles">
            <div
              v-for="(record, index) in form.record_list"
              :class="{ active: record.user_id >= 0 }"
              :key="index"
              class="step-title"
            >
                        <div v-for="(record, index) in form.record_list" :class="{ active: record.user_id >= 0 }"
                            :key="index" class="step-title">
              {{ record.status_str }}
            </div>
          </div>
@@ -354,12 +229,8 @@
          <el-col :span="12">
            <el-form-item label="关联航线" prop="file_id">
              <el-select v-model="form.file_id" placeholder="请选择航线" @change="getFlyingNestBy">
                <el-option
                  v-for="item in wayLineList"
                  :key="item.wayline_id"
                  :label="item.name"
                  :value="item.wayline_id"
                />
                                <el-option v-for="item in wayLineList" :key="item.wayline_id" :label="item.name"
                                    :value="item.wayline_id" />
              </el-select>
            </el-form-item>
          </el-col>
@@ -368,24 +239,16 @@
          <el-col :span="12">
            <el-form-item label="关联机巢" prop="device_sns">
              <el-select v-model="form.device_sns" placeholder="请选择机巢" multiple>
                <el-option
                  v-for="item in device_sns"
                  :key="item.device_sn"
                  :label="item.nickname"
                  :value="item.device_sn"
                />
                                <el-option v-for="item in device_sns" :key="item.device_sn" :label="item.nickname"
                                    :value="item.device_sn" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="关联算法" prop="ai_types">
              <el-select v-model="form.ai_types" placeholder="请选择关联算法" multiple>
                <el-option
                  v-for="item in ai_types"
                  :key="item.dictKey"
                  :label="item.dictValue"
                  :value="item.dictKey"
                />
                                <el-option v-for="item in ai_types" :key="item.dictKey" :label="item.dictValue"
                                    :value="item.dictKey" />
              </el-select>
            </el-form-item>
          </el-col>
@@ -394,46 +257,24 @@
        <el-row :gutter="20">
          <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="6">
            <el-form-item label="周期频次" prop="date_range">
              <el-date-picker
                v-model="form.date_range"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                class="date-picker"
              />
                            <el-date-picker v-model="form.date_range" type="daterange" range-separator="至"
                                start-placeholder="开始日期" end-placeholder="结束日期" class="date-picker" />
            </el-form-item>
            <el-button
              type="danger"
                        <el-button type="danger"
              v-if="form.status == 0 || (form.status == 2 && userInfo.user_id == form.create_user)"
              @click="submitForm(1)"
              >发布</el-button
            >
            <el-button
              type="primary"
              v-if="form.status == 1 && userInfo.user_id != form.create_user"
              @click="orderLogPass(form.id)"
              >通过</el-button
            >
            <el-button
              type="danger"
              v-if="form.status == 1 && userInfo.user_id != form.create_user"
              @click="orderLogReject(form.id)"
              >驳回</el-button
            >
                            @click="submitForm(1)">发布</el-button>
                        <el-button type="primary" v-if="form.status == 1 && userInfo.user_id != form.create_user"
                            @click="orderLogPass(form.id)">通过</el-button>
                        <el-button type="danger" v-if="form.status == 1 && userInfo.user_id != form.create_user"
                            @click="orderLogReject(form.id)">驳回</el-button>
          </el-col>
          <el-col :span="3">
            <el-select v-model="form.rep_fre_type" placeholder="请选择频次">
@@ -442,22 +283,17 @@
          </el-col>
          <el-col :span="3">
            <el-time-picker
              style="width: 100px"
              v-model="form.deal_time"
              prop="deal_time"
              value-format="HH:mm"
              :picker-options="{
                        <el-time-picker style="width: 100px" v-model="form.deal_time" prop="deal_time"
                            value-format="HH:mm" :picker-options="{
                selectableRange: '00:00 - 23:59',
              }"
            />
                            }" />
          </el-col>
        </el-row>
         <el-row :gutter="20" style="height: 400px">
          <el-col :span="24">
              这里放地图
                        <map-container v-if='detailVisible' ref="MapContainer"></map-container>
          </el-col>
          
          </el-row>
@@ -475,16 +311,17 @@
  orderLogReject,
  orderLogPass,
  orderLogExport,
} from '@/api/tickets/orderLog';
import { getTicketInfo } from '@/api/tickets/ticket';
import { getDictionary } from '@/api/system/dictbiz';
import { getWaylineFileListByArea } from '@/api/resource/wayline';
import { export_json_to_excel } from '@/utils/exportExcel';
import { getFlyingNestBy } from '@/api/device/device';
import { mapGetters } from 'vuex';
import NProgress from 'nprogress';
import { downloadXls } from '@/utils/util';
import 'nprogress/nprogress.css';
} from '@/api/tickets/orderLog'
import { getTicketInfo } from '@/api/tickets/ticket'
import { getDictionary } from '@/api/system/dictbiz'
import { getWaylineFileListByArea } from '@/api/resource/wayline'
import { export_json_to_excel } from '@/utils/exportExcel'
import { getFlyingNestBy } from '@/api/device/device'
import { mapGetters } from 'vuex'
import NProgress from 'nprogress'
import { downloadXls } from '@/utils/util'
import 'nprogress/nprogress.css'
import { analyzeKmzFile, removeTextKey, XMLToJSON } from '@/utils/cesium/kmz'
export default {
  name: 'TicketPage',
@@ -590,24 +427,24 @@
      loading: false,
      globalCounts: {},
      mapLoaded: false,
    };
        }
  },
  async created() {
    var response = await getDictionary({ code: 'SF' });
    var word_order_typeResponse = await getDictionary({ code: 'WORK_ORDER_TYPE' });
    this.ai_types = response.data.data;
    this.types = word_order_typeResponse.data.data;
        var response = await getDictionary({ code: 'SF' })
        var word_order_typeResponse = await getDictionary({ code: 'WORK_ORDER_TYPE' })
        this.ai_types = response.data.data
        this.types = word_order_typeResponse.data.data
    //获取航线
    this.asyncgetWaylineFileListByArea();
       const response2 = await getTicketInfo();
      const { dept_data, event_type, ai_type } = response2.data.data;
        this.asyncgetWaylineFileListByArea()
        const response2 = await getTicketInfo()
        const { dept_data, event_type, ai_type } = response2.data.data
      this.departments = dept_data.map(item => ({
        label: item.dept_name,
        value: item.id,
      }));
        }))
  },
  mounted() {
    this.fetchTableData();
        this.fetchTableData()
  },
  computed: {
    ...mapGetters(['userInfo']),
@@ -615,85 +452,85 @@
  methods: {
    searchChange(params, done) {
      console.log('searchChange');
      this.query = params;
      this.parentId = '';
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
            console.log('searchChange')
            this.query = params
            this.parentId = ''
            this.page.currentPage = 1
            this.onLoad(this.page, params)
            done()
    },
    async onLoad(page, params = {}) {
      this.loading = true;
            this.loading = true
      getList(
        null,
        this.page.currentPage,
        this.page.pageSize,
        Object.assign(params, this.query)
      ).then(res => {
        this.tableData = res.data.data;
        this.loading = false;
        this.selectionClear();
      });
                this.tableData = res.data.data
                this.loading = false
                this.selectionClear()
            })
   
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
            this.selectionList = []
            this.$refs.crud.toggleSelection()
    },
    async loadAMapScripts() {
      try {
        // await loadAMap();
        // await loadAMapUI();
        this.mapLoaded = true;
                this.mapLoaded = true
      } catch (error) {
        console.error('Failed to load AMap scripts:', error);
        this.$message.error('地图加载失败,请检查网络或API Key配置');
                console.error('Failed to load AMap scripts:', error)
                this.$message.error('地图加载失败,请检查网络或API Key配置')
      }
    },
    formatCycleTime(row) {
      return row.begin_time + '-' + row.end_time +'<br/>'
       +row.rep_rule_type + row.rep_rule_val;
                + row.rep_rule_type + row.rep_rule_val
    },
    async fetchTableData() {
      this.loading = true;
            this.loading = true
      try {
        let params = this.getQueryParam();
        console.log('发送的参数:', params);
        const response = await getList(params, this.page.currentPage, this.page.pageSize);
                let params = this.getQueryParam()
                console.log('发送的参数:', params)
                const response = await getList(params, this.page.currentPage, this.page.pageSize)
        if (!response?.data?.data?.records) {
          throw new Error('接口返回数据格式不正确');
                    throw new Error('接口返回数据格式不正确')
        }
        const { total, records } = response.data.data;
                const { total, records } = response.data.data
        this.tableData = records.map(item => {
          return item;
        });
                    return item
                })
        if (this.activeTab === 'all') {
          this.updateGlobalCounts(records, total);
                    this.updateGlobalCounts(records, total)
        }
        this.page.total = total || 0;
        this.updateTabCounts();
                this.page.total = total || 0
                this.updateTabCounts()
      } 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.loading = false
      }
    },
    getQueryParam() {
      const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
            const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
      if (this.filters.dateRange) {
        console.log(
          'this.formatDate(this.filters.dateRange[0])',
          this.formatDate(this.filters.dateRange[0])
        );
                )
      }
      const params = {
@@ -723,43 +560,43 @@
          deal_time: this.filters.deal_time || undefined,
        current: this.page.currentPage,
        size: this.page.pageSize,
      };
      return params;
            }
            return params
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
            this.page.pageSize = pageSize
    },
    async submitForm(status) {
      this.$refs.form.validate(async valid => {
        if (valid) {
          let dateRange = this.form.date_range;
          console.log('dateRange' + dateRange);
                    let dateRange = this.form.date_range
                    console.log('dateRange' + dateRange)
          this.form.begin_time = this.formatDate(dateRange[0]);
          this.form.end_time = this.formatDate(dateRange[1]);
                    this.form.begin_time = this.formatDate(dateRange[0])
                    this.form.end_time = this.formatDate(dateRange[1])
          const submitData = {
            ...this.form,
            status: status,
          };
          await saveUpdateOrderLog(submitData);
          let id = this.form.id;
                    }
                    await saveUpdateOrderLog(submitData)
                    let id = this.form.id
          if (id) {
            this.$message.success('工单发布成功');
                        this.$message.success('工单发布成功')
          } else {
            this.$message.success('工单创建成功');
                        this.$message.success('工单创建成功')
          }
          this.dialogVisible = false;
                    this.dialogVisible = false
          this.detailVisible = false;
          (this.device_sns = []), (this.wayLineList = []), this.fetchTableData();
                    (this.device_sns = []), (this.wayLineList = []), this.fetchTableData()
        }
      });
            })
    },
    //驳回原因显示
    async rejectDetail(id) {
      const response = await orderLogDetails(id);
      let data = response.data.data;
            const response = await orderLogDetails(id)
            let data = response.data.data
      this.$confirm(data.remark, '驳回原因', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
@@ -767,16 +604,16 @@
      }).then(() => {
        this.form = {
          ...response.data.data,
        };
        this.detailVisible = true;
      });
                }
                this.detailVisible = true
            })
    },
    formatDate(date) {
      if (!date) return undefined;
      const d = new Date(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`;
            ).padStart(2, '0')} 00:00:00`
    },
    mapStatus(status) {
@@ -785,8 +622,8 @@
        1: '待审核',
        2: '已驳回',
        3: '已通过',
      };
      return statusTextMap[status] || '未知状态';
            }
            return statusTextMap[status] || '未知状态'
    },
    getStatusTagType(status) {
@@ -796,20 +633,20 @@
        3: 'primary',
        4: 'success',
        5: 'danger',
      };
      return statusMap[status] || 'info';
            }
            return statusMap[status] || 'info'
    },
    handleTabChange(tab) {
      this.activeTab = tab.props?.name || tab.name;
      this.filters.status = '';
      this.page.currentPage = 1;
      this.fetchTableData();
            this.activeTab = tab.props?.name || tab.name
            this.filters.status = ''
            this.page.currentPage = 1
            this.fetchTableData()
    },
    handleSearch() {
      this.page.currentPage = 1;
      this.fetchTableData();
            this.page.currentPage = 1
            this.fetchTableData()
    },
    handleReset() {
@@ -819,13 +656,13 @@
        type: '',
        dateRange: [],
        status: '',
      };
      this.page.currentPage = 1;
      this.fetchTableData();
            }
            this.page.currentPage = 1
            this.fetchTableData()
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
            this.page.currentPage = currentPage
    },
    updateGlobalCounts(records, total) {
@@ -837,39 +674,39 @@
        completed: 0,
        closed: 0,
        myTickets: 0,
      };
            }
      records.forEach(item => {
        const tab = this.tabs.find(t => t.value === Number(item.status));
                const tab = this.tabs.find(t => t.value === Number(item.status))
        if (tab) {
          counts[tab.name] = (counts[tab.name] || 0) + 1;
                    counts[tab.name] = (counts[tab.name] || 0) + 1
        }
      });
            })
      this.globalCounts = counts;
            this.globalCounts = counts
    },
    updateTabCounts() {
      if (this.activeTab === 'all') {
        this.tabs.forEach(tab => {
          tab.count = this.globalCounts[tab.name] || 0;
        });
                    tab.count = this.globalCounts[tab.name] || 0
                })
      } else {
        this.tabs.forEach(tab => {
          if (tab.name === this.activeTab) {
            tab.count = this.tableData.length;
                        tab.count = this.tableData.length
          } else {
            tab.count = this.globalCounts[tab.name] || 0;
                        tab.count = this.globalCounts[tab.name] || 0
          }
        });
                })
      }
    },
    handleAdd() {
      this.form = {};
      this.dialogVisible = true;
            this.form = {}
            this.dialogVisible = true
      //航线列表
      this.asyncgetWaylineFileListByArea();
            this.asyncgetWaylineFileListByArea()
    },
    resetForm() {
@@ -882,28 +719,29 @@
        address: '',
        content: '',
        photos: [],
      };
            }
      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) {
      const response = await orderLogDetails(row.id);
            const response = await orderLogDetails(row.id)
      this.form = {
        ...response.data.data,
      };
      this.detailVisible = true;
            }
            this.detailVisible = true
      //航线列表
      this.asyncgetWaylineFileListByArea();
      this.device_sns = response.data.data.deviceList;
            this.asyncgetWaylineFileListByArea()
            this.device_sns = response.data.data.deviceList
    },
    //导出
    async exportData() {
@@ -912,32 +750,78 @@
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        NProgress.start();
        let params = this.getQueryParam();
                NProgress.start()
                let params = this.getQueryParam()
        orderLogExport(params).then(res => {
          downloadXls(res.data, `智飞工单${this.$dayjs().format('YYYY-MM-DD')}.xlsx`);
          NProgress.done();
        });
      });
                    downloadXls(res.data, `智飞工单${this.$dayjs().format('YYYY-MM-DD')}.xlsx`)
                    NProgress.done()
                })
            })
    },
    refreshChange() {
      this.fetchTableData();
            this.fetchTableData()
    },
    //获取航线列表
    async asyncgetWaylineFileListByArea(name) {
      var wayLineListResponse = await getWaylineFileListByArea(this.userInfo.detail.areaCode);
      this.wayLineList = wayLineListResponse.data.data;
            var wayLineListResponse = await getWaylineFileListByArea(this.userInfo.detail.areaCode)
            this.wayLineList = wayLineListResponse.data.data
            this.initMapLine()
    },
        initMapLine () {
            let currentLine = this.wayLineList.find(item => item.wayline_id == this.form.file_id)
            if (!currentLine) return
            // 异步解析kmz文件
            const analysis = async url => {
                return new Promise(async resolve => {
                    const res = await analyzeKmzFile(`${url}?_t=${new Date().getTime()}`)
                    const templateXML = await res.fileInfoObj['wpmz/template.kml']
                    const templateXMLJSON = XMLToJSON(templateXML)?.['Document']
                    const templateXMLObj = removeTextKey(templateXMLJSON.Folder)
                    resolve(templateXMLObj)
                })
            }
            const drawLine = async () => {
                let prexUrl = ref(import.meta.env.VITE_APP_AIRLINE_URL + currentLine.object_key)
                const res = await analysis(prexUrl.value)
                if (!res.Placemark.length) return
                renderingLine(res)
            }
            const renderingLine = lineObj => {
                const positions = lineObj.Placemark.map(item => {
                    return item.Point.coordinates.split(',')
                })
                this.$nextTick(() => {
                    if (this.$refs.MapContainer && this.$refs.MapContainer.initAddEntity) {
                        this.$refs.MapContainer.initAddEntity('polyline', positions)
                    }
                })
            }
            drawLine()
        },
    //可飞行机巢列表
    async getFlyingNestBy(waylineId) {
            this.initMapLine()
      //按照航线来
      const params = {
        type: 0,
        waylineId: waylineId,
      };
      var wayLineListResponse = await getFlyingNestBy(params);
      this.device_sns = wayLineListResponse.data.data;
            }
            var wayLineListResponse = await getFlyingNestBy(params)
            this.device_sns = wayLineListResponse.data.data
    },
    //撤回
@@ -947,21 +831,21 @@
        cancelButtonText: '取消',
        type: 'warning',
      }).then(async () => {
        let reposne = await orderLogRecall(id);
        this.handleSearch();
      });
                let reposne = await orderLogRecall(id)
                this.handleSearch()
            })
    },
    onLoad() {
      this.fetchTableData();
            this.fetchTableData()
    },
    /**
     * 通过
     */
    async orderLogPass(id) {
      let response = await orderLogPass(id);
      let data = response.data.data;
      this.$message.success('审核通过');
      this.detailVisible = false;
            let response = await orderLogPass(id)
            let data = response.data.data
            this.$message.success('审核通过')
            this.detailVisible = false
    },
    /**
     * 驳回
@@ -971,23 +855,23 @@
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(async ({ value }) => {
        let response = await orderLogReject(id, value);
        let data = response.data.data;
        this.$message.success('驳回成果');
        this.detailVisible = false;
      });
                let response = await orderLogReject(id, value)
                let data = response.data.data
                this.$message.success('驳回成果')
                this.detailVisible = false
            })
    },
  },
  watch: {
    tableData: {
      handler() {
        this.updateTabCounts();
                this.updateTabCounts()
      },
      deep: true,
    },
  },
};
}
</script>
<style lang="scss" scoped>
@@ -1094,7 +978,8 @@
}
.custom-steps {
  margin-top: -20px; /* 向上移动与标题重叠 */
    margin-top: -20px;
    /* 向上移动与标题重叠 */
}
.el-step__head {