fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
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
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
<template>
  <div>
    <!-- {{listQuery}} -->
    <list-condition-template ref="table" :form="listQuery" :formLabel="formLabel"
                             :tableData="tableData" :total="total"
                             @page-info-change="handlePageInfoChange" :showFormItem="showFormItem"
                             :dataKey="'key'">
      <template slot="otherElement">
        <el-col :span="24" :offset="0" style="text-align:center;">
          <el-form-item>
            <el-button size="mini" type="primary" @click="queryData">查询</el-button>
            <el-button size="mini" @click="resetQuery">重置</el-button>
            <el-button type="text" @click.stop="toggleForm" style="font-size:14px;">
              {{showFormItem ? '收起' : '展开'}} <i
                 :class="showFormItem?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
            </el-button>
          </el-form-item>
        </el-col>
      </template>
      <template slot="operationSection">
        <!-- 手动开票 -->
        <el-button size="mini" type="success" @click="shoudongkaipiao">手动开票</el-button>
      </template>
      <template slot="columns">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-table border class="expand" :data="props.row.orderInfo.omsOrderItems">
              <el-table-column type="index" align="center" label="序号" width="80px">
              </el-table-column>
              <el-table-column label="商品图片" align="center">
                <template slot-scope="scope">
                  <product-img :imgUrl="scope.row.imgUrl"></product-img>
                </template>
              </el-table-column>
              <el-table-column label="商品名称" prop="spuName" show-overflow-tooltip>
                <template slot-scope="scope">
                  <span class="giftStyle"
                        v-if="scope.row.promotionType === '2'">赠</span><span>{{scope.row.spuName}}</span>
                </template>
              </el-table-column>
              <el-table-column label="商品规格" prop="spuUnit">
                <template slot-scope="scope">
                  {{scope.row.skuProps && JSON.parse(scope.row.skuProps).length ? JSON.parse(scope.row.skuProps).map(item=>item.propValueName).join('/') : '-'}}
                </template>
              </el-table-column>
              <el-table-column label="数量" prop="state">
                <template slot-scope="scope">
                  {{scope.row.buyQuantity}} * {{JSON.parse(scope.row.expInfo).skuReduceStorage}}
                  ({{scope.row.spuUnit ? scope.row.spuUnit : '瓶'}})
                </template>
              </el-table-column>
              <el-table-column label="销售金额(元)">
                <template slot-scope="scope">
                  <span v-if="scope.row.promotionType !== '2'">
                    {{scope.row.totelAmt ? '¥'+scope.row.totelAmt.toFixed(2) : ''}}
                  </span>
                  <span v-else>-</span>
                </template>
              </el-table-column>
              <el-table-column label="实收金额(元)" width="460px">
                <template slot-scope="scope">
                  <span v-if="scope.row.promotionType !== '2'">
                    {{scope.row.totelAmtAct ? '¥'+scope.row.totelAmtAct.toFixed(2) : ''}}
                  </span>
                  <span v-else>-</span>
                  <el-button size="mini" @click="discountDetails(scope.row)"
                             v-if="scope.row.promotionType !== '2'">优惠明细</el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column label="原始订单编号" :key="Math.random()" width="180px" show-overflow-tooltip>
          <template slot-scope="scope">
            {{(scope.row.orderInfo.expInfo && JSON.parse(scope.row.orderInfo.expInfo).sourceOrderCode) ? JSON.parse(scope.row.orderInfo.expInfo).sourceOrderCode : '-'}}
          </template>
        </el-table-column>
        <el-table-column label="订单号" :key="Math.random()" width="180px" show-overflow-tooltip
                         prop="orderId">
          <template slot-scope="scope">
            <el-link class="urlLink" @click="lookOrderInfo(scope.row)">{{ scope.row.orderId }}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="下单时间" :key="Math.random()" prop="orderInfo.orderTime" width="180"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="发票代码-发票号" :key="Math.random()" v-if="invoiceStatus === '1'"
                         width="130px" show-overflow-tooltip prop="fpqqlsh"></el-table-column>
        <el-table-column label="开票人" width="150px" :key="Math.random()"
                         prop="orderInfo.creatorName">
        </el-table-column>
        <el-table-column label="开票金额" :key="Math.random()" width="130px" prop="invoiceAmount"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.invoiceAmount ? '¥' +scope.row.invoiceAmount.toFixed(2) : ''}}
          </template>
        </el-table-column>
        <el-table-column label="开票来源" :key="Math.random()" width="130px"
                         prop="orderInfo.orderSource">
          <template slot-scope="scope">
            {{getLabel(orderSourceArr, scope.row.orderInfo.orderSource)}}
          </template>
        </el-table-column>
        <!-- 开票类型 申请开票和手动开票-->
        <el-table-column label="开票类型" :key="Math.random()" width="130px" prop="invoiceSource"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <span>{{getinvoiceSource(scope.row)}}</span>
          </template>
        </el-table-column>
        <el-table-column label="开票日期" width="180px" :key="Math.random()"
                         v-if="invoiceStatus !== '0'" prop="invoiceTime" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="ESB推送状态" key='7' prop="pushStatus" width="140"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <span class="statusTag"
                  :style="{ background: getPushStatus(scope.row).color == 'success' ? '#52c41a' :'#f5222d'}"></span>
            <span>{{getPushStatus(scope.row).name}}</span>
          </template>
        </el-table-column>
        <el-table-column label="开票状态" width="120px" :key="Math.random()" prop="status"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <span v-if="getStatus(scope.row).color == 'info'">
              <span class="statusTag" :style="{ background: '#d0931e'}"></span>
              <span>{{getStatus(scope.row).name}}</span>
            </span>
            <span v-else-if="getStatus(scope.row).color == 'success'">
              <span class="statusTag" :style="{ background: '#10b434'}"></span>
              <span>{{getStatus(scope.row).name}}</span>
            </span>
            <span v-else-if="getStatus(scope.row).color == 'warning'">
              <span class="statusTag" :style="{ background: '#f5222d'}"></span>
              <span>{{getStatus(scope.row).name}}</span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="备注" :key="Math.random()" prop="invoiceFailMsg" show-overflow-tooltip
                         width="200px">
          <template slot-scope="scope">
            <span v-if="scope.row.status === '2'">失败原因:{{scope.row.invoiceFailMsg}}</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="抬头类型" :key="Math.random()" prop="invoiceType" width="100px">
          <template slot-scope="scope">
            <!-- <span>{{getInvoiceType(scope.row)}}</span> -->
            {{scope.row.invoiceType === '0' ? "个人" : scope.row.invoiceType === '1' ? "企业" : ' '}}
          </template>
        </el-table-column>
        <el-table-column label="操作" :key="Math.random()" fixed="right" align="center" width="200px">
          <template slot-scope="scope">
            <wly-btn @click="lookInfo(scope.row)">查看</wly-btn>
            <wly-btn type="primary" @click="itemAudit(scope.row)"
                     v-if="scope.row.pushStatus === '0' && scope.row.auditStatus === '0'">审核
            </wly-btn>
            <!-- 添加手动推送 -->
            <!-- <el-button size="mini" type="warning" @click="getmanualPush(scope.row)" v-if="scope.row.pushStatus === '0' && scope.row.pushStatus === '2'">手动推送</el-button> -->
            <wly-btn type="warning" @click="getmanualPush(scope.row)"
                     v-if="scope.row.pushStatus !== '1'">手动推送</wly-btn>
            <wly-btn type="success" @click="lookAccountStatement(scope.row)">对账单
            </wly-btn>
          </template>
        </el-table-column>
      </template>
    </list-condition-template>
    <account-statement ref="accountStatement" :show.sync="accountStatementIsShow">
    </account-statement>
  </div>
</template>
<script>
import orderSourceArr from '@/utils/constant/orderSourceArr'
import BillingResources from '@/api/invoice/invoiceapi.js'
import productImg from '@/views/product/components/productImg.vue'
import accountStatement from './components/accountStatement.vue'
import { getDate } from '@/utils/getDate'
 
var _this = null
export default {
  components: { productImg, accountStatement },
  data() {
    return {
      orderSourceArr,
      listQuery: {
        orderStatuss: null, // 订单状态
        isInvoice: null, // 是否需要开具发票  (1=需要,0=不需要)
        auditStatus: null, // 审计状态 (0待审核 1已审核)
        orderId: null, // 订单编号
        fpqqlsh: null, // esb发票编号 1
        pushStatus: null, // 1
        invoiceCode: null, // 发票代码
        invoiceStartTime: null, // 开票开始时间 1
        invoiceEndTime: null, // 开票结束时间 1
        status: null, // 开票状态  1
        spuName: null,
        orderSourceArr: null,
        orderSource: null, // 订单来源
        invoiceType: null, // 发票类型 1
        invoiceAmount: null,
        invoiceSource: null,
        invoiceTime: null, // 开票时间
        sourceOrderCode: null, // 原始订单号
        startOrderTime: null, // 订单开始时间
        endOrderTime: null// 订单截止时间
      },
      formLabel: [
        {
          model: 'orderId',
          label: '订单号',
          type: 'input',
          rule: /[^\w]/g // 可输入数字字母
        },
        {
          model: 'sourceOrderCode',
          label: '原始订单号',
          labelWidth: '100px',
          type: 'input',
          rule: /[^\w]/g // 可输入数字字母
        },
        {
          model: 'invoiceStartTime',
          label: '开票日期',
          type: 'date',
          pickerOptions: {
            disabledDate(time) {
              return _this.listQuery.invoiceEndTime && time.getTime() >= new Date(_this.listQuery.invoiceEndTime).getTime() + 86400000
            }
          },
          timeClass: 'start-time-style'
        },
        {
          model: 'invoiceEndTime',
          label: '-',
          customLabel: '开票日期',
          type: 'date',
          valueFormat: 'yyyy-MM-dd 23:59:59',
          labelWidth: '20px',
          pickerOptions: {
            disabledDate(time) {
              return _this.listQuery.invoiceStartTime && time.getTime() <= new Date(_this.listQuery.invoiceStartTime).getTime() - 86400000
            }
          },
          timeClass: 'end-time-style'
        },
 
        {
          model: 'startOrderTime',
          label: '下单时间',
          type: 'date',
          pickerOptions: {
            disabledDate(time) {
              return _this.listQuery.endOrderTime && time.getTime() >= new Date(_this.listQuery.endOrderTime).getTime() + 86400000
            }
          },
          timeClass: 'start-time-style'
        },
        {
          model: 'endOrderTime',
          label: '-',
          customLabel: '下单时间',
          type: 'date',
          valueFormat: 'yyyy-MM-dd 23:59:59',
          labelWidth: '20px',
          pickerOptions: {
            disabledDate(time) {
              return _this.listQuery.startOrderTime && time.getTime() <= new Date(_this.listQuery.startOrderTime).getTime() - 86400000
            }
          },
          timeClass: 'end-time-style'
        },
        {
          model: 'status',
          label: '开票状态',
          type: 'select',
          opts: [
            {
              id: '0',
              name: '未开票'
            },
            {
              id: '1',
              name: '已开票'
            },
            {
              id: '2',
              name: '开票失败'
            }
          ]
        },
        {
          model: 'orderSource',
          label: '开票来源',
          type: 'select',
          multiple: false,
          opts: orderSourceArr
        },
        {
          model: 'fpqqlsh',
          label: '发票号',
          type: 'input',
          showItem: false
        },
        {
          model: 'pushStatus',
          label: 'ESB推送状态',
          type: 'select',
          labelWidth: '100px',
          showItem: false,
          opts: [
            {
              id: '1',
              name: '推送成功'
            },
            {
              id: '0',
              name: '推送失败'
            }
          ]
        },
        {
          model: 'invoiceType',
          label: '抬头类型',
          type: 'select',
          showItem: false,
          opts: [
            {
              id: '0',
              name: '个人'
            },
            {
              id: '1',
              name: '企业'
            }
          ]
        }
      ],
      tableData: [],
      total: 0,
      form: {},
      accountStatementIsShow: false, // 对账单弹出框是否展示
      invoiceStatus: null, // 查询成功后存入发票状态
      showFormItem: false
    }
  },
  /**
   * 数据变化后刷新列表
   */
  activated() {
    this.queryList(this.$refs.table.getPageInfo())
  },
  created() {
    _this = this
  },
  methods: {
    toggleForm() {
      this.showFormItem = !this.showFormItem
    },
    /**
     * 查看对账单
     */
    lookAccountStatement(row) {
      this.$refs.accountStatement.accountStatementInfo(row.orderId)
      this.accountStatementIsShow = true
    },
    shoudongkaipiao() {
      this.$router.push({ name: 'manualInvoice' })
    },
    getPushStatus(row) {
      switch (row.pushStatus) {
        case '1': return {
          name: '推送成功',
          color: 'success'
        }
        default: return {
          name: '推送失败',
          color: 'warning'
        }
      }
    },
    // getInvoiceType (row) {
    //   if (row.invoiceType === '0') {
    //     return '个人'
    //   } else {
    //     return '企业'
    //   }
    // },
    getinvoiceSource(row) {
      if (row.invoiceSource === '0') {
        return '用户申请'
      } else {
        return '手动开票'
      }
    },
    getStatus(row) {
      switch (row.status) {
        case '0': return {
          name: '未开票',
          color: 'info'
        }
        case '1': return {
          name: '已开票',
          color: 'success'
        }
        case '2': return {
          name: '开票失败',
          color: 'warning'
        }
        default: break
      }
    },
    /**
   * 获取数组的label
   */
    getLabel(array, id) {
      var lableText = array.find((item) => {
        return item.id === id
      })
      if (lableText) {
        return lableText.name
      }
      return ''
    },
    /**
       * '分页信息改变时查询列表
       */
    handlePageInfoChange(pageInfo) {
      this.queryList(pageInfo)
    },
 
    /**
     * 重置
     */
    resetQuery() {
      this.$refs.table.reloadCurrent()
    },
    /**
     * 点击查询按钮
     *
      },
     */
    queryData() {
      this.$refs.table.changeCondition()
    },
    /**
     * 点击查看
     */
    lookInfo(row) {
      this.$router.push({
        name: 'invoiceInfo',
        query: { orderId: row.orderId }
      })
    },
    /**
 * 查看订单详情
 */
    lookOrderInfo(row) {
      this.$router.push({
        name: 'orderMgtInfo',
        query: {
          orderId: row.orderId,
          // promotionStatus: row.promotionStatus
        }
      })
    },
    /**
     * 点击审核
     */
    itemAudit(row) {
      this.$router.push({
        name: 'invoiceAudit',
        query: { orderId: row.orderId }
      })
    },
    /**
     * 手动推送
     */
    getmanualPush(row, index) {
      this.$confirm('是否手动推送?', '手动推送', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          BillingResources.manualPush(row.orderId).then((res) => {
            if (res.code === '0') {
              this.$message.success('操作成功')
              this.$refs.table.changeCondition()
            }
          })
        })
    },
    /**
     *优惠明细
     */
    discountDetails(row) {
      this.$router.push({
        name: 'invoiceInfo',
        query: { orderId: row.orderId, name: 'productdetails' }
      })
    },
    /**
         * 查询列表
         */
    queryList(pageInfo = { pageNum: 1, pageSize: 10 }) {
      let queryIsNull = true
      for (const i in this.listQuery) {
        if (this.listQuery[i]) {
          queryIsNull = false
          break
        }
      }
      const params = JSON.parse(JSON.stringify(this.listQuery))
      // 当查询条件为空时设置开票状态和推送状态的值
      if (queryIsNull) {
        const initTime = getDate(-30)
        params.status = '1'
        params.pushStatus = '1'
        params.invoiceStartTime = initTime[0] + ' 00:00:00'
        params.invoiceEndTime = initTime[1] + ' 23:59:59'
      }
      BillingResources.getList({
        ...params,
        ...pageInfo
      }).then((res) => {
        if (res.data) {
          this.tableData = res.data.list
          this.setKey(res.data.list, pageInfo);
          this.total = res.data.total
          this.invoiceStatus = this.listQuery.status
          this.$nextTick(() => {
            this.$refs.table.$refs.table.doLayout()
          })
        }
      })
    },
    /**
     * 设置表格行唯一key
     */
    setKey(data, pageInfo) {
      if (data && data.length) {
        data.forEach((item, index) => {
          let curIndex = index + 1;
          item.key = (pageInfo.pageNum - 1) * pageInfo.pageSize + curIndex;
        })
      }
    }
  }
}
</script>
<style lang="scss">
.el-table__body img {
  width: 50px;
}
.refundInfo {
  .el-dialog__body {
    padding: 15px 20px;
    height: 700px;
    max-height: 800px;
    position: relative;
    overflow: hidden;
    .refund {
      position: absolute;
      left: 0;
      top: 0;
      right: -17px;
      bottom: 0;
      overflow-y: scroll;
      padding: 5px 10px;
    }
  }
}
</style>