From 46df49c08231721a3ff5bbcc1ad7724340ea68b9 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Thu, 13 Jun 2024 00:26:31 +0800 Subject: [PATCH] uu --- common/validate.js | 2 +- .../deliveryDeal/problemsRegisteScanning.vue | 19 ++++++++---- pages/deliveryDeal/stayScanning.vue | 30 +++++++++++++------ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/common/validate.js b/common/validate.js index d59cf2d..767f6df 100644 --- a/common/validate.js +++ b/common/validate.js @@ -4,7 +4,7 @@ const checkParams = (param, validConfig)=> { let errMsg = '' Object.keys(validConfig).map(key=> { const itemConf = validConfig[key] - if(!errMsg && itemConf.required && !param[key]) { + if(!errMsg && itemConf.required && (!param[key] || param[key]?.length == 0)) { errMsg = itemConf.requiredMsg || `${itemConf.label}不能为空` } let customerValidMsg = itemConf?.validMsgFun?.({ val: param }) diff --git a/pages/deliveryDeal/problemsRegisteScanning.vue b/pages/deliveryDeal/problemsRegisteScanning.vue index 65aad4d..5e93abf 100644 --- a/pages/deliveryDeal/problemsRegisteScanning.vue +++ b/pages/deliveryDeal/problemsRegisteScanning.vue @@ -52,6 +52,7 @@ import { debounce } from "@/common/util" import * as apiService from "@/common/api" import BpeGoodphotoTmp from "@/components/buns-post-edit-templates/bpe-goodphoto-tmp" + import { checkParams } from "@/common/validate" export default { components:{ BpeGoodphotoTmp }, @@ -69,7 +70,14 @@ problemType: '', // 问题类型 problemCause: "", // 问题件原因 sendSiteCode: "", // 通知网点代码 - filePath: "", // 图片路径 + filePath: [], // 图片路径 + }, + submitValidConfig: { + billCode: { required: true, requiredMsg: '运单号不能为空' }, + problemType: { required: true, requiredMsg: '问题类型不能为空' }, + problemCause: { required: true, requiredMsg: '问题描述不能为空' }, + sendSiteCode: { required: true, requiredMsg: '网点不能为空' }, + filePath: { required: true, requiredMsg: '图片不能为空' }, }, } }, @@ -100,9 +108,10 @@ ] }, async handleSubmit() { - let params = JSON.parse(JSON.stringify(this.submitParam)); - params.filePath = params.filePath?.join?.(",") || '' - await apiService.registerProblemInfo({ ...params, _loading: true }) + await checkParams(this.submitParam, this.submitValidConfig) + let extParams = {} + extParams.filePath = this.submitParam.filePath?.join?.(",") || '' + await apiService.registerProblemInfo({ ...this.submitParam, ...extParams, _loading: true }) this.showToast('操作成功') this.resetForm() // this.goBack() @@ -110,7 +119,7 @@ resetForm() { this.submitParam.billCode = '' this.submitParam.sendSiteCode = '' - this.submitParam.filePath = '' + this.submitParam.filePath = [] }, } } diff --git a/pages/deliveryDeal/stayScanning.vue b/pages/deliveryDeal/stayScanning.vue index f1e81bb..d9c01e8 100644 --- a/pages/deliveryDeal/stayScanning.vue +++ b/pages/deliveryDeal/stayScanning.vue @@ -10,6 +10,10 @@ iconPos="left"> + + + @@ -36,25 +40,31 @@ import * as apiService from "@/common/api" import BpeGoodphotoTmp from "@/components/buns-post-edit-templates/bpe-goodphoto-tmp" import { scanTypeEnum, getScanParams, ansScanResponse } from "@/common/scanUtil" + import { checkParams } from "@/common/validate" - import { - goto - } from "@/common/untool" export default { components:{ BpeGoodphotoTmp }, props: { }, computed: { - + dicData() { + return this.$store.getters.dicData + }, }, data() { return { submitParam: { billCode: '', - picUrl: '', - remark: '' + keepType: '', + picUrl: [], + remark: '', + }, + submitValidConfig: { + billCode: { required: true, requiredMsg: '运单号不能为空' }, + keepType: { required: true, requiredMsg: '留仓类型不能为空' }, + // picUrl: { required: true, requiredMsg: '图片不能为空' }, + // remark: { required: true, requiredMsg: '备注不能为空' }, }, - } }, onShareAppMessage() { @@ -73,8 +83,10 @@ }, async handleSubmit() { - this.submitParam.picUrl = this.submitParam.picUrl?.join?.(",") || '' - let scnParam = getScanParams(scanTypeEnum.liuCang, { ...this.submitParam }) + await checkParams(this.submitParam, this.submitValidConfig) + let extParams = {} + extParams.picUrl = this.submitParam.picUrl?.join?.(",") || '' + let scnParam = getScanParams(scanTypeEnum.liuCang, { ...this.submitParam, ...extParams }) let res = await apiService.scanRecord({...scnParam, _loading: true}) let { bl, resItem } = ansScanResponse({ res, title: "留仓" }) if(bl) {