Browse Source

检验任务可以新增修改删除

master_hella_20240701
zhang_li 4 months ago
parent
commit
67324b9307
  1. 172
      src/views/qms/inspectionScheme/addForm.vue
  2. 7
      src/views/qms/inspectionTemplate/addForm.vue

172
src/views/qms/inspectionScheme/addForm.vue

@ -195,7 +195,11 @@
</el-col>
<el-col :span="12">
<el-form-item label="每份样品量" prop="samplePieceSize">
<el-input v-model="data.samplePieceSize" placeholder="请填写每份样品量" :disabled='isSamplePieceSizeDisabled'/>
<el-input
v-model="data.samplePieceSize"
placeholder="请填写每份样品量"
:disabled="isSamplePieceSizeDisabled"
/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -229,6 +233,7 @@
</el-form>
<el-tabs
v-model="editableTabsValue"
editable
class="demo-tabs"
@edit="handleTabsEdit"
type="border-card"
@ -462,10 +467,7 @@
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item
label="计量单位"
prop="inspectionCharacteristicsBaseVO.quantifyUom"
>
<el-form-item label="计量单位" prop="inspectionCharacteristicsBaseVO.quantifyUom">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyUom"
:disabled="!item.inspectionCharacteristicsBaseVO.isCanUpdate"
@ -519,7 +521,13 @@
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsCapping">
<el-col
:span="12"
v-if="
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsCapping
"
>
<el-form-item
label="上限值"
prop="inspectionCharacteristicsBaseVO.quantifyCapping"
@ -527,11 +535,18 @@
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping"
:disabled="!item.inspectionCharacteristicsBaseVO.isCanUpdate"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit">
<el-col
:span="12"
v-if="
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit
"
>
<el-form-item
label="下限值"
prop="inspectionCharacteristicsBaseVO.quantifyLowlimit"
@ -539,11 +554,18 @@
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit"
:disabled="!item.inspectionCharacteristicsBaseVO.isCanUpdate"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsTarget">
<el-col
:span="12"
v-if="
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsTarget
"
>
<el-form-item
label="目标值"
prop="inspectionCharacteristicsBaseVO.quantifyTarget"
@ -551,16 +573,15 @@
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget"
:disabled="!item.inspectionCharacteristicsBaseVO.isCanUpdate"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 1">
<el-form-item
label="选定集"
prop="inspectionCharacteristicsBaseVO.quantifyQuantifyCode"
>
<div style="display: flex; width: 100%">
<el-input
@ -648,7 +669,7 @@ import * as DynamicRuleApi from '@/api/qms/dynamicRule' //动态修改规则
import { DynamicRule } from '@/views/qms/dynamicRule/dynamicRule.data' //
import * as SelectedSetApi from '@/api/qms/selectedSet' //
import { SelectedSet } from '@/views/qms/selectedSet/selectedSet.data' //
import {validateTwoNum} from '@/utils/validator'
import { validateInteger, validateMaxNumber5, validateTwoNum } from '@/utils/validator'
const message = useMessage() //
@ -730,20 +751,21 @@ const rules = ref({
programmeTemplateCode: [
{ required: true, message: '请选择检验模板', trigger: ['blur', 'change'] }
],
description: [
{ required: true, message: '请选择描述', trigger: 'blur' }
],
description: [{ required: true, message: '请选择描述', trigger: 'blur' }],
// splitRule: [{ required: true, message: '', trigger: ['blur', 'change'] }],
aql: [{ required: true, message: '请选择aql', trigger: ['blur', 'change'] }],
inspectionLevel: [
{ required: true, message: '请选择检验水平', trigger: ['blur', 'change'] },
],
inspectionLevel: [{ required: true, message: '请选择检验水平', trigger: ['blur', 'change'] }],
samplePieceSize: [
{ required: true, message: '请输入每份样品量', trigger: ['blur', 'change'] },
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'},
{ validator: validateTwoNum, message: '小数点后最多2位', trigger: 'blur' }
],
effectiveDate: [{ required: true, message: '请选择生效时间', trigger: ['blur', 'change'] }],
expirationDate: [{ required: true, message: '请选择失效时间', trigger: ['blur', 'change'] }],
sequenceCode: [
{ required: true, message: '请填写顺序号', trigger: 'blur' },
{ validator: validateInteger, message: '请输入正确的整数', trigger: 'blur' }
],
'inspectionCharacteristicsBaseVO.description': [
{ required: true, message: '请填写描述', trigger: ['blur', 'change'] }
],
@ -775,7 +797,9 @@ const rules = ref({
{ 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' }
@ -809,7 +833,10 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
item.name = index + 1
// rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = true
//
if (item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsCapping) {
if (
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsCapping
) {
rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = true
}
if (item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit) {
@ -845,9 +872,9 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
expirationDate: '',
available: 'TRUE',
dynamicUpdateCode: '',
description:"",
samplePieceSize:"",
uom:"",
description: '',
samplePieceSize: '',
uom: '',
process: []
}
}
@ -901,13 +928,13 @@ const buttonBaseClick1 = (val) => {
inspectionMethodCode: '',
dynamicUpdateCode: '',
inspectionMethod: '',
isCanUpdate: '',
isCanUpdate: true,
isDestructionInspection: '',
resultEntryMethod: '',
featureType: '',
quantifyIsCapping: '',
quantifyIsLowlimit: '',
quantifyIsTarget: '',
quantifyIsCapping: false,
quantifyIsLowlimit: false,
quantifyIsTarget: false,
quantifyTarget: '',
quantifyCapping: '',
quantifyLowlimit: '',
@ -954,10 +981,29 @@ const validateForm = (formRef) => {
return false
})
}
// true \ false
const hasDuplicates = (array) => {
const seen = new Set()
const repeatCode = new Set()
let arr = array.map((item) => parseInt(item.sequenceCode))
arr.forEach((item) => {
if (seen.has(item)) {
repeatCode.add(item)
} else {
seen.add(item)
}
})
const arr1 = Array.from(repeatCode)
if (arr1.length > 0) {
return true
} else {
return false
}
}
const submitForm = async () => {
try {
const aa = await getStrDictOptions(DICT_TYPE.SPLIT_RULES);//
const aa = await getStrDictOptions(DICT_TYPE.SPLIT_RULES) //
data.value.splitRule = aa[0].value
const validateForm1 = await validateForm(formProcessRef.value)
await formMainRef.value.validate()
@ -965,6 +1011,11 @@ const submitForm = async () => {
message.error(`请添加工序`)
return
}
// debugger
if (hasDuplicates(data.value.process)) {
message.error(`检验工序顺序号不能相同`)
return
}
const bol1 = await validateForm(formProcessRef.value)
const bol2 = await validateForm(formFeaturesRef.value)
if (!bol1 || !bol2) {
@ -984,8 +1035,65 @@ const submitForm = async () => {
message.error(`${str}是否设定上线,是否设定下限,是否是定目标值至少一项为是`)
return
}
// ,,
console.log(data.value.process)
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) => {
// ,
return (
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit &&
!item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyCapping) <=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyLowlimit)) ||
//
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
!item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit &&
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyCapping) <=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyTarget)) ||
//
(item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit &&
item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
!item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyLowlimit) >=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyTarget)) ||
//
(item.inspectionCharacteristicsBaseVO.quantifyIsCapping &&
item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit &&
item.inspectionCharacteristicsBaseVO.quantifyIsTarget &&
(parseFloat(item.inspectionCharacteristicsBaseVO.quantifyCapping) <=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyLowlimit) ||
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyCapping) <=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyTarget) ||
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyLowlimit) >=
parseFloat(item.inspectionCharacteristicsBaseVO.quantifyTarget)))
)
})
if (arr2 && arr2.length > 0) {
const str = arr2.map((item) => item.description).join(',')
message.error(`${str}工序上限值应大于目标值大于下限值`)
return
}
if (formType.value == 'create') {
//
emit('submitForm', formType.value, data.value)
} else {
@ -1143,7 +1251,10 @@ const searchTableSuccess = async (formField, searchField, val, type, row) => {
item.name = index + 1
// rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = true
//
if (item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsCapping) {
if (
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsCapping
) {
rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = true
}
if (item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit) {
@ -1181,7 +1292,6 @@ const changeIsCapping = (e,item) => {
} else {
rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = false
}
}
//
const changeLowlimit = (e, item) => {

7
src/views/qms/inspectionTemplate/addForm.vue

@ -297,7 +297,8 @@
prop="inspectionCharacteristicsBaseVO.quantifyDecimal"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal" />
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal"
type="number"/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
@ -822,10 +823,6 @@ const submitForm = async () => {
console.log(data.value.process)
const arr1 = data.value.process.filter(
(item) =>
// {
// console.log(String(item.inspectionCharacteristicsBaseVO.quantifyCapping).split('.')[1]?.length)
// console.log(Number(item.inspectionCharacteristicsBaseVO.quantifyDecimal))
// }
((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)))) &&

Loading…
Cancel
Save