riku
2024-09-27 1abb6a9ca01cc76f271542a063d1b19839448019
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
  <el-row>
    <el-col :span="8">
      <el-text>新设备</el-text>
      <el-form :inline="true">
        <FYOptionTime :initValue="true" type="date" v-model:value="updateTime"></FYOptionTime>
        <el-form-item>
          <el-button type="primary" :loading="loading" @click="fetchNewDevice"
            >查询新设备</el-button
          >
        </el-form-item>
      </el-form>
      <el-scrollbar height="76vh">
        <el-space direction="vertical" alignment="normal">
          <ItemDevice v-for="item in deviceList" :key="item.id" :item="item" @add="addDevice" />
        </el-space>
      </el-scrollbar>
    </el-col>
    <el-col :span="8">
      <DeviceMatch :device="selectedDevice" :scene="selectedScene" @success="onUploadSuccess"></DeviceMatch>
    </el-col>
    <el-col :span="8">
      <el-text>监管工地</el-text>
      <el-form :inline="false">
        <FYOptionText
          label="场景名称"
          placeholder="输入名称关键字"
          width="400px"
          v-model:value="searchText"
        ></FYOptionText>
        <el-form-item>
          <el-button type="primary" :loading="loading2" @click="fetchScene">查询监管场景</el-button>
        </el-form-item>
      </el-form>
      <el-scrollbar height="70vh">
        <!-- <el-space direction="vertical" alignment="normal"> -->
        <ItemScene v-for="item in sceneList" :key="item.sguid" :item="item" @add="addScene" />
        <!-- </el-space> -->
      </el-scrollbar>
    </el-col>
  </el-row>
</template>
<script setup>
import { ref, computed } from 'vue';
import dayjs from 'dayjs';
import constructionApi from '@/api/additional-jingan/constructionApi';
import sceneApi from '@/api/fysp/sceneApi';
import { useFetchData } from '@/composables/fetchData';
 
import ItemDevice from './components/ItemDevice.vue';
import DeviceMatch from './components/DeviceMatch.vue';
 
const { loading, fetchData } = useFetchData();
 
const updateTime = ref();
const deviceList = ref([]);
const selectedDevice = ref(null);
 
const searchText = ref();
const sceneList = ref([]);
const selectedScene = ref(null);
 
// 查询需确认的设备清单
function fetchNewDevice() {
  const param = dayjs(updateTime.value).format('YYYY-MM-DD HH:mm:ss');
  fetchData(() => {
    return constructionApi.queryDevice(param).then((res) => {
      deviceList.value = res.data;
    });
  });
}
 
function addDevice(item) {
  selectedDevice.value = item;
  searchText.value = item.name;
  fetchScene();
}
 
const { loading: loading2, fetchData: fetchData2 } = useFetchData();
// 查询监管场景
function fetchScene() {
  const area = {};
  area.sceneName = searchText.value;
  fetchData2((page, pageSize) => {
    return sceneApi.searchScene(area, page, pageSize).then((res) => {
      sceneList.value = res.data;
    });
  });
}
 
function addScene(item) {
  selectedScene.value = item;
}
 
/**
 * 上传设备完成
 */
function onUploadSuccess() {
  const i = deviceList.value.indexOf(selectedDevice.value)
  deviceList.value.splice(i, 1)
  selectedDevice.value = null
  selectedScene.value = null
  
}
</script>
<style scoped>
.device-scene-wrap {
  border: 1px solid black;
}
</style>