wuyouming666
2024-07-18 8e1ee5781fb9c3a812c24934d74272bcc1a6eaa0
UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
@@ -156,6 +156,45 @@
  console.log("关闭了")
  closeWebSocket();
});
const getTagType =(status) => {
      return status === 1 ? 'success' : 'danger';
      // 根据状态值决定标签类型,这里假设状态为1时为成功(绿色),否则为失败(红色)
    }
    const toggleStatus = (row) => {
      // 切换料架状态的逻辑
      row.enableState = 1 - row.enableState; // Toggle between 0 and 1
      // 此处可以添加保存状态的逻辑,比如调用 API 更新数据
      updateRowStatus(row);
    };
    const updateRowStatus = async (row) => {
  try {
    // 假设你的后端 API 接收 PUT 请求,并且需要传递 row.id 和 row.enableState 参数
    const response = await request.post('unLoadGlass/downWorkStation/updateDownWorkstation', {
      enableState: row.enableState,
      id: row.id
    });
    console.log('Updated row status:', response.data);
    // 可以根据后端返回的数据进行进一步处理,比如更新本地状态等
  } catch (error) {
    console.error('Error updating row status:', error);
    // 处理错误情况,比如提示用户更新失败
  }
};
// beforeUnmount(() => {
//   closeWebSocket();
// });
@@ -185,7 +224,10 @@
            prop="enableState"
          >
          <template #default="scope">
            <el-tag type="success" >{{ scope.row.enableState==1? $t('reportWork.enable') : $t('reportWork.unenable')}}</el-tag>
            <el-tag :type="getTagType(scope.row.enableState)" @click="toggleStatus(scope.row)">
          {{ scope.row.enableState === 1 ? $t('reportWork.enable') : $t('reportWork.unenable') }}
        </el-tag>
          </template>
          </el-table-column>
          <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="200">