From 6aea8a9c8e749713c69865c7a37b43e93627ca0f Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 25 Jul 2024 13:52:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96-=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=B7=BB=E5=8A=A0=E6=97=B6=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=A6=82=E6=9E=9C=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=80=BC=E8=B6=85=E8=8C=83=E5=9B=B4=E6=97=B6=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E5=BC=B9=E7=AA=97=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/format.js | 9 +++++++-- src/views/product/add_shop.vue | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/utils/format.js b/src/utils/format.js index 3a49b01..69788f0 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -4,9 +4,10 @@ * @param {number} price - 需要格式化的价格。 * @param {number} min - 价格的最小值。 * @param {number} max - 价格的最大值,默认为100000000。 + * @param {Boolean} returnIsArea - 是否返回值符合范围区间,默认为false。 * @returns {number} - 返回格式化后的价格,如果超出范围则返回最小值或最大值。 */ -export const formatPrice = (price,min=-Infinity, max = 100000000 ) => { +export const formatPrice = (price,min=-Infinity, max = 100000000,returnIsArea=false ) => { if(price === undefined || price === null||price===''){ return 0 } @@ -14,7 +15,11 @@ export const formatPrice = (price,min=-Infinity, max = 100000000 ) => { const newval = parseFloat(price.toFixed(2)) // 如果价格大于最大值,返回最大值 if (newval > max) { - return max + return returnIsArea?{value:max,error:true}:max + } + // 如果价格小于最小值,返回最小值 + if (newval < min) { + return returnIsArea?{value:min,error:true}:min } // 如果价格小于最小值,返回最小值 if (newval < min) { diff --git a/src/views/product/add_shop.vue b/src/views/product/add_shop.vue index 2e2306c..380fb50 100644 --- a/src/views/product/add_shop.vue +++ b/src/views/product/add_shop.vue @@ -88,7 +88,7 @@ @@ -519,8 +519,23 @@ export default { methods: { priceFormat(item,key){ + const messageheight=48; + const offset=window.innerHeight/2-(messageheight/2) -100 this.$nextTick(()=>{ - item[key]=formatPrice(item[key],0,100000000) + const min=0; + const max=100000000; + const newval=formatPrice(item[key],min,max,true) + console.log(newval) + if(typeof newval!=='number'){ + item[key]=newval.value + this.$message({ + offset, + message: `请输入${min}到${max}范围内的数字`, + type: "error" + }); + }else{ + item[key]=newval + } }) }, // 删除分组商品 From 79a0a2c1a25fedd77e34552683fcdfa2f3dae142 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 25 Jul 2024 13:56:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=89=93=E5=8C=85=E8=B4=B9=EF=BC=8C=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E9=94=80=E9=87=8F=E8=BE=93=E5=85=A5=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E5=80=BC=E4=B8=BA0=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E8=BE=93=E5=85=A5=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=90=8E=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/product/add_shop.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/product/add_shop.vue b/src/views/product/add_shop.vue index 380fb50..978f4d1 100644 --- a/src/views/product/add_shop.vue +++ b/src/views/product/add_shop.vue @@ -303,13 +303,13 @@
开启后: 收银完成后会自动打印对应数量的标签数
- +
单份商品打包费。注:店铺开启外卖模式下该数据才生效
- +