Browse Source

模板校验

master_hella_20240701
zhang_li 8 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>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="版本" prop="version"> <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-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -112,7 +112,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="顺序号" prop="sequenceCode"> <el-form-item label="顺序号" prop="sequenceCode">
<el-input v-model="item.sequenceCode" /> <el-input v-model="item.sequenceCode" type="number"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <el-col :span="12"> <!-- <el-col :span="12">
@ -270,81 +270,75 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item <el-form-item
label="是否设定上限" label="计量单位"
prop="inspectionCharacteristicsBaseVO.quantifyIsCapping" prop="inspectionCharacteristicsBaseVO.quantifyUom"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyUom" />
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping" @change="changeIsCapping"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="上限值" label="小数位"
prop="inspectionCharacteristicsBaseVO.quantifyCapping" prop="inspectionCharacteristicsBaseVO.quantifyDecimal"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping" /> <el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item <el-form-item
prop="inspectionCharacteristicsBaseVO.quantifyIsLowlimit" label="是否设定上限"
label="是否设定下限" prop="inspectionCharacteristicsBaseVO.quantifyIsCapping"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit" @change="changeLowlimit"/> <el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping" @change="changeIsCapping"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item <el-form-item
label="下限值" prop="inspectionCharacteristicsBaseVO.quantifyIsLowlimit"
prop="inspectionCharacteristicsBaseVO.quantifyLowlimit" label="是否设定下限"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit" /> <el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit" @change="changeLowlimit"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
prop="inspectionCharacteristicsBaseVO.quantifyIsTarget" prop="inspectionCharacteristicsBaseVO.quantifyIsTarget"
label="是否设定目标值" label="是否设定目标值"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0" 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-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsCapping">
<el-form-item <el-form-item
label="目标值" label="上限值"
prop="inspectionCharacteristicsBaseVO.quantifyTarget" prop="inspectionCharacteristicsBaseVO.quantifyCapping"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget" /> <el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping" type="number"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit">
<el-col :span="12">
<el-form-item <el-form-item
label="计量单位" label="下限值"
prop="inspectionCharacteristicsBaseVO.quantifyUom" prop="inspectionCharacteristicsBaseVO.quantifyLowlimit"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyUom" /> <el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit" type="number"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsTarget">
<el-form-item <el-form-item
label="小数位" label="目标值"
prop="inspectionCharacteristicsBaseVO.quantifyDecimal" prop="inspectionCharacteristicsBaseVO.quantifyTarget"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
> >
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal" /> <el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget" type="number"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <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 { DynamicRule } from '@/views/qms/basicDataManage/dynamicRule/dynamicRule.data' //
import * as SelectedSetApi from '@/api/qms/selectedSet' // import * as SelectedSetApi from '@/api/qms/selectedSet' //
import { SelectedSet } from '@/views/qms/basicDataManage/selectedSet/selectedSet.data' // import { SelectedSet } from '@/views/qms/basicDataManage/selectedSet/selectedSet.data' //
import { validateInteger,validateTwoNum,validateMaxNumber5 } from '@/utils/validator'
const message = useMessage() // const message = useMessage() //
const props = defineProps({ const props = defineProps({
@ -492,9 +487,15 @@ if (props.basicFormWidth) {
} }
const rules = ref({ const rules = ref({
description: [{ required: true, message: '请填写描述', trigger: 'blur' }], 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' }], 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' }], inspectionCharCode: [{ required: true, message: '请选择检验特性', trigger: 'blur' }],
'inspectionCharacteristicsBaseVO.description': [ 'inspectionCharacteristicsBaseVO.description': [
{ required: true, message: '请填写描述', trigger: ['blur', 'change'] } { required: true, message: '请填写描述', trigger: ['blur', 'change'] }
@ -515,24 +516,28 @@ const rules = ref({
{ required: true, message: '请选择特征类型', trigger: ['blur', 'change'] } { required: true, message: '请选择特征类型', trigger: ['blur', 'change'] }
], ],
'inspectionCharacteristicsBaseVO.quantifyTarget': [ 'inspectionCharacteristicsBaseVO.quantifyTarget': [
{ required: true, message: '请输入目标值', trigger: 'blur' } { required: true, message: '请输入目标值', trigger: 'blur' },
], ],
'inspectionCharacteristicsBaseVO.quantifyCapping': [ 'inspectionCharacteristicsBaseVO.quantifyCapping': [
{ required: true, message: '请输入上限值', trigger: 'blur' } { required: true, message: '请输入上限值', trigger: 'blur' },
], ],
'inspectionCharacteristicsBaseVO.quantifyLowlimit': [ 'inspectionCharacteristicsBaseVO.quantifyLowlimit': [
{ required: true, message: '请输入下限值', trigger: 'blur' } { required: true, message: '请输入下限值', trigger: 'blur' },
], ],
'inspectionCharacteristicsBaseVO.quantifyUom': [ 'inspectionCharacteristicsBaseVO.quantifyUom': [
{ required: true, message: '请选择计量单位', trigger: 'blur' } { required: true, message: '请选择计量单位', trigger: 'blur' }
], ],
'inspectionCharacteristicsBaseVO.quantifyDecimal': [ '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': [ 'inspectionCharacteristicsBaseVO.quantifyQuantifyCode': [
{ required: true, message: '请输入选择集', trigger: 'blur' } { required: true, message: '请输入选择集', trigger: 'blur' }
] ]
}) })
/** 打开弹窗 */ /** 打开弹窗 */
let tabIndex = 1 let tabIndex = 1
const open = async (type: string, row?: any, masterParmas?: any, titleName?: any) => { const open = async (type: string, row?: any, masterParmas?: any, titleName?: any) => {
@ -681,22 +686,44 @@ const validateForm = (formRef) => {
return false 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 () => { const submitForm = async () => {
try { try {
const validateForm1 = await validateForm(formProcessRef.value)
console.log(validateForm1) //
await validateForm(formProcessRef.value)
await formMainRef.value.validate() await formMainRef.value.validate()
//
if (!data.value.process || data.value.process.length == 0) { if (!data.value.process || data.value.process.length == 0) {
message.error(`请添加工序`) message.error(`请添加工序`)
return return
} }
if(hasDuplicates(data.value.process)){
message.error(`检验工序顺序号不能相同`)
return
}
//
const bol1 = await validateForm(formProcessRef.value) const bol1 = await validateForm(formProcessRef.value)
const bol2 = await validateForm(formFeaturesRef.value) const bol2 = await validateForm(formFeaturesRef.value)
if (!bol1 || !bol2) { if (!bol1 || !bol2) {
message.error(`模板中有检验工序和检验特性未填写完全`) message.error(`模板中有检验工序和检验特性未填写完全`)
return return
} }
// 线,,
const arr = data.value.process.filter( const arr = data.value.process.filter(
(item) => (item) =>
!item.inspectionCharacteristicsBaseVO.quantifyIsCapping && !item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
@ -704,10 +731,39 @@ const submitForm = async () => {
!item.inspectionCharacteristicsBaseVO.quantifyIsTarget && !item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
item.inspectionCharacteristicsBaseVO.featureType == 0 item.inspectionCharacteristicsBaseVO.featureType == 0
) )
console.log(arr)
if (arr && arr.length > 0) { if (arr && arr.length > 0) {
const str = arr.map((item) => item.description).join(',') 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 return
} }
if (formType.value == 'create') { if (formType.value == 'create') {

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

@ -240,7 +240,7 @@
:span="12" :span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1" v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1"
> >
<el-form-item label="合格数量"> <el-form-item label="合格数量" required>
<el-input v-model="cur.qualifiedQuantity" placeholder="请输入合格数量" /> <el-input v-model="cur.qualifiedQuantity" placeholder="请输入合格数量" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -248,7 +248,7 @@
:span="12" :span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1" v-if="item.inspectionJobCharacteristicsUpdateReqVO.resultEntryMethod == 1"
> >
<el-form-item label="不合格数量"> <el-form-item label="不合格数量" required>
<el-input <el-input
v-model="cur.unqualifiedQuantity" v-model="cur.unqualifiedQuantity"
placeholder="请输入不合格数量" placeholder="请输入不合格数量"
@ -257,7 +257,7 @@
</el-col> </el-col>
<!-- 手动评估的时候显示 --> <!-- 手动评估的时候显示 -->
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1"> <el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1">
<el-form-item label="评估代码"> <el-form-item label="评估代码" required>
<el-select <el-select
v-model="cur.estimateCode" v-model="cur.estimateCode"
placeholder="请选择评估代码" placeholder="请选择评估代码"
@ -276,7 +276,7 @@
:span="12" :span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.featureType == 0" 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-input v-model="cur.inspectionValue" placeholder="请输入检验值" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -284,7 +284,7 @@
:span="12" :span="12"
v-if="item.inspectionJobCharacteristicsUpdateReqVO.featureType == 1" v-if="item.inspectionJobCharacteristicsUpdateReqVO.featureType == 1"
> >
<el-form-item label="选定集" prop="qualitativeCode"> <el-form-item label="选定集" required>
<el-select <el-select
v-model="cur.qualitativeCode" v-model="cur.qualitativeCode"
placeholder="请选择选定集" placeholder="请选择选定集"
@ -300,8 +300,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1"> <el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1" >
<el-form-item label="缺陷级别"> <el-form-item label="缺陷级别" required>
<el-select v-model="cur.defectLevel" placeholder="请选择缺陷级别" disabled> <el-select v-model="cur.defectLevel" placeholder="请选择缺陷级别" disabled>
<el-option <el-option
v-for="dict in getStrDictOptions(DICT_TYPE.DEFECT_LEVEL)" 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: '检验申请包装列表', // label: '检验申请包装列表',
field: 'applicationPackageCode', // field: 'applicationPackageCode',
sort: 'custom', // sort: 'custom',
isSearch: false, // isSearch: false,
table: { // table: {
width: 150 // width: 150
} // }
}, // },
{ {
label: '检验水平', label: '检验水平',
field: 'inspectionLevel', field: 'inspectionLevel',

Loading…
Cancel
Save