Pārlūkot izejas kodu

增加分仓数据统计展示

lichunlei 4 gadi atpakaļ
vecāks
revīzija
a107b9df5c

+ 234 - 0
Areas/Admin/Controllers/MainServer/StoreHouseController.cs

@@ -546,6 +546,240 @@ namespace MySystem.Areas.Admin.Controllers
 
 
 
 
 
 
+        
+        #region 仓库列表
+
+        /// <summary>
+        /// 根据条件查询仓库列表
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Stat(StoreHouse data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            return View();
+        }
+
+        #endregion
+
+        #region 根据条件查询仓库列表
+
+        /// <summary>
+        /// 仓库列表
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult StatDo(string CreateDateData, int page = 1, int limit = 30)
+        {
+            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
+            string sCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
+            string eCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
+            if(!string.IsNullOrEmpty(CreateDateData))
+            {
+                string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                sCreateDate = datelist[0] + " 00:00:00";
+                eCreateDate = datelist[1] + " 23:59:59";
+            }
+            string minId = "0";
+            string maxId = "0";
+            string minPosId = "0";
+            string maxPosId = "0";
+            DataTable startDt = OtherMySqlConn.dtable("select min(Id) from StoreStockChange where CreateDate>='" + sCreateDate + "'");
+            if(startDt.Rows.Count > 0)
+            {
+                minId = function.CheckInt(startDt.Rows[0][0].ToString());
+                if(minId == "0")
+                {
+                    startDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange");
+                    if(startDt.Rows.Count > 0)
+                    {
+                        minId = function.CheckInt(startDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable endDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange where CreateDate>='" + sCreateDate + "'");
+            if(endDt.Rows.Count > 0)
+            {
+                maxId = function.CheckInt(endDt.Rows[0][0].ToString());
+                if(minId == "0")
+                {
+                    endDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange");
+                    if(endDt.Rows.Count > 0)
+                    {
+                        maxId = function.CheckInt(endDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            if(startPosDt.Rows.Count > 0)
+            {
+                minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+                if(minPosId == "0")
+                {
+                    startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+                    if(startPosDt.Rows.Count > 0)
+                    {
+                        minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            if(endPosDt.Rows.Count > 0)
+            {
+                maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+                if(maxPosId == "0")
+                {
+                    endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+                    if(endPosDt.Rows.Count > 0)
+                    {
+                        maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where c1>0 or c2>0 or c3>0");
+
+            int recordcount = list.Rows.Count;
+            List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
+            foreach (DataRow sub in list.Rows)
+            {
+                Dictionary<string, object> row = new Dictionary<string, object>();
+                row.Add("StoreName", sub["StoreName"].ToString());
+                row.Add("StoreNo", sub["StoreNo"].ToString());
+                row.Add("Mobile", sub["Mobile"].ToString());
+                row.Add("RealName", sub["RealName"].ToString());
+                row.Add("Name", sub["Name"].ToString());
+                row.Add("LaveNum", sub["LaveNum"].ToString());
+                row.Add("c1", sub["c1"].ToString());
+                row.Add("c2", sub["c2"].ToString());
+                row.Add("c3", sub["c3"].ToString());
+                diclist.Add(row);
+            }
+
+            Dictionary<string, object> obj = new Dictionary<string, object>();
+            obj.Add("code", 0);
+            obj.Add("msg", "");
+            obj.Add("count", recordcount);
+            obj.Add("data", diclist);
+            
+            return Json(obj);
+        }
+
+        #endregion
+
+        #region 导出Excel
+
+        /// <summary>
+        /// 导出Excel
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult StatExportExcel(string CreateDateData)
+        {
+            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
+            string sCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00";
+            string eCreateDate = DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59";
+            if(!string.IsNullOrEmpty(CreateDateData))
+            {
+                string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
+                sCreateDate = datelist[0] + " 00:00:00";
+                eCreateDate = datelist[1] + " 23:59:59";
+            }
+            string minId = "0";
+            string maxId = "0";
+            string minPosId = "0";
+            string maxPosId = "0";
+            DataTable startDt = OtherMySqlConn.dtable("select min(Id) from StoreStockChange where CreateDate>='" + sCreateDate + "'");
+            if(startDt.Rows.Count > 0)
+            {
+                minId = function.CheckInt(startDt.Rows[0][0].ToString());
+                if(minId == "0")
+                {
+                    startDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange");
+                    if(startDt.Rows.Count > 0)
+                    {
+                        minId = function.CheckInt(startDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable endDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange where CreateDate>='" + sCreateDate + "'");
+            if(endDt.Rows.Count > 0)
+            {
+                maxId = function.CheckInt(endDt.Rows[0][0].ToString());
+                if(minId == "0")
+                {
+                    endDt = OtherMySqlConn.dtable("select max(Id) from StoreStockChange");
+                    if(endDt.Rows.Count > 0)
+                    {
+                        maxId = function.CheckInt(endDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable startPosDt = OtherMySqlConn.dtable("select min(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            if(startPosDt.Rows.Count > 0)
+            {
+                minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+                if(minPosId == "0")
+                {
+                    startPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+                    if(startPosDt.Rows.Count > 0)
+                    {
+                        minPosId = function.CheckInt(startPosDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo where ActivationTime>='" + sCreateDate + "'");
+            if(endPosDt.Rows.Count > 0)
+            {
+                maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+                if(maxPosId == "0")
+                {
+                    endPosDt = OtherMySqlConn.dtable("select max(Id) from PosMachinesTwo");
+                    if(endPosDt.Rows.Count > 0)
+                    {
+                        maxPosId = function.CheckInt(endPosDt.Rows[0][0].ToString());
+                    }
+                }
+            }
+            DataTable list = OtherMySqlConn.dtable("select * from (select s.StoreName,s.StoreNo,u.RealName,u.Mobile,k.Name,s.LaveNum,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType=1) as c1,(select count(Id) from StoreStockChange where Id>=" + minId + " and Id<=" + maxId + " and CreateDate>='" + sCreateDate + "' and CreateDate<='" + eCreateDate + "' and StoreId=s.Id and TransType in (10,11,2)) as c2,(select count(Id) from PosMachinesTwo where Id>=" + minPosId + " and Id<=" + maxPosId + " and ActivationState=1 and ActivationTime>='" + sCreateDate + "' and ActivationTime<='" + eCreateDate + "' and StoreId=s.Id) as c3 from StoreHouse s left join Users u on s.BrandId>0 and s.UserId=u.Id left join KqProducts k on s.BrandId=k.Id) tb where c1>0 or c2>0 or c3>0");
+
+            int recordcount = list.Rows.Count;
+            List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
+            foreach (DataRow sub in list.Rows)
+            {
+                Dictionary<string, object> row = new Dictionary<string, object>();
+                row.Add("StoreName", sub["StoreName"].ToString());
+                row.Add("StoreNo", sub["StoreNo"].ToString());
+                row.Add("Mobile", sub["Mobile"].ToString());
+                row.Add("RealName", sub["RealName"].ToString());
+                row.Add("Name", sub["Name"].ToString());
+                row.Add("LaveNum", sub["LaveNum"].ToString());
+                row.Add("c1", sub["c1"].ToString());
+                row.Add("c2", sub["c2"].ToString());
+                row.Add("c3", sub["c3"].ToString());
+                diclist.Add(row);
+            }
+
+            Dictionary<string, object> result = new Dictionary<string, object>();
+            result.Add("Status", "1");
+            result.Add("Info", "分仓统计数据报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
+            result.Add("Obj", diclist);
+            Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
+            ReturnFields.Add("StoreName", "仓库名称");
+            ReturnFields.Add("StoreNo", "仓库编号");
+            ReturnFields.Add("Mobile", "仓库所属人手机号");
+            ReturnFields.Add("RealName", "仓库所属人名称");
+            ReturnFields.Add("Name", "品牌");
+            ReturnFields.Add("LaveNum", "当前库存");
+            ReturnFields.Add("c1", "出库(调拨)量");
+            ReturnFields.Add("c2", "出货(发货到创客)量");
+            ReturnFields.Add("c3", "激活量");
+            result.Add("Fields", ReturnFields);
+            AddSysLog("0", "StoreHouse", "StatExportExcel");
+            return Json(result);
+        }
+
+        #endregion
+
+
         #region 同步数据
         #region 同步数据
 
 
         /// <summary>
         /// <summary>

+ 1 - 1
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -874,7 +874,7 @@ namespace MySystem.Areas.Admin.Controllers
             }
             }
             string tradeAmount = pos.CreditTrade.ToString();
             string tradeAmount = pos.CreditTrade.ToString();
             decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
             decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
-            if (pos.BrandId != 2)
+            if (pos.BrandId != 2 && pos.BrandId != 7)
             {
             {
                 Deposit = Deposit / 100;
                 Deposit = Deposit / 100;
             }
             }

+ 73 - 0
Areas/Admin/Views/MainServer/StoreHouse/Stat.cshtml

@@ -0,0 +1,73 @@
+@{
+    string RightInfo = ViewBag.RightInfo as string;
+    string right = ViewBag.right as string;
+    
+}
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>仓库</title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
+    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
+    <script src="/admin/js/jquery-1.10.1.min.js"></script>
+    <style>
+        .layui-input-inline{
+            width: 175px !important;
+        }
+        .layui-form-label{
+            width: 128px !important;
+        }
+        .layui-inline{
+            margin-right: 0px !important;
+        }
+        .w100{
+            width: 100px !important;
+        }
+        .ml50{
+            margin-left: 50px !important;
+        }
+    </style>
+</head>
+<body>
+    <div class="layui-fluid">
+        <div class="layui-card">
+            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
+                <div class="layui-form-item">
+                    <div class="layui-inline">
+                        <label class="layui-form-label">创建时间</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" readonly name="CreateDateData" id="CreateDate"
+                                placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline ml50">
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
+                        </button>
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-searchall">
+                            <i class="layui-icon layui-icon-list layuiadmin-button-btn"></i>全部
+                        </button>
+                    </div>
+                </div>
+            </div>
+
+            <div class="layui-card-body">
+                <div style="padding-bottom: 10px;">
+                    <button class="layui-btn" data-type="ExportExcel"><i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出</button>
+                </div>                
+                <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/layuiadmin/modules_main/StoreHouseStat_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+        
+    </script>
+</body>
+</html>

+ 0 - 1
Startup.cs

@@ -138,7 +138,6 @@ namespace MySystem
             SycnProfitService.Instance.Start();
             SycnProfitService.Instance.Start();
             ExcelHelper.Instance.Start();
             ExcelHelper.Instance.Start();
             TestHelper.Instance.Start();
             TestHelper.Instance.Start();
-
         }
         }
 
 
 
 

+ 4 - 3
appsettings.json

@@ -11,12 +11,13 @@
     "ConnectionStrings": "",
     "ConnectionStrings": "",
     "Host": "http://localhost:5044/",
     "Host": "http://localhost:5044/",
     "Database": "KxsMainServer",
     "Database": "KxsMainServer",
-    "SqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
+    "SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
+    "StatSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;ConnectionTimeout=600;DefaultCommandTimeout=600;",
     "BsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsBsServer;password=wyA1bEhi6aAkN8SB;database=KxsBsServer;charset=utf8;",
     "BsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsBsServer;password=wyA1bEhi6aAkN8SB;database=KxsBsServer;charset=utf8;",
     "SpSqlConnStr": "server=47.109.31.237;port=3306;user=KxsSpServer;password=jJ9qKsvwWgQA9xWG;database=KxsSpServer;charset=utf8;",
     "SpSqlConnStr": "server=47.109.31.237;port=3306;user=KxsSpServer;password=jJ9qKsvwWgQA9xWG;database=KxsSpServer;charset=utf8;",
     "CashSqlConnStr": "server=47.109.31.237;port=3306;user=KxsCashServer;password=LNGvM18W6SaIGKBC;database=KxsCashServer;charset=utf8;",
     "CashSqlConnStr": "server=47.109.31.237;port=3306;user=KxsCashServer;password=LNGvM18W6SaIGKBC;database=KxsCashServer;charset=utf8;",
-    "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
-    "TendisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
+    "RedisConnStr": "localhost:6379,password=,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
+    "TendisConnStr": "localhost:6379,password=,DefaultDatabase=1,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "OSSKey": "",
     "OSSKey": "",

+ 657 - 0
wwwroot/layuiadmin/modules_main/StoreHouseStat_Admin.js

@@ -0,0 +1,657 @@
+var ExcelData, ExcelKind;
+
+function ConfirmImport() {
+    var index = layer.load(1, {
+        shade: [0.5, '#000']
+    });
+    $.ajax({
+        type: "POST",
+        url: "/Admin/StoreHouse/Import?r=" + Math.random(1),
+        data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            layer.close(index);
+            if (data.indexOf("success") == 0) {
+                layer.msg("成功操作" + data.split('|')[1] + "部机具", {
+                    time: 2000
+                }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+function CheckImport(table, key, loadindex, index) {
+    $.ajax({
+        url: "/Admin/StoreHouse/CheckImport?r=" + Math.random(1),
+        data: "key=" + key,
+        dataType: "text",
+        success: function (data) {
+            if (data.indexOf('success') == 0) {
+                layer.msg("成功操作" + data.split('|')[1] + "部机具", {
+                    time: 2000
+                }, function () {
+                    layer.close(index); //关闭弹层
+                    layer.close(loadindex);
+                    table.reload('LAY-list-manage'); //数据刷新
+                });
+            } else {
+                layer.msg(data, {
+                    time: 1000
+                }, function () {
+                    CheckImport(table, key, loadindex, index);
+                });
+            }
+        }
+    });
+}
+
+var excel;
+layui.config({
+    base: '/layuiadmin/' //静态资源所在路径
+}).extend({
+    myexcel: 'layui/lay/modules/excel',
+    index: 'lib/index' //主入口模块
+}).use(['index', 'table', 'excel', 'laydate'], function () {
+    var $ = layui.$,
+        form = layui.form,
+        table = layui.table;
+
+    //- 筛选条件-日期
+    var laydate = layui.laydate;
+    var layCreateDate = laydate.render({
+        elem: '#CreateDate',
+        type: 'date',
+        range: true,
+        trigger: 'click',
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 1) {
+                if (endDate.month - date.month == 1 && endDate.date > date.date) {
+                    op = false;
+                    layCreateDate.hint('日期范围请不要超过1个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layCreateDate.hint('日期范围请不要超过1个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#CreateDate').val(value);
+            }
+        }
+    });
+
+
+    //excel导入
+    excel = layui.excel;
+    $('#ExcelFile').change(function (e) {
+        var files = e.target.files;
+        excel.importExcel(files, {}, function (data) {
+            ExcelData = data[0].Sheet1;
+        });
+    });
+
+    //监听单元格编辑
+    table.on('edit(LAY-list-manage)', function (obj) {
+        var value = obj.value //得到修改后的值
+            ,
+            data = obj.data //得到所在行所有键值
+            ,
+            field = obj.field; //得到字段
+        if (field == "Sort") {
+            $.ajax({
+                type: "POST",
+                url: "/Admin/StoreHouse/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {}
+            });
+        }
+    });
+
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage',
+        url: '/Admin/StoreHouse/StatDo' //模拟接口
+            ,
+        cols: [
+            [{
+                    field: 'StoreName',
+                    width: 200,
+                    title: '仓库名称',
+                    sort: true
+                }, {
+                    field: 'StoreNo',
+                    width: 200,
+                    title: '仓库编号',
+                    sort: true
+                }, {
+                    field: 'Mobile',
+                    width: 200,
+                    title: '仓库所属人手机号',
+                    sort: true
+                }, {
+                    field: 'RealName',
+                    width: 200,
+                    title: '仓库所属人名称',
+                    sort: true
+                }, {
+                    field: 'Name',
+                    width: 200,
+                    title: '品牌',
+                    sort: true
+                }, {
+                    field: 'LaveNum',
+                    width: 200,
+                    title: '当前库存',
+                    sort: true
+                }, {
+                    field: 'c1',
+                    width: 200,
+                    title: '出库(调拨)量',
+                    sort: true
+                }, {
+                    field: 'c2',
+                    width: 200,
+                    title: '出货(发货到创客)量',
+                    sort: true
+                }, {
+                    field: 'c3',
+                    width: 200,
+                    title: '激活量',
+                    sort: true
+                }
+            ]
+        ],
+        where: {
+
+        },
+        // page: true,
+        // limit: 30,
+        height: 'full-' + String($('.layui-card-header').height() + 130),
+        text: '对不起,加载出现异常!',
+        done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+            layer.close(publicindex);
+        }
+    });
+
+    //监听工具条
+    table.on('tool(LAY-list-manage)', function (obj) {
+        var data = obj.data;
+        if (obj.event === 'del') {
+            var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        if (data == "success") {
+                            obj.del();
+                            layer.close(index);
+                        } else {
+                            parent.layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'sycn') {
+            var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
+                layer.close(index);
+                var loadindex = layer.load(1, {
+                    shade: [0.5, '#000']
+                });
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
+                    data: "Id=" + data.Id,
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(loadindex);
+                        if (data == "success") {
+                            layer.msg('同步成功');
+                            table.reload('LAY-list-manage');
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            });
+        } else if (obj.event === 'edit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2,
+                title: '仓库-编辑',
+                content: 'Edit?Id=' + data.Id + '',
+                maxmin: true,
+                area: ['800px', '650px'],
+                btn: ['确定', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data == "success") {
+                                    layer.close(index); //关闭弹层
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                },
+                success: function (layero, index) {
+
+                }
+            });
+        }
+    });
+
+
+    //监听搜索
+    var publicindex;
+    form.on('submit(LAY-list-front-search)', function (data) {
+        publicindex = layer.load(1, {
+            shade: [0.5, '#000']
+        });
+        var field = data.field;
+
+        //执行重载
+        table.reload('LAY-list-manage', {
+            where: field
+        });
+    });
+    form.on('submit(LAY-list-front-searchall)', function (data) {
+        publicindex = layer.load(1, {
+            shade: [0.5, '#000']
+        });
+        table.reload('LAY-list-manage', {
+            where: null
+        });
+    });
+
+    //事件
+    var active = {
+        batchdel: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage'),
+                data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要删除的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        },
+        add: function () {
+            var perContent = layer.open({
+                type: 2,
+                title: '仓库-添加',
+                content: 'Add',
+                maxmin: true,
+                area: ['950px', '650px'],
+                btn: ['确定', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+                    setTimeout(function () {
+                        layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
+                            var errObj = $(this).find('.layui-form-danger');
+                            if (errObj.length > 0) {
+                                iframeWindow.element.tabChange('mytabbar', String(i + 1));
+                                submit.click();
+                            }
+                        });
+                    }, 300);
+
+
+
+
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data == "success") {
+                                    layer.close(index); //关闭弹层
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+        },
+        ImportMachine: function () {
+            var perContent = layer.open({
+                type: 2,
+                title: '机具入库',
+                content: 'Import?ExcelKind=1',
+                maxmin: true,
+                area: ['650px', '350px'],
+                btn: ['确定', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+                        var loadindex = layer.load(1, {
+                            shade: [0.5, '#000']
+                        });
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data.indexOf("success") == 0) {
+                                    var datalist = data.split('|');
+                                    var key = datalist[1];
+                                    CheckImport(table, key, loadindex, index);
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+        },
+        ImportChange: function () {
+            var perContent = layer.open({
+                type: 2,
+                title: '仓库调拨',
+                content: 'Import?ExcelKind=2',
+                maxmin: true,
+                area: ['650px', '350px'],
+                btn: ['确定', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+                        var loadindex = layer.load(1, {
+                            shade: [0.5, '#000']
+                        });
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data.indexOf("success") == 0) {
+                                    var datalist = data.split('|');
+                                    var key = datalist[1];
+                                    CheckImport(table, key, loadindex, index);
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+        },
+        ImportSend: function () {
+            var perContent = layer.open({
+                type: 2,
+                title: '仓库发货至创客',
+                content: 'Import?ExcelKind=3',
+                maxmin: true,
+                area: ['650px', '350px'],
+                btn: ['确定', '取消'],
+                yes: function (index, layero) {
+                    var iframeWindow = window['layui-layer-iframe' + index],
+                        submitID = 'LAY-list-front-submit',
+                        submit = layero.find('iframe').contents().find('#' + submitID);
+
+
+                    //监听提交
+                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
+                        var field = data.field; //获取提交的字段
+                        var userdata = "";
+                        for (var prop in field) {
+                            userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
+                        }
+                        //提交 Ajax 成功后,静态更新表格中的数据
+                        //$.ajax({});
+                        var loadindex = layer.load(1, {
+                            shade: [0.5, '#000']
+                        });
+                        $.ajax({
+                            type: "POST",
+                            url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                if (data.indexOf("success") == 0) {
+                                    var datalist = data.split('|');
+                                    var key = datalist[1];
+                                    CheckImport(table, key, loadindex, index);
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+        },
+        ExportExcel: function () {
+            var loadindex = layer.load(1, {
+                shade: [0.5, '#000']
+            });
+            var userdata = '';
+            $(".layuiadmin-card-header-auto input").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $(".layuiadmin-card-header-auto select").each(function (i) {
+                userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
+            });
+            $.ajax({
+                type: "GET",
+                url: "/Admin/StoreHouse/StatExportExcel?r=" + Math.random(1),
+                data: userdata,
+                dataType: "json",
+                success: function (data) {
+                    data.Obj.unshift(data.Fields);
+                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
+                    layer.close(loadindex);
+                }
+            });
+        },
+        Open: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage'),
+                data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要开启的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要开启吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        },
+        Close: function () {
+            var checkStatus = table.checkStatus('LAY-list-manage'),
+                data = checkStatus.data; //得到选中的数据
+            if (data.length < 1) {
+                parent.layer.msg("请选择要关闭的项");
+            } else {
+                var ids = "";
+                $.each(data, function (index, value) {
+                    ids += data[index].Id + ",";
+                });
+                ids = ids.substring(0, ids.length - 1);
+                var index = layer.confirm('确定要关闭吗?', function (index) {
+                    $.ajax({
+                        type: "POST",
+                        url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
+                        data: "Id=" + ids,
+                        dataType: "text",
+                        success: function (data) {
+                            layer.close(index);
+                            if (data == "success") {
+                                table.reload('LAY-list-manage');
+                            } else {
+                                layer.msg(data);
+                            }
+                        }
+                    });
+                });
+            }
+        },
+        SycnData: function () {
+            var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
+                layer.close(index);
+                var loadindex = layer.load(1, {
+                    shade: [0.5, '#000']
+                });
+                $.ajax({
+                    type: "POST",
+                    url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
+                    data: "Id=0",
+                    dataType: "text",
+                    success: function (data) {
+                        layer.close(loadindex);
+                        if (data == "success") {
+                            layer.msg('同步成功');
+                            table.reload('LAY-list-manage');
+                        } else {
+                            layer.msg(data);
+                        }
+                    }
+                });
+            });
+        },
+    };
+
+    $('.layui-btn').on('click', function () {
+        var type = $(this).data('type');
+        active[type] ? active[type].call(this) : '';
+    });
+});