Blame view

src/components/index/indexNotice.vue 4.45 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
6d9d3e27   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
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
    <div class="index-1-right-1">
      <div class="index-title text-left">
        <span>{{ $t('propertyIndex.ownerFeedback') }}</span>
      </div>
      <ul id="pool" class="notice-list">
        <li v-if="!indexNoticeInfo.notices || indexNoticeInfo.notices.length < 1" 
            class="flex justify-between padding-top-sm no-data">
          <div class="vc-index-notice-title">
            {{ $t('propertyIndex.noFeedback') }}
          </div>
        </li>
        <li v-else v-for="(item, index) in indexNoticeInfo.notices" :key="index" 
            class="flex justify-between padding-top-sm notice-item">
          <div class="vc-index-notice-title">
            {{ item.objName }}({{ item.roomName }}){{ $t('propertyIndex.feedback') }}{{ item.title }}
            ({{ item.state === 'F' ? $t('propertyIndex.completed') : $t('propertyIndex.followingUp') }}<span v-if="item.thridId">-{{ $t('propertyIndex.transferRepair') }}</span>)
          </div>
          <div class="vc-index-notice-time">
            {{ item.createTime }}
          </div>
        </li>
      </ul>
    </div>
  </template>
  
  <script>
  import { getNotepadList } from '@/api/index/propertyIndexApi'
  
  export default {
    name: 'IndexNotice',
    data() {
      return {
        indexNoticeInfo: {
          notices: [],
          scrollInterval: null,
          scrollTopValue: 0,
          scrollDirection: true,
        }
      }
    },
    created() {
    },
    mounted() {
      this.$nextTick(() => {
        window.addEventListener('resize', this.checkPoolScroll)
      })
    },
    beforeDestroy() {
      if (this.indexNoticeInfo.scrollInterval) {
        clearInterval(this.indexNoticeInfo.scrollInterval)
      }
      window.removeEventListener('resize', this.checkPoolScroll)
    },
    methods: {
      async _loadPropertyIndexNotices() {
        const param = {
          page: 1,
          row: 10,
          communityId: this.getCommunityId()
        }
  
        try {
          const res = await getNotepadList(param)
          this.indexNoticeInfo.notices = res.data
          this.$nextTick(() => {
            this.checkPoolScroll()
          })
        } catch (error) {
          console.error('请求失败处理', error)
        }
      },
      checkPoolScroll() {
        const element = document.getElementById('pool')
        if (!element) return
        
        const clientHeight = element.clientHeight
        const scrollHeight = element.scrollHeight
        
        if (scrollHeight > clientHeight) {
          if (!this.indexNoticeInfo.scrollInterval) {
            this.indexNoticeInfo.scrollInterval = setInterval(this.poolScroll, 5000)
          }
        } else {
          clearInterval(this.indexNoticeInfo.scrollInterval)
          this.indexNoticeInfo.scrollInterval = null
        }
      },
      poolScroll() {
        const element = document.getElementById('pool')
        if (!element) return
        
        const clientHeight = element.clientHeight
        const scrollHeight = element.scrollHeight
        const canScrollHeight = scrollHeight - clientHeight
        
        if (this.indexNoticeInfo.scrollTopValue <= 0) {
          this.indexNoticeInfo.scrollDirection = true
        }
        
        if (this.indexNoticeInfo.scrollDirection) {
          this.indexNoticeInfo.scrollTopValue += canScrollHeight / 1200
        } else {
          this.indexNoticeInfo.scrollTopValue -= canScrollHeight / 1200
        }
        
        if (canScrollHeight <= this.indexNoticeInfo.scrollTopValue) {
          this.indexNoticeInfo.scrollDirection = !this.indexNoticeInfo.scrollDirection
        }
        
        element.scrollTop = this.indexNoticeInfo.scrollTopValue
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .index-1-right-1 {
    background: #fff;
    border-radius: 4px;
    padding: 15px;
    height: 100%;
    
    .index-title {
      font-size: 16px;
      font-weight: bold;
      margin-bottom: 15px;
      color: #333;
    }
    
    .notice-list {
      height: 300px;
      overflow-y: auto;
      padding: 0;
      margin: 0;
      list-style: none;
      
      .no-data {
        color: #999;
        text-align: center;
        padding: 20px 0;
      }
      
      .notice-item {
        padding: 8px 0;
        border-bottom: 1px solid #eee;
        
        &:last-child {
          border-bottom: none;
        }
        
        .vc-index-notice-title {
          font-size: 14px;
          color: #333;
          width: 70%;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
32a770b5   wuxw   加入费用项明细功能
159
          text-align: left;
6d9d3e27   wuxw   完成物业首页功能
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
        }
        
        .vc-index-notice-time {
          font-size: 12px;
          color: #999;
          width: 30%;
          text-align: right;
        }
      }
    }
    
    .padding-top-sm {
      padding-top: 5px;
    }
  }
  </style>