Browse Source

检验记录更新按钮添加包装列表

master_hella_20240701
zhang_li 7 months ago
parent
commit
1f5e393d8b
  1. 11
      src/views/qms/inspection/inspectionJob/addForm.vue
  2. 18
      src/views/qms/inspection/inspectionJob/index.vue
  3. 309
      src/views/qms/inspection/inspectionRecord/addForm.vue
  4. 62
      src/views/qms/inspection/inspectionRecord/index.vue
  5. 139
      src/views/qms/inspection/inspectionRecord/inspectionRecordMain.data.ts

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

@ -26,7 +26,7 @@
:maxHeight = "490"
:tableFields="tableAllSchemas.tableFormColumns"
:tableFormRules="tableFormRules"
:tableData="data.packageVOList"
:tableData="data.packageList"
:isShowButton="false"
:isShowReduceButton="false"
/>
@ -312,7 +312,6 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-if="item.samplingProcessRespVO.evaluationMode == 1" >
<el-form-item label="缺陷级别" required>
<el-select v-model="cur.defectLevel" placeholder="请选择缺陷级别" disabled>
@ -359,7 +358,6 @@
<SearchTable ref="searchTableRef" @searchTableSuccess="searchTableSuccess" />
</div>
</template>
<script setup lang="ts">
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import { getCurrentInstance } from 'vue'
@ -538,7 +536,7 @@ const open = async (type: string, row?: any, masterParmas?: any, titleName?: any
console.log(data.value)
let list = []
list = await InspectionJobDetailPageApi.getInspectionJobDetailList(row.id)
data.value.packageVOList = await InspectionJobMainApi.getInspectionJobPackageList(row.id)
data.value.packageList = await InspectionJobMainApi.getInspectionJobPackageList(row.id)
list.forEach((item, index) => {
editableTabsValue.value = index + 1
item.name = index + 1
@ -617,7 +615,6 @@ import type { TabPaneName } from 'element-plus'
const editableTabsValue = ref('1')
// const editableTabs = ref([])
const handleTabsEdit = (targetName: TabPaneName | undefined, action: 'remove' | 'add') => {
if (action === 'add') {
nameForm.value.name = ''
@ -724,7 +721,7 @@ const submitForm = async () => {
const validateForm1 = await tableFormRef.value.validateForm()
if (!validateForm1) return
let number = 0
data.value.packageVOList.forEach(cur=>{
data.value.packageList.forEach(cur=>{
number += parseFloat(cur.sampleAmount)
})
if(number > data.value.sampleTotalAmount){
@ -998,4 +995,4 @@ const changeQualitativeCode = (e, item, cur) => {
.el-tabs--left.el-tabs--border-card .el-tabs__item.is-left {
min-width: 120px !important;
}
</style>
</style>

18
src/views/qms/inspection/inspectionJob/index.vue

@ -28,7 +28,7 @@
<!-- 表单弹窗添加/修改 -->
<AddForm
ref="basicFormRef"
ref="formRef"
basicFormWidth="80"
:formAllSchemasFeatures="InspectionTemplateFeatures.allSchemas"
:formAllSchemasProcess="InspectionTemplateProcess.allSchemas"
@ -165,7 +165,7 @@
defaultButtons.mainListJobCloBtn({hide:isShowMainButton(row,['1']),hasPermi:'wms:purchasereceipt-job-main:close'}), //
// defaultButtons.mainListJobAbaBtn({hide:isShowMainButton(row,['2'])}), //
defaultButtons.mainListJobExeBtn({hide:isShowMainButton(row,['2'])}), //
defaultButtons.mainListPackageBtn({hide:isShowMainButton(row,['2'])}), //
defaultButtons.mainListPackageBtn(null), //
]
}
const listTableRef = ref()
@ -183,11 +183,11 @@ const listTableRef = ref()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = async (type : string, row ?: number) => {
tableData.value = [] //
formRef.value.open(type, row)
}
// const formRef = ref()
// const openForm = async (type : string, row ?: number) => {
// tableData.value = [] //
// formRef.value.open(type, row)
// }
/** 详情操作 */
const detailRef = ref()
@ -196,9 +196,9 @@ const listTableRef = ref()
}
//
const basicFormRef = ref()
const formRef = ref()
const execute = async (type : string, row ?: number) => {
basicFormRef.value.open(type, row)
formRef.value.open(type, row)
}
/** 删除按钮操作 */
const handleDelete = async (id : number) => {

309
src/views/qms/inspection/inspectionRecord/addForm.vue

@ -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) // 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: []
})
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>

62
src/views/qms/inspection/inspectionRecord/index.vue

@ -27,21 +27,30 @@
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<BasicForm ref="formRef" @success="getList" :rules="InspectionRecordMainRules"
:formAllSchemas="InspectionRecordMain.allSchemas" :tableAllSchemas="InspectionRecordDetail.allSchemas"
:tableFormRules="InspectionRecordDetailRules" :tableData="tableData"
<!-- <BasicForm ref="formRef"
@success="getList"
:rules="InspectionRecordMainRules"
:formAllSchemas="InspectionRecordMain.allSchemas"
:tableData="tableData"
:tableAllSchemas="InspectionJobPackage.allSchemas"
:tableFormRules="InspectionJobPackageRules"
:apiUpdate="InspectionRecordMainApi.updateInspectionRecordMain"
:apiCreate="InspectionRecordMainApi.createInspectionRecordMain" :isBusiness="true" @handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable" @searchTableSuccess="searchTableSuccess" @submitForm="submitForm" />
:apiCreate="InspectionRecordMainApi.createInspectionRecordMain"
<!-- 详情 -->
<!-- <Detail ref="detailRef" :isBasic="false" :allSchemas="InspectionRecordMain.allSchemas"
:detailAllSchemas="InspectionRecordDetail.allSchemas" :detailAllSchemasRules="InspectionRecordDetailRules"
:apiCreate="InspectionRecordDetailApi.createInspectionRecordDetail"
:apiUpdate="InspectionRecordDetailApi.updateInspectionRecordDetail"
:apiPage="InspectionRecordDetailApi.getInspectionRecordDetailPage"
:apiDelete="InspectionRecordDetailApi.deleteInspectionRecordDetail"
@searchTableSuccessDetail="searchTableSuccessDetail" :isShowAddBtn="false" :detailButtonIsShow="true" /> -->
@handleAddTable="handleAddTable"
@handleDeleteTable="handleDeleteTable"
@searchTableSuccess="searchTableSuccess"
@submitForm="submitForm" /> -->
<AddForm
ref="formRef"
basicFormWidth="80"
:tableAllSchemas="InspectionRecordPackage.allSchemas"
:tableFormRules="InspectionRecordPackageRules"
:rules="InspectionRecordMainRules"
:formAllSchemas="InspectionRecordMain.allSchemas"
@submitForm="submitForm"
@onChange='onChange'
/>
<Detail
ref="detailRef" :isBasic="false" :allSchemas="InspectionRecordMain.allSchemas"
:detailAllSchemas="InspectionRecordDetail.allSchemas" :detailAllSchemasRules="InspectionRecordDetailRules"
@ -57,13 +66,14 @@
<script setup lang="ts">
import download from '@/utils/download'
import { InspectionRecordMain, InspectionRecordMainRules, InspectionRecordDetail, InspectionRecordDetailRules } from './inspectionRecordMain.data'
import { InspectionJobPackage} from '../inspectionJob/inspectionJobMain.data'
import { InspectionRecordMain, InspectionRecordMainRules, InspectionRecordDetail, InspectionRecordDetailRules,InspectionRecordPackage, InspectionRecordPackageRules} from './inspectionRecordMain.data'
// import { InspectionJobPackage,InspectionJobPackageRules} from '../inspectionJob/inspectionJobMain.data'
import * as InspectionRecordMainApi from '@/api/qms/inspectionRecord/inspectionRecordMain'
import * as InspectionRecordDetailApi from '@/api/qms/inspectionRecord/inspectionRecordDetail'
import * as defaultButtons from '@/utils/disposition/defaultButtons'
import listTable from '@/components/listTable/src/listTable.vue'
import TableHead from '@/components/TableHead/src/TableHead.vue'
import AddForm from './addForm.vue'
import Detail from './detail.vue'
//
@ -173,6 +183,7 @@
defaultButtons.mainListEditBtn(null), //
// defaultButtons.mainListDeleteBtn(null), //
defaultButtons.mainListOrderPubBtn(null), //
defaultButtons.mainListPackageBtn(null), //
]
}
@ -197,7 +208,7 @@
openForm('update', row)
}else if (val == 'mainPackage') { //
const list = await InspectionRecordMainApi.getInspectionRecordPackageList(row.id)
listTableRef.value.openPackage(row,'包装信息',InspectionJobPackage.allSchemas.tableColumns,list)
listTableRef.value.openPackage(row,'包装信息',InspectionRecordPackage.allSchemas.tableColumns,list)
}else if (val == 'delete') { //
handleDelete(row.id)
}else if (val == 'mainOrderPub') { //
@ -278,8 +289,23 @@
const handleDeleteTable = (item, index) => {
tableData.value.splice(index, 1)
}
//
const count = ref(0)
const onChange = (field, cur)=>{
console.log(field, cur)
// if(field=='useDecision'){
// if(cur == 1){
// InspectionRecordPackage.allSchemas.tableFormColumns.forEach(item=>{
// if(item.field == 'qualifiedAmount'){
// console.log(item.disabled)
// item.disabled = true
// console.log(item.disabled)
// }
// })
// }
// }
console.log(InspectionRecordPackage.allSchemas.tableFormColumns)
}
// //
const submitForm = async (formType, data) => {
data.subList = tableData.value //
try {

139
src/views/qms/inspection/inspectionRecord/inspectionRecordMain.data.ts

@ -2,6 +2,7 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter2 } from '@/utils/formatTime'
import { validateHanset, validateEmail } from '@/utils/validator'
import { dateFormatter } from '@/utils/formatTime'
import {validateTwoNum } from '@/utils/validator'
const { t } = useI18n() // 国际化
/**
@ -398,25 +399,7 @@ export const InspectionRecordMain = useCrudSchemas(reactive<CrudSchema[]>([
//表单校验
export const InspectionRecordMainRules = reactive({
number: [required],
applicationCode: [required],
taskCode: [required],
supplierCode: [required],
materialCode: [required],
batch: [required],
inspectionSchemeCode: [required],
inspectionBatch: [required],
inspectionBatchAmount: [required],
sampleTatalAmount: [required],
inspectionType: [required],
inspectionBatchSource: [required],
orderCode: [required],
orderRow: [required],
inspectionStage: [required],
inspectionStringency: [required],
useDecision: [required],
inspectionLevel: [required],
available: [required],
})
@ -569,3 +552,123 @@ export const InspectionRecordDetailRules = reactive({
isDestroyInspection: [required],
available: [required],
})
/**
* @returns {Array}
*/
export const InspectionRecordPackage = useCrudSchemas(reactive<CrudSchema[]>([
{
label: '编码',
field: 'number',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '包装号',
field: 'packageCode',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '包装规格',
field: 'packageSpecificationCode',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '数量',
field: 'amount',
sort: 'custom',
isSearch: true,
form: {
component: 'InputNumber',
value: 0
},
tableForm:{
disabled:true
}
},
{
label: '计量单位',
field: 'measuringUnit',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '采样数量',
field: 'sampleAmount',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '合格数量',
field: 'qualifiedAmount',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '不合格数量',
field: 'noQualifiedAmount',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '破坏数量',
field: 'destroyAmount',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
},
{
label: '冻结数量',
field: 'frozenAmount',
sort: 'custom',
isSearch: true,
tableForm:{
disabled:true
}
}
]))
//表单校验
export const InspectionRecordPackageRules = reactive({
qualifiedAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
],
frozenAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
],
destroyAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
],
noQualifiedAmount: [
required,
{ validator:validateTwoNum, message: '小数点后最多2位', trigger: 'blur'}
],
})
Loading…
Cancel
Save