feat(mes): 更新缺陷类型字典和必填字段验证

修改缺陷相关的字典类型为 MES_DEFECT_TYPE,并在缺陷数量字段添加必填验证,确保数据完整性。
pull/871/MERGE
YunaiV 2026-04-04 20:54:00 +08:00
parent 23799e7f21
commit 3ab07d7412
3 changed files with 18 additions and 54 deletions

View File

@ -1,35 +0,0 @@
import request from '@/config/axios'
// MES 来料检验缺陷记录 VO
export interface QcIqcDefectVO {
id: number // 编号
iqcId: number // 来料检验单 ID
lineId: number // 来料检验行 ID
defectName: string // 缺陷描述
defectLevel: number // 缺陷等级
defectQuantity: number // 缺陷数量
remark: string // 备注
}
// MES 来料检验缺陷记录 API
export const QcIqcDefectApi = {
// 查询来料检验缺陷记录分页
getIqcDefectPage: async (params: any) => {
return await request.get({ url: `/mes/qc/iqc/defect/page`, params })
},
// 新增来料检验缺陷记录
createIqcDefect: async (data: QcIqcDefectVO) => {
return await request.post({ url: `/mes/qc/iqc/defect/create`, data })
},
// 修改来料检验缺陷记录
updateIqcDefect: async (data: QcIqcDefectVO) => {
return await request.put({ url: `/mes/qc/iqc/defect/update`, data })
},
// 删除来料检验缺陷记录
deleteIqcDefect: async (id: number) => {
return await request.delete({ url: `/mes/qc/iqc/defect/delete?id=` + id })
}
}

View File

@ -21,7 +21,7 @@
<el-form-item label="检测项类型" prop="type"> <el-form-item label="检测项类型" prop="type">
<el-select v-model="formData.type" placeholder="请选择检测项类型" clearable class="!w-1/1"> <el-select v-model="formData.type" placeholder="请选择检测项类型" clearable class="!w-1/1">
<el-option <el-option
v-for="dict in getStrDictOptions(DICT_TYPE.MES_INDICATOR_TYPE)" v-for="dict in getStrDictOptions(DICT_TYPE.MES_DEFECT_TYPE)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
@ -48,19 +48,22 @@
</template> </template>
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { QcDefectApi, QcDefectVO } from '@/api/mes/qc/defect' import { QcDefectApi, QcDefectVO } from '@/api/mes/qc/defect'
import { generateRandomStr } from '@/utils' import { AutoCodeRecordApi } from '@/api/mes/md/autocode/record'
import { MesAutoCodeRuleCode } from '@/views/mes/utils/constants'
defineOptions({ name: 'DefectForm' }) defineOptions({ name: 'DefectForm' })
const emit = defineEmits(['success'])
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) //
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData = ref({ const formData = ref({
id: undefined, id: undefined,
@ -79,9 +82,10 @@ const formRules = reactive({
const formRef = ref() // Ref const formRef = ref() // Ref
/** 生成缺陷编码 */ /** 生成缺陷编码 */
const generateCode = () => { const generateCode = async () => {
// TODO @ formData.value.code = await AutoCodeRecordApi.generateAutoCode(
formData.value.code = 'DF' + generateRandomStr(12) MesAutoCodeRuleCode.QC_DEFECT_CODE
)
} }
/** 打开弹窗 */ /** 打开弹窗 */
@ -100,10 +104,8 @@ const open = async (type: string, id?: number) => {
} }
} }
} }
defineExpose({ open }) // open
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => { const submitForm = async () => {
// //
await formRef.value.validate() await formRef.value.validate()
@ -138,4 +140,6 @@ const resetForm = () => {
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
defineExpose({ open })
</script> </script>

View File

@ -35,7 +35,7 @@
class="!w-240px" class="!w-240px"
> >
<el-option <el-option
v-for="dict in getStrDictOptions(DICT_TYPE.MES_INDICATOR_TYPE)" v-for="dict in getStrDictOptions(DICT_TYPE.MES_DEFECT_TYPE)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
@ -88,7 +88,7 @@
<el-table-column label="缺陷描述" align="center" prop="name" min-width="200" /> <el-table-column label="缺陷描述" align="center" prop="name" min-width="200" />
<el-table-column label="检测项类型" align="center" prop="type" width="120"> <el-table-column label="检测项类型" align="center" prop="type" width="120">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.MES_INDICATOR_TYPE" :value="scope.row.type" /> <dict-tag :type="DICT_TYPE.MES_DEFECT_TYPE" :value="scope.row.type" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="缺陷等级" align="center" prop="level" width="120"> <el-table-column label="缺陷等级" align="center" prop="level" width="120">
@ -140,10 +140,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import download from '@/utils/download' import download from '@/utils/download'
import { QcDefectApi, QcDefectVO } from '@/api/mes/qc/defect' import { QcDefectApi, QcDefectVO } from '@/api/mes/qc/defect'
import DefectForm from './DefectForm.vue' import DefectForm from './DefectForm.vue'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
defineOptions({ name: 'MesQcDefect' }) defineOptions({ name: 'MesQcDefect' })
@ -153,6 +153,7 @@ const { t } = useI18n() // 国际化
const loading = ref(true) // const loading = ref(true) //
const list = ref<QcDefectVO[]>([]) // const list = ref<QcDefectVO[]>([]) //
const total = ref(0) // const total = ref(0) //
const exportLoading = ref(false) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
@ -162,7 +163,7 @@ const queryParams = reactive({
level: undefined level: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) // const formRef = ref() //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
@ -189,7 +190,6 @@ const resetQuery = () => {
} }
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
@ -197,12 +197,9 @@ const openForm = (type: string, id?: number) => {
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
//
await message.delConfirm() await message.delConfirm()
//
await QcDefectApi.deleteDefect(id) await QcDefectApi.deleteDefect(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
//
await getList() await getList()
} catch {} } catch {}
} }
@ -210,9 +207,7 @@ const handleDelete = async (id: number) => {
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
try { try {
//
await message.exportConfirm() await message.exportConfirm()
//
exportLoading.value = true exportLoading.value = true
const data = await QcDefectApi.exportDefect(queryParams) const data = await QcDefectApi.exportDefect(queryParams)
download.excel(data, '缺陷类型.xls') download.excel(data, '缺陷类型.xls')
@ -222,7 +217,7 @@ const handleExport = async () => {
} }
} }
/** 初始化 **/ /** 初始化 */
onMounted(() => { onMounted(() => {
getList() getList()
}) })