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

355 lines
13 KiB
Vue
Raw Normal View History

2025-06-16 15:57:53 +08:00
<template>
<div class="app-container">
2025-06-19 13:21:27 +08:00
<div style="width: 100%;overflow-y: auto;">
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
<el-tab-pane :label="item.label" :name="item.key" v-for="(item,index) in deviceTypeList" :key="index"></el-tab-pane>
</el-tabs>
</div>
2025-06-16 15:57:53 +08:00
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
2025-06-19 17:53:35 +08:00
<el-form-item label="关键字" prop="keyWord">
<el-input v-model="queryParams.keyWord" placeholder="请输入设备名称,编号" maxlength="20" clearable style="width: 240px"/>
2025-06-16 15:57:53 +08:00
</el-form-item>
2025-06-19 13:21:27 +08:00
<el-form-item label="设备状态" prop="deviceNetworkState">
<el-select v-model="queryParams.deviceNetworkState" style="width: 240px" clearable>
<el-option label="在线" value="1"></el-option>
<el-option label="离线" value="2"></el-option>
2025-06-16 15:57:53 +08:00
</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>
2025-06-19 13:21:27 +08:00
</el-form>
2025-06-16 15:57:53 +08:00
<el-row :gutter="10" class="mb8">
2025-06-17 17:49:22 +08:00
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
2025-06-16 15:57:53 +08:00
<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>
2025-06-19 13:21:27 +08:00
<el-table-column label="设备编号" align="center" prop="deviceNo" :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="deviceName" :show-overflow-tooltip="true" />
<el-table-column label="设备SN码" align="center" prop="deviceSn" :show-overflow-tooltip="true" />
2025-06-27 17:20:53 +08:00
<el-table-column label="所属区域" align="center" prop="areaName" :show-overflow-tooltip="true"/>
2025-06-16 15:57:53 +08:00
<el-table-column label="所属食堂" align="center" prop="canteenName" :show-overflow-tooltip="true" />
<el-table-column label="位置" align="center" prop="subPlaceName" :show-overflow-tooltip="true" />
2025-06-16 15:57:53 +08:00
<el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</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"
/>
<!-- 添加或修改参数配置对话框 -->
2025-06-17 17:49:22 +08:00
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
2025-06-27 17:20:53 +08:00
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
2025-06-17 17:49:22 +08:00
<el-row>
<el-col :span="24">
<div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
基本信息
</div>
</el-col>
<el-col :span="12">
2025-06-19 13:21:27 +08:00
<el-form-item label="设备编号:" prop="deviceNo">
<el-input v-model="form.deviceNo"
2025-06-17 17:49:22 +08:00
placeholder="请输入设备编号"
maxlength="30"
/>
</el-form-item>
</el-col>
<el-col :span="12">
2025-06-19 13:21:27 +08:00
<el-form-item label="设备名称:" prop="deviceName">
<el-input v-model="form.deviceName"
2025-06-17 17:49:22 +08:00
placeholder="请输入设备名称"
maxlength="30"
/>
</el-form-item>
</el-col>
<el-col :span="12">
2025-06-19 13:21:27 +08:00
<el-form-item label="设备SN码:" prop="deviceSn">
<el-input v-model="form.deviceSn"
placeholder="请输入设备SN码"
2025-06-17 17:49:22 +08:00
maxlength="30"
/>
</el-form-item>
</el-col>
2025-06-27 17:20:53 +08:00
<el-col :span="12">
<el-form-item label="所属区域:" prop="areaId">
<el-cascader v-model="form.areaId"
:options="treeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
:props="{
emitPath: false,// 若设置 false则只返回该节点的值只返回最后选择的id
checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
value:'id',label:'label'
}" clearable @change="handleTreeChange">
</el-cascader>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属食堂:" prop="canteenId">
<el-select v-model="form.canteenId" style="width: 100%;" placeholder="请选择所属食堂">
2025-06-19 10:40:59 +08:00
<el-option
v-for="item in canteenOptions"
:key="item.canteenId"
:label="item.canteenName"
:value="item.canteenId"
></el-option>
</el-select>
2025-06-17 17:49:22 +08:00
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="设备位置:" prop="subPlace">
<el-select v-model="form.subPlace" style="width: 100%;" placeholder="请选择设备位置">
<el-option
v-for="item in subPlaceOptions"
:key="item.subPlaceId"
:label="item.subPlaceName"
:value="item.subPlaceId"
></el-option>
</el-select>
2025-06-17 17:49:22 +08:00
</el-form-item>
</el-col>
<el-col :span="24">
<div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
设备参数
</div>
</el-col>
</el-row>
2025-06-16 15:57:53 +08:00
</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 { getKitchenDeviceTypeApi, getKitchenDeviceListApi, addKitchenDeviceApi, editKitchenDeviceApi, delKitchenDeviceApi,getKitchenSubPlaceListAllApi } from "@/api/kitchen/devices";
2025-06-27 17:20:53 +08:00
import { systemAreaTreeApi,getCanteenByAreaApi } from "@/api/base/stall";
2025-06-16 15:57:53 +08:00
export default {
name: "",
dicts: [],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
//表格数据
tableListData: [],
2025-06-27 17:20:53 +08:00
deviceTypeList: [],
treeOptions:[], //区域
2025-06-19 10:40:59 +08:00
canteenOptions: [],
subPlaceOptions: [],
2025-06-16 15:57:53 +08:00
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
canteenName: undefined,
areaNameStr: undefined,
},
2025-06-19 13:21:27 +08:00
activeName:"1",
2025-06-16 15:57:53 +08:00
// 表单参数
form: {},
// 表单校验
rules: {
2025-06-27 17:20:53 +08:00
areaId: [
{ required: true, message: "所属区域不能为空", trigger: "change" }
],
canteenId: [
{ required: true, message: "所属食堂不能为空", trigger: "change" }
],
2025-06-16 15:57:53 +08:00
// canteenName: [
// { required: true, message: "字典名称不能为空", trigger: "blur" }
// ],
// dictType: [
// { required: true, message: "字典类型不能为空", trigger: "blur" }
// ]
}
};
},
created() {
this.getKitchenSubPlaceList();
2025-06-27 17:20:53 +08:00
this.getTreeData();
2025-06-19 13:21:27 +08:00
this.getKitchenDeviceType();
this.getList();
2025-06-16 15:57:53 +08:00
},
methods: {
2025-06-19 13:21:27 +08:00
// 设备类型选项
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]})
}
}
})
},
// 设备类型选项
getKitchenSubPlaceList(){
getKitchenSubPlaceListAllApi({canteenId:this.form.canteenId}).then((response) => {
this.subPlaceOptions = response.rows
})
},
2025-06-27 17:20:53 +08:00
//区域树
getTreeData() {
systemAreaTreeApi({}).then((response) => {
this.treeOptions = response.data;
});
},
handleTreeChange(e){
let param= {
"areaId":e,
"canteenType":1
}
getCanteenByAreaApi(param).then((response) => {
this.canteenOptions=response.rows||[]
this.$set(this.form,'canteenId',null)
});
},
2025-06-19 10:40:59 +08:00
// 食堂选项
getCanteenList(){
getCanteenByAreaApi({}).then((response) => {
this.canteenOptions = response.rows
})
},
2025-06-16 15:57:53 +08:00
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
2025-06-19 13:21:27 +08:00
handleTabClick(tab, event) {
console.log(tab.name,tab.label)
this.handleQuery()
},
2025-06-16 15:57:53 +08:00
/** 查询列表 */
getList() {
this.loading = true;
let param = {
2025-06-19 13:21:27 +08:00
"deviceType":this.activeName,
2025-06-19 17:53:35 +08:00
"keyWord":this.queryParams.keyWord,
2025-06-19 13:21:27 +08:00
"deviceNetworkState":this.queryParams.deviceNetworkState,
"pageNum": this.queryParams.pageNum,
"pageSize": this.queryParams.pageSize,
2025-06-16 15:57:53 +08:00
}
2025-06-19 13:21:27 +08:00
getKitchenDeviceListApi(param).then(response => {
this.tableListData = response.rows;
2025-06-16 15:57:53 +08:00
this.total = Number(response.total);
this.loading = false;
});
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增";
},
/** 修改按钮操作 */
handleUpdate(row) {
2025-06-19 13:21:27 +08:00
this.reset();
this.form = Object.assign({}, row)
this.open = true;
this.title = "修改";
2025-06-16 15:57:53 +08:00
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {};
this.resetForm("form");
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
2025-06-19 13:21:27 +08:00
if (valid) {
this.form.deviceType = this.activeName
if (this.form.deviceId != undefined) {
editKitchenDeviceApi(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
2025-06-16 15:57:53 +08:00
} else {
2025-06-19 13:21:27 +08:00
addKitchenDeviceApi(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
2025-06-16 15:57:53 +08:00
}
2025-06-19 13:21:27 +08:00
}
2025-06-16 15:57:53 +08:00
});
},
/** 删除按钮操作 */
2025-06-19 17:53:35 +08:00
handleDelete(row) {
2025-06-16 15:57:53 +08:00
this.$modal.confirm('是否确认删除数据项?').then(function() {
2025-06-19 17:53:35 +08:00
return delKitchenDeviceApi({deviceId:row.deviceId});
2025-06-16 15:57:53 +08:00
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
}
};
</script>