From 5da57ebe0b9ee84e959eec20153b0886c9cc1f0d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 11 Aug 2022 14:35:14 +0800
Subject: [PATCH] 去掉数字输入框后的加减按钮。农产品、加工产品、农资数字输入框不能为负数

---
 src/views/farmplant/process.vue |   72 ++++++++++++++++++++++--------------
 1 files changed, 44 insertions(+), 28 deletions(-)

diff --git a/src/views/farmplant/process.vue b/src/views/farmplant/process.vue
index 443b3b7..9330527 100644
--- a/src/views/farmplant/process.vue
+++ b/src/views/farmplant/process.vue
@@ -97,7 +97,7 @@
                 </template>
                 <template slot-scope="{disabled,size}" slot="saleNum">
                     <div style="margin-bottom: -20px">
-                        <el-input type="number" placeholder="请输入销售数量" v-model="form.saleNum">
+                        <el-input type="number" min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入销售数量" v-model="form.saleNum">
                             <i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
                         </el-input>
                         <div style="text-align: right;color: #ffb218">可销售量:{{ form.weight }}公斤</div>
@@ -105,7 +105,7 @@
                 </template>
                 <template slot-scope="{disabled,size}" slot="salePrice">
                     <div style="margin-bottom: -20px">
-                        <el-input type="number" placeholder="请输入销售价格" v-model="form.salePrice">
+                        <el-input type="number"  min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入销售价格" v-model="form.salePrice">
                             <i slot="suffix" style="font-style:normal;margin-right: 5px;">元/公斤</i>
                         </el-input>
                     </div>
@@ -137,7 +137,7 @@
                 </template>
                 <template slot-scope="{disabled,size}" slot="saleNum">
                     <div style="margin-bottom: -20px">
-                        <el-input type="number" placeholder="请输入损耗数量" v-model="formKC.saleNum">
+                        <el-input type="number" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入损耗数量" v-model="formKC.saleNum">
                             <i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
                         </el-input>
                         <div style="text-align: right;color: #ffb218">库存量:{{ formKC.weight }}公斤</div>
@@ -725,21 +725,29 @@
             var that = this
             this.$refs.form.validate((vaild, done) => {
                 if (vaild) {
-                    insert(this.form).then(() => {
-                        this.onLoad(this.page)
+                    if(this.form.saleNum<0 || this.form.salePrice<0){
                         this.$message({
-                            type: "success",
-                            message: "操作成功!"
+                            type: "warning",
+                            message: "销售数量和销售价格不能为负数!"
                         })
-                        //提交完成,关闭窗口清空数据
-                        that.cleanData()
-                        done()
-                    }, error => {
-                        window.console.log(error)
-                        //提交失败,关闭窗口清空数据
-                        that.cleanData()
-                        done()
-                    })
+                        done()                        
+                    }else{
+                        insert(this.form).then(() => {
+                            this.onLoad(this.page)
+                            this.$message({
+                                type: "success",
+                                message: "操作成功!"
+                            })
+                            //提交完成,关闭窗口清空数据
+                            that.cleanData()
+                            done()
+                        }, error => {
+                            window.console.log(error)
+                            //提交失败,关闭窗口清空数据
+                            that.cleanData()
+                            done()
+                        })
+                    }
                 }
             })
         },
@@ -771,21 +779,29 @@
             var that = this
             this.$refs.form.validate((vaild, done) => {
                 if (vaild) {
-                    insertKC(this.formKC).then(() => {
-                        this.onLoad(this.page)
+                    if(this.formKC.saleNum<0){
                         this.$message({
-                            type: "success",
-                            message: "操作成功!"
+                            type: "warning",
+                            message: "损耗数量不能为负数!"
                         })
-                        //提交完成,关闭窗口清空数据
-                        that.cleanKCData()
                         done()
-                    }, error => {
-                        window.console.log(error)
-                        //提交失败,关闭窗口清空数据
-                        that.cleanKCData()
-                        done()
-                    })
+                    }else{
+                        insertKC(this.formKC).then(() => {
+                            this.onLoad(this.page)
+                            this.$message({
+                                type: "success",
+                                message: "操作成功!"
+                            })
+                            //提交完成,关闭窗口清空数据
+                            that.cleanKCData()
+                            done()
+                        }, error => {
+                            window.console.log(error)
+                            //提交失败,关闭窗口清空数据
+                            that.cleanKCData()
+                            done()
+                        })
+                    }
                 }
             })
         },

--
Gitblit v1.9.3