TG.WXCRM.V4/WEB/Views/WeiXin/JZOrder/ImportBasicsGiftView.cshtml

131 lines
4.8 KiB
Plaintext

@{
ViewBag.Title = "BasicsProductList";
Layout = "~/Views/Shared/_content.cshtml";
}
<style>
.self-table-click td {
background-color: #f3ebbc;
}
</style>
<div class="x-body">
<div class="layui-btn-group" style="padding-bottom:10px;">
</div>
<table class="layui-hide" id="tabl1" lay-filter="tabl1"></table>
<div class="layui-form-item" id="extdiv">
<button class="layui-btn" lay-submit="" lay-filter="save">确认导入</button>
</div>
</div>
<script>
var apiPath = '@ViewBag.apiPath';
var selectRow = {};
var table;
var importData = [];
var data = parent.GetImportData2();
data = JSON.parse(data);
layui.use(['table', 'form', 'layer', 'upload'], function () {
table = layui.table;
var layer = layui.layer;
var form = layui.form;
table.render({
id: 'testReload',//列表别名ID
elem: '#tabl1',//表ID
data: data,//parent.GetImportData(),
cols: [[
{ field: 'Umid', title: '客户Id' }
, { field: 'Name', title: '客户姓名' }
, { field: 'OrderId', title: '订单号' }
, { field: 'ProductCode', title: '产品编码' }
, { field: 'ProductName', title: '产品名称' }
, { field: 'UserName', title: '用户名' }
, { field: 'Day', title: '开通天数' }
, {
field: 'Msg', title: '校验信息', width: 200, fixed: 'right', templet: function (res) {
if (res.Msg == '' || res.Msg == null) {
return "<span style='color:blue'>校验通过</span>"
} else {
return "<span style='color:red'>" + res.Msg + "</span>"
}
}
}
]]
});
//清空
$("#clear").on('click', function (e) {
$("#mytoolbar input[type='text']").val("");
$("#mytoolbar select").val("");
form.render("select");
});
//监听行单击事件
table.on('row(tabl1)', function (obj) {
var data = obj.data;
//console.log(data);
//标注选中样式
obj.tr.addClass('self-table-click').siblings().removeClass('self-table-click');
selectRow = data;
});
//点击事件
var active = {
};
form.on('submit(save)', function (data) {
var data = parent.GetImportData();
if (data.length <= 0) {
layer.alert("当前没有数据要导入");
return;
}
if (data.length > 0) {
$.ajax({
type: "Post",
url: '/JZOrder/ImportBasicsGiftResult',
data: JSON.stringify(data),
dataType: "json",
contentType: "application/json",
success: function (msg) {
debugger
console.log(msg);
if (msg.result) {
debugger
var importData = parent.GetImportData();
var newDataList = [];
for (var i = 0; i < importData.length; i++) {
var newData = importData[i];
if (msg.retmsg.errList.indexOf(newData.OrderId)>-1) {
newData.Msg = "导入失败";
}
if (msg.retmsg.successList.indexOf(newData.OrderId) > -1) {
newData.Msg = "导入成功";
}
newDataList.push(newData);
}
importData = newDataList;
parent.UserSetImportData(importData);
TableReload();
}
else {
layer.alert(msg.message);
}
},
error: function () {
layer.msg('创建失败!', { icon: 2 });
}
});
}
$(this).show();
return false;
});
$('.layui-btn-group .layui-btn').on('click', function () {
var othis = $(this), method = othis.data('method');
active[method] ? active[method].call(this, othis) : '';
});
});
function TableReload() {
data = parent.GetImportData2();
data = JSON.parse(data);
location.reload();
}
</script>