无人机管理后台前端(已迁走)
rain
2025-04-19 446234bee3336d10e3fe836ae8e0ca1594d1a55a
切换部门后动态更新tab栏数据
2 files modified
39 ■■■■■ changed files
src/api/tickets/ticket.js 3 ●●●● patch | view | raw | blame | history
src/views/tickets/ticket.vue 36 ●●●●● patch | view | raw | blame | history
src/api/tickets/ticket.js
@@ -73,10 +73,11 @@
};
// 新增接口:获取状态统计数据
export const getstatusCount = () => {
export const getstatusCount = (params) => {
  return request({
    url: '/drone-device-core/jobEvent/getstatusCount',
    method: 'get',
    params,
  });
};
src/views/tickets/ticket.vue
@@ -1150,22 +1150,27 @@
    },
    async fetchTabCounts() {
      try {
        const response = await getstatusCount();
        const { statusCount, totalCount, userCount } = response.data.data;
        this.tabs.forEach(tab => {
          if (tab.name === 'all') {
            tab.count = totalCount || 0; // 总工单数
          } else if (tab.name === 'myTickets') {
            tab.count = userCount || 0; // 我发起的工单数
          } else {
            tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
          }
        });
      } catch (error) {
        this.$message.error('获取 tab 数据失败');
  try {
    // 判断是否有部门筛选
    let params = {};
    if (this.filters.department) {
      params.deptId = this.filters.department;
    }
    const response = await getstatusCount(params);
    const { statusCount, totalCount, userCount } = response.data.data;
    this.tabs.forEach(tab => {
      if (tab.name === 'all') {
        tab.count = totalCount || 0; // 总工单数
      } else if (tab.name === 'myTickets') {
        tab.count = userCount || 0; // 我发起的工单数
      } else {
        tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
      }
    },
    });
  } catch (error) {
    this.$message.error('获取 tab 数据失败');
  }
},
    handleTabChange(tab) {
      this.activeTab = tab.props?.name || tab.name;
@@ -1178,6 +1183,7 @@
    handleSearch() {
      this.page.currentPage = 1;
      this.fetchTableData();
      this.fetchTabCounts();
    },
    handleReset() {