✨ feat(mes): 更新缺陷类型字典和必填字段验证
修改缺陷相关的字典类型为 MES_DEFECT_TYPE,并在缺陷数量字段添加必填验证,确保数据完整性。pull/871/MERGE
parent
23799e7f21
commit
3ab07d7412
|
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
<el-form-item label="检测项类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择检测项类型" clearable class="!w-1/1">
|
||||
<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"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
|
|
@ -48,19 +48,22 @@
|
|||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
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' })
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
|
|
@ -79,9 +82,10 @@ const formRules = reactive({
|
|||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 生成缺陷编码 */
|
||||
const generateCode = () => {
|
||||
// TODO @芋艿:后续对接后端编码生成接口
|
||||
formData.value.code = 'DF' + generateRandomStr(12)
|
||||
const generateCode = async () => {
|
||||
formData.value.code = await AutoCodeRecordApi.generateAutoCode(
|
||||
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 () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
|
|
@ -138,4 +140,6 @@ const resetForm = () => {
|
|||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
class="!w-240px"
|
||||
>
|
||||
<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"
|
||||
:label="dict.label"
|
||||
: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="type" width="120">
|
||||
<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>
|
||||
</el-table-column>
|
||||
<el-table-column label="缺陷等级" align="center" prop="level" width="120">
|
||||
|
|
@ -140,10 +140,10 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||
import download from '@/utils/download'
|
||||
import { QcDefectApi, QcDefectVO } from '@/api/mes/qc/defect'
|
||||
import DefectForm from './DefectForm.vue'
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||
|
||||
defineOptions({ name: 'MesQcDefect' })
|
||||
|
||||
|
|
@ -153,6 +153,7 @@ const { t } = useI18n() // 国际化
|
|||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<QcDefectVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
|
|
@ -162,7 +163,7 @@ const queryParams = reactive({
|
|||
level: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const formRef = ref() // 表单弹窗
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
|
|
@ -189,7 +190,6 @@ const resetQuery = () => {
|
|||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
|
@ -197,12 +197,9 @@ const openForm = (type: string, id?: number) => {
|
|||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await QcDefectApi.deleteDefect(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
|
@ -210,9 +207,7 @@ const handleDelete = async (id: number) => {
|
|||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await QcDefectApi.exportDefect(queryParams)
|
||||
download.excel(data, '缺陷类型.xls')
|
||||
|
|
@ -222,7 +217,7 @@ const handleExport = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue