解决单位被删后导致商品选择的bug

This commit is contained in:
季圣华
2020-04-22 23:58:46 +08:00
parent 19a90d578a
commit 4d05d5ee2f
2 changed files with 46 additions and 36 deletions

View File

@@ -330,44 +330,53 @@
oldUnit = "";
unitID = 0;
url = '/unit/add';
//单位名称事件
$("#basicName").textbox('textbox').bind("keyup", function () {
$("#unitName").text($(this).val());
});
}
//保存信息
$("#saveUnit").off("click").on("click", function () {
if (checkUnitName()) {
if(!$('#unitFM').form('validate')){
return;
}
var basicName = $.trim($("#basicName").val());
var otherName = $.trim($("#otherName").val());
var otherNum = $.trim($("#otherNum").val());
var name = basicName + "," + otherName + "(1:" + otherNum + ")";
$.ajax({
url: url,
type: "post",
dataType: "json",
data: ({
info: JSON.stringify({
uname: name,
basicUnit: basicName,
otherUnit: otherName,
ratio: otherNum
})
}),
success: function(res) {
if(res && res.code === 200) {
$('#unitDlg').dialog('close');
//加载完以后重新初始化
var opts = $("#tableData").datagrid('options');
showUnitDetails(opts.pageNumber, opts.pageSize);
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存计量单位异常,请稍后再试!', 'error');
else {
if (checkUnitName()) {
return;
}
});
var basicName = $.trim($("#basicName").val());
var otherName = $.trim($("#otherName").val());
var otherNum = $.trim($("#otherNum").val());
var name = basicName + "," + otherName + "(1:" + otherNum + ")";
$.ajax({
url: url,
type: "post",
dataType: "json",
data: ({
info: JSON.stringify({
uname: name,
basicUnit: basicName,
otherUnit: otherName,
ratio: otherNum
})
}),
success: function (res) {
if (res && res.code === 200) {
$('#unitDlg').dialog('close');
//加载完以后重新初始化
var opts = $("#tableData").datagrid('options');
showUnitDetails(opts.pageNumber, opts.pageSize);
}
},
//此处添加错误处理
error: function () {
$.messager.alert('提示', '保存计量单位异常,请稍后再试!', 'error');
return;
}
});
}
});
//编辑信息
@@ -382,6 +391,10 @@
$("#otherNum").textbox("setValue", rowsdata.ratio);
$("#unitName").text(rowsdata.basicUnit);
url = '/unit/update?id=' + rowsdata.id;
//单位名称事件
$("#basicName").textbox('textbox').bind("keyup", function () {
$("#unitName").text($(this).val());
});
}
//检查名称是否存在 ++ 重名无法提示问题需要跟进
@@ -472,11 +485,6 @@
$("#searchBtn").click();
}
});
//单位名称事件
$("#basicName").off("keyup").on("keyup", function () {
$("#unitName").text($(this).val());
});
</script>
</body>
</html>