diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/QuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/QuController.java index e88402f..689c256 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/QuController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/QuController.java @@ -182,6 +182,12 @@ public class QuController extends BaseController { } + @RequiresPermissions("system:qu:import") + @GetMapping("/toImport") + public String toImport() { + return prefix + "/toImport"; + } + @ApiOperation("导入Excel") @RequiresPermissions("system:qu:import") @ResponseBody diff --git a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/qu.html b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/qu.html index 95d683e..07a526e 100644 --- a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/qu.html +++ b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/qu.html @@ -39,7 +39,7 @@ 删除 - + 导入 @@ -47,17 +47,6 @@
- - - 上传导入 - 下载导入模板 - - - @@ -110,96 +99,47 @@ }; $.table.init(options); }); - // function toImport(){ - // $.modal.open("试题导入", prefix + "/toImport",'500','300'); - // } - console.log(document.getElementsByClassName('fixed-sidebar')) - // 请求实例 - const instance = axios.create({ - baseURL: ctx, - timeout: 60000 - }) - var app = new Vue({ - el: '#app', - data: { - importVisible:false - }, - mounted(){ - - }, - methods: { - toImport(){ - this.importVisible = true - }, - // 只是为了美化一下导入按钮 - chooseFile: function() { - this.$refs.upFile.dispatchEvent(new MouseEvent('click')) - }, - downloadTemplate() { - // 创建一个隐藏的标签 - var link = document.createElement('a'); - link.style.display = 'none'; - document.body.appendChild(link); - link.setAttribute('href', '/file/试题导入模板.xlsx'); - link.setAttribute('download', '试题导入模板.xlsx'); - link.click(); - document.body.removeChild(link); - }, - upload(url, file, data) { - const formData = new FormData() - formData.append('file', file) - - // 附加数据 - if (data) { - Object.keys(data).forEach((key) => { - formData.append(key, data[key]) - }) - } - const loading = this.$loading({ - lock: true, - text: 'Loading', - spinner: 'el-icon-loading', - background: 'rgba(0, 0, 0, 0.7)' - }); - return new Promise((resolve, reject) => { - instance.request({ - url: url, - method: 'post', - data: formData, - timeout: 1200000 - }).then(response => { - loading.close(); - console.log(response) - resolve(response) - }).catch(err => { - reject(err) - }) - }) - }, - importExcel(file) { - return this.upload('system/qu/import', file) - }, - doImport(e) { - const file = e.target.files[0] - let that = this - this.importExcel(file).then((res)=>{ - console.log(res) - if (res.data.code !== 0) { - that.$alert(res.data.msg, '导入信息', { - dangerouslyUseHTMLString: true - }) - } else { - that.$message({ - message: '数据导入成功!', - type: 'success' - }) - this.importVisible = false - $.table.refresh() - } - }) - }, - }, - }); + function toImport(){ + open("试题导入", prefix + "/toImport",'500','300'); + } + // 弹出层指定宽度 + function open(title, url, width, height, callback) { + // 如果是移动端,就使用自适应大小弹窗 + if ($.common.isMobile()) { + width = 'auto'; + height = 'auto'; + } + if ($.common.isEmpty(title)) { + title = false; + } + if ($.common.isEmpty(url)) { + url = "/404.html"; + } + if ($.common.isEmpty(width)) { + width = 800; + } + if ($.common.isEmpty(height)) { + height = ($(window).height() - 50); + } + if ($.common.isEmpty(callback)) { + callback = function(index, layero) { + var iframeWin = layero.find('iframe')[0]; + iframeWin.contentWindow.submitHandler(index, layero); + } + } + top.layer.open({ + type: 2, + area: [width + 'px', height + 'px'], + fix: false, + //不固定 + maxmin: true, + shade: 0.3, + title: title, + content: url, + // 弹层外区域关闭 + shadeClose: true, + }); + } diff --git a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/toImport.html b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/toImport.html new file mode 100644 index 0000000..0b8a50b --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/toImport.html @@ -0,0 +1,135 @@ + + + + + + + +
+ + 上传导入 + 下载导入模板 + + +
+ + + + +