12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- $(function() {
- var params = window.location.href.split("?");
- if (params.length > 1) {
- values = params[1].split("&");
- if (values.length > 1) {
- var funcId = values[0].replace("id=", "");
- var algorithm_path = "";//资料
-
- //var purpose = "";
- if (funcId !== "0") {
- algorithm_path = decodeURI(values[1].replace("algorithm_path=", ""));//资料
-
- }
- }
- }
- $("#algorithm_path").val(algorithm_path);//资料
- // if (isHide === "1") {
- // $("#flag").attr("checked", "checked");
- // }
- layui.use("form", function() {
- layui.form.render();
- });
- layui.use(["form", "layer","upload"], function() {
- $ = layui.jquery;
- var form = layui.form,
- layer = layui.layer;
- var upload = layui.upload;
- //监听提交
- form.on("switch(hide)", function(data) {
- isHide = data.elem.checked ? 1 : 0;
- });
- form.on("submit(save)", function(data) {
- if ($("#algorithm_path").val().trim() === "") {
- showMsg("没有选择文件", 2);
- $("#algorithm_path").focus();
- return false;
- }
-
- var func = data.field;
- //var str = $("#hide").val()
- //func.hide = str === "on" ? 1 : 0;
-
- func.id = funcId;
- func.algorithm_path = file
- //func.flag = isHide;
- // let url = "";
- var url = "api/algorithm/add";
- fetchJSON(url, func, "post", function(data) {
- if (data.status === 0) {
- var index = parent.layer.getFrameIndex(window.name);
- showMsg("上传成功", 1, 2000);
- parent.layer.close(index);
- } else {
- showMsg(data.msg, 2);
- }
- });
- return false;
- });
-
- upload.render({
- elem: '#algorithm_path',
- url: urlBase + "api/algorithm/importData" ,//改成您自己的上传接口
- headers: {
- "token":sessionStorage.getItem("token")
- },
- data: {},
- accept: 'file',
- // exts: 'xls|xlsx',
- done: function(res){
- if (res.status === 0) {
- var index = parent.layer.getFrameIndex(window.name);
- showMsg("上传成功", 1, 2000);
- parent.layer.close(index);
- }else{
- var index = parent.layer.getFrameIndex(window.name);
- showMsg("上传失败", 1, 2000);
- parent.layer.close(index);
- }
- }
- });
-
- });
- });
|