✨ feat(mes): 优化点检方案表单及子资源列表的编辑逻辑
调整点检方案表单,简化字段的禁用逻辑,确保在编辑模式下可以生成方案编码。更新子资源列表组件,基于表单类型动态控制操作权限,提升用户体验。pull/871/MERGE
parent
476dd53a3c
commit
e035774e38
|
|
@ -1,19 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
<!-- TODO @AI:disabled 是不是全局 form?别的模块是这么干的。 -->
|
|
||||||
<el-form
|
<el-form
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
:model="formData"
|
:model="formData"
|
||||||
:rules="formRules"
|
:rules="formRules"
|
||||||
label-width="100px"
|
label-width="100px"
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
|
:disabled="isDetail"
|
||||||
>
|
>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="方案编码" prop="code">
|
<el-form-item label="方案编码" prop="code">
|
||||||
<el-input v-model="formData.code" placeholder="请输入方案编码" :disabled="isDetail">
|
<el-input v-model="formData.code" placeholder="请输入方案编码">
|
||||||
<!-- TODO @AI:对齐别的模块,看看 isDetail 要不要保留生成按钮; -->
|
<template #append>
|
||||||
<template v-if="!isDetail" #append>
|
|
||||||
<el-button @click="generateCode"> 生成 </el-button>
|
<el-button @click="generateCode"> 生成 </el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
|
|
@ -21,7 +20,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="方案名称" prop="name">
|
<el-form-item label="方案名称" prop="name">
|
||||||
<el-input v-model="formData.name" placeholder="请输入方案名称" :disabled="isDetail" />
|
<el-input v-model="formData.name" placeholder="请输入方案名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
|
|
@ -30,7 +29,6 @@
|
||||||
v-model="formData.type"
|
v-model="formData.type"
|
||||||
placeholder="请选择方案类型"
|
placeholder="请选择方案类型"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
:disabled="isDetail"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getIntDictOptions(DICT_TYPE.MES_DV_SUBJECT_TYPE)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_DV_SUBJECT_TYPE)"
|
||||||
|
|
@ -50,7 +48,6 @@
|
||||||
:min="1"
|
:min="1"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
@ -60,7 +57,6 @@
|
||||||
v-model="formData.cycleType"
|
v-model="formData.cycleType"
|
||||||
placeholder="请选择周期类型"
|
placeholder="请选择周期类型"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
:disabled="isDetail"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in getIntDictOptions(DICT_TYPE.MES_DV_CYCLE_TYPE)"
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_DV_CYCLE_TYPE)"
|
||||||
|
|
@ -86,7 +82,6 @@
|
||||||
value-format="x"
|
value-format="x"
|
||||||
placeholder="请选择开始日期"
|
placeholder="请选择开始日期"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
@ -98,7 +93,6 @@
|
||||||
value-format="x"
|
value-format="x"
|
||||||
placeholder="请选择结束日期"
|
placeholder="请选择结束日期"
|
||||||
class="!w-1/1"
|
class="!w-1/1"
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
@ -110,24 +104,18 @@
|
||||||
v-model="formData.remark"
|
v-model="formData.remark"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
placeholder="请输入备注"
|
placeholder="请输入备注"
|
||||||
:disabled="isDetail"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<!-- 编辑/查看时显示子资源 Tab -->
|
<!-- 编辑/查看时显示子资源 Tab -->
|
||||||
<!-- todo @AI:formtype 的处理;isXXX 这种 compute 计算; -->
|
<el-tabs v-if="formData.id" 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="machinery">
|
<el-tab-pane label="设备清单" name="machinery">
|
||||||
<CheckPlanMachineryList :plan-id="formData.id!" :readonly="isDetail" />
|
<CheckPlanMachineryList :plan-id="formData.id!" :form-type="formType" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="保养项目" name="subject">
|
<el-tab-pane label="保养项目" name="subject">
|
||||||
<CheckPlanSubjectList :plan-id="formData.id!" :readonly="isDetail" />
|
<CheckPlanSubjectList :plan-id="formData.id!" :form-type="formType" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
|
@ -142,8 +130,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
import { DvCheckPlanApi, DvCheckPlanVO } from '@/api/mes/dv/checkplan'
|
import { DvCheckPlanApi, DvCheckPlanVO } from '@/api/mes/dv/checkplan'
|
||||||
import { generateRandomStr } from '@/utils'
|
import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
|
||||||
import { MesDvCheckPlanStatusEnum } from '@/views/mes/utils/constants'
|
import { MesAutoCodeRuleCode, MesDvCheckPlanStatusEnum } from '@/views/mes/utils/constants'
|
||||||
import CheckPlanMachineryList from './CheckPlanMachineryList.vue'
|
import CheckPlanMachineryList from './CheckPlanMachineryList.vue'
|
||||||
import CheckPlanSubjectList from './CheckPlanSubjectList.vue'
|
import CheckPlanSubjectList from './CheckPlanSubjectList.vue'
|
||||||
|
|
||||||
|
|
@ -180,15 +168,16 @@ const formRules = reactive({
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
|
||||||
/** 生成方案编码 */
|
/** 生成方案编码 */
|
||||||
const generateCode = () => {
|
const generateCode = async () => {
|
||||||
// TODO @AI:接入编码规则。mysql 直接插入下,已经启动。
|
formData.value.code = await AutoCodeRecordApi.generateAutoCode(
|
||||||
formData.value.code = 'CHP' + generateRandomStr(8)
|
MesAutoCodeRuleCode.DV_CHECK_PLAN_CODE
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = type === 'detail' ? '查看' : t('action.' + type)
|
dialogTitle.value = type === 'detail' ? '方案详情' : t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
resetForm()
|
resetForm()
|
||||||
// 修改时,设置数据
|
// 修改时,设置数据
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<div>
|
<div>
|
||||||
<!-- 操作栏 -->
|
<!-- 操作栏 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="!readonly"
|
v-if="isUpdate"
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
size="small"
|
size="small"
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
<el-table-column label="设备名称" align="center" prop="machineryName" min-width="150" />
|
<el-table-column label="设备名称" align="center" prop="machineryName" min-width="150" />
|
||||||
<el-table-column label="品牌" align="center" prop="machineryBrand" min-width="100" />
|
<el-table-column label="品牌" align="center" prop="machineryBrand" min-width="100" />
|
||||||
<el-table-column label="规格型号" align="center" prop="machinerySpec" min-width="120" />
|
<el-table-column label="规格型号" align="center" prop="machinerySpec" min-width="120" />
|
||||||
<!-- TODO @AI:【备注】展示下; -->
|
<el-table-column label="备注" align="center" prop="remark" min-width="120" />
|
||||||
<el-table-column v-if="!readonly" label="操作" align="center" width="80">
|
<el-table-column v-if="isUpdate" label="操作" align="center" width="80">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -58,12 +58,14 @@ defineOptions({ name: 'CheckPlanMachineryList' })
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
planId: number // 方案编号
|
planId: number // 方案编号
|
||||||
readonly?: boolean // 是否只读模式 TODO @AI:【听我的】,参考别的模块,基于 formType 做判断;你参考下;
|
formType: string // 表单类型
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // 是否为编辑模式
|
||||||
|
|
||||||
const loading = ref(false) // 列表的加载中
|
const loading = ref(false) // 列表的加载中
|
||||||
const list = ref<DvCheckPlanMachineryVO[]>([]) // 列表的数据
|
const list = ref<DvCheckPlanMachineryVO[]>([]) // 列表的数据
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<div>
|
<div>
|
||||||
<!-- 操作栏 -->
|
<!-- 操作栏 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="!readonly"
|
v-if="isUpdate"
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
size="small"
|
size="small"
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="项目内容" align="center" prop="subjectContent" min-width="150" />
|
<el-table-column label="项目内容" align="center" prop="subjectContent" min-width="150" />
|
||||||
<el-table-column label="标准" align="center" prop="subjectStandard" min-width="120" />
|
<el-table-column label="标准" align="center" prop="subjectStandard" min-width="120" />
|
||||||
<el-table-column v-if="!readonly" label="操作" align="center" width="80">
|
<el-table-column v-if="isUpdate" label="操作" align="center" width="80">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row.id)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -63,12 +63,14 @@ defineOptions({ name: 'CheckPlanSubjectList' })
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
planId: number // 方案编号
|
planId: number // 方案编号
|
||||||
readonly?: boolean // 是否只读模式 TODO @AI:【听我的】,参考别的模块,基于 formType 做判断;你参考下;
|
formType: string // 表单类型
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // 是否为编辑模式
|
||||||
|
|
||||||
const loading = ref(false) // 列表的加载中
|
const loading = ref(false) // 列表的加载中
|
||||||
const list = ref<DvCheckPlanSubjectVO[]>([]) // 列表的数据
|
const list = ref<DvCheckPlanSubjectVO[]>([]) // 列表的数据
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,13 @@
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
<el-table-column label="方案编码" align="center" prop="code" min-width="120" />
|
<el-table-column label="方案编码" align="center" prop="code" min-width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="openForm('detail', scope.row.id)">
|
||||||
|
{{ scope.row.code }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="方案名称" align="center" prop="name" min-width="150" />
|
<el-table-column label="方案名称" align="center" prop="name" min-width="150" />
|
||||||
<el-table-column label="方案类型" align="center" prop="type" min-width="100">
|
<el-table-column label="方案类型" align="center" prop="type" min-width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
|
|
@ -120,16 +126,6 @@
|
||||||
/>
|
/>
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<!-- TODO @AI:查看,挪到【方案编码】点击打开;并且不用判断状态; -->
|
|
||||||
<el-button
|
|
||||||
v-if="scope.row.status !== MesDvCheckPlanStatusEnum.PREPARE"
|
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
@click="openForm('detail', scope.row.id)"
|
|
||||||
v-hasPermi="['mes:dv-check-plan:query']"
|
|
||||||
>
|
|
||||||
查看
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
v-if="scope.row.status === MesDvCheckPlanStatusEnum.PREPARE"
|
v-if="scope.row.status === MesDvCheckPlanStatusEnum.PREPARE"
|
||||||
link
|
link
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,8 @@ export const MesAutoCodeRuleCode = {
|
||||||
CAL_TEAM_CODE: 'CAL_TEAM_CODE', // 班组编码
|
CAL_TEAM_CODE: 'CAL_TEAM_CODE', // 班组编码
|
||||||
CAL_PLAN_CODE: 'CAL_PLAN_CODE', // 排班计划编码
|
CAL_PLAN_CODE: 'CAL_PLAN_CODE', // 排班计划编码
|
||||||
DV_MACHINERY_CODE: 'DV_MACHINERY_CODE', // 设备编码
|
DV_MACHINERY_CODE: 'DV_MACHINERY_CODE', // 设备编码
|
||||||
DV_MACHINERY_TYPE_CODE: 'DV_MACHINERY_TYPE_CODE' // 设备类型编码
|
DV_MACHINERY_TYPE_CODE: 'DV_MACHINERY_TYPE_CODE', // 设备类型编码
|
||||||
|
DV_CHECK_PLAN_CODE: 'DV_CHECK_PLAN_CODE' // 点检保养方案编码
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
/** 获取物料/产品标识的标签 */
|
/** 获取物料/产品标识的标签 */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue