DuGuYang %!s(int64=2) %!d(string=hai) anos
pai
achega
841637b49e

+ 1 - 1
Areas/Admin/Views/MainServer/TradeRecord/Index.cshtml

@@ -148,7 +148,7 @@
                             <button class="layui-btn" data-type="ImportTrade">
                                 <i class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>导交易
                             </button>
-                            <button class="layui-btn" data-type="GetActInfo">
+                            <button class="layui-btn" lay-href="IndexDataSIM">
                                 <i class="layui-icon layui-icon-upload layuiadmin-button-btn"></i>获取激活信息
                             </button>
                             }

+ 14 - 4
Areas/Admin/Views/MainServer/TradeRecord/IndexDataSIM.cshtml

@@ -1,4 +1,4 @@
-@* @{
+@{
     string RightInfo = ViewBag.RightInfo as string;
     string right = ViewBag.right as string;
     string DateStr = ViewBag.DateStr as string;
@@ -45,11 +45,21 @@
                                 lay-verify="" autocomplete="off" placeholder="请输入日期">
                         </div>
                     </div>
+                    <div class="layui-form-item">
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>预览
+                        </button>
+                    </div>
+                    <div class="layui-form-item">                                          
+                        <button class="layui-btn" lay-submit lay-filter="LAY-list-front-search">
+                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>执行
+                        </button>
+                    </div>
                 </div>
             </div>
 
             <div class="layui-card-body">
-                <table id="LAY-list-managesim" lay-filter="LAY-list-managesim"></table>
+                <table id="LAY-list-manage" lay-filter="LAY-list-manage"></table>
                 <script type="text/html" id="table-list-tools">
                 </script>
             </div>
@@ -57,9 +67,9 @@
     </div>
 
     <script src="/layuiadmin/layui/layui.js"></script>
-    <script src="/layuiadmin/modules_main/TradeRecord_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
+    <script src="/layuiadmin/modules_main/TradeRecordSIM_Admin.js?r=@DateTime.Now.ToString("yyyyMMddHHmmss")"></script>
     <script>
         var DateStr = '@DateStr';
     </script>
 </body>
-</html> *@
+</html>

+ 287 - 0
wwwroot/layuiadmin/modules_main/TradeRecordSIM_Admin.js

@@ -0,0 +1,287 @@
+var ExcelData;
+function ConfirmImport() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/TradeRecord/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);
+            }
+        }
+    });
+}
+
+function ConfirmImportTrade() {
+    $.ajax({
+        type: "POST",
+        url: "/Admin/TradeRecord/ImportTrade?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);
+            }
+        }
+    });
+}
+
+function CheckImport(table, key, loadindex, index) {
+    $.ajax({
+        url: "/Admin/TradeRecord/CheckImportV2?r=" + Math.random(1),
+        data: "key=" + key,
+        dataType: "json",
+        success: function (data) {
+            console.log(data);
+            if (data.status == 1) {
+                layer.msg("成功操作" + data.data + "条", {
+                    time: 2000
+                }, function () {
+                    layer.close(index); //关闭弹层
+                    layer.close(loadindex);
+                    table.reload('LAY-list-manage'); //数据刷新
+                });
+            } else if (data.status == 2) {
+                layer.close(index); //关闭弹层
+                layer.close(loadindex);
+                var content = '';
+                for (var i = 0; i < data.errList.length; i++) {
+                    content += data.errList[i] + '<br/>'
+                }
+                layer.alert(content);
+            } else {
+                layer.msg(data.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);
+            }
+        }
+    });
+    var layTradeDate = laydate.render({
+        elem: '#TradeDate',
+        trigger: 'click',
+        type: 'date',
+        range: true,
+        change: function (value, date, endDate) {
+            var op = true;
+            if (date.year == endDate.year && endDate.month - date.month <= 2) {
+                if (endDate.month - date.month == 2 && endDate.date > date.date) {
+                    op = false;
+                    layTradeDate.hint('日期范围请不要超过2个月');
+                    setTimeout(function () {
+                        $(".laydate-btns-confirm").addClass("laydate-disabled");
+                    }, 1);
+                }
+            } else {
+                op = false;
+                layTradeDate.hint('日期范围请不要超过2个月');
+                setTimeout(function () {
+                    $(".laydate-btns-confirm").addClass("laydate-disabled");
+                }, 1);
+            }
+            if (op) {
+                $('#TradeDate').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/TradeRecord/Sort?r=" + Math.random(1),
+                data: "Id=" + data.Id + "&Sort=" + value,
+                dataType: "text",
+                success: function (data) {
+                }
+            });
+        }
+    });
+
+    //激活预览列表数据
+    table.render({
+        elem: '#LAY-list-managesim'
+        , url: '/Admin/TradeRecord/IndexDataSIMDo' //模拟接口
+        , cols: [[
+            { type: 'checkbox', fixed: 'left' }
+            , { field: 'iccId', width: 200, title: '广电卡号', sort: true } //广电卡号
+            , { field: 'orderNo', width: 200, title: '订单编码', sort: true } //订单编码
+            , { field: 'orderCreateTime', width: 200, title: '订单创建时间', sort: true } //订单创建时间
+            , { field: 'phoneNo', width: 200, title: '选择号码', sort: true } //选择号码
+            , { field: 'firstCharge', width: 200, title: '是否有首充', sort: true } //是否有首充
+            , { field: 'initialChargeAmount', width: 200, title: '首充金额(元)', sort: true } //首充金额(元)
+            , { field: 'province', width: 200, title: '号码归属省份', sort: true } //号码归属省份
+            , { field: 'city', width: 200, title: '号码归属地市', sort: true } //号码归属地市
+            , { field: 'productName', width: 200, title: '商品名称', sort: true } //商品名称
+            , { field: 'promotionName', width: 200, title: '促销活动名称', sort: true } //促销活动名称
+            , { field: 'productTypeName', width: 200, title: '商品类型名称', sort: true } //商品类型名称
+            , { field: 'paidInAmount', width: 200, title: '实付金额', sort: true } //实付金额(元)
+            , { field: 'orderStatus', width: 200, title: '订单状态', sort: true } //订单状态
+            , { field: 'activationStatusName', width: 200, title: '激活状态名称', sort: true } //激活状态名称
+            , { field: 'activationTime', width: 200, title: '激活时间', sort: true } //激活时间
+            , { field: 'jobId', width: 200, title: 'BOSS员工工号', sort: true } //BOSS员工工号
+        ]]
+        , where: {
+            DateStr: DateStr
+        }
+        , page: true
+        , limit: 30
+        , height: 'full-' + String($('.layui-card-header').height() + 130)
+        , text: '对不起,加载出现异常!'
+        , done: function (res, curr, count) {
+            $(".layui-none").text("无数据");
+        }
+    });
+
+
+    //监听搜索
+    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 = {
+        GetActInfo: function () {
+            var perContent = layer.open({
+                type: 2
+                , title: '获取广电卡激活数据'
+                , content: 'GetSimTrade'
+                , 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/TradeRecord/GetSimTradePost?r=" + Math.random(1),
+                            data: userdata,
+                            dataType: "text",
+                            success: function (data) {
+                                layer.close(index); //关闭弹层
+                                if (data == "success") {
+                                    layer.msg("提交成功");
+                                } else {
+                                    layer.msg(data);
+                                }
+                            }
+                        });
+                    });
+
+                    submit.trigger('click');
+                }
+            });
+        }
+    };
+
+    $('.layui-btn').on('click', function () {
+        var type = $(this).data('type');
+        active[type] ? active[type].call(this) : '';
+    });
+});

+ 0 - 36
wwwroot/layuiadmin/modules_main/TradeRecord_Admin.js

@@ -208,42 +208,6 @@ layui.config({
         }
     });
 
-
-    // //激活预览列表数据
-    // table.render({
-    //     elem: '#LAY-list-managesim'
-    //     , url: '/Admin/TradeRecord/IndexDataSIMDo' //模拟接口
-    //     , cols: [[
-    //         { type: 'checkbox', fixed: 'left' }
-    //         , { field: 'iccId', width: 200, title: '广电卡号', sort: true } //广电卡号
-    //         , { field: 'orderNo', width: 200, title: '订单编码', sort: true } //订单编码
-    //         , { field: 'orderCreateTime', width: 200, title: '订单创建时间', sort: true } //订单创建时间
-    //         , { field: 'phoneNo', width: 200, title: '选择号码', sort: true } //选择号码
-    //         , { field: 'firstCharge', width: 200, title: '是否有首充', sort: true } //是否有首充
-    //         , { field: 'initialChargeAmount', width: 200, title: '首充金额(元)', sort: true } //首充金额(元)
-    //         , { field: 'province', width: 200, title: '号码归属省份', sort: true } //号码归属省份
-    //         , { field: 'city', width: 200, title: '号码归属地市', sort: true } //号码归属地市
-    //         , { field: 'productName', width: 200, title: '商品名称', sort: true } //商品名称
-    //         , { field: 'promotionName', width: 200, title: '促销活动名称', sort: true } //促销活动名称
-    //         , { field: 'productTypeName', width: 200, title: '商品类型名称', sort: true } //商品类型名称
-    //         , { field: 'paidInAmount', width: 200, title: '实付金额', sort: true } //实付金额(元)
-    //         , { field: 'orderStatus', width: 200, title: '订单状态', sort: true } //订单状态
-    //         , { field: 'activationStatusName', width: 200, title: '激活状态名称', sort: true } //激活状态名称
-    //         , { field: 'activationTime', width: 200, title: '激活时间', sort: true } //激活时间
-    //         , { field: 'jobId', width: 200, title: 'BOSS员工工号', sort: true } //BOSS员工工号
-    //     ]]
-    //     , where: {
-    //         DateStr: DateStr
-    //     }
-    //     , 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;