<template>
|
<TableLayout :permissions="['business:ywcustomerrecharge:query']">
|
<el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
|
<el-form-item label="客户名称" prop="nameKeyword">
|
<el-input v-model="searchForm.nameKeyword" placeholder="客户名称" clearable @keypress.enter.native="search"/>
|
</el-form-item>
|
<el-form-item label="电表状态" prop="electricalStatusFilter">
|
<el-select v-model="searchForm.electricalStatusFilter" clearable placeholder="全部" style="min-width: 120px">
|
<el-option label="全在线" :value="1"/>
|
<el-option label="存在离线" :value="2"/>
|
<el-option label="无设备" :value="3"/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="空调状态" prop="conditionerStatusFilter">
|
<el-select v-model="searchForm.conditionerStatusFilter" clearable placeholder="全部" style="min-width: 120px">
|
<el-option label="全在线" :value="1"/>
|
<el-option label="存在离线" :value="2"/>
|
<el-option label="无设备" :value="3"/>
|
</el-select>
|
</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>
|
<el-table v-loading="isWorking.search" :data="tableData.list" stripe>
|
<el-table-column prop="type" label="客户类型" min-width="80" align="center">
|
<template slot-scope="{ row }">
|
<span>{{ row.type == 0 || row.type === '0' ? '个人' : '企业' }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="name" label="客户名称" min-width="140" align="center" show-overflow-tooltip/>
|
<el-table-column prop="memberName" label="联系人" min-width="120" align="center" show-overflow-tooltip>
|
<template slot-scope="{ row }">{{ row.memberName || '-' }}</template>
|
</el-table-column>
|
<el-table-column prop="memberPhone" label="联系电话" min-width="130" align="center">
|
<template slot-scope="{ row }">{{ row.memberPhone || '-' }}</template>
|
</el-table-column>
|
<el-table-column prop="electricalCount" label="关联电表数" min-width="100" align="center"/>
|
<el-table-column label="电表余额" min-width="140" align="center">
|
<template slot-scope="{ row }">
|
<span v-if="!row.electricalBalances || !row.electricalBalances.length" class="balance-text">-</span>
|
<el-tooltip v-else placement="top" effect="dark">
|
<div slot="content" class="balance-tooltip">
|
<div v-for="(item, idx) in row.electricalBalances" :key="idx" class="balance-tooltip-line">
|
{{ item.name }}({{ item.address }}):{{ formatBalance(item.balance) }}
|
</div>
|
</div>
|
<span class="balance-text balance-summary">
|
<template v-for="(item, idx) in row.electricalBalances">
|
<span :key="'b-' + idx" :class="{ red: isAmountLow(item.balance) }">{{ formatBalance(item.balance) }}</span><span v-if="idx < row.electricalBalances.length - 1" :key="'s-' + idx">/</span>
|
</template>
|
</span>
|
</el-tooltip>
|
</template>
|
</el-table-column>
|
<el-table-column prop="conditionerCount" label="空调内机数" min-width="100" align="center"/>
|
<el-table-column label="空调余额" min-width="110" align="center">
|
<template slot-scope="{ row }">
|
<span v-if="row.acBalance == null" class="balance-text">-</span>
|
<span v-else class="balance-text" :class="{ red: isAmountLow(row.acBalance) }">{{ row.acBalance }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createDate" label="创建时间" min-width="160" align="center"/>
|
<el-table-column label="操作" min-width="180" align="center" fixed="right">
|
<template slot-scope="{ row }">
|
<el-button type="text" v-permissions="['business:ywcustomerrecharge:bindDevice']" @click="openDevice(row)">关联设备</el-button>
|
<el-button type="text" v-permissions="['business:ywcustomerrecharge:recharge']" @click="openRecharge(row)">充值</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"/>
|
</template>
|
<YwCustomerDeviceWindow ref="deviceWindow" @success="search"/>
|
<YwCustomerRechargeWindow ref="rechargeWindow" @success="search"/>
|
</TableLayout>
|
</template>
|
|
<script>
|
import BaseTable from '@/components/base/BaseTable'
|
import TableLayout from '@/layouts/TableLayout'
|
import Pagination from '@/components/common/Pagination'
|
import * as api from '@/api/business/ywcustomerrecharge'
|
import YwCustomerDeviceWindow from './components/YwCustomerDeviceWindow'
|
import YwCustomerRechargeWindow from './components/YwCustomerRechargeWindow'
|
|
export default {
|
name: 'YwCustomerRecharge',
|
extends: BaseTable,
|
components: { TableLayout, Pagination, YwCustomerDeviceWindow, YwCustomerRechargeWindow },
|
data () {
|
return {
|
searchForm: {
|
nameKeyword: '',
|
electricalStatusFilter: null,
|
conditionerStatusFilter: null
|
}
|
}
|
},
|
created () {
|
this.search()
|
},
|
methods: {
|
handlePageChange (pageIndex) {
|
this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
|
this.loadList()
|
},
|
loadList () {
|
this.isWorking.search = true
|
api.merchantPage({
|
page: this.tableData.pagination.pageIndex,
|
capacity: this.tableData.pagination.pageSize,
|
model: this.buildSearchModel()
|
}).then(data => {
|
this.tableData.list = (data && data.records) || []
|
this.tableData.pagination.total = (data && data.total) || 0
|
}).catch(e => {
|
this.$tip.apiFailed(e)
|
}).finally(() => { this.isWorking.search = false })
|
},
|
search () {
|
this.tableData.pagination.pageIndex = 1
|
this.loadList()
|
},
|
handleSizeChange (size) {
|
this.tableData.pagination.pageSize = size
|
this.loadList()
|
},
|
buildSearchModel () {
|
const model = {}
|
if (this.searchForm.nameKeyword) model.nameKeyword = this.searchForm.nameKeyword
|
if (this.searchForm.electricalStatusFilter != null) model.electricalStatusFilter = this.searchForm.electricalStatusFilter
|
if (this.searchForm.conditionerStatusFilter != null) model.conditionerStatusFilter = this.searchForm.conditionerStatusFilter
|
return model
|
},
|
reset () {
|
this.searchForm = { nameKeyword: '', electricalStatusFilter: null, conditionerStatusFilter: null }
|
this.search()
|
},
|
openDevice (row) {
|
this.$refs.deviceWindow.open(row)
|
},
|
openRecharge (row) {
|
this.$refs.rechargeWindow.open(row)
|
},
|
formatBalance (val) {
|
if (val == null || val === '') return '0'
|
const n = parseFloat(val)
|
return isNaN(n) ? val : String(val)
|
},
|
isAmountLow (val) {
|
if (val == null || val === '' || val === '-') return false
|
const n = parseFloat(val)
|
return !isNaN(n) && n <= 0
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.red { color: #f56c6c; }
|
.balance-text { white-space: nowrap; }
|
.balance-summary {
|
cursor: default;
|
}
|
</style>
|
|
<style>
|
.balance-tooltip {
|
line-height: 22px;
|
}
|
.balance-tooltip-line {
|
white-space: nowrap;
|
}
|
</style>
|