| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- 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-manage'
- , 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) : '';
- });
- });
|