Web/src/views/device/deviceInfo/index.vue
@@ -1,68 +1,45 @@
<template>
   <div class="sys-user-container">
     <splitpanes>
      <pane size="10">
      <el-row>
         <el-col :span="3">
        <el-collapse v-model="activeName">
         <el-collapse-item title="设备控制" name="1">
           <el-card
            class="box-card"
            shadow="hover">
            <el-switch v-model="value1" active-text="" inactive-text="程序服务"></el-switch>
                  <el-card class="box-card" shadow="hover">
                     <el-switch v-model="state.boRunningState" active-text="" inactive-text="程序服务"></el-switch>
           </el-card>
           <el-card
            class="box-card"
            shadow="hover"
            style="margin-top: 3px;">
            <el-switch v-model="value2" active-text="" inactive-text="脱机模式"></el-switch>
                  <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                     <el-switch v-model="state.boOffline" active-text="" inactive-text="脱机模式"></el-switch>
           </el-card>
           <el-card
            class="box-card"
            shadow="hover"
            style="margin-top: 3px;">
            <el-switch v-model="value3" active-text="" inactive-text="自刷新"></el-switch>
                  <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                     <el-switch v-model="state.boRefresh" active-text="" inactive-text="自刷新"></el-switch>
           </el-card>
         </el-collapse-item>
  
         <el-collapse-item title="堆垛机" name="2">
           <div style="overflow-x: auto;white-space: nowrap;height: 380px;">
            <el-card
              v-for="(stacker, index) in stackers"
              :key="index"
              class="box-card"
              shadow="hover"
              style="margin-top: 3px;">
              <el-switch v-model="stacker.value" :inactive-text="`${index + 1}号堆垛机`"></el-switch>
                  <div style="overflow-x: auto;white-space: nowrap;">
                     <el-card v-for="(stacker, index) in stackers" :key="index" class="box-card" shadow="hover">
                        <el-switch v-model="stacker.isConn" :inactive-text="`${stacker.text}`"></el-switch>
            </el-card>
           </div>
         </el-collapse-item>
  
         <el-collapse-item title="输送线" name="3">
           <el-card
            v-for="(conveyor, index) in conveyors"
            :key="index"
            class="box-card"
            shadow="hover"
            style="margin-top: 3px;">
            <el-switch v-model="conveyor.value" :inactive-text="`${index + 1}楼输送线`"></el-switch>
                  <el-card v-for="(conveyor, index) in conveyors" :key="index" class="box-card" shadow="hover">
                     <el-switch v-model="conveyor.isConn" :inactive-text="`${conveyor.text}`"></el-switch>
           </el-card>
         </el-collapse-item>
        </el-collapse>
      </pane>
      <pane size="90" style="position: relative;background-color: #fff;">
         <el-card shadow="hover" :body-style="{ paddingBottom: '0', padding: '10px' }">
         </el-col>
         <el-col :span="21">
            <div class="card-page">
               <el-button type="primary" :plain="isPlain1" @click="floorTogglePlain(1)">一层平面</el-button>
               <el-button type="primary" :plain="isPlain2" @click="floorTogglePlain(2)">二层平面</el-button>
               <el-button type="primary" :plain="isPlain3" @click="floorTogglePlain(3)">三层平面</el-button>
            </div>
         </el-card>
         <el-card shadow="hover" :body-style="{ paddingBottom: '0', padding: '10px' }" class="card-line">
            <div style="margin: 40px; height: 50%;">
            <div class="grid-container-line">
               <div
                  v-for="cell in cellsDataLine"
                  :key="cell.Id">
                  <div v-if="cell.IsShow === 0"
                     class="grid-item-line">
                  <div v-for="cell in cellsDataLine" :key="cell.Id">
                     <div v-if="cell.IsShow === 0" class="grid-item-line">
                     <div class="grid-item-line-end">
                        {{cell.EndLocat}}
                     </div>
@@ -73,61 +50,46 @@
                  </div>
               </div>
            </div>
         </el-card>
         <el-card shadow="hover" :body-style="{ paddingBottom: '0', padding: '10px' }" class="card">
            <div class="grid-container">
               <div
                  v-for="cell in cellsData"
                  :key="cell.Id">
                  <div
                     v-if="cell.IsShow === 0"
                     :class="['grid-item', { 'active': cell.IsUse === 1 }, { 'active2': cell.IsUse === 2 }]"
                     >
                            <!-- 临时用的code需增加点位字段替换 -->
                  <div v-for="cell in cellsData" :key="cell.Id">
                     <div v-if="cell.IsShow === 0"
                        :class="['grid-item', { 'active': cell.IsUse === 1 }, { 'active2': cell.IsUse === 2 }]">
                     <div>{{ cell.Code }}</div>
                  </div>
               </div>
            </div>
         </el-card>
      </pane>
     </splitpanes>
            </div>
         </el-col>
      </el-row>
   </div>
  </template>
  
  <script lang="ts" setup>
  import { ref, reactive } from 'vue';
  import { Splitpanes, Pane } from 'splitpanes';
  import 'splitpanes/dist/splitpanes.css';
  import { Vue2 } from 'vue-demi';
import { listStatus } from '/@/api/wcs/wcsPlc';
const state = ref<any>({});
const stackers = ref<any>({});
const conveyors = ref<any>({});
// 查询状态
const handleQuery = async () => {
   var res = await listStatus();
   state.value = res.data.result.modService;
   stackers.value = res.data.result.listPlc.filter(s => s.type == 0);
   conveyors.value = res.data.result.listPlc.filter(s => s.type == 1 || s.type == 4);
};
handleQuery();
  const activeName = ['1', '2', '3'];
  const value1 = ref(false);
  const value2 = ref(false);
  const value3 = ref(false);
  const stackers = reactive([
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
   { value: false },
  ]);
  const conveyors = reactive([
   { value: false },
   { value: false },
   { value: false },
  ]);
  //堆垛机数据
  const cellsDataLine=[
     { Id: 1, Code: '001', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 2, Code: '002', LineCode:'01',EndLocat:'01010101',IsShow: 0, IsUse: 0,BoxHeight:190 },
   { Id: 2, Code: '002', LineCode: '01', EndLocat: '01010101', IsShow: 0, IsUse: 0, BoxHeight: 10 },
   { Id: 3, Code: '003', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 4, Code: '004', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 5, Code: '005', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
@@ -148,7 +110,7 @@
   { Id: 20, Code: '020', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 21, Code: '021', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 22, Code: '022', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 23, Code: '023', LineCode:'05',EndLocat:'',IsShow: 0, IsUse: 0,BoxHeight:300 },
   { Id: 23, Code: '023', LineCode: '05', EndLocat: '', IsShow: 0, IsUse: 0, BoxHeight: 200 },
   { Id: 24, Code: '024', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10},
   { Id: 25, Code: '025', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
   { Id: 26, Code: '026', LineCode:'',EndLocat:'',IsShow: 1, IsUse: 0,BoxHeight:10 },
@@ -1960,7 +1922,9 @@
      padding: 0;
      display: flex;
      align-items: center;
   margin-top: 3px;
   }
   .card-page{
      width: 100%;
      height: 30px;
@@ -1970,27 +1934,35 @@
      align-items: center;
       text-align: center;
   }
   .card-page>button{
      width: 150px;
      height: 30px;
   }
   .card-line{
      border: none;
      background-color: transparent;
      position:absolute;
      z-index: 99;
   }
   .grid-container-line{
      display: grid;
      grid-template-columns: repeat(51, 30px); /* 每列宽度 */
      grid-template-rows: repeat(1, 310px);  /* 每行高度 */
      gap: 0px; /* Gap between cells */
   grid-template-columns: repeat(51, 1fr); /* 自适应列宽 */
   grid-template-rows: 1fr; /* 自适应行高 */
   gap: 0;
      margin-top: 25px;
   width: 100%; /* 宽度自适应 */
   height: 1fr; /* 高度自适应 */
   }
   .grid-item-line{
      text-align: center;
      line-height: 50px; /* Vertical center the content */
      font-size: 12px; /* Adjust font size */
   line-height: 50px;
   /* Vertical center the content */
   font-size: 12px;
   /* Adjust font size */
      width: 30px;
      height: 100%;
      color: #fff;
@@ -1999,6 +1971,7 @@
      display: flex;
      justify-content: center;
   }
   .grid-item-line-end{
      width:80px;
      height: 25px;
@@ -2013,6 +1986,7 @@
       text-align: center;
       color: #fff;
   }
   .grid-item-line-box{
      width: 20px;
      height: 20px;
@@ -2021,14 +1995,16 @@
      display: flex;
      text-align: center;
      justify-content: center;
      align-items: center; /* Added to vertically center the text */
   align-items: center;
   /* Added to vertically center the text */
       text-align: center;
       color: black;
   }
   .grid-item-line-child{
      height: 100%;
   height: 220px;
      width: 3px;
      background-color: #9c9c9c;
   background-color: #000000;
   }
   .card{
@@ -2038,32 +2014,37 @@
      z-index: 90;
      margin-top: 310px;
   }
     .grid-container {
   margin-top: 10px;
      width: 100%;
      display: grid;
      grid-template-columns: repeat(51, 30px); /* 每列宽度 */
      grid-template-rows: repeat(12, 35px);  /* 每行高度 */
      gap: 0px; /* Gap between cells */
   grid-template-columns: repeat(51, 1fr);
   /* 每列宽度 */
   grid-template-rows: repeat(12, 1fr);
   /* 每行高度 */
   gap: 0px;
   /* Gap between cells */
   }
   .grid-item {
      background-color: #9c9c9c;
      border: 1px solid #797777;
      text-align: center;
      line-height: 35px;
      font-size: 12px;
      width: 30px;
      height: 35px;
   line-height: 1.4vw; /* 行高 */
   width: 100%; /* 自适应宽度 */
   height: 100%; /* 自适应高度 */
      color: #fff;
      font-size: 14px;
   font-size: 0.7vw;
   }
   .active {
      background-color: rgb(57, 141, 251); /* IsUse 为1时背景颜色为蓝色 */
   background-color: rgb(57, 141, 251);
   /* IsUse 为1时背景颜色为蓝色 */
      color: #f5f5f5;
   }
   .active2>div {
      display: none;
   }
  </style>