无人机管理后台前端(已迁走)
张含笑
2025-08-05 c832bf2e80ac465e71b7a1c1f7a59d4252030989
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<template>
  <div class="bocklogBox">
    <div class="block">
      <div class="titleBox">
        <div class="title">待办事项</div>
        <div class="rightTab">
          <div class="titleItem" :class="item.name === checked ? 'activeItem' : ''" v-for="(item, index) in titleList"
            :key="index" @click="titleClick(item, index)">
            <div>
              {{ item.name }}
              <div class="dots">{{ item.number >= 100 ? '99+' : item.number }}</div>
              
            </div>
          </div>
        </div>
      </div>
 
      <div class="todo-items" v-if="todos.length > 0" v-loading="loading" element-loading-background="rgba(255, 255, 255, 0.5)">
        <div v-for="(item, index) in todos" :key="index" class="todo-item" :style="getStatusStyle(item.status)"
          @click="jumporder(item)">
          <div class="status-indicator"><img :src="getStatus(item.status)" alt=""></div>
 
          <div class="content-wrapper">
            <div class="main-content">
              <span class="status-tag" :style="{ color: getStatusColor(item.status) }">{{
                checked == '智飞工单' ? zfstatusMap[item.status] : statusMap[item.status]
              }}</span>
              <span class="reads" :class="item.is_read === 0 ? 'unread' : ''"></span>
              <span class="todo-text">{{ item.event_num }}</span>
            </div>
 
            <div class="action-area">
              <!-- <img :src="st7" alt="" /> -->
              <!-- <span class="todo-date">{{ item.date?.slice(0, 10).replace(/-/g, '.') }}</span> -->
          <span class="todo-date">{{ item.name }}</span>
            </div>
          </div>
        </div>
      </div>
      <div v-else>
        <el-empty>
          <template #description>
            <span class="custom-text">暂无数据</span>
          </template>
        </el-empty>
      </div>
    </div>
  </div>
</template>
 
<script setup>
 
import db1 from '@/assets/images/workbench/db1.svg'
import db2 from '@/assets/images/workbench/db2.svg'
import db3 from '@/assets/images/workbench/db3.svg'
import db4 from '@/assets/images/workbench/db4.svg'
import db5 from '@/assets/images/workbench/db5.svg'
import { getOrderCountApi, addOrderRecordApi, getOrderOrEventApi } from '@/api/home/index'
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
 
const router = useRouter()
const store = useStore()
const permission = computed(() => store.getters.permission)
const checked = ref('事件工单')
const todosCache = reactive({
  '事件工单': [],
  '智飞工单': []
})
const titleList = ref([
  {
    label: 'event_order_count',
    name: '事件工单',
    number: 0,
  },
  {
    label: 'wayline_order_count',
    name: '智飞工单',
    number: 0,
  },
])
 
const titleClick = async (item, index) => {
  checked.value = item.name
  await getListMatter()
}
const userInfo = computed(() => store.getters.userInfo)
const todos = ref([])
const loading = ref(false)
// * 事件工单中2=待审核,0=待处理,3=处理中
// * 智飞工单中1: 待审核,2=已驳回,3=已通过
const statusMap = {
  0: '待处理',
  2: '待审核',
  3: '处理中',
}
const statusMapColor = {
  0: { color: '#FF7411', backgroundImage: db3, borderLeftColor: '#FF7411' },
  2: { color: '#FF472F', backgroundImage: db1, borderLeftColor: '#FF472F' },
  3: { color: '#FFC300', backgroundImage: db4, borderLeftColor: '#FFC300' },
}
const zfstatusMap = {
  1: '待审核',
  2: '已驳回',
  3: '已通过',
}
const zfstatusMapColor = {
  1: { color: '#FF472F', backgroundImage: db2, borderLeftColor: '#FF472F' },
  2: { color: '#4200DD', backgroundImage: db5, borderLeftColor: '#4200DD' },
  3: { color: '#FF472F', backgroundImage: db2, borderLeftColor: '#FF472F' },
}
 
const getStatus = statusIndex => {
  if (checked.value === '智飞工单') {
    const style = zfstatusMapColor[statusIndex]
    return style ? style.backgroundImage : ''
  } else {
    const style = statusMapColor[statusIndex]
    return style ? style.backgroundImage : ''
  }
}
const getStatusStyle = statusIndex => {
  if (checked.value === '智飞工单') {
    const style = zfstatusMapColor[statusIndex] || {
      color: '#999',
      borderLeftColor: '#999',
    }
    return {
      color: style.color,
      borderLeft: `3px solid ${style.borderLeftColor}`,
    }
  } else {
    const style = statusMapColor[statusIndex] || {
      color: '#999',
      borderLeftColor: '#999',
    }
    return {
      color: style.color,
      borderLeft: `3px solid ${style.borderLeftColor}`,
    }
  }
}
// 获取状态对应的文字颜色
const getStatusColor = statusIndex => {
  if (checked.value === '智飞工单') {
    return zfstatusMapColor[statusIndex]?.color || '#999'
  } else {
    return statusMapColor[statusIndex]?.color || '#999'
  }
}
// 跳转到对应详情页
const jumporder = val => {
  if (checked.value === '智飞工单') {
    const id = val.id
    getaddOrderRecord(id)
    router.replace({
      path: `/tickets/orderLog`,
      query: {
        id,
      },
    })
  } else {
    getaddOrderRecord(val.id)
    const orderNumber = val.event_num
    router.replace({
    path: `/tickets/ticket`,
    query: { orderNumber },
})
  }
}
// 标记事件工单或智飞工单已读
const getaddOrderRecord = async id => {
  const ticketId = id
  if (checked.value === '事件工单') {
    loading.value = true
    const type = 1
    const res = await addOrderRecordApi(type, ticketId)
 
    
  } else if (checked.value === '智飞工单') {
    loading.value = true
    const type = 2
    const res = await addOrderRecordApi(type, ticketId)
  }
}
// 获取事件工单和智飞工单的数量
const getOrderCount = async () => {
  const res = await getOrderCountApi(userInfo.value.detail.areaCode)
  const data = res.data.data
  titleList.value.forEach(item => {
    if (data[item.label] !== undefined) {
      item.number = data[item.label]
    }
  })
}
// 获取事件工单或者智飞工单的信息
 
const getListMatter = async () => {
  loading.value = true
  const type = checked.value === '事件工单' ? 1 : 2
  
  // 使用缓存数据
  if (todosCache[checked.value].length > 0) {
    todos.value = todosCache[checked.value]
  }
  const todosParams = {
    type:type,
    area_code: userInfo.value.detail.areaCode,
  }
  try {
    const res = await getOrderOrEventApi(todosParams)
    const data = res.data.data || []
    todos.value = data.sort((a, b) => a.is_read - b.is_read)  
    todosCache[checked.value] = todos.value
  } finally {
    loading.value = false
  }
}
onMounted(() => {
  getListMatter()
  getOrderCount()
})
</script>
<style>
.el-empty__image {
  width: 100px !important;
}
</style>
<style lang="scss" scoped>
.bocklogBox {
  width: 100%;
  // height: 306px;
  height: pxToVh(316);
  background: rgba(255, 255, 255, 0.41);
  box-shadow: 0px 3px 4px -1px rgba(125, 125, 125, 0.25);
  border-radius: 8px 8px 8px 8px;
  border: 2px solid #ffffff;
  box-sizing: border-box;
 
  .block {
    margin: 11px 21px 13px 22px;
 
    .titleBox {
      display: flex;
      justify-content: space-between;
    }
 
    .title {
      font-family: 'Source Han Sans CN';
      font-weight: bold;
      font-size: 16px;
      color: #363636;
    }
 
    .rightTab {
      display: flex;
      text-align: center;
      padding-right: 10px;
 
      .titleItem {
        position: relative;
        font-weight: 400;
        font-size: 14px;
        color: #7c8091;
        margin-left: 18px;
        cursor: pointer;
      }
 
      .activeItem {
        border-radius: 0px 0px 0px 0px;
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: bold;
        font-size: 14px;
        color: #1c5cff;
        border-bottom: 2px solid #1c5cff;
      }
 
      .dots {
        width: 17px;
        // height: 17px;
        height: pxToVh(17);
        border-radius: 50%;
        background: #366fff;
        color: #fff;
        font-size: 9px;
        position: absolute;
        top: -10px;
        right: -13px;
        padding: 1px;
        line-height: 17px;
      }
 
      .dots1 {
        width: 17px;
        // height: 17px;
        height: pxToVh(17);
        border-radius: 50%;
        background: none !important;
        color: #366fff !important;
        font-size: 9px;
        position: absolute;
        top: -10px;
        right: -13px;
        padding: 1px;
        line-height: 17px;
      }
    }
 
    .todo-items {
      margin-top: 10px;
  transition: opacity 0.3s ease;
      height: pxToVh(250);
      overflow-y: scroll;
       &:empty {
    display: none;
  }
    }
 
    .todo-item {
      transition: 
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.3s ease;
      margin: 6px 0;
      display: flex;
      align-items: center;
      cursor: pointer;
      background: #ffffff;
      border-radius: 8px;
      box-shadow: 0px 2px 4px 0px rgba(173, 173, 173, 0.18);
      transition: all 0.2s ease;
      border-left: 4px solid transparent;
      // height: 42px;
      height: pxToVh(42);
 
      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
      }
 
      .status-indicator {
        margin-left: 3px;
        width: 1.6rem;
        height: 1.6rem;
 
        img {
          width: 100%;
          height: 100%;
        }
      }
 
      .content-wrapper {
        flex: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        // gap: 1rem;
      }
 
      .main-content {
        display: flex;
        align-items: center;
        // gap: 0.8rem;
 
        .status-tag {
          font-weight: 400;
          font-size: 14px;
          margin-left: 2px;
          // padding: 0.3rem 0;
          border-radius: 12px;
        }
 
        .todo-text {
          font-weight: 400;
          font-size: 14px;
         color: #5C6476;
        }
 
        .unread {
          width: 5px;
          height: 5px;
          background: #1c5cff !important;
          border-radius: 50%;
          margin: 0 4px;
        }
 
        .reads {
          width: 5px;
          height: 5px;
          background: transparent;
          border-radius: 50%;
          margin: 0 4px;
        }
      }
 
      .action-area {
        display: flex;
        align-items: center;
        margin-right: 42px;
 
        img {
          width: 15px;
          height: 15px;
        }
 
        .todo-date {
          font-weight: 400;
        font-size: 14px;
color: #343434;
          margin-left: 2px;
        }
      }
    }
  }
 
  .custom-text {
    font-size: 14px;
    color: #7c8091;
  }
  .el-empty {
  transition: opacity 0.3s ease;
}
}
</style>