zhang_li
7 months ago
5 changed files with 487 additions and 52 deletions
@ -0,0 +1,309 @@ |
|||
<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" |
|||
/> |
|||
</div> |
|||
</div> |
|||
<template #footer> |
|||
<ButtonBase :Butttondata="Butttondata" @button-base-click="buttonBaseClick" /> |
|||
</template> |
|||
</Dialog> |
|||
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import { getCurrentInstance } from 'vue' |
|||
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' |
|||
import * as InspectionJobDetailPageApi from '@/api/qms/inspectionJob/inspectionJobDetail' |
|||
import { SearchTable } from '@/components/SearchTable' |
|||
import { SamplingProcess } from '@/views/qms/samplingProcess/samplingProcess.data' |
|||
// import { InspectionTemplateMain } from '@/views/qms/basicDataManage/inspectionTemplate/inspectionTemplate.data' |
|||
// import * as InspectionTemplateApi from '@/api/qms/inspectionTemplate' |
|||
// import { Itembasic } from '@/views/wms/basicDataManage/itemManage/itembasic/itembasic.data' |
|||
// import * as ItemBasicApi from '@/api/wms/itembasic' |
|||
import * as SamplingProcessApi from '@/api/qms/samplingProcess' //采样过程 |
|||
import * as InspectionMethodApi from '@/api/qms/inspectionMethod' //检验方法 |
|||
import { InspectionMethod } from '@/views/qms/inspectionMethod/inspectionMethod.data' //检验方法 |
|||
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 * as InspectionJobMainApi from '@/api/qms/inspectionJob/inspectionJobMain' |
|||
|
|||
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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|||
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: [] |
|||
}) |
|||
|
|||
const dialogVisibleName = ref(false) |
|||
const nameForm = ref({ |
|||
name: '' |
|||
}) |
|||
const nameRef = ref() |
|||
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) => { |
|||
if (titleName) { |
|||
dialogTitle.value = t('action.' + titleName) |
|||
} else { |
|||
dialogTitle.value = t('action.' + type) |
|||
} |
|||
formType.value = type |
|||
if (row) { |
|||
data.value = JSON.parse(JSON.stringify(row)) |
|||
data.value.packageList = await InspectionJobMainApi.getInspectionJobPackageList(row.id) |
|||
data.value.packageList.forEach(item=>{ |
|||
item.qualifiedAmount =0 |
|||
item.noQualifiedAmount =0 |
|||
item.destroyAmount =0 |
|||
item.frozenAmount =0 |
|||
}) |
|||
dialogVisible.value = true |
|||
tableSchemas.value.tableFormColumns.map(item=>{ |
|||
item.tableForm.disabled = true |
|||
}) |
|||
// 全部合格时合格数量==数量 |
|||
if(row.useDecision == 1){ |
|||
data.value.packageList.forEach(item=>{ |
|||
item.qualifiedAmount = item.amount |
|||
}) |
|||
} |
|||
// 全不合格只能输入不合格数量 |
|||
else if(row.useDecision == 2 || row.useDecision == 6){ |
|||
tableSchemas.value.tableFormColumns.map(item=>{ |
|||
if(item.field == 'qualifiedAmount' ||item.field == 'noQualifiedAmount'){ |
|||
item.tableForm.disabled = false |
|||
}else{ |
|||
item.tableForm.disabled = true |
|||
} |
|||
}) |
|||
} |
|||
// 全不合格只能输入不合格数量 |
|||
else if(row.useDecision == 3){ |
|||
data.value.packageList.forEach(item=>{ |
|||
item.noQualifiedAmount = item.amount |
|||
}) |
|||
} |
|||
else if(row.useDecision == 4){ |
|||
data.value.packageList.forEach(item=>{ |
|||
item.frozenAmount = item.amount |
|||
}) |
|||
} |
|||
nextTick(() => { |
|||
formMainRef.value.setValues(row) |
|||
}) |
|||
} |
|||
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){ |
|||
tableSchemas.value.tableFormColumns.map(item=>{ |
|||
if(item.field == 'qualifiedAmount' ||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 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 |
|||
console.log(33,data1) |
|||
if(data1.useDecision == 2 || data1.useDecision == 6){ |
|||
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…
Reference in new issue