From 417a382745ec73ce569c631151a5f33cd160710f Mon Sep 17 00:00:00 2001 From: zhaoyiran Date: Thu, 11 Apr 2024 11:35:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/qms/samplingProcess/index.vue | 59 +++++++++++++++---- .../samplingProcess/samplingProcess.data.ts | 22 ++++--- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/views/qms/samplingProcess/index.vue b/src/views/qms/samplingProcess/index.vue index cc083c0e4..185dab487 100644 --- a/src/views/qms/samplingProcess/index.vue +++ b/src/views/qms/samplingProcess/index.vue @@ -66,7 +66,6 @@ import * as defaultButtons from '@/utils/disposition/defaultButtons' import TableHead from '@/components/TableHead/src/TableHead.vue' import ImportForm from '@/components/ImportForm/src/ImportForm.vue' import Detail from '@/components/Detail/src/Detail.vue' -import {getSamplingScheme} from "@/api/qms/samplingProcess"; defineOptions({ name: 'SamplingProcess' }) @@ -150,8 +149,56 @@ const buttonTableClick = async (val, row) => { /** 添加/修改操作 */ const basicFormRef = ref() -const openForm = (type: string, row?: any) => { +const openForm = async (type: string, row?: any) => { basicFormRef.value.open(type, row) + SamplingProcess.allSchemas.formSchema.forEach(item=>{ + if(item.field =="sampleType"){ + if(row.sampleType == "1"){ + SamplingProcess.allSchemas.formSchema.forEach(item=>{ + if(item.field == "sampleSize"){ + item.label='样品量' + item.component = 'Input' + item.componentProps.disabled = true + } + if(item.field == "sampleProgCode"){ + item.componentProps.disabled = true + } + }) + }else if(row.sampleType == "2"){ + SamplingProcess.allSchemas.formSchema.forEach(item=>{ + if(item.field == "sampleSize"){ + item.label='样品量(%)' + item.component = 'Input' + item.componentProps.disabled = false + } + if(item.field == "sampleProgCode"){ + item.componentProps.disabled = true + } + }) + }else if(row.sampleType == "3"){ + SamplingProcess.allSchemas.formSchema.forEach(item=>{ + if(item.field == "sampleSize"){ + item.label='样品量' + item.component = 'Input' + item.componentProps.disabled = false + } + if(item.field == "sampleProgCode"){ + item.componentProps.disabled = true + } + }) + }else if(row.sampleType == "4"){ + SamplingProcess.allSchemas.formSchema.forEach(item=>{ + if(item.field == "sampleSize"){ + item.componentProps.disabled = true + } + if(item.field == "sampleProgCode"){ + item.component = 'Select' + item.componentProps.disabled = false + } + }) + } + } + }) } // form表单提交 @@ -263,13 +310,6 @@ const onChange =async (field,value)=>{ } }) }else if(field == 'sampleType'&& value == '4'){ - const data = await SamplingProcessApi.getSamplingScheme() - const options = data.map(item=>{ - return{ - value:item.code, - label:item.description, - } - }) SamplingProcess.allSchemas.formSchema.forEach(item=>{ if(item.field == "sampleSize"){ item.componentProps.disabled = true @@ -277,7 +317,6 @@ const onChange =async (field,value)=>{ if(item.field == "sampleProgCode"){ item.component = 'Select' item.componentProps.disabled = false - item.componentProps.options = options } }) } diff --git a/src/views/qms/samplingProcess/samplingProcess.data.ts b/src/views/qms/samplingProcess/samplingProcess.data.ts index 02c4b6b32..eed4addcb 100644 --- a/src/views/qms/samplingProcess/samplingProcess.data.ts +++ b/src/views/qms/samplingProcess/samplingProcess.data.ts @@ -1,5 +1,6 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' +import {getSamplingScheme} from "@/api/qms/samplingProcess"; // 表单校验 export const SamplingProcessRules = reactive({ @@ -7,7 +8,7 @@ export const SamplingProcessRules = reactive({ evaluationMode: [required], description: [required], }) - +const samplingSchemeList = await getSamplingScheme() export const SamplingProcess = useCrudSchemas(reactive([ { label: '编码', @@ -56,19 +57,16 @@ export const SamplingProcess = useCrudSchemas(reactive([ field: 'sampleProgCode', sort: 'custom', form: { - component: 'Select' + component: 'Select', + componentProps: { + options: samplingSchemeList, + optionsAlias: { + labelField: 'description', + valueField: 'code' + }, + } }, }, - // { - // label: '是否可用', - // field: 'available', - // sort: 'custom', - // dictType: DICT_TYPE.TRUE_FALSE, - // dictClass: 'string', // 默认都是字符串类型其他暂不考虑 - // form: { - // component: 'Select' - // }, - // }, { label: '创建时间', field: 'createTime',