计数功能校验输入正整数

其他几个页面扫码出错后,清空已扫描的值
This commit is contained in:
zhougf committed 2024-04-25 18:53:35 +08:00
1 parent c286bf55d7
commit a869449034
5 files changed
+50 -36

No files matched your search

@@ -109,6 +109,7 @@
type: "warning", type: "warning",
duration: "10000", duration: "10000",
}); });
_this.qrcode = "";
} }
if (_this.clear) { if (_this.clear) {
_this.gendCode = ""; _this.gendCode = "";
@@ -263,6 +263,10 @@ namespace HHWMS.Web.Controllers
/// <returns></returns> /// <returns></returns>
public ActionResult CountCommit(string code, string uniqueCode, int qty) public ActionResult CountCommit(string code, string uniqueCode, int qty)
{ {
if (qty <= 0)
{
return JsonMore(null, 500, $"数量必须大于0!");
}
var receiptDetail = _unitwork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode)); var receiptDetail = _unitwork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
if (receiptDetail != null) if (receiptDetail != null)
{ {
@@ -88,8 +88,12 @@ var app = new Vue({
onSubmit() { onSubmit() {
var _this = this; var _this = this;
var qty = _this.form.qty; var qty = _this.form.qty;
if (qty == "")
qty = parseInt(_this.qtyPlaceholder); // 正则表达式 校验qty为正整数
if (!/^[1-9]\d*$/.test(qty)) {
layer.alert("数量必须为正整数");
return;
}
// 提交已绑定数据 // 提交已绑定数据
$.ajax({ $.ajax({
type: "post", type: "post",
@@ -22,35 +22,38 @@
</el-row> </el-row>
<el-table :data="bindingData" stripe max-height="450" border style="width: 100%"> <el-table :data="bindingData" stripe max-height="450" border style="width: 100%">
<el-table-column fixed="left" label="操作" width="120" align="center"> <el-table-column type="index"
<template slot-scope="scope"> width="50">
<el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)" </el-table-column>
type="text" <el-table-column fixed="left" label="操作" width="120" align="center">
size="small"> <template slot-scope="scope">
移除 <el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)"
</el-button> type="text"
</template> size="small">
</el-table-column> 移除
<el-table-column label="位置" </el-button>
align="center" </template>
prop="boxCode"> </el-table-column>
</el-table-column> <el-table-column label="位置"
<el-table-column label="唯一码" align="center"
align="center" prop="boxCode">
prop="uniqueCode"> </el-table-column>
</el-table-column> <el-table-column label="唯一码"
<el-table-column label="物料码" align="center"
align="center" prop="uniqueCode">
prop="materialCode"> </el-table-column>
</el-table-column> <el-table-column label="物料码"
<el-table-column label="名称" align="center"
align="center" prop="materialCode">
prop="materialName"> </el-table-column>
</el-table-column> <el-table-column label="名称"
<el-table-column label="数量" align="center"
align="center" prop="materialName">
prop="bindQty"> </el-table-column>
</el-table-column> <el-table-column label="数量"
align="center"
prop="bindQty">
</el-table-column>
</el-table> </el-table>
<el-form-item style="float: right"> <el-form-item style="float: right">
<el-button type="primary" @@click="onSubmit">入库</el-button> <el-button type="primary" @@click="onSubmit">入库</el-button>
@@ -155,6 +158,7 @@
type: "warning", type: "warning",
duration: "10000", duration: "10000",
}); });
_this.form.uniqueCode = '';
} else { } else {
// 3.已扫描增加 // 3.已扫描增加
_this.bindingData.push({ _this.bindingData.push({
@@ -125,11 +125,12 @@
}); });
if (t == -1) { if (t == -1) {
_this.$message({ _this.$message({
message: "扫描失败 " + data + " 不存在!", message: "扫描失败 " + data + " 不存在!",
type: "error", type: "error",
duration: "10000", duration: "10000",
}); });
_this.form.uniqueCode = "";
} else { } else {
var value = _this.invTable[t]; var value = _this.invTable[t];
_this.form.uniqueCode = value.UniqueCode; _this.form.uniqueCode = value.UniqueCode;