Browse Source

模板校验

master_hella_20240701
zhang_li 7 months ago
parent
commit
8a754aa097
  1. 156
      src/views/qms/basicDataManage/inspectionTemplate/addForm.vue
  2. 14
      src/views/qms/inspection/inspectionJob/addForm.vue
  3. 18
      src/views/qms/inspection/inspectionRequest/inspectionMain.data.ts

156
src/views/qms/basicDataManage/inspectionTemplate/addForm.vue

@ -22,7 +22,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="版本" prop="version">
<el-input v-model="data.version" placeholder="请填写版本" />
<el-input v-model="data.version" placeholder="请填写版本" type="number"/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -112,7 +112,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="顺序号" prop="sequenceCode">
<el-input v-model="item.sequenceCode" />
<el-input v-model="item.sequenceCode" type="number"/>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
@ -270,81 +270,75 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-col :span="12">
<el-form-item
label="是否设定上限"
prop="inspectionCharacteristicsBaseVO.quantifyIsCapping"
label="计量单位"
prop="inspectionCharacteristicsBaseVO.quantifyUom"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping" @change="changeIsCapping"/>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyUom" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="上限值"
prop="inspectionCharacteristicsBaseVO.quantifyCapping"
label="小数位"
prop="inspectionCharacteristicsBaseVO.quantifyDecimal"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping" />
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item
prop="inspectionCharacteristicsBaseVO.quantifyIsLowlimit"
label="是否设定下限"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
label="是否设定上限"
prop="inspectionCharacteristicsBaseVO.quantifyIsCapping"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit" @change="changeLowlimit"/>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping" @change="changeIsCapping"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item
label="下限值"
prop="inspectionCharacteristicsBaseVO.quantifyLowlimit"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
prop="inspectionCharacteristicsBaseVO.quantifyIsLowlimit"
label="是否设定下限"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit" />
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit" @change="changeLowlimit"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
prop="inspectionCharacteristicsBaseVO.quantifyIsTarget"
label="是否设定目标值"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsTarget" @change="changeIsTarget"/>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsTarget" @change="changeIsTarget" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsCapping">
<el-form-item
label="目标值"
prop="inspectionCharacteristicsBaseVO.quantifyTarget"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
label="上限值"
prop="inspectionCharacteristicsBaseVO.quantifyCapping"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget" />
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping" type="number"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit">
<el-form-item
label="计量单位"
prop="inspectionCharacteristicsBaseVO.quantifyUom"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
label="下限值"
prop="inspectionCharacteristicsBaseVO.quantifyLowlimit"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyUom" />
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit" type="number"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsTarget">
<el-form-item
label="小数位"
prop="inspectionCharacteristicsBaseVO.quantifyDecimal"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
label="目标值"
prop="inspectionCharacteristicsBaseVO.quantifyTarget"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal" />
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget" type="number"/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -428,6 +422,7 @@ import * as DynamicRuleApi from '@/api/qms/dynamicRule' //动态修改规则
import { DynamicRule } from '@/views/qms/basicDataManage/dynamicRule/dynamicRule.data' //
import * as SelectedSetApi from '@/api/qms/selectedSet' //
import { SelectedSet } from '@/views/qms/basicDataManage/selectedSet/selectedSet.data' //
import { validateInteger,validateTwoNum,validateMaxNumber5 } from '@/utils/validator'
const message = useMessage() //
const props = defineProps({
@ -492,9 +487,15 @@ if (props.basicFormWidth) {
}
const rules = ref({
description: [{ required: true, message: '请填写描述', trigger: 'blur' }],
version: [{ required: true, message: '请填写版本', trigger: 'blur' }],
version: [
{ required: true, message: '请填写版本', trigger: 'blur' },
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
],
inspectionCode: [{ required: true, message: '请选择检验方案模板', trigger: 'blur' }],
sequenceCode: [{ required: true, message: '请填写顺序号', trigger: 'blur' }],
sequenceCode: [
{ required: true, message: '请填写顺序号', trigger: 'blur' },
{ validator:validateInteger, message: '请输入正确的整数', trigger: 'blur'}
],
inspectionCharCode: [{ required: true, message: '请选择检验特性', trigger: 'blur' }],
'inspectionCharacteristicsBaseVO.description': [
{ required: true, message: '请填写描述', trigger: ['blur', 'change'] }
@ -515,24 +516,28 @@ const rules = ref({
{ required: true, message: '请选择特征类型', trigger: ['blur', 'change'] }
],
'inspectionCharacteristicsBaseVO.quantifyTarget': [
{ required: true, message: '请输入目标值', trigger: 'blur' }
{ required: true, message: '请输入目标值', trigger: 'blur' },
],
'inspectionCharacteristicsBaseVO.quantifyCapping': [
{ required: true, message: '请输入上限值', trigger: 'blur' }
{ required: true, message: '请输入上限值', trigger: 'blur' },
],
'inspectionCharacteristicsBaseVO.quantifyLowlimit': [
{ required: true, message: '请输入下限值', trigger: 'blur' }
{ required: true, message: '请输入下限值', trigger: 'blur' },
],
'inspectionCharacteristicsBaseVO.quantifyUom': [
{ required: true, message: '请选择计量单位', trigger: 'blur' }
],
'inspectionCharacteristicsBaseVO.quantifyDecimal': [
{ required: true, message: '请输入小数位', trigger: 'blur' }
{ required: true, message: '请输入小数位', trigger: 'blur' },
{ validator:validateInteger, message: '请输入正确的整数', trigger: 'blur'},
{ validator:validateMaxNumber5, message: '不能大于5', trigger: 'blur'}
],
'inspectionCharacteristicsBaseVO.quantifyQuantifyCode': [
{ required: true, message: '请输入选择集', trigger: 'blur' }
]
})
/** 打开弹窗 */
let tabIndex = 1
const open = async (type: string, row?: any, masterParmas?: any, titleName?: any) => {
@ -681,22 +686,44 @@ const validateForm = (formRef) => {
return false
})
}
// true \ false
const hasDuplicates =(array)=>{
return array.some((item, index) => {
return (
array.findIndex((v, i) => {
return (
i !== index &&
JSON.stringify(v.sequenceCode) === JSON.stringify(item.sequenceCode)
)
}) !== -1
)
})
}
const submitForm = async () => {
try {
const validateForm1 = await validateForm(formProcessRef.value)
console.log(validateForm1)
//
await validateForm(formProcessRef.value)
await formMainRef.value.validate()
//
if (!data.value.process || data.value.process.length == 0) {
message.error(`请添加工序`)
return
}
if(hasDuplicates(data.value.process)){
message.error(`检验工序顺序号不能相同`)
return
}
//
const bol1 = await validateForm(formProcessRef.value)
const bol2 = await validateForm(formFeaturesRef.value)
if (!bol1 || !bol2) {
message.error(`模板中有检验工序和检验特性未填写完全`)
return
}
// 线,,
const arr = data.value.process.filter(
(item) =>
!item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
@ -704,10 +731,39 @@ const submitForm = async () => {
!item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
item.inspectionCharacteristicsBaseVO.featureType == 0
)
console.log(arr)
if (arr && arr.length > 0) {
const str = arr.map((item) => item.description).join(',')
message.error(`${str}是否设定上线,是否设定下限,是否是定目标值至少一项为是`)
message.error(`${str}是否设定上线,是否设定下限,是否设定目标值至少一项为是`)
return
}
// ,,
const arr1 = data.value.process.filter(
(item) =>
((item.inspectionCharacteristicsBaseVO.quantifyIsCapping && (String(item.inspectionCharacteristicsBaseVO.quantifyCapping).split('.')[1].length>Number(item.inspectionCharacteristicsBaseVO.quantifyDecimal)))||
(item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit && (String(item.inspectionCharacteristicsBaseVO.quantifyLowlimit).split('.')[1].length>Number(item.inspectionCharacteristicsBaseVO.quantifyDecimal)))||
(item.inspectionCharacteristicsBaseVO.quantifyIsTarget && (String(item.inspectionCharacteristicsBaseVO.quantifyTarget).split('.')[1].length>Number(item.inspectionCharacteristicsBaseVO.quantifyDecimal)))) &&
item.inspectionCharacteristicsBaseVO.featureType == 0
)
if (arr1 && arr1.length > 0) {
const str = arr1.map((item) => item.description).join(',')
message.error(`${str}上限值,下限值,目标值小数位数不可以大于小数位`)
return
}
//
const arr2 = data.value.process.filter(
(item) =>
//
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping && item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit && (item.inspectionCharacteristicsBaseVO.quantifyCapping <=item.inspectionCharacteristicsBaseVO.quantifyLowlimit))||
//
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping && item.inspectionCharacteristicsBaseVO.quantifyIsTarget && (item.inspectionCharacteristicsBaseVO.quantifyCapping <=item.inspectionCharacteristicsBaseVO.quantifyTarget))||
//
( item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit && item.inspectionCharacteristicsBaseVO.quantifyIsTarget && (item.inspectionCharacteristicsBaseVO.quantifyLowlimit >= item.inspectionCharacteristicsBaseVO.quantifyTarget))||
//
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping && item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit && item.inspectionCharacteristicsBaseVO.quantifyIsTarget && ((item.inspectionCharacteristicsBaseVO.quantifyCapping <=item.inspectionCharacteristicsBaseVO.quantifyLowlimit)||(item.inspectionCharacteristicsBaseVO.quantifyCapping <=item.inspectionCharacteristicsBaseVO.quantifyTarget)||(item.inspectionCharacteristicsBaseVO.quantifyLowlimit >= item.inspectionCharacteristicsBaseVO.quantifyTarget)))
)
if (arr2 && arr2.length > 0) {
const str = arr2.map((item) => item.description).join(',')
message.error(`${str}上限值应大目标值大于下限值`)
return
}
if (formType.value == 'create') {

14
src/views/qms/inspection/inspectionJob/addForm.vue

@ -240,7 +240,7 @@
:span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1"
>
<el-form-item label="合格数量">
<el-form-item label="合格数量" required>
<el-input v-model="cur.qualifiedQuantity" placeholder="请输入合格数量" />
</el-form-item>
</el-col>
@ -248,7 +248,7 @@
:span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1"
>
<el-form-item label="不合格数量">
<el-form-item label="不合格数量" required>
<el-input
v-model="cur.unqualifiedQuantity"
placeholder="请输入不合格数量"
@ -257,7 +257,7 @@
</el-col>
<!-- 手动评估的时候显示 -->
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1">
<el-form-item label="评估代码">
<el-form-item label="评估代码" required>
<el-select
v-model="cur.estimateCode"
placeholder="请选择评估代码"
@ -276,7 +276,7 @@
:span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.featureType == 0"
>
<el-form-item label="检验值" prop="inspectionValue">
<el-form-item label="检验值" required>
<el-input v-model="cur.inspectionValue" placeholder="请输入检验值" />
</el-form-item>
</el-col>
@ -284,7 +284,7 @@
:span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.featureType == 1"
>
<el-form-item label="选定集" prop="qualitativeCode">
<el-form-item label="选定集" required>
<el-select
v-model="cur.qualitativeCode"
placeholder="请选择选定集"
@ -300,8 +300,8 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1">
<el-form-item label="缺陷级别">
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1" >
<el-form-item label="缺陷级别" required>
<el-select v-model="cur.defectLevel" placeholder="请选择缺陷级别" disabled>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.DEFECT_LEVEL)"

18
src/views/qms/inspection/inspectionRequest/inspectionMain.data.ts

@ -256,15 +256,15 @@ export const InspectionMain = useCrudSchemas(reactive<CrudSchema[]>([
}
},
},
{
label: '检验申请包装列表',
field: 'applicationPackageCode',
sort: 'custom',
isSearch: false,
table: {
width: 150
}
},
// {
// label: '检验申请包装列表',
// field: 'applicationPackageCode',
// sort: 'custom',
// isSearch: false,
// table: {
// width: 150
// }
// },
{
label: '检验水平',
field: 'inspectionLevel',

Loading…
Cancel
Save