【全系统 · 时间权威与鉴权(核心)】 - 新增 clock 包(三端各一份):谁签发 JWT 就以谁的时间验 exp——验签方向签发方取 /api/server-time(30s 缓存,取不到降级本机 + 10min 容差兜底),本端签发用本机时间 - 三端均注册 GET /api/server-time;MES/WMS/终端配同一份「签发方→取时间地址」映射 - 密钥 SHA256 前 8 位指纹日志([鉴权诊断]),现场比对两端指纹秒定位密钥不一致导致的 401「登录已失效」 - token 由 localStorage 改 sessionStorage;登录响应带服务器时间,偏差只提示「时间已自动校正」不拦截 - 现场人工 w32tm 对时操作卡作废(随文档留存,正常部署无需执行) 【WMS · 库存盘点重构】 - 快照粒度改「物料 × 库位」:同物料 A/B 区拆两条各盘各的;扫码命中多行弹库位清单逐库位录入、写回精确定位,行不存在报错不静默跳过 - GET /api/stocktake/active 返回全部进行中单(旧 .First() 只返一条导致历史多单看不见、库存长期冻结);前端加单号下拉切换,刷新保持当前单 - 历史卡死单只走「完成/取消」事务解冻,严禁删库;写回任何一行失败都强提示,不吞错 - 去「全库」,按区域筛选支持选到区/货架/层/号任意层级;「本次盘点范围」同步加筛选、物料按区域过滤;去多余「(可选)」字样 【WMS/MES · 档案删除与停用口径】 - 产品档案新建默认停用(product_process.status ACTIVE→INACTIVE),配齐工艺路线+总账+分账才允许启用 - 产品/物料档案删除按钮统一为一个(按 WMS 做法),仅「无任何引用」可物理删;引用检查覆盖两库、查库报错一律拒绝删除(fail-close,不再误删) - 产品编码自动生成,重复则自增保证唯一;权限对齐:停用走「编辑」、删除走独立「删除」码 - WMS 删物料同步核查 MES 引用,MES 不可达/删除失败则拒绝并落同步失败台账,无兼容补录行 【业务整改】 - MES 工单整体完工自动结算遗留 PENDING 叫料单(释放占用额度);已发货 SHIPPED 不动,仅落日志提示人工签收 - WMS 已收货退库单支持直接修正数量(问题14):原单不动、留痕(修正人/时间/原因/前后值),库存差额补扣,SN 件按最终 SN 集合增删行 - 日排产:「排产日期范围」→「排产日期」;平铺补产品编码/名称;「产品型号」→「产品」去产品编号/名称;平均分摊与每日固定互算;删除写操作日志 - 齐套测算:逐日消耗模拟按实际排产日期;工单详情增「总物料清单」(照搬产品档案总账,实时) - PLC 对账:虚拟/离线工位(OFFLINE,如 15)跳过 PLC 托盘位读取,不再为特例扔给 PLC - AGV 点位锁与回调细节按 11-20 现场整改继续修正(agv.go / agv_point_lock.go) 【文档】 - 新增《全系统业务深坑审计报告》《全系统串联审计报告》《现场对时操作卡》;更新产线API.md、案例.md、问题临时.md(记录甲方逐条原话与验收口径)
240 lines
7.3 KiB
Vue
240 lines
7.3 KiB
Vue
<template>
|
||
<div class="login-page">
|
||
<div class="login-card">
|
||
<h1 class="title">工位终端</h1>
|
||
<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>
|
||
<div class="field">
|
||
<span class="lab">工位</span>
|
||
<!-- 固定模式:服务端配置了工位(stationNo>0),不允许选择 -->
|
||
<span v-if="fixedStation" class="station-fixed">工位 {{ fixedStation }}</span>
|
||
<!-- 选择模式(2026-11-11 多会话拍板):终端未配置工位=虚拟工位专用机,只允许选虚拟工位 -->
|
||
<el-select v-else v-model="pickedStation" filterable class="station-el" :placeholder="stationGroups.OFFLINE.length ? '请选择虚拟工位' : '未查到可用的虚拟工位,请先在 MES 工位管理中配置'" size="large">
|
||
<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>
|
||
</div>
|
||
|
||
<el-button class="btn-login" type="primary" size="large" :loading="loading" @click="submit">
|
||
登 录
|
||
</el-button>
|
||
|
||
<p class="hint">账号由 MES 统一管理</p>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { computed, onMounted, ref } from 'vue'
|
||
import { useRouter } from 'vue-router'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import { getConfig, getStationOptions, login } from '../api'
|
||
import { setAuth } from '../utils/request'
|
||
|
||
const router = useRouter()
|
||
const username = ref('')
|
||
const password = ref('')
|
||
// null=未加载;>0=固定工位模式;<=0=选择模式(终端未配置工位)
|
||
const fixedStation = ref(null)
|
||
const pickedStation = ref(null)
|
||
const stationList = ref([])
|
||
const loading = ref(false)
|
||
|
||
const stationGroups = computed(() => ({
|
||
// 2026-11-24 拍板:放开负数号虚拟工位(前段虚拟工位 -1/-2… 在 MES 合法),
|
||
// 只排除 0(原 0 号上线位已废弃);仍以 stationType=OFFLINE 为准。
|
||
OFFLINE: stationList.value.filter((s) => s.stationType === 'OFFLINE' && Number.isInteger(Number(s.stationNo)) && Number(s.stationNo) !== 0)
|
||
}))
|
||
const stationLabel = (s) => {
|
||
const tip = s.stationType === 'OFFLINE' ? '(虚拟)' : ''
|
||
return s.name ? `工位 ${s.stationNo} ${s.name}${tip}` : `工位 ${s.stationNo}${tip}`
|
||
}
|
||
|
||
// 2026-11-09 拍板:配置了工位(stationNo>0)登录页不允许选择。
|
||
// 2026-11-11 多会话拍板:未配置工位(<=0)的终端实例=虚拟工位专用机,登录页只显示虚拟工位
|
||
//(后端登录接口同样硬校验 stationType=OFFLINE,防前端绕过)。固定模式下不显示接驳台。
|
||
onMounted(async () => {
|
||
try {
|
||
const cfg = await getConfig()
|
||
if (typeof cfg?.stationNo === 'number' && cfg.stationNo > 0) {
|
||
fixedStation.value = cfg.stationNo
|
||
return
|
||
}
|
||
const list = await getStationOptions()
|
||
stationList.value = Array.isArray(list) ? list : []
|
||
// 默认选中首个可选虚拟工位(只列正整数工位号)
|
||
pickedStation.value = stationGroups.value.OFFLINE[0]?.stationNo ?? null
|
||
} catch {
|
||
// 网络异常:固定模式保持 null(提交时提示),选择模式保持空清单(提交时提示)
|
||
}
|
||
})
|
||
|
||
async function submit() {
|
||
if (!username.value || !password.value) {
|
||
ElMessage.warning('请输入账号和密码')
|
||
return
|
||
}
|
||
let stationNo
|
||
if (fixedStation.value) {
|
||
stationNo = fixedStation.value
|
||
} else {
|
||
if (pickedStation.value === null || pickedStation.value === undefined) {
|
||
ElMessage.warning(stationGroups.value.OFFLINE.length
|
||
? '请选择虚拟工位'
|
||
: '未查到可用的虚拟工位,请先在 MES 工位管理中配置')
|
||
return
|
||
}
|
||
stationNo = pickedStation.value
|
||
}
|
||
loading.value = true
|
||
try {
|
||
const data = await login({
|
||
username: username.value,
|
||
password: password.value,
|
||
stationNo
|
||
})
|
||
// 选择模式:记住本班次实际登录工位与工位类型(供主界面判定虚拟工位)
|
||
if (!fixedStation.value) {
|
||
sessionStorage.setItem('stationNo', String(stationNo))
|
||
const picked = stationList.value.find((s) => String(s.stationNo) === String(stationNo))
|
||
sessionStorage.setItem('stationType', picked?.stationType || '')
|
||
}
|
||
setAuth(data.accessToken, data.user)
|
||
// 2026-11-24 时间权威(用户拍板):JWT 验签已改为按签发方服务器时间,不再要求现场人工对时。
|
||
// 登录响应带 MES 服务器时间,记下本机与服务器的偏移供前端展示;偏差大只提示"已按服务器时间校正",不拦登录。
|
||
if (data.serverTime) {
|
||
const serverSec = Number(data.serverTime)
|
||
const offset = serverSec - Math.floor(Date.now() / 1000)
|
||
sessionStorage.setItem('serverTimeOffset', String(offset))
|
||
const skew = Math.abs(offset)
|
||
if (skew > 60) {
|
||
const desc = skew >= 60 ? Math.round(skew / 60) + ' 分钟' : skew + ' 秒'
|
||
ElMessageBox.alert(
|
||
'本机与 MES 服务器时钟相差约 ' + desc + '。\n\n' +
|
||
'系统已按服务器时间校正登录校验,不影响使用;报工/签字时间以服务器时间为准。',
|
||
'时间已自动校正',
|
||
{ confirmButtonText: '知道了', type: 'info', customStyle: { whiteSpace: 'pre-line' } }
|
||
).catch(() => {})
|
||
}
|
||
}
|
||
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;
|
||
font-size: 34px;
|
||
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;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.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;
|
||
}
|
||
</style>
|