2026-08-29 15:30:25 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-card>
|
|
|
|
|
|
<el-form inline>
|
|
|
|
|
|
<el-form-item label="工单号">
|
|
|
|
|
|
<el-select v-model="query.orderNo" filterable allow-create clearable placeholder="请选择/输入工单号" style="width:220px" @change="load">
|
|
|
|
|
|
<el-option v-for="w in workOrders" :key="w.workOrderNo" :label="w.workOrderNo" :value="w.workOrderNo" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="排产日期">
|
|
|
|
|
|
<el-date-picker v-model="query.planDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" @change="load" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button type="primary" @click="load">查询</el-button>
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<el-button v-if="can('produce.workorder:dailyplan')" type="success" @click="openAdd">新建排产</el-button>
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<el-table :data="list" border size="small">
|
|
|
|
|
|
<el-table-column prop="orderNo" label="工单号" min-width="180" />
|
|
|
|
|
|
<el-table-column prop="planDate" label="排产日期" width="120" />
|
|
|
|
|
|
<el-table-column prop="planQty" label="计划数量" width="100" />
|
|
|
|
|
|
<el-table-column prop="completedQty" label="已完成" width="90" />
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<el-table-column label="送达接驳台(派生)" min-width="160">
|
2026-09-04 14:18:53 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<el-tag v-for="d in docksOf(row)" :key="d" size="small" class="dock-tag">{{ d }}</el-tag>
|
|
|
|
|
|
<span v-if="!docksOf(row).length" class="dock-empty">未配置工艺组合</span>
|
2026-09-04 14:18:53 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="执行状态" width="110">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag :type="planStatusTag(row.status)" size="small">{{ statusText(row.status) }}</el-tag>
|
|
|
|
|
|
</template>
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="operator" label="操作人" min-width="90" />
|
2026-09-18 13:54:30 +08:00
|
|
|
|
<el-table-column label="操作" width="330">
|
2026-08-29 15:30:25 +08:00
|
|
|
|
<template #default="{ row }">
|
2026-09-18 13:54:30 +08:00
|
|
|
|
<el-button size="small" type="primary" link @click="openDetail(row)">详情</el-button>
|
2026-09-17 12:49:07 +08:00
|
|
|
|
<el-button v-if="can('produce.workorder:dailyplan') && (row.status === 'PENDING' || row.status === 'CONFIRMED')"
|
|
|
|
|
|
size="small" :type="row.status === 'CONFIRMED' ? 'warning' : 'success'" @click="toggleStatus(row)">
|
|
|
|
|
|
{{ row.status === 'CONFIRMED' ? '停用' : '启用' }}
|
|
|
|
|
|
</el-button>
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<el-button v-if="can('produce.workorder:dailyplan')" size="small" @click="openEdit(row)">编辑</el-button>
|
|
|
|
|
|
<el-button v-if="can('produce.workorder:dailyplan')" size="small" type="danger" @click="del(row)">删除</el-button>
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<el-dialog v-model="dialog.show" :title="dialog.id ? '编辑排产' : '新建排产'" width="600px">
|
2026-09-18 13:54:30 +08:00
|
|
|
|
<el-form :model="dialog" label-width="92px">
|
2026-08-29 15:30:25 +08:00
|
|
|
|
<el-form-item label="工单号">
|
2026-09-18 13:54:30 +08:00
|
|
|
|
<el-select v-model="dialog.orderNo" filterable allow-create placeholder="请选择/输入工单号" style="width:100%" @change="onOrderChange">
|
2026-08-29 15:30:25 +08:00
|
|
|
|
<el-option v-for="w in workOrders" :key="w.workOrderNo" :label="w.workOrderNo" :value="w.workOrderNo" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2026-09-18 13:54:30 +08:00
|
|
|
|
<!-- 选工单号后自动带出(只读) -->
|
|
|
|
|
|
<el-form-item label="产品型号"><el-input :model-value="dialog.productType" disabled placeholder="随工单号自动带出" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="产品编号"><el-input :model-value="dialog.productCode" disabled placeholder="随工单号自动带出" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="产品名称"><el-input :model-value="dialog.productName" disabled placeholder="随工单号自动带出" /></el-form-item>
|
|
|
|
|
|
<el-form-item label="工单数量"><el-input :model-value="dialog.woQty" disabled placeholder="随工单号自动带出" /></el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 新建:日期范围 + 排产模式(一排多天,参考工单「自动排产」) -->
|
|
|
|
|
|
<template v-if="!dialog.id">
|
|
|
|
|
|
<el-form-item label="排产日期范围">
|
|
|
|
|
|
<el-date-picker v-model="dialog.planRange" type="daterange" value-format="YYYY-MM-DD"
|
|
|
|
|
|
start-placeholder="开始日期" end-placeholder="结束日期" style="width:100%" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="排产模式">
|
|
|
|
|
|
<el-radio-group v-model="dialog.mode">
|
|
|
|
|
|
<el-radio value="AVG">平均分摊</el-radio>
|
|
|
|
|
|
<el-radio value="FIXED">固定日产</el-radio>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item :label="dialog.mode === 'FIXED' ? '每日产量' : '总数量'">
|
|
|
|
|
|
<el-input-number v-model="dialog.planQty" :min="1" style="width:100%" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
|
|
|
|
|
:title="`共 ${previewDates.length} 天:${previewDates.join('、') || '-'}`" />
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
2026-09-22 11:32:29 +08:00
|
|
|
|
title="送达接驳台与工位产量分配由工单「工艺组合」自动派生,此处无需手填;如需调整工位产量,启用后点击「编辑」设置。" />
|
2026-09-18 13:54:30 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<!-- 编辑:单日 -->
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<el-form-item label="排产日期">
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<el-date-picker v-model="dialog.planDate" type="date" value-format="YYYY-MM-DD" style="width:100%" />
|
2026-09-18 13:54:30 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="计划数量">
|
|
|
|
|
|
<el-input-number v-model="dialog.planQty" :min="1" style="width:100%" />
|
|
|
|
|
|
</el-form-item>
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<el-form-item label="工位产量分配">
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<div v-if="allocStations.length" style="width:100%">
|
|
|
|
|
|
<div v-for="st in allocStations" :key="st" style="display:flex;gap:8px;align-items:center;margin-bottom:6px">
|
2026-09-19 07:50:21 +08:00
|
|
|
|
<span style="width:150px">工位{{ st }}<template v-if="stationNameMap[st]">({{ stationNameMap[st] }})</template></span>
|
|
|
|
|
|
<el-input-number v-model="alloc[st]" :min="0" :max="dialog.planQty" controls-position="right" style="width:150px" />
|
|
|
|
|
|
<span style="color:#909399;font-size:12px">件</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="font-size:12px;color:#909399">已分配合计:{{ allocTotal }} / 计划 {{ dialog.planQty }}(建议相等;留空或 0 的工位不分担产量)</div>
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<div style="font-size:12px;color:#909399">各工位分产量决定备料拆分;未配置则同工艺工位平均分</div>
|
2026-09-19 07:50:21 +08:00
|
|
|
|
</div>
|
2026-09-22 11:32:29 +08:00
|
|
|
|
<el-alert v-else type="info" :closable="false" title="该工单未配置工艺组合,无法分配工位产量;请先到「工单管理」编辑工单勾选工艺组合。" />
|
2026-09-19 07:50:21 +08:00
|
|
|
|
</el-form-item>
|
2026-09-18 13:54:30 +08:00
|
|
|
|
</template>
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="dialog.show=false">取消</el-button>
|
2026-08-31 08:06:55 +08:00
|
|
|
|
<el-button v-if="can('produce.workorder:dailyplan')" type="primary" @click="save">保存</el-button>
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2026-09-18 13:54:30 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 排产详情(只读,列表点「详情」打开,不可编辑) -->
|
|
|
|
|
|
<DetailDrawer :visible="detail.show" @update:visible="detail.show = $event"
|
|
|
|
|
|
:title="detail.title" :fields="detail.fields" :data="detail.row" />
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</el-card>
|
2026-09-07 11:58:19 +08:00
|
|
|
|
<PageHelp :data="helpDailyPlan" page="DailyPlan" />
|
2026-08-29 15:30:25 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
2026-09-04 14:18:53 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.dock-tag { margin-right: 4px; }
|
|
|
|
|
|
.dock-empty { color: #999; font-size: 12px; }
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
2026-08-29 15:30:25 +08:00
|
|
|
|
<script setup>
|
2026-09-18 13:54:30 +08:00
|
|
|
|
import { reactive, ref, computed, onMounted } from 'vue'
|
2026-08-29 15:30:25 +08:00
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
|
import request from '../utils/request'
|
2026-08-31 08:06:55 +08:00
|
|
|
|
import { can } from '../utils/perm'
|
2026-08-29 15:30:25 +08:00
|
|
|
|
import PageHelp from '../components/PageHelp.vue'
|
2026-09-18 13:54:30 +08:00
|
|
|
|
import DetailDrawer from '../components/DetailDrawer.vue'
|
2026-08-29 15:30:25 +08:00
|
|
|
|
import { helpDailyPlan } from '../help'
|
|
|
|
|
|
|
|
|
|
|
|
const query = reactive({ orderNo: '', planDate: '' })
|
|
|
|
|
|
const list = ref([])
|
|
|
|
|
|
const workOrders = ref([])
|
2026-09-18 13:54:30 +08:00
|
|
|
|
const productTypes = ref([])
|
2026-09-22 11:32:29 +08:00
|
|
|
|
const dialog = reactive({ show: false, id: 0, orderNo: '', planDate: '', planRange: [], mode: 'AVG', planQty: 1, productType: '', productCode: '', productName: '', woQty: '', stationPlanQty: {}, combination: [] })
|
2026-09-19 07:50:21 +08:00
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 工位号→接驳台编码、工位号→名称(送达接驳台由工单工艺组合派生)
|
2026-09-19 07:50:21 +08:00
|
|
|
|
const stationDockMap = ref({})
|
|
|
|
|
|
const stationNameMap = ref({})
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 编辑时工位产量分配(按工单工艺组合工位拆分)
|
|
|
|
|
|
const allocStations = ref([])
|
2026-09-19 07:50:21 +08:00
|
|
|
|
const alloc = reactive({})
|
|
|
|
|
|
const allocTotal = computed(() => Object.values(alloc).reduce((a, b) => a + (Number(b) || 0), 0))
|
2026-09-18 13:54:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 新建排产「日期范围 + 模式」预览:展开为去重升序日期列表(仅前端提示,后端以 planRange 为准)
|
|
|
|
|
|
const previewDates = computed(() => {
|
|
|
|
|
|
const r = dialog.planRange
|
|
|
|
|
|
if (!r || r.length !== 2 || !r[0] || !r[1]) return []
|
|
|
|
|
|
const p = (n) => String(n).padStart(2, '0')
|
|
|
|
|
|
const start = new Date(r[0] + 'T00:00:00')
|
|
|
|
|
|
const end = new Date(r[1] + 'T00:00:00')
|
|
|
|
|
|
if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || end < start) return []
|
|
|
|
|
|
const out = []
|
|
|
|
|
|
for (let d = new Date(start); d <= end; d.setDate(d.getDate() + 1)) {
|
|
|
|
|
|
out.push(`${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`)
|
|
|
|
|
|
}
|
|
|
|
|
|
return out
|
|
|
|
|
|
})
|
2026-08-29 15:30:25 +08:00
|
|
|
|
|
|
|
|
|
|
const statusOptions = [
|
2026-09-17 12:49:07 +08:00
|
|
|
|
{ v: 'PENDING', l: '未启用' }, { v: 'CONFIRMED', l: '已启用' },
|
|
|
|
|
|
{ v: 'PROCESSING', l: '执行中' }, { v: 'DONE', l: '已完成' }, { v: 'CANCELLED', l: '已取消' }
|
2026-08-29 15:30:25 +08:00
|
|
|
|
]
|
|
|
|
|
|
const statusText = (s) => (statusOptions.find((x) => x.v === s) || {}).l || s
|
2026-09-04 14:18:53 +08:00
|
|
|
|
const planStatusTag = (s) =>
|
2026-09-17 12:49:07 +08:00
|
|
|
|
s === 'DONE' ? 'success' : s === 'PROCESSING' ? 'warning' : s === 'CONFIRMED' ? 'primary' : 'info'
|
2026-08-29 15:30:25 +08:00
|
|
|
|
|
2026-09-19 07:50:21 +08:00
|
|
|
|
async function loadStations() {
|
|
|
|
|
|
const sts = (await request.get('/stations')) || []
|
|
|
|
|
|
const dm = {}
|
|
|
|
|
|
const nm = {}
|
|
|
|
|
|
sts.forEach((s) => { dm[s.stationNo] = s.dockCode || ''; nm[s.stationNo] = s.name })
|
|
|
|
|
|
stationDockMap.value = dm
|
|
|
|
|
|
stationNameMap.value = nm
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-29 15:30:25 +08:00
|
|
|
|
async function load() {
|
|
|
|
|
|
list.value = (await request.get('/daily-plans', { params: query })) || []
|
2026-09-19 07:50:21 +08:00
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 该行送达接驳台:由工单工艺组合的工位号 → 接驳台编码去重派生
|
|
|
|
|
|
function docksOf(row) {
|
|
|
|
|
|
const comb = row.flowCombination || []
|
|
|
|
|
|
const seen = {}
|
|
|
|
|
|
const ds = []
|
|
|
|
|
|
comb.map((c) => c.stationNo).sort((a, b) => a - b).forEach((n) => {
|
|
|
|
|
|
const dc = stationDockMap.value[n]
|
|
|
|
|
|
if (dc && !seen[dc]) { seen[dc] = true; ds.push(dc) }
|
|
|
|
|
|
})
|
|
|
|
|
|
return ds
|
2026-08-29 15:30:25 +08:00
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 从工单工艺组合派生分配工位,初始化工位产量分配
|
|
|
|
|
|
function loadAlloc() {
|
|
|
|
|
|
const stations = [...new Set((dialog.combination || []).map((c) => c.stationNo))].sort((a, b) => a - b)
|
|
|
|
|
|
allocStations.value = stations
|
2026-09-19 07:50:21 +08:00
|
|
|
|
const init = {}
|
|
|
|
|
|
stations.forEach((st) => { init[st] = 0 })
|
|
|
|
|
|
const spq = dialog.stationPlanQty || {}
|
|
|
|
|
|
const hasAny = stations.some((st) => spq[String(st)] != null)
|
|
|
|
|
|
if (hasAny) {
|
|
|
|
|
|
stations.forEach((st) => { if (spq[String(st)] != null) init[st] = spq[String(st)] })
|
|
|
|
|
|
} else if (stations.length) {
|
|
|
|
|
|
const base = Math.floor(dialog.planQty / stations.length)
|
|
|
|
|
|
stations.forEach((st, i) => { init[st] = base + (i < dialog.planQty % stations.length ? 1 : 0) })
|
|
|
|
|
|
}
|
|
|
|
|
|
Object.keys(alloc).forEach((k) => { delete alloc[k] })
|
|
|
|
|
|
Object.assign(alloc, init)
|
2026-09-04 14:18:53 +08:00
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 选工单号自动带出其产品信息与工艺组合(只读展示,避免手填错位)
|
2026-09-18 13:54:30 +08:00
|
|
|
|
function loadWorkOrderInfo() {
|
|
|
|
|
|
const wo = workOrders.value.find((w) => w.workOrderNo === dialog.orderNo)
|
|
|
|
|
|
if (!wo) {
|
|
|
|
|
|
dialog.productType = ''; dialog.productCode = ''; dialog.productName = ''; dialog.woQty = ''
|
2026-09-22 11:32:29 +08:00
|
|
|
|
dialog.combination = []
|
2026-09-18 13:54:30 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
dialog.productCode = wo.productCode || ''
|
|
|
|
|
|
dialog.productName = wo.productName || ''
|
|
|
|
|
|
dialog.woQty = wo.quantity || 0
|
2026-09-22 11:32:29 +08:00
|
|
|
|
dialog.combination = Array.isArray(wo.flowCombination) ? wo.flowCombination : []
|
2026-09-18 13:54:30 +08:00
|
|
|
|
const pt = productTypes.value.find((p) => p.id === wo.productTypeId)
|
|
|
|
|
|
dialog.productType = pt ? (pt.name + (pt.code ? ' / ' + pt.code : '')) : ''
|
|
|
|
|
|
}
|
|
|
|
|
|
function onOrderChange() {
|
|
|
|
|
|
loadWorkOrderInfo()
|
|
|
|
|
|
}
|
2026-08-29 15:30:25 +08:00
|
|
|
|
function openAdd() {
|
2026-09-18 13:54:30 +08:00
|
|
|
|
const today = new Date().toISOString().slice(0, 10)
|
|
|
|
|
|
Object.assign(dialog, {
|
|
|
|
|
|
show: true, id: 0, orderNo: '', planDate: '', planRange: [today, today], mode: 'AVG',
|
2026-09-22 11:32:29 +08:00
|
|
|
|
planQty: 1, productType: '', productCode: '', productName: '', woQty: '', stationPlanQty: {}, combination: []
|
2026-09-18 13:54:30 +08:00
|
|
|
|
})
|
2026-08-29 15:30:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
function openEdit(row) {
|
2026-09-19 07:50:21 +08:00
|
|
|
|
const spq = row.stationPlanQty || {}
|
2026-09-18 13:54:30 +08:00
|
|
|
|
Object.assign(dialog, {
|
|
|
|
|
|
show: true, id: row.id, orderNo: row.orderNo, planDate: row.planDate, planRange: [],
|
2026-09-22 11:32:29 +08:00
|
|
|
|
mode: 'AVG', planQty: row.planQty, productType: '', productCode: '', productName: '', woQty: '', stationPlanQty: spq, combination: []
|
2026-09-18 13:54:30 +08:00
|
|
|
|
})
|
|
|
|
|
|
loadWorkOrderInfo()
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 路线来源:优先行上 flowCombination,其次按工单号匹配工单
|
|
|
|
|
|
dialog.combination = (Array.isArray(row.flowCombination) && row.flowCombination.length)
|
|
|
|
|
|
? row.flowCombination
|
|
|
|
|
|
: dialog.combination
|
|
|
|
|
|
loadAlloc()
|
2026-08-29 15:30:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
async function save() {
|
2026-09-18 13:54:30 +08:00
|
|
|
|
if (!dialog.orderNo) return ElMessage.warning('请选择工单号')
|
|
|
|
|
|
if (dialog.id) {
|
2026-09-22 11:32:29 +08:00
|
|
|
|
// 编辑单条日排产:工位产量分配按工艺组合工位拆分
|
2026-09-19 07:50:21 +08:00
|
|
|
|
const spq = {}
|
2026-09-22 11:32:29 +08:00
|
|
|
|
allocStations.value.forEach((st) => {
|
2026-09-19 07:50:21 +08:00
|
|
|
|
if (alloc[st]) spq[String(st)] = Number(alloc[st]) || 0
|
|
|
|
|
|
})
|
2026-09-18 13:54:30 +08:00
|
|
|
|
if (!dialog.planDate) return ElMessage.warning('请选择排产日期')
|
|
|
|
|
|
await request.put(`/daily-plans/${dialog.id}`, {
|
2026-09-19 07:50:21 +08:00
|
|
|
|
id: dialog.id, orderNo: dialog.orderNo, planDate: dialog.planDate, planQty: dialog.planQty, stationPlanQty: spq
|
2026-09-18 13:54:30 +08:00
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 新建批量:按日期范围 + 模式生成多天日排产
|
|
|
|
|
|
if (!dialog.planRange || dialog.planRange.length !== 2 || !dialog.planRange[0] || !dialog.planRange[1])
|
|
|
|
|
|
return ElMessage.warning('请选择排产日期范围')
|
|
|
|
|
|
if (!dialog.planQty || dialog.planQty < 1) return ElMessage.warning('请填写数量')
|
|
|
|
|
|
await request.post('/daily-plans', {
|
2026-09-19 07:50:21 +08:00
|
|
|
|
orderNo: dialog.orderNo, planRange: dialog.planRange, mode: dialog.mode, planQty: dialog.planQty
|
2026-09-18 13:54:30 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-08-29 15:30:25 +08:00
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
|
dialog.show = false
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
2026-09-18 13:54:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 排产详情(只读,列表点「详情」打开)
|
|
|
|
|
|
const detail = reactive({ show: false, title: '排产详情', fields: [], row: null })
|
|
|
|
|
|
function openDetail(row) {
|
|
|
|
|
|
detail.fields = [
|
|
|
|
|
|
{ key: 'orderNo', label: '工单号' },
|
|
|
|
|
|
{ key: 'planDate', label: '排产日期' },
|
|
|
|
|
|
{ key: 'planQty', label: '计划数量' },
|
|
|
|
|
|
{ key: 'completedQty', label: '已完成' },
|
|
|
|
|
|
{ key: 'status', label: '执行状态', type: 'enum', map: statusOptions.reduce((m, x) => { m[x.v] = x.l; return m }, {}) },
|
|
|
|
|
|
{ key: 'operator', label: '操作人' }
|
|
|
|
|
|
]
|
|
|
|
|
|
detail.row = row
|
|
|
|
|
|
detail.show = true
|
|
|
|
|
|
}
|
2026-08-29 15:30:25 +08:00
|
|
|
|
async function del(row) {
|
|
|
|
|
|
await ElMessageBox.confirm('确认删除该排产?', '提示', { type: 'warning' })
|
|
|
|
|
|
await request.delete(`/daily-plans/${row.id}`)
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
2026-09-17 12:49:07 +08:00
|
|
|
|
// 启用(PENDING→CONFIRMED) / 停用(CONFIRMED→PENDING):自动排产生成的是 PENDING,需人工启用后才生效
|
|
|
|
|
|
async function toggleStatus(row) {
|
|
|
|
|
|
const target = row.status === 'CONFIRMED' ? 'PENDING' : 'CONFIRMED'
|
|
|
|
|
|
const label = target === 'CONFIRMED' ? '启用' : '停用'
|
|
|
|
|
|
await ElMessageBox.confirm(`确认${label}该排产(${row.orderNo} ${row.planDate})?`, '提示', { type: 'warning' })
|
|
|
|
|
|
await request.put(`/daily-plans/${row.id}`, {
|
2026-09-19 07:50:21 +08:00
|
|
|
|
orderNo: row.orderNo, planDate: row.planDate, planQty: row.planQty, status: target
|
2026-09-17 12:49:07 +08:00
|
|
|
|
})
|
|
|
|
|
|
ElMessage.success(`已${label}`)
|
|
|
|
|
|
load()
|
|
|
|
|
|
}
|
2026-08-29 15:30:25 +08:00
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
workOrders.value = (await request.get('/work-orders')) || []
|
2026-09-18 13:54:30 +08:00
|
|
|
|
productTypes.value = (await request.get('/product-types')) || []
|
2026-09-19 07:50:21 +08:00
|
|
|
|
await loadStations()
|
2026-08-29 15:30:25 +08:00
|
|
|
|
load()
|
|
|
|
|
|
})
|
2026-09-19 07:50:21 +08:00
|
|
|
|
</script>
|