Blame view

src/views/report/commonReportList.vue 2.58 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
71def04c   wuxw   优化优惠
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
    <div class="common-report-container">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-card class="tree-card">
            <ul class="report-list">
              <li v-for="(item, index) in commonReportInfo.reportCustoms" :key="index"
                :class="{ 'selected-item': commonReportInfo.switchValue === item.customId }" @click="swatch(item)">
                {{ item.title }}
              </li>
            </ul>
          </el-card>
        </el-col>
        <el-col :span="20">
  
          <common-report-table ref="reportTable" />
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import CommonReportTable from '@/components/report/commonReportTable'
  import { listReportCustom } from '@/api/report/commonReportApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'CommonReportList',
    components: {
      CommonReportTable
    },
    data() {
      return {
        commonReportInfo: {
          groupId: '',
          switchValue: '',
          reportCustoms: []
        },
        communityId: ''
      }
    },
    watch: {
      '$route'(to, from) {
        // 对路由变化作出响应...
        console.log(to, from)
        if (to.query.groupId !== from.query.groupId) {
          this.commonReportInfo.groupId = to.query.groupId
          this._loadReportCustom()
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.commonReportInfo.groupId = this.$route.query.groupId
      this._loadReportCustom()
    },
    methods: {
      swatch(value) {
        this.commonReportInfo.switchValue = value.customId
        this.$refs.reportTable.handleSwitch(value)
      },
      async _loadReportCustom() {
        try {
          const params = {
            page: 1,
            row: 50,
            groupId: this.commonReportInfo.groupId
          }
          const { data } = await listReportCustom(params)
          this.commonReportInfo.reportCustoms = data
          if (data && data.length > 0) {
            this.swatch(data[0])
          }
        } catch (error) {
          console.error('Failed to load report custom:', error)
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .common-report-container {
    padding: 20px;
  
    .tree-card {
      height: 100%;
  
      .report-list {
        list-style: none;
        padding: 0;
        margin: 0;
  
        li {
          padding: 10px;
          margin-bottom: 5px;
          text-align: center;
          cursor: pointer;
          border-radius: 4px;
          transition: all 0.3s;
  
          &:hover {
            background-color: #f5f7fa;
          }
  
          &.selected-item {
            background-color: #409eff;
            color: white;
          }
        }
      }
    }
  }
  </style>