Blame view

src/views/fee/printSmallPayFeeList.vue 10.3 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
f99ceb4f   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
    <div class="printSmallPayFee-container">
  
        <div class="print_container">
          <div style="color:#000;font-size:32px" class="text-center">
            <span>{{ $t('printSmallPayFee.receipt') }}</span>
          </div>
          <span>**************************</span>
          <div class="section2" style="font-size: 12px; margin-left: 5px;">
            <div>
              <span>{{ $t('printSmallPayFee.receiptNum') }}</span>{{ printSmallPayFeeInfo.receiptNum }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.orderNum') }}</span>{{ printSmallPayFeeInfo.payOrderId }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.roomNum') }}</span>: {{ printSmallPayFeeInfo.roomName }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.owner') }}</span>: {{ printSmallPayFeeInfo.payObjName }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.time') }}</span>: {{ printSmallPayFeeInfo.feeTime }}
            </div>
          </div>
          <span>**************************</span>
          <div class="section2" style="font-size: 12px; margin-left: 5px;"
            v-for="(item, index) in printSmallPayFeeInfo.fees" :key="index">
            <div>
              <span>{{ $t('printSmallPayFee.feeItem') }}</span>: {{ item.feeName }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.feeRange') }}</span>: {{ formatDate(item.startTime) }}
              <span>{{ $t('printSmallPayFee.to') }}</span>{{ formatDate(item.endTime) }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.unitPrice') }}</span>{{ item.squarePrice }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.areaUsage') }}</span>{{ item.area }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.paymentMethod') }}</span>{{ item.primeRate }}
            </div>
            <div v-if="item.preDegrees">
              <span>{{ $t('printSmallPayFee.meterReading') }}</span>{{ item.preDegrees }} {{ $t('printSmallPayFee.to') }}
              {{ item.curDegrees }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.amount') }}</span>
              <span>{{ formatAmount(item.amount) }}</span>
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.discount') }}</span> {{ item.discountPrice || 0 }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.remark') }}</span>: {{ item.remark }}
            </div>
            <span>**************************</span>
          </div>
          <div class="section5" style="font-size: 12px; margin-left: 5px;">
            <div>
              <span>{{ $t('printSmallPayFee.total') }}</span>: {{ printSmallPayFeeInfo.amount }}
            </div>
            <div>
              <span>{{ $t('printSmallPayFee.issuer') }}</span>: {{ userInfo.name }}
            </div>
            <div v-html="printSmallPayFeeInfo.content"></div>
            <div><img :src="printSmallPayFeeInfo.qrImg" width="100px" height="100px"></div>
          </div>
          <span>**************************</span>
        </div>
  
        <div id="print-btn" class="action-buttons">
          <el-button type="primary" class="float-right" @click="handlePrint">
            <i class="el-icon-printer"></i>&nbsp;{{ $t('printSmallPayFee.print') }}
          </el-button>
          <el-button class="float-right margin-right" @click="handleCloudPrint">
            <i class="el-icon-cloudy"></i>&nbsp;{{ $t('printSmallPayFee.cloudPrint') }}
          </el-button>
          <el-button class="float-right margin-right" @click="handleClose">
            <span>{{ $t('printSmallPayFee.cancel') }}</span>
          </el-button>
        </div>
  
  
      <el-dialog :title="$t('printSmallPayFee.cloudPrint')" :visible.sync="cloudPrintVisible" width="50%">
        <div class="cloud-print-content">
          <el-form label-width="120px">
            <el-form-item :label="$t('printSmallPayFee.printer')">
              <el-select v-model="printSmallPayFeeInfo.machineId" style="width:100%"
                :placeholder="$t('printSmallPayFee.printerRequired')">
                <el-option v-for="(item, index) in printSmallPayFeeInfo.machines" :key="index"
                  :label="`${item.machineName}(${item.machineCode})`" :value="item.machineId" />
              </el-select>
            </el-form-item>
            <el-form-item :label="$t('printSmallPayFee.quantity')">
              <el-input v-model="printSmallPayFeeInfo.quantity" type="number"
                :placeholder="$t('printSmallPayFee.quantityRequired')" />
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
219071af   wuxw   优化张峰反馈bug
104
          <el-button @click="handleClose">{{ $t('printSmallPayFee.cancel') }}</el-button>
f99ceb4f   wuxw   收据优化完成
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
          <el-button type="primary" @click="handleSubmitCloudPrint">{{ $t('printSmallPayFee.submit') }}</el-button>
        </span>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import {
    queryFeeReceipt,
    queryFeeReceiptDetail,
    queryFeePrintSpec,
    listMachinePrinter,
    printPayFeeDetail
  } from '@/api/fee/printSmallPayFeeApi'
  import { getCommunityId } from '@/api/community/communityApi'
  import { getUserId,getUserName } from '@/api/user/userApi'
  
  export default {
    name: 'PrintSmallPayFeeList',
    data() {
      return {
        printSmallPayFeeInfo: {
          communityName: '',
          receiptId: '',
          receiptIds: '',
          receiptNum: '',
          payOrderId: '',
          roomName: '',
          amount: 0.00,
          fees: [],
          feeTime: '',
          wechatName: '',
          content: '',
          qrImg: '',
          payObjName: '',
          machineId: '',
          quantity: '1',
          machines: []
        },
        cloudPrintVisible: false,
        userInfo: {}
      }
    },
    created() {
      this.printSmallPayFeeInfo.receiptId = this.$route.query.receiptId
      this.printSmallPayFeeInfo.receiptIds = this.$route.query.receiptIds
      this.printSmallPayFeeInfo.communityName = getCommunityId().name
      this.loadData()
      this.userInfo = {
        userId: getUserId(),
        name: getUserName()
      }
    },
    methods: {
      async loadData() {
        await this.loadReceipt()
        await this.loadReceiptDetail()
        await this.loadPrintSpec()
      },
      async loadReceipt() {
        try {
          const params = {
            page: 1,
            row: 30,
            receiptId: this.printSmallPayFeeInfo.receiptId,
            receiptIds: this.printSmallPayFeeInfo.receiptIds,
            communityId: getCommunityId()
          }
          const { data } = await queryFeeReceipt(params)
          const _feeReceipt = data
          let _amount = 0
          _feeReceipt.forEach(item => {
            _amount += parseFloat(item.amount)
          })
          this.printSmallPayFeeInfo.amount = _amount.toFixed(2)
          this.printSmallPayFeeInfo.roomName = _feeReceipt[0].objName
          this.printSmallPayFeeInfo.feeTime = _feeReceipt[0].createTime
          this.printSmallPayFeeInfo.payObjName = _feeReceipt[0].payObjName
          this.printSmallPayFeeInfo.receiptNum = _feeReceipt[0].receiptCode
        } catch (error) {
          console.error('Failed to load receipt:', error)
        }
      },
      async loadReceiptDetail() {
        try {
          const params = {
            page: 1,
            row: 100,
            receiptId: this.printSmallPayFeeInfo.receiptId,
            receiptIds: this.printSmallPayFeeInfo.receiptIds,
            communityId: getCommunityId(),
            orderBy: 'start_time'
          }
          const { data } = await queryFeeReceiptDetail(params)
          this.printSmallPayFeeInfo.payOrderId = data[0].payOrderId
          this.printSmallPayFeeInfo.fees = data
        } catch (error) {
          console.error('Failed to load receipt detail:', error)
        }
      },
      async loadPrintSpec() {
        try {
          const params = {
            page: 1,
            row: 1,
            specCd: 2020,
            communityId: getCommunityId()
          }
          const { data } = await queryFeePrintSpec(params)
          if (data.length > 0) {
            this.printSmallPayFeeInfo.content = data[0].content
            this.printSmallPayFeeInfo.qrImg = data[0].qrImg
          }
        } catch (error) {
          console.error('Failed to load print spec:', error)
        }
      },
      formatDate(date) {
        if (!date) return ''
        return new Date(date).toLocaleDateString()
      },
      formatAmount(amount) {
        if (amount < 0) {
          return amount + this.$t('printSmallPayFee.refund')
        }
        return amount
      },
      handlePrint() {
        window.print()
      },
      handleCloudPrint() {
        this.listMachinePrinter()
        this.cloudPrintVisible = true
      },
      async listMachinePrinter() {
        try {
          const params = {
            page: 1,
            row: 100,
            communityId: getCommunityId()
          }
          const { data } = await listMachinePrinter(params)
          this.printSmallPayFeeInfo.machines = data
          if (this.printSmallPayFeeInfo.machines && this.printSmallPayFeeInfo.machines.length > 0) {
            this.printSmallPayFeeInfo.machineId = this.printSmallPayFeeInfo.machines[0].machineId
          }
        } catch (error) {
          console.error('Failed to list machine printer:', error)
        }
      },
      async handleSubmitCloudPrint() {
        try {
          const detailIds = this.printSmallPayFeeInfo.fees.map(item => item.detailId)
          if (detailIds.length < 1) {
            this.$message.error(this.$t('printSmallPayFee.noFee'))
            return
          }
          const data = {
            communityId: getCommunityId(),
            machineId: this.printSmallPayFeeInfo.machineId,
            quantity: this.printSmallPayFeeInfo.quantity,
            detailId: detailIds.join(',')
          }
a291ba27   wuxw   v1.9 优化云打印bug
268
269
270
271
272
          const {code,msg} = await printPayFeeDetail(data)
          if (code != 0) {
            this.$message.error(msg)
            return;
          }
f99ceb4f   wuxw   收据优化完成
273
          this.cloudPrintVisible = false
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
274
          this.$message.success(this.$t('common.operationSuccess'))
f99ceb4f   wuxw   收据优化完成
275
276
277
278
279
280
        } catch (error) {
          console.error('Failed to submit cloud print:', error)
          this.$message.error(error.message || this.$t('printSmallPayFee.submitFailed'))
        }
      },
      handleClose() {
219071af   wuxw   优化张峰反馈bug
281
        window.close()
f99ceb4f   wuxw   收据优化完成
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
      }
    }
  }
  </script>
  
  <style scoped>
  .printSmallPayFee-container {
    padding: 20px;
  }
  
  .print_container {
    padding: 20px;
    background: #fff;
  }
  
  .text-center {
    text-align: center;
  }
  
  .section2,
  .section5 {
    margin-bottom: 15px;
  }
  
  .action-buttons {
    margin-top: 20px;
    text-align: right;
  }
  
  .float-right {
    float: right;
  }
  
  .margin-right {
    margin-right: 10px;
  }
  
  .cloud-print-content {
    padding: 20px;
  }
  </style>