nursing_unit_vue/src/views/iot/tq/electricity/index.vue

219 lines
6.3 KiB
Vue
Raw Normal View History

<template>
<div class="p-2">
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form ref="formRef" @keyup.enter.native="reload" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
<a-col :lg="6">
<a-form-item name="address">
<template #label><span title="同步类型">表号</span></template>
<a-input placeholder="请输入同步类型" v-model:value="queryParam.address" allow-clear ></a-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="reload">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
</a-col>
</a-row>
</a-form>
</div>
<a-row>
<a-col v-for="(item,index) in tableData.records" :key="index" :xs="24" :sm="24" :md="12" :lg="12" :xl="8" :xxl="6" style="padding: 8px;">
<a-card style="width: 100%;border-radius: 8px;">
<template #title >
<div class="cardTitle">
<a-row>
<a-col :span="12">
<span style="margin-left:15px;font-size:14px;">表号{{item.address}}</span>
</a-col>
<a-col :span="12" style="text-align: right;">
<span style="margin-right:15px;font-size:14px;">{{item.relayState=='1'?'在线':'离线'}}</span>
</a-col>
</a-row>
</div>
</template>
<p>
<span>护理单元名称{{item.nuName?item.nuName:'未配置'}}</span>
</p>
<p>
<span>上次抄表时间{{item.readTime?item.readTime:'未抄表'}}</span>
</p>
<p style="margin-top: 20px;">
<span><Statistic title="用电量(KWH)" :value="item.eleValue?item.eleValue:'无'" style="text-align:center;" /></span>
</p>
<a-divider />
<p style="text-align:center;">
<span>
<a @click="handleRead(item)">抄表</a>
<a-divider type="vertical" />
<a @click="handleControlLz(item)">拉闸</a>
<a-divider type="vertical" />
<a @click="handleControlHz(item)">合闸</a>
<a-divider type="vertical" />
<a @click="handleReset(item)">清零</a>
<a-divider type="vertical" />
<a @click="showApiLog(item)">日志</a>
</span>
</p>
</a-card>
</a-col>
</a-row>
<div
style="float:right;bottom: 20px;z-index: 999;padding: 8px 16px;border-radius: 4px;display: flex;align-items: center;">
<span style="margin-right: 10px;"> {{ tableData.total }} 条数据</span>
<Pagination showLessItems v-model:current="pageParams.pageNo" :pageSize="pageParams.pageSize" size="small"
show-quick-jumper :total="tableData.total" @change="reload" />
</div>
<!--引用表格-->
<ApiLogModal ref="apiLogModal"></ApiLogModal>
</div>
</template>
<script lang="ts" name="iot-nuIotRegionInfo" setup>
import {reactive, ref,h,onMounted} from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { Statistic } from 'ant-design-vue';
import {Modal} from "ant-design-vue";
import {list, eleReset, eleControl, eleRead } from './electricity.api';
import { Pagination } from 'ant-design-vue';
import ApiLogModal from "@/views/iot/tq/electricity/apilog/ApiLogModal.vue";
import { set } from 'lodash-es';
const formRef = ref();
const queryParam = reactive<any>({});
const apiLogModal = ref();
const tableData = ref<any>([]);
const pageParams = ref({ pageNo: 1, pageSize: 8 })
const labelCol = reactive({
xs:24,
sm:4,
xl:6,
xxl:4
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 重置
*/
function searchReset() {
formRef.value.resetFields();
//刷新数据
reload();
}
// 抄电表
async function handleRead(record) {
const params = {
'cid' : record.cid,
'address' : record.address,
};
await eleRead(params);
setTimeout(() => {
reload();
}, 4000);
}
// 电表拉闸
async function handleControlLz(record) {
if(record.relayState == '0'){
Modal.info({
title: '拉闸',
content: h('div', {}, [
h('p', '此电表已拉闸!'),
]),
onOk() {},
});
return;
}
const params = {
'cid' : record.cid,
'address' : record.address,
'type' : '10',
};
await eleControl(params);
setTimeout(() => {
reload();
}, 4000);
}
// 电表合闸
async function handleControlHz(record) {
if(record.relayState == '1'){
Modal.info({
title: '合闸',
content: h('div', {}, [
h('p', '此电表已合闸!'),
]),
onOk() {},
});
return;
}
const params = {
'cid' : record.cid,
'address' : record.address,
'type' : '11',
};
await eleControl(params);
setTimeout(() => {
reload();
}, 4000);
}
// 电表清零
async function handleReset(record) {
const params = {
'cid' : record.cid,
'address' : record.address,
};
await eleReset(params);
setTimeout(() => {
reload();
}, 4000);
}
/**
* 查看api日志
*/
function showApiLog(record){
console.log(record);
apiLogModal.value.disableSubmit = true;
apiLogModal.value.showApiLog(record);
}
function reload(){
queryParam.pageSize = pageParams.value.pageSize;
queryParam.pageNo = pageParams.value.pageNo;
defHttp.get({url: '/iot/tq/electricityMeter/list',params:queryParam}).then(res => {
console.log("🚀 ~ defHttp.get ~ res:", res)
tableData.value = res;
});
}
// 自动请求并暴露内部方法
onMounted(() => {
reload();
});
</script>
<style lang="less" scoped>
.cardTitle{
background: #1ea0fa;
width: 100%;
margin: -28px -24px;
padding-top: 15px;
border-radius: 5px 5px 0px 0px;
color: white;
height: 55px;
display: block;
position: absolute;
}
</style>