<template>
|
<TableLayout :permissions="['business:ywelectricalactions:query']">
|
<el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
|
<el-form-item label="操作类型" prop="actionType">
|
<el-select v-model="searchForm.actionType" clearable placeholder="全部" style="min-width: 160px">
|
<el-option
|
v-for="item in actionTypeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="操作时间" prop="operateTimeRange">
|
<el-date-picker
|
v-model="searchForm.operateTimeRange"
|
type="datetimerange"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
range-separator="-"
|
start-placeholder="开始时间"
|
end-placeholder="结束时间"
|
style="width: 360px"
|
/>
|
</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="id" label="ID" min-width="80" align="center" />
|
<el-table-column prop="electricalName" label="电表名称" min-width="140" align="center" show-overflow-tooltip>
|
<template slot-scope="{ row }">{{ row.electricalName || '-' }}</template>
|
</el-table-column>
|
<el-table-column prop="electricalAddress" label="电表地址" min-width="140" align="center" show-overflow-tooltip>
|
<template slot-scope="{ row }">{{ row.electricalAddress || '-' }}</template>
|
</el-table-column>
|
<el-table-column label="操作类型" min-width="120" align="center">
|
<template slot-scope="{ row }">{{ formatActionType(row.actionType) }}</template>
|
</el-table-column>
|
<el-table-column prop="oprId" label="操作ID" min-width="180" align="center" show-overflow-tooltip />
|
<el-table-column label="状态" min-width="90" align="center">
|
<template slot-scope="{ row }">
|
<span :class="statusClass(row.status)">{{ formatStatus(row.status) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="resultMsg" label="执行结果" min-width="160" align="center" show-overflow-tooltip>
|
<template slot-scope="{ row }">{{ row.resultMsg || '-' }}</template>
|
</el-table-column>
|
<el-table-column prop="createDate" label="操作时间" min-width="160" align="center" />
|
<el-table-column label="请求报文" min-width="100" align="center">
|
<template slot-scope="{ row }">
|
<el-button type="text" :disabled="!row.requestBody" @click="openJson('请求报文', row.requestBody)">查看</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column label="响应报文" min-width="100" align="center">
|
<template slot-scope="{ row }">
|
<el-button type="text" :disabled="!row.responseBody" @click="openJson('响应报文', row.responseBody)">查看</el-button>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" min-width="120" align="center" fixed="right">
|
<template slot-scope="{ row }">
|
<el-button
|
v-if="row.status === 0 && row.oprId"
|
type="text"
|
:loading="queryLoadingId === row.id"
|
v-permissions="['business:ywelectricalactions:queryResult']"
|
@click="handleQueryResult(row)"
|
>手动查询结果</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination
|
@size-change="handleSizeChange"
|
@current-change="handlePageChange"
|
:pagination="tableData.pagination"
|
/>
|
</template>
|
<OperaInterfaceLogWindow ref="jsonWindow" />
|
</TableLayout>
|
</template>
|
|
<script>
|
import BaseTable from '@/components/base/BaseTable'
|
import TableLayout from '@/layouts/TableLayout'
|
import Pagination from '@/components/common/Pagination'
|
import OperaInterfaceLogWindow from '@/components/business/OperaInterfaceLogWindow'
|
import * as actionsApi from '@/api/business/ywelectricalactions'
|
|
const ACTION_TYPE_MAP = {
|
1: '预付费清零',
|
2: '后付费清零',
|
3: '远程销户',
|
4: '拉闸',
|
5: '合闸',
|
6: '开户',
|
7: '充值',
|
8: '抄表',
|
9: '保电',
|
10: '解除保电'
|
}
|
|
export default {
|
name: 'YwElectricalActions',
|
extends: BaseTable,
|
components: { TableLayout, Pagination, OperaInterfaceLogWindow },
|
data () {
|
return {
|
searchForm: {
|
actionType: null,
|
operateTimeRange: []
|
},
|
actionTypeOptions: Object.keys(ACTION_TYPE_MAP).map(key => ({
|
value: Number(key),
|
label: ACTION_TYPE_MAP[key]
|
})),
|
queryLoadingId: null
|
}
|
},
|
created () {
|
this.api = actionsApi
|
this.module = '电表远程操作记录'
|
this.configData['field.id'] = 'id'
|
this.configData['field.main'] = 'id'
|
this.search()
|
},
|
methods: {
|
buildSearchModel () {
|
const model = {}
|
if (this.searchForm.actionType !== null && this.searchForm.actionType !== '' && this.searchForm.actionType !== undefined) {
|
model.actionType = this.searchForm.actionType
|
}
|
if (this.searchForm.operateTimeRange && this.searchForm.operateTimeRange.length === 2) {
|
model.operateTimeBegin = this.searchForm.operateTimeRange[0]
|
model.operateTimeEnd = this.searchForm.operateTimeRange[1]
|
}
|
return model
|
},
|
handlePageChange (pageIndex) {
|
this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
|
this.isWorking.search = true
|
actionsApi.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 })
|
},
|
reset () {
|
this.searchForm = { actionType: null, operateTimeRange: [] }
|
if (this.$refs.searchForm) {
|
this.$refs.searchForm.resetFields()
|
}
|
this.search()
|
},
|
formatActionType (val) {
|
return ACTION_TYPE_MAP[val] || val || '-'
|
},
|
formatStatus (val) {
|
if (val === 0 || val === '0') return '处理中'
|
if (val === 1 || val === '1') return '成功'
|
if (val === 2 || val === '2') return '失败'
|
return val == null || val === '' ? '-' : String(val)
|
},
|
statusClass (val) {
|
if (val === 1 || val === '1') return 'green'
|
if (val === 2 || val === '2') return 'red'
|
if (val === 0 || val === '0') return 'orange'
|
return ''
|
},
|
openJson (title, content) {
|
if (!content) return
|
this.$refs.jsonWindow.open(title, { content })
|
},
|
handleQueryResult (row) {
|
this.queryLoadingId = row.id
|
actionsApi.queryResult(row.id)
|
.then(msg => {
|
this.$tip.success(msg || '查询完成')
|
this.handlePageChange(this.tableData.pagination.pageIndex)
|
})
|
.catch(e => this.$tip.apiFailed(e))
|
.finally(() => { this.queryLoadingId = null })
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.green { color: #67c23a; }
|
.red { color: #f56c6c; }
|
.orange { color: #e6a23c; }
|
</style>
|