var id = localStorage.getItem("costListId"); var proId = localStorage.getItem("costListProId"); var inputOutType= localStorage.getItem("inputOutType"); layui.use(['layer', 'laydate', 'upload'], function () { var layer = layui.layer; var laydate = layui.laydate; loadFile(); }); function loadFile() { var formdata = $("form").serializeObject(); formdata.id = id; formdata.proId=proId; $.ajax({ type: 'post', url: smz_ht_url + "/engineeringCostDetailedSchedule/getFileByProId", contentType: "application/json; charset=utf-8", data: JSON.stringify(formdata), success: function (data) { console.log("data", data); setData(data); }, error: function (err) { console.log("err", err); } }); } function setData(data) { var html = ''; $("#fileViewForm").html(""); for (var i = 0; i < data.length; i++) { html += '
'; var suffix = data[i].fileName.split('.')[1]; if(suffix.lastIndexOf("xls") != -1 || suffix.lastIndexOf("xlsx") != -1 || suffix.lastIndexOf("xlsm") != -1){ html += ' '; }else if(suffix.lastIndexOf("doc") != -1 || suffix.lastIndexOf("docx") != -1){ html += ' '; }else if(suffix.lastIndexOf("pdf") != -1){ html += ' '; } html += '
'; html += ' ' + data[i].fileName + '
'; html += ' 上传人:' + data[i].nickName + '
'; html += ' 上传时间:' + data[i].uploadTime + ''; html += '
'; html += '
'; } $("#fileViewForm").append(htcheckFile.htmlml); } function view(filePath) { filePreview(filePath); } $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); $.each(a, function () { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; };