$(document).ready(() => { //init(); // $('[data-toggle="tooltip"]').tooltip(); // AREA_BOOK.handleSelectionChanged(0); // 锁定、解锁 lockUtil.displayLock($('.lock'), lockUtil.getLocked()); $('.lock').click(function () { window.location.search = `?locked=${!lockUtil.getLocked()}`; }); // 搜索 $('#summary-search').bind('keydown', function (event) { if (event.keyCode === 13) { // 回车搜索 const searchStr = $(this).val(); SUMMARY_BOOK.handleSearch(searchStr); } }); // 点击导出按钮 $('#export').click(() => { window.location.href = '/priceInfoClass/export'; }); $('#import').click(() => { $('#import-modal').modal('show'); }); // 导入确认 $('#import-confirm').click(function () { const self = $(this); try { const formData = new FormData(); const file = $("input[name='import_data']")[0]; if (file.files.length <= 0) { throw '请选择文件!'; } formData.append('file', file.files[0]); $.ajax({ url: '/priceInfoClass/importExcel', type: 'POST', data: formData, cache: false, contentType: false, processData: false, beforeSend: function () { self.attr('disabled', 'disabled'); self.text('上传中...'); }, success: function (response) { self.removeAttr('disabled'); self.text('确定导入'); if (response.err === 0) { $.bootstrapLoading.end(); const message = response.msg !== undefined ? response.msg : ''; if (message !== '') { alert(message); } // 成功则关闭窗体 $('#import').modal("hide"); window.location.reload(); } else { $.bootstrapLoading.end(); const message = response.msg !== undefined ? response.msg : '上传失败!'; alert(message); } }, error: function () { $.bootstrapLoading.end(); alert("与服务器通信发生错误"); self.removeAttr('disabled'); self.text('确定导入'); } }); } catch (error) { alert(error); } }); });