设备微调
This commit is contained in:
parent
c50d41bf45
commit
0c06cbb3ac
44
src/api/ss/time.js
Normal file
44
src/api/ss/time.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询设备时长变化记录列表
|
||||
export function listTime(query) {
|
||||
return request({
|
||||
url: '/ss/time/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询设备时长变化记录详细
|
||||
export function getTime(id) {
|
||||
return request({
|
||||
url: '/ss/time/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增设备时长变化记录
|
||||
export function addTime(data) {
|
||||
return request({
|
||||
url: '/ss/time',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改设备时长变化记录
|
||||
export function updateTime(data) {
|
||||
return request({
|
||||
url: '/ss/time',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除设备时长变化记录
|
||||
export function delTime(id) {
|
||||
return request({
|
||||
url: '/ss/time/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
|
@ -76,3 +76,19 @@ export function refreshIot(deviceId) {
|
|||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 添加时长
|
||||
export function addTime(deviceId, amount) {
|
||||
return request({
|
||||
url: `/system/device/addTime/${deviceId}?amount=${amount}`,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
||||
// 时长归零
|
||||
export function resetDevice(deviceId) {
|
||||
return request({
|
||||
url: `/system/device/${deviceId}/reset`,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -450,3 +450,7 @@ export function escapeHtml(text, allowScript = false) {
|
|||
// 再转义其他HTML特殊字符
|
||||
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
|
||||
}
|
||||
|
||||
export function isEmpty(str) {
|
||||
return str == null || str.length === 0;
|
||||
}
|
||||
|
|
27
src/utils/mixins.js
Normal file
27
src/utils/mixins.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
export const $view = {
|
||||
props: {
|
||||
view: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hasView() {
|
||||
return (views) => {
|
||||
if (views == null || views.length === 0) {
|
||||
return false;
|
||||
}
|
||||
let list = views;
|
||||
if (views instanceof String) {
|
||||
list = views.split(',');
|
||||
}
|
||||
return list != null && list.includes(this.view);
|
||||
}
|
||||
},
|
||||
notHasView() {
|
||||
return (views) => {
|
||||
return !this.hasView(views);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
270
src/views/ss/time/index.vue
Normal file
270
src/views/ss/time/index.vue
Normal file
|
@ -0,0 +1,270 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="变化原因" prop="reason">
|
||||
<el-input
|
||||
v-model="queryParams.reason"
|
||||
placeholder="请输入变化原因"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人" prop="operatorName">
|
||||
<el-input
|
||||
v-model="queryParams.operatorName"
|
||||
placeholder="请输入操作人名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['ss:time:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="timeList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="记录id" align="center" prop="id" width="100"/>
|
||||
<el-table-column label="时长" align="center" prop="amount" >
|
||||
<template slot-scope="d">{{d.row.amount}} 分钟</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="变化原因" align="center" prop="reason" />\
|
||||
<el-table-column label="操作人名称" align="center" prop="operatorName" />
|
||||
<el-table-column label="操作人类型" align="center" prop="operatorType">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.ss_record_time_operator_type" :value="scope.row.operatorType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作时间" align="center" prop="operatorTime" width="180"/>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改设备时长变化记录对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="设备id" prop="deviceId">
|
||||
<el-input v-model="form.deviceId" placeholder="请输入设备id" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时长变化量" prop="amount">
|
||||
<el-input v-model="form.amount" placeholder="请输入时长变化量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="变化原因" prop="reason">
|
||||
<el-input v-model="form.reason" placeholder="请输入变化原因" />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人名称" prop="operatorName">
|
||||
<el-input v-model="form.operatorName" placeholder="请输入操作人名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人类型" prop="operatorType">
|
||||
<el-select v-model="form.operatorType" placeholder="请选择操作人类型">
|
||||
<el-option
|
||||
v-for="dict in dict.type.ss_record_time_operator_type"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作时间" prop="operatorTime">
|
||||
<el-date-picker clearable
|
||||
v-model="form.operatorTime"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="请选择操作时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listTime, getTime, delTime, addTime, updateTime } from "@/api/ss/time";
|
||||
import { $view } from '@/utils/mixins'
|
||||
|
||||
export default {
|
||||
name: "RecordTime",
|
||||
mixins: [$view],
|
||||
dicts: ['ss_record_time_operator_type'],
|
||||
props: {
|
||||
query: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备时长变化记录表格数据
|
||||
timeList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
deviceSn: null,
|
||||
reason: null,
|
||||
operatorName: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
deviceId: [
|
||||
{ required: true, message: "设备id不能为空", trigger: "blur" }
|
||||
],
|
||||
amount: [
|
||||
{ required: true, message: "时长变化量不能为空", trigger: "blur" }
|
||||
],
|
||||
operatorTime: [
|
||||
{ required: true, message: "操作时间不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.queryParams = {
|
||||
...this.queryParams,
|
||||
...this.query
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询设备时长变化记录列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTime(this.queryParams).then(response => {
|
||||
this.timeList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
deviceId: null,
|
||||
amount: null,
|
||||
reason: null,
|
||||
operatorId: null,
|
||||
operatorName: null,
|
||||
operatorType: null,
|
||||
operatorTime: null
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.id)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加设备时长变化记录";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids
|
||||
getTime(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改设备时长变化记录";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateTime(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addTime(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal.confirm('是否确认删除设备时长变化记录编号为"' + ids + '"的数据项?').then(function() {
|
||||
return delTime(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('ss/time/export', {
|
||||
...this.queryParams
|
||||
}, `time_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -3,6 +3,8 @@
|
|||
<el-card class="box-card">
|
||||
<el-descriptions title="设备详情">
|
||||
<template slot="extra">
|
||||
<el-button icon="el-icon-refresh" @click="handleReset">时长归零</el-button>
|
||||
<el-button icon="el-icon-plus" @click="handleAddElectricity">增加时长</el-button>
|
||||
<el-button icon="el-icon-refresh" @click="refreshIot" style="margin-right: 1em">刷新设备信息</el-button>
|
||||
<el-popover
|
||||
placement="left"
|
||||
|
@ -33,41 +35,61 @@
|
|||
<!-- <template v-else>--</template>-->
|
||||
<!-- </el-descriptions-item>-->
|
||||
<el-descriptions-item label="WIFI">{{deviceData.wifi | defaultValue}}</el-descriptions-item>
|
||||
<el-descriptions-item label="剩余时长">{{surplusTime | defaultValue}} 分钟</el-descriptions-item>
|
||||
<el-descriptions-item label="剩余时长">{{surplusTime}} 分钟</el-descriptions-item>
|
||||
<el-descriptions-item label="设备剩余时长">
|
||||
{{deviceData.remainTime / 60 | money | defaultValue}} 分钟
|
||||
<span class="remark-text">最近更新时间:{{deviceData.lastPullTime}}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="实时功率">{{deviceData.realTimePower | defaultValue}} KWH</el-descriptions-item>
|
||||
<el-descriptions-item label="备注">{{deviceData.remark | defaultValue}}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<el-card class="box-card">
|
||||
<meter-record-report :device-id="deviceData.deviceId"/>
|
||||
</el-card>
|
||||
<!-- <el-card class="box-card">-->
|
||||
<!-- <meter-record-report :device-id="deviceData.deviceId"/>-->
|
||||
<!-- </el-card>-->
|
||||
|
||||
<el-card class="box-card">
|
||||
<el-tabs>
|
||||
<el-tab-pane label="套餐列表" :lazy="true">
|
||||
<suit v-if="deviceData.deviceId != null" :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="充值记录" :lazy="true">
|
||||
<el-tab-pane label="用户充值记录" :lazy="true">
|
||||
<recharge-record :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="时长归零记录" :lazy="true">
|
||||
<reset-record :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="时长增加记录" :lazy="true">
|
||||
<record-time :query="{deviceId: deviceData.deviceId}" view="device"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="抄表记录" :lazy="true">
|
||||
<reading-record :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="归零记录" :lazy="true">
|
||||
<reset-record :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="绑定记录" :lazy="true">
|
||||
<bind-record :device-id="deviceData.deviceId"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
|
||||
<!--添加时长-->
|
||||
<el-dialog title="增加时长" :visible.sync="showAddElectricity" center width="400px">
|
||||
<el-form :model="addElectricityForm" :rules="addRules">
|
||||
<el-form-item label="时长" prop="amount">
|
||||
<el-input-number v-model="addElectricityForm.amount" style="width: 250px" controls-position="right" :step="1" step-strictly :min="0"/> 分钟
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" plain @click="submitAddElectricity">确认</el-button>
|
||||
<el-button plain @click="showAddElectricity = false">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {getDevice, refreshIot} from "@/api/system/device";
|
||||
import { addTime, getDevice, refreshIot, resetDevice } from '@/api/system/device'
|
||||
import LineChart from "@/views/dashboard/LineChart.vue";
|
||||
import RechargeRecord from "@/views/system/device/components/rechargeRecord.vue";
|
||||
import {formatDate} from "@/utils";
|
||||
|
@ -80,10 +102,12 @@ import ResetRecord from "@/views/system/device/components/resetRecord.vue";
|
|||
import TenantList from "@/views/system/device/components/tenantList.vue";
|
||||
import SuitList from '@/views/system/device/components/suitList.vue'
|
||||
import Suit from '@/views/ss/suit/index.vue'
|
||||
import RecordTime from '@/views/ss/time/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'deviceDetail',
|
||||
components: {
|
||||
RecordTime,
|
||||
Suit,
|
||||
SuitList,
|
||||
TenantList, ResetRecord, BindRecord, ReadingRecord, MeterRecordReport, QrCode, RechargeRecord, LineChart},
|
||||
|
@ -94,6 +118,15 @@ export default {
|
|||
deviceData: {},
|
||||
timer: null,
|
||||
surplusTime: 0, // 剩余时长
|
||||
addElectricityForm: {
|
||||
amount: 0
|
||||
},
|
||||
showAddElectricity: false,
|
||||
addRules: {
|
||||
amount: [
|
||||
{ required: true, message: '请输入电量', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -123,6 +156,32 @@ export default {
|
|||
}
|
||||
return ((expireTime - now) / 60000).toFixed(2);
|
||||
},
|
||||
handleReset() {
|
||||
resetDevice(this.deviceData.deviceId).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('操作成功');
|
||||
this.getDevice();
|
||||
}
|
||||
})
|
||||
},
|
||||
handleAddElectricity() {
|
||||
this.resetAddElectricityForm();
|
||||
this.showAddElectricity = true;
|
||||
},
|
||||
submitAddElectricity() {
|
||||
addTime(this.deviceData.deviceId, this.addElectricityForm.amount).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('操作成功');
|
||||
this.showAddElectricity = false;
|
||||
this.getDevice();
|
||||
}
|
||||
})
|
||||
},
|
||||
resetAddElectricityForm() {
|
||||
this.addElectricityForm = {
|
||||
amount: 0
|
||||
}
|
||||
},
|
||||
// 刷新设备信息
|
||||
refreshIot() {
|
||||
refreshIot(this.deviceData.deviceId).then(data => {
|
||||
|
|
|
@ -124,9 +124,10 @@
|
|||
<el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="ID" align="center" prop="deviceId" />
|
||||
<el-table-column label="型号图片" align="center" prop="picture" width="100">
|
||||
<el-table-column label="图片" align="center" prop="picture" width="100">
|
||||
<template slot-scope="scope">
|
||||
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
|
||||
<image-preview v-if="isEmpty(scope.row.customPicture)" :src="scope.row.picture" :width="50" :height="50"/>
|
||||
<image-preview v-else :src="scope.row.customPicture" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="设备二维码" align="center">
|
||||
|
@ -210,6 +211,11 @@
|
|||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="6em">
|
||||
<el-row :gutter="gutter">
|
||||
<el-col :span="span">
|
||||
<el-form-item label="自定义图片" prop="customPicture">
|
||||
<image-upload v-model="form.customPicture" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="span">
|
||||
<el-form-item label="型号" prop="modelId">
|
||||
<model-select v-model="form.modelId" :show-value.sync="form.model" @submit="onSubmitModel" :disabled="isEdit"/>
|
||||
|
@ -225,11 +231,6 @@
|
|||
<el-input v-model="form.deviceNo" placeholder="请输入设备SN" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="span">
|
||||
<el-form-item label="店铺" prop="storeId">
|
||||
<store-input v-model="form.storeId" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="span">
|
||||
<el-form-item label="设备名称" prop="deviceName">
|
||||
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||
|
@ -266,6 +267,7 @@ import {getWxIndexUrl} from "@/utils/wx";
|
|||
import SnInput from '@/components/SnInput/index.vue'
|
||||
import StoreInput from '@/components/Business/Store/StoreInput.vue'
|
||||
import UserInput from '@/components/Business/SmUser/UserInput.vue'
|
||||
import { isEmpty } from '@/utils'
|
||||
|
||||
export default {
|
||||
name: "Device",
|
||||
|
@ -346,6 +348,7 @@ export default {
|
|||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
isEmpty,
|
||||
handleBindSn(row) {
|
||||
this.form.deviceId = row.deviceId;
|
||||
this.showBindSn = true;
|
||||
|
@ -415,6 +418,7 @@ export default {
|
|||
remark: null,
|
||||
expireDate: null,
|
||||
expireDay: null,
|
||||
customPicture: null,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="时间" align="center" prop="createTime" width="180"/>
|
||||
<el-table-column label="到账时间" align="center" prop="payTime" width="180"/>
|
||||
<el-table-column label="打款方式" align="center">
|
||||
<template slot-scope="d">
|
||||
<dict-tag :value="d.row.channelId" :options="dict.type.sm_transaction_bill_pay_type"/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user