Browse Source

检验模板失去焦点校验

hella_online_20240829
zhang_li 4 months ago
parent
commit
b0f2776f21
  1. 268
      src/views/qms/inspectionTemplate/addForm.vue

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

@ -26,15 +26,13 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="动态修改规则编码"
prop="dynamicUpdateCode"
>
<el-form-item label="动态修改规则编码" prop="dynamicUpdateCode">
<div style="display: flex; width: 100%">
<el-input
v-model="data.dynamicUpdateCode"
placeholder="请选择动态修改规则编码"
@blur='dynamicUpdateCodeBlur'
@blur="mainblur('dynamicUpdate', DynamicRuleApi.getDynamicRulePage)"
@focus="mainFocus"
/>
<el-button
type="info"
@ -65,10 +63,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="动态修改规则描述"
prop="dynamicUpdateName"
>
<el-form-item label="动态修改规则描述" prop="dynamicUpdateName">
<div style="display: flex; width: 100%">
<el-input
v-model="data.dynamicUpdateName"
@ -97,7 +92,6 @@
>
<template #label>
<span class="custom-tabs-label" style="display: flex; align-items: center">
<span>{{ item.description }}</span>
<Icon
icon="ep:document-copy"
@ -150,7 +144,6 @@
/>
</el-form-item>
</el-col> -->
</el-row>
</el-form>
<div class="small-title">检验特性</div>
@ -179,8 +172,14 @@
<el-input
v-model="item.inspectionCharacteristicsBaseVO.inspectionMethodCode"
placeholder="请选择检验方法编码"
disabled
@blur='inspectionMethodCodeBlur(item)'
@blur="
mainblur(
'inspectionMethod',
InspectionMethodApi.getInspectionMethodPage,
item
)
"
@focus="mainFocus"
/>
<el-button
type="info"
@ -219,7 +218,7 @@
<el-input
v-model="item.inspectionCharacteristicsBaseVO.inspectionMethodName"
disabled
placeholder="请选择检验方法编码"
placeholder="请选择检验方法"
/>
</div>
</el-form-item>
@ -231,9 +230,12 @@
>
<div style="display: flex; width: 100%">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.samplingProcessName"
disabled
v-model="item.inspectionCharacteristicsBaseVO.samplingProcessCode"
placeholder="请选择采样过程"
@blur="
mainblur('samplingProcess', SamplingProcessApi.getSamplingProcessPage, item)
"
@focus="mainFocus"
/>
<el-button
type="info"
@ -263,7 +265,20 @@
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="采样过程描述"
prop="inspectionCharacteristicsBaseVO.inspectionMethodName"
>
<div style="display: flex; width: 100%">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.inspectionMethodName"
disabled
placeholder="请选择采样过程描述"
/>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="是否允许修改特征值"
@ -322,9 +337,7 @@
placeholder="请选择结果录入方式"
>
<el-option
v-for="dict in getStrDictOptions(
DICT_TYPE.UOM
)"
v-for="dict in getStrDictOptions(DICT_TYPE.UOM)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -338,8 +351,10 @@
prop="inspectionCharacteristicsBaseVO.quantifyDecimal"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal"
type="number"/>
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyDecimal"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
@ -347,7 +362,10 @@
label="是否设定上限"
prop="inspectionCharacteristicsBaseVO.quantifyIsCapping"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping" @change="changeIsCapping($event,item)"/>
<el-switch
v-model="item.inspectionCharacteristicsBaseVO.quantifyIsCapping"
@change="changeIsCapping($event, item)"
/>
</el-form-item>
</el-col>
@ -356,56 +374,80 @@
prop="inspectionCharacteristicsBaseVO.quantifyIsLowlimit"
label="是否设定下限"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit" @change="changeLowlimit($event,item)"/>
<el-switch
v-model="item.inspectionCharacteristicsBaseVO.quantifyIsLowlimit"
@change="changeLowlimit($event, item)"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0">
<el-form-item
prop="inspectionCharacteristicsBaseVO.quantifyIsTarget"
label="是否设定目标值"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 0"
>
<el-switch v-model="item.inspectionCharacteristicsBaseVO.quantifyIsTarget" @change="changeIsTarget($event,item)" />
<el-switch
v-model="item.inspectionCharacteristicsBaseVO.quantifyIsTarget"
@change="changeIsTarget($event, item)"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO. quantifyIsCapping">
<el-form-item
label="上限值"
prop="inspectionCharacteristicsBaseVO.quantifyCapping"
<el-col
:span="12"
v-if="
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsCapping
"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping" type="number"/>
<el-form-item label="上限值" prop="inspectionCharacteristicsBaseVO.quantifyCapping">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyCapping"
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"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit" type="number"/>
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyLowlimit"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 0 && item.inspectionCharacteristicsBaseVO.quantifyIsTarget">
<el-form-item
label="目标值"
prop="inspectionCharacteristicsBaseVO.quantifyTarget"
<el-col
:span="12"
v-if="
item.inspectionCharacteristicsBaseVO.featureType == 0 &&
item.inspectionCharacteristicsBaseVO.quantifyIsTarget
"
>
<el-input v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget" type="number"/>
<el-form-item label="目标值" prop="inspectionCharacteristicsBaseVO.quantifyTarget">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyTarget"
type="number"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 1">
<el-form-item
label="选定集"
prop="inspectionCharacteristicsBaseVO.quantifyQuantifyCode"
v-if="item.inspectionCharacteristicsBaseVO.featureType == 1"
>
<div style="display: flex; width: 100%">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyQuantifyName"
disabled
v-model="item.inspectionCharacteristicsBaseVO.quantifyQuantifyCode"
placeholder="请选择选定集"
@blur="mainblur('quantifyQuantify', SelectedSetApi.getSelectedSetPage, item)"
@focus="mainFocus"
/>
<el-button
type="info"
@ -435,13 +477,31 @@
</div>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.inspectionCharacteristicsBaseVO.featureType == 1">
<el-form-item
label="选定集描述"
prop="inspectionCharacteristicsBaseVO.quantifyQuantifyName"
>
<div style="display: flex; width: 100%">
<el-input
v-model="item.inspectionCharacteristicsBaseVO.quantifyQuantifyName"
disabled
placeholder="请选择选定集描述"
/>
</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-tab-pane>
</el-tabs>
</div>
<template #footer>
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" />
<ButtonBase
:Butttondata="Butttondata"
@button-base-click="buttonBaseClick"
:key="count"
/>
</template>
</Dialog>
<Dialog title="修改名称" v-model="dialogVisibleName" width="500px" :close-on-click-modal="false">
@ -476,7 +536,12 @@ 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 { validateInteger,validateTwoNum,validateMaxNumber5,validateNumSix } from '@/utils/validator'
import {
validateInteger,
validateTwoNum,
validateMaxNumber5,
validateNumSix
} from '@/utils/validator'
const message = useMessage() //
const props = defineProps({
@ -571,13 +636,13 @@ 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' }
@ -592,7 +657,6 @@ const rules = ref({
]
})
/** 打开弹窗 */
let tabIndex = 1
const open = async (type: string, row?: any, masterParmas?: any, titleName?: any) => {
@ -644,7 +708,7 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
quantifyUom: item.inspectionCharacteristicsBaseVO.quantifyUom,
resultEntryMethod: item.inspectionCharacteristicsBaseVO.resultEntryMethod,
samplingProcessCode: item.inspectionCharacteristicsBaseVO.samplingProcessCode,
samplingProcessName:item.inspectionCharacteristicsBaseVO.samplingProcessName,
samplingProcessName: item.inspectionCharacteristicsBaseVO.samplingProcessName
}
}
@ -667,7 +731,6 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
arr.push(obj)
})
data.value.process = arr
} else {
data.value = JSON.parse(JSON.stringify(row))
data.value.version = String(data.value.version)
@ -694,7 +757,6 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
})
data.value.process = list
}
} else {
data.value = {
code: '',
@ -786,6 +848,7 @@ const buttonBaseClick1 = (val) => {
}
}
const buttonBaseClick = (val) => {
console.log(val)
//
if (val == 'save') {
submitForm()
@ -813,10 +876,7 @@ const validateForm = (formRef) => {
return array.some((item, index) => {
return (
array.findIndex((v, i) => {
return (
i !== index &&
JSON.stringify(v.sequenceCode) === JSON.stringify(item.sequenceCode)
)
return i !== index && JSON.stringify(v.sequenceCode) === JSON.stringify(item.sequenceCode)
}) !== -1
)
})
@ -824,7 +884,6 @@ const validateForm = (formRef) => {
const submitForm = async () => {
try {
//
await validateForm(formProcessRef.value)
await formMainRef.value.validate()
@ -862,9 +921,15 @@ const submitForm = async () => {
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.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) {
@ -873,19 +938,38 @@ const submitForm = async () => {
return
}
//
const arr2 = data.value.process.filter(
(item) =>
{
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)))||
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.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.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))))
}
(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)))
)
})
console.log(99, arr2)
if (arr2 && arr2.length > 0) {
const str = arr2.map((item) => item.description).join(',')
@ -1025,7 +1109,6 @@ const searchTableSuccess = (formField, searchField, val, type, row) => {
data.value.dynamicUpdateName = val[0].description
}
}
}
//
const changeIsCapping = (e, item) => {
@ -1035,7 +1118,6 @@ const changeIsCapping = (e,item) => {
} else {
rules.value['inspectionCharacteristicsBaseVO.quantifyCapping'][0].required = false
}
}
//
const changeLowlimit = (e, item) => {
@ -1061,7 +1143,9 @@ const copy = (item)=>{
newItem.name = data.value.process[data.value.process.length - 1].name + 1
newItem.code = ''
newItem.id = ''
newItem.sequenceCode =data.value?.process[data.value?.process?.length-1]?.sequenceCode? parseInt(data.value.process[data.value.process.length-1].sequenceCode) + 1 : ''
newItem.sequenceCode = data.value?.process[data.value?.process?.length - 1]?.sequenceCode
? parseInt(data.value.process[data.value.process.length - 1].sequenceCode) + 1
: ''
newItem.inspectionCharacteristicsBaseVO.code = ''
newItem.inspectionCharacteristicsBaseVO.id = ''
newItem.inspectionCharacteristicsBaseVO.concurrencyStamp = 1
@ -1069,7 +1153,9 @@ const copy = (item)=>{
editableTabsValue.value = newItem.name
}
//
const dynamicUpdateCodeBlur = async () => {
const mainblur = async (field, pageApi, item) => {
const dataObj = item ? item.inspectionCharacteristicsBaseVO : data.value
if (dataObj[field + 'Code']) {
const _searchCondition = {}
const filters: any[] = []
filters.push(
@ -1081,27 +1167,43 @@ const dynamicUpdateCodeBlur = async () => {
{
column: 'code',
action: '==',
value: data.value?.dynamicUpdateCode?.trim()
value: dataObj[field + 'Code']?.trim()
}
)
//
_searchCondition.isSearch = true
_searchCondition.filters = filters
const array = await DynamicRuleApi.getDynamicRulePage(_searchCondition)
const array = await pageApi(_searchCondition)
Butttondata = [
defaultButtons.formSaveBtn(null), //
defaultButtons.formCloseBtn(null) //
]
count.value++
const obj = array.list[0]
if (obj) {
data.value.dynamicUpdateName = obj.description
dataObj[field + 'Name'] = obj.description
} else {
message.alert('暂无数据')
data.value.dynamicUpdateCode =''
data.value.dynamicUpdateName =''
dataObj[field + 'Code'] = ''
dataObj[field + 'Name'] = ''
}
} else {
dataObj[field + 'Name'] = ''
Butttondata = [
defaultButtons.formSaveBtn(null), //
defaultButtons.formCloseBtn(null) //
]
count.value++
}
}
//
const inspectionMethodCodeBlur = async () => {
const count = ref(0)
const mainFocus = () => {
Butttondata = [
defaultButtons.formSaveBtn({ disabled: true }), //
defaultButtons.formCloseBtn(null) //
]
count.value++
}
</script>
<style scoped>
.small-title {

Loading…
Cancel
Save