530 lines
17 KiB
Vue
530 lines
17 KiB
Vue
<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="storeName">
|
|
<el-input
|
|
v-model="queryParams.storeName"
|
|
placeholder="请输入店铺名称"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="设备名称" prop="deviceName">
|
|
<el-input
|
|
v-model="queryParams.deviceName"
|
|
placeholder="请输入设备名称"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="型号" prop="model">
|
|
<el-input
|
|
v-model="queryParams.model"
|
|
placeholder="请输入型号"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="设备Mac" prop="mac">
|
|
<el-input
|
|
v-model="queryParams.mac"
|
|
placeholder="请输入设备Mac"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="在线状态" prop="onlineStatus">
|
|
<el-select v-model="queryParams.onlineStatus" placeholder="请选择在线状态" clearable>
|
|
<el-option
|
|
v-for="dict in dict.type.sm_device_online_status"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="状态" prop="status">
|
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
|
<el-option
|
|
v-for="dict in dict.type.sm_device_status"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="房东名称" prop="userName">
|
|
<el-input
|
|
v-model="queryParams.userName"
|
|
placeholder="请输入房东名称"
|
|
clearable
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="租户昵称" prop="tenantName">
|
|
<el-input
|
|
v-model="queryParams.tenantName"
|
|
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="primary"
|
|
plain
|
|
icon="el-icon-plus"
|
|
size="mini"
|
|
@click="handleAdd"
|
|
v-hasPermi="['system:device:add']"
|
|
>新增</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="success"
|
|
plain
|
|
icon="el-icon-edit"
|
|
size="mini"
|
|
:disabled="single"
|
|
@click="handleUpdate"
|
|
v-hasPermi="['system:device:edit']"
|
|
>修改</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="danger"
|
|
plain
|
|
icon="el-icon-delete"
|
|
size="mini"
|
|
:disabled="multiple"
|
|
@click="handleDelete"
|
|
v-hasPermi="['system:device:remove']"
|
|
>删除</el-button>
|
|
</el-col>
|
|
<el-col :span="1.5">
|
|
<el-button
|
|
type="warning"
|
|
plain
|
|
icon="el-icon-download"
|
|
size="mini"
|
|
@click="handleExport"
|
|
v-hasPermi="['system:device:export']"
|
|
>导出</el-button>
|
|
</el-col>
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
</el-row>
|
|
|
|
<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">
|
|
<template slot-scope="scope">
|
|
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="设备二维码" align="center">
|
|
<template slot-scope="d">
|
|
<el-popover
|
|
placement="top"
|
|
width="180"
|
|
trigger="hover">
|
|
<div class="qr-code-box">
|
|
<qr-code :text="qrCodeText(d.row.mac)" :width="150" :height="150" />
|
|
<p>扫描二维码进行设备绑定</p>
|
|
</div>
|
|
<el-button slot="reference" type="text" icon="el-icon-picture">查看</el-button>
|
|
</el-popover>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" />
|
|
<el-table-column label="型号" align="center" prop="model" />
|
|
<el-table-column label="设备Mac" align="center" prop="mac" />
|
|
<el-table-column label="剩余电量" align="center" prop="surplusElectriQuantity" />
|
|
<el-table-column label="在线状态" align="center" prop="onlineStatus">
|
|
<template slot-scope="scope">
|
|
<dict-tag :options="dict.type.sm_device_online_status" :value="scope.row.onlineStatus"/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
<template slot-scope="scope">
|
|
<dict-tag :options="dict.type.sm_device_status" :value="scope.row.status"/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="实时功率" align="center" prop="realTimePower" />
|
|
<el-table-column label="电流" align="center" prop="electricity" />
|
|
<el-table-column label="电压" align="center" prop="voltage" />
|
|
<el-table-column label="房东" align="center" prop="userName" />
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-view"
|
|
@click="handleSee(scope.row)"
|
|
v-hasPermi="['system:device:detail']"
|
|
>详细信息</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-edit"
|
|
@click="handleUpdate(scope.row)"
|
|
v-hasPermi="['system:device:edit']"
|
|
>修改</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-delete"
|
|
@click="handleDelete(scope.row)"
|
|
v-hasPermi="['system:device:remove']"
|
|
>删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</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="50%" append-to-body>
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
<el-row :gutter="gutter">
|
|
<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"/>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="房东" prop="userId">
|
|
<sm-user-select v-model="form.userId"
|
|
:show-value.sync="form.userName"
|
|
placeholder="点击选择房东"
|
|
title="选择房东"
|
|
:search="{userType: '01'}"
|
|
@submit="onSubmitUser" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="设备名称" prop="deviceName">
|
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="电费单价" prop="price">
|
|
<el-input v-model.trim="form.price" placeholder="请输入电费单价">
|
|
<template #append>元/度</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="断电方式" prop="outageWay">
|
|
<el-select v-model="form.outageWay" placeholder="请选择断电方式" style="width: 100%">
|
|
<el-option
|
|
v-for="dict in dict.type.sm_device_outage_way"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="房租到期提醒" prop="expireDate" label-width="7em">
|
|
<el-switch v-model="form.enableExpireNotice"/>
|
|
<el-row v-show="form.enableExpireNotice">
|
|
|
|
<el-select v-model="form.noticeWay" placeholder="请选择提醒方式">
|
|
<el-option
|
|
v-for="dict in dict.type.sm_device_notice_way"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.value"
|
|
/>
|
|
</el-select>
|
|
|
|
<el-date-picker
|
|
v-model="form.expireDate"
|
|
v-show="form.noticeWay === '1'"
|
|
:clearable="false"
|
|
type="date"
|
|
:picker-options="expireDatePickerOptions"
|
|
placeholder="请选择提醒日期">
|
|
</el-date-picker>
|
|
|
|
<el-select v-model="form.expireDay" placeholder="请选择提醒日" v-show="form.noticeWay === '2'">
|
|
<el-option v-for="day in 31" :key="day" :label="day + '日'" :value="day"/>
|
|
</el-select>
|
|
</el-row>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="服务费承担方" prop="tenantBearServiceFee" label-width="7em">
|
|
<el-select v-model="form.tenantBearServiceFee" style="width: 100%">
|
|
<el-option :value="true" label="租户"/>
|
|
<el-option :value="false" label="房东"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="span">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</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 {listDevice, getDevice, addDevice, updateDevice, logicDelDevice} from "@/api/system/device";
|
|
import ModelSelect from "@/components/Business/Model/modelSelect.vue";
|
|
import GroupSelect from "@/components/Business/Group/groupSelect.vue";
|
|
import SmUserSelect from "@/components/Business/SmUser/smUserSelect.vue";
|
|
import QrCode from "@/components/QrCode/index.vue";
|
|
import {getWxIndexUrl, getWxSchemeUrl} from "@/utils/wx";
|
|
|
|
export default {
|
|
name: "Device",
|
|
components: {QrCode, SmUserSelect, GroupSelect, ModelSelect},
|
|
dicts: ['sm_device_online_status', 'sm_device_status', 'sm_device_outage_way','sm_device_notice_way'],
|
|
data() {
|
|
return {
|
|
span: 12,
|
|
gutter: 16,
|
|
// 遮罩层
|
|
loading: true,
|
|
// 选中数组
|
|
ids: [],
|
|
// 非单个禁用
|
|
single: true,
|
|
// 非多个禁用
|
|
multiple: true,
|
|
// 显示搜索条件
|
|
showSearch: true,
|
|
// 总条数
|
|
total: 0,
|
|
// 设备表格数据
|
|
deviceList: [],
|
|
// 弹出层标题
|
|
title: "",
|
|
// 是否显示弹出层
|
|
open: false,
|
|
// 查询参数
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
storeName: null,
|
|
deviceName: null,
|
|
model: null,
|
|
mac: null,
|
|
onlineStatus: null,
|
|
status: null,
|
|
userName: null,
|
|
tenantName: null,
|
|
},
|
|
// 表单参数
|
|
form: {},
|
|
// 表单校验
|
|
rules: {
|
|
groupId: [
|
|
{ required: true, message: "分组不能为空", trigger: "change" }
|
|
],
|
|
modelId: [
|
|
{ required: true, message: "型号不能为空", trigger: "change" }
|
|
],
|
|
userId: [
|
|
{ required: true, message: "房东不能为空", trigger: "change" }
|
|
],
|
|
deviceName: [
|
|
{ required: true, message: "设备名称不能为空", trigger: "change" }
|
|
],
|
|
},
|
|
// 分组的查询条件
|
|
groupSearchForm: {
|
|
userId: null,
|
|
},
|
|
// 房租提醒日期选项配置
|
|
expireDatePickerOptions: {
|
|
disabledDate(date) {
|
|
return date.getTime() <= Date.now();
|
|
}
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
isEdit() {
|
|
return this.title === "修改设备";
|
|
},
|
|
// 二维码文本
|
|
qrCodeText() {
|
|
return (mac) => {
|
|
return getWxIndexUrl({ mac: mac});
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
// 选中房东后
|
|
onSubmitUser(user) {
|
|
this.form.userName = user?.userName;
|
|
this.form.nickName = user?.nickName;
|
|
this.onSubmitGroup(null);
|
|
},
|
|
// 打开分组前
|
|
beforeOpenGroup() {
|
|
if (this.form.userId == null) {
|
|
this.$message.error("请先选择房东")
|
|
return false;
|
|
}
|
|
this.groupSearchForm.userId = this.form.userId;
|
|
return true;
|
|
},
|
|
// 选中分组后
|
|
onSubmitGroup(group) {
|
|
this.form.groupId = group?.groupId;
|
|
this.form.groupName = group?.groupName;
|
|
},
|
|
// 选中型号后
|
|
onSubmitModel(model) {
|
|
this.form.model = model?.modelName;
|
|
},
|
|
/** 查询设备列表 */
|
|
getList() {
|
|
this.loading = true;
|
|
listDevice(this.queryParams).then(response => {
|
|
this.deviceList = response.rows;
|
|
this.total = response.total;
|
|
this.loading = false;
|
|
});
|
|
},
|
|
// 取消按钮
|
|
cancel() {
|
|
this.open = false;
|
|
this.reset();
|
|
},
|
|
// 表单重置
|
|
reset() {
|
|
this.form = {
|
|
deviceId: null,
|
|
picture: null,
|
|
groupId: null,
|
|
groupName: null,
|
|
deviceName: null,
|
|
modelId: null,
|
|
model: null,
|
|
mac: null,
|
|
activationTime: null,
|
|
surplusElectriQuantity: null,
|
|
lastPullTime: null,
|
|
onlineStatus: null,
|
|
status: null,
|
|
realTimePower: null,
|
|
electricity: null,
|
|
voltage: null,
|
|
userId: null,
|
|
userName: null,
|
|
nickName: null,
|
|
createBy: null,
|
|
createTime: null,
|
|
updateBy: null,
|
|
updateTime: null,
|
|
remark: null,
|
|
expireDate: null,
|
|
expireDay: 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.deviceId)
|
|
this.single = selection.length!==1
|
|
this.multiple = !selection.length
|
|
},
|
|
// 查看按钮操作
|
|
handleSee(row) {
|
|
this.$router.push({path: '/smDevice/detail', query: {deviceId: row.deviceId}})
|
|
},
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
this.reset();
|
|
this.open = true;
|
|
this.title = "添加设备";
|
|
},
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
this.reset();
|
|
const deviceId = row.deviceId || this.ids
|
|
getDevice(deviceId).then(response => {
|
|
this.form = response.data;
|
|
this.open = true;
|
|
this.title = "修改设备";
|
|
});
|
|
},
|
|
/** 提交按钮 */
|
|
submitForm() {
|
|
this.$refs["form"].validate(valid => {
|
|
if (valid) {
|
|
if (this.form.deviceId != null) {
|
|
updateDevice(this.form).then(response => {
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
} else {
|
|
addDevice(this.form).then(response => {
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.open = false;
|
|
this.getList();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
const deviceIds = row.deviceId || this.ids;
|
|
this.$modal.confirm('是否确认删除设备编号为"' + deviceIds + '"的数据项?').then(function() {
|
|
return logicDelDevice(deviceIds);
|
|
}).then(() => {
|
|
this.getList();
|
|
this.$modal.msgSuccess("删除成功");
|
|
}).catch(() => {});
|
|
},
|
|
/** 导出按钮操作 */
|
|
handleExport() {
|
|
this.download('system/device/export', {
|
|
...this.queryParams
|
|
}, `device_${new Date().getTime()}.xlsx`)
|
|
}
|
|
}
|
|
};
|
|
</script>
|