From 306dc69b6e13ebfd9224a5464a4c44c716b20ee4 Mon Sep 17 00:00:00 2001 From: songguoqiang <765017469@qq.com> Date: Thu, 23 Nov 2023 18:01:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E7=89=88=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.test | 8 +- src/api/spc/itembasic/index.ts | 2 +- .../detectionTemplate.data.ts | 102 +++++++++++------- src/views/spc/detectiontemplate/index.vue | 60 +++++++++-- src/views/spc/itembasic/itembasic.data.ts | 4 +- 5 files changed, 123 insertions(+), 53 deletions(-) diff --git a/.env.test b/.env.test index c556152..f14a81a 100644 --- a/.env.test +++ b/.env.test @@ -4,10 +4,10 @@ NODE_ENV=test VITE_DEV=false # 请求路径 -VITE_BASE_URL='http://dev.ccwin-in.com:26100/api' +VITE_BASE_URL='http://192.168.20.252:26100/api' # 上传路径 -VITE_UPLOAD_URL='http://dev.ccwin-in.com:26100/api/admin-api/infra/file/upload' +VITE_UPLOAD_URL='http://192.168.20.252:26100/api/admin-api/infra/file/upload' # 接口前缀 VITE_API_BASEPATH= @@ -31,7 +31,7 @@ VITE_BASE_PATH=/ VITE_OUT_DIR=dist-test # 自定义接口路径 -VITE_INTERFACE_URL='http://dev.ccwin-in.com:26101/magic/web/index.html' +VITE_INTERFACE_URL='http://192.168.20.252:26101/magic/web/index.html' # 积木报表请求路径 -VITE_JMREPORT_BASE_URL='http://dev.ccwin-in.com:26101' +VITE_JMREPORT_BASE_URL='http://192.168.20.252:26101' diff --git a/src/api/spc/itembasic/index.ts b/src/api/spc/itembasic/index.ts index f50d2f9..b000c8c 100644 --- a/src/api/spc/itembasic/index.ts +++ b/src/api/spc/itembasic/index.ts @@ -88,4 +88,4 @@ export const selectItems = async () => { export const selectItemsByProjectCode = async (code:String) => { return await request.get({ url: `/spc/itembasic/selectItemsByProjectCode?code=` + code}) -} \ No newline at end of file +} diff --git a/src/views/spc/detectiontemplate/detectionTemplate.data.ts b/src/views/spc/detectiontemplate/detectionTemplate.data.ts index d15bb85..66f6f0d 100644 --- a/src/views/spc/detectiontemplate/detectionTemplate.data.ts +++ b/src/views/spc/detectiontemplate/detectionTemplate.data.ts @@ -1,5 +1,7 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import { dateFormatter } from '@/utils/formatTime' +import * as ItembasicApi from '@/api/spc/itembasic/index' +import {Itembasic} from '@/views/spc/itembasic/itembasic.data' // 表单校验 export const DetectionTemplateRules = reactive({ @@ -8,35 +10,59 @@ export const DetectionTemplateRules = reactive({ export const DetectionTemplate = useCrudSchemas(reactive([ { - label: '物料code', - field: 'itemCode', + label: '物料编码', + field: 'itemCode',//传第给后端字段名称 sort: 'custom', + table: { + width: 150, + fixed: 'left' + }, isSearch: true, + isTable:true, + form: { + // labelMessage: '信息提示说明!!!', + componentProps: { + isSearchList: true, // 开启查询弹窗 + searchListPlaceholder: '请选择物料编码', // 输入框占位文本 + searchField: 'code', // 查询弹窗赋值字段 + searchTitle: '物料信息', // 查询弹窗标题 + searchAllSchemas: Itembasic.allSchemas, // 查询弹窗所需类 + searchPage: ItembasicApi.getItembasicPage // 查询弹窗所需分页方法 + } + } + }, + + { + label: '物料名称', + field: 'itemName', + sort: 'custom', + isSearch: true, + isTable:true, + form: { + // labelMessage: '信息提示说明!!!', + componentProps: { + disabled:true + } + } }, + + { + label: '项目名称', + field: 'projectName', + sort: 'custom', + form: { + // labelMessage: '信息提示说明!!!', + componentProps: { + disabled:true + } + } + }, + { label: '模版名称', field: 'name', sort: 'custom', - isSearch: true }, - // { - // label: '描述', - // field: 'desc', - // sort: 'custom', - // isSearch: false - // }, - // { - // label: '是否可用', - // field: 'available', - // sort: 'custom', - // isSearch: false, - // }, - // { - // label: '版本号', - // field: 'version', - // sort: 'custom', - // isSearch: true - // }, { label: '备注', field: 'remark', @@ -92,24 +118,6 @@ export const DetectionTemplate = useCrudSchemas(reactive([ isTable:false, isForm:false }, - // { - // label: '扩展属性', - // field: 'extraProperties', - // sort: 'custom', - // isSearch: true - // }, - // { - // label: '并发乐观锁', - // field: 'concurrencyStamp', - // sort: 'custom', - // isSearch: true - // }, - // { - // label: '地点ID', - // field: 'siteId', - // sort: 'custom', - // isSearch: true - // }, { label: '物料类型', field: 'itemType', @@ -138,3 +146,19 @@ export const DetectionTemplate = useCrudSchemas(reactive([ } } ])) + +// 表单校验 +export const rules = reactive({ + itemCode: [ + { required: true, message: '请选择物料编码', trigger: 'blur' } + ], + itemName: [ + { required: true, message: '请输入物料名称', trigger: 'blur' } + ], + projectName: [ + { required: true, message: '请输入项目名称', trigger: 'blur' } + ], + itemType: [ + { required: true, message: '请选择物料类型', trigger: 'change' } + ], +}) diff --git a/src/views/spc/detectiontemplate/index.vue b/src/views/spc/detectiontemplate/index.vue index 5f107df..96c7a32 100644 --- a/src/views/spc/detectiontemplate/index.vue +++ b/src/views/spc/detectiontemplate/index.vue @@ -41,8 +41,8 @@ import download from '@/utils/download' -import { DetectionTemplate,DetectionTemplateRules } from './detectionTemplate.data' +import { DetectionTemplate,DetectionTemplateRules,rules } from './detectionTemplate.data' import * as DetectionTemplateApi from '@/api/spc/detectionTemplate' import * as defaultButtons from '@/utils/disposition/defaultButtons' // import TableHead from '@/components/TableHead/src/TableHead.vue' @@ -156,14 +156,60 @@ const openForm = (type: string, row?: any) => { } // 查询页面返回 -const searchTableSuccess = (formField, searchField, val, formRef) => { +const searchTableSuccess = (formField, searchField, val, formRef,type,row) => { + // nextTick(() => { + // const setV = {} + // setV[formField] = val[0][searchField] + // formRef.setValues(setV) + // }) nextTick(() => { - const setV = {} - setV[formField] = val[0][searchField] - formRef.setValues(setV) + if (type == 'tableForm') { + // 子表查询页赋值 + row[formField] = val[0][searchField] + row['poLine'] = val[0]['poLine'] + row['batch'] = val[0]['toBatch'] + row['altBatch'] = val[0]['altBatch'] + row['itemCode'] = val[0]['itemCode'] + row['itemName'] = val[0]['itemName'] + row['itemDesc1'] = val[0]['itemDesc1'] + row['itemDesc2'] = val[0]['itemDesc2'] + row['projectCode'] = val[0]['projectCode'] + row['qty'] = val[0]['qty'] + row['uom'] = val[0]['uom'] + } else { + // 主表查询页赋值 + const setV = {} + setV[formField] = val[0][searchField] + setV['itemName'] = val[0]['name'] + setV['projectName'] = val[0]['projectName'] + formRef.setValues(setV) + } }) } +const formsSuccess = async (formType,data) => { + var isHave =DetectionTemplate.allSchemas.formSchema.some(function (item) { + return item.field === 'activeTime' || item.field === 'expireTime'; + }); + if(isHave){ + if(data.activeTime && data.expireTime && data.activeTime >=data.expireTime){ + message.error('失效时间要大于生效时间') + return; + } + } + if(data.activeTime==0)data.activeTime = null; + if(data.expireTime==0)data.expireTime = null; + if (formType === 'create') { + await DetectionTemplateApi.createDetectionTemplate(data) + message.success(t('common.createSuccess')) + } else { + await DetectionTemplateApi.updateDetectionTemplate(data) + message.success(t('common.updateSuccess')) + } + basicFormRef.value.dialogVisible = false + getList() +} + /** 详情操作 */ const openDetail = () => { router.push({ path: '/spc/templateitemdetails' }) diff --git a/src/views/spc/itembasic/itembasic.data.ts b/src/views/spc/itembasic/itembasic.data.ts index 538e6f8..93cabfb 100644 --- a/src/views/spc/itembasic/itembasic.data.ts +++ b/src/views/spc/itembasic/itembasic.data.ts @@ -124,10 +124,10 @@ export const Itembasic = useCrudSchemas(reactive([ // 表单校验 export const rules = reactive({ code: [ - { required: true, message: '请输入物料', trigger: 'blur' } + { required: true, message: '请输入物料编码', trigger: 'blur' } ], name: [ - { required: true, message: '请输入物料', trigger: 'blur' } + { required: true, message: '请输入物料名称', trigger: 'blur' } ], projcetCode: [