Admin
2022-08-16 f064f30c91750ae7ffb912e47bca5f9dbc143c8b
src/views/intellectInspect/intelligentLine/index.vue
@@ -10,11 +10,12 @@
                <div>全屏</div>
            </div>
            <div class="backBtn" @click="goBack()">
                <img src="../../../assets/loginPage/back-icon.png" />
                <img src="../../../assets/loginPage/back-icon.png"/>
                <div>退出</div>
            </div>
        </div>
        <div class="blocks">
            <div>
            <div class="star-pic">
                <div class="star-bg"><img src="../../../assets/loginPage/star-bg.png" /></div>
                <div class="star"><img src="../../../assets/loginPage/device-pic.png" /></div>
@@ -30,14 +31,14 @@
                            位置: <span>{{ item.region.toString() }}</span>
                        </p>
                    </div>
                    <div class="area-head" :class="item.points.some((e) => e.reportResult == null) ? 'fadeBorder' : ''">
                        <div class="indicator" :class="item.points.every((e) => e.reportResult == null) ? 'someUndone' : (item.points.some((e) => e.reportResult == 1) ? 'somewarning' : '')">
                    <div class="area-head">
                        <div class="indicator" :class="item.points.some((e) => e.reportResult == 1) ? 'somewarning' : (item.points.some((e) => e.reportResult == null) ? 'someUndone' : '')">
                            <div class="indi-dot"></div>
                            <!--              <div class="indi-pulse"></div>-->
                            <!--              <div class="indi-pulse1"></div>-->
                        </div>
                        <div class="arrow" v-if="item.points.some((e) => e.reportResult != null)"></div>
                        <div class="top-line" :class="item.points.some((e) => e.reportResult == null) ? 'fadeLine' : ''"></div>
                        <div class="top-line" :class="item.points.some((e) => e.reportResult !== null) ? '' : 'fadeLine'"></div>
                    </div>
                    <div class="more-info">
                        <div class="item" v-for="(t, i) in item.points" :key="i" :class="t.reportResult == null ? 'undone' : t.reportResult == 1 ? 'warning' : ''">
@@ -76,6 +77,7 @@
                </div>
            </div>
            <div class="tip" v-else>抱歉,暂时查询不到巡检路线...</div>
            </div>
        </div>
    </div>
</template>
@@ -113,7 +115,7 @@
        const state = reactive<stateType>({
            present: '',
            isScreenfull: false,
            path: 'http://192.168.0.29:8008/ws/test/',
            path: '',
            socketData: '',
            socket: null,
            data: [],
@@ -126,50 +128,62 @@
            }, 1000);
            let curId = route.query.id
            state.id = curId.toString()
            console.log(state.id)
            getLine(state.id)
            init(state.id);
            getUrl(state.id)
        });
        const dataList = computed(() => {
            return userInfos.value.dataList;
        });
        // socket获取数据
        const init = (id:string) => {
            if (typeof window.WebSocket === 'undefined') {
                alert('您的浏览器不支持socket');
            } else {
                // 实例化socket
                var url = state.path + id;
                url = url.replace('https', 'ws').replace('http', 'ws');
                console.log(url, '获取地址');
                state.socket = new window.WebSocket(url);
                // 监听socket连接
                state.socket.onopen = () => {
                    console.log('socket连接成功');
                };
                // 监听socket错误信息
                state.socket.onerror = () => {
                    console.log('socket连接错误');
                };
                // 监听socket消息
                state.socket.onmessage = (msg) => {
                    if (msg.data === '连接成功') return;
                    userInfos.value.dataList = JSON.parse(msg.data);
                };
            }
        };
        // 获取url
        const send = () => {
            state.socket.send(params);
        };
        const getUrl =async (id:string)=>{
            const res = await lineApi().getUrl();
            if (res.data.code === '200') {
                state.path = 'http://' + res.data.data.ip + ':' + res.data.data.port + '/ws/test/'
                if (typeof window.WebSocket === 'undefined') {
                    alert('您的浏览器不支持socket');
                } else {
                    // 实例化socket
                    // debugger
                    let uid =  userInfos.value.uid.toString()
                    var url = state.path + uid + '*' + id;
                    console.log(url,'url',uid,'uid')
                    url = url.replace('https', 'ws').replace('http', 'ws');
                    console.log(url, '获取地址');
                    state.socket = new window.WebSocket(url);
                    // 监听socket连接
                    state.socket.onopen = () => {
                        console.log('socket连接成功');
                    };
                    // 监听socket错误信息
                    state.socket.onerror = () => {
                        console.log('socket连接错误');
                    };
                    // 监听socket消息
                    state.socket.onmessage = (msg) => {
                        if (msg.data === '连接成功') return;
                        console.log(msg.data,'data')
                        userInfos.value.dataList = JSON.parse(msg.data);
                    };
                }
            } else {
                ElMessage({
                    type: 'warning',
                    message: res.data.msg
                });
            }
        }
        // const send = () => {
        //     state.socket.send(params);
        // };
        // 接口获取数据
        const getLine = async (id:string) => {
            let res = await lineApi().getLine({ id: id });
            if (res.data.code === '200') {
                console.log(res.data.data, '获取巡检点');
                userInfos.value.dataList = res.data.data;
            } else {
                ElMessage({
@@ -470,14 +484,19 @@
    .blocks {
        width: 100%;
        height: calc(100% - 90px);
        padding: 20px 40px 30px;
        padding: 10px 40px 35px;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        overflow: hidden;
        overflow-x: auto;
        overflow-y: auto;
        &>div{
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            overflow: hidden;
            overflow-x: auto;
            overflow-y: auto;
        }
        .line-map {
            display: flex;
@@ -647,11 +666,11 @@
                    }
                    .fadeLine {
                        width: 100%;
                        border-top: 1px solid #ccc;
                        border-top: 1px solid rgba(54,252,252,.6);
                    }
                }
                .fadeBorder {
                    border-left: 1px solid rgba(54, 252, 252, 0.4);
                    border-left: 1px solid #ccc;
                }
                .more-info {
                    width: 100%;
@@ -806,7 +825,6 @@
                        }
                    }
                    .undone {
                        border-left: 1px solid rgba(54, 252, 252, 0.4);
                        & > section {
                            border: 1px solid #ccc;