2026-08-31 12:58:28 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-card>
|
|
|
|
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
2026-10-31 15:41:27 +08:00
|
|
|
|
title="工位数以数据库为准。新增/停用/绑定工艺在此完成;虚拟工位(线下位)可在「工位名称」列直接点选重命名;内置工位名称锁定不可改、不可删除。" />
|
2026-09-17 19:41:00 +08:00
|
|
|
|
|
2026-11-10 23:42:50 +08:00
|
|
|
|
<!-- 工位模板:平铺展示(最多 20 个),点击应用 -->
|
|
|
|
|
|
<div style="margin-bottom:12px">
|
|
|
|
|
|
<div style="font-size:13px;font-weight:600;margin-bottom:6px">工位模板(点击应用,最多展示 20 个):</div>
|
|
|
|
|
|
<div style="display:flex;flex-wrap:wrap;gap:8px">
|
|
|
|
|
|
<el-button v-for="t in templates" :key="t.name" size="small" @click="openTemplate(t)">
|
|
|
|
|
|
{{ t.name }}<el-tag v-if="t.productCode" size="small" type="success" style="margin-left:6px">{{ t.productCode }}</el-tag>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<span v-if="!templates.length" style="color:#909399;font-size:12px">暂无工位模板,可在「产品工艺」页勾选多个产品工艺生成</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<div style="margin-bottom:12px">
|
|
|
|
|
|
<el-button v-if="can('produce.station:add')" type="primary" @click="openAdd">新增工位</el-button>
|
2026-10-17 17:49:47 +08:00
|
|
|
|
<span style="margin-left:12px;color:#909399;font-size:12px">虚拟工位类型选「线下位」,不连 PLC、仅记录上下线。</span>
|
2026-09-17 19:41:00 +08:00
|
|
|
|
</div>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
|
2026-10-09 13:46:33 +08:00
|
|
|
|
<el-form inline style="margin-bottom:10px">
|
|
|
|
|
|
<el-form-item label="绑定工艺">
|
|
|
|
|
|
<el-select v-model="filterFlow" clearable filterable placeholder="全部" style="width:180px">
|
|
|
|
|
|
<el-option v-for="f in flows" :key="f.id" :value="f.id" :label="f.name" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="产品工艺">
|
2026-10-10 15:58:59 +08:00
|
|
|
|
<el-select v-model="filterPP" clearable filterable placeholder="全部" style="width:190px">
|
|
|
|
|
|
<el-option v-for="p in ppOptions" :key="p.id" :value="p.name" :label="p.name" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="状态">
|
|
|
|
|
|
<el-select v-model="filterStatus" clearable placeholder="全部" style="width:110px">
|
|
|
|
|
|
<el-option label="启用" value="ENABLED" />
|
|
|
|
|
|
<el-option label="停用" value="DISABLED" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button type="primary" @click="load">查询</el-button>
|
|
|
|
|
|
<el-button @click="resetFilter">重置</el-button>
|
2026-10-09 13:46:33 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
2026-08-31 12:58:28 +08:00
|
|
|
|
<el-table :data="rows" border size="small">
|
|
|
|
|
|
<el-table-column prop="stationNo" label="工位号" width="90" align="center" />
|
2026-10-31 15:41:27 +08:00
|
|
|
|
<el-table-column label="工位名称" min-width="170">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-input v-if="row.stationType === 'OFFLINE' && renamingId === row.id" v-model="renameVal" size="small"
|
|
|
|
|
|
@blur="commitRename(row)" @keyup.enter="commitRename(row)" />
|
|
|
|
|
|
<span v-else-if="row.stationType === 'OFFLINE'" style="cursor:pointer;color:#409eff"
|
|
|
|
|
|
@click="startRename(row)">{{ row.name }} ✎</span>
|
|
|
|
|
|
<span v-else>{{ row.name }}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<el-table-column label="类型" width="90" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag size="small" :type="row.stationType === 'OFFLINE' ? 'info' : 'success'">
|
|
|
|
|
|
{{ row.stationType === 'OFFLINE' ? '线下位' : '线上位' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-09-18 18:54:54 +08:00
|
|
|
|
<el-table-column label="来源" width="90" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag size="small" :type="row.isBuiltin ? 'warning' : 'info'">
|
|
|
|
|
|
{{ row.isBuiltin ? '内置' : '自定义' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<el-table-column label="接驳台(实体)" width="100" align="center">
|
2026-09-18 18:54:54 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-10-07 20:00:06 +08:00
|
|
|
|
<el-tag size="small" :type="hasDockOf(row.stationNo) ? 'success' : 'info'">{{ hasDockOf(row.stationNo) ? '有' : '无' }}</el-tag>
|
2026-09-18 18:54:54 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-10-07 20:00:06 +08:00
|
|
|
|
<el-table-column label="接驳台编码" min-width="170">
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-10-07 20:00:06 +08:00
|
|
|
|
<span v-if="dockCodesOf(row.stationNo)">{{ dockCodesOf(row.stationNo) }}</span>
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<span v-else style="color:#909399">未绑定</span>
|
2026-09-19 07:50:21 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-10-10 15:58:59 +08:00
|
|
|
|
<el-table-column label="状态" width="80" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
2026-10-12 22:32:55 +08:00
|
|
|
|
<el-tag size="small" :type="row.status === 'ENABLED' ? 'success' : 'warning'">{{ row.status === 'ENABLED' ? '启用' : '停用' }}</el-tag>
|
2026-10-10 15:58:59 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<el-table-column label="绑定工艺" min-width="240">
|
2026-08-31 12:58:28 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-09-10 16:59:15 +08:00
|
|
|
|
<el-select :model-value="row.flowId" size="small" placeholder="未绑定" @change="(v) => bindFlow(row, v)" style="width:100%">
|
|
|
|
|
|
<el-option :value="0" label="未绑定" />
|
|
|
|
|
|
<el-option v-for="f in flows" :key="f.id" :value="f.id" :label="f.name + (f.status === 'ACTIVE' ? '' : '(停用)')" />
|
|
|
|
|
|
</el-select>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-10-09 13:46:33 +08:00
|
|
|
|
<el-table-column label="产品工艺(反查)" min-width="180" show-overflow-tooltip>
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<span v-if="row.productProcesses && row.productProcesses.length">{{ row.productProcesses.join('、') }}</span>
|
|
|
|
|
|
<span v-else style="color:#909399">-</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-09-23 11:41:28 +08:00
|
|
|
|
<el-table-column label="终端可见页签" min-width="200">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<template v-if="row.visibleTabs && row.visibleTabs.length">
|
|
|
|
|
|
<el-tag v-for="t in row.visibleTabs" :key="t" size="small" style="margin-right:4px">{{ tabLabel(t) }}</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span v-else style="color:#909399">全部显示</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2026-11-03 10:17:49 +08:00
|
|
|
|
<el-table-column label="操作" width="168" align="center" fixed="right">
|
2026-08-31 12:58:28 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-11-03 10:17:49 +08:00
|
|
|
|
<div style="display:flex;align-items:center;justify-content:center;gap:4px;flex-wrap:nowrap">
|
2026-10-31 15:41:27 +08:00
|
|
|
|
<el-button v-if="can('produce.station:edit') && !row.isBuiltin && row.stationType !== 'OFFLINE'" link type="primary" size="small" @click="openName(row)">编辑</el-button>
|
2026-11-02 19:17:05 +08:00
|
|
|
|
<el-button link type="primary" size="small" @click="openTabs(row)">页签</el-button>
|
|
|
|
|
|
<el-button v-if="can('produce.station:edit')" link size="small" :type="row.status === 'ENABLED' ? 'warning' : 'success'" @click="toggleStationStatus(row)">{{ row.status === 'ENABLED' ? '停用' : '启用' }}</el-button>
|
|
|
|
|
|
<el-button v-if="can('produce.station:delete') && !row.isBuiltin" link type="danger" size="small" @click="remove(row)">删除</el-button>
|
2026-10-20 16:36:26 +08:00
|
|
|
|
</div>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<el-dialog v-model="dlg.show" :title="dlg.title" width="440px">
|
2026-08-31 12:58:28 +08:00
|
|
|
|
<el-form :model="dlg" label-width="90px">
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<el-form-item label="工位号" required>
|
2026-11-02 19:17:05 +08:00
|
|
|
|
<el-input-number v-model="dlg.stationNo" :min="-999" :max="999" :disabled="!dlg.isAdd" style="width:100%" />
|
2026-10-29 18:16:53 +08:00
|
|
|
|
<div v-if="dlg.isAdd && dlg.stationNo >= 1 && dlg.stationNo <= 12" style="color:#F56C6C;font-size:12px;line-height:1.5;margin-top:4px">
|
|
|
|
|
|
物理工位 1~12 为硬件锁定,不可新增
|
|
|
|
|
|
</div>
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<div v-if="dlg.isAdd" style="color:#909399;font-size:12px;line-height:1.5;margin-top:4px">
|
2026-11-02 19:17:05 +08:00
|
|
|
|
1~12 为物理产线工位(已锁定,中间连续、不可插入虚拟工位);负数(-1、-2…)为产线前段虚拟工位(排在工位1之前);≥13 为扩展工位。创建后不可修改。
|
2026-09-17 19:41:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-form-item>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
<el-form-item label="工位名称" required>
|
|
|
|
|
|
<el-input v-model="dlg.name" placeholder="如 一号装配工位" />
|
|
|
|
|
|
</el-form-item>
|
2026-09-17 19:41:00 +08:00
|
|
|
|
<el-form-item label="工位类型">
|
2026-11-03 10:17:49 +08:00
|
|
|
|
<el-select v-if="!dlg.isBuiltin && !dlg.isAdd" v-model="dlg.stationType" style="width:100%">
|
2026-11-02 19:17:05 +08:00
|
|
|
|
<el-option value="OFFLINE" label="线下位(虚拟,不连 PLC,仅记录)" />
|
|
|
|
|
|
<el-option value="LINE" label="线上位(连 PLC)" />
|
|
|
|
|
|
</el-select>
|
2026-11-03 10:17:49 +08:00
|
|
|
|
<span v-else>线下位(虚拟,不连 PLC,仅记录)</span>
|
2026-10-26 16:32:35 +08:00
|
|
|
|
<div style="color:#909399;font-size:12px;line-height:1.5;margin-top:4px">
|
2026-11-03 10:17:49 +08:00
|
|
|
|
<template v-if="dlg.isAdd">新增工位均为虚拟工位(线下位),不连 PLC、仅记录上下线,类型不可选。</template>
|
|
|
|
|
|
<template v-else-if="dlg.isBuiltin">内置工位类型由产线初始配置固定,不可修改。</template>
|
|
|
|
|
|
<template v-else>非内置工位可调整类型(看板按「线下位」统计虚拟工位)。</template>
|
2026-10-26 16:32:35 +08:00
|
|
|
|
</div>
|
2026-09-17 19:41:00 +08:00
|
|
|
|
</el-form-item>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="dlg.show = false">取消</el-button>
|
2026-10-29 18:16:53 +08:00
|
|
|
|
<el-button v-if="can('produce.station:edit')" type="primary" :disabled="dlg.isAdd && dlg.stationNo >= 1 && dlg.stationNo <= 12" @click="save">保存</el-button>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2026-09-23 11:41:28 +08:00
|
|
|
|
<!-- 终端可见页签配置 -->
|
|
|
|
|
|
<el-dialog v-model="tabDlg.show" :title="`工位${tabDlg.stationNo} - 终端可见页签`" width="480px">
|
|
|
|
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
|
|
|
|
|
title="勾选该工位终端允许显示的页签;全部不勾 = 显示全部页签。配置后终端下次拉取任务即生效。" />
|
|
|
|
|
|
<el-checkbox-group v-model="tabDlg.tabs">
|
|
|
|
|
|
<el-checkbox v-for="t in TAB_OPTIONS" :key="t.v" :value="t.v">{{ t.l }}</el-checkbox>
|
|
|
|
|
|
</el-checkbox-group>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="tabDlg.show = false">取消</el-button>
|
|
|
|
|
|
<el-button v-if="can('produce.station:edit')" type="primary" @click="saveTabs">保存</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2026-11-10 23:42:50 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 查看工位模板并确认应用 -->
|
|
|
|
|
|
<el-dialog v-model="tplDlg.show" :title="`工位模板 - ${tplDlg.name}`" width="620px">
|
|
|
|
|
|
<div style="font-weight:600;margin-bottom:8px">工位 → 绑定工艺</div>
|
|
|
|
|
|
<el-table :data="tplDlg.stations" border size="small" empty-text="该模板未配置工位">
|
|
|
|
|
|
<el-table-column prop="stationNo" label="工位" width="90" align="center" />
|
|
|
|
|
|
<el-table-column label="绑定工艺" min-width="220">
|
|
|
|
|
|
<template #default="{ row }">{{ flowNameOf(row.flowId) }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<div style="margin-top:10px;font-size:13px">满足产品工艺:<b>{{ tplDlg.processNames.join('、') || '—' }}</b></div>
|
|
|
|
|
|
<div style="margin-top:6px;font-size:13px">适用产品:<b>{{ tplDlg.productCode || '不限定(跨产品模板)' }}</b></div>
|
|
|
|
|
|
<div style="margin-top:10px;font-size:13px">
|
|
|
|
|
|
本次要生产的产品(用于产品一致性校验):
|
|
|
|
|
|
<el-select v-model="tplDlg.targetProductCode" clearable filterable placeholder="不选=跳过校验" style="width:230px;margin-left:6px">
|
|
|
|
|
|
<el-option v-for="c in productCodes" :key="c" :value="c" :label="c" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="margin-top:6px;color:#909399;font-size:12px">点「预检并应用」会先逐条列出会被跳过的工位与原因,确认后才真正写入绑定。</div>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="tplDlg.show = false">取消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="precheckTemplate">预检并应用</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 套用前冲突清单:逐条列出跳过原因,用户确认后才提交 -->
|
|
|
|
|
|
<el-dialog v-model="precheckDlg.show" title="套用前检查" width="620px">
|
|
|
|
|
|
<div style="margin-bottom:8px;font-size:13px">
|
|
|
|
|
|
模板:<b>{{ precheckDlg.name }}</b> 适用产品:<b>{{ precheckDlg.productCode || '不限定' }}</b>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-alert v-if="precheckDlg.blockedCount" type="warning" :closable="false" show-icon
|
|
|
|
|
|
:title="`有 ${precheckDlg.blockedCount} 个工位会被跳过,其余工位仍会正常套用`" style="margin-bottom:10px" />
|
|
|
|
|
|
<el-alert v-else type="success" :closable="false" show-icon title="未发现冲突,全部工位可套用" style="margin-bottom:10px" />
|
|
|
|
|
|
<el-table :data="precheckDlg.rows" border size="small" max-height="320">
|
|
|
|
|
|
<el-table-column prop="stationNo" label="工位" width="80" align="center" />
|
|
|
|
|
|
<el-table-column label="绑定工艺" width="160">
|
|
|
|
|
|
<template #default="{ row }">{{ flowNameOf(row.flowId) }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="结果 / 跳过原因" min-width="240">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<span v-if="row.blocked" style="color:#e6a23c">{{ row.reasons.join(';') }}</span>
|
|
|
|
|
|
<span v-else style="color:#67c23a">可套用</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="precheckDlg.show = false">返回修改</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="confirmApplyTemplate">确认应用(跳过冲突工位)</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 模板应用结果(一次列全 applied / skipped / matched) -->
|
|
|
|
|
|
<el-dialog v-model="resultDlg.show" title="模板应用结果" width="520px">
|
|
|
|
|
|
<div style="margin-bottom:8px;font-size:13px">已应用工位:<b>{{ resultDlg.applied.length ? resultDlg.applied.map((n) => '工位' + n).join('、') : '—' }}</b></div>
|
|
|
|
|
|
<div style="margin-bottom:8px;font-size:13px">满足产品工艺:<b>{{ resultDlg.matched.length ? resultDlg.matched.join('、') : '—' }}</b></div>
|
|
|
|
|
|
<div style="font-weight:600;margin-bottom:6px">跳过的工位(冲突):</div>
|
|
|
|
|
|
<template v-if="resultDlg.skipped.length">
|
|
|
|
|
|
<div v-for="(s, i) in resultDlg.skipped" :key="i" style="color:#e6a23c;font-size:13px">工位{{ s.stationNo }}:{{ s.reason }}</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div v-else style="color:#909399;font-size:13px">无</div>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button type="primary" @click="resultDlg.show = false">知道了</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</el-card>
|
2026-09-07 11:58:19 +08:00
|
|
|
|
<PageHelp :data="helpStation" page="Station" />
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { reactive, ref, computed, onMounted } from 'vue'
|
2026-09-18 18:54:54 +08:00
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2026-08-31 12:58:28 +08:00
|
|
|
|
import request from '../utils/request'
|
|
|
|
|
|
import { can } from '../utils/perm'
|
|
|
|
|
|
import PageHelp from '../components/PageHelp.vue'
|
|
|
|
|
|
import { helpStation } from '../help'
|
|
|
|
|
|
|
|
|
|
|
|
const stations = ref([])
|
2026-09-10 16:59:15 +08:00
|
|
|
|
const flows = ref([])
|
2026-10-28 10:10:17 +08:00
|
|
|
|
// 接驳台主数据(真源在 dock 表):一工位可绑多个接驳台(左L/右R),展示按 dock.station_no 聚合
|
2026-10-07 20:00:06 +08:00
|
|
|
|
const dockByStation = ref({})
|
|
|
|
|
|
|
|
|
|
|
|
async function loadDocks() {
|
2026-10-08 16:08:16 +08:00
|
|
|
|
// GET /docks 返回裸数组(接驳台全量,非分页包裹),直接取数组本身
|
|
|
|
|
|
const data = await request.get('/docks')
|
|
|
|
|
|
const list = Array.isArray(data) ? data : (data?.list || [])
|
2026-10-07 20:00:06 +08:00
|
|
|
|
const map = {}
|
2026-10-08 16:08:16 +08:00
|
|
|
|
for (const d of list) {
|
2026-10-07 20:00:06 +08:00
|
|
|
|
const no = Number(d.stationNo) || 0
|
|
|
|
|
|
if (no <= 0) continue
|
|
|
|
|
|
;(map[no] = map[no] || []).push(d.dockCode)
|
|
|
|
|
|
}
|
|
|
|
|
|
dockByStation.value = map
|
|
|
|
|
|
}
|
|
|
|
|
|
function dockCodesOf(no) {
|
|
|
|
|
|
const codes = dockByStation.value[Number(no)] || []
|
|
|
|
|
|
return codes.length ? codes.join(' / ') : ''
|
|
|
|
|
|
}
|
|
|
|
|
|
function hasDockOf(no) {
|
|
|
|
|
|
return (dockByStation.value[Number(no)] || []).length > 0
|
|
|
|
|
|
}
|
2026-08-31 12:58:28 +08:00
|
|
|
|
|
2026-09-23 11:41:28 +08:00
|
|
|
|
// 终端页签固定集合(与工位终端 Main.vue 页签一一对应)
|
|
|
|
|
|
const TAB_OPTIONS = [
|
|
|
|
|
|
{ v: 'online', l: '上线建档' },
|
|
|
|
|
|
{ v: 'work', l: '作业' },
|
|
|
|
|
|
{ v: 'material', l: '物料' },
|
|
|
|
|
|
{ v: 'pdf', l: '工艺文件' },
|
|
|
|
|
|
{ v: 'inspect', l: '巡检' },
|
|
|
|
|
|
{ v: 'offline', l: '下线完工' }
|
|
|
|
|
|
]
|
|
|
|
|
|
const tabLabel = (v) => (TAB_OPTIONS.find((t) => t.v === v) || {}).l || v
|
|
|
|
|
|
|
2026-10-09 13:46:33 +08:00
|
|
|
|
// 筛选:绑定工艺(下拉)+ 产品工艺(名称模糊,反查列 client 端过滤;工位为全量小表无需后端分页)
|
|
|
|
|
|
const filterFlow = ref(null)
|
|
|
|
|
|
const filterPP = ref('')
|
2026-10-10 15:58:59 +08:00
|
|
|
|
const filterStatus = ref('ENABLED')
|
|
|
|
|
|
const ppOptions = ref([])
|
2026-10-09 13:46:33 +08:00
|
|
|
|
|
2026-08-31 12:58:28 +08:00
|
|
|
|
const rows = computed(() => {
|
2026-09-10 16:59:15 +08:00
|
|
|
|
return [...stations.value]
|
|
|
|
|
|
.sort((a, b) => (a.stationNo || 0) - (b.stationNo || 0))
|
2026-10-10 15:58:59 +08:00
|
|
|
|
.map((s) => ({ id: s.id, stationNo: s.stationNo, name: s.name, flowId: s.flowId, flowName: s.flowName, stationType: s.stationType, status: s.status, isBuiltin: !!s.isBuiltin, visibleTabs: Array.isArray(s.visibleTabs) ? s.visibleTabs : [], productProcesses: Array.isArray(s.productProcesses) ? s.productProcesses : [] }))
|
2026-10-09 13:46:33 +08:00
|
|
|
|
.filter((r) => (filterFlow.value ? r.flowId === filterFlow.value : true))
|
|
|
|
|
|
.filter((r) => (filterPP.value ? r.productProcesses.some((n) => n.toLowerCase().includes(filterPP.value.toLowerCase())) : true))
|
2026-10-10 15:58:59 +08:00
|
|
|
|
.filter((r) => (filterStatus.value ? r.status === filterStatus.value : true))
|
2026-08-31 12:58:28 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-10-10 15:58:59 +08:00
|
|
|
|
function resetFilter() {
|
|
|
|
|
|
filterFlow.value = null
|
|
|
|
|
|
filterPP.value = ''
|
|
|
|
|
|
filterStatus.value = 'ENABLED'
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function toggleStationStatus(row) {
|
|
|
|
|
|
const to = row.status === 'ENABLED' ? 'DISABLED' : 'ENABLED'
|
|
|
|
|
|
const action = to === 'DISABLED' ? '停用' : '启用'
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(`确认${action}工位${row.stationNo}「${row.name}」?`, '提示', { type: 'warning' })
|
|
|
|
|
|
} catch { return }
|
|
|
|
|
|
await request.post('/stations/status', { id: row.id, status: to })
|
|
|
|
|
|
ElMessage.success(`已${action}`)
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-02 19:17:05 +08:00
|
|
|
|
// 操作列按钮已外露(2026-11-02):页签/停用·启用/删除直接绑定,不再经"更多"下拉分发
|
2026-10-10 18:09:17 +08:00
|
|
|
|
|
2026-10-08 13:09:53 +08:00
|
|
|
|
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'OFFLINE', isBuiltin: false })
|
2026-08-31 12:58:28 +08:00
|
|
|
|
|
2026-09-23 11:41:28 +08:00
|
|
|
|
// 终端可见页签编辑(空数组 = 显示全部)
|
|
|
|
|
|
const tabDlg = reactive({ show: false, id: 0, stationNo: 0, name: '', stationType: 'LINE', tabs: [] })
|
|
|
|
|
|
|
|
|
|
|
|
function openTabs(row) {
|
|
|
|
|
|
Object.assign(tabDlg, { show: true, id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', tabs: [...row.visibleTabs] })
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function saveTabs() {
|
|
|
|
|
|
await request.post('/stations', {
|
|
|
|
|
|
id: tabDlg.id, stationNo: tabDlg.stationNo, name: tabDlg.name,
|
|
|
|
|
|
stationType: tabDlg.stationType, visibleTabs: tabDlg.tabs
|
|
|
|
|
|
})
|
|
|
|
|
|
ElMessage.success('页签配置已保存')
|
|
|
|
|
|
tabDlg.show = false
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-31 12:58:28 +08:00
|
|
|
|
async function load() {
|
|
|
|
|
|
stations.value = (await request.get('/stations')) || []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-17 19:41:00 +08:00
|
|
|
|
function openAdd() {
|
|
|
|
|
|
const used = new Set(stations.value.map((s) => s.stationNo))
|
|
|
|
|
|
let next = 14
|
|
|
|
|
|
while (used.has(next)) next++
|
2026-10-08 13:09:53 +08:00
|
|
|
|
Object.assign(dlg, { show: true, isAdd: true, title: '新增工位', id: 0, stationNo: next, name: '', stationType: 'OFFLINE', isBuiltin: false })
|
2026-09-17 19:41:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-31 12:58:28 +08:00
|
|
|
|
function openName(row) {
|
2026-10-08 13:09:53 +08:00
|
|
|
|
Object.assign(dlg, { show: true, isAdd: false, title: `工位${row.stationNo} - 修改`, id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', isBuiltin: !!row.isBuiltin })
|
2026-08-31 12:58:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-31 15:41:27 +08:00
|
|
|
|
// 虚拟工位(线下位)行内重命名:点名称旁 ✎ 进入编辑,失焦或回车提交
|
|
|
|
|
|
const renamingId = ref(0)
|
|
|
|
|
|
const renameVal = ref('')
|
|
|
|
|
|
function startRename(row) {
|
|
|
|
|
|
renamingId.value = row.id
|
|
|
|
|
|
renameVal.value = row.name
|
|
|
|
|
|
}
|
|
|
|
|
|
async function commitRename(row) {
|
|
|
|
|
|
if (renamingId.value !== row.id) return
|
|
|
|
|
|
const v = (renameVal.value || '').trim()
|
|
|
|
|
|
renamingId.value = 0
|
|
|
|
|
|
if (!v) {
|
|
|
|
|
|
ElMessage.warning('名称不能为空')
|
|
|
|
|
|
await load()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (v === row.name) return
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: v, stationType: row.stationType || 'LINE' })
|
|
|
|
|
|
ElMessage.success('名称已更新')
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
// 拦截器已提示
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
await load()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-31 12:58:28 +08:00
|
|
|
|
async function save() {
|
|
|
|
|
|
if (!dlg.name) return ElMessage.warning('请输入工位名称')
|
2026-10-29 18:16:53 +08:00
|
|
|
|
if (dlg.isAdd && dlg.stationNo >= 1 && dlg.stationNo <= 12) {
|
|
|
|
|
|
return ElMessage.warning('物理工位 1~12 为硬件锁定,不可新增')
|
|
|
|
|
|
}
|
2026-09-17 19:41:00 +08:00
|
|
|
|
if (dlg.isAdd && stations.value.some((s) => s.stationNo === dlg.stationNo)) {
|
|
|
|
|
|
return ElMessage.warning(`工位${dlg.stationNo} 已存在,请换一个工位号`)
|
|
|
|
|
|
}
|
2026-08-31 12:58:28 +08:00
|
|
|
|
await request.post('/stations', {
|
2026-11-03 10:17:49 +08:00
|
|
|
|
id: dlg.id, stationNo: dlg.stationNo, name: dlg.name, stationType: dlg.isAdd ? 'OFFLINE' : dlg.stationType
|
2026-08-31 12:58:28 +08:00
|
|
|
|
})
|
2026-09-17 19:41:00 +08:00
|
|
|
|
ElMessage.success(dlg.isAdd ? '工位已新增' : '已保存')
|
2026-08-31 12:58:28 +08:00
|
|
|
|
dlg.show = false
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 16:59:15 +08:00
|
|
|
|
async function bindFlow(row, fid) {
|
|
|
|
|
|
try {
|
2026-09-22 11:32:29 +08:00
|
|
|
|
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', flowId: fid })
|
|
|
|
|
|
ElMessage.success(fid ? '已绑定工艺' : '已解除绑定')
|
2026-10-20 16:36:26 +08:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
// 规则3(fail-open):PLC 离线未确认 → 后端返回 3021(拦截器不弹 toast),此处弹二次确认
|
|
|
|
|
|
if (e && e.code === 3021) {
|
|
|
|
|
|
let confirmed = false
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(
|
|
|
|
|
|
`PLC 当前离线,无法确认工位${row.stationNo} 是否还有工件。请到现场确认工位已清空后再操作。`,
|
|
|
|
|
|
'PLC 离线',
|
|
|
|
|
|
{ type: 'warning', confirmButtonText: '已现场确认,继续', cancelButtonText: '取消' }
|
|
|
|
|
|
)
|
|
|
|
|
|
confirmed = true
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
confirmed = false
|
|
|
|
|
|
}
|
|
|
|
|
|
if (confirmed) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.post('/stations', {
|
|
|
|
|
|
id: row.id, stationNo: row.stationNo, name: row.name,
|
|
|
|
|
|
stationType: row.stationType || 'LINE', flowId: fid, plcOfflineConfirmed: true
|
|
|
|
|
|
})
|
|
|
|
|
|
ElMessage.success(fid ? '已绑定工艺(PLC 离线已现场确认)' : '已解除绑定(PLC 离线已现场确认)')
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
// 二次重发仍失败:拦截器已提示(如在途指令/托盘在位等硬拒绝)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 其他错误拦截器已提示(如绑定到未启用的流程)
|
2026-09-10 16:59:15 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
await load()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-18 18:54:54 +08:00
|
|
|
|
async function remove(row) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(`确认删除工位${row.stationNo}「${row.name}」?`, '删除工位', { type: 'warning' })
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.delete(`/stations/${row.id}`)
|
|
|
|
|
|
ElMessage.success('工位已删除')
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
// 拦截器已提示(如内置工位不允许删除)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
await load()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// ---------- 工位派工已删除:路线由工单「工艺组合」决定,绑定关系即本页下拉选择 ----------
|
2026-09-19 07:50:21 +08:00
|
|
|
|
|
2026-11-10 23:42:50 +08:00
|
|
|
|
// ---------- 工位模板(平铺展示 / 查看 / 应用)----------
|
|
|
|
|
|
const templates = ref([])
|
|
|
|
|
|
async function loadTemplates() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = await request.get('/station-templates')
|
|
|
|
|
|
templates.value = (data?.list || []).slice(0, 20)
|
|
|
|
|
|
} catch { templates.value = [] }
|
|
|
|
|
|
}
|
|
|
|
|
|
const flowNameOf = (id) => (flows.value.find((f) => f.id === id) || {}).name || ('工艺' + id)
|
|
|
|
|
|
const tplDlg = reactive({ show: false, name: '', productCode: '', targetProductCode: '', stations: [], processNames: [] })
|
|
|
|
|
|
const productCodes = computed(() => [...new Set((ppOptions.value || []).map((p) => p.productCode).filter(Boolean))])
|
|
|
|
|
|
function openTemplate(t) {
|
|
|
|
|
|
tplDlg.name = t.name || ''
|
|
|
|
|
|
tplDlg.productCode = t.productCode || ''
|
|
|
|
|
|
// 默认目标产品=模板适用产品;用户可改选,改选后不一致会在预检时被拒
|
|
|
|
|
|
tplDlg.targetProductCode = t.productCode || ''
|
|
|
|
|
|
tplDlg.stations = Array.isArray(t.stations) ? t.stations : []
|
|
|
|
|
|
tplDlg.processNames = Array.isArray(t.processNames) ? t.processNames : []
|
|
|
|
|
|
tplDlg.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 套用两步走:先只读预检列冲突清单,用户确认后才写库(2026-11-10 问题2 闭环)
|
|
|
|
|
|
const precheckDlg = reactive({ show: false, name: '', productCode: '', targetProductCode: '', rows: [], blockedCount: 0 })
|
|
|
|
|
|
async function precheckTemplate() {
|
|
|
|
|
|
const resp = await request.post('/stations/apply-template/precheck', {
|
|
|
|
|
|
name: tplDlg.name, targetProductCode: tplDlg.targetProductCode
|
|
|
|
|
|
})
|
|
|
|
|
|
const rows = Array.isArray(resp?.rows) ? resp.rows : []
|
|
|
|
|
|
precheckDlg.name = tplDlg.name
|
|
|
|
|
|
precheckDlg.productCode = resp?.productCode || tplDlg.productCode
|
|
|
|
|
|
precheckDlg.targetProductCode = tplDlg.targetProductCode
|
|
|
|
|
|
precheckDlg.rows = rows
|
|
|
|
|
|
precheckDlg.blockedCount = rows.filter((r) => r.blocked).length
|
|
|
|
|
|
tplDlg.show = false
|
|
|
|
|
|
precheckDlg.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
async function confirmApplyTemplate() {
|
|
|
|
|
|
await applyTemplate(precheckDlg.targetProductCode)
|
|
|
|
|
|
precheckDlg.show = false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const resultDlg = reactive({ show: false, applied: [], skipped: [], matched: [] })
|
|
|
|
|
|
async function applyTemplate(targetProductCode) {
|
|
|
|
|
|
const resp = await request.post('/stations/apply-template', {
|
|
|
|
|
|
name: tplDlg.name, targetProductCode: targetProductCode || ''
|
|
|
|
|
|
})
|
|
|
|
|
|
tplDlg.show = false
|
|
|
|
|
|
resultDlg.applied = Array.isArray(resp?.applied) ? resp.applied : []
|
|
|
|
|
|
resultDlg.skipped = Array.isArray(resp?.skipped) ? resp.skipped : []
|
|
|
|
|
|
resultDlg.matched = Array.isArray(resp?.matched) ? resp.matched : []
|
|
|
|
|
|
resultDlg.show = true
|
|
|
|
|
|
await load()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-10 16:59:15 +08:00
|
|
|
|
onMounted(async () => {
|
2026-11-10 23:42:50 +08:00
|
|
|
|
await Promise.all([load(), loadDocks(), loadTemplates()])
|
2026-09-10 16:59:15 +08:00
|
|
|
|
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
2026-10-10 15:58:59 +08:00
|
|
|
|
try {
|
|
|
|
|
|
ppOptions.value = (await request.get('/product-processes', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
|
|
|
|
|
} catch { ppOptions.value = [] }
|
2026-09-10 16:59:15 +08:00
|
|
|
|
})
|
2026-08-31 12:58:28 +08:00
|
|
|
|
</script>
|