wxw
8 天以前 6a738089d6471d048c32ce7f3dcbd15c935ada79
Web/src/views/device/deviceInfo/index.vue
@@ -24,6 +24,14 @@
                     <el-switch v-model="state.boDrumReversal" active-text="" inactive-text="滚动反转"
                        @change="handleSwitchChange('boDrumReversal', $event)"></el-switch>
                  </el-card>
                  <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                     <el-switch v-model="state.boOutLock" active-text="" inactive-text="出库锁定"
                        @change="handleSwitchChange('boOutLock', $event)"></el-switch>
                  </el-card>
                  <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                     <el-switch v-model="state.boEnterLock" active-text="" inactive-text="入库锁定"
                        @change="handleSwitchChange('boEnterLock', $event)"></el-switch>
                  </el-card>
               </el-collapse-item>
               <el-collapse-item title="堆垛机" name="2">
@@ -52,7 +60,7 @@
               <el-button type="primary" :plain="floorStates.isPlain3"
                  @click="floorTogglePlain(3)">三层平面</el-button>
            </div>
            <div style="margin: 40px; height: 50%;">
            <div style="margin: 40px; height: 58%;">
               <div class="grid-container-line">
                  <div v-for="cell in cellsDataLine" :key="cell.Id">
                     <div v-if="cell.IsShow === 0" class="grid-item-line">
@@ -75,6 +83,165 @@
                  </div>
               </div>
            </div>
            <div style="margin: 10px 40px;height: 30%; width: 100%; ">
               <el-row>
                  <el-col :span="9">
                     <div>
                        <el-form label-position="right" label-width="40px" style="">
                           <el-form-item label="工位">
                              <el-input id="locaText" :disabled="lockInputStatus"
                                 v-model="stationValue.locatNo"
                                 style="width: 200px; margin-right: 10px;"></el-input>
                              <el-button @click="textLock(stationValue)">{{ lockText }}</el-button>
                              <el-button @click="write('zidong', stationValue)">自动</el-button>
                              <el-button @click="write('shoudong', stationValue)">手动</el-button>
                              <el-button @mousedown="writeDown('huifu', stationValue)"
                                 @mouseup="writeUp('huifu', stationValue)">报警恢复</el-button>
                           </el-form-item>
                           <el-form-item>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('1diandong', stationValue)"
                                 @mouseup="writeUp('1diandong', stationValue)">1点动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('2diandong', stationValue)"
                                 @mouseup="writeUp('2diandong', stationValue)">2点动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('3diandong', stationValue)"
                                 @mouseup="writeUp('3diandong', stationValue)">3点动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('4diandong', stationValue)"
                                 @mouseup="writeUp('4diandong', stationValue)">4点动</el-button>
                           </el-form-item>
                           <el-form-item>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('1liandong', stationValue)"
                                 @mouseup="writeUp('1liandong', stationValue)">1联动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('2liandong', stationValue)"
                                 @mouseup="writeUp('2liandong', stationValue)">2联动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('3liandong', stationValue)"
                                 @mouseup="writeUp('3liandong', stationValue)">3联动</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('4liandong', stationValue)"
                                 @mouseup="writeUp('4liandong', stationValue)">4联动</el-button>
                           </el-form-item>
                           <el-form-item>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('yizaisheng', stationValue)"
                                 @mouseup="writeUp('yizaisheng', stationValue)">移栽上升</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('fanzhuansheng', stationValue)"
                                 @mouseup="writeUp('fanzhuansheng', stationValue)">翻转机上升</el-button>
                           </el-form-item>
                           <el-form-item>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('yizaijiang', stationValue)"
                                 @mouseup="writeUp('yizaijiang', stationValue)">移栽下降</el-button>
                              <el-button size="large" :disabled="lockStatus"
                                 @mousedown="writeDown('fanzhuanjiang', stationValue)"
                                 @mouseup="writeUp('fanzhuanjiang', stationValue)">翻转机下降</el-button>
                           </el-form-item>
                        </el-form>
                     </div>
                  </el-col>
                  <el-col :span="15">
                     <div>
                        <el-form label-position="right" label-width="60px" style="" :inline="true">
                           <el-row :gutter="23">
                              <el-col :span="8">
                                 <el-form-item>
                                    <el-button @click="write('UpTask', stationValue)">更改任务</el-button>
                                    <el-button
                                       @click="writeTaskInfo('writeTask', stationValue)">任务写入</el-button>
                                    <el-button
                                       @click="writeTaskInfo('writeTaskDelete', stationValue)">任务清空</el-button>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="任务号">
                                    <el-input v-model="stationValue.taskNo"
                                       style="width: 200px; "></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="托盘号">
                                    <el-input v-model="stationValue.palletNo"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="起始工位">
                                    <el-input v-model="stationValue.startLoction"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="目标工位">
                                    <el-input v-model="stationValue.endLoction"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="起始排">
                                    <el-input v-model="stationValue.startPai"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="起始列">
                                    <el-input v-model="stationValue.startLie"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="起始层">
                                    <el-input v-model="stationValue.startCeng"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="目标排">
                                    <el-input v-model="stationValue.endPai"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="目标列">
                                    <el-input v-model="stationValue.endLie"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="目标层">
                                    <el-input v-model="stationValue.endCeng"
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="缠膜信号">
                                    <el-input v-model="stationValue.chanMo" disabled
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                              <el-col :span="6">
                                 <el-form-item label="拆膜信号">
                                    <el-input v-model="stationValue.chaiMo" disabled
                                       style="width: 200px; margin-right: 10px;"></el-input>
                                 </el-form-item>
                              </el-col>
                           </el-row>
                        </el-form>
                     </div>
                  </el-col>
               </el-row>
            </div>
         </el-col>
      </el-row>
   </div>
@@ -83,13 +250,46 @@
<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue';
import { listStatus, listPosition } from '/@/api/wcs/wcsPlc';
import { GetLocationInfo, WriteLocationInfo, WriteInfo, WriteTaskInfo } from '/@/api/wcs/wcsDevice';
import { signalR } from './signalR';
import { cellsDataLine, cellsDataOne, cellsDataTwo, cellsDataThree } from './data';
import { ElMessage } from "element-plus";
// export default{
// }
const state = ref<any>({});
const stackers = ref<any>({});
const conveyors = ref<any>({});
const lockText = ref("锁定");
const lockStatus = ref(true);
const lockInputStatus = ref(false);
const stationValue = ref<any>({
   locatNo: '',//工位
   layer: '',//楼层
   typeName: '',//操作类型名称
   funcName: '',//事件结果  true/false
   taskNo: '',
   palletNo: '',
   startLoction: '',
   endLoction: '',
   startPai: '',
   startLie: '',
   startCeng: '',
   endPai: '',
   endLie: '',
   endCeng: '',
   chanMo: '',
   chaiMo: '',
});
// 查询状态
const handleQuery = async () => {
   var res = await listStatus();
@@ -110,9 +310,9 @@
      }
      else if (s.type == 1) {
         // 更新输送线数据
         updateCellData(cellsDataOne, s);
         updateCellData(cellsDataTwo, s);
         updateCellData(cellsDataThree, s);
         updateCellData(cellsDataOne.value, s);
         updateCellData(cellsDataTwo.value, s);
         updateCellData(cellsDataThree.value, s);
      }
   });
};
@@ -150,12 +350,11 @@
   });
   signalR.off('PublicPosition');
   signalR.on('PublicPosition', (data: any) => {
      if (data.type == 1) {
         // 更新输送线数据
         updateCellData(cellsDataOne, data);
         updateCellData(cellsDataTwo, data);
         updateCellData(cellsDataThree, data);
         updateCellData(cellsDataOne.value, data);
         updateCellData(cellsDataTwo.value, data);
         updateCellData(cellsDataThree.value, data);
      }
      else if (data.type == 0) {
         // 更新堆垛机数据
@@ -167,6 +366,11 @@
         // }
      }
   });
   signalR.onreconnected(() => {
      console.log('重连成功plc***');
      handleQuery();
   });
});
const handleSwitchChange = (field: string, value: boolean) => {
   const param = { [field]: value };
@@ -175,7 +379,6 @@
//更新堆垛机
// updateStacker({ stationNum: '10', boxHeight: 200 })
function updateStacker(data: any) {
   debugger;
   const foundCell = cellsDataLine.value.find(cell => cell.Code === data.stationNum);
   if (foundCell) {
      foundCell.EndLocat = data.endLocat;
@@ -217,7 +420,7 @@
const activeName = ['1', '2', '3'];
//输送线数据
let cellsData = ref(cellsDataOne);
let cellsData = cellsDataOne.value;
// 层平面状态
@@ -229,8 +432,7 @@
//切换层平面
function floorTogglePlain(buttonNumber) {
   const floorData = [cellsDataOne, cellsDataTwo, cellsDataThree];
   const floorData = [cellsDataOne.value, cellsDataTwo.value, cellsDataThree.value];
   if (buttonNumber >= 1 && buttonNumber <= 3) {
      const index = buttonNumber - 1;
      floorStates.value = {
@@ -238,9 +440,139 @@
         isPlain2: index !== 1,
         isPlain3: index !== 2
      };
      cellsData.value = floorData[index];
      cellsData = floorData[index];
   }
}
const textLock = async (row: any) => {
   if (lockText.value == "锁定") {
      lockStatus.value = true;
      lockInputStatus.value = true;
      lockText.value = "解锁";
      if (floorStates.value.isPlain1 == false) {
         row.layer = 1;
      } else if (floorStates.value.isPlain2 == false) {
         row.layer = 2;
      }
      else if (floorStates.value.isPlain3 == false) {
         row.layer = 3;
      }
      row.typeName = "suoding";
      console.log(row);
      var res = await WriteLocationInfo(row);
      var res2 = await GetLocationInfo(row);
      let rowData = JSON.parse(JSON.stringify(res2.data.result));
      stationValue.value = res2.data.result;
      //       stationValue.value = {
      //    locatNo: '',//工位
      //    layer:'',//楼层
      //    typeName:'',//操作类型名称
      //    funcName:null,//事件结果  true/false
      //    taskNo:'',
      //    palletNo:'',
      //    startLoction:'',
      //    endLoction:'',
      //    startPai:'',
      //    startLie:'',
      //    startCeng:'',
      //    endPai:'',
      //    endLie:'',
      //    endCeng:'',
      // }
      console.log(res2.data.result);
      console.log(rowData);
   } else {
      lockStatus.value = true;
      lockInputStatus.value = false;
      lockText.value = "锁定";
   }
}
const write = async (type: string, row: any) => {
   if (lockStatus.value == false) {
      ElMessage.success("请先锁定");
      return;
   }
   if (floorStates.value.isPlain1 == false) {
      row.layer = 1;
   } else if (floorStates.value.isPlain2 == false) {
      row.layer = 2;
   }
   else if (floorStates.value.isPlain3 == false) {
      row.layer = 3;
   }
   row.typeName = type;
   console.log(row);
   var res = await WriteInfo(row);
   console.log(res.data.result);
   ElMessage.success(res.data.result);
}
const writeDown = async (type: string, row: any) => {
   if (lockStatus.value == false) {
      ElMessage.success("请先锁定");
      return;
   }
   if (floorStates.value.isPlain1 == false) {
      row.layer = 1;
   } else if (floorStates.value.isPlain2 == false) {
      row.layer = 2;
   }
   else if (floorStates.value.isPlain3 == false) {
      row.layer = 3;
   }
   row.typeName = type;
   row.funcName = "true";
   var res = await WriteInfo(row);
   console.log(type + "按下事件");
   // ElMessage.success(res.data.result);
}
const writeUp = async (type: string, row: any) => {
   if (lockStatus.value == false) {
      ElMessage.success("请先锁定");
      return;
   }
   if (floorStates.value.isPlain1 == false) {
      row.layer = 1;
   } else if (floorStates.value.isPlain2 == false) {
      row.layer = 2;
   }
   else if (floorStates.value.isPlain3 == false) {
      row.layer = 3;
   }
   row.typeName = type;
   row.funcName = "false";
   var res = await WriteInfo(row);
   console.log(type + "抬起事件");
   // ElMessage.success('asdf'+ res.data.result);
}
const writeTaskInfo = async (type: string, row: any) => {
   if (floorStates.value.isPlain1 == false) {
      row.layer = 1;
   } else if (floorStates.value.isPlain2 == false) {
      row.layer = 2;
   }
   else if (floorStates.value.isPlain3 == false) {
      row.layer = 3;
   }
   row.typeName = type;
   var res = await WriteTaskInfo(row);
   console.log(type + "抬起事件");
   // ElMessage.success('asdf'+ res.data.result);
}
</script>
<style scoped>