From 126bde584b7a925650df0183325cff5094bd8ac3 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 10 Apr 2025 18:54:09 +0800
Subject: [PATCH] 示例---获取当前登录账号行政区划对应对象
---
src/views/tickets/orderLog.vue | 1460 +++++++++++++++++++++++++++------------------------------
1 files changed, 698 insertions(+), 762 deletions(-)
diff --git a/src/views/tickets/orderLog.vue b/src/views/tickets/orderLog.vue
index e3ec6bc..26f460a 100644
--- a/src/views/tickets/orderLog.vue
+++ b/src/views/tickets/orderLog.vue
@@ -1,827 +1,763 @@
<template>
- <basic-container>
- <el-tabs v-model="activeTab" @tab-click="handleTabChange">
- <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
- <div class="tab-content">
- <!-- 查询条件筛选栏 -->
- <div class="filter-bar">
- <el-input
- v-model="filters.key_word"
- placeholder="输入工单编号/名称/内容/姓名"
- class="filter-item"
- clearable
- @keyup.enter="handleSearch"
- />
- <el-select
- v-model="filters.create_dept"
- placeholder="请选择所属单位"
- class="filter-item"
- clearable
- >
- <el-option
- v-for="item in departments"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- <el-date-picker
- v-model="filters.dateRange"
- type="daterange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- class="date-picker"
- value-format="yyyy-MM-dd"
- />
-
- </el-select>
+ <basic-container>
+ <el-tabs v-model="activeTab" @tab-click="handleTabChange">
+ <el-tab-pane v-for="tab in tabs" :key="tab.name" :label="`${tab.label} (${tab.count})`" :name="tab.name">
+ <div class="tab-content">
+ <!-- 查询条件筛选栏 -->
+ <div class="filter-bar">
+ <el-input v-model="filters.key_word" placeholder="输入工单编号/名称/内容/姓名" class="filter-item" clearable
+ @keyup.enter="handleSearch" />
+ <el-select v-model="filters.create_dept" placeholder="请选择所属单位" class="filter-item" clearable>
+ <el-option v-for="item in departments" :key="item.value" :label="item.label"
+ :value="item.value" />
+ <el-date-picker v-model="filters.dateRange" type="daterange" range-separator="至"
+ start-placeholder="开始日期" end-placeholder="结束日期" class="date-picker"
+ value-format="yyyy-MM-dd" />
- <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>
- <el-select
- v-model="filters.type"
- placeholder="请选择工单类型"
- class="filter-item"
- clearable
- >
- <el-option
- v-for="item in types"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </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>
- <el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
- <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
- </div>
+ <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>
- <!-- 表格部分 -->
- <avue-crud
- :data="tableData"
- :option="option"
- :page.sync="pagination"
- :table-loading="loading"
- @current-change="handlePaginationChange"
- @size-change="handlePaginationChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- >
- <template #menu-left>
- <el-button
- type="primary"
- icon="el-icon-plus"
- @click="handleAdd"
- >新建工单</el-button>
- <el-button
- type="success"
- plain
- icon="el-icon-download"
- @click="exportData"
- >导出</el-button>
- </template>
- <template #menu="{ row }">
- <el-button
- type="text"
- icon="el-icon-view"
- @click="handleViewDetail(row)"
- >详情</el-button>
- </template>
- <template #status="{ row }">
- <el-tag :type="getStatusTagType(row.status)">{{ mapStatus(row.status) }}</el-tag>
- </template>
- <template #keyData="{ row }">
- <el-tooltip :content="row.address" placement="top" effect="light">
- <span>{{ row.keyData }}</span>
- </el-tooltip>
- </template>
- </avue-crud>
- </div>
- </el-tab-pane>
- </el-tabs>
+ <el-select v-model="filters.type" placeholder="请选择工单类型" class="filter-item" clearable>
+ <el-option v-for="item in types" :key="item.value" :label="item.label"
+ :value="item.value" />
+ </el-select>
- <!-- 新建工单对话框 -->
- <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">
- <el-form-item label="工单名称" prop="name">
- <el-input v-model="form.name" placeholder="请输入工单名称"></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="工单类型" prop="type">
- <el-select v-model="form.type" placeholder="请选择工单类型">
- <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item label="处理人员" prop="handler">
- <el-select v-model="form.handler" placeholder="请选择处理人员">
- <el-option v-for="item in handlers" :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="algorithm">
- <el-select v-model="form.algorithm" placeholder="请选择关联算法">
- <el-option v-for="item in algorithms" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="24">
- <el-form-item label="位置选择">
- <el-button @click="openMap">地图选址</el-button>
- <span v-if="form.location" style="margin-left: 10px;">
- 已选择位置: {{ formatLocation(form.location) }}
- </span>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="24">
- <el-form-item label="工单内容" prop="content">
- <el-input type="textarea" v-model="form.content" rows="4" placeholder="请输入工单内容"></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="24">
- <el-form-item label="上传图片">
- <el-upload
- action="/api/upload"
- list-type="picture-card"
- :on-preview="handleUploadPreview"
- :on-remove="handleUploadRemove"
- :on-success="handleUploadSuccess"
- :on-error="handleUploadError"
- :file-list="form.photos"
- :limit="5"
- :multiple="true"
- accept="image/*"
- :before-upload="beforeUpload"
- >
- <i class="el-icon-plus"></i>
- <div slot="tip" class="el-upload__tip">
- 上传工单相关图片(支持jpg/png格式),最多5张,单张不超过5MB
+ <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-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
+ <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
+ </div>
+
+ <!-- 表格部分 -->
+ <avue-crud :data="tableData" :option="option" :page.sync="pagination" :table-loading="loading"
+ @current-change="handlePaginationChange" @size-change="handlePaginationChange"
+ @refresh-change="refreshChange" @on-load="onLoad">
+ <template #menu-left>
+ <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建工单</el-button>
+ <el-button type="success" plain icon="el-icon-download" @click="exportData">导出</el-button>
+ </template>
+ <template #menu="{ row }">
+ <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)">详情</el-button>
+ </template>
+ <template #status="{ row }">
+ <el-tag :type="getStatusTagType(row.status)">{{ mapStatus(row.status) }}</el-tag>
+ </template>
+ <template #keyData="{ row }">
+ <el-tooltip :content="row.address" placement="top" effect="light">
+ <span>{{ row.keyData }}</span>
+ </el-tooltip>
+ </template>
+ </avue-crud>
</div>
- </el-upload>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer">
- <el-button @click="dialogVisible = false">取消</el-button>
- <el-button type="primary" @click="submitForm">提交</el-button>
- </div>
- </el-dialog>
+ </el-tab-pane>
+ </el-tabs>
- <!-- 工单详情对话框 -->
- <el-dialog v-model="detailVisible" title="工单详情" width="80%" append-to-body>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form label-width="100px">
- <el-form-item label="上传照片">
- <el-upload
- action="/api/upload"
- list-type="picture-card"
- :on-preview="handlePreview"
- :on-remove="handleRemove"
- :file-list="currentDetail.photos"
- >
- <i class="el-icon-plus"></i>
- </el-upload>
- <div class="el-upload__tip">
- 上传相关照片(jpg、jpeg、png),单张不超过5M
- </div>
- </el-form-item>
- </el-form>
- </el-col>
- <el-col :span="12">
- <el-form label-width="100px" class="detail-form">
- <el-form-item label="工单编号">
- <span>{{ currentDetail.orderNumber }}</span>
- </el-form-item>
- <el-form-item label="任务名称">
- <span>{{ currentDetail.orderName }}</span>
- </el-form-item>
- <el-form-item label="工单状态">
- <el-tag :type="getStatusTagType(currentDetail.status)">
- {{ mapStatus(currentDetail.status) }}
- </el-tag>
- </el-form-item>
- <el-form-item label="发起时间">
- <span>{{ currentDetail.startTime }}</span>
- </el-form-item>
- <el-form-item label="发起人">
- <span>{{ currentDetail.creator }}</span>
- </el-form-item>
- <el-form-item label="经纬度">
- <span>{{ currentDetail.keyData }}</span>
- </el-form-item>
- <el-form-item label="详细地址">
- <span>{{ currentDetail.address }}</span>
- </el-form-item>
- </el-form>
- </el-col>
- </el-row>
- <template #footer>
- <el-button @click="detailVisible = false">关闭</el-button>
- </template>
- </el-dialog>
- </basic-container>
+ <!-- 新建工单对话框 -->
+ <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">
+ <el-form-item label="工单名称" prop="name">
+ <el-input v-model="form.name" placeholder="请输入工单名称"></el-input>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="工单类型" prop="type">
+ <el-select v-model="form.type" placeholder="请选择工单类型">
+ <el-option v-for="item in types" :key="item.value" :label="item.label"
+ :value="item.value" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="处理人员" prop="handler">
+ <el-select v-model="form.handler" placeholder="请选择处理人员">
+ <el-option v-for="item in handlers" :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="algorithm">
+ <el-select v-model="form.algorithm" placeholder="请选择关联算法">
+ <el-option v-for="item in algorithms" :key="item.value" :label="item.label"
+ :value="item.value" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24">
+ <el-form-item label="位置选择">
+ <el-button @click="openMap">地图选址</el-button>
+ <span v-if="form.location" style="margin-left: 10px;">
+ 已选择位置: {{ formatLocation(form.location) }}
+ </span>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24">
+ <el-form-item label="工单内容" prop="content">
+ <el-input type="textarea" v-model="form.content" rows="4" placeholder="请输入工单内容"></el-input>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="24">
+ <el-form-item label="上传图片">
+ <el-upload action="/api/upload" list-type="picture-card" :on-preview="handleUploadPreview"
+ :on-remove="handleUploadRemove" :on-success="handleUploadSuccess"
+ :on-error="handleUploadError" :file-list="form.photos" :limit="5" :multiple="true"
+ accept="image/*" :before-upload="beforeUpload">
+ <i class="el-icon-plus"></i>
+ <div slot="tip" class="el-upload__tip">
+ 上传工单相关图片(支持jpg/png格式),最多5张,单张不超过5MB
+ </div>
+ </el-upload>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <div slot="footer">
+ <el-button @click="dialogVisible = false">取消</el-button>
+ <el-button type="primary" @click="submitForm">提交</el-button>
+ </div>
+ </el-dialog>
+
+ <!-- 工单详情对话框 -->
+ <el-dialog v-model="detailVisible" title="工单详情" width="80%" append-to-body>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form label-width="100px">
+ <el-form-item label="上传照片">
+ <el-upload action="/api/upload" list-type="picture-card" :on-preview="handlePreview"
+ :on-remove="handleRemove" :file-list="currentDetail.photos">
+ <i class="el-icon-plus"></i>
+ </el-upload>
+ <div class="el-upload__tip">
+ 上传相关照片(jpg、jpeg、png),单张不超过5M
+ </div>
+ </el-form-item>
+ </el-form>
+ </el-col>
+ <el-col :span="12">
+ <el-form label-width="100px" class="detail-form">
+ <el-form-item label="工单编号">
+ <span>{{ currentDetail.orderNumber }}</span>
+ </el-form-item>
+ <el-form-item label="任务名称">
+ <span>{{ currentDetail.orderName }}</span>
+ </el-form-item>
+ <el-form-item label="工单状态">
+ <el-tag :type="getStatusTagType(currentDetail.status)">
+ {{ mapStatus(currentDetail.status) }}
+ </el-tag>
+ </el-form-item>
+ <el-form-item label="发起时间">
+ <span>{{ currentDetail.startTime }}</span>
+ </el-form-item>
+ <el-form-item label="发起人">
+ <span>{{ currentDetail.creator }}</span>
+ </el-form-item>
+ <el-form-item label="经纬度">
+ <span>{{ currentDetail.keyData }}</span>
+ </el-form-item>
+ <el-form-item label="详细地址">
+ <span>{{ currentDetail.address }}</span>
+ </el-form-item>
+ </el-form>
+ </el-col>
+ </el-row>
+ <template #footer>
+ <el-button @click="detailVisible = false">关闭</el-button>
+ </template>
+ </el-dialog>
+ </basic-container>
</template>
<script>
-import { getList, createTicket, getTicketInfo } from '@/api/tickets/orderLog';
-import { getDictionary } from '@/api/system/dictbiz';
-import { export_json_to_excel } from '@/utils/exportExcel';
+import geoJson from '@/assets/geoJson.json'
+
+import { mapGetters } from 'vuex'
+import { getAdcodeObj } from '@/utils/disposeData'
+import { getList, createTicket, getTicketInfo } from '@/api/tickets/orderLog'
+import { getDictionary } from '@/api/system/dictbiz'
+import { export_json_to_excel } from '@/utils/exportExcel'
export default {
- name: "TicketPage",
- data() {
- return {
- activeTab: "all",
- tabs: [
- { label: "全部工单", name: "all", value: null, count: 0 },
- { label: "待审核", name: "pending", value: 1, count: 0 },
- { label: "已驳回", name: "processing", value: 2, count: 0 },
- { label: "已通过", name: "inProgress", value: 3, count: 0 },
- { label: "草稿", name: "completed", value: 0, count: 0 },
- ],
- filters: {
- key_word: "",
- create_dept: "",
- start_date:null,
- end_date:null,
- file_id: "",
- ai_types: [],
- status: "",
- dateRange:null,
- },
- departments: [],
- types: [],
- ai_types: [],
- handlers: [
- { label: "处理人A", value: "handlerA" },
- { label: "处理人B", value: "handlerB" },
- ],
- algorithms: [
- { label: "算法A", value: "algorithmA" },
- { label: "算法B", value: "algorithmB" },
- ],
- statuses: [
- { label: "草稿", value: "0" },
- { label: "待审核", value: "1" },
- { label: "已驳回", value: "2" },
- { label: "已通过", value: "3" },
- ],
- tableData: [],
- option: {
- border: true,
- stripe: true,
- menuWidth: 150,
- searchMenuSpan: 6,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- menu: true,
- column: [
- { label: "序号", prop: "id", width: 70 },
- { label: "工单编号", prop: "job_info_num", width: 150 },
- { label: "工单名称", prop: "name", width: 150 },
- { label: "所属单位", prop: "dept_name", width: 100 },
- { label: "发起时间", prop: "create_time", width: 160 },
- { label: "工单内容", prop: "content", width: 160 },
- { label: "关联航线", prop: "wayline_name", width: 160 },
- { label: "关联算法", prop: "ai_type_str", width: 180 },
- { label: "创建人", prop: "creator_name", width: 180 },
- { label: "关联机巢", prop: "device_names", width: 108 },
-
- { label: "工单周期凭次", prop: "", width: 108, formatter: (row) => this.formatCycleTime(row)},
- { label: "工单状态", prop: "status", width: 60}
+ name: "TicketPage",
+ data () {
+ return {
+ activeTab: "all",
+ tabs: [
+ { label: "全部工单", name: "all", value: null, count: 0 },
+ { label: "待审核", name: "pending", value: 1, count: 0 },
+ { label: "已驳回", name: "processing", value: 2, count: 0 },
+ { label: "已通过", name: "inProgress", value: 3, count: 0 },
+ { label: "草稿", name: "completed", value: 0, count: 0 },
+ ],
+ filters: {
+ key_word: "",
+ create_dept: "",
+ start_date: null,
+ end_date: null,
+ file_id: "",
+ ai_types: [],
+ status: "",
+ dateRange: null,
+ },
+ departments: [],
+ types: [],
+ ai_types: [],
+ handlers: [
+ { label: "处理人A", value: "handlerA" },
+ { label: "处理人B", value: "handlerB" },
+ ],
+ algorithms: [
+ { label: "算法A", value: "algorithmA" },
+ { label: "算法B", value: "algorithmB" },
+ ],
+ statuses: [
+ { label: "草稿", value: "0" },
+ { label: "待审核", value: "1" },
+ { label: "已驳回", value: "2" },
+ { label: "已通过", value: "3" },
+ ],
+ tableData: [],
+ option: {
+ border: true,
+ stripe: true,
+ menuWidth: 150,
+ searchMenuSpan: 6,
+ viewBtn: false,
+ editBtn: false,
+ delBtn: false,
+ menu: true,
+ column: [
+ { label: "序号", prop: "id", width: 70 },
+ { label: "工单编号", prop: "job_info_num", width: 150 },
+ { label: "工单名称", prop: "name", width: 150 },
+ { label: "所属单位", prop: "dept_name", width: 100 },
+ { label: "发起时间", prop: "create_time", width: 160 },
+ { label: "工单内容", prop: "content", width: 160 },
+ { label: "关联航线", prop: "wayline_name", width: 160 },
+ { label: "关联算法", prop: "ai_type_str", width: 180 },
+ { label: "创建人", prop: "creator_name", width: 180 },
+ { label: "关联机巢", prop: "device_names", width: 108 },
-
- ],
- },
- pagination: {
- currentPage: 1,
- pageSize: 10,
- total: 0,
- },
- dialogVisible: false,
- detailVisible: false,
- currentDetail: {},
- form: {
- name: '',
- type: '',
- handler: '',
- algorithm: '',
- location: '',
- address: '',
- content: '',
- photos: [],
- },
- rules: {
- name: [{ required: true, message: '请输入工单名称', trigger: 'blur' }],
- type: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
- handler: [{ required: true, message: '请选择处理人员', trigger: 'change' }],
- content: [{ required: true, message: '请输入工单内容', trigger: 'blur' }],
- },
- loading: false,
- globalCounts: {},
- mapLoaded: false,
- };
- },
- async created() {
- this.loadAMapScripts();
- this.fetchDropdownData();
- var response=await getDictionary({ code: 'SF' });
- this.ai_types= response.data.data;
-
- },
- mounted() {
- this.fetchTableData();
- },
+ { label: "工单周期凭次", prop: "", width: 108, formatter: (row) => this.formatCycleTime(row) },
+ { label: "工单状态", prop: "status", width: 60 }
- methods: {
- async loadAMapScripts() {
- try {
- // await loadAMap();
- // await loadAMapUI();
- this.mapLoaded = true;
- } catch (error) {
- console.error('Failed to load AMap scripts:', error);
- this.$message.error('地图加载失败,请检查网络或API Key配置');
- }
- },
- formatCycleTime(row){
- return row.begin_time+"-"+row.end_time+" "+row.rep_rule_val;
- },
- async fetchDropdownData() {
- try {
- const response = await getTicketInfo();
- console.log('接口返回数据:', response.data.data);
- const { dept_data, event_type } = response.data.data;
-
- this.departments = dept_data.map(item => ({
- label: item.dept_name,
- value: item.id,
- }));
-
- this.types = Object.entries(event_type).map(([key, value]) => ({
- label: value,
- value: key,
- }));
-
- console.log('departments:', this.departments);
- console.log('types:', this.types);
- } catch (error) {
- console.error('获取下拉框数据失败:', error);
- this.$message.error('加载下拉框数据失败');
- }
- },
-
- async fetchTableData() {
- this.loading = true;
- try {
- const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
-
- const params = {
- key_word: this.filters.key_word || undefined,
- create_dept: this.filters.create_dept || undefined,
- ai_types:this.filters.ai_types && this.filters.ai_types.length > 0?[this.filters.ai_types]:null,
- file_id: this.filters.file_id || undefined,
- status: this.filters.status !== "" ? Number(this.filters.status) : currentTab?.value,
- dept_id: this.filters.department || undefined,
- start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
- end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]).replace("00:00:00", "23:59:59") : undefined,
- current: this.pagination.currentPage,
- size: this.pagination.pageSize,
- };
- console.log("发送的参数:", params);
- const response = await getList(params);
- if (!response?.data?.data?.records) {
- throw new Error('接口返回数据格式不正确');
+ ],
+ },
+ pagination: {
+ currentPage: 1,
+ pageSize: 10,
+ total: 0,
+ },
+ dialogVisible: false,
+ detailVisible: false,
+ currentDetail: {},
+ form: {
+ name: '',
+ type: '',
+ handler: '',
+ algorithm: '',
+ location: '',
+ address: '',
+ content: '',
+ photos: [],
+ },
+ rules: {
+ name: [{ required: true, message: '请输入工单名称', trigger: 'blur' }],
+ type: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
+ handler: [{ required: true, message: '请选择处理人员', trigger: 'change' }],
+ content: [{ required: true, message: '请输入工单内容', trigger: 'blur' }],
+ },
+ loading: false,
+ globalCounts: {},
+ mapLoaded: false,
}
-
- const { total, records } = response.data.data;
- this.tableData = records.map(item => {
-
- return item;
- });
-
- if (this.activeTab === 'all') {
- this.updateGlobalCounts(records, total);
- }
-
- this.pagination.total = total || 0;
- this.updateTabCounts();
- } catch (error) {
- console.error("获取数据失败:", error);
- this.$message.error(error.message || "获取数据失败");
- this.tableData = [];
- this.pagination.total = 0;
- } finally {
- this.loading = false;
- }
},
- beforeUpload(file) {
- const isImage = file.type.includes('image');
- const isLt5M = file.size / 1024 / 1024 < 5;
-
- if (!isImage) {
- this.$message.error('只能上传图片文件!');
- return false;
- }
- if (!isLt5M) {
- this.$message.error('图片大小不能超过5MB!');
- return false;
- }
- return true;
+ computed: {
+ ...mapGetters(['userInfo']),
},
- handleUploadPreview(file) {
- this.$message.info(`预览图片:${file.name}`);
+ async created () {
+ this.loadAMapScripts()
+ this.fetchDropdownData()
+ var response = await getDictionary({ code: 'SF' })
+ this.ai_types = response.data.data
+
+ },
+ mounted () {
+ this.fetchTableData()
},
- handleUploadRemove(file, fileList) {
- this.form.photos = fileList;
- this.$message.success(`已移除图片:${file.name}`);
- },
- handleUploadSuccess(response, file, fileList) {
- this.form.photos = fileList;
- this.$message.success(`图片上传成功:${file.name}`);
- },
+ methods: {
+ async loadAMapScripts () {
+ try {
+ // await loadAMap();
+ // await loadAMapUI();
+ this.mapLoaded = true
+ } catch (error) {
+ console.error('Failed to load AMap scripts:', error)
+ this.$message.error('地图加载失败,请检查网络或API Key配置')
+ }
+ },
+ formatCycleTime (row) {
+ return row.begin_time + "-" + row.end_time + " " + row.rep_rule_val
+ },
+ async fetchDropdownData () {
+ try {
+ const response = await getTicketInfo()
+ console.log('接口返回数据:', response.data.data)
+ const { dept_data, event_type } = response.data.data
- handleUploadError(err, file) {
- this.$message.error(`图片上传失败:${file.name}`);
- console.error('上传失败:', err);
- },
+ this.departments = dept_data.map(item => ({
+ label: item.dept_name,
+ value: item.id,
+ }))
- async uploadFiles(files) {
- const uploadPromises = files.map(file => {
- return new Promise((resolve) => {
- const formData = new FormData();
- formData.append('file', file.raw);
- setTimeout(() => {
- resolve({
- url: URL.createObjectURL(file.raw),
- name: file.name
- });
- }, 1000);
- });
- });
- return Promise.all(uploadPromises);
- },
+ this.types = Object.entries(event_type).map(([key, value]) => ({
+ label: value,
+ value: key,
+ }))
- async submitForm() {
- this.$refs.form.validate(async (valid) => {
- if (valid) {
- if (!this.form.location || this.form.location.length !== 2) {
- this.$message.warning('请在地图上选择位置');
- return;
- }
+ console.log('departments:', this.departments)
+ console.log('types:', this.types)
+ } catch (error) {
+ console.error('获取下拉框数据失败:', error)
+ this.$message.error('加载下拉框数据失败')
+ }
+ },
- try {
- const unUploadedFiles = this.form.photos.filter(file => file.raw);
- if (unUploadedFiles.length > 0) {
- await this.uploadFiles(unUploadedFiles);
+ async fetchTableData () {
+ this.loading = true
+ try {
+ const currentTab = this.tabs.find(tab => tab.name === this.activeTab)
+
+ const params = {
+ key_word: this.filters.key_word || undefined,
+ create_dept: this.filters.create_dept || undefined,
+ ai_types: this.filters.ai_types && this.filters.ai_types.length > 0 ? [this.filters.ai_types] : null,
+ file_id: this.filters.file_id || undefined,
+ status: this.filters.status !== "" ? Number(this.filters.status) : currentTab?.value,
+ dept_id: this.filters.department || undefined,
+ start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
+ end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]).replace("00:00:00", "23:59:59") : undefined,
+ current: this.pagination.currentPage,
+ size: this.pagination.pageSize,
+ }
+ console.log("发送的参数:", params)
+ const response = await getList(params)
+ if (!response?.data?.data?.records) {
+ throw new Error('接口返回数据格式不正确')
+ }
+
+ const { total, records } = response.data.data
+ this.tableData = records.map(item => {
+
+ return item
+ })
+
+ if (this.activeTab === 'all') {
+ this.updateGlobalCounts(records, total)
+ }
+
+ this.pagination.total = total || 0
+ this.updateTabCounts()
+ } catch (error) {
+ console.error("获取数据失败:", error)
+ this.$message.error(error.message || "获取数据失败")
+ this.tableData = []
+ this.pagination.total = 0
+ } finally {
+ this.loading = false
+ }
+ },
+
+ beforeUpload (file) {
+ const isImage = file.type.includes('image')
+ const isLt5M = file.size / 1024 / 1024 < 5
+
+ if (!isImage) {
+ this.$message.error('只能上传图片文件!')
+ return false
+ }
+ if (!isLt5M) {
+ this.$message.error('图片大小不能超过5MB!')
+ return false
+ }
+ return true
+ },
+
+ handleUploadPreview (file) {
+ this.$message.info(`预览图片:${file.name}`)
+ },
+
+ handleUploadRemove (file, fileList) {
+ this.form.photos = fileList
+ this.$message.success(`已移除图片:${file.name}`)
+ },
+
+ handleUploadSuccess (response, file, fileList) {
+ this.form.photos = fileList
+ this.$message.success(`图片上传成功:${file.name}`)
+ },
+
+ handleUploadError (err, file) {
+ this.$message.error(`图片上传失败:${file.name}`)
+ console.error('上传失败:', err)
+ },
+
+ async uploadFiles (files) {
+ const uploadPromises = files.map(file => {
+ return new Promise((resolve) => {
+ const formData = new FormData()
+ formData.append('file', file.raw)
+ setTimeout(() => {
+ resolve({
+ url: URL.createObjectURL(file.raw),
+ name: file.name
+ })
+ }, 1000)
+ })
+ })
+ return Promise.all(uploadPromises)
+ },
+
+ async submitForm () {
+ this.$refs.form.validate(async (valid) => {
+ if (valid) {
+ if (!this.form.location || this.form.location.length !== 2) {
+ this.$message.warning('请在地图上选择位置')
+ return
+ }
+
+ try {
+ const unUploadedFiles = this.form.photos.filter(file => file.raw)
+ if (unUploadedFiles.length > 0) {
+ await this.uploadFiles(unUploadedFiles)
+ }
+
+ const submitData = {
+ ...this.form,
+ photos: this.form.photos.map(file => file.url || file.response?.url),
+ location: this.form.location.join(','),
+ status: 1
+ }
+
+ await createTicket(submitData)
+ this.dialogVisible = false
+ this.$message.success('工单创建成功')
+ this.fetchTableData()
+ } catch (error) {
+ console.error('提交失败:', error)
+ this.$message.error('工单创建失败: ' + (error.message || '服务器错误'))
+ }
+ }
+ })
+ },
+
+ formatDate (date) {
+ if (!date) return undefined
+ const d = new Date(date)
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} 00:00:00`
+ },
+
+ mapStatus (status) {
+ const statusTextMap = {
+ 1: "待审核",
+ 2: "待处理",
+ 3: "处理中",
+ 4: "已完成",
+ 5: "已完结"
+ }
+ return statusTextMap[status] || "未知状态"
+ },
+
+ getStatusTagType (status) {
+ const statusMap = {
+ 1: "warning",
+ 2: "info",
+ 3: "primary",
+ 4: "success",
+ 5: "danger",
+ }
+ return statusMap[status] || "info"
+ },
+
+ handleTabChange (tab) {
+ this.activeTab = tab.props?.name || tab.name
+ this.filters.status = ""
+ this.pagination.currentPage = 1
+ this.fetchTableData()
+ },
+
+ handleSearch () {
+ this.pagination.currentPage = 1
+ this.fetchTableData()
+ },
+
+ handleReset () {
+ this.filters = {
+ keyword: "",
+ department: "",
+ type: "",
+ dateRange: [],
+ status: "",
+ }
+ this.pagination.currentPage = 1
+ this.fetchTableData()
+ },
+
+ handlePaginationChange (val) {
+ this.pagination.currentPage = val.currentPage
+ this.pagination.pageSize = val.pageSize
+ this.fetchTableData()
+ },
+
+ updateGlobalCounts (records, total) {
+ const counts = {
+ all: total,
+ pending: 0,
+ processing: 0,
+ inProgress: 0,
+ completed: 0,
+ closed: 0,
+ myTickets: 0
}
- const submitData = {
- ...this.form,
- photos: this.form.photos.map(file => file.url || file.response?.url),
- location: this.form.location.join(','),
- status: 1
- };
+ records.forEach(item => {
+ const tab = this.tabs.find(t => t.value === Number(item.status))
+ if (tab) {
+ counts[tab.name] = (counts[tab.name] || 0) + 1
+ }
+ })
- await createTicket(submitData);
- this.dialogVisible = false;
- this.$message.success('工单创建成功');
- this.fetchTableData();
- } catch (error) {
- console.error('提交失败:', error);
- this.$message.error('工单创建失败: ' + (error.message || '服务器错误'));
- }
- }
- });
+ this.globalCounts = counts
+ },
+
+ updateTabCounts () {
+ if (this.activeTab === 'all') {
+ this.tabs.forEach(tab => {
+ tab.count = this.globalCounts[tab.name] || 0
+ })
+ } else {
+ this.tabs.forEach(tab => {
+ if (tab.name === this.activeTab) {
+ tab.count = this.tableData.length
+ } else {
+ tab.count = this.globalCounts[tab.name] || 0
+ }
+ })
+ }
+ },
+
+ handleAdd () {
+ this.dialogVisible = true
+ },
+
+ resetForm () {
+ this.form = {
+ name: '',
+ type: '',
+ handler: '',
+ algorithm: '',
+ location: '',
+ address: '',
+ content: '',
+ photos: [],
+ }
+ if (this.$refs.form) {
+ this.$refs.form.resetFields()
+ }
+ },
+
+ formatLocation (location) {
+ if (!Array.isArray(location)) {
+ return '未知位置'
+ }
+ return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`
+ },
+
+ handleViewDetail (row) {
+ this.currentDetail = {
+ ...row,
+ photos: row.photos || [],
+ }
+ this.detailVisible = true
+ },
+
+ openMap () {
+ let cur = getAdcodeObj(geoJson, 'adcode', this.userInfo.detail.areaCode.substring(0, 6))
+ console.log(cur, 111)
+
+
+
+ this.$message.info("地图选址功能暂未实现")
+ },
+
+ handlePreview (file) {
+ this.$message.info(`预览图片:${file.name}`)
+ },
+
+ handleRemove (file) {
+ this.$message.info(`移除图片:${file.name}`)
+ },
+
+ refreshChange () {
+ this.fetchTableData()
+ },
+
+ onLoad () {
+ this.fetchTableData()
+ },
+
+ async exportData () {
+ try {
+ this.loading = true
+ const params = {
+ keyword: this.filters.keyword || undefined,
+ word_order_type: this.filters.type || undefined,
+ status: this.filters.status || undefined,
+ dept_id: this.filters.department || undefined,
+ start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
+ end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]) : undefined,
+ }
+
+ const response = await getList(params)
+ if (!response?.data?.data?.records) {
+ throw new Error('接口返回数据格式不正确')
+ }
+
+ const records = response.data.data.records
+ const exportData = records.map(item => ({
+ 工单编号: item.wayline_job_id || '',
+ 工单名称: item.event_name || '',
+ 所属单位: this.departments.find(d => d.value === item.deptId)?.label || '未知单位',
+ 发起时间: item.create_time || '',
+ 工单内容: item.ai_types || '',
+ 工单类型: this.types.find(t => t.value === item.event_dict_key)?.label || '未知类型',
+ 经纬度: `${item.longitude || '未知'}, ${item.latitude || '未知'}`,
+ 详细地址: item.address || '暂无地址信息',
+ 创建人: item.create_user || '未知创建人',
+ 处理人: item.update_user || '未分配',
+ 工单状态: this.mapStatus(Number(item.status || 0)),
+ }))
+
+ export_json_to_excel(
+ ['工单编号', '工单名称', '所属单位', '发起时间', '工单内容', '工单类型', '经纬度', '详细地址', '创建人', '处理人', '工单状态'],
+ exportData,
+ '工单数据'
+ )
+ this.$message.success('数据导出成功')
+ } catch (error) {
+ console.error('导出失败:', error)
+ this.$message.error('数据导出失败')
+ } finally {
+ this.loading = false
+ }
+ },
},
-
- formatDate(date) {
- if (!date) return undefined;
- const d = new Date(date);
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} 00:00:00`;
- },
-
- mapStatus(status) {
- const statusTextMap = {
- 1: "待审核",
- 2: "待处理",
- 3: "处理中",
- 4: "已完成",
- 5: "已完结"
- };
- return statusTextMap[status] || "未知状态";
- },
-
- getStatusTagType(status) {
- const statusMap = {
- 1: "warning",
- 2: "info",
- 3: "primary",
- 4: "success",
- 5: "danger",
- };
- return statusMap[status] || "info";
- },
-
- handleTabChange(tab) {
- this.activeTab = tab.props?.name || tab.name;
- this.filters.status = "";
- this.pagination.currentPage = 1;
- this.fetchTableData();
- },
-
- handleSearch() {
- this.pagination.currentPage = 1;
- this.fetchTableData();
- },
-
- handleReset() {
- this.filters = {
- keyword: "",
- department: "",
- type: "",
- dateRange: [],
- status: "",
- };
- this.pagination.currentPage = 1;
- this.fetchTableData();
- },
-
- handlePaginationChange(val) {
- this.pagination.currentPage = val.currentPage;
- this.pagination.pageSize = val.pageSize;
- this.fetchTableData();
- },
-
- updateGlobalCounts(records, total) {
- const counts = {
- all: total,
- pending: 0,
- processing: 0,
- inProgress: 0,
- completed: 0,
- closed: 0,
- myTickets: 0
- };
-
- records.forEach(item => {
- const tab = this.tabs.find(t => t.value === Number(item.status));
- if (tab) {
- counts[tab.name] = (counts[tab.name] || 0) + 1;
- }
- });
-
- this.globalCounts = counts;
- },
-
- updateTabCounts() {
- if (this.activeTab === 'all') {
- this.tabs.forEach(tab => {
- tab.count = this.globalCounts[tab.name] || 0;
- });
- } else {
- this.tabs.forEach(tab => {
- if (tab.name === this.activeTab) {
- tab.count = this.tableData.length;
- } else {
- tab.count = this.globalCounts[tab.name] || 0;
- }
- });
- }
- },
-
- handleAdd() {
- this.dialogVisible = true;
- },
-
- resetForm() {
- this.form = {
- name: '',
- type: '',
- handler: '',
- algorithm: '',
- location: '',
- address: '',
- content: '',
- photos: [],
- };
- if (this.$refs.form) {
- this.$refs.form.resetFields();
- }
- },
-
- formatLocation(location) {
- if (!Array.isArray(location)) {
- return '未知位置';
- }
- return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`;
- },
-
- handleViewDetail(row) {
- this.currentDetail = {
- ...row,
- photos: row.photos || [],
- };
- this.detailVisible = true;
- },
-
- openMap() {
- this.$message.info("地图选址功能暂未实现");
- },
-
- handlePreview(file) {
- this.$message.info(`预览图片:${file.name}`);
- },
-
- handleRemove(file) {
- this.$message.info(`移除图片:${file.name}`);
- },
-
- refreshChange() {
- this.fetchTableData();
- },
-
- onLoad() {
- this.fetchTableData();
- },
-
- async exportData() {
- try {
- this.loading = true;
- const params = {
- keyword: this.filters.keyword || undefined,
- word_order_type: this.filters.type || undefined,
- status: this.filters.status || undefined,
- dept_id: this.filters.department || undefined,
- start_date: this.filters.dateRange?.[0] ? this.formatDate(this.filters.dateRange[0]) : undefined,
- end_date: this.filters.dateRange?.[1] ? this.formatDate(this.filters.dateRange[1]) : undefined,
- };
-
- const response = await getList(params);
- if (!response?.data?.data?.records) {
- throw new Error('接口返回数据格式不正确');
- }
-
- const records = response.data.data.records;
- const exportData = records.map(item => ({
- 工单编号: item.wayline_job_id || '',
- 工单名称: item.event_name || '',
- 所属单位: this.departments.find(d => d.value === item.deptId)?.label || '未知单位',
- 发起时间: item.create_time || '',
- 工单内容: item.ai_types || '',
- 工单类型: this.types.find(t => t.value === item.event_dict_key)?.label || '未知类型',
- 经纬度: `${item.longitude || '未知'}, ${item.latitude || '未知'}`,
- 详细地址: item.address || '暂无地址信息',
- 创建人: item.create_user || '未知创建人',
- 处理人: item.update_user || '未分配',
- 工单状态: this.mapStatus(Number(item.status || 0)),
- }));
-
- export_json_to_excel(
- ['工单编号', '工单名称', '所属单位', '发起时间', '工单内容', '工单类型', '经纬度', '详细地址', '创建人', '处理人', '工单状态'],
- exportData,
- '工单数据'
- );
- this.$message.success('数据导出成功');
- } catch (error) {
- console.error('导出失败:', error);
- this.$message.error('数据导出失败');
- } finally {
- this.loading = false;
- }
- },
- },
- watch: {
- tableData: {
- handler() {
- this.updateTabCounts();
- },
- deep: true
- },
- }
-};
+ watch: {
+ tableData: {
+ handler () {
+ this.updateTabCounts()
+ },
+ deep: true
+ },
+ }
+}
</script>
<style lang="scss" scoped>
.tab-content {
- padding: 10px;
+ padding: 10px;
}
.filter-bar {
- display: flex;
- align-items: center;
- margin-bottom: 15px;
- flex-wrap: wrap;
+ display: flex;
+ align-items: center;
+ margin-bottom: 15px;
+ flex-wrap: wrap;
- .filter-item {
- margin-right: 10px;
- margin-bottom: 10px;
- width: 200px;
- }
+ .filter-item {
+ margin-right: 10px;
+ margin-bottom: 10px;
+ width: 200px;
+ }
- .date-picker {
- width: 240px;
- }
+ .date-picker {
+ width: 240px;
+ }
}
.action-bar {
- margin-bottom: 16px;
+ margin-bottom: 16px;
}
.el-tabs {
- :deep(.el-tabs__content) {
- overflow: visible;
- }
+ :deep(.el-tabs__content) {
+ overflow: visible;
+ }
}
.tab-content {
- min-height: 200px;
+ min-height: 200px;
}
.detail-form {
- :deep(.el-form-item) {
- margin-bottom: 10px;
- }
+ :deep(.el-form-item) {
+ margin-bottom: 10px;
+ }
- :deep(.el-form-item__label) {
- color: #606266;
- font-weight: normal;
- }
+ :deep(.el-form-item__label) {
+ color: #606266;
+ font-weight: normal;
+ }
- :deep(.el-form-item__content) {
- color: #303133;
- }
+ :deep(.el-form-item__content) {
+ color: #303133;
+ }
}
.el-dialog {
- .el-form-item {
- margin-bottom: 20px;
- }
+ .el-form-item {
+ margin-bottom: 20px;
+ }
}
.el-upload {
- width: 100%;
- display: flex;
- flex-wrap: wrap;
-
- :deep(.el-upload-list__item) {
- transition: all 0.3s ease;
- }
-
- :deep(.el-upload-list__item:hover) {
- background-color: #f5f7fa;
- }
+ width: 100%;
+ display: flex;
+ flex-wrap: wrap;
+
+ :deep(.el-upload-list__item) {
+ transition: all 0.3s ease;
+ }
+
+ :deep(.el-upload-list__item:hover) {
+ background-color: #f5f7fa;
+ }
}
.el-upload__tip {
- font-size: 12px;
- color: #909399;
- margin-top: 7px;
+ font-size: 12px;
+ color: #909399;
+ margin-top: 7px;
}
</style>
\ No newline at end of file
--
Gitblit v1.9.3