feat(mes): 新增查看模式下的只读功能及相关按钮逻辑

pull/871/MERGE
YunaiV 2026-04-02 00:34:22 +08:00
parent f133e4f5c5
commit 71c7d498f1
4 changed files with 49 additions and 27 deletions

View File

@ -6,6 +6,7 @@
:rules="formRules" :rules="formRules"
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
:disabled="formType === 'detail'"
> >
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
@ -111,27 +112,32 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<!-- 编辑时显示子资源 Tab --> <!-- 编辑/查看时显示子资源 Tab -->
<el-tabs v-if="formType === 'update'" v-model="activeTab" class="mt-10px"> <el-tabs v-if="formType === 'update' || formType === 'detail'" v-model="activeTab" class="mt-10px">
<el-tab-pane label="班次" name="shift"> <el-tab-pane label="班次" name="shift">
<CalShiftList :plan-id="formData.id!" /> <CalShiftList :plan-id="formData.id!" :readonly="formType === 'detail'" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="班组" name="team"> <el-tab-pane label="班组" name="team">
<CalPlanTeamList :plan-id="formData.id!" /> <CalPlanTeamList :plan-id="formData.id!" :readonly="formType === 'detail'" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<template #footer> <template #footer>
<!-- 确认按钮仅草稿状态显示 --> <template v-if="formType !== 'detail'">
<el-button <!-- 确认按钮仅草稿状态显示 -->
v-if="formType === 'update' && formData.status === MesCalPlanStatusEnum.PREPARE" <el-button
type="warning" v-if="formType === 'update' && formData.status === MesCalPlanStatusEnum.PREPARE"
@click="handleConfirm" type="warning"
:disabled="formLoading" @click="handleConfirm"
> :disabled="formLoading"
确认计划 >
</el-button> 确认计划
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button> </el-button>
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
<template v-else>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</template> </template>
</Dialog> </Dialog>
</template> </template>
@ -148,6 +154,7 @@ import {
import CalShiftList from './CalShiftList.vue' import CalShiftList from './CalShiftList.vue'
import CalPlanTeamList from './CalPlanTeamList.vue' import CalPlanTeamList from './CalPlanTeamList.vue'
// TODO @AIisDetail compute
defineOptions({ name: 'CalPlanForm' }) defineOptions({ name: 'CalPlanForm' })
const { t } = useI18n() // const { t } = useI18n() //
@ -174,23 +181,27 @@ const formData = ref({
const formRules = reactive({ const formRules = reactive({
code: [{ required: true, message: '计划编码不能为空', trigger: 'blur' }], code: [{ required: true, message: '计划编码不能为空', trigger: 'blur' }],
name: [{ required: true, message: '计划名称不能为空', trigger: 'blur' }], name: [{ required: true, message: '计划名称不能为空', trigger: 'blur' }],
calendarType: [{ required: true, message: '班组类型不能为空', trigger: 'change' }],
startDate: [{ required: true, message: '开始日期不能为空', trigger: 'change' }], startDate: [{ required: true, message: '开始日期不能为空', trigger: 'change' }],
endDate: [{ required: true, message: '结束日期不能为空', trigger: 'change' }] endDate: [{ required: true, message: '结束日期不能为空', trigger: 'change' }],
shiftType: [{ required: true, message: '轮班方式不能为空', trigger: 'change' }]
}) })
const formRef = ref() const formRef = ref()
/** 生成计划编码 */ /** 生成计划编码 */
const generateCode = () => { const generateCode = () => {
// TODO @AI
formData.value.code = 'PLAN' + generateRandomStr(8) formData.value.code = 'PLAN' + generateRandomStr(8)
} }
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = t('action.' + type) // TODO @AIdialogtitle compute
dialogTitle.value = type === 'detail' ? '查看' : t('action.' + type)
formType.value = type formType.value = type
resetForm() resetForm()
// // /
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
@ -223,11 +234,16 @@ const submitForm = async () => {
} }
} }
/** 确认计划 */ /** 确认计划(先自动保存再确认) */
const handleConfirm = async () => { const handleConfirm = async () => {
try { try {
await message.confirm('确认该排班计划?确认后将不可修改或删除。') // 1.
await formRef.value.validate()
formLoading.value = true formLoading.value = true
const data = formData.value as unknown as CalPlanVO
await CalPlanApi.updatePlan(data)
// 2.
await message.confirm('确认该排班计划?确认后将不可修改或删除。')
await CalPlanApi.confirmPlan(formData.value.id!) await CalPlanApi.confirmPlan(formData.value.id!)
message.success('确认成功') message.success('确认成功')
dialogVisible.value = false dialogVisible.value = false

View File

@ -2,10 +2,18 @@
<template> <template>
<div> <div>
<!-- 操作栏 --> <!-- 操作栏 -->
<el-button v-if="!readonly" type="primary" plain size="small" @click="openForm('create')" class="mb-10px"> <el-button
v-if="!readonly"
type="primary"
plain
size="small"
@click="openForm('create')"
class="mb-10px"
>
<Icon icon="ep:plus" class="mr-5px" /> 添加班组 <Icon icon="ep:plus" class="mr-5px" /> 添加班组
</el-button> </el-button>
<!-- 列表 --> <!-- 列表 -->
<!-- TODO @AI左边班组 -->
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
<el-table-column label="班组编号" align="center" prop="teamId" width="120" /> <el-table-column label="班组编号" align="center" prop="teamId" width="120" />
<el-table-column label="班组编码" align="center" prop="teamCode" min-width="120" /> <el-table-column label="班组编码" align="center" prop="teamCode" min-width="120" />
@ -17,6 +25,7 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- TODO @AI右边成员 -->
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<Dialog :title="dialogTitle" v-model="dialogVisible" width="500px"> <Dialog :title="dialogTitle" v-model="dialogVisible" width="500px">

View File

@ -40,7 +40,6 @@
<el-form-item label="班次名称" prop="name"> <el-form-item label="班次名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入班次名称" /> <el-input v-model="formData.name" placeholder="请输入班次名称" />
</el-form-item> </el-form-item>
<!-- TODO @芋艿这块要测试下 -->
<el-form-item label="开始时间" prop="startTime"> <el-form-item label="开始时间" prop="startTime">
<el-time-picker <el-time-picker
v-model="formData.startTime" v-model="formData.startTime"

View File

@ -1,6 +1,7 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<!-- TODO @AI开始时间结束时间 -->
<el-form <el-form
class="-mb-15px" class="-mb-15px"
:model="queryParams" :model="queryParams"
@ -86,6 +87,7 @@
<dict-tag :type="DICT_TYPE.MES_CAL_CALENDAR_TYPE" :value="scope.row.calendarType" /> <dict-tag :type="DICT_TYPE.MES_CAL_CALENDAR_TYPE" :value="scope.row.calendarType" />
</template> </template>
</el-table-column> </el-table-column>
<!-- TODO @AIdateFormatter2dateFormatter2 -->
<el-table-column <el-table-column
label="开始日期" label="开始日期"
align="center" align="center"
@ -124,11 +126,7 @@
/> />
<el-table-column label="操作" align="center" width="150"> <el-table-column label="操作" align="center" width="150">
<template #default="scope"> <template #default="scope">
<el-button <el-button link type="primary" @click="openForm('detail', scope.row.id)">
link
type="primary"
@click="openForm('detail', scope.row.id)"
>
查看 查看
</el-button> </el-button>
<el-button <el-button