Import.js
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
let action = null;
let customImportFileName = ["form", "table", "element", "jquery"];
layui.config({
base: "/js/",
version: 111
}).use(["system", "vue"], function () {
var form = layui.form,
$ = layui.jquery,
system = layui.system,
sysU = new system.u(),
vueApp = null,
areaName = "Planned",
tableName = "Import";
action = {
uploadOptions: function () {
var options = {
url: `/${areaName}/${tableName}/Import`,
fromFile: "#excelfile",
content: $("#ImportData")
}
return options;
},
uploadSaveBefore: function (formData, selectRow, callBack) {
debugger
var excelfile = formData.formFile.getAll("excelfile");
if (excelfile.length === 0) {
layer.close(formData.closeIndex);
layer.alert(`请先选择需要上传的文件!`, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleOpen });
return false;
}
var tableName = $(".fileName");
for (var i = 0; i < excelfile.length; i++) {
var isOk = false;
var excelfileName = "";
var tableFileName = "";
for (var xp = 0; xp < tableName.length; xp++) {
excelfileName = excelfile[i].name;
tableFileName = $(tableName[xp]).text();
if (tableFileName == excelfileName) {
isOk = true;
break;
}
}
if (!isOk) {
layer.alert(`导入的文件名【${excelfileName}】和Excel列表模板名称不一致!`, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleOpen });
layer.close(formData.closeIndex);
return false;
}
}
if (callBack != null) callBack();
},
//所有动作成功之后
actionSuccess: (falg) => {
},
getFileName:(data) =>{
return data.substring(0, data.indexOf("."));
}
}
var app = {
data: {
},
methods: {
initVue: function () {
vueApp = new Vue({
el: '#listForm',
data: {
contentList: [
{ title: "设备管理", href: "../../ExcelTemplate/设备管理.xlsx" },
{ title: "工艺路线", href: "../../ExcelTemplate/工艺路线.xlsx" },
{ title: "物料信息", href: "../../ExcelTemplate/物料信息.xlsx" },
{ title: "人员信息", href: "../../ExcelTemplate/人员信息.xlsx" },
{ title: "生产订单", href: "../../ExcelTemplate/生产订单.xlsx" },
]
},
methods: {
}
});
},
initFrom: function () {
}
},
registerEvent: function () {
//自定义按钮执行公共方法
system.query();
system.queryExtend();
},
init: function () {
app.registerEvent();
app.methods.initVue();
}
};
app.init();
});