abp(net core)+easyui+efcore实现仓储管理系统目录

abp(net core)+easyui+efcore实现仓储管理系统——abp总体介绍(一)
abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)
abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三)
 abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)
abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八)
abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九)
abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)
abp(net core)+easyui+efcore实现仓储管理系统——使用 webapi实现curd (十一)
abp(net core)+easyui+efcore实现仓储管理系统——菜单-上 (十六)

abp(net core)+easyui+efcore实现仓储管理系统——easyui前端页面框架 (十八)

abp(net core)+easyui+efcore实现仓储管理系统——easyui之货物管理一 (十九)
abp(net core)+easyui+efcore实现仓储管理系统——abp webapi与easyui结合增删改查之一(二十七)
abp(net core)+easyui+efcore实现仓储管理系统——abp webapi与easyui结合增删改查之三(二十九)

abp(net core)+easyui+efcore实现仓储管理系统——abp webapi与easyui结合增删改查之八(三十四)

abp(net core)+easyui+efcore实现仓储管理系统——abp webapi与easyui结合增删改查之十(三十六)
abp(net core)+easyui+efcore实现仓储管理系统——入库管理之一(三十七)
abp(net core)+easyui+efcore实现仓储管理系统——入库管理之二(三十八)
abp(net core)+easyui+efcore实现仓储管理系统——入库管理之三存储过程(三十九)
abp(net core)+easyui+efcore实现仓储管理系统——入库管理之四(四十)

 

 

   在上一篇abp(net core)+easyui+efcore实现仓储管理系统——入库管理之四(四十)文章中我们已经定义了应用的接口,并在应用层实现了这些接口。接下来我们要在展示层来实现前端功能。

 

 创建instockcontroller继承自tplmscontrollerbase

    1. visual studio 2017的“解决方案资源管理器”中,右键单击在领域层“abp.tplms.web.mvc”项目中的controller目录。 选择“添加” > “新建项…”。如下图。

 

    2. 在弹出对话框“添加新项-abp.tplms.web.mvc”中选择“控制器类”,然后在名称输入框中输入“instockcontroller”,然后点击“添加”按钮。

     3.在instockcontroller.cs文件中输入如下代码,通过构造函数注入对应用服务的依赖。

using system;
using system.collections.generic;
using system.linq;
using system.threading.tasks;
using abp.runtime.validation;
using abp.web.models;
using abp.tplms.controllers;
using abp.tplms.entitys;
using abp.tplms.helpers;
using abp.tplms.instocks;
using abp.tplms.instocks.dto;
using abp.tplms.models.instock;
using microsoft.aspnetcore.mvc; 

namespace abp.tplms.web.controllers
{

    public class instockcontroller : tplmscontrollerbase
    {

        private readonly iinstockorderappservice _insoappservice;
        private readonly iinstockorderdetailappservice _insodappservice;
        

        private const int max_count = 1000;
        public instockcontroller(iinstockorderappservice insoappservice,iinstockorderdetailappservice insodappservice)
        {

            _insoappservice = insoappservice;
            _insodappservice = insodappservice;

        }

        public iactionresult index()
        {

            return view();
        }

        [dontwrapresult]
        [httppost]
        public string list()
        {


            var page = request.form["page"].tostring();
            var size = request.form["rows"].tostring();
            int pageindex = page == null ? 1 : int.parse(page);
            int pagesize = size == null ? 20 : int.parse(size);
            pagedinstockresultrequestdto paged = new pagedinstockresultrequestdto();

            paged.maxresultcount = max_count;
            paged.skipcount = ((pageindex - 1) < 0 ? 0 : pageindex - 1) * pagesize;
            paged.begintime = datetime.now.addmonths(-1);
            paged.endtime = datetime.now.adddays(1);
            var query = _insoappservice.getall(paged).getawaiter().getresult();
            var isolist = query.items;

            int total = query.totalcount;
            var json = jsoneasyui(isolist, total);


            return json;
        }

        [dontwrapresult]
        public string getdetail(string no)
        {

            pagedinstockdetailresultrequestdto paged = new pagedinstockdetailresultrequestdto();
            paged.maxresultcount = max_count;
            paged.instockno = no;            

            var podlist = _insodappservice.getall(paged).getawaiter().getresult().items; ;

            var json = jsoneasyui(podlist);
            return json;

        }

        [httppost]
        [disablevalidation]
        public actionresult add(instockorderdto iso)
        {

            string result = "no";
            try
            {

                pagedinstockresultrequestdto condition = new pagedinstockresultrequestdto();
                condition.no = iso.no;
 

                var isoexists = _insoappservice.getall(condition).getawaiter().getresult();
                if (isoexists.totalcount > 0)
                {
                    return content(result);
                }
 

                createupdateinstockorderdto cuiso = objectmapper.map<createupdateinstockorderdto>(iso);
                // todo: add logic here

              var obj=  _insoappservice.create(cuiso);
                result = "ok";

            }
            catch(exception ex)
            {
                result = "no";
            }
            return content(result);
        }

        [httppost]
        [disablevalidation] 
        public string update(instockorderdto iso)
        {

            string result = "no";
            list<instockorderdetaildto> list = new list<instockorderdetaildto>();

            try

            {

                string deleted = request.form["deleted"];
                string inserted = request.form["inserted"];
                string updated = request.form["updated"];
                string head = request.form["postdata"];
                if (!string.isnullorempty(head))
                {

                    //把json字符串转换成对象
                    iso = jsonhelper.instance.deserialize<instockorderdto>(head);

                }

             
                if (!string.isnullorempty(deleted))
                {

                    //把json字符串转换成对象
                    list<instockorderdetaildto> listdeleted = jsonhelper.instance.deserialize<list<instockorderdetaildto>>(deleted);

                    //todo 下面就可以根据转换后的对象进行相应的操作了

                    if (listdeleted != null && listdeleted.count > 0)
                    {

                        list.addrange(listdeleted.toarray());
                    }
                }

                if (!string.isnullorempty(inserted))
                {
                    //把json字符串转换成对象

                    list<instockorderdetaildto> listinserted = jsonhelper.instance.deserialize<list<instockorderdetaildto>>(inserted);

                    if (listinserted != null && listinserted.count > 0)
                    {

                        list.addrange(listinserted.toarray());
                    }
                }
 

                if (!string.isnullorempty(updated))
                {
                    //把json字符串转换成对象
                    list<instockorderdetaildto> listupdated = jsonhelper.instance.deserialize<list<instockorderdetaildto>>(updated);

                    if (listupdated != null && listupdated.count > 0)
                    {
                        list.addrange(listupdated.toarray());

                    }
                }

                if (iso == null)
                {
                    return "没有表头!";
                }
   // todo: add update logic here
                iso.instockorderdetail = list;
                result = _insoappservice.save(iso); 

            }
            catch
            {
            }

            if (result == "ok")
            {
                return "更新成功!";
            }
            else
                return "更新失败!";

        }

        [httppost]
        [disablevalidation]
        public actionresult importcargo(cargomodel cargos)
        {
            string result = "no";
            try
            {                

                // todo: 导入货物信息
                result = _insoappservice.importcargo(cargos.ids, cargos.no);

            }
            catch
            { 

            }
            return content(result);
        }

        [httppost]
        [dontwrapresult]
        public actionresult delete(string ids)
        {

            string result = "no";
            try
            {
                // todo: add delete logic here
                bool flag = _insoappservice.deletebyid(ids);
                if (flag)
                {
                    result = "ok";
                }
            }
            catch
            { 
            }
            return content(result);

        }
    }
}

、使用easyui创建入库单管理页面

    1. 在visual studio 2017的“解决方案资源管理器”中,右键单击在领域层“abp.tplms.web.mvc”项目中的views目录。 选择“添加” > “新建文件夹”。并重命名为“instock”。

    2. 在visual studio 2017的“解决方案资源管理器”中,鼠标右键单击“instock”文件夹,然后选择“添加” > “新建项…”。 在“添加新项-abp.tplms.web.mvc”对话框中,选择“razor视图”,并将名称命名为index.cshmtl。如下图。

 

3. 在我们刚才创建的index.cshmtl文件中,编写如下代码:

 

@using abp.tplms.web.startup

@{

    viewdata["title"] = pagenames.instock;
}

@section scripts{
  <script src="~/view-resources/views/instock/index.js" asp-append-version="true"></script>

    <script type="text/javascript">
          $(function () {

            initable();
             reloaded(); 

              $('#box').tabs({
                width: 780,      //选项卡容器宽度
                height: 465,      //选项卡容器高度
                onselect: function (title, index) {
                    var rcv = $("#rcvupdate").val();
                    if (title == "入库单明细") {
                        $("#rcv").val(rcv);
                    }
                }
            });
        });

    </script>
}

    <div data-options="region:'center'" style="overflow: hidden;">
        <div id="containter" style="width: 1000px; height: auto; margin: 0px auto;">
            <!--toolbar-->

            <div style="margin-bottom:1px;font-weight:bold;">
                <a href="#" id="add" class="easyui-linkbutton" data-options="iconcls:'icon-add'" style="width:100px; height:30px; ">生成入库单</a>
                <a href="#" id="del" class="easyui-linkbutton" data-options="iconcls:'icon-remove'" style="width:100px; height:30px; ">删除</a>
                <a href="#" id="edit" class="easyui-linkbutton" data-options="iconcls:'icon-edit'" style="width:100px; height:30px; ">修改</a>
                <a href="#" id="submits" class="easyui-linkbutton" data-options="iconcls:'icon-ok'" style="width:100px; height:30px; ">提交</a>
                <a href="#" id="reload" class="easyui-linkbutton" data-options="iconcls:'icon-reload'" style="width:100px; height:30px; ">刷新</a>
            </div>

            <!--panel-->
            <div data-options="region:'center',split:false" style="height:500px;">

                <!--表格-->
                <table id="dginso"></table>
            </div>
        </div>
    </div>

 

     4. 在visual studio 2017的“解决方案资源管理器”中,找到领域层“abp.tplms.web.mvc”项目中的wwwroot目录下的view-resources目录。使用鼠标右键单击此目录,在弹出菜单中选择“添加” > “新建文件夹”。并重命名为“instock”。

     5. 在visual studio 2017的“解决方案资源管理器”中,鼠标右键单击“instock”文件夹,然后选择“添加” > “新建项…”。 在“添加新项-abp.tplms.web.mvc”对话框中,选择“javascript文件”,并将名称命名为index.js。如下图

 

     6. 在index.js文件中,我们写入如下代码。

//-----------------------系统管理-->入库单管理-----------------------------------------//
//刷新数据

function initable() {
    $("#dginso").datagrid({
        url: "/instock/list",
        //url:"api/services/app/instock/getallinstockorders",
        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: 150, sortable: false },

            { title: '客户', field: 'customername', width: 60, align: 'center' },

            { title: '收货人',field: 'oper', width: 100, align: 'center' },
            { title: '审核人',field: 'checker', width: 120, align: 'center' },
            { title: '件数', field: 'packagenum', width: 120, align: 'center' },
            { title: '创建时间', field: 'creationtime', width: 100, align: 'center' }
        ]]
    }); 
} 

function reloaded() {   //reload
    $("#reload").click(function () {
        //
        $('#dginso').datagrid('reload'); 

    });}

       7. visual studio 2017中按f5运行应用程序。登录之后,点击“[入库管理]”菜单,我们可以看到货物管理列表页面。如下图。