修正ts类型
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" label-width="100px" @submit.prevent="handleQuery" :model="queryParams" :inline="true">
|
||||
<el-form ref="queryFormRef" label-width="70px" @submit.prevent="handleQuery" :model="queryParams" :inline="true">
|
||||
<!-- <el-form-item label="设备状态" prop="eleStatus">
|
||||
<el-select v-model="queryParams.eleStatus">
|
||||
<el-option v-for="(item, index) in com_waterdevice_on_status" :key="index" :label="item.label" :value="item.value"></el-option>
|
||||
@@ -15,8 +15,11 @@
|
||||
<el-option v-for="(item, index) in com_water_readrecord_status" :key="index" :label="item.label" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="设备编号" prop="deviceCode">
|
||||
<el-input v-model="queryParams.deviceCode" placeholder="请输入" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="房屋" prop="houseName">
|
||||
<el-input v-model="queryParams.houseName" placeholder="请输入" clearable />
|
||||
<el-input clearable v-model="queryParams.houseName" placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">搜索</el-button>
|
||||
@@ -38,6 +41,9 @@
|
||||
<el-dropdown-item @click="handleMarkqrcode" v-if="checkPermi(['equipment:addqrcode:waterdevice'])">
|
||||
<span>批量生成条形码</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click="handleMarkQrcodeZip">
|
||||
<span>批量下载条形码</span>
|
||||
</el-dropdown-item>
|
||||
<!-- <el-dropdown-item v-hasPermi="['equipment:addqrcode:electricitydevice']">
|
||||
<div @click="handleMarkqrcode">批量更新固件</div>
|
||||
</el-dropdown-item> -->
|
||||
@@ -51,13 +57,14 @@
|
||||
<el-table-column label="设备编码" width="250" align="center" prop="deviceCode" />
|
||||
<el-table-column label="设备状态" width="100" align="center" prop="eleStatus">
|
||||
<template #default="scope">
|
||||
<dict-tag v-if="scope.row.waterRecord" :options="com_waterdevice_on_status" :value="scope.row.waterRecord.eleStatus"></dict-tag>
|
||||
<!-- 1 离线 0在线 -->
|
||||
<dict-tag v-if="scope.row.waterRecord" :options="com_waterdevice_on_status" :value="Number(scope.row.status)"></dict-tag>
|
||||
<span v-else>---</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分合状态" width="100" align="center">
|
||||
<template #default="scope">
|
||||
<dict-tag v-if="scope.row.status" :options="com_water_readrecord_status" :value="scope.row.waterRecord.status"></dict-tag>
|
||||
<dict-tag v-if="scope.row.status !== null" :options="com_water_readrecord_status" :value="scope.row.waterRecord.status"></dict-tag>
|
||||
<span v-else>---</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -102,29 +109,30 @@
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<el-table-column label="操作" min-width="120" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-row>
|
||||
<el-col :span="24" class="flex flex-items-center actions">
|
||||
<el-button link type="primary" @click="handleRecode(scope.row)" v-hasPermi="['equipment:view:waterdevice']">充值记录</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
:loading="loadingQRCode.includes(scope.row.id)"
|
||||
@click="handleQrCode(scope.row)"
|
||||
v-hasPermi="['equipment:addqrcode:waterdevice']"
|
||||
>生成条码</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleOpenDialog('usedWater', scope.row)" v-hasPermi="['equipment:useWater:waterdevice']"
|
||||
>用水量</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleOpenDialog('Upload', scope.row)" v-hasPermi="['equipment:updatehardware:waterdevice']"
|
||||
>更新固件</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleOpenDialog('UpdateHouse', scope.row)" v-hasPermi="['equipment:edithouse:waterdevice']"
|
||||
>绑定房屋</el-button
|
||||
>
|
||||
<!-- <el-dropdown style="vertical-align: text-top">
|
||||
<div class="actions">
|
||||
<el-button link type="primary" @click="handleRecode(scope.row)" v-hasPermi="['equipment:view:waterdevice']">充值记录</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
:loading="loadingQRCode.includes(scope.row.id)"
|
||||
@click="handleQrCode(scope.row)"
|
||||
v-hasPermi="['equipment:addqrcode:waterdevice']"
|
||||
>生成条码</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleOpenDialog('usedWater', scope.row)" v-hasPermi="['equipment:useWater:waterdevice']"
|
||||
>用水量</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleOpenDialog('Upload', scope.row)" v-hasPermi="['equipment:updatehardware:waterdevice']"
|
||||
>更新固件</el-button
|
||||
>
|
||||
<el-button link type="primary" @click="handleUpdate(scope.row.deviceCode)">最新抄表记录</el-button>
|
||||
|
||||
<el-button link type="primary" @click="handleOpenDialog('UpdateHouse', scope.row)" v-hasPermi="['equipment:edithouse:waterdevice']"
|
||||
>绑定房屋</el-button
|
||||
>
|
||||
<!-- <el-dropdown style="vertical-align: text-top">
|
||||
<el-button link type="primary">
|
||||
<div>
|
||||
更多<el-icon><arrow-down /></el-icon>
|
||||
@@ -144,13 +152,19 @@
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown> -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
<pagination
|
||||
:pageSizes="[10, 30, 50, 100]"
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
<!-- 添加或修改水 设备对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
@@ -163,6 +177,7 @@
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
v-model="UsedWaterform.startTime"
|
||||
type="datetime"
|
||||
@update:model-value="handleStarTime"
|
||||
placeholder="开始时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -172,6 +187,7 @@
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
v-model="UsedWaterform.endTime"
|
||||
type="datetime"
|
||||
@update:model-value="handleEndTime"
|
||||
placeholder="结束时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
@@ -251,6 +267,19 @@
|
||||
<div class="useditem">用水量</div>
|
||||
<div class="useditem value">{{ UsedWaterInfo.count }}</div>
|
||||
</div>
|
||||
|
||||
<el-form v-if="dialogType === 'deviceLastRecord'" ref="deviceLastRecordformRef" :model="EditHouseform" label-width="100px">
|
||||
<el-form-item label="设备编号" prop="deviceCode"> {{ deviceLastRecordform.deviceCode }} </el-form-item>
|
||||
<el-form-item label="读表时间" prop="readTime"> {{ deviceLastRecordform.readTime }} </el-form-item>
|
||||
<el-form-item label="阀门状态" prop="status">
|
||||
<DictTag :options="com_water_readrecord_status" :value="deviceLastRecordform.status"></DictTag>
|
||||
</el-form-item>
|
||||
<el-form-item label="余额" prop="balance"> {{ deviceLastRecordform.balance }} </el-form-item>
|
||||
<el-form-item label="用水量" prop="totalWater"> {{ deviceLastRecordform.totalWater }} </el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="unSubmit">关闭</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -262,18 +291,17 @@ import {
|
||||
getWaterDeviceTimeRangeUsedWater,
|
||||
WaterDeviceMakerQrcode,
|
||||
updateWaterDevice,
|
||||
WaterDeviceUpdateBin
|
||||
WaterDeviceUpdateBin,
|
||||
latestRecord
|
||||
} from '@/api/system/SdbWaterDevice/index';
|
||||
import { WaterDeviceVO, WaterDeviceQuery, WaterDeviceForm } from '@/api/system/SdbWaterDevice/type';
|
||||
import { WaterDeviceVO } from '@/api/system/SdbWaterDevice/type';
|
||||
import { useHouseStore } from '@/store/modules/house';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { getHousePathById } from '@/utils/house';
|
||||
import { Upload } from '@element-plus/icons-vue';
|
||||
import { CascaderValue, tourEmits, UploadProps, UploadRawFile } from 'element-plus';
|
||||
import { formatDate } from '@/utils/time';
|
||||
import { CascaderValue, UploadProps, UploadRawFile } from 'element-plus';
|
||||
import { checkPermi } from '@/utils/permission';
|
||||
import { exportImagesToZip } from '@/utils/exportZip';
|
||||
|
||||
const huhao = 3096371295;
|
||||
const uploadAUrl = import.meta.env.VITE_APP_BASE_API + '/waterDevice/uploadA';
|
||||
const uploadBUrl = import.meta.env.VITE_APP_BASE_API + '/waterDevice/uploadB';
|
||||
|
||||
@@ -285,7 +313,7 @@ const waterDeviceList = ref<WaterDeviceVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<{ id: string; deviceCode: string }[]>([]);
|
||||
const ids = ref<WaterDeviceVO[]>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
@@ -303,19 +331,21 @@ const data = reactive({
|
||||
pageSize: 10,
|
||||
eleStatus: '',
|
||||
houseName: '',
|
||||
status: ''
|
||||
status: '',
|
||||
deviceCode: ''
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams } = toRefs(data);
|
||||
|
||||
/** 查询水 设备列表 */
|
||||
const getList = async () => {
|
||||
const getList = async (callback?: (vals: WaterDeviceVO[]) => void) => {
|
||||
loading.value = true;
|
||||
const res = await listWaterDevice(queryParams.value);
|
||||
waterDeviceList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
callback && callback(waterDeviceList.value);
|
||||
};
|
||||
// ! 用水量 =============================================================================
|
||||
const usedWaterInfo = ref(true);
|
||||
@@ -325,6 +355,27 @@ const UsedWaterform = ref({
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
});
|
||||
function handleStarTime(val: string) {
|
||||
if (!val) return;
|
||||
const current = new Date(val).getTime();
|
||||
if (UsedWaterform.value.endTime && UsedWaterform.value.startTime) {
|
||||
if (current > new Date(UsedWaterform.value.endTime).getTime()) {
|
||||
UsedWaterform.value.endTime = '';
|
||||
ElMessage.warning('开始时间不能大于结束时间');
|
||||
}
|
||||
}
|
||||
}
|
||||
function handleEndTime(val: string) {
|
||||
if (!val) return;
|
||||
const current = new Date(val).getTime();
|
||||
if (UsedWaterform.value.startTime && UsedWaterform.value.endTime) {
|
||||
if (current < new Date(UsedWaterform.value.startTime).getTime()) {
|
||||
UsedWaterform.value.startTime = '';
|
||||
ElMessage.warning('结束时间不能小于开始时间');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const UsedWaterInfo = ref({
|
||||
count: '',
|
||||
startTime: '',
|
||||
@@ -334,6 +385,7 @@ const rules = {
|
||||
startTime: [{ required: true, message: '请选择开始时间', trigger: 'blur' }],
|
||||
endTime: [{ required: true, message: '请选择结束时间', trigger: 'blur' }]
|
||||
};
|
||||
|
||||
// ! =======================================================================================
|
||||
|
||||
// ? 上传固件 ==============================================================================================
|
||||
@@ -395,7 +447,19 @@ const EditHouseform = ref({
|
||||
houseId: ''
|
||||
});
|
||||
// * 编辑房屋 ==============================================================================================
|
||||
const deviceLastRecordformRef = ref(null);
|
||||
const deviceLastRecordform = ref({
|
||||
id: '',
|
||||
deviceCode: '',
|
||||
balance: '',
|
||||
eleStatus: '',
|
||||
readTime: '',
|
||||
status: '',
|
||||
totalWater: '',
|
||||
type: ''
|
||||
});
|
||||
|
||||
const imageRefs = ref([]);
|
||||
/** 批量生成 条形码 */
|
||||
function handleMarkqrcode() {
|
||||
if (ids.value.length > 0) {
|
||||
@@ -407,13 +471,33 @@ function handleMarkqrcode() {
|
||||
ElMessage.warning('请选择设备');
|
||||
}
|
||||
}
|
||||
|
||||
function handleMarkQrcodeZip() {
|
||||
if (ids.value.length > 0) {
|
||||
const selectedIds = new Set(ids.value.map((item) => item.id));
|
||||
const matchedList = waterDeviceList.value.filter((item) => {
|
||||
return selectedIds.has(item.id) && item.url;
|
||||
});
|
||||
produceQRzip(matchedList);
|
||||
} else {
|
||||
ElMessage.warning('请选择设备');
|
||||
}
|
||||
}
|
||||
|
||||
function produceQRzip(vals: WaterDeviceVO[]) {
|
||||
const arr = vals.map((item) => {
|
||||
return {
|
||||
name: item.deviceCode,
|
||||
url: item.url
|
||||
};
|
||||
});
|
||||
exportImagesToZip(arr);
|
||||
}
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: WaterDeviceVO[]) => {
|
||||
ids.value = selection.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
deviceCode: item.deviceCode
|
||||
};
|
||||
return item;
|
||||
});
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
@@ -430,11 +514,14 @@ const handleQrCode = (row: WaterDeviceVO) => {
|
||||
id: row.id,
|
||||
deviceCode: row.deviceCode
|
||||
}
|
||||
]).then(() => {
|
||||
ElMessage.success('生成成功');
|
||||
loadingQRCode.value = loadingQRCode.value.filter((item) => item !== row.id);
|
||||
getList();
|
||||
});
|
||||
])
|
||||
.then(() => {
|
||||
ElMessage.success('生成成功');
|
||||
getList();
|
||||
})
|
||||
.finally(() => {
|
||||
loadingQRCode.value = loadingQRCode.value.filter((item) => item !== row.id);
|
||||
});
|
||||
}, 1000);
|
||||
};
|
||||
// * house
|
||||
@@ -446,26 +533,31 @@ function handleChange(val: CascaderValue) {
|
||||
EditHouseform.value.houseId = val[2];
|
||||
}
|
||||
// * house
|
||||
const dialogType = ref<'usedWater' | 'Upload' | 'UpdateHouse'>('usedWater');
|
||||
const dialogType = ref<'usedWater' | 'Upload' | 'UpdateHouse' | 'deviceLastRecord'>('usedWater');
|
||||
/** 用水量 更新固件 编辑房屋*/
|
||||
const handleOpenDialog = (type: 'usedWater' | 'Upload' | 'UpdateHouse', row: WaterDeviceVO) => {
|
||||
const handleOpenDialog = (type: 'usedWater' | 'Upload' | 'UpdateHouse' | 'deviceLastRecord', row?: WaterDeviceVO) => {
|
||||
reset();
|
||||
if (type === 'usedWater') {
|
||||
UsedWaterform.value.deviceCode = row.deviceCode;
|
||||
UsedWaterform.value.startTime = '';
|
||||
UsedWaterform.value.endTime = '';
|
||||
usedWaterInfo.value = true;
|
||||
dialog.title = '用水量查询';
|
||||
} else if (type === 'Upload') {
|
||||
UploadFileform.value.deviceCodes = [row.deviceCode];
|
||||
dialog.title = '固件上传';
|
||||
} else if (type === 'UpdateHouse') {
|
||||
EditHouseform.value.id = row.id;
|
||||
EditHouseform.value.deviceCode = row.deviceCode;
|
||||
EditHouseform.value.houseId = '';
|
||||
dialog.title = '编辑户号';
|
||||
getTree();
|
||||
} else if (type === 'deviceLastRecord') {
|
||||
// 处理设备最后记录的逻辑
|
||||
dialog.title = '设备最新抄表记录';
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialogType.value = type;
|
||||
dialog.title = type === 'usedWater' ? '用水量查询' : type === 'UpdateHouse' ? '编辑户号' : '更新固件';
|
||||
};
|
||||
|
||||
function getTree() {
|
||||
@@ -479,6 +571,26 @@ function getTree() {
|
||||
/** 水表 启停*/
|
||||
const handleChangeWater = (val: string, row: WaterDeviceVO) => {};
|
||||
|
||||
function handleUpdate(id: string) {
|
||||
latestRecord(id).then((res) => {
|
||||
console.log('设备最新抄表记录', res);
|
||||
deviceLastRecordform.value = {
|
||||
id: '',
|
||||
deviceCode: '',
|
||||
balance: '',
|
||||
eleStatus: '',
|
||||
readTime: '',
|
||||
status: '',
|
||||
totalWater: '',
|
||||
type: ''
|
||||
};
|
||||
deviceLastRecordform.value = {
|
||||
...res.data
|
||||
};
|
||||
handleOpenDialog('deviceLastRecord');
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
if (dialogType.value === 'usedWater') {
|
||||
|
||||
Reference in New Issue
Block a user