| | |
| | | case "edit": |
| | | showEditForm(data); |
| | | break; |
| | | case "upload": |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl+"/reimburseOnline/viewCheck/" + data.id + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | if (res.code == 200) { |
| | | layer.confirm('当前已存在数据,继续上传将会覆盖旧数据,是否上传?', function(){ |
| | | $("#uploadQuote").click() |
| | | }); |
| | | }else{ |
| | | $("#uploadQuote").click() |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $("#uploadQuote").on("change",(evt) => { |
| | | var files = evt.target.files; |
| | | if(files==null || files.length==0){ |
| | | alert("No files wait for import"); |
| | | return; |
| | | } |
| | | |
| | | let name = files[0].name; |
| | | let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length-1]; |
| | | if(suffix!="xlsx"){ |
| | | alert("Currently only supports the import of xlsx files"); |
| | | return; |
| | | } |
| | | LuckyExcel.transformExcelToLucky(files[0], function(exportJson, luckysheetfile){ |
| | | if(exportJson.sheets==null || exportJson.sheets.length==0){ |
| | | alert("Failed to read the content of the excel file, currently does not support xls files!"); |
| | | return; |
| | | } |
| | | |
| | | let formData = new FormData($("#uploadFile")[0]); |
| | | formData.append("id", data.id); |
| | | formData.append("checkData", zip(exportJson.sheets)); |
| | | $.ajax({ |
| | | url: baseUrl+"/reimburseOnline/uploadCheck/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: formData, |
| | | // data: JSON.stringify({ |
| | | // id: data.id, |
| | | // checkData: zip(exportJson.sheets) |
| | | // }), |
| | | // dataType: "json", |
| | | method: 'POST', |
| | | cache: false, |
| | | processData: false, |
| | | contentType: false, |
| | | // contentType:'application/json;charset=UTF-8', |
| | | success: function (res) { |
| | | if (res.code == 200) { |
| | | layer.msg('上传成功',{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000},() => { |
| | | parent.location.reload() |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | }) |
| | | break; |
| | | case "viewCheck": |
| | | //查看询价 |
| | | $.ajax({ |
| | | type:"get", |
| | | url: baseUrl+"/reimburseOnline/viewCheck/" + data.id + "/auth", |
| | | dataType:"json", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | success:function(res) { |
| | | if (res.code == 200) { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '查看询价', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | | content: 'reimburseOnline_check.html?id=' + data.id, |
| | | success: function(layero, index){ |
| | | // layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"}); |
| | | } |
| | | }); |
| | | }else{ |
| | | layer.msg(res.msg,{time:1000}) |
| | | } |
| | | } |
| | | }); |
| | | break; |
| | | case "look": |
| | | var $a = $(obj.tr).find('a[lay-event="look"]'); |
| | | var offset = $a.offset(); |
| | |
| | | // }); |
| | | // } |
| | | |
| | | //更新form |
| | | // 更新form |
| | | function showEditForm(mData) { |
| | | admin.open({ |
| | | type: 1, |