PT PC端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

85 lines
2.5 KiB

<template>
<el-form ref="searchDeviceForm" :inline="true" :model="searchDevice">
<el-form-item label="选择站点">
<el-select v-model="searchDevice.deviceId" placeholder="请选择站点" @change="change">
<el-option label="全部" value></el-option>
<el-option
v-for="item in devices"
:key="item.deviceId"
:label="`${item.address}-${item.deviceId}`"
:value="item.deviceId"
></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="类型">-->
<!-- <el-select v-model="searchDevice.type" placeholder="选择查询类型">-->
<!-- <el-option label="全部" value=""></el-option>-->
<!-- <el-option label="事件上报" value="EVENT"></el-option>-->
<!-- <el-option label="业务上报" value="DATA"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="状态">-->
<!-- <el-select v-model="searchDevice.status" placeholder="选择查询类型">-->
<!-- <el-option label="全部" value=""></el-option>-->
<!-- <el-option label="PENDING" value="PENDING"></el-option>-->
<!-- <el-option label="SUCCESS" value="SUCCESS"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" @click="onSubmit">
<i class="el-icon-search mr-2"></i>
查询
</el-button>
</el-form-item>
</el-form>
</template>
<script setup>
import { computed, defineEmits, reactive, ref, watch } from 'vue';
import { useStore } from 'vuex';
const emit = defineEmits(['search']);
const searchDevice = reactive({
deviceId: '',
paging: true,
page: 1,
size: 50,
sort: [
{
col: 'createdAt',
order: 'DESC',
},
],
type: '',
status: '',
});
const searchDeviceForm = ref(null); // form
const store = useStore();
const devices = computed(() => store.state.device.devices);
const currentDeviceId = computed(() => store.state.device.currentDeviceId); // 正在操作的设备的id
// 监听currentDeviceId
watch(
() => currentDeviceId.value,
newValue => {
if (newValue) {
searchDevice.deviceId !== newValue && (searchDevice.deviceId = newValue);
}
},
{ immediate: true },
);
const change = e => {
store.commit('device/setCurrentDeviceId', e);
};
// 提交
const onSubmit = () => {
searchDeviceForm.value.validate(() => {
emit('search', { ...searchDevice });
});
};
</script>