doum
9 天以前 0201c32312f6478b2bde706607c8c6338e9e1d06
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
<template>
  <TableLayout :permissions="['business:ywelectricalcharge:query']">
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="电表信息" prop="meterKeyword">
        <el-input v-model="searchForm.meterKeyword" placeholder="表名称/表地址" clearable @keypress.enter.native="search"/>
      </el-form-item>
      <el-form-item label="充值状态" prop="status">
        <el-select v-model="searchForm.status" clearable placeholder="全部" style="min-width: 120px">
          <el-option label="充值中" :value="0"/>
          <el-option label="充值成功" :value="1"/>
          <el-option label="充值失败" :value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item label="任务ID" prop="oprId">
        <el-input v-model="searchForm.oprId" placeholder="opr_id" clearable/>
      </el-form-item>
      <section>
        <el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
        <el-button icon="el-icon-refresh" @click="reset">重置</el-button>
      </section>
    </el-form>
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li>
          <el-button @click="exportExcel" :loading="isWorking.export" v-permissions="['business:ywelectricalcharge:exportExcel']">导出</el-button>
        </li>
      </ul>
      <el-table v-loading="isWorking.search" :data="tableData.list" stripe>
        <el-table-column prop="name" label="电表名称" min-width="130" align="center" show-overflow-tooltip/>
        <el-table-column prop="address" label="表地址" min-width="130" align="center" show-overflow-tooltip/>
        <el-table-column prop="roomNames" label="绑定房间" min-width="150" align="center" show-overflow-tooltip/>
        <el-table-column prop="money" label="充值金额(元)" min-width="110" align="center"/>
        <el-table-column prop="banlance" label="充值前余额" min-width="110" align="center"/>
        <el-table-column prop="balanceAfter" label="充值后余额" min-width="110" align="center"/>
        <el-table-column label="状态" min-width="100" align="center">
          <template slot-scope="{ row }">
            <span v-if="row.status === 0">充值中</span>
            <span v-else-if="row.status === 1" class="green">充值成功</span>
            <span v-else-if="row.status === 2" class="red">充值失败</span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column prop="oprId" label="任务ID" min-width="200" align="center" show-overflow-tooltip/>
        <el-table-column prop="remark" label="备注" min-width="120" align="center" show-overflow-tooltip/>
        <el-table-column prop="statusInfo" label="状态说明" min-width="140" align="center" show-overflow-tooltip/>
        <el-table-column prop="createDate" label="提交时间" min-width="160" align="center"/>
        <el-table-column prop="statusTime" label="状态更新时间" min-width="160" align="center"/>
        <el-table-column label="操作" min-width="100" align="center" fixed="right">
          <template slot-scope="{ row }">
            <el-button v-if="row.status === 0" type="text" v-permissions="['business:ywelectricalcharge:syncStatus']" @click="handleSync(row)">手动同步</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"/>
    </template>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import * as chargeApi from '@/api/business/ywelectricalcharge'
 
export default {
  name: 'YwElectricalCharge',
  extends: BaseTable,
  components: { TableLayout, Pagination },
  data () {
    return {
      searchForm: {
        meterKeyword: '',
        status: '',
        oprId: ''
      }
    }
  },
  created () {
    this.api = chargeApi
    this.module = '电表充值记录'
    this.configData['field.id'] = 'id'
    this.configData['field.main'] = 'name'
    this.search()
  },
  methods: {
    handlePageChange (pageIndex) {
      this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
      this.isWorking.search = true
      chargeApi.fetchList({
        page: this.tableData.pagination.pageIndex,
        capacity: this.tableData.pagination.pageSize,
        model: this.buildSearchModel(),
        sorts: this.tableData.sorts
      })
        .then(data => {
          this.tableData.list = data.records
          this.tableData.pagination.total = data.total
        })
        .catch(() => {})
        .finally(() => { this.isWorking.search = false })
    },
    buildSearchModel () {
      const model = { type: 0 }
      if (this.searchForm.meterKeyword) model.meterKeyword = this.searchForm.meterKeyword
      if (this.searchForm.status !== '' && this.searchForm.status !== null) model.status = this.searchForm.status
      if (this.searchForm.oprId) model.oprId = this.searchForm.oprId
      return model
    },
    reset () {
      this.searchForm = { meterKeyword: '', status: '', oprId: '' }
      this.search()
    },
    handleSync (row) {
      chargeApi.syncStatus(row.id)
        .then(msg => {
          this.$tip.success(msg || '同步完成')
          this.handlePageChange(this.tableData.pagination.pageIndex)
        })
        .catch(e => this.$tip.apiFailed(e))
    }
  }
}
</script>
 
<style scoped>
.green { color: #67c23a; }
.red { color: #f56c6c; }
</style>