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 +++++++----
src/views/farmplant/farmproductstock.vue | 140 ++++++++++++++---------
src/views/stock/stockmanage.vue | 110 +++++++++++-------
src/App.vue | 14 ++
4 files changed, 211 insertions(+), 125 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 1697360..0cdfe86 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -27,4 +27,18 @@
.avue--detail .el-col{
margin-bottom: 0;
}
+ input::-webkit-inner-spin-button {
+ -webkit-appearance: none !important;
+
+ }
+
+ input::-webkit-outer-spin-button{
+ -webkit-appearance: none !important;
+
+ }
+
+ input[type="number"]{
+ -moz-appearance: textfield;
+
+ }
</style>
diff --git a/src/views/farmplant/farmproductstock.vue b/src/views/farmplant/farmproductstock.vue
index 6299bf8..87a94b2 100644
--- a/src/views/farmplant/farmproductstock.vue
+++ b/src/views/farmplant/farmproductstock.vue
@@ -161,7 +161,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>
@@ -169,7 +169,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>
@@ -201,7 +201,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" min="0" @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>
@@ -235,7 +235,7 @@
</template>
<template slot-scope="{disabled,size}" slot="saleNum">
<div style="margin-bottom: -20px">
- <el-input type="number" placeholder="请输入加工数量" v-model="formJG.saleNum">
+ <el-input type="number" min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入加工数量" v-model="formJG.saleNum">
<i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
</el-input>
<div style="text-align: right;color: #ffb218">库存量:{{ formJG.weight }}公斤</div>
@@ -243,7 +243,7 @@
</template>
<template slot-scope="{disabled,size}" slot="processNum">
<div style="margin-bottom: -20px">
- <el-input type="number" placeholder="请输入产品数量" v-model="formJG.processNum">
+ <el-input type="number" min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入产品数量" v-model="formJG.processNum">
<i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
</el-input>
</div>
@@ -288,7 +288,7 @@
</template>
<template slot-scope="{disabled,size}" slot="saleNum">
<div style="margin-bottom: -20px">
- <el-input type="number" placeholder="请输入出库数量" v-model="formCK.saleNum">
+ <el-input type="number" min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入出库数量" v-model="formCK.saleNum">
<i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
</el-input>
<div style="text-align: right;color: #ffb218">可出库量:{{ formCK.weight }}公斤</div>
@@ -908,21 +908,29 @@
this.$refs.form.validate((vaild, done) => {
if (vaild) {
this.form.id = ""
- add(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()
- })
+ }else{
+ add(this.form).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ //提交完成,关闭窗口清空数据
+ that.cleanData()
+ done()
+ }, error => {
+ window.console.log(error)
+ //提交失败,关闭窗口清空数据
+ that.cleanData()
+ done()
+ })
+ }
}
})
},
@@ -933,21 +941,29 @@
if (vaild) {
this.formJG.id = ""
Object.assign(this.formJG,this.JG)
- addjg(this.formJG).then(() => {
- this.onLoad(this.page)
+ if(this.formJG.saleNum <0 || this.formJG.processNum<0){
this.$message({
- type: "success",
- message: "操作成功!"
+ type: "warning",
+ message: "加工数量和产品数量不能为负数!"
})
- //提交完成,关闭窗口清空数据
- that.cleanJGData()
done()
- }, error => {
- window.console.log(error)
- //提交失败,关闭窗口清空数据
- that.cleanJGData()
- done()
- })
+ }else{
+ addjg(this.formJG).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ //提交完成,关闭窗口清空数据
+ that.cleanJGData()
+ done()
+ }, error => {
+ window.console.log(error)
+ //提交失败,关闭窗口清空数据
+ that.cleanJGData()
+ done()
+ })
+ }
}
})
},
@@ -957,21 +973,29 @@
this.$refs.form.validate((vaild, done) => {
if (vaild) {
this.formKC.id = ""
- addKC(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{
+ addKC(this.formKC).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ //提交完成,关闭窗口清空数据
+ that.cleanKCData()
+ done()
+ }, error => {
+ window.console.log(error)
+ //提交失败,关闭窗口清空数据
+ that.cleanKCData()
+ done()
+ })
+ }
}
})
},
@@ -981,21 +1005,29 @@
this.$refs.form.validate((vaild, done) => {
if (vaild) {
this.formCK.id = ""
- addck(this.formCK).then(() => {
- this.onLoad(this.page)
+ if(this.formCK.saleNum<0){
this.$message({
- type: "success",
- message: "操作成功!"
+ type: "warning",
+ message: "出库数量不能为负数!"
})
- //提交完成,关闭窗口清空数据
- that.cleanCKData()
done()
- }, error => {
- window.console.log(error)
- //提交失败,关闭窗口清空数据
- that.cleanCKData()
- done()
- })
+ }else{
+ addck(this.formCK).then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ })
+ //提交完成,关闭窗口清空数据
+ that.cleanCKData()
+ done()
+ }, error => {
+ window.console.log(error)
+ //提交失败,关闭窗口清空数据
+ that.cleanCKData()
+ done()
+ })
+ }
}
})
},
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()
+ })
+ }
}
})
},
diff --git a/src/views/stock/stockmanage.vue b/src/views/stock/stockmanage.vue
index 11394bc..2e559b0 100644
--- a/src/views/stock/stockmanage.vue
+++ b/src/views/stock/stockmanage.vue
@@ -758,63 +758,87 @@
//农资入库按钮
submitK(row, done, loading) {
row.deptId=this.userInfo.dept_id;
- add(row).then(() => {
- this.onLoad(this.page);
+ if(row.amount<0 || row.specs <0){
this.$message({
- type: "success",
- message: "操作成功!"
+ type:"warning",
+ message:"规格和入库数量不能为负数"
+ })
+ done();
+ }else{
+ add(row).then(() => {
+ this.onLoad(this.page);
+ this.$message({
+ type: "success",
+ message: "操作成功!"
+ });
+ this.$refs.formK.resetFields();
+ this.gradec = false;
+
+ }, error => {
+ loading();
+ window.console.log(error);
});
- this.$refs.formK.resetFields();
- this.gradec = false;
- done();
- }, error => {
- loading();
- window.console.log(error);
- });
+ }
},
//入库
submitR(row, done, loading) {
row.deptId=this.userInfo.dept_id;
var that = this;
- add1(row).then(
- () => {
- that.onLoad(this.page);
- that.$refs.formR.resetFields();
- that.$message({
- type: "success",
- message: "操作成功!",
- });
- that.gradeBoxVisible = false;
- done();
- },
- (error) => {
- window.console.log(error);
- done();
- }
- );
+ if(row.amount1<0){
+ this.$message({
+ type:"warning",
+ message:"入库数量不能为负数"
+ })
+ done();
+ }else{
+ add1(row).then(
+ () => {
+ that.onLoad(this.page);
+ that.$refs.formR.resetFields();
+ that.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.gradeBoxVisible = false;
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ done();
+ }
+ );
+ }
}
,
//出库
submitC(row, done, loading) {
var that = this;
row.deptId=this.userInfo.dept_id;
- add1(row).then(
- () => {
- that.onLoad(this.page);
- that.$refs.formC.resetFields();
- that.$message({
- type: "success",
- message: "操作成功!",
- });
- that.gradeBoxVisible1 = false;
+ if(row.amount1<0 || row.num<row.amount1){
+ this.$message({
+ type:"warning",
+ message:"出库数量不能为负数且出库数量不能大于库存数"
+ })
+ done();
+ }else{
+ add1(row).then(
+ () => {
+ that.onLoad(this.page);
+ that.$refs.formC.resetFields();
+ that.$message({
+ type: "success",
+ message: "操作成功!",
+ });
+ that.gradeBoxVisible1 = false;
- done();
- },
- (error) => {
- window.console.log(error);
- done();
- }
- );
+ done();
+ },
+ (error) => {
+ window.console.log(error);
+ done();
+ }
+ );
+ }
}
,
// 往入库页面填充数据
--
Gitblit v1.9.3