DuGuYang před 3 roky
rodič
revize
e1d60714db

+ 138 - 0
Areas/Admin/Controllers/MainServer/SetMerchantTypeRecordController.cs

@@ -0,0 +1,138 @@
+/*
+ * 设置商户型创客记录
+ */
+
+using System;
+using System.Web;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+using MySystem.Models;
+using Library;
+using LitJson;
+using MySystemLib;
+
+namespace MySystem.Areas.Admin.Controllers
+{
+    [Area("Admin")]
+    [Route("Admin/[controller]/[action]")]
+    public class SetMerchantTypeRecordController : BaseController
+    {
+        public SetMerchantTypeRecordController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
+        {
+            OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+        }
+
+        #region 设置商户型创客记录
+
+        /// <summary>
+        /// 根据条件查询设置商户型创客记录
+        /// </summary>
+        /// <returns></returns>
+        public IActionResult Index(StoreSwapSn data, string right)
+        {
+            ViewBag.RightInfo = RightInfo;
+            ViewBag.right = right;
+
+            return View();
+        }
+
+        #endregion
+
+        #region 根据条件查询设置商户型创客记录
+
+        /// <summary>
+        /// 设置商户型创客记录
+        /// </summary>
+        /// <returns></returns>
+        public JsonResult IndexData(StoreSwapSn data, string MakerCode, string RealName, string SnTypeSelect, string SwapStatusSelect, string BizStatusSelect, string RiskStatusSelect, int page = 1, int limit = 30)
+        {
+
+            Dictionary<string, string> Fields = new Dictionary<string, string>();
+
+            Fields.Add("BrandId", "1"); //品牌
+            Fields.Add("SnNo", "1"); //SN号
+            Fields.Add("StandardDate", "3"); //激活时间
+            Fields.Add("SwapSnNo", "1"); //兑换SN号
+            Fields.Add("SwapApplyOrderNo", "1"); //兑换申请单号
+            Fields.Add("SwapApplyDate", "3"); //兑换时间
+
+            string condition = " and Status>-1";
+            //创客编号
+            if (!string.IsNullOrEmpty(MakerCode))
+            {
+                condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
+            }
+            //创客名称
+            if (!string.IsNullOrEmpty(RealName))
+            {
+                condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
+            }
+            //SN类型
+            if(!string.IsNullOrEmpty(SnTypeSelect))
+            {
+                condition += " and SnType=" + SnTypeSelect;
+            }
+            //兑换状态
+            if(!string.IsNullOrEmpty(SwapStatusSelect))
+            {
+                condition += " and SwapStatus=" + SwapStatusSelect;
+            }
+            //业务状态
+            if(!string.IsNullOrEmpty(BizStatusSelect))
+            {
+                condition += " and BizStatus=" + BizStatusSelect;
+            }
+            //风控状态
+            if(!string.IsNullOrEmpty(RiskStatusSelect))
+            {
+                condition += " and RiskStatus=" + RiskStatusSelect;
+            }
+
+            Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("SetMerchantTypeRecord", Fields, "Id desc", "0", page, limit, condition);
+            List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
+            foreach (Dictionary<string, object> dic in diclist)
+            {
+                dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
+                dic["SwapExtProductTypes"] = RelationClass.GetKqProductBrandList(dic["SwapExtProductTypes"].ToString());
+
+                //创客信息
+                int UserId = int.Parse(dic["UserId"].ToString());
+                Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                dic["MakerCode"] = puser.MakerCode;
+                dic["MakerName"] = puser.RealName;
+
+                //SN类型
+                int SnType = int.Parse(dic["SnType"].ToString());
+                if(SnType == 0) dic["SnType"] = "兑换机具";
+                if(SnType == 1) dic["SnType"] = "循环机具";
+
+                //兑换状态
+                int SwapStatus = int.Parse(dic["SwapStatus"].ToString());
+                if(SwapStatus == 0) dic["SwapStatus"] = "未兑换";
+                if(SwapStatus == 1) dic["SwapStatus"] = "兑换中";
+                if(SwapStatus == 2) dic["SwapStatus"] = "已兑换";
+                
+                //业务状态
+                int BizStatus = int.Parse(dic["BizStatus"].ToString());
+                if(BizStatus == 0) dic["BizStatus"] = "正常";
+                if(BizStatus == 1) dic["BizStatus"] = "异常";
+                
+                //风控状态
+                int RiskStatus = int.Parse(dic["RiskStatus"].ToString());
+                if(RiskStatus == 0) dic["RiskStatus"] = "未风控";
+                if(RiskStatus == 1) dic["RiskStatus"] = "已风控";
+
+            }
+            return Json(obj);
+        }
+
+        #endregion
+
+    }
+}

+ 92 - 53
Areas/Admin/Controllers/MainServer/SysToolsController.cs

@@ -875,7 +875,7 @@ namespace MySystem.Areas.Admin.Controllers
         }
 
         [HttpPost]
-        public string CancelMerAgentDo(string MakerCode, string PosSn, int IsSend = 0)
+        public string CancelMerAgentDo(string MakerCode, string PosSn, string MerNo, int IsSend = 0)
         {
             if (string.IsNullOrEmpty(MakerCode))
             {
@@ -885,6 +885,10 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "请输入机具SN";
             }
+            if (string.IsNullOrEmpty(MerNo))
+            {
+                return "请输入商户编号";
+            }
             PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
             KqProducts kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId);
             if (pos == null)
@@ -896,11 +900,26 @@ namespace MySystem.Areas.Admin.Controllers
             {
                 return "创客编号不存在";
             }
-            PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == PosSn);
+            PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == MerNo);
             pos.UserId = pos.BuyUserId;
             merchant.UserId = pos.BuyUserId;
             merchant.MerUserType = 0;
             user.MerchantType = 0;
+            db.SetMerchantTypeRecord.Add(new SetMerchantTypeRecord()
+            {
+                CreateDate = DateTime.Now,
+                IsRecyc = (ulong)pos.IsPurchase,
+                CreditAmount = pos.CreditTrade,
+                PosSnType = pos.PosSnType,
+                ActDate = pos.ActivationTime,
+                BindDate = pos.BindingTime,
+                ActStatus = (ulong)pos.ActivationState,
+                BindStatus = (ulong)pos.BindingState,
+                MerNo = MerNo,
+                PosSn = pos.PosSn,
+                Note = "后台取消商户型创客",
+                // OpeateType = 1,
+            });
             db.SaveChanges();
             if (pos.BindMerchantId == 0)
             {
@@ -3973,29 +3992,29 @@ namespace MySystem.Areas.Admin.Controllers
                         SourceStoreId = posInfo.SourceStoreId, //源仓库
                         ToUserId = tUserId.Id,//收货创客
                     });
-                    // UserStoreChange userstore = db.UserStoreChange.Add(new UserStoreChange()
-                    // {
-                    //     CreateDate = DateTime.Now,
-                    //     UserId = fUserId.Id, //创客
-                    //     BrandId = posInfo.BrandId, //产品类型
-                    //     ChangeRecordNo = ChangeRecordNo, //变更记录单号
-                    //     TransType = 0, //交易类型
-                    //     SnNo = posInfo.PosSn, //SN编号
-                    //     SnType = posInfo.PosSnType, //SN机具类型
-                    //     StockOpDirect = 0, //库存操作方向
-                    //     DeviceVendor = posInfo.DeviceName, //设备厂商
-                    //     DeviceType = posInfo.DeviceKind, //设备类型
-                    //     DeviceModel = posInfo.DeviceType, //设备型号
-                    //     ToUserId = tUserId.Id, //收货创客
-                    //     ToDate = DateTime.Now, //入库时间
-                    //     SourceStoreId = posInfo.SourceStoreId, //源仓库
-                    //     SnStatus = 1, //SN状态
-                    //     BindStatus = (int)posInfo.BindingState, //绑定状态
-                    //     BindMerchantId = posInfo.BindMerchantId, //绑定商户
-                    //     ActiveStatus = (int)posInfo.ActivationState, //激活状态
-                    //     ActRewardUserId = posInfo.BuyUserId, //激活奖励创客
-                    //     BrandType = posInfo.DeviceType, //品牌类型
-                    // }).Entity;
+                    UserStoreChange userstore = db.UserStoreChange.Add(new UserStoreChange()
+                    {
+                        CreateDate = DateTime.Now,
+                        UserId = fUserId.Id, //创客
+                        BrandId = posInfo.BrandId, //产品类型
+                        ChangeRecordNo = ChangeRecordNo, //变更记录单号
+                        TransType = 0, //交易类型
+                        SnNo = posInfo.PosSn, //SN编号
+                        SnType = posInfo.PosSnType, //SN机具类型
+                        StockOpDirect = 0, //库存操作方向
+                        DeviceVendor = posInfo.DeviceName, //设备厂商
+                        DeviceType = posInfo.DeviceKind, //设备类型
+                        DeviceModel = posInfo.DeviceType, //设备型号
+                        ToUserId = tUserId.Id, //收货创客
+                        ToDate = DateTime.Now, //入库时间
+                        SourceStoreId = posInfo.SourceStoreId, //源仓库
+                        SnStatus = 1, //SN状态
+                        BindStatus = (int)posInfo.BindingState, //绑定状态
+                        BindMerchantId = posInfo.BindMerchantId, //绑定商户
+                        ActiveStatus = (int)posInfo.ActivationState, //激活状态
+                        ActRewardUserId = posInfo.BuyUserId, //激活奖励创客
+                        BrandType = posInfo.DeviceType, //品牌类型
+                    }).Entity;
                 }
                 var query = SnIds + ";" + FromMakerCode + ";" + ToMakerCode;
                 function.WriteLog(DateTime.Now.ToString() + ":请求参数," + query + ":" + SysUserName + "-" + SysRealName, "划拨创客机具");
@@ -4270,39 +4289,59 @@ namespace MySystem.Areas.Admin.Controllers
                 {
                     return "机具券" + PosCouponCode + "已使用";
                 }
+                if (item.QueryCount != int.Parse(Kind))
+                {
+                    return "机具券" + PosCouponCode + "类型和您选择的类型不同";
+                }
                 item.UserId = tUserId.Id;
                 if (LeaderUserId > 0 && item.LeaderUserId == 0)
                 {
                     item.LeaderUserId = LeaderUserId;
                 }
-                // PosCouponRecord posCouponRecord = db.PosCouponRecord.Add(new PosCouponRecord()
-                // {
-                //     QueryCount = item.QueryCount,//券类型(1 电签 2 大POS)
-                //     CreateDate = DateTime.Now,
-                //     ChangeKind = 1,//类型(0购买,1划拨,2使⽤,3申请机具循环驳回)
-                //     OrderNo = ChangeRecordNo,
-                //     ToUserId = tUserId.Id,
-                //     FromUserId = fUserId.Id,
-                //     PosCouponId = item.Id,
-                // }).Entity;
-            }
-            // int CouponCount = PosCouponList.Length;
-            // PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
-            // {
-            //     QueryCount = 2,
-            //     CreateDate = DateTime.Now,
-            //     ChangeKind = 2,
-            //     ChangeCount = CouponCount,
-            //     // AfterOut = AfterOut,
-            //     // AfterTotal = AfterTotal,
-            //     // AfterStock = AfterStock,
-            //     // BeforeOut = BeforeOut,
-            //     // BeforeTotal = BeforeTotal,
-            //     // BeforeStock = BeforeStock,
-            //     OrderNo = ChangeRecordNo,
-            //     ToUserId = tUserId.Id,
-            //     FromUserId = fUserId.Id,
-            // }).Entity;
+                PosCouponRecord posCouponRecord = db.PosCouponRecord.Add(new PosCouponRecord()
+                {
+                    QueryCount = item.QueryCount,//券类型(1 电签 2 大POS)
+                    CreateDate = DateTime.Now,
+                    ChangeKind = 1,//类型(0购买,1划拨,2使⽤,3申请机具循环驳回)
+                    OrderNo = ChangeRecordNo,
+                    ToUserId = tUserId.Id,
+                    FromUserId = fUserId.Id,
+                    PosCouponId = item.Id,
+                }).Entity;
+            }
+            int CouponCount = PosCouponList.Length;
+            PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
+            {
+                QueryCount = int.Parse(Kind),
+                CreateDate = DateTime.Now,
+                ChangeKind = 2,
+                ChangeCount = CouponCount,
+                // AfterOut = AfterOut,
+                // AfterTotal = AfterTotal,
+                // AfterStock = AfterStock,
+                // BeforeOut = BeforeOut,
+                // BeforeTotal = BeforeTotal,
+                // BeforeStock = BeforeStock,
+                OrderNo = ChangeRecordNo,
+                ToUserId = tUserId.Id,
+                FromUserId = fUserId.Id,
+            }).Entity;
+            PosCouponOrders tostat = db.PosCouponOrders.Add(new PosCouponOrders()
+            {
+                QueryCount = int.Parse(Kind),
+                CreateDate = DateTime.Now,
+                ChangeKind = 1,
+                ChangeCount = CouponCount,
+                // AfterOut = AfterOut,
+                // AfterTotal = AfterTotal,
+                // AfterStock = AfterStock,
+                // BeforeOut = BeforeOut,
+                // BeforeTotal = BeforeTotal,
+                // BeforeStock = BeforeStock,
+                // OrderNo = ChangeRecordNo,
+                ToUserId = fUserId.Id,
+                FromUserId = tUserId.Id,
+            }).Entity;
             db.SaveChanges();
             db.Dispose();
 

+ 185 - 0
Areas/Admin/Views/MainServer/SetMerchantTypeRecord/Index.cshtml

@@ -0,0 +1,185 @@
+@{
+    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: 85px !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" name="StoreNo" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    <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">
+                        <label class="layui-form-label">仓库名称</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="StoreName" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    @* <div class="layui-inline">
+                        <label class="layui-form-label">仓库归属人</label>
+                        <div class="layui-input-inline">
+                            <select id="UserIdSelect" name="UserIdSelect" lay-search="">
+                                <option value="">全部...</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">产品类型</label>
+                        <div class="layui-input-inline">
+                            <select id="BrandId" name="BrandId" lay-search="">
+                                <option value="">全部...</option>
+                            </select>
+                        </div>
+                    </div> *@
+                    <div class="layui-inline">
+                        <label class="layui-form-label">仓库归属人手机号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="Mobile" placeholder="" autocomplete="off">
+                        </div>
+                    </div>
+                    @* <div class="layui-inline">
+                        <label class="layui-form-label">出货仓库编号</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="FromStoreIdStoreNo" autocomplete="off">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <label class="layui-form-label">出货仓库名称</label>
+                        <div class="layui-input-inline">
+                            <input class="layui-input" type="text" name="FromStoreIdStoreName" 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;">
+                    @if (RightInfo.Contains("," + right + "_add,"))
+                    {
+                        <button class="layui-btn" data-type="add"><i
+                            class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>添加</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                        <button class="layui-btn" data-type="batchdel"><i
+                            class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除</button>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <button class="layui-btn" data-type="ImportData"><i
+                            class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导入</button>
+                        <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>
+                <script type="text/html" id="table-list-tools">
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_delete,"))
+                    {
+                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+                    }
+                    @if (RightInfo.Contains("," + right + "_edit,"))
+                    {
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-href="/Admin/PreSendStockDetail/Index?right=@right&StoreId=@("{{d.Id}}")">预发货库存明细</a>
+
+                    }
+                </script>
+            </div>
+        </div>
+    </div>
+    <div id="excelForm" style="display:none; padding:20px;">
+        <div class="layui-tab-item layui-show">
+            <div class="layui-form-item">
+                <label class="layui-form-label">模板下载</label>
+                <div class="layui-form-mid layui-word-aux" id="excelTemp">
+                </div>
+            </div>
+            <div class="layui-form-item">
+                <label class="layui-form-label">excel文件</label>
+                <div class="layui-form-mid layui-word-aux">
+                    <div class="layui-upload">
+                        <input type="file" id="ExcelFile" name="ExcelFile" value="">
+                    </div>
+                    <div class="mt10" id="ExcelFileList">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div class="layui-form-item ml10">
+            <div class="layui-input-block">
+                <button type="button" class="layui-btn" onclick="ConfirmImport()">立即导入</button>
+            </div>
+        </div>
+    </div>
+
+    <script src="/layuiadmin/layui/layui.js"></script>
+    <script src="/layuiadmin/modules_main/SmallStoreHouse_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script>
+
+    </script>
+</body>
+
+</html>

+ 8 - 0
Areas/Admin/Views/MainServer/SysTools/CancelMerAgent.cshtml

@@ -43,6 +43,14 @@
                                             autocomplete="off" placeholder="请输入机具SN">
                                     </div>
                                 </div>
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">商户编号</label>
+                                    <div class="layui-input-inline">
+                                        <input class="layui-input" type="text" id="MerNo"
+                                            name="MerNo" maxlength="50" lay-verify="required|"
+                                            autocomplete="off" placeholder="请输入商户编号">
+                                    </div>
+                                </div>
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">是否推送消息</label>
                                     <div class="layui-input-block">

+ 9 - 0
Areas/Admin/Views/MainServer/SysTools/TransferPosCoupon.cshtml

@@ -30,6 +30,15 @@
                         </ul>
                         <div class="layui-tab-content mt20">
                             <div class="layui-tab-item layui-show">
+                                <div class="layui-form-item">
+                                    <label class="layui-form-label">券类型</label>
+                                    <div class="layui-input-inline">
+                                        <select id="Kind" name="Kind" lay-search="">
+                                            <option value="1">电签券</option>
+                                            <option value="2">大POS券</option>
+                                        </select>
+                                    </div>
+                                </div>
                                 <div class="layui-form-item">
                                     <label class="layui-form-label">机具券码</label>
                                     <div class="layui-input-block">

+ 415 - 0
wwwroot/layuiadmin/modules_main/SetMerchantTypeRecord_Admin.js

@@ -0,0 +1,415 @@
+var ExcelData, ExcelKind;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/SetMerchantTypeRecord/Import?r=" + Math.random(1),
+        data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
+        dataType: "text",
+        success: function (data) {
+            if (data == "success") {
+                layer.msg("导入成功", { time: 2000 }, function () {
+                    window.location.reload();
+                });
+            } else {
+                layer.msg(data);
+            }
+        }
+    });
+}
+
+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/SetMerchantTypeRecord/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+
+    //列表数据
+    table.render({
+        elem: '#LAY-list-manage'
+        , url: '/Admin/SetMerchantTypeRecord/IndexData' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            , { field: 'StoreIdStoreNo', width: 200, title: '仓库编号', sort: true }
+            , { field: 'StoreIdStoreName', width: 200, title: '仓库名称', sort: true }
+            , { field: 'BrandId', width: 200, title: '产品类型', sort: true }
+            , { field: 'TransType', width: 200, title: '交易类型', sort: true }
+            , { field: 'SnNo', width: 200, title: 'SN编号', sort: true }
+            , { field: 'StockOpDirect', width: 200, title: '库存操作方向', sort: true }
+            , { field: 'SnStatus', width: 200, title: 'SN状态', sort: true }
+            , { field: 'BindStatus', width: 200, title: '绑定状态', sort: true }
+            , { field: 'BindMerchantMerchantNo', width: 200, title: '绑定商户编号', sort: true }
+            , { field: 'BindMerchantMerchantName', width: 200, title: '绑定商户姓名', sort: true }
+            , { field: 'ActiveStatus', width: 200, title: '激活状态', sort: true }
+            , { field: 'ExpressNo', width: 200, title: '快递单号', sort: true }
+            , { field: 'BrandType', width: 200, title: '品牌类型', sort: true }
+            , { field: 'CreateDate', width: 200, title: '变动时间', sort: true }
+            // SN、机具类型、操作类别(关联、取消关联)、商户型创客姓名、商户型创客编码、机具所属创客姓名、机具所属创客编码、转换时间、取消转换时间、操作人、操作
+        ]]
+        , where: {
+
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-' + String($('.layui-card-header').height() + 130)
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+        }
+    });
+
+    //监听工具条
+    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/SetMerchantTypeRecord/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 === 'edit') {
+            var tr = $(obj.tr);
+            var perContent = layer.open({
+                type: 2
+                , title: '仓库库存变动记录-编辑'
+                , content: 'Edit?Id=' + data.Id + ''
+                , maxmin: true
+                , area: ['500px', '450px']
+                , 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/SetMerchantTypeRecord/Edit?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+                , success: function (layero, index) {
+
+                }
+            });
+            layer.full(perContent);
+        }
+    });
+
+
+    //监听搜索
+    form.on('submit(LAY-list-front-search)', function (data) {
+        var field = data.field;
+
+        //执行重载
+        table.reload('LAY-list-manage', {
+            where: field,
+            page: {
+                curr: 1
+            }
+        });
+    });
+    form.on('submit(LAY-list-front-searchall)', function (data) {
+        table.reload('LAY-list-manage', {
+            where: null,
+            page: {
+                curr: 1
+            }
+        });
+    });
+
+    //事件
+    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/SetMerchantTypeRecord/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: ['500px', '450px']
+                , 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/SetMerchantTypeRecord/Add?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    table.reload('LAY-list-manage'); //数据刷新
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+            layer.full(perContent);
+        }
+        , ImportData: function () {
+            ExcelKind = 1;
+            layer.open({
+                type: 1,
+                title: '导入',
+                maxmin: false,
+                area: ['460px', '280px'],
+                content: $('#excelForm'),
+                cancel: function () {
+                }
+            });
+            $("#excelTemp").html('<a href="/excelfile/模板文件.xlsx">点击下载模板文件</a>');
+        }
+        , ExportExcel: function () {
+            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/SetMerchantTypeRecord/ExportExcel?r=" + Math.random(1),
+                data: userdata,
+                dataType: "json",
+                success: function (data) {
+                    data.Obj.unshift(data.Fields);
+                    excel.exportExcel(data.Obj, data.Info, 'xlsx');
+                }
+            });
+        }
+        , 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/SetMerchantTypeRecord/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/SetMerchantTypeRecord/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);
+                            }
+                        }
+                    });
+                });
+            }
+        }
+    };
+
+    $('.layui-btn').on('click', function () {
+        var type = $(this).data('type');
+        active[type] ? active[type].call(this) : '';
+    });
+});