abp(net core)+easyui+efcore入库管理
程序员文章站
2022-04-23 09:11:03
在经过前面八篇文章(abp(net core)+easyui+efcore实现仓储管理系统——入库管理之一(三十七) 至abp(net core)+easyui+efcore实现仓储管理系统——入库管理之八(四十四) )的学习之后,我们知道了已经基本完成了入库管理功能。在这篇文章中我们来增加更新与删... ......
修改更新与删除脚本
1. 在visual studio 2017的“解决方案资源管理器”中,找到领域层“abp.tplms.web.mvc”项目中的wwwroot目录下的view-resources\views\instock目录中的找到index.js文件。如下图。
2. 在index.js文件中,写入相应的脚本代码。代码如下:
//-----------------------系统管理-->入库单管理----------------------//
var editindex = undefined;
var mainindex = undefined;
//刷新数据
function initable() {
$("#dginso").datagrid({
url: "/instock/list",
title: "入库单管理",
pagination: true,
pagesize: 10,
pagelist: [10, 20, 30],
fit: true,
fitcolumns: false,
loadmsg: "正在加载入库单信息...",
nowarp: false,
border: false,
idfield: "id",
sortname: "id",
sortorder: "asc",
frozencolumns: [[//冻结列
{ field: "ck", checkbox: true, align: "left", width: 50 }
]],
columns: [[
{ title: "编号", field: "id", width: 50, sortable: true },
{ title: "入库单号", field: "no", width: 100, sortable: true },
{title: "状态", field: "status", width: 50 },
{ title: '到货日期', field: 'receivetime', width: 100, align: 'center' },
{ title: "货主", field: "ownercode", width: 150, sortable: true },
{ title: "预计到货时间", field: "predeliverytime", width: 100, sortable: false },
{ title: '客户', field: 'customername', width: 120, align: 'center' },
{ title: '收货人',field: 'oper', width: 100, align: 'center' },
{ title: '审核人',field: 'checker', width: 120, align: 'center' },
{ title: '件数', field: 'packageqty', width: 100, align: 'center' },
{ title: '创建时间', field: 'creationtime', width: 100, align: 'center' }
]]
});
}
//显示送货单数据
function showcargo() {
abp.log.warn('货物信息列表日志...');
$("#dgcargo").datagrid({
url: "/cargo/list",
title: "货物管理管理",
pagination: true,
pagesize: 10,
pagelist: [10, 20, 30],
fit: true,
fitcolumns: false,
loadmsg: "正在加载货物信息...",
nowarp: false,
border: false,
idfield: "id",
sortname: "id",
sortorder: "asc",
frozencolumns: [[//冻结列
{ field: "ck", checkbox: true, align: "left", width: 50 }
]],
columns: [[
{ title: "编号", field: "id", width: 50, sortable: true },
{ title: "供应商", field: "supplierid", width: 80, sortable: true },
{ title: "hscode", field: "hscode", width: 100, sortable: true },
{ title: "货物代码", field: "cargocode", width: 100, sortable: true },
{ title: "货物名称", field: "cargoname", width: 80, sortable: false },
{ title: "规格型号", field: "spcf", width: 100, sortable: false },
{ title: "产销国", field: "country", width: 80, sortable: false },
{ title: "计量单位", field: "unit", width: 100, sortable: false },
{ title: "包装", field: "package", width: 100, sortable: false },
{ title: "单价", field: "price", width: 100, sortable: false },
{ title: "币制", field: "curr", width: 80, sortable: false },
{
title: "长宽高", field: "length", width: 100, sortable: false, formatter: function (value, row, index) {
return row.length + '*' + row.width + '*' + row.height;
}
},
{ title: "体积", field: "vol", width: 80, sortable: false },
{ title: "备注", field: "remark", width: 80, sortable: false },
{ title: '创建时间', field: 'creationtime', width: 100, align: 'center' }
]]
});
abp.log.warn('3货物信息列表日志...');
}
function showcargoinfo() {
$("#divimportcargo").dialog({
closed: false,
title: "选择货物信息",
modal: true,
width: 820,
height: 550,
collapsible: true,
minimizable: true,
maximizable: true,
resizable: true
});
showcargo();
$("#dgcargo").datagrid("clearchecked");
$("#dgcargo").datagrid("clearselections");
}
function reloaded() { //reload
$("#reload").click(function () {
//
$('#dginso').datagrid('reload');
});}
//修改点击按钮事件
function updinsoinfo() {
$("#edit").click(function () {
//判断选择的中
var row = $("#dginso").datagrid('getselected');
if (row) {
$.messager.confirm('编辑', '您想要编辑吗?', function (r) {
if (r) {
//先绑定
showino(row);
//打开对话框编辑
$("#divaddupdino").dialog({
closed: false,
title: "修改入库单",
modal: true,
width: 820,
height: 550,
collapsible: true,
minimizable: true,
maximizable: true,
resizable: true,
});
defaulttab();
showdetail(row.no);
}
});
setenabled(row.status);
} else {
$.messager.alert('提示', ' 请选择要编辑的行!', 'warning');
}
});
}
//删除入库单
function deleteinso() {
$("#del").click(function () {
var rows = $("#dginso").datagrid("getselections");
if (rows.length > 0) {
$.messager.confirm("提示", "确定要删除吗?", function (res) {
if (res) {
var codes = []; //重要不是{}
for (var i = 0; i < rows.length; i++) {
codes.push(rows[i].id);
}
$.post("/instock/delete", { "ids": codes.join(',') }, function (data) {
if (data == "ok") {
$.messager.alert("提示", "删除成功!");
$("#dginso").datagrid("clearchecked");
$("#dginso").datagrid("clearselections");
$("#dginso").datagrid("load", {});
}
else if (data == "no") {
$.messager.alert("提示", "删除失败!");
return;
}
});
}
});
}
})
}
//清空文本框
function clearall() {
$("#divaddupdino input").each(function () {
$(this).val("");
});
$("#predeliverytimeupdate").val(getnowformatdate());
$("#statusupdate").val("0");
$("#nwtupdate").val("0");
$("#gwtupdate").val("0");
$("#packageqtyupdate").val("0");
}
function getno() {
$.get(abp.apppath + "api/services/app/instockorder/getno", function (data) {
$("#updno").val(data);
});
}
//获取当前时间,格式yyyy-mm-dd
function getnowformatdate() {
var date = new date();
var seperator1 = "-";
var year = date.getfullyear();
var month = date.getmonth() + 1;
var strdate = date.getdate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strdate >= 0 && strdate <= 9) {
strdate = "0" + strdate;
}
var currentdate = year + seperator1 + month + seperator1 + strdate;
return currentdate;
}
//将表单数据转为json
function form2json(id) {
var arr = $("#" + id).serializearray()
var jsonstr = "";
jsonstr += '{';
for (var i = 0; i < arr.length; i++) {
jsonstr += '"' + arr[i].name + '":"' + arr[i].value + '",'
}
jsonstr = jsonstr.substring(0, (jsonstr.length - 1));
jsonstr += '}'
var json = json.parse(jsonstr)
return json
}
function setenabled(status) {
//var status = $("#statusupdate").val()
if (status == "提交") {
$("#btnsave").prop('disabled', true);
}
else {
$("#btnsave").removeattr("disabled");
}
}
function defaulttab() {
//默认显示第一个tab
$('#box').tabs('select', "入库单");
}
//弹出 导入送货单的的对话框
function showinsodialog() {
$("#add").click(function () {
$.messager.confirm('编辑', '您想要创建入库单吗?', function (r) {
if (r) {
//打开对话框编辑
$("#divaddupdino").dialog({
closed: false,
title: "新增入库单",
modal: true,
width: 820,
height: 550,
collapsible: true,
minimizable: true,
maximizable: true,
resizable: true,
});
}
defaulttab();
getno();
clearall();
showdetail("");
});
});
$("#btnsave").click(function () {
//保存
var id = $("#idupdate").val();
if (id == "" || id == undefined) {
//验证
$.messager.confirm('确认', '您确认要保存吗?', function (r) {
if (r) {
var postdata = getino();
if (postdata.no == "" || postdata.customercode == "" || postdata.customername=="" || postdata.ownername=="") {
$.messager.alert('提示', ' 请填写相关必填项!', 'warning');
return;
}
$.post("/instock/add", postdata, function (data) {
if (data == "ok") {
// $("#divaddupddo").dialog("close");
$.messager.alert("提示", "保存成功!");
initable();
collapserows();
}
else if (data == "no") {
$.messager.alert("提示", "保存失败!");
return;
}
});
}
})
}
else {
savedetail();
initable();
collapserows();
}
});
}
//添加明细
function showdetail(no) {
var lastindex;
$("#dginod").datagrid({
url: "/instock/getdetail?no=" + no,
title: "入库单明细",
pagination: false,
fit: true,
fitcolumns: false,
loadmsg: "正在加载入库单明细信息...",
toolbar: [
{ text: '添加明细', iconcls: 'icon-add', handler: function () { showcargoinfo(); } },
{ text: '添加库位', iconcls: 'icon-edit', handler: function () { subgridaddrow(); } },
{ text: '删除', iconcls: 'icon-remove', handler: function () { deviceinfodeleteclick(); } },
'-'
],
nowarp: false,
border: false,
idfield: "id",
sortname: "id",
sortorder: "asc",
singleselect: true,
iconcls: 'icon-edit',
columns: [[
{ title: "编号", field: "seqno", width: 50, sortable: true },
{ title: "入库单号", field: "instockno", width: 100, sortable: true },
{ title: "hscode", field: "hscode", width: 80, sortable: false },
{ title: "货物代码", field: "cargocode", width: 100, sortable: true },
{ title: "货物名称", field: "cargoname", width: 160, sortable: false },
{ title: "规格型号", field: "spcf", width: 80, sortable: false },
{
title: "数量", field: "qty", width: 100, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 4
}
}
},
{
title: "长", field: "length", width: 70, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 2
}
}
},
{ title: "宽", field: "width", width: 70, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 2
}
}
},
{
title: "高", field: "height", width: 70, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 2
}
}
},
{ title: "产销国", field: "country", width: 70, align: 'center' },
{
title: "单价", field: "price", width: 100, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 2
}
}
},
{
title: "总价", field: "totalamt", width: 100, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 2
}
}
},
{ title: "包装", field: "package", width: 70, align: 'center' },
{ title: "计量单位", field: "unit", width: 70, align: 'center' },
{
title: "总体积", field: "vol", width: 70, align: 'center', editor: {
type: 'numberbox', options: {
required: true, min: 0, precision: 4
}
}
},
{ title: "品牌", field: "brand", width: 70, align: 'center' }
]],
onclickrow: function (index, rowdata) {
if (mainindex!=undefined) {
$('#dginod').datagrid('collapserow', mainindex);
}
if (lastindex != index) {
$('#dginod').datagrid('endedit', lastindex);
editrow(index);
}
lastindex = index;
},
onbeginedit: function (rowindex, rowdata) {
setediting(rowindex);
}
});
}
//计算报价小计
function setediting(rowindex) {
var editors = $('#dginod').datagrid('geteditors', rowindex);
var priceeditor = editors[4];
var qtyeditor = editors[0];
var lengtheditor = editors[1];
var widtheditor = editors[2];
var heighteditor = editors[3];
var totalvoleditor = editors[6];
var totalamteditor = editors[5];
priceeditor.target.numberbox({
onchange: function () { calculate();}
});
qtyeditor.target.numberbox({
onchange: function () {
calculate();
calculatevol();
}
});
lengtheditor.target.numberbox({
onchange: function () { calculatevol(); }
});
widtheditor.target.numberbox({
onchange: function () { calculatevol(); }
});
heighteditor.target.numberbox({
onchange: function () { calculatevol(); }
});
function calculate() {
var cost = (priceeditor.target.val()) * (qtyeditor.target.val());
console.log(cost);
totalamteditor.target.numberbox("setvalue", cost);
}
function calculatevol() {
var vol = (lengtheditor.target.val() / 100.0) * (widtheditor.target.val() / 100.0)
* (heighteditor.target.val() / 100.0)* (qtyeditor.target.val());
console.log(vol);
totalvoleditor.target.numberbox("setvalue", vol);
}
}
function editrow(index) {
$('#dginod').datagrid('selectrow', index)
.datagrid('beginedit', index);
}
function endedit() {
var rows = $('#dginod').datagrid('getrows');
if (rows==undefined) {
return;
}
for (var i = 0; i < rows.length; i++) {
$('#dginod').datagrid('endedit', i);
}
}
//设置入库单明细数据
function setgriddetail(effectrow) {
if ($('#dginod').datagrid('getchanges').length) {
var inserted = $('#dginod').datagrid('getchanges', "inserted");
var deleted = $('#dginod').datagrid('getchanges', "deleted");
var updated = $('#dginod').datagrid('getchanges', "updated");
if (inserted.length) {
effectrow["inserted"] = json.stringify(inserted);
}
if (deleted.length) {
effectrow["deleted"] = json.stringify(deleted);
}
if (updated.length) {
effectrow["updated"] = json.stringify(updated);
}
}
return effectrow;
}
function savedetail() {
endedit();
$.messager.confirm('确认', '您确认要修改吗?', function (r) {
var effectrow = new object();
var postdata = getino();
if (postdata.id) {
effectrow["postdata"] = json.stringify(postdata);
}
effectrow = setgriddetail(effectrow);
$.post("/instock/update", effectrow, function (data) {
if (data.success) {
$.messager.alert("提示", data.result);
$('#dginod').datagrid('acceptchanges');
}
else {
$.messager.alert("提示", data.result);
return;
}
}, "json")
;
})
}
function init() {
$("#predeliverytimeupdate").val(getnowformatdate());
$("#creationtimeupdate").val(getnowformatdate());
$("#btncancle").click(function () {
$("#divaddupdino").dialog("close");
$('#dginso').datagrid('reload');
});
$("#btncancledo").click(function () {
$("#divimportcargo").dialog("close");
$('#dginso').datagrid('reload');
});
$("#btnimportdo").click(function () {
//保存
var rows = $('#dgcargo').datagrid('getselections');
if (rows.length > 0) {
//验证
$.messager.confirm('确认', '您确认要保存所选择的货物信息吗?', function (r) {
if (r) {
var obj_no = $("#updno").val();
var ids = [];//重要不是{}
for (var i = 0; i < rows.length; i++) {
ids.push(rows[i].id);
}
var postdata = {
"ids": ids.join(','),
"no": obj_no
};
$.post("/instock/importcargo", postdata, function (data) {
if (data == "ok") {
$.messager.alert("提示", "保存货物信息成功!");
showdetail(obj_no);
}
else if (data == "no") {
$.messager.alert("提示", "保存货物信息失败!");
return;
}
});
}
})
}
});
$("#btnsubmit").click(function () {
//保存
var id = $("#idupdate").val();
if (id == "" || id == undefined) {
$.messager.alert("提示", "入库单没有保存,请先保存!");
return;
}
//验证
$.messager.confirm('确认', '您确认要提交入库单吗?', function (r) {
if (r) {
var postdata = {
"id": id
};
$.post("/instockmgr/submit", postdata, function (data) {
if (data == "ok") {
$.messager.alert("提示", "入库单已经提交成功!");
$("#statusupdate").val("提交");
setenabled("提交");
}
else if (data == "no") {
$.messager.alert("提示", "入库单提交失败!");
return;
}
});
}
})
});
}
function getino() {
var postdata = {
"no": $("#updno").val(),
"deliveryno": "",
"predeliverytime": $("#predeliverytimeupdate").val(),
"customercode": $("#customercodeupdate").val(),
"ownername": $("#ownernameupdate").val(),
"ownercode": $("#ownercodeupdate").val(),
"customername": $("#customernameupdate").val(),
"creationtime": $("#creationtimeupdate").val(),
"checktime": $("#checktimeupdate").val(),
"warehousetype": $("#warehousetypeupdate").val(),
"warehouseno": $("#warehousenoupdate").val(),
"oper": $("#operupdate").val(),
"receiver": $("#receiverupdate").val(),
"nwt": $("#nwtupdate").val(),
"remark": $("#remarkupdate").val(),
"receivetime": $("#receivetimeupdate").val(),
"status": $("#statusupdate").val(),
"gwt": $("#gwtupdate").val(),
"checker": $("#checkerupdate").val(),
"packageqty": $("packageqtyupdate").val(),
"lastupdatetime": "",
"lastoper":""
};
var id = $("#idupdate").val();
if (!(id=="" || id==undefined)) {
postdata.id = id;
}
return postdata;
}
function showino(row)
{
$("#idupdate").val(row.id);
$("#updno").val(row.no);
$("#predeliverytimeupdate").val(row.predeliverytime);
$("#customercodeupdate").val(row.customercode);
$("#customernameupdate").val(row.customername);
$("#ownercodeupdate").val(row.ownercode);
$("#ownernameupdate").val(row.ownername);
$("#creationtimeupdate").val(row.creationtime);
$("#checktimeupdate").val(row.checktime);
$("#warehousetypeupdate").val(row.warehousetype);
$("#warehousenoupdate").val(row.warehouseno);
$("#operupdate").val(row.oper);
$("#receiverupdate").val(row.receiver);
$("#nwtupdate").val(row.nwt);
$("#remarkupdate").val(row.remark);
$("#receivetimeupdate").val(row.receivetime);
$("#statusupdate").val(row.status);
$("#gwtupdate").val(row.gwt);
$("#checkerupdate").val(row.checker);
}
//------------------------系统管理-->入库单管理结束--------------------------//
3. 在visual studio 2017的“解决方案资源管理器”中,找到“abp.tplms.web.mvc”项目中的views目录下的instock目录中的index.cshtml文件。双击打开此文件,把以下代码删除或注释。
<div id="dg-detail-button"> <a href="#" id="add" class="easyui-linkbutton" data-options="iconcls:'icon-add'" style="width:100px; " onclick="showcargoinfo()">添加明细</a> <a href="#" id="addloc" class="easyui-linkbutton" data-options="iconcls:'icon-add'" style="width:100px; " onclick="subgridaddrow()">添加库位</a> <a href="#" id="del" class="easyui-linkbutton" data-options="iconcls:'icon-remove'" style="width:100px; ">删除</a> </div>
4. 修改代码,如下图。
<td>创建时间:</td> <td> <input type="text" id="creationtimeupdate" name="ucreationtime" class="form-control input-sm" /> </td>
推荐阅读
-
Asp.Net Core 轻松学-基于微服务的后台任务调度管理器
-
.Net Core 3.0开源可视化设计CMS内容管理系统建站系统
-
Asp.net Core中如何使用中间件来管理websocket
-
abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理四 (二十二)
-
.NET Core实战项目之CMS 第八章 设计篇-内容管理极简设计全过程
-
abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之一(二十七)
-
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)
-
abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理三 (二十一)
-
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)
-
4. abp中的asp.net core模块剖析