2026-08-28 15:06:01 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="login-page">
|
|
|
|
|
|
<div class="login-card">
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<h1 class="title">工位终端</h1>
|
2026-08-28 15:06:01 +08:00
|
|
|
|
<p class="subtitle">产线触屏终端(端口 8892)</p>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
|
<span class="lab">账号</span>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model.trim="username"
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
placeholder="请输入账号"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
@keyup.enter="submit"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="field">
|
|
|
|
|
|
<span class="lab">密码</span>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="password"
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
type="password"
|
|
|
|
|
|
show-password
|
|
|
|
|
|
placeholder="请输入密码"
|
|
|
|
|
|
@keyup.enter="submit"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<div class="field">
|
|
|
|
|
|
<span class="lab">工位</span>
|
2026-11-09 18:58:47 +08:00
|
|
|
|
<!-- 固定模式:服务端配置了工位(stationNo>0),不允许选择 -->
|
|
|
|
|
|
<span v-if="fixedStation" class="station-fixed">工位 {{ fixedStation }}</span>
|
|
|
|
|
|
<!-- 选择模式:终端未配置工位(2026-11-09 拍板),实体+虚拟工位都可选 -->
|
|
|
|
|
|
<el-select v-else v-model="pickedStation" class="station-el" placeholder="请选择工位" size="large">
|
|
|
|
|
|
<el-option-group v-if="stationGroups.LINE.length" label="实体工位">
|
|
|
|
|
|
<el-option v-for="s in stationGroups.LINE" :key="s.stationNo" :label="stationLabel(s)" :value="s.stationNo" />
|
|
|
|
|
|
</el-option-group>
|
|
|
|
|
|
<el-option-group v-if="stationGroups.OFFLINE.length" label="虚拟工位">
|
|
|
|
|
|
<el-option v-for="s in stationGroups.OFFLINE" :key="s.stationNo" :label="stationLabel(s)" :value="s.stationNo" />
|
|
|
|
|
|
</el-option-group>
|
|
|
|
|
|
</el-select>
|
2026-08-31 08:06:55 +08:00
|
|
|
|
</div>
|
2026-08-28 15:06:01 +08:00
|
|
|
|
|
|
|
|
|
|
<el-button class="btn-login" type="primary" size="large" :loading="loading" @click="submit">
|
|
|
|
|
|
登 录
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<p class="hint">账号由 MES 统一管理</p>
|
2026-08-28 15:06:01 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-11-09 18:58:47 +08:00
|
|
|
|
import { computed, onMounted, ref } from 'vue'
|
2026-08-28 15:06:01 +08:00
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
2026-11-09 18:58:47 +08:00
|
|
|
|
import { getConfig, getStationOptions, login } from '../api'
|
2026-08-28 15:06:01 +08:00
|
|
|
|
import { setAuth } from '../utils/request'
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const username = ref('')
|
|
|
|
|
|
const password = ref('')
|
2026-11-09 18:58:47 +08:00
|
|
|
|
// null=未加载;>0=固定工位模式;<=0=选择模式(终端未配置工位)
|
2026-09-23 11:41:28 +08:00
|
|
|
|
const fixedStation = ref(null)
|
2026-11-09 18:58:47 +08:00
|
|
|
|
const pickedStation = ref(null)
|
|
|
|
|
|
const stationList = ref([])
|
2026-08-28 15:06:01 +08:00
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
2026-11-09 18:58:47 +08:00
|
|
|
|
const stationGroups = computed(() => ({
|
|
|
|
|
|
LINE: stationList.value.filter((s) => s.stationType !== 'OFFLINE'),
|
|
|
|
|
|
OFFLINE: stationList.value.filter((s) => s.stationType === 'OFFLINE')
|
|
|
|
|
|
}))
|
|
|
|
|
|
const stationLabel = (s) => {
|
|
|
|
|
|
const tip = s.stationType === 'OFFLINE' ? '(虚拟)' : ''
|
|
|
|
|
|
return s.name ? `工位 ${s.stationNo} ${s.name}${tip}` : `工位 ${s.stationNo}${tip}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2026-11-09 拍板:配置了工位(stationNo>0)登录页不允许选择;未配置则加载工位清单供选择
|
|
|
|
|
|
//(实体工位 + 虚拟工位 0 上线位/13 下线位)。固定模式下不再显示接驳台(dock 配置已删除)。
|
2026-08-31 08:06:55 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const cfg = await getConfig()
|
2026-11-09 18:58:47 +08:00
|
|
|
|
if (typeof cfg?.stationNo === 'number' && cfg.stationNo > 0) {
|
|
|
|
|
|
fixedStation.value = cfg.stationNo
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const list = await getStationOptions()
|
|
|
|
|
|
stationList.value = Array.isArray(list) ? list : []
|
|
|
|
|
|
// 默认选中首个虚拟工位(上线位 0)优先,否则首个实体工位
|
|
|
|
|
|
pickedStation.value = stationList.value.find((s) => s.stationType === 'OFFLINE')?.stationNo ??
|
|
|
|
|
|
stationList.value[0]?.stationNo ?? null
|
2026-08-31 08:06:55 +08:00
|
|
|
|
} catch {
|
2026-11-09 18:58:47 +08:00
|
|
|
|
// 网络异常:固定模式保持 null(提交时提示),选择模式保持空清单(提交时提示)
|
2026-08-31 08:06:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-08-28 15:06:01 +08:00
|
|
|
|
async function submit() {
|
|
|
|
|
|
if (!username.value || !password.value) {
|
|
|
|
|
|
ElMessage.warning('请输入账号和密码')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-11-09 18:58:47 +08:00
|
|
|
|
let stationNo
|
|
|
|
|
|
if (fixedStation.value) {
|
|
|
|
|
|
stationNo = fixedStation.value
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (pickedStation.value === null || pickedStation.value === undefined) {
|
|
|
|
|
|
ElMessage.warning('请选择工位(工位清单未加载时请检查 MES 服务)')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
stationNo = pickedStation.value
|
2026-08-31 08:06:55 +08:00
|
|
|
|
}
|
2026-08-28 15:06:01 +08:00
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
2026-08-31 08:06:55 +08:00
|
|
|
|
const data = await login({
|
|
|
|
|
|
username: username.value,
|
|
|
|
|
|
password: password.value,
|
2026-11-09 18:58:47 +08:00
|
|
|
|
stationNo
|
2026-08-31 08:06:55 +08:00
|
|
|
|
})
|
2026-11-09 18:58:47 +08:00
|
|
|
|
// 选择模式:记住本班次实际登录工位(0 为合法虚拟工位号,sessionStorage 保存)
|
|
|
|
|
|
if (!fixedStation.value) sessionStorage.setItem('stationNo', String(stationNo))
|
2026-08-31 08:06:55 +08:00
|
|
|
|
setAuth(data.accessToken, data.user)
|
2026-08-28 15:06:01 +08:00
|
|
|
|
ElMessage.success('登录成功')
|
|
|
|
|
|
router.push('/main')
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
// 错误提示已由 request 封装统一弹出
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.login-page {
|
|
|
|
|
|
height: 100vh;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
background: linear-gradient(135deg, #0f2b4c 0%, #14385f 60%, #1a4a7a 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.login-card {
|
|
|
|
|
|
width: 480px;
|
|
|
|
|
|
padding: 48px 56px;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
|
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
|
margin: 0 0 8px;
|
2026-08-31 08:06:55 +08:00
|
|
|
|
font-size: 34px;
|
2026-08-28 15:06:01 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
color: #16324f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.subtitle {
|
|
|
|
|
|
margin: 0 0 32px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
color: #7a8aa0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.field {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
margin-bottom: 22px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.lab {
|
|
|
|
|
|
width: 64px;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #16324f;
|
|
|
|
|
|
text-align: right;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.field :deep(.el-input__inner) {
|
|
|
|
|
|
height: 52px;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-31 08:06:55 +08:00
|
|
|
|
.station-el {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.station-el :deep(.el-input__inner) {
|
|
|
|
|
|
height: 52px;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #16324f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.station-fixed {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
font-size: 22px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #16324f;
|
|
|
|
|
|
line-height: 52px;
|
|
|
|
|
|
background: #f2f6fb;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-28 15:06:01 +08:00
|
|
|
|
.btn-login {
|
|
|
|
|
|
width: calc(100% - 80px);
|
|
|
|
|
|
margin-left: 80px;
|
|
|
|
|
|
height: 54px;
|
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
|
letter-spacing: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.hint {
|
|
|
|
|
|
margin-top: 26px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #9aa7b8;
|
|
|
|
|
|
}
|
2026-08-31 08:06:55 +08:00
|
|
|
|
</style>
|