From a714879dc0fbca06b5feebc08416bb24f5e29a6b Mon Sep 17 00:00:00 2001 From: yunuo970428 <405378304@qq.com> Date: Fri, 16 Aug 2024 14:28:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/goods/product/productAdd.vue | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/views/goods/product/productAdd.vue b/src/views/goods/product/productAdd.vue index a25851b..9168aa9 100644 --- a/src/views/goods/product/productAdd.vue +++ b/src/views/goods/product/productAdd.vue @@ -189,13 +189,11 @@ export default { this.$message({ showClose: true, type: 'error', message: '原料列表不能为空' }) return } else { - if (this.formobj.list.length > 1) { - for (var i = 0; i < this.formobj.list.length; i++) { - if (this.formobj.list[i].materialCode === this.formobj.list[this.formobj.list.length - 1].materialCode) { - this.$message({ showClose: true, type: 'error', message: '原料列表中需选择不同的原料进行操作' }) - return - } - } + let materialCodes = this.formobj.list.map(item => item['materialCode']) + let materialCodeSet = new Set(materialCodes) + if (materialCodeSet.size !== materialCodes.length) { + this.$message({ showClose: true, type: 'error', message: '原料列表中需选择不同的原料进行操作' }) + return } } this.submitdisabled = true