diff --git a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue index b80e141..f933b0c 100644 --- a/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue +++ b/ant-design-vue-jeecg/src/views/modulex/ModulexList.vue @@ -123,7 +123,7 @@ 导入实体 + @click="showProcess(tablexData)">导入实体 返回 @@ -264,7 +264,9 @@ export default { uploaded: '0', isVisible: 'false', records: '0', - status: '判断文件结构' + status: '判断文件结构', + isError: 'false', + closeable: 'false' }, visible: false, moduleximport: false, @@ -473,6 +475,7 @@ export default { userRole1: '', //管理员是1 其他是2 projectIdx: '', loadRouteType: false, + ws:{} } }, created() { @@ -483,7 +486,6 @@ export default { this.loginRole(usercode) //console.log('userole1',this.userRole1) this.getSuperFieldList() - /* this.showProcess()*/ }, computed: { importExcelUrl: function () { @@ -513,7 +515,6 @@ export default { note: ['对应模块id(必填):填写正确的模块名称', '中文名称(必填):与模块名称相同。', '英文名称(必填):与模块名称相同,写模块名称的英文名称。', - '结构图(选填):类图或E-R图,可以为空,不填写。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', '版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态', '版本号:请填写小与五位数的正整数' @@ -525,17 +526,35 @@ export default { } }, methods: { - // 显示进度 - showProcess(data) { + // 初始化websocket + initWS() { let userId = store.getters.userInfo.id let base_url = window._CONFIG['domianURL'] base_url = base_url.replace('http', 'ws') - let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`) - this.$refs.moduleximport.show(data); - ws.onmessage = (e) => { - this.$refs.moduleximport.edit(JSON.parse(e.data)); + this.ws = new WebSocket(`${base_url}/uploadProcess/${userId}`) + let flag = false + this.ws.onmessage = (e) => { + let res = JSON.parse(e.data); + this.$refs.moduleximport.edit(res); + if (res.isError === 'true') { + this.$message.error(res.status) + } + if (res.uploaded === res.records && flag) { + flag = false + this.$message.success(res.status) + } + if (res.uploaded === res.records) { + flag = true + } else { + flag = false; + } } }, + // 显示上传弹窗 + showProcess(data) { + this.initWS() + this.$refs.moduleximport.show(data,this.ws); + }, // 多选框的事件回调 checkChange(checked) { // 初始是默认全选的,假设此刻点击了name的选择框 diff --git a/ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue b/ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue index cb26dfe..58bf422 100644 --- a/ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue +++ b/ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue @@ -3,10 +3,10 @@ :title="title" width="50%" :visible="visible" - :confirmLoading="confirmLoading" - @ok="handleOk" + :closable="closable" @cancel="handleCancel" - cancelText="关闭"> + :maskClosable="maskClosable" + > @@ -33,14 +33,14 @@ -

当前状态:{{ ModalData.status }}

-

总记录数:{{ ModalData.records }}

-

已上传:{{ ModalData.uploaded }}

- +

当前状态:{{ ModalData.status }}

+

总记录数:{{ ModalData.records }}

+

已上传:{{ ModalData.uploaded }}

+
@@ -52,6 +52,9 @@
+ @@ -67,6 +70,8 @@ export default { comments: {}, data() { return { + closable:false, + maskClosable:false, title: '导入xxxxx', visible: false, model: {}, @@ -76,9 +81,10 @@ export default { uploaded: '0', isVisible: 'false', records: '0', - status: '判断文件结构' + status: '判断文件结构', + closeable:'false' }, - confirmLoading: false, + btnState:false, form: this.$form.createForm(this), url: { @@ -92,7 +98,9 @@ export default { 'Australian walks 100km after outback crash.', 'Man charged over missing wedding girl.', 'Los Angeles battles huge wildfires.' - ] + ], + stateFontColor: 'stateFontColor', + ws:{} } }, @@ -131,27 +139,28 @@ export default { handleDownload() { // getAction(this.url.list, params).then((res) => getAction(this.url.downfile).then((response) => { - const url = window.URL.createObjectURL(new Blob([response.data])) - const link = document.createElement('a') - link.href = url - link.setAttribute('download', 'your-document.pdf') - document.body.appendChild(link) - link.click() + const url = window.URL.createObjectURL(new Blob([response.data])) + const link = document.createElement('a') + link.href = url + link.setAttribute('download', 'your-document.pdf') + document.body.appendChild(link) + link.click() }) - .catch(error => { + .catch(error => { console.error(error) - }) + }) }, add() { }, - show(data) { + show(data,ws) { this.url.uploadUrl = data.uploadUrl this.url.downfile = data.downUrl - this.datas=data.note - this.title=data.title + this.datas = data.note + this.title = data.title this.ModalData = {} this.visible = true + this.ws=ws }, edit(record) { this.ModalData = record @@ -163,13 +172,18 @@ export default { close() { this.$emit('close') this.visible = false + this.ws.close() }, handleCancel() { - this.close() - }, - - handleOk() { - + console.log(4444) + if(this.ModalData.closeable == 'false'){ + this.btnState=!this.btnState + } + this.close() + this.ws.close() + // this.close() + // this.ws.close() + // console.log(4444) }, // 关闭提示标签 onClose(e) { @@ -189,10 +203,15 @@ export default { width: 85%; float: right; } -.box{ + +.box { display: flex; - flex-direction:column; - justify-content:center; + flex-direction: column; + justify-content: center; align-items: center; } + +.stateFontColor { + color: red; +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index 9eb9ff8..3c86d3f 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -292,6 +292,8 @@ public class TablexController extends JeecgController { message.put("isVisible", "true"); message.put("uploaded", "0"); message.put("status", "判断文件结构"); + message.put("isError", "false"); + message.put("closeable","false"); webSocketUtils.sendMessage(loginUser.getId(), message); try { @@ -300,6 +302,10 @@ public class TablexController extends JeecgController { if (StringUtils.isBlank(originalFilename) || (!originalFilename.endsWith("xls") && !originalFilename.endsWith("xlsx"))) { + message.put("isError", "true"); + message.put("status","文件格式不正确"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件格式不正确"); } @@ -313,10 +319,18 @@ public class TablexController extends JeecgController { //读取excel数据 list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); } catch (Exception e) { + message.put("isError", "true"); + message.put("status","文件读取失败"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件读取失败"); } //判断文件中是否存在数据 if (list == null || list.size() == 0) { + message.put("isError", "true"); + message.put("status","Excel数据为空"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("Excel数据为空"); } @@ -338,7 +352,9 @@ public class TablexController extends JeecgController { //判断版本号长度 String verison = tablexVo.getVerison(); if (verison.length() > 5) { - /* message.put("isVisible", "false");*/ + message.put("isError", "true"); + message.put("status","预读入失败,版本号格式错误"); + message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("预读入失败,版本号格式错误"); } @@ -354,7 +370,9 @@ public class TablexController extends JeecgController { tablexVoService.removeAll(voList); if (voList.size() == 0) { - /* message.put("isVisible", "false");*/ + message.put("isError", "true"); + message.put("status","导入失败,数据为空"); + message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,数据为空"); } @@ -368,12 +386,20 @@ public class TablexController extends JeecgController { String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { + message.put("isError", "true"); + message.put("status","导入失败,对应模块填写不能为空"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写不能为空"); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Modulex::getId, moduleId); Modulex modulex = modulexService.getOne(queryWrapper); if (modulex == null) { + message.put("isError", "true"); + message.put("status","导入失败,对应模块填写错误"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写错误"); } String modulexId = modulex.getId(); @@ -421,28 +447,57 @@ public class TablexController extends JeecgController { tablexService.saveSingleBatch(tablexList, loginUser, message); message.put("status", "上传成功"); + message.put("closeable","true"); webSocketUtils.sendMessage(loginUser.getId(), message); } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的版本号填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); } } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的版本状态填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); } } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的实体状态填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); } } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的英文名称填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); } } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的中文名称填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); } } else { + message.put("isError", "true"); + message.put("status","导入失败,第" + i + 1 + "行的对应模块填写错误!"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); } } } catch (Exception e) { + message.put("isError", "true"); + message.put("status","文件导入失败"); + message.put("closeable","true"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败"); } return Result.ok("文件导入成功!");