excel导入js
//导入初始化
var uploadInst = upload.render({
elem: '#exportShop', //绑定元素
url: '/api/file/add', //上传接口
accept: 'file', //普通文件
multiple: false,
data: {
path: 'tempData'
},
size: 204800,
done: function (res) {
var cardNos = ''; var telphones = ''; var exMemberIds = '';
var errorData = [], errorData1 = [], errorData2 = [], errorData3 = [], errorData4 = [], errorData5 = [], errorData6 = [], errorData7 = [], errorData8 = [], errorData9 = [], errorData10 = [];
$.post("/api/excel/get", { path: "/tempData/" + res.fileName }, function (data) {
var count = 0;
if (data.length == 0) {
layer.msg("Execl中没有需要导入的数据")
return false;
}
var param = [];
var dataList = [];
//遍历excel
$.each(data, function (i, n) {
}
});
//删除导入文件
$.post('/api/file/delete', { path: "/tempData/" + res.fileName }, function () { })
}, 'json')
}
});
//导入结束
报表
<script>
new App({
//默认 数据
modelId: '',
TH004: '',//搜索条件列内容
TH005: '',//列字段控制内容
TH009: '',//列字段宽度
orgID: sessionInfo.organId,
projectId: sessionInfo.projectId,
userId: sessionInfo.userId,
reportHref: 'reports/vipSpendDetailsReport',
pageName: 'vip消费数据详情',
//查询所需字段
vipName: '',
phone: '',
//
init: function () {
debugger;
var form = layui.form;
form.render();
var table = layui.table;
var that = this;
table.render();
//单选框初始化
form.on("select(repModel)", function (obj) {
that.clearData();
if (obj.value == "") {
that.modelId = "";
$(".width").val("120");
that.clearData();
} else {
that.modelId = obj.value;
that.getModelInfo();
}
});
form.on('checkbox(c_all)', function (data) {
var a = data.elem.checked;
if (a == true) {
$("[name=one]").prop("checked", true);
form.render('checkbox');
} else {
$("[name=one]").prop("checked", false);
form.render('checkbox');
}
});
localStorage.modelName = "";
},
query: function () {
//专页面数据记录
localStorage.vipName = $("#vipName").val();
localStorage.phone = $("#phone").val();
var rand = Math.random() * (100 - 0 + 1) + 0;
var ids = [];
var titles = [];
var widths = [];
var istrue = false;
$('input[name="one"]:checked').each(function () {
ids.push($(this).val());
titles.push($(this).attr("title"));
if ($("[name=" + $(this).val() + "]").val() == "") {
istrue = true;
}
widths.push($("[name=" + $(this).val() + "]").val());
});
ids.push("clos");
titles.push("clos");
widths.push("clos");
if (istrue) {
layer.msg("请填写显示列的宽度");
return false;
}
localStorage.spc_lines = ids.join(",");
localStorage.spc_titles = titles.join(",");
localStorage.spc_widths = widths.join(",");
var m = $("#repModel").val();
var modelName = "";
if (m != "") {
localStorage.modelName = $("#repModel option:selected").text();
}
layer.closeAll();
this.closeThisTab();
this.openPage("商品库存明细表", this.reportHref, this.reportHref + new Date().format("yyyyMMddHHmmss") + rand);
},
create: function () {
this.getRepList();
// layui.laydate.render({
// elem: '#beginTime'
// , type: 'date'
// , trigger: 'click'
// });
// layui.laydate.render({
// elem: '#endTime'
// , type: 'date'
// , trigger: 'click'
// });
var that = this;
that.clearData();
},
//取消查询
cancel: function () {
layer.closeAll();
if (this.getQueryString("type") != "add")
this.closeThisTab();
},
//模板报错
saveModel: function () {
var modelName = this.pageName;
var that = this;
var url = "/reports/modelCofig.html";
if (this.modelId == "") {
url += "?type=add&typeName=" + modelName;
} else {
url += "?type=update&typeName=" + modelName + "&id=" + this.modelId;
}
//模板保存的数据
var json = { vipName: $("#vipName").val() };
json.phone = $("#phone").val();
var ids = [], widths = [];
var istrue = false;
$('input[name="one"]:checked').each(function () {
ids.push($(this).val());
if ($("[name=" + $(this).val() + "]").val() == "") {
istrue = true;
}
widths.push($("[name=" + $(this).val() + "]").val());
});
//分割
ids.push("clos");
widths.push("clos");
if (istrue) {
layer.msg("请填写显示列的宽度");
return false;
}
this.TH005 = ids.join(",");
this.TH004 = JSON.stringify(json);
this.TH009 = widths.join(",");
this.showPage("保存模板", '460px', '150px', url);
},
getRepList: function (isId) {
var where = { TH003: sessionInfo.userId, TH007: this.pageName, TH008: sessionInfo.projectId };
var id = "";
$.post("/api/data/get/admth", where, function (res) {
var str = "<option value=''>请选择模板</option>";
if (res.count > 0) {
$.each(res.data, function (i, n) {
if (n.TH006 == 1) {
id = n.TH001;
}
if (isId) {
id = isId;
}
str += "<option value = '" + n.TH001 + "'>" + n.TH002 + "</option>"
})
}
$("#repModel").html(str);
$("#repModel").attr("lay-search", true);
layui.form.render();
if (id) {
var select = 'dd[lay-value=' + id + ']';// 设置value
$('#repModel').siblings("div.layui-form-select").find('dl').find(select).click();
}
}, "json")
},
delModel: function () {
var that = this;
if (this.modelId == "") {
layer.msg("请选择需要删除的模板");
} else {
layer.confirm('您确认删除选择的模板?', {
btn: ['取消', '确定'] //按钮
}, function () {
//取消
layer.close(layer.index)
}, function () {
$.post("/api/data/del/admth", { TH001: that.modelId }, function (data) {
that.clearData();
that.getRepList();
}, 'json')
});
}
},
getModelInfo: function () {
$("input[type=checkbox]").prop("checked", false);
$(".width").val("");
layui.form.render();
$.post("/api/data/get/admth", { TH001: this.modelId }, function (res) {
var res = res.data[0];
this.TH004 = res.TH004;
this.TH005 = res.TH005;
this.TH009 = res.TH009;
var lines = res.TH005.split(",");
var widhts = res.TH009.split(",");
$.each(lines, function (i, n) {
if (n != "") {
$("input[type=checkbox][value=" + n + "]").prop("checked", true);
$("input[name=" + n + "]").val(widhts[i]);
}
})
var json = JSON.parse(res.TH004);
// 保存的模板中存在什么字段就调用什么方法
for (var key in json) {
$("#" + key).val(json[key]);
// if (key == "spId") {
// this.getSpInfo(json[key]);
// } else if (key == "MA001") {
// this.getCardList(json[key]);
// } else {
// $("#" + key).val(json[key]);
// }
}
layui.form.render();
}.bind(this), "json")
},
clearData: function () {
$("input[type=checkbox]").prop("checked", true);
$(".width").val(120);
//清空字段
$("#vipName").val("");
$("#phone").val("");
layui.form.render();
// this.getCardList();//回调
},
});
</script>
本文作者:Author: 寒光博客
文章标题:开发模版
本文地址:https://dxoca.cn/StudyNotes/396.html 百度已收录
版权说明:若无注明,本文皆为“Dxoca's blog (寒光博客)”原创,转载请保留文章出处。
本文地址:https://dxoca.cn/StudyNotes/396.html 百度已收录
版权说明:若无注明,本文皆为“Dxoca's blog (寒光博客)”原创,转载请保留文章出处。