无人机管理后台前端(已迁走)
chenyao
2025-07-30 e41f52fa15319540574081f263d680b3a642cb3f
src/views/tickets/ticket.vue
@@ -98,22 +98,20 @@
          </div>
          <!-- 表格部分 -->
          <avue-crud
            class="ztzf-public-general-avue-crud"
            ref="avueCrud"
            v-model="tableData"
            :option="option"
            :data="tableData"
            v-model:page="page"
            @size-change="sizeChange"
            @current-change="handleCurrentChange"
            @refresh-change="refreshChange"
            :table-loading="loading"
            @selection-change="handleSelectionChange"
            @cell-click="handleCellClick"
            :permission="permissionList"
            v-if="activeTab === tab.name"
          >
          <avue-crud class="ztzf-public-general-avue-crud" ref="avueCrud" v-model="tableData" :option="option"
            :data="tableData" v-model:page="page" @size-change="sizeChange" @current-change="handleCurrentChange"
            @refresh-change="refreshChange" :table-loading="loading" @selection-change="handleSelectionChange"
            :permission="permissionList" v-if="activeTab === tab.name">
            <template #orderNumber="{ row }">
              <el-tooltip-copy :content="row.orderNumber" :showCopyText="true" textAlign="left">
                {{ row.orderNumber }}
              </el-tooltip-copy>
            </template>
            <template #orderName="{ row }">
              <el-tooltip-copy :content="row.orderName" :showCopyText="true" textAlign="left">
                {{ row.orderName }}
              </el-tooltip-copy>
            </template>
            <template #menu-left>
              <el-button
                v-if="(activeTab === 'all' || activeTab === 'myTickets') && permissionList.addBtn"
@@ -210,7 +208,8 @@
            </el-col>
            <el-col :span="12">
              <el-form-item label="工单类型" prop="type">
                <el-select v-model="form.type" placeholder="请选择工单类型" class="full-width">
                <el-select  @change="handleTypeChange" v-model="form.type" placeholder="请选择工单类型" class="full-width" >
                  <el-option
                    v-for="item in types"
                    :key="item.value"
@@ -267,6 +266,7 @@
                  multiple
                  placeholder="请选择关联算法"
                  class="full-width"
                  :disabled="!form.type"
                >
                  <el-option
                    v-for="item in algorithms"
@@ -365,7 +365,9 @@
          <el-button type="infoprimary" plain :loading="draftLoading" @click="saveDraft"
            >存草稿</el-button
          >
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button  @click="handleCancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
@@ -866,17 +868,19 @@
  getStepInfo,
  getReviewById,
  getCreateEventJob,
} from '@/api/tickets/ticket';
import { export_json_to_excel } from '@/utils/exportExcel';
import geoJson from '@/assets/geoJson.json';
import { mapGetters } from 'vuex';
import { getAdcodeObj } from '@/utils/disposeData';
function regExp(label, name) {
  var reg = new RegExp(label + '=([^&]*)(&|$)', 'g');
  return name.match(reg)[0].split('=')[1];
} from '@/api/tickets/ticket'
import { export_json_to_excel } from '@/utils/exportExcel'
import geoJson from '@/assets/geoJson.json'
import { mapGetters } from 'vuex'
import { getAdcodeObj } from '@/utils/disposeData'
import elTooltipCopy from '@/components/ElTooltipCopy.vue'
function regExp (label, name) {
  var reg = new RegExp(label + '=([^&]*)(&|$)', 'g')
  return name.match(reg)[0].split('=')[1]
}
export default {
  components: { elTooltipCopy },
  name: 'TicketPage',
  data() {
    return {
@@ -911,6 +915,7 @@
      },
      departments: [],
      types: [],
      allAlgorithms: [],
      handlers: [
        { label: '处理人A', value: 'handlerA' },
        { label: '处理人B', value: 'handlerB' },
@@ -949,15 +954,15 @@
        column: [
          // { label: "序号", prop: "id", width: 70 },
          { label: '工单编号', prop: 'orderNumber', width: 120, overHidden: true, tooltip: true },
          { label: '工单编号', prop: 'orderNumber', width: 170 },
          { label: '工单名称', prop: 'orderName', width: 150, overHidden: true, tooltip: true },
          { label: '所属单位', prop: 'department', overHidden: true, tooltip: true },
          { label: '所属单位', prop: 'department',width: 150, overHidden: true, tooltip: true },
          { label: '发起时间', prop: 'startTime', width: 160 },
          { label: '关联算法', prop: 'aiType', width: 150, overHidden: true, tooltip: true },
          {
            label: '工单类型',
            prop: 'type',
            width: 130,
            width: 110,
            overHidden: true,
            tooltip: true,
            type: 'select',
@@ -970,8 +975,8 @@
            width: 152,
            overHidden: true,
          },
          { label: '创建人', prop: 'creator', width: 100 },
          { label: '处理人', prop: 'handler', width: 100 },
          { label: '创建人', prop: 'creator', width: 70 },
          { label: '处理人', prop: 'handler', width: 70 },
          {
            slot: true,
            hide: false,
@@ -1131,7 +1136,7 @@
        this.$nextTick(() => {
          this.isShowInfo = true;
        });
        console.log('orderNumber', orderNumber);
      }
    }
@@ -1393,7 +1398,7 @@
        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;
@@ -1479,7 +1484,8 @@
    async fetchDropdownData() {
      try {
        const response = await getTicketInfo();
        const { dept_data, event_type, ai_type } = response.data.data;
        const { dept_data, event_type, ai_type,info } = response.data.data;
        this.departments = dept_data.map(item => ({
          label: item.dept_name,
@@ -1498,16 +1504,19 @@
        const columnType = this.findObject(this.option.column, 'type');
        columnType.dicData = this.types;
        this.allAlgorithms  = info
        // console.log('工单类型',this.types);
        // console.log('关联算法',this.allAlgorithms );
        // 确保算法数据的映射一致
        this.algorithms =
          ai_type?.map(item => ({
            dict_key: item.dict_key,
            dict_value: item.dict_value,
            // 同时添加 label 和 value 以兼容两处使用
            label: item.dict_value,
            value: item.dict_key,
          })) || [];
        // this.algorithms =
        //   ai_type?.map(item => ({
        //     dict_key: item.dict_key,
        //     dict_value: item.dict_value,
        //     // 同时添加 label 和 value 以兼容两处使用
        //     label: item.dict_value,
        //     value: item.dict_key,
        //   })) || [];
        // 构建用户ID和名称的映射关系
        this.userNameToIdMap = {};
@@ -1519,6 +1528,33 @@
      } catch (error) {
        this.$message.error('加载下拉框数据失败');
      }
    },
    // 工单类型变化时触发
    handleTypeChange(typeValue) {
      if (!typeValue) {
        // 未选择类型时清空算法列表
        this.algorithms = [];
        return;
      }
      const matchedCategory = this.allAlgorithms.find(
        category => category.dict_key === typeValue
      );
      if (!matchedCategory || !matchedCategory.algorithms || matchedCategory.algorithms.length === 0) {
        // 无匹配的算法时清空
        this.algorithms = [];
        this.$message.info('该工单类型暂无关联算法');
        return;
      }
      this.algorithms = matchedCategory.algorithms.map(algo => ({
        label: algo.dict_value,
        value: algo.dict_key,
        dict_key: algo.dict_key,
        dict_value: algo.dict_value
      }));
    },
    async fetchTableData() {
@@ -1773,7 +1809,10 @@
        this.draftLoading = false;
      }
    },
    handleCancel (){
      this.resetForm();
       this.dialogVisible = false;
},
    handleLocationChange(val) {
      let locationValue = val.value;
      if (locationValue && locationValue.length >= 2) {
@@ -2434,8 +2473,7 @@
      // 获取工单类型值 - 从types中找到匹配的值
      const typeValue =
        this.types.find(t => t.label === row.type)?.value || row.work_order_type_dict_key;
        this.types.find(t => t.value === row.type)?.value || row.work_order_type_dict_key;
      // 获取处理人ID - 使用userNameToIdMap映射
      const handlerId = this.userNameToIdMap[row.handler] || row.handler;