zhoushihao
2024-12-10 24bc065e9009bfb3c778e762921268a389aeaf49
UI-Project/src/views/hollow/hollowequipment.vue
@@ -5,14 +5,15 @@
        <el-button id="searchButton" type="success" @click="handlezhiban">
          {{ $t('hellow.createtask') }}
        </el-button>
        <el-button style="margin-left: 20px;" id="searchButton" type="success" @click="handleBinda">
          {{ $t('hellow.starttask') }}
        </el-button>
        <el-button style="margin-left: 20px;" id="searchButton" type="success" @click="handleBindb">{{
            $t('hellow.stoptask')
          }}
        </el-button>
      </div>
<!--        <el-button style="margin-left: 20px;" id="searchButton" type="success" @click="handleBinda">-->
<!--          {{ $t('hellow.starttask') }}-->
<!--        </el-button>-->
<!--        <el-button style="margin-left: 20px;" id="searchButton" type="success" @click="handleBindb">{{-->
<!--            $t('hellow.stoptask')-->
<!--          }}-->
<!--        </el-button>-->
    <el-switch style="margin-top: 7px;margin-left: 10px;" v-model="ganghua" class="mb-2" :inactive-text="$t('hellow.schedulingswitch')" @change="handleChange" />
  </div>
      <div style="margin-bottom: -5px;margin-left: 5px;">
        <el-form>
          <el-row>
@@ -41,43 +42,59 @@
        </el-form>
      </div>
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
    <el-table height="480" ref="table" :data="tableDataa"
    <el-table height="650" ref="table" :data="tableDataa"
              :header-cell-style="{ background: '#F2F3F5', color: '#1D2129' }">
      <el-table-column prop="sequence" :label="$t('hellow.order')" align="center"/>
      <el-table-column prop="thickness" :label="$t('hellow.thickness')" align="center"/>
      <el-table-column prop="layer" :label="$t('hellow.coatingtypes')" align="center"/>
      <el-table-column prop="layer" :label="$t('hellow.layer')" align="center"/>
      <el-table-column prop="filmsId" :label="$t('hellow.coatingtypes')" align="center"/>
      <el-table-column prop="height" :label="$t('hellow.height')" align="center"/>
      <el-table-column prop="width" :label="$t('hellow.width')" align="center"/>
      <el-table-column prop="state" :label="$t('hellow.state')" align="center"/>
      <el-table-column prop="state" :label="$t('hellow.state')" align="center">
        <template #default="scope">
          {{ scope.row.state == -1 ? "等待出片" : "出片完成" }}
        </template>
      </el-table-column>
    </el-table>
    <div style="float: right;">
        <el-pagination
      <div style="display: flex;margin-left: 40%;margin-top: 10px;">
        <!-- <div style="float: center;"> -->
      <div style="margin-top: 5px;margin-right: 5px;">线路</div>
  <el-pagination
           background
           size="large"
          layout="prev, pager, next"
          :total="30"
          :current-page.sync="currentPage"
          @current-change="handlePageChange"
        />
      </div>
    <!-- <div style="float: right;">
      <el-pagination layout="prev, pager, next" :total="3" :current-page.sync="currentPage" @current-change="handlePageChange"/>
    </div> -->
  </div>
    </el-card>
  </div>
  <!-- 创建任务 -->
  <el-dialog v-model="dialogFormVisiblea" top="5vh" width="85%">
    <el-table ref="table" style="margin-top: 20px;height: 500px;"
              :data="tableDatab" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
      <el-table-column prop="flowCardId" fixed align="center" :label="$t('hellow.cardnumber')" min-width="80"/>
      <el-table-column prop="layer" fixed align="center" :label="$t('hellow.layernumber')" min-width="80"/>
  <el-table
    ref="table"
    style="margin-top: 20px; height: 700px;"
    :data="tableDatab"
    :header-cell-style="{ background: '#F2F3F5', color: '#1D2129' }"
    row-key="projectNumber"
  >
    <!-- <el-table-column type="expand"> -->
      <el-table-column >
      <template #default="props">
        <el-table :data="props.row.records" style="width: 100%">
          <el-table-column prop="layer" fixed align="center" :label="$t('hellow.layernumber')" min-width="80"/>
      <el-table-column prop="thickness" align="center" :label="$t('hellow.thickness')" min-width="80"/>
      <el-table-column prop="filmsId" align="center" :label="$t('hellow.coatingtypes')" min-width="80"/>
      <el-table-column prop="sumCount" align="center" :label="$t('hellow.totalnumber')" min-width="80"/>
      <el-table-column prop="realCount" align="center" :label="$t('hellow.realpieces')" min-width="80"/>
      <el-table-column prop="patternHeight" align="center" :label="$t('hellow.pairsnumber')" min-width="80"/>
      <!-- <el-table-column prop="damageCount" align="center" :label="$t('hellow.brokenpieces')" min-width="80"/> -->
      <!-- <el-table-column prop="lackCount" align="center" :label="$t('hellow.missingnumber')" min-width="80"/> -->
      <el-table-column fixed="right" :label="$t('hellow.operate')" align="center" width="270">
      <el-table-column prop="pairCount" align="center" :label="$t('hellow.pairsnumber')" min-width="80"/>
        </el-table>
      </template>
    </el-table-column>
    <el-table-column prop="projectNumber" fixed align="center" :label="$t('hellow.cardnumber')" min-width="20"/>
    <el-table-column fixed="right" :label="$t('hellow.operate')" align="center" width="270">
        <template #default="scope">
          <el-button size="mini" type="text" plain @click="handletake(scope.row)">{{ $t('hellow.claimquest') }}</el-button>
          <el-button size="mini" type="text" plain @click="handleBindRack(scope.row)">{{
@@ -90,8 +107,8 @@
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
  </el-table>
</el-dialog>
  <!-- 领取任务 -->
  <el-dialog v-model="dialogFormVisiblec" top="21vh" width="40%" :title="$t('hellow.claimquest')">
    <div style="margin-left: 20px;margin-top: 10px;margin-bottom: 10px;">
@@ -132,13 +149,13 @@
      <el-form size="mini" label-width="100px">
        <el-form label-width="210px" label-position="right">
          <el-form-item :label="$t('hellow.pairQuantity')" :required="true" style="width: 25vw">
            <el-input :placeholder="$t('hellow.cpairQuantity')" v-model="totalPairQuantity" autocomplete="off" />
            <el-input :placeholder="$t('hellow.cpairQuantity')" v-model="totalPairQuantitya" autocomplete="off" />
          </el-form-item>
          <el-form-item :label="$t('hellow.route')" :required="true" style="width: 25vw;">
            <el-select 
            :placeholder="$t('hellow.croute')"
             style="width: 270px"  
             v-model="cell">
             v-model="cella">
               <el-option
                v-for="item in options"
                :key="item.value"
@@ -159,10 +176,11 @@
      </div>
    </template>
  </el-dialog>
  <!-- 缺片详情 -->
  <el-dialog v-model="dialogFormVisibleb" top="7vh" width="70%" height="500">
    <div style="margin-top: -20px;text-align: center;margin-left: 400px;">
      <el-form-item :label="$t('hellow.cardnumbera')" style="width: 14vw">
        {{ currentRow.flowCardId }}
        {{ currentRow.projectNumber }}
      </el-form-item>
    </div>
    <el-table ref="table" style="margin-top: 20px;height: 400px;"
@@ -171,9 +189,9 @@
      <el-table-column prop="filmsId" align="center" :label="$t('hellow.coatingtypes')" min-width="80"/>
      <el-table-column prop="height" align="center" :label="$t('hellow.height')" min-width="80"/>
      <el-table-column prop="width" align="center" :label="$t('hellow.width')" min-width="80"/>
      <el-table-column prop="totalCount" align="center" :label="$t('hellow.totalnumber')" min-width="80"/>
      <!-- <el-table-column prop="totalCount" align="center" :label="$t('hellow.totalnumber')" min-width="80"/> -->
      <el-table-column prop="lackCount" align="center" :label="$t('hellow.missingnumber')" min-width="80"/>
      <el-table-column prop="damageCount" align="center" :label="$t('hellow.brokenpieces')" min-width="80"/>
      <!-- <el-table-column prop="damageCount" align="center" :label="$t('hellow.brokenpieces')" min-width="80"/> -->
      <div style="float: right;margin-bottom: 5px;">
        <el-pagination layout="prev, pager, next" :total="50"/>
      </div>
@@ -218,7 +236,10 @@
const allData = ref({})
const flowCard = ref('')
const cell = ref('')
const cella = ref('')
const ganghua = ref('')
const totalPairQuantity = ref('')
const totalPairQuantitya = ref('')
const dialogFormVisiblea = ref(false)
const dialogFormVisibleb = ref(false)
const dialogFormVisiblec = ref(false)
@@ -227,15 +248,15 @@
const options = [
  {
    value: 930,
    label: 930,
    label: '线路一',
  },
  {
    value: 931,
    label: 931,
    label: '线路二',
  },
  {
    value: 932,
    label: 932,
    label: '线路三',
  }
]
let socket = null;
@@ -283,45 +304,69 @@
  dialogFormVisiblea.value = true;
  fetchFlowCardId();
};
// 缺片详情
const handleBindRack = (row) => {
  const { flowCardId, layer } = row;
  currentRow.flowCardId  = row.flowCardId;
  const { projectNumber, layer } = row;
  currentRow.projectNumber  = row.projectNumber;
  dialogFormVisibleb.value = true;
  fetchFlowBind(flowCardId, layer);
  fetchFlowBind(projectNumber, layer);
};
// 领取任务
const handletake = (row) => {
  window.localStorage.setItem('flowCardId', row.flowCardId)
  window.localStorage.setItem('flowCardId', row.projectNumber)
  dialogFormVisiblec.value = true;
};
// 强制出片
const handleout = (row) => {
  window.localStorage.setItem('flowCardId', row.flowCardId)
  window.localStorage.setItem('flowCardId', row.projectNumber)
  dialogFormVisibled.value = true;
};
// 创建任务
const fetchFlowCardId = async () => {
  try {
    const response = await request.post('/hollowGlass/hollowGlassRelationInfo/queryHollowAllFlowCard')
    const response = await request.post('/hollowGlass/hollowGlassRelationInfo/queryHollowAllFlowCard');
    if (response.code == 200) {
      ElMessage.success(response.message);
      console.log(response.data.NG24111426A001);
      const newData = parseData(response.data);
      console.log(newData);
      
      tableDatab.value = response.data.NG24111426A001;
} else {
      ElMessage.error(response.message);
      tableDatab.value = newData;
    } else {
      ElMessage.error('Failed to fetch data');
    }
  } catch (error) {
    console.error(error);
    ElMessage.error('Error fetching data');
  }
}
};
const parseData = (rawData) => {
  return Object.keys(rawData).map(projectNumber => ({
    projectNumber,
    records: rawData[projectNumber]
  }));
};
// const fetchFlowCardId = async () => {
//   try {
//     const response = await request.post('/hollowGlass/hollowGlassRelationInfo/queryHollowAllFlowCard')
//     if (response.code == 200) {
//       ElMessage.success(response.message);
//       console.log(response.data);
//       tableDatab.value = response.data;
// } else {
//       ElMessage.error(response.message);
//     }
//   } catch (error) {
//     console.error(error);
//   }
// }
// 缺片详情
const fetchFlowBind = async (flowCardId, layer) => {
  try {
    var url="/hollowGlass/hollowGlassRelationInfo/queryLackByFlowCard?flowCardId="+flowCardId + "&layer=" + layer;
    const response = await request.post(url)
    if (response.code == 200) {
      tableDatac.value = response.data[1];
      // tableDatac.value = response.data[1];
      tableDatac.value = response.data;
      ElMessage.success(response.message);
    } else {
      ElMessage.error(response.message);
@@ -378,13 +423,13 @@
const finishb = async () => {
  let flowCardId = window.localStorage.getItem('flowCardId')
  try {
      var url="/hollowGlass/hollowGlassOutRelationInfo/forceOutGlass?cell="+cell.value + "&flowCardId=" + flowCardId + "&totalPairQuantity=" + totalPairQuantity.value;
      var url="/hollowGlass/hollowGlassOutRelationInfo/forceOutGlass?cell="+cella.value + "&flowCardId=" + flowCardId + "&totalPairQuantity=" + totalPairQuantitya.value;
      const response = await request.post(url)
    if (response.code == 200) {
      ElMessage.success(response.message);
      dialogFormVisibled.value = false;
      cell.value = '';
      totalPairQuantity.value = '';
      cella.value = '';
      totalPairQuantitya.value = '';
    } else {
          ElMessage.error(response.message);
        }
@@ -392,6 +437,28 @@
        console.error(error);
      }
    }
    // 调度
    const handleChange = async () => {
  try  {
    const body = {
      flag: ganghua.value, // 使用 ganghua.value 获取当前开关的状态
    };
    var url="/hollowGlass/hollowGlassOutRelationInfo/dispatchHollowSwitch?flag="+ganghua.value;
  const response = await request.post(url)
    if (response.code == 200) {
      // 绑定成功,处理逻辑
      ElMessage.success(response.message);
      ganghua.value = response.data
    }else {
      ElMessage.error(response.message);
      }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
onBeforeUnmount(() => {
  console.log("关闭了")
  closeWebSocket();