bonus-ui/src/views/kitchen/devicesManage/deviesRecord/index.vue

210 lines
7.2 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="searchValue">
<el-input v-model="queryParams.searchValue" placeholder="请输入设备名称,编号" maxlength="20" clearable style="width: 240px"/>
</el-form-item>
<el-form-item label="设备类型" prop="deviceType">
<el-select v-model="queryParams.deviceType" style="width: 100%;" placeholder="请选择设备类型">
<el-option
v-for="item in deviceTypeList"
:key="item.key"
:label="item.label"
:value="item.key"
></el-option>
</el-select>
</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">
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="tableListData" height="800">
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column label="设备名称" align="center" prop="deviceName" :show-overflow-tooltip="true" />
<el-table-column label="设备类型" align="center" prop="deviceType" :show-overflow-tooltip="true" />
<el-table-column label="所属食堂" align="center" prop="canteenName" :show-overflow-tooltip="true" />
<el-table-column label="位置" align="center" prop="subPlace" :show-overflow-tooltip="true" />
<el-table-column label="工作状态" align="center" prop="deviceNetworkState" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.deviceNetworkState==1">在线</span>
<span v-if="scope.row.deviceNetworkState==2">离线</span>
</template>
</el-table-column>
<el-table-column label="开始使用时间" align="center" prop="" :show-overflow-tooltip="true" width="160"/>
<el-table-column label="结束使用时间" align="center" prop="" :show-overflow-tooltip="true" width="160"/>
<el-table-column label="使用时长(h)" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="离线时长(h)" align="center" prop="" :show-overflow-tooltip="true" />
</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>
<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 { getKitchenDeviceUsageApi,getKitchenDeviceTypeApi } from "@/api/kitchen/devices";
export default {
name: "",
dicts: [],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//表格数据
tableListData: [],
deviceTypeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
deviceType: undefined,
searchValue: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
// canteenName: [
// { required: true, message: "字典名称不能为空", trigger: "blur" }
// ],
// dictType: [
// { required: true, message: "字典类型不能为空", trigger: "blur" }
// ]
}
};
},
created() {
this.getKitchenDeviceType();
this.getList();
},
methods: {
// 设备类型选项
getKitchenDeviceType(){
getKitchenDeviceTypeApi({}).then((response) => {
let obj = response.data
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
console.log(`Key: ${key}, Value: ${obj[key]}`);
this.deviceTypeList.push({"key":key,"label":obj[key]})
}
}
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 查询列表 */
getList() {
this.loading = true;
getKitchenDeviceUsageApi(this.queryParams).then(response => {
this.tableListData = response.rows;
this.total = Number(response.total);
this.loading = false;
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// const dictId = row.dictId || this.ids
// getType(dictId).then(response => {
// this.form = response.data;
this.open = true;
this.title = "修改";
// });
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {};
this.resetForm("form");
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictId != undefined) {
// updateType(this.form).then(response => {
// this.$modal.msgSuccess("修改成功");
// this.open = false;
// this.getList();
// });
} else {
// addType(this.form).then(response => {
// this.$modal.msgSuccess("新增成功");
// this.open = false;
// this.getList();
// });
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const dictIds = row.dictId || this.ids;
this.$modal.confirm('是否确认删除数据项?').then(function() {
// return delType(dictIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
}
};
</script>