From 2a9f0e7497d60d94795ce795863e0e24be5d44f9 Mon Sep 17 00:00:00 2001 From: xuxueyang <xuxy@fengyuntec.com> Date: 星期一, 15 七月 2024 18:27:57 +0800 Subject: [PATCH] 1 --- sub_pages/supplier/flower-manage/flower-add.vue | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 42 insertions(+), 8 deletions(-) diff --git a/sub_pages/supplier/flower-manage/flower-add.vue b/sub_pages/supplier/flower-manage/flower-add.vue index 2aff894..a3e96c9 100644 --- a/sub_pages/supplier/flower-manage/flower-add.vue +++ b/sub_pages/supplier/flower-manage/flower-add.vue @@ -225,19 +225,25 @@ bannerList: [], //str[] video: '', level: '', //FLOWER_LEVEL - price: 0.00, - stock: 0, + price: '', + stock: '', params: [], //id,value }, requireFields: [{ name: '商品分类', key: 'category' - },{ + }, { name: '列表封面图', key: 'cover' - },{ + }, { name: '商品等级', key: 'level' + }, { + name: '商品价格', + key: 'price' + }, { + name: '商品库存', + key: 'stock' }], show_select_category: false, show_select_level: false, @@ -510,16 +516,44 @@ }, async submit() { + if (!this.dto.price) { + this.$message.showToast('商品价格未设置') + return + } + var tmp = parseFloat(this.dto.price) + if (isNaN(tmp) || ('' + tmp.toFixed(2)) !== ('' + this.dto.price)) { + this.$message.showToast('商品价格格式错误,精确到分') + return + } + + if (this.dto.price <= 0) { + this.$message.showToast('商品价格不能小于等于0') + return + } + tmp = parseFloat(this.dto.stock) + if (isNaN(tmp) || ('' + tmp.toFixed(0)) !== ('' + this.dto.stock) || tmp < 0) { + this.$message.showToast('商品库存格式错误,需要大于等于0') + return + } + for (var field of this.requireFields) { if (!this.dto[field.key]) { this.$message.showToast(`${field.name}信息未填写`) return } - } - if(this.dto.params.length<1){ - this.$message.showToast('商品参数详情未设置') - return } + if (this.dto.params.length < 1) { + this.$message.showToast('商品参数详情未设置') + return + } else { + for (var item of this.dto.params) { + if (!item.value) { + this.$message.showToast('存在商品参数详情未设置') + return + } + } + } + // if (!this.dto.applicationType) { // this.$message.showToast('未选择类型') // return -- Gitblit v1.9.3