Compare commits

..

2 Commits

Author SHA1 Message Date
mqh 6c3d0c6836 Merge remote-tracking branch 'origin/dev_2307' into dev_2307 1 year ago
mqh 325bff3537 更新导入功能界面交互 1 year ago
  1. 37
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 71
      ant-design-vue-jeecg/src/views/modulex/modules/ModulexImport.vue
  3. 59
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java

@ -245,7 +245,9 @@ export default {
uploaded: '0', uploaded: '0',
isVisible: 'false', isVisible: 'false',
records: '0', records: '0',
status: '判断文件结构' status: '判断文件结构',
isError: 'false',
closeable: 'false'
}, },
visible: false, visible: false,
moduleximport: false, moduleximport: false,
@ -458,6 +460,7 @@ export default {
userRole1: '', //1 2 userRole1: '', //1 2
projectIdx: '', projectIdx: '',
loadRouteType: false, loadRouteType: false,
ws:{}
} }
}, },
created() { created() {
@ -468,7 +471,6 @@ export default {
this.loginRole(usercode) this.loginRole(usercode)
//console.log('userole1',this.userRole1) //console.log('userole1',this.userRole1)
this.getSuperFieldList() this.getSuperFieldList()
/* this.showProcess()*/
}, },
computed: { computed: {
modelImportExcelUrl: function () { modelImportExcelUrl: function () {
@ -507,7 +509,6 @@ export default {
note: ['对应模块id(必填):填写正确的模块名称', note: ['对应模块id(必填):填写正确的模块名称',
'中文名称(必填):与模块名称相同。', '中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,写模块名称的英文名称。', '英文名称(必填):与模块名称相同,写模块名称的英文名称。',
'结构图(选填):类图或E-R图,可以为空,不填写。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',
'版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态', '版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态',
'版本号:请填写小与五位数的正整数' '版本号:请填写小与五位数的正整数'
@ -595,17 +596,35 @@ export default {
} }
}, },
methods: { methods: {
// // websocket
showProcess(data) { initWS() {
let userId = store.getters.userInfo.id let userId = store.getters.userInfo.id
let base_url = window._CONFIG['domianURL'] let base_url = window._CONFIG['domianURL']
base_url = base_url.replace('http', 'ws') base_url = base_url.replace('http', 'ws')
let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`) this.ws = new WebSocket(`${base_url}/uploadProcess/${userId}`)
this.$refs.moduleximport.show(data); let flag = false
ws.onmessage = (e) => { this.ws.onmessage = (e) => {
this.$refs.moduleximport.edit(JSON.parse(e.data)); 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) { checkChange(checked) {
// name // name

@ -3,10 +3,10 @@
:title="title" :title="title"
width="50%" width="50%"
:visible="visible" :visible="visible"
:confirmLoading="confirmLoading" :closable="closable"
@ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
cancelText="关闭"> :maskClosable="maskClosable"
>
<a-alert message="请下载" type="info" show-icon style="margin-bottom: 20px;"/> <a-alert message="请下载" type="info" show-icon style="margin-bottom: 20px;"/>
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }"> <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
<!-- <a-alert message="请下载" type="info" show-icon /> --> <!-- <a-alert message="请下载" type="info" show-icon /> -->
@ -33,7 +33,7 @@
</a-upload> </a-upload>
</a-form-item> </a-form-item>
<a-form-item v-if="ModalData.isVisible==='true'" class="box"> <a-form-item v-if="ModalData.isVisible==='true'" class="box">
<p>当前状态{{ ModalData.status }}</p> <p>当前状态<span :class=" ModalData.isError==='true'?stateFontColor:''">{{ ModalData.status }}</span></p>
<p>总记录数{{ ModalData.records }}</p> <p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p> <p>已上传{{ ModalData.uploaded }}</p>
<a-progress <a-progress
@ -52,11 +52,14 @@
</a-list> </a-list>
</a-form-model-item> </a-form-model-item>
</a-form> </a-form>
<template slot="footer">
<a-button type="primary" @click="handleCancel" :disabled="btnState">确定</a-button>
</template>
</a-modal> </a-modal>
</template> </template>
<script> <script>
import {downloadFile, getAction} from "@api/manage" import {getAction} from "@api/manage"
import store from '@/store' import store from '@/store'
import {JeecgListMixin} from '@/mixins/JeecgListMixin' import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin' import {mixinDevice} from '@/utils/mixin'
@ -67,6 +70,8 @@ export default {
comments: {}, comments: {},
data() { data() {
return { return {
closable:false,
maskClosable:false,
title: '导入xxxxx', title: '导入xxxxx',
visible: false, visible: false,
model: {}, model: {},
@ -76,11 +81,11 @@ export default {
uploaded: '0', uploaded: '0',
isVisible: 'false', isVisible: 'false',
records: '0', records: '0',
status: '判断文件结构' status: '判断文件结构',
closeable:'false'
}, },
confirmLoading: false, btnState:false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
downName:'',
url: url:
{ {
downfile: '', downfile: '',
@ -93,7 +98,9 @@ export default {
'Australian walks 100km after outback crash.', 'Australian walks 100km after outback crash.',
'Man charged over missing wedding girl.', 'Man charged over missing wedding girl.',
'Los Angeles battles huge wildfires.' 'Los Angeles battles huge wildfires.'
] ],
stateFontColor: 'stateFontColor',
ws:{}
} }
}, },
@ -130,32 +137,30 @@ export default {
}, },
// //
handleDownload() { handleDownload() {
downloadFile( this.url.downfile,this.downName)
// getAction(this.url.list, params).then((res) => // getAction(this.url.list, params).then((res) =>
// getAction(this.url.downfile) getAction(this.url.downfile).then((response) => {
// downloadFile( window._CONFIG['downloadUrl'],'temp/ (1).xls').then((response) => { const url = window.URL.createObjectURL(new Blob([response.data]))
// const url = window.URL.createObjectURL(new Blob([response.data])) const link = document.createElement('a')
// const link = document.createElement('a') link.href = url
// link.href = url link.setAttribute('download', 'your-document.pdf')
// link.setAttribute('download', 'your-document.pdf') document.body.appendChild(link)
// document.body.appendChild(link) link.click()
// link.click() })
// }) .catch(error => {
// .catch(error => { console.error(error)
// console.error(error) })
// })
}, },
add() { add() {
}, },
show(data) { show(data,ws) {
this.url.uploadUrl = data.uploadUrl this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl this.url.downfile = data.downUrl
this.downName = data.downName
this.datas = data.note this.datas = data.note
this.title = data.title this.title = data.title
this.ModalData = {} this.ModalData = {}
this.visible = true this.visible = true
this.ws=ws
}, },
edit(record) { edit(record) {
this.ModalData = record this.ModalData = record
@ -167,13 +172,18 @@ export default {
close() { close() {
this.$emit('close') this.$emit('close')
this.visible = false this.visible = false
this.ws.close()
}, },
handleCancel() { handleCancel() {
console.log(4444)
if(this.ModalData.closeable == 'false'){
this.btnState=!this.btnState
}
this.close() this.close()
}, this.ws.close()
// this.close()
handleOk() { // this.ws.close()
// console.log(4444)
}, },
// //
onClose(e) { onClose(e) {
@ -193,10 +203,15 @@ export default {
width: 85%; width: 85%;
float: right; float: right;
} }
.box { .box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.stateFontColor {
color: red;
}
</style> </style>

@ -292,6 +292,8 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
message.put("isVisible", "true"); message.put("isVisible", "true");
message.put("uploaded", "0"); message.put("uploaded", "0");
message.put("status", "判断文件结构"); message.put("status", "判断文件结构");
message.put("isError", "false");
message.put("closeable","false");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
try { try {
@ -300,6 +302,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
if (StringUtils.isBlank(originalFilename) || if (StringUtils.isBlank(originalFilename) ||
(!originalFilename.endsWith("xls") && (!originalFilename.endsWith("xls") &&
!originalFilename.endsWith("xlsx"))) { !originalFilename.endsWith("xlsx"))) {
message.put("isError", "true");
message.put("status","文件格式不正确");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件格式不正确"); return Result.error("文件格式不正确");
} }
@ -313,10 +319,18 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//读取excel数据 //读取excel数据
list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params);
} catch (Exception e) { } catch (Exception e) {
message.put("isError", "true");
message.put("status","文件读取失败");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件读取失败"); return Result.error("文件读取失败");
} }
//判断文件中是否存在数据 //判断文件中是否存在数据
if (list == null || list.size() == 0) { 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数据为空"); return Result.error("Excel数据为空");
} }
@ -338,7 +352,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断版本号长度 //判断版本号长度
String verison = tablexVo.getVerison(); String verison = tablexVo.getVerison();
if (verison.length() > 5) { if (verison.length() > 5) {
/* message.put("isVisible", "false");*/ message.put("isError", "true");
message.put("status","预读入失败,版本号格式错误");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读入失败,版本号格式错误"); return Result.error("预读入失败,版本号格式错误");
} }
@ -354,7 +370,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexVoService.removeAll(voList); tablexVoService.removeAll(voList);
if (voList.size() == 0) { if (voList.size() == 0) {
/* message.put("isVisible", "false");*/ message.put("isError", "true");
message.put("status","导入失败,数据为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,数据为空"); return Result.error("导入失败,数据为空");
} }
@ -368,12 +386,20 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
String moduleId = voList.get(i).getModuleId(); String moduleId = voList.get(i).getModuleId();
if (moduleId == null || moduleId.equals("")) { if (moduleId == null || moduleId.equals("")) {
message.put("isError", "true");
message.put("status","导入失败,对应模块填写不能为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写不能为空"); return Result.error("对应模块填写不能为空");
} }
LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Modulex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Modulex::getId, moduleId); queryWrapper.eq(Modulex::getId, moduleId);
Modulex modulex = modulexService.getOne(queryWrapper); Modulex modulex = modulexService.getOne(queryWrapper);
if (modulex == null) { if (modulex == null) {
message.put("isError", "true");
message.put("status","导入失败,对应模块填写错误");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("对应模块填写错误"); return Result.error("对应模块填写错误");
} }
String modulexId = modulex.getId(); String modulexId = modulex.getId();
@ -421,28 +447,57 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexService.saveSingleBatch(tablexList, loginUser, message); tablexService.saveSingleBatch(tablexList, loginUser, message);
message.put("status", "上传成功"); message.put("status", "上传成功");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的版本号填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!");
} }
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的版本状态填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!");
} }
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的实体状态填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!");
} }
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的英文名称填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!");
} }
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的中文名称填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!");
} }
} else { } else {
message.put("isError", "true");
message.put("status","导入失败,第" + i + 1 + "行的对应模块填写错误!");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!");
} }
} }
} catch (Exception e) { } catch (Exception e) {
message.put("isError", "true");
message.put("status","文件导入失败");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("文件导入失败"); return Result.error("文件导入失败");
} }
return Result.ok("文件导入成功!"); return Result.ok("文件导入成功!");

Loading…
Cancel
Save