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
<template>
  <div class="cardCurrentStyle1 thirdPartLogStyle">
    <!-- {{activeName}} -->
    <el-tabs type="card" v-model="activeName" @tab-click="pcc">
      <el-tab-pane label="发货物流推送日志" name="deliveryPushLog"></el-tab-pane>
      <el-tab-pane label="发货物流回传日志" name="deliveryReturnLog"></el-tab-pane>
      <el-tab-pane label="未发货拦截日志" name="noDeliveryInterceptLog"></el-tab-pane>
      <el-tab-pane label="退款申请推送日志" name="refundPushLog"></el-tab-pane>
      <el-tab-pane label="退款结果回传日志" name="refundReturnLog"></el-tab-pane>
      <!-- <el-tab-pane label="订单接收日志" name="fifth"></el-tab-pane> -->
    </el-tabs>
    <!-- {{listQuery}} -->
    <list-condition-template ref="table" :form="listQuery" :formLabel="formLabel"
                             :tableData="tableData" :total="total"
                             @page-info-change="handlePageInfoChange" :pageParams="pageInfo">
      <template slot="otherElement">
        <el-col :span="6" :offset="0">
          <el-form-item>
            <el-button size="mini" type="primary" @click="queryData">查询</el-button>
            <el-button size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </template>
      <template slot="columns">
        <el-table-column label="接口" prop="identification" width="160" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="订单编号" prop="orderId" show-overflow-tooltip width="180">
          <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="订单来源" prop="orderSource" width="160" show-overflow-tooltip>
          <template slot-scope="scope">
            {{getLabel(scope.row.orderSource, 'orderSource')}}
          </template>
        </el-table-column>
        <el-table-column label="物流服务商" width="120px" show-overflow-tooltip>
          <template slot-scope="scope">
            {{
              scope.row.logisticSupplier
                ? getText(logisticSupplierData, scope.row.logisticSupplier)
                : '-'
            }}</template>
        </el-table-column>
        <template v-if="activeName === 'deliveryPushLog' || activeName === 'refundPushLog'">
          <el-table-column label="推送状态" prop="responseResult" :key="Math.random()" width="150">
            <template slot-scope="scope">
              {{scope.row.responseResult === '1' ? "推送成功" : scope.row.responseResult === '2' ? "推送失败" : ' '}}
            </template>
          </el-table-column>
          <el-table-column label="推送失败原因" prop="message" :key="Math.random()">
            <template slot-scope="scope">
              <span>{{scope.row.message}}</span>
            </template>
          </el-table-column>
        </template>
        <template v-if="activeName === 'deliveryReturnLog'">
          <el-table-column label="物流回传状态" prop="responseResult" :key="Math.random()">
            <template slot-scope="scope">
              {{scope.row.responseResult === '1' ? "回传成功" : scope.row.responseResult === '2' ? "回传失败" : ' '}}
            </template>
          </el-table-column>
          <el-table-column label="回传失败原因" prop="message" :key="Math.random()">
            <template slot-scope="scope">
              <span>{{scope.row.message}}</span>
            </template>
          </el-table-column>
        </template>
        <template v-if="activeName === 'refundReturnLog'">
          <el-table-column label="退款结果回传" prop="responseResult" :key="Math.random()">
            <template slot-scope="scope">
              {{scope.row.responseResult === '1' ? "回传成功" : scope.row.responseResult === '2' ? "回传失败" : ' '}}
            </template>
          </el-table-column>
          <el-table-column label="退款结果失败原因" prop="message" :key="Math.random()">
            <template slot-scope="scope">
              <span>{{scope.row.message}}</span>
            </template>
          </el-table-column>
        </template>
        <template v-if="activeName === 'noDeliveryInterceptLog'">
          <el-table-column label="拦截类型" prop="interceptType" :key="Math.random()">
            <template slot-scope="scope">
              {{scope.row.interceptType === '1' ? "系统拦截" : scope.row.interceptType === '2' ? "手动拦截" : ' '}}
            </template>
          </el-table-column>
          <el-table-column label="拦截状态" prop="responseResult" :key="Math.random()">
            <template slot-scope="scope">
              {{scope.row.responseResult === '1' ? "拦截成功" : scope.row.responseResult === '2' ? "拦截失败" : ' '}}
            </template>
          </el-table-column>
          <el-table-column label="拦截失败原因" prop="message" :key="Math.random()">
            <template slot-scope="scope">
              <span>{{scope.row.message}}</span>
            </template>
          </el-table-column>
        </template>
        <el-table-column label="开始时间" prop="requestTiem" width="180">
          <template slot-scope="scope">
            <span>{{scope.row.requestTiem}}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" :width="`${$store.getters.colSize + 20}px`">
          <template slot-scope="scope">
            <wly-btn @click="logInfo(scope.row)">查看</wly-btn>
          </template>
        </el-table-column>
      </template>
    </list-condition-template>
  </div>
</template>
 
<script>
import orderSourceArr from '@/utils/constant/orderSourceArr'
import orderMgtApi from '@/api/orderMgt'
import logThirdPartySystemApi from '@/api/LogId'
import { getDate } from '@/utils/getDate'
import { getArrayLable } from '@/utils/getArrayLable'
 
export default {
  data() {
    return {
      activeName: 'deliveryPushLog',
      listQuery: {
        orderSourceArr: null,
        orderSource: null,
        responseResult: null,
        message: null,
        identification: null,
        orderId: null,
        createTime: null,
        timeSlot: [],
        type: '',
        interceptType: null
      },
      formLabel: [
        {
          model: 'identification',
          label: '接口名',
          type: 'input'
        },
        {
          model: 'responseResult',
          label: '',
          type: 'select',
          opts: []
        },
        {
          model: 'timeSlot',
          label: '选择时间',
          type: 'date',
          flag: 'daterange',
          valueFormat: 'yyyy-MM-dd'
        },
        {
          model: 'orderSource',
          label: '订单来源',
          type: 'select',
          multiple: false,
          opts: orderSourceArr
        },
        {
          model: 'interceptType',
          label: '拦截类型',
          type: 'select',
          isHide: true,
          opts: [
            {
              id: '1',
              name: '系统拦截'
            },
            {
              id: '2',
              name: '手动拦截'
            }
          ]
        },
        {
          model: 'orderId',
          label: '订单号',
          type: 'input',
          flag: 'textarea',
          rule: /[^\w]/g // 可输入数字字母
        }
      ],
      tableData: [],
      total: 0,
      form: {},
      pushArr: [ // 推送状态
        {
          id: '1',
          name: '推送成功'
        },
        {
          id: '2',
          name: '推送失败'
        }
      ],
      returnArr: [ // 回传状态
        {
          id: '1',
          name: '回传成功'
        },
        {
          id: '2',
          name: '回传失败'
        }
      ],
      interceptArr: [ // 拦截状态
        {
          id: '1',
          name: '拦截成功'
        },
        {
          id: '2',
          name: '拦截失败'
        }
      ],
      deliveryPushLog: {
        tableData: [],
        total: 0
      },
      deliveryReturnLog: {
        tableData: [],
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
      refundPushLog: {
        tableData: [],
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
      refundReturnLog: {
        tableData: [],
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
      noDeliveryInterceptLog: {
        tableData: [],
        total: 0,
        pageNum: 1,
        pageSize: 10
      },
      pageInfo: {
        pageNum: 1,
        pageSize: 10
      },
      logisticSupplierData: [],
    }
  },
  activated() {
    // this.queryList(this.$refs.table.getPageInfo())
  },
  mounted() {
    this.initFormLabel()
    // 获取物流服务商
    this.getLogisticsProvidersData();
  },
  methods: {
    /**
     * 获取物流服务商
     */
    async getLogisticsProvidersData() {
      let arr = [];
      const res = await orderMgtApi.getWarehouseTree({})
      if (res.code === '200' && res.data.length) {
        res.data.forEach((item) => {
          arr.push({
            id: item.warehouseService,
            name: item.warehouseServiceName,
          })
        })
        this.logisticSupplierData = arr;
      }
    },
    /**
 * 查看订单详情
 */
    lookOrderInfo(row) {
      this.$router.push({
        name: 'orderMgtInfo',
        query: {
          orderId: row.orderId
          // promotionStatus: row.promotionStatus
        }
      })
    },
    initFormLabel() {
      this.formLabel.forEach((item) => {
        if (item.model === 'responseResult') {
          if (this.activeName === 'deliveryPushLog' || this.activeName === 'refundPushLog') {
            item.label = '推送状态'
            item.opts = this.pushArr
          } else if (this.activeName === 'deliveryReturnLog' || this.activeName === 'refundReturnLog') {
            item.opts = this.returnArr
            item.label = '回传状态'
          } else if (this.activeName === 'noDeliveryInterceptLog') {
            item.opts = this.interceptArr
            item.label = '拦截状态'
          }
        } else if (this.activeName === 'noDeliveryInterceptLog' && item.model === 'interceptType') {
          item.isHide = false
        } else if (item.model === 'interceptType') {
          item.isHide = true
        }
      })
    },
    pcc() {
      this.initFormLabel();
      this.tableData = this[this.activeName].tableData;
      this.total = this[this.activeName].total;
      this.pageInfo = {
        pageNum: this[this.activeName].pageNum,
        pageSize: this[this.activeName].pageSize,
      }
      // this.resetQuery()
    },
    /**
     * 获取数组的label
     */
    getLabel(id, orderSource) {
      let lableText = ''
      this.formLabel.forEach((item) => {
        if (item.model === orderSource) {
          item.opts.forEach((list) => {
            if (id === list.id) {
              lableText = list.name
            }
          })
        }
      })
      return lableText
    },
    getText(array, id) {
      return getArrayLable(array, id)
    },
    /**
       * '分页信息改变时查询列表
       */
    handlePageInfoChange(pageInfo) {
      this.queryList(pageInfo)
    },
    /**
     * 重置
     */
    resetQuery() {
      this.$refs.table.reloadCurrent()
    },
    /**
     * 点击查询按钮
     *
      },
     */
    queryData() {
      this.$refs.table.changeCondition()
    },
    /**
     * 点击查看
     */
    logInfo(row) {
      this.$router.push({
        name: 'thirdPartLogInfo',
        query: {
          logId: row.logId,
          state: this.activeName
        }
      })
    },
    /**
         * 查询列表
         */
    fomeState(type) {
      switch (type) {
        case 'deliveryPushLog':
          return '1'
        case 'deliveryReturnLog':
          return '2'
        case 'refundPushLog':
          return '3'
        case 'refundReturnLog':
          return '4'
        case 'noDeliveryInterceptLog':
          return '5'
        default:
          break
      }
    },
    /**
     * 当初始条件为空时 设置时间为当前的一个月
     */
    initOrderTime() {
      let queryIsNull = true
      let initTime = null
      for (const i in this.listQuery) {
        if ((Array.isArray(this.listQuery[i]) && this.listQuery[i].length) || (!Array.isArray(this.listQuery[i]) && this.listQuery[i])) {
          queryIsNull = false
          break
        }
      }
      if (queryIsNull) {
        initTime = getDate(-30)
      }
      return initTime
    },
    queryList(pageInfo = { pageNum: 1, pageSize: 10 }) {
      const param = JSON.parse(JSON.stringify(this.listQuery))
      param.type = this.fomeState(this.activeName)
      const initTime = this.initOrderTime()
      if (initTime) {
        param.startTime = initTime[0] + ' 00:00:00'
        param.endTime = initTime[1] + ' 23:59:59'
      }
      if (param.timeSlot && param.timeSlot.length) {
        param.startTime = param.timeSlot[0] + ' 00:00:00'
        param.endTime = param.timeSlot[1] + ' 23:59:59'
      }
      logThirdPartySystemApi.getList({
        ...pageInfo,
        param
      }).then((res) => {
        if (res.data) {
          this.tableData = this[this.activeName].tableData = res.data.list;
          this.total = this[this.activeName].total = res.data.total;
          this[this.activeName].pageNum = pageInfo.pageNum;
          this[this.activeName].pageSize = pageInfo.pageSize;
        }
      })
    }
  }
}
</script>
 
<style lang="scss">
.thirdPartLogStyle {
  background-color: rgb(242, 242, 242);
  // padding:20px;
  .el-tabs__header {
    // height:20px;
    background-color: #fff !important;
    border-top-right-radius: 6px;
    padding: 20px 20px 0;
    border-bottom: none;
    .el-tabs__nav-wrap {
      border-bottom: 1px solid #e4e7ed !important;
    }
  }
}
</style>