✨ feat(mes): 添加工单完成功能,优化任务管理界面
parent
3d459b292f
commit
d49ba31f78
|
|
@ -1,281 +0,0 @@
|
||||||
<!-- MES 生产任务表单 -->
|
|
||||||
<!-- TODO @芋艿:晚点在 review -->
|
|
||||||
<!-- TODO @AI:融合到 /Users/yunai/Java/yudao-all-in-one/yudao-ui-admin-vue3/src/views/mes/pro/task/ProTaskList.vue;参考 /Users/yunai/Java/yudao-all-in-one/yudao-ui-admin-vue3/src/views/mes/wm/productionissue/ProductionIssueLineList.vue -->
|
|
||||||
<template>
|
|
||||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
|
||||||
<el-form
|
|
||||||
ref="formRef"
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
label-width="120px"
|
|
||||||
v-loading="formLoading"
|
|
||||||
>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="所属工单" prop="workOrderId">
|
|
||||||
<el-input :model-value="workOrderInfo" disabled />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="工序" prop="processId">
|
|
||||||
<el-select
|
|
||||||
v-model="formData.processId"
|
|
||||||
placeholder="请选择工序"
|
|
||||||
class="!w-1/1"
|
|
||||||
:disabled="isDetail"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in processList"
|
|
||||||
:key="item.processId"
|
|
||||||
:label="item.processName"
|
|
||||||
:value="item.processId"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="工作站" prop="workstationId">
|
|
||||||
<MdWorkstationSelect v-model="formData.workstationId" :disabled="isDetail" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="排产数量" prop="quantity">
|
|
||||||
<el-input-number
|
|
||||||
v-model="formData.quantity"
|
|
||||||
:min="0"
|
|
||||||
:precision="2"
|
|
||||||
class="!w-1/1"
|
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="开始时间" prop="startTime">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="formData.startTime"
|
|
||||||
type="datetime"
|
|
||||||
placeholder="请选择开始时间"
|
|
||||||
value-format="x"
|
|
||||||
class="!w-1/1"
|
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="生产时长(工作日)" prop="duration">
|
|
||||||
<el-input-number
|
|
||||||
v-model="formData.duration"
|
|
||||||
:min="1"
|
|
||||||
:precision="0"
|
|
||||||
class="!w-1/1"
|
|
||||||
:disabled="isDetail"
|
|
||||||
@change="computeEndTime"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="结束时间">
|
|
||||||
<el-date-picker
|
|
||||||
v-model="formData.endTime"
|
|
||||||
type="datetime"
|
|
||||||
disabled
|
|
||||||
value-format="x"
|
|
||||||
class="!w-1/1"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="甘特颜色" prop="colorCode">
|
|
||||||
<el-color-picker v-model="formData.colorCode" :disabled="isDetail" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row v-if="formType !== 'create'">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="任务状态">
|
|
||||||
<dict-tag :type="DICT_TYPE.MES_PRO_TASK_STATUS" :value="formData.status" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="备注" prop="remark">
|
|
||||||
<el-input
|
|
||||||
type="textarea"
|
|
||||||
v-model="formData.remark"
|
|
||||||
placeholder="请输入备注"
|
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer v-if="!isDetail">
|
|
||||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
||||||
</template>
|
|
||||||
</Dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
|
||||||
import { ProTaskApi, ProTaskVO } from '@/api/mes/pro/task'
|
|
||||||
import { ProRouteProcessVO } from '@/api/mes/pro/route/process'
|
|
||||||
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
|
||||||
|
|
||||||
defineOptions({ name: 'ProTaskForm' })
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const message = useMessage()
|
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const dialogTitle = ref('')
|
|
||||||
const formLoading = ref(false)
|
|
||||||
const formType = ref('')
|
|
||||||
|
|
||||||
const formData = ref({
|
|
||||||
id: undefined,
|
|
||||||
workOrderId: undefined,
|
|
||||||
workstationId: undefined,
|
|
||||||
routeId: undefined,
|
|
||||||
processId: undefined,
|
|
||||||
itemId: undefined,
|
|
||||||
unitMeasureId: undefined,
|
|
||||||
quantity: undefined,
|
|
||||||
startTime: undefined,
|
|
||||||
duration: 1,
|
|
||||||
endTime: undefined,
|
|
||||||
colorCode: '#00AEF3',
|
|
||||||
status: undefined,
|
|
||||||
remark: undefined
|
|
||||||
})
|
|
||||||
|
|
||||||
const formRules = reactive({
|
|
||||||
workstationId: [{ required: true, message: '工作站不能为空', trigger: 'change' }],
|
|
||||||
processId: [{ required: true, message: '工序不能为空', trigger: 'change' }],
|
|
||||||
quantity: [{ required: true, message: '排产数量不能为空', trigger: 'blur' }],
|
|
||||||
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'change' }],
|
|
||||||
duration: [{ required: true, message: '生产时长不能为空', trigger: 'blur' }]
|
|
||||||
})
|
|
||||||
const formRef = ref()
|
|
||||||
|
|
||||||
/** 工单信息(只读展示) */
|
|
||||||
const workOrderInfo = ref('')
|
|
||||||
/** 工序列表(从工艺路线工序加载) */
|
|
||||||
const processList = ref<ProRouteProcessVO[]>([])
|
|
||||||
|
|
||||||
const isDetail = computed(() => formType.value === 'detail')
|
|
||||||
|
|
||||||
/** 自动计算结束时间:startTime + duration * 8h */
|
|
||||||
const computeEndTime = () => {
|
|
||||||
if (formData.value.startTime && formData.value.duration) {
|
|
||||||
const start =
|
|
||||||
typeof formData.value.startTime === 'number'
|
|
||||||
? formData.value.startTime
|
|
||||||
: new Date(formData.value.startTime).getTime()
|
|
||||||
formData.value.endTime = start + formData.value.duration * 8 * 3600 * 1000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听开始时间变化也重新计算
|
|
||||||
watch(
|
|
||||||
() => formData.value.startTime,
|
|
||||||
() => computeEndTime()
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 打开弹窗 */
|
|
||||||
const open = async (
|
|
||||||
type: string,
|
|
||||||
params: {
|
|
||||||
id?: number
|
|
||||||
workOrderId?: number
|
|
||||||
workOrderCode?: string
|
|
||||||
workOrderName?: string
|
|
||||||
routeId?: number
|
|
||||||
processId?: number
|
|
||||||
itemId?: number
|
|
||||||
unitMeasureId?: number
|
|
||||||
processList?: ProRouteProcessVO[]
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
dialogVisible.value = true
|
|
||||||
dialogTitle.value = type === 'detail' ? '任务详情' : t('action.' + type)
|
|
||||||
formType.value = type
|
|
||||||
resetForm()
|
|
||||||
|
|
||||||
// 设置工序列表
|
|
||||||
if (params.processList) {
|
|
||||||
processList.value = params.processList
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type === 'create') {
|
|
||||||
// 新增时预填工单信息
|
|
||||||
formData.value.workOrderId = params.workOrderId
|
|
||||||
formData.value.routeId = params.routeId
|
|
||||||
formData.value.processId = params.processId
|
|
||||||
formData.value.itemId = params.itemId
|
|
||||||
formData.value.unitMeasureId = params.unitMeasureId
|
|
||||||
workOrderInfo.value = `${params.workOrderCode || ''} ${params.workOrderName || ''}`
|
|
||||||
} else if (params.id) {
|
|
||||||
// 编辑/详情
|
|
||||||
formLoading.value = true
|
|
||||||
try {
|
|
||||||
const data = await ProTaskApi.getTask(params.id)
|
|
||||||
formData.value = data
|
|
||||||
workOrderInfo.value = `${data.workOrderCode || ''} ${data.workOrderName || ''}`
|
|
||||||
} finally {
|
|
||||||
formLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ open })
|
|
||||||
|
|
||||||
/** 提交表单 */
|
|
||||||
const emit = defineEmits(['success'])
|
|
||||||
const submitForm = async () => {
|
|
||||||
await formRef.value.validate()
|
|
||||||
formLoading.value = true
|
|
||||||
try {
|
|
||||||
const data = formData.value as unknown as ProTaskVO
|
|
||||||
if (formType.value === 'create') {
|
|
||||||
await ProTaskApi.createTask(data)
|
|
||||||
message.success(t('common.createSuccess'))
|
|
||||||
} else {
|
|
||||||
await ProTaskApi.updateTask(data)
|
|
||||||
message.success(t('common.updateSuccess'))
|
|
||||||
}
|
|
||||||
dialogVisible.value = false
|
|
||||||
emit('success')
|
|
||||||
} finally {
|
|
||||||
formLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重置表单 */
|
|
||||||
const resetForm = () => {
|
|
||||||
formData.value = {
|
|
||||||
id: undefined,
|
|
||||||
workOrderId: undefined,
|
|
||||||
workstationId: undefined,
|
|
||||||
routeId: undefined,
|
|
||||||
processId: undefined,
|
|
||||||
itemId: undefined,
|
|
||||||
unitMeasureId: undefined,
|
|
||||||
quantity: undefined,
|
|
||||||
startTime: undefined,
|
|
||||||
duration: 1,
|
|
||||||
endTime: undefined,
|
|
||||||
colorCode: '#00AEF3',
|
|
||||||
status: undefined,
|
|
||||||
remark: undefined
|
|
||||||
}
|
|
||||||
formRef.value?.resetFields()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
<!-- MES 生产任务投料列表 -->
|
|
||||||
<!-- TODO @芋艿:待 review -->
|
|
||||||
<!-- TODO @芋艿:投料记录依赖仓库模块的领料出库单(wm_issue),当前仓库模块未迁移,先展示列表 -->
|
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
||||||
<el-table-column label="物料编码" align="center" prop="itemCode" width="120" />
|
|
||||||
<el-table-column label="物料名称" align="center" prop="itemName" min-width="150" />
|
|
||||||
<el-table-column label="规格" align="center" prop="itemSpec" width="120" />
|
|
||||||
<el-table-column label="单位" align="center" prop="unitMeasureName" width="80" />
|
|
||||||
<el-table-column label="来源单据编码" align="center" prop="sourceDocCode" width="140" />
|
|
||||||
<el-table-column label="来源类型" align="center" prop="sourceDocType" width="100" />
|
|
||||||
<el-table-column label="批次" align="center" prop="batchCode" width="120" />
|
|
||||||
<el-table-column label="投料数量" align="center" prop="issuedQuantity" width="100" />
|
|
||||||
<el-table-column label="可用数量" align="center" prop="availableQuantity" width="100" />
|
|
||||||
<el-table-column label="已用数量" align="center" prop="usedQuantity" width="100" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ProTaskIssueApi, ProTaskIssueVO } from '@/api/mes/pro/task/issue'
|
|
||||||
|
|
||||||
defineOptions({ name: 'ProTaskIssueList' })
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
taskId: number
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const list = ref<ProTaskIssueVO[]>([])
|
|
||||||
|
|
||||||
/** 查询投料列表 */
|
|
||||||
const getList = async () => {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
list.value = await ProTaskIssueApi.getTaskIssueListByTask(props.taskId)
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.taskId,
|
|
||||||
() => getList()
|
|
||||||
)
|
|
||||||
|
|
||||||
onMounted(() => getList())
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<!-- MES 生产任务列表(工单维度,排产 Drawer 内使用) -->
|
<!-- MES 生产任务列表(工单维度,排产对话框内使用) -->
|
||||||
<!-- TODO @芋艿:待 review -->
|
<!-- TODO @芋艿:待 review -->
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
@click="handleAdd"
|
@click="openForm('create')"
|
||||||
v-hasPermi="['mes:pro-task:create']"
|
v-hasPermi="['mes:pro-task:create']"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
>
|
>
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleEdit(scope.row)"
|
@click="openForm('update', scope.row.id)"
|
||||||
v-hasPermi="['mes:pro-task:update']"
|
v-hasPermi="['mes:pro-task:update']"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
|
|
@ -135,7 +135,7 @@
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleDetail(scope.row)"
|
@click="openForm('detail', scope.row.id)"
|
||||||
v-hasPermi="['mes:pro-task:query']"
|
v-hasPermi="['mes:pro-task:query']"
|
||||||
>
|
>
|
||||||
详情
|
详情
|
||||||
|
|
@ -143,10 +143,128 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<!-- 任务表单 -->
|
|
||||||
<ProTaskForm ref="formRef" @success="getList" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加/编辑/详情任务弹窗 -->
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="所属工单" prop="workOrderId">
|
||||||
|
<el-input :model-value="workOrderInfo" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="工序" prop="processId">
|
||||||
|
<el-select
|
||||||
|
v-model="formData.processId"
|
||||||
|
placeholder="请选择工序"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isDetail"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in props.processList"
|
||||||
|
:key="item.processId"
|
||||||
|
:label="item.processName"
|
||||||
|
:value="item.processId"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="工作站" prop="workstationId">
|
||||||
|
<MdWorkstationSelect v-model="formData.workstationId" :disabled="isDetail" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="排产数量" prop="quantity">
|
||||||
|
<el-input-number
|
||||||
|
v-model="formData.quantity"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isDetail"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="开始时间" prop="startTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="formData.startTime"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="请选择开始时间"
|
||||||
|
value-format="x"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isDetail"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="生产时长(工作日)" prop="duration">
|
||||||
|
<el-input-number
|
||||||
|
v-model="formData.duration"
|
||||||
|
:min="1"
|
||||||
|
:precision="0"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isDetail"
|
||||||
|
@change="computeEndTime"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="结束时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="formData.endTime"
|
||||||
|
type="datetime"
|
||||||
|
disabled
|
||||||
|
value-format="x"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="甘特颜色" prop="colorCode">
|
||||||
|
<el-color-picker v-model="formData.colorCode" :disabled="isDetail" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row v-if="taskFormType !== 'create'">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="任务状态">
|
||||||
|
<dict-tag :type="DICT_TYPE.MES_PRO_TASK_STATUS" :value="formData.status" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
type="textarea"
|
||||||
|
v-model="formData.remark"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
:disabled="isDetail"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer v-if="!isDetail">
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -155,7 +273,7 @@ import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { ProTaskApi, ProTaskVO } from '@/api/mes/pro/task'
|
import { ProTaskApi, ProTaskVO } from '@/api/mes/pro/task'
|
||||||
import { ProRouteProcessVO } from '@/api/mes/pro/route/process'
|
import { ProRouteProcessVO } from '@/api/mes/pro/route/process'
|
||||||
import { MesProTaskStatusEnum } from '@/views/mes/utils/constants'
|
import { MesProTaskStatusEnum } from '@/views/mes/utils/constants'
|
||||||
import ProTaskForm from './ProTaskForm.vue'
|
import MdWorkstationSelect from '@/views/mes/md/workstation/components/MdWorkstationSelect.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'ProTaskList' })
|
defineOptions({ name: 'ProTaskList' })
|
||||||
|
|
||||||
|
|
@ -174,6 +292,7 @@ const props = defineProps<{
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
|
// ==================== 列表 ====================
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const list = ref<ProTaskVO[]>([])
|
const list = ref<ProTaskVO[]>([])
|
||||||
|
|
||||||
|
|
@ -193,40 +312,6 @@ const getList = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新增任务 */
|
|
||||||
const formRef = ref()
|
|
||||||
const handleAdd = () => {
|
|
||||||
formRef.value.open('create', {
|
|
||||||
workOrderId: props.workOrderId,
|
|
||||||
workOrderCode: props.workOrderCode,
|
|
||||||
workOrderName: props.workOrderName,
|
|
||||||
routeId: props.routeId,
|
|
||||||
processId: props.processId,
|
|
||||||
itemId: props.itemId,
|
|
||||||
unitMeasureId: props.unitMeasureId,
|
|
||||||
processList: props.processList
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑任务 */
|
|
||||||
const handleEdit = (row: any) => {
|
|
||||||
formRef.value.open('update', {
|
|
||||||
id: row.id,
|
|
||||||
workOrderId: props.workOrderId,
|
|
||||||
workOrderCode: props.workOrderCode,
|
|
||||||
workOrderName: props.workOrderName,
|
|
||||||
processList: props.processList
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查看详情 */
|
|
||||||
const handleDetail = (row: any) => {
|
|
||||||
formRef.value.open('detail', {
|
|
||||||
id: row.id,
|
|
||||||
processList: props.processList
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除任务 */
|
/** 删除任务 */
|
||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -247,6 +332,127 @@ const handleChangeStatus = async (id: number, status: number, actionName: string
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 添加/编辑/详情表单 ====================
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const dialogTitle = ref('')
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const taskFormType = ref('')
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
workOrderId: undefined,
|
||||||
|
workstationId: undefined,
|
||||||
|
routeId: undefined,
|
||||||
|
processId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
unitMeasureId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
duration: 1,
|
||||||
|
endTime: undefined,
|
||||||
|
colorCode: '#00AEF3',
|
||||||
|
status: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
workstationId: [{ required: true, message: '工作站不能为空', trigger: 'change' }],
|
||||||
|
processId: [{ required: true, message: '工序不能为空', trigger: 'change' }],
|
||||||
|
quantity: [{ required: true, message: '排产数量不能为空', trigger: 'blur' }],
|
||||||
|
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'change' }],
|
||||||
|
duration: [{ required: true, message: '生产时长不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
/** 工单信息(只读展示) */
|
||||||
|
const workOrderInfo = ref('')
|
||||||
|
|
||||||
|
const isDetail = computed(() => taskFormType.value === 'detail')
|
||||||
|
|
||||||
|
/** 自动计算结束时间:startTime + duration * 8h */
|
||||||
|
const computeEndTime = () => {
|
||||||
|
if (formData.value.startTime && formData.value.duration) {
|
||||||
|
const start =
|
||||||
|
typeof formData.value.startTime === 'number'
|
||||||
|
? formData.value.startTime
|
||||||
|
: new Date(formData.value.startTime).getTime()
|
||||||
|
formData.value.endTime = start + formData.value.duration * 8 * 3600 * 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听开始时间变化也重新计算
|
||||||
|
watch(
|
||||||
|
() => formData.value.startTime,
|
||||||
|
() => computeEndTime()
|
||||||
|
)
|
||||||
|
|
||||||
|
/** 打开表单弹窗 */
|
||||||
|
const openForm = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = type === 'detail' ? '任务详情' : type === 'create' ? '新增任务' : '编辑任务'
|
||||||
|
taskFormType.value = type
|
||||||
|
resetForm()
|
||||||
|
|
||||||
|
if (type === 'create') {
|
||||||
|
// 新增时预填工单信息
|
||||||
|
formData.value.workOrderId = props.workOrderId
|
||||||
|
formData.value.routeId = props.routeId
|
||||||
|
formData.value.processId = props.processId
|
||||||
|
formData.value.itemId = props.itemId
|
||||||
|
formData.value.unitMeasureId = props.unitMeasureId
|
||||||
|
workOrderInfo.value = `${props.workOrderCode || ''} ${props.workOrderName || ''}`
|
||||||
|
} else if (id) {
|
||||||
|
// 编辑/详情:加载任务数据
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = await ProTaskApi.getTask(id)
|
||||||
|
formData.value = data
|
||||||
|
workOrderInfo.value = `${data.workOrderCode || ''} ${data.workOrderName || ''}`
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as ProTaskVO
|
||||||
|
if (taskFormType.value === 'create') {
|
||||||
|
await ProTaskApi.createTask(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await ProTaskApi.updateTask(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await getList()
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
workOrderId: undefined,
|
||||||
|
workstationId: undefined,
|
||||||
|
routeId: undefined,
|
||||||
|
processId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
unitMeasureId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
startTime: undefined,
|
||||||
|
duration: 1,
|
||||||
|
endTime: undefined,
|
||||||
|
colorCode: '#00AEF3',
|
||||||
|
status: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
// 监听 processId 切换重新加载
|
// 监听 processId 切换重新加载
|
||||||
watch(
|
watch(
|
||||||
() => props.processId,
|
() => props.processId,
|
||||||
|
|
|
||||||
|
|
@ -111,29 +111,27 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<!-- TODO @AI:都展示,不只 isSchedule -->
|
<!-- 工序步骤导航 -->
|
||||||
<!-- 工序步骤导航(仅排产模式显示) -->
|
|
||||||
<el-steps
|
<el-steps
|
||||||
v-if="isSchedule && routeProcessList.length && formData.id"
|
v-if="routeProcessList.length && formData.id"
|
||||||
:active="activeProcessStep"
|
:active="activeProcessStep"
|
||||||
align-center
|
align-center
|
||||||
simple
|
simple
|
||||||
class="my-10px"
|
class="my-10px"
|
||||||
>
|
>
|
||||||
<!-- TODO @AI:style 改成 unocss -->
|
|
||||||
<el-step
|
<el-step
|
||||||
v-for="(rp, index) in routeProcessList"
|
v-for="(rp, index) in routeProcessList"
|
||||||
:key="rp.processId"
|
:key="rp.processId"
|
||||||
:title="rp.processName"
|
:title="rp.processName"
|
||||||
style="cursor: pointer"
|
class="cursor-pointer"
|
||||||
@click="activeProcessStep = index"
|
@click="activeProcessStep = index"
|
||||||
/>
|
/>
|
||||||
</el-steps>
|
</el-steps>
|
||||||
|
|
||||||
<!-- 当前工序的任务列表(仅排产模式显示) -->
|
<!-- 当前工序的任务列表 -->
|
||||||
<el-card
|
<el-card
|
||||||
v-for="(rp, index) in routeProcessList"
|
v-for="(rp, index) in routeProcessList"
|
||||||
v-show="isSchedule && activeProcessStep === index && formData.id"
|
v-show="activeProcessStep === index && formData.id"
|
||||||
:key="rp.processId"
|
:key="rp.processId"
|
||||||
shadow="never"
|
shadow="never"
|
||||||
>
|
>
|
||||||
|
|
@ -148,16 +146,7 @@
|
||||||
:process-list="routeProcessList"
|
:process-list="routeProcessList"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
<!-- TODO @AI:完成拿到 index.vue 里;这里不放 -->
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<!-- TODO @芋艿:完成排产的逻辑,需要后端提供对应接口 -->
|
|
||||||
<el-button
|
|
||||||
v-if="isSchedule && formData.status === MesProWorkOrderStatusEnum.CONFIRMED && formData.id"
|
|
||||||
type="success"
|
|
||||||
@click="handleFinish"
|
|
||||||
>
|
|
||||||
完成
|
|
||||||
</el-button>
|
|
||||||
<el-button @click="dialogVisible = false">关 闭</el-button>
|
<el-button @click="dialogVisible = false">关 闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
@ -170,36 +159,25 @@ import { ProRouteProcessApi, ProRouteProcessVO } from '@/api/mes/pro/route/proce
|
||||||
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
import MdClientSelect from '@/views/mes/md/client/components/MdClientSelect.vue'
|
import MdClientSelect from '@/views/mes/md/client/components/MdClientSelect.vue'
|
||||||
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
||||||
import {
|
import { MesProWorkOrderSourceTypeEnum, MesProWorkOrderTypeEnum } from '@/views/mes/utils/constants'
|
||||||
MesProWorkOrderSourceTypeEnum,
|
|
||||||
MesProWorkOrderTypeEnum,
|
|
||||||
MesProWorkOrderStatusEnum
|
|
||||||
} from '@/views/mes/utils/constants'
|
|
||||||
import ProTaskList from './ProTaskList.vue'
|
import ProTaskList from './ProTaskList.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'WorkOrderForm2' })
|
defineOptions({ name: 'WorkOrderForm2' })
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const message = useMessage() // 消息弹窗
|
||||||
const dialogTitle = ref('')
|
|
||||||
const formLoading = ref(false)
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const formType = ref('') // 'detail' - 详情;'schedule' - 排产
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中
|
||||||
|
const formType = ref('') // 表单的类型:detail - 详情;schedule - 排产
|
||||||
const formData = ref<any>({})
|
const formData = ref<any>({})
|
||||||
const formRef = ref()
|
const formRef = ref() // 表单 Ref
|
||||||
|
|
||||||
/** 是否为排产模式 */
|
const routeProcessList = ref<ProRouteProcessVO[]>([]) // 工艺路线工序列表
|
||||||
const isSchedule = computed(() => formType.value === 'schedule')
|
const activeProcessStep = ref(0) // 当前工序步骤索引
|
||||||
|
const currentRouteId = ref(0) // 当前工艺路线编号
|
||||||
|
|
||||||
// ==================== 工序步骤 ====================
|
/** 打开弹窗 */
|
||||||
const routeProcessList = ref<ProRouteProcessVO[]>([])
|
|
||||||
const activeProcessStep = ref(0)
|
|
||||||
const currentRouteId = ref(0)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开对话框
|
|
||||||
*
|
|
||||||
* @param type 'detail' - 工单详情;'schedule' - 生产排产
|
|
||||||
* @param id 工单 ID
|
|
||||||
*/
|
|
||||||
const open = async (type: string, id: number) => {
|
const open = async (type: string, id: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = type === 'schedule' ? '生产排产' : '工单详情'
|
dialogTitle.value = type === 'schedule' ? '生产排产' : '工单详情'
|
||||||
|
|
@ -208,11 +186,9 @@ const open = async (type: string, id: number) => {
|
||||||
formData.value = {}
|
formData.value = {}
|
||||||
routeProcessList.value = []
|
routeProcessList.value = []
|
||||||
activeProcessStep.value = 0
|
activeProcessStep.value = 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 加载工单详情
|
// 加载工单详情
|
||||||
formData.value = await ProWorkOrderApi.getWorkOrder(id)
|
formData.value = await ProWorkOrderApi.getWorkOrder(id)
|
||||||
|
|
||||||
// 加载工艺路线工序列表
|
// 加载工艺路线工序列表
|
||||||
if (formData.value.productId) {
|
if (formData.value.productId) {
|
||||||
await loadRouteProcesses(formData.value.productId)
|
await loadRouteProcesses(formData.value.productId)
|
||||||
|
|
@ -221,33 +197,20 @@ const open = async (type: string, id: number) => {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
/** 加载工艺路线工序列表(通过产品查找关联的工艺路线) */
|
/** 加载工艺路线工序列表 */
|
||||||
const message = useMessage()
|
|
||||||
const loadRouteProcesses = async (productId: number) => {
|
const loadRouteProcesses = async (productId: number) => {
|
||||||
try {
|
try {
|
||||||
const processes = await ProRouteProcessApi.getRouteProcessListByProduct(productId)
|
const processes = await ProRouteProcessApi.getRouteProcessListByProduct(productId)
|
||||||
if (processes && processes.length > 0) {
|
if (!processes || processes.length === 0) {
|
||||||
currentRouteId.value = processes[0].routeId
|
|
||||||
routeProcessList.value = processes.sort((a: any, b: any) => a.sort - b.sort)
|
|
||||||
} else {
|
|
||||||
message.warning('当前产品未配置工艺路线,请先在工艺路线中维护')
|
message.warning('当前产品未配置工艺路线,请先在工艺路线中维护')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
currentRouteId.value = processes[0].routeId
|
||||||
|
routeProcessList.value = processes.sort((a: any, b: any) => a.sort - b.sort)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('加载工艺路线工序失败', e)
|
console.warn('加载工艺路线工序失败', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 完成排产(对齐 KTG 的 handleFinish) */
|
|
||||||
const handleFinish = async () => {
|
|
||||||
try {
|
|
||||||
await message.confirm('是否完成工单排产?【完成后将不能更改】')
|
|
||||||
// TODO @芋艿:调用后端接口,更新工单状态为已完成
|
|
||||||
// await ProWorkOrderApi.updateWorkOrderStatus(formData.value.id, MesProWorkOrderStatusEnum.FINISHED)
|
|
||||||
message.success('排产完成')
|
|
||||||
dialogVisible.value = false
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ open })
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,15 @@
|
||||||
>
|
>
|
||||||
排产
|
排产
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="scope.row.status === MesProWorkOrderStatusEnum.CONFIRMED"
|
||||||
|
link
|
||||||
|
type="success"
|
||||||
|
@click="handleFinish(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:pro-task:update']"
|
||||||
|
>
|
||||||
|
完成
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -161,6 +170,7 @@ import WorkOrderForm2 from './WorkOrderForm2.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'MesProTask' })
|
defineOptions({ name: 'MesProTask' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
const loading = ref(true) // 列表加载状态
|
const loading = ref(true) // 列表加载状态
|
||||||
const workOrderList = ref<ProWorkOrderVO[]>([]) // 工单列表数据
|
const workOrderList = ref<ProWorkOrderVO[]>([]) // 工单列表数据
|
||||||
const total = ref(0) // 总条数
|
const total = ref(0) // 总条数
|
||||||
|
|
@ -226,6 +236,16 @@ const openForm = (type: string, id: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 完成工单 */
|
||||||
|
const handleFinish = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认要完成该工单吗?')
|
||||||
|
await ProWorkOrderApi.finishWorkOrder(id)
|
||||||
|
message.success('工单已完成')
|
||||||
|
await getWorkOrderList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO @芋艿:后续可以考虑把甘特图预览和编辑合并成一个组件,统一管理甘特图数据和刷新逻辑;
|
// TODO @芋艿:后续可以考虑把甘特图预览和编辑合并成一个组件,统一管理甘特图数据和刷新逻辑;
|
||||||
/** 打开甘特图编辑弹窗 */
|
/** 打开甘特图编辑弹窗 */
|
||||||
const ganttEditRef = ref()
|
const ganttEditRef = ref()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue