Browse Source

首件检验

hella_online_20240829
zhang_li 4 months ago
parent
commit
acd2d24dd1
  1. 1472
      src/views/qms/inspectionRecord/addForm.vue
  2. 56
      src/views/qms/inspectionRecord/index.vue
  3. 312
      src/views/qms/inspectionRecord/useAddForm.vue

1472
src/views/qms/inspectionRecord/addForm.vue

File diff suppressed because it is too large

56
src/views/qms/inspectionRecord/index.vue

@ -27,7 +27,7 @@
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<AddForm
<UseAddForm
ref="formRef"
basicFormWidth="80"
:tableAllSchemas="InspectionRecordPackage.allSchemas"
@ -36,6 +36,17 @@
:formAllSchemas="InspectionRecordMain.allSchemas"
@submitForm="submitForm"
/>
<!-- 新增 -->
<AddForm
ref="basicFormRef"
basicFormWidth="80"
:formAllSchemasFeatures="InspectionTemplateFeatures.allSchemas"
:formAllSchemasProcess="InspectionTemplateProcess.allSchemas"
:formAllSchemasMain="InspectionTemplateMain.allSchemas"
:rules="InspectionTemplateRules"
@submitForm="submitForm"
/>
<Detail
ref="detailRef" :isBasic="false" :allSchemas="InspectionRecordMain.allSchemas"
:detailAllSchemas="InspectionRecordDetail.allSchemas" :detailAllSchemasRules="InspectionRecordDetailRules"
@ -60,8 +71,13 @@
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import ListTable from '@/components/ListTable/src/ListTable.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import UseAddForm from './useAddForm.vue'
import AddForm from './addForm.vue'
import Detail from './detail.vue'
import Detail from './detail.vue'
import { InspectionTemplateMain,InspectionTemplateProcess,InspectionTemplateFeatures,InspectionTemplateRules } from '../inspectionTemplate/inspectionTemplate.data'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
//
@ -100,16 +116,29 @@ import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
const { getList, setSearchParams } = tableMethods
//
const HeadButttondata = [
// defaultButtons.defaultAddBtn(null), //
let HeadButttondata = []
//
if (routeName.value == 'inspectionRecordMain') {
// [
HeadButttondata = [
// defaultButtons.defaultExportBtn(null), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
]
}else if (routeName.value == 'inspectionRecordMainFirst') {
// [
HeadButttondata = [
defaultButtons.defaultAddBtn(null), //
// defaultButtons.defaultExportBtn(null), //
defaultButtons.defaultFreshBtn(null), //
defaultButtons.defaultFilterBtn(null), //
defaultButtons.defaultSetBtn(null), //
]
]
}
//
const buttonBaseClick = (val, item) => {
//
const buttonBaseClick = (val, item) => {
if (val == 'add') { //
openForm('create')
} else if (val == 'import') { //
@ -167,7 +196,7 @@ import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
}
})
}
openForm('update', row)
openUseForm('update', row)
}else if (val == 'mainPackage') { //
list.value = await InspectionRecordPackageApi.getInspectionRecordPackageList(row.id)
list.value.forEach(item=>{
@ -184,10 +213,15 @@ import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
handleOrderPub(row)
}
}
/** 添加/修改操作 */
const formRef = ref()
/** 添加/修改操作 */
const basicFormRef = ref()
const openForm = async (type : string, row ?: number) => {
tableData.value = [] //
basicFormRef.value.open(type, row)
}
/** 使用决策操作操作 */
const formRef = ref()
const openUseForm = async (type : string, row ?: number) => {
tableData.value = [] //
formRef.value.open(type, row)
}

312
src/views/qms/inspectionRecord/useAddForm.vue

@ -0,0 +1,312 @@
<template>
<div>
<Dialog
:title="dialogTitle"
v-model="dialogVisible"
:width="dialogWidth"
:close-on-click-modal="false"
:vLoading="formLoading"
>
<div style="max-height: 80vh; overflow-y: auto; padding: 0px 20px">
<Form
ref="formMainRef"
:rules="rules"
:schema="formSchema"
:is-col="true"
@onChange="onChange"
/>
<div class="small-title">包装列表</div>
<div style="border:1px solid #dedede;margin-bottom:20px;display: flex;">
<TableForm
ref="tableFormRef"
style="width:100%;"
:maxHeight = "490"
:tableFields="tableSchemas.tableFormColumns"
:tableFormRules="tableFormRules"
:tableData="data.packageList"
:isShowButton="false"
:isShowReduceButton="false"
@inputStringBlur="tableFormBlur"
/>
</div>
</div>
<template #footer>
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" />
</template>
</Dialog>
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
</div>
</template>
<script setup lang="ts">44
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { getCurrentInstance } from 'vue'
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { SearchTable } from '@/components/SearchTable'
import * as InspectionRecordMainApi from '@/api/qms/inspectionRecord/inspectionRecordMain'
import * as InspectionRecordPackageApi from '@/api/qms/inspectionRecord/InspectionRecordPackage/InspectionRecordPackage'
const { proxy } = getCurrentInstance()
const message = useMessage() //
const props = defineProps({
//
basicFormWidth: {
type: String,
default: ''
},
//
footButttondata: {
type: Array,
required: false,
default: null
},
//
formAllSchemas: {
type: Object,
required: true,
default: null
},
// rules
rules: {
type: Object,
required: true,
default: null
},
//
tableAllSchemas: {
type: Array,
required: true,
default: null
},
tableFormRules: {
type: Array,
required: true,
default: null
},
})
const { t } = useI18n() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const dialogWidth = ref()
const formSchema = ref(props.formAllSchemas?.formSchema)
const tableSchemas = ref(props.tableAllSchemas)
const tableFormRules = ref(props.tableFormRules)
const formMainRef = ref()
const data = ref({
code: '',
itemCode: '',
version: '',
testTypeCode: '',
programmeTemplateCode: '',
splitRule: '',
aql: '',
inspectionLevel: '',
effectiveDate: '',
expirationDate: '',
available: 'TRUE',
subList: []
})
if (props.basicFormWidth) {
dialogWidth.value = props.basicFormWidth + '%'
} else {
dialogWidth.value = props.isBusiness ? '60%' : '40%'
}
/** 打开弹窗 */
const open = async (type: string, row?: any, masterParmas?: any, titleName?: any) => {
dialogTitle.value = t('action.applyDecision')
formType.value = type
if (row) {
data.value = JSON.parse(JSON.stringify(row))
data.value.packageList = await InspectionRecordPackageApi.getInspectionRecordPackageList(row.id)
data.value.packageList.forEach(item=>{
item.qualifiedAmount = item.qualifiedAmount?item.qualifiedAmount:0
item.noQualifiedAmount = item.noQualifiedAmount?item.noQualifiedAmount:0
item.destroyAmount = item.destroyAmount?item.destroyAmount:0
item.frozenAmount = item.frozenAmount?item.frozenAmount:0
})
dialogVisible.value = true
tableSchemas.value.tableFormColumns.map(item=>{
item.tableForm.disabled = true
})
// 1使
if(row.estimateCode == 1){
data.value.useDecision = '1'
}else{
data.value.useDecision =''
}
// ==
if(data.value.useDecision == 1){
data.value.packageList.forEach(item=>{
item.qualifiedAmount = item.amount
})
}
//
else if(data.value.useDecision == 2 || data.value.useDecision == 6){
tableSchemas.value.tableFormColumns.map(item=>{
if(item.field == 'noQualifiedAmount'){
item.tableForm.disabled = false
}else{
item.tableForm.disabled = true
}
})
}
//
else if(data.value.useDecision == 3){
data.value.packageList.forEach(item=>{
item.noQualifiedAmount = item.amount
})
}
else if(data.value.useDecision == 4){
data.value.packageList.forEach(item=>{
item.frozenAmount = item.amount
})
}
nextTick(() => {
formMainRef.value.setValues( data.value)
})
}
dialogVisible.value = true
}
defineExpose({ open, dialogVisible, formLoading }) // open
// console.log(11,tableAllSchemas.value.tableFormColumns)
//
const emit = defineEmits([
'onChange',
'submitForm'
])
/** 弹窗按钮 */
let Butttondata: any = []
if (props.footButttondata) {
Butttondata = props.footButttondata
} else {
Butttondata = [
defaultButtons.formSaveBtn(null), //
defaultButtons.formCloseBtn(null) //
]
}
const onChange = (field, cur)=>{
if(field=='useDecision'){
tableSchemas.value.tableFormColumns.map(item=>{
item.tableForm.disabled = true
})
data.value.packageList.forEach(item=>{
item.qualifiedAmount =0
item.noQualifiedAmount =0
item.destroyAmount =0
item.frozenAmount =0
})
// ==
if(cur == 1){
data.value.packageList.forEach(item=>{
item.qualifiedAmount = item.amount
})
}
//
else if(cur == 2 || cur == 6){
data.value.packageList.forEach(item=>{
item.qualifiedAmount = item.amount
})
tableSchemas.value.tableFormColumns.map(item=>{
if(item.field == 'noQualifiedAmount'){
item.tableForm.disabled = false
}else{
item.tableForm.disabled = true
}
})
}
//
else if(cur == 3){
data.value.packageList.forEach(item=>{
item.noQualifiedAmount = item.amount
})
}
else if(cur == 4){
data.value.packageList.forEach(item=>{
item.frozenAmount = item.amount
})
}
}
}
//
const tableFormBlur = (field, val,row)=>{
if( row.amount < val){
row.noQualifiedAmount = row.amount
row.qualifiedAmount = 0
}else{
row.qualifiedAmount = row.amount - val
row.qualifiedAmount = row.qualifiedAmount.toFixed(6)
}
}
const buttonBaseClick = (val) => {
//
if (val == 'save') {
submitForm()
}
//
else if (val == 'close') {
dialogVisible.value = false
}
}
const tableFormRef = ref()
const submitForm = async () => {
try {
const elForm = unref(formMainRef)?.getElFormRef()
//
if (!elForm) return
const valid = await elForm.validate()
if (!valid) return
//
const validateForm1 = await tableFormRef.value.validateForm()
if (!validateForm1) return
const data1 = unref(formMainRef)?.formModel
data.value.useDecision = data1.useDecision
if(data1.useDecision == 2 || data1.useDecision == 6){
if(data.value.packageList.length>0){
let isBol = data.value.packageList.filter(cur=>parseFloat(cur.qualifiedAmount)+parseFloat(cur.noQualifiedAmount)!=parseFloat(cur.amount))
console.log(isBol)
if(isBol&&isBol.length>0){
message.error(`合格数量和不合格数量总和不等于数量`)
return
}
}
}
if (formType.value == 'create') {
//
emit('submitForm', formType.value, data.value)
} else {
// /
emit('submitForm', formType.value, data.value)
}
} catch {
console.log(111)
}
}
</script>
<style scoped>
.small-title {
font-weight: bold;
padding: 0px 10px 10px;
color: #1a8bfc;
font-size: 16px;
}
</style>
<style>
.el-tabs--left .el-tabs__header.is-left {
min-height: 700px !important;
min-width: 150px !important;
}
.el-tabs--left.el-tabs--border-card .el-tabs__item.is-left {
min-width: 120px !important;
}
</style>
Loading…
Cancel
Save