Blame view

src/views/oa/printOwnerVotingList.vue 7.23 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
a99eb7a5   wuxw   开发完成办公下功能
2
    <div class="print-owner-voting-container">
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
3
4
5
      <div class="text-center">
        <h1>{{ printOwnerVotingInfo.qaName }}</h1>
      </div>
2e81c59f   wuxw   完成办公功能测试
6
  
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
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
      <div class="text-left">
        <div v-html="printOwnerVotingInfo.content"></div>
      </div>
  
      <div>
        <table class="table vc-table-border margin-top" style="color:#000;font-size:14px;width: 100%;">
          <thead>
            <tr>
              <th class="text-center" >
                <div class="text-left">
                  {{ $t('printOwnerVoting.room') }}
                </div>
              </th>
              <th
                v-for="(item, index) in printOwnerVotingInfo.titleValues"
                :key="'head-left-' + index"
                scope="col"
                class="text-center"
              >
                {{ item.qaValue }}
              </th>
              <th class="text-center ">
                <div class="text-left">
                  {{ $t('printOwnerVoting.room') }}
                </div>
              </th>
              <th
                v-for="(item, index) in printOwnerVotingInfo.titleValues"
                :key="'head-right-' + index"
                scope="col"
                class="text-center"
              >
                {{ item.qaValue }}
              </th>
            </tr>
          </thead>
          <tbody>
            <tr
              v-for="(pair, index) in pairedVotes"
              :key="'row-' + index"
              class="vc-table-border"
            >
              <td class="text-center">
                <div style="max-width: 200px;">{{ pair.left ? pair.left.roomName : '' }}</div>
              </td>
              <td
                v-for="(item, tIndex) in printOwnerVotingInfo.titleValues"
                :key="'left-' + index + '-' + tIndex"
                class="text-center"
              >
                {{ pair.left ? pair.left[item.qaValue] : '' }}
              </td>
              <td class="text-center">
                <div style="max-width: 200px;">
                  {{ pair.right ? pair.right.roomName : '' }}
                </div>
              </td>
              <td
                v-for="(item, tIndex) in printOwnerVotingInfo.titleValues"
                :key="'right-' + index + '-' + tIndex"
                class="text-center"
              >
                <div v-if="pair.right">
                  {{ pair.right[item.qaValue] }}
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
  
      <div class="summary text-left">
        <span>{{ $t('printOwnerVoting.totalVotes') }}:{{ printOwnerVotingInfo.voteCount }}</span>;
        <span>{{ $t('printOwnerVoting.votedCount') }}:{{ printOwnerVotingInfo.votedCount }}</span>;
        <span v-for="(item, tIndex) in printOwnerVotingInfo.titleValues" :key="'summary-' + tIndex">
          {{ item.qaValue }}: {{ item.personCount }}{{ $t('printOwnerVoting.person') }};
        </span>
      </div>
  
      <div class="text-right margin-top margin-right">
        {{ currentCommunity.name }}
      </div>
  
      <div class="text-right margin-top-sm margin-right">
        {{ formatDate(new Date()) }}
      </div>
  
      <div id="print-btn" class="actions text-right">
     
        <button type="button" class="btn btn-warning float-right" style="margin-right:20px;" @click="_closePage">
          {{ $t('common.cancel') }}
        </button>
        <button class="btn btn-primary float-right" type="button" @click="_printPurchaseApplyDiv">
          <i class="fa fa-check"></i>&nbsp;{{ $t('common.print') }}
        </button>
      </div>
a99eb7a5   wuxw   开发完成办公下功能
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
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { listOwnerVote, listUserQuestionAnswer } from '@/api/oa/printOwnerVotingApi'
  
  export default {
    name: 'PrintOwnerVotingList',
    data() {
      return {
        printOwnerVotingInfo: {
          qaName: '',
          content: '',
          titleValues: [],
          qaId: '',
          userVotes: [],
          voteCount: 0,
          votedCount: 0
        },
        currentCommunity: {
          name: '',
          communityId: ''
        }
      }
    },
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
129
130
131
132
133
134
135
136
137
138
139
140
141
    computed: {
      pairedVotes() {
        const votes = this.printOwnerVotingInfo.userVotes || []
        const result = []
        for (let i = 0; i < votes.length; i += 2) {
          result.push({
            left: votes[i] || null,
            right: votes[i + 1] || null
          })
        }
        return result
      }
    },
a99eb7a5   wuxw   开发完成办公下功能
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    created() {
      this.printOwnerVotingInfo.qaId = this.$route.query.qaId
      this.currentCommunity.communityId = getCommunityId()
      this._listOwnerVotings()
    },
    methods: {
      async _listOwnerVotings() {
        try {
          const params = {
            page: 1,
            row: 1,
            communityId: this.currentCommunity.communityId,
            qaId: this.printOwnerVotingInfo.qaId
          }
          const { data } = await listOwnerVote(params)
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
157
158
          //this.printOwnerVotingInfo = data[0]
          Object.assign(this.printOwnerVotingInfo, data[0])
a99eb7a5   wuxw   开发完成办公下功能
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
          this._listValues()
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      async _listValues() {
        try {
          const params = {
            page: 1,
            row: 500,
            communityId: this.currentCommunity.communityId,
            qaId: this.printOwnerVotingInfo.qaId
          }
          const { data } = await listUserQuestionAnswer(params)
          const _titleValues = this.printOwnerVotingInfo.titleValues
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
174
          console.log(data, '_titleValues', _titleValues)
a99eb7a5   wuxw   开发完成办公下功能
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
          data.forEach(_value => {
            _titleValues.forEach(_title => {
              _value[_title.qaValue] = ''
              if (_value['values']) {
                _value.values.forEach(tmpValue => {
                  if (tmpValue.qaValue === _title.qaValue) {
                    _value[_title.qaValue] = 'V'
                  }
                })
              }
            })
          })
          this.printOwnerVotingInfo.userVotes = data
        } catch (error) {
          console.error('请求失败:', error)
        }
      },
      _printPurchaseApplyDiv() {
        document.getElementById("print-btn").style.display = "none"
        window.print()
        window.opener = null
        window.close()
      },
      _closePage() {
        window.opener = null
        window.close()
      },
      formatDate(date) {
        const year = date.getFullYear()
        const month = String(date.getMonth() + 1).padStart(2, '0')
        const day = String(date.getDate()).padStart(2, '0')
        return `${year}-${month}-${day}`
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .print-owner-voting-container {
    padding: 20px;
  
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
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
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 6px 15px;
      border-radius: 4px;
      border: 1px solid transparent;
      cursor: pointer;
      font-size: 14px;
      line-height: 1.5;
      transition: all 0.2s;
    }
  
    .btn-primary {
      background-color: #409eff;
      border-color: #409eff;
      color: #fff;
    }
  
    .btn-warning {
      background-color: #e6a23c;
      border-color: #e6a23c;
      color: #fff;
    }
  
    .btn:hover {
      opacity: 0.85;
    }
  
a99eb7a5   wuxw   开发完成办公下功能
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
    .margin-top {
      margin-top: 20px;
    }
  
    .margin-top-sm {
      margin-top: 10px;
    }
  
    .margin-right {
      margin-right: 20px;
    }
  
    .text-center {
      text-align: center;
    }
  
    .text-right {
      text-align: right;
    }
  
    .vc-table-border {
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
266
      border: 1px solid #000000;
a99eb7a5   wuxw   开发完成办公下功能
267
268
269
270
      border-collapse: collapse;
  
      th,
      td {
32722b0a   wuxw   v1.9 优化办公和合同测试 部分...
271
        border: 1px solid #000000;
a99eb7a5   wuxw   开发完成办公下功能
272
273
274
275
276
277
278
279
280
        padding: 8px;
      }
    }
  
    #print-btn {
      margin-top: 20px;
    }
  }
  </style>