Compare commits

..

No commits in common. '6c3d0c6836d77137dd7f0dd950860234bf1c0a47' and '85d6e31eabae2a83204ab1ad2301ddb8c86d35a6' have entirely different histories.

  1. 39
      ant-design-vue-jeecg/src/views/modulex/ModulexList.vue
  2. 97
      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

@ -105,7 +105,7 @@
<a-button type="primary" icon="import" <a-button type="primary" icon="import"
@click="showProcess(tablexData)">导入实体 @click="showProcess( tablexData)">导入实体
</a-button> </a-button>
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button> <a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
@ -245,9 +245,7 @@ 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,
@ -460,7 +458,6 @@ export default {
userRole1: '', //1 2 userRole1: '', //1 2
projectIdx: '', projectIdx: '',
loadRouteType: false, loadRouteType: false,
ws:{}
} }
}, },
created() { created() {
@ -471,6 +468,7 @@ 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 () {
@ -509,6 +507,7 @@ export default {
note: ['对应模块id(必填):填写正确的模块名称', note: ['对应模块id(必填):填写正确的模块名称',
'中文名称(必填):与模块名称相同。', '中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,写模块名称的英文名称。', '英文名称(必填):与模块名称相同,写模块名称的英文名称。',
'结构图(选填):类图或E-R图,可以为空,不填写。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。', '实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',
'版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态', '版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态',
'版本号:请填写小与五位数的正整数' '版本号:请填写小与五位数的正整数'
@ -596,35 +595,17 @@ export default {
} }
}, },
methods: { methods: {
// websocket //
initWS() { showProcess(data) {
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')
this.ws = new WebSocket(`${base_url}/uploadProcess/${userId}`) let ws = new WebSocket(`${base_url}/uploadProcess/${userId}`)
let flag = false this.$refs.moduleximport.show(data);
this.ws.onmessage = (e) => { ws.onmessage = (e) => {
let res = JSON.parse(e.data); this.$refs.moduleximport.edit(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"
:closable="closable" :confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
:maskClosable="maskClosable" cancelText="关闭">
>
<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,14 +33,14 @@
</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>当前状态<span :class=" ModalData.isError==='true'?stateFontColor:''">{{ ModalData.status }}</span></p> <p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p> <p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p> <p>已上传{{ ModalData.uploaded }}</p>
<a-progress <a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))" :percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:" title="上传进度:"
status="active" status="active"
:steps="ModalData.records"/> :steps="ModalData.records"/>
</a-form-item> </a-form-item>
<!-- <a-form-model-item label="注意事项" v-if="uploadFinished">--> <!-- <a-form-model-item label="注意事项" v-if="uploadFinished">-->
<a-form-model-item label="注意事项"> <a-form-model-item label="注意事项">
@ -52,14 +52,11 @@
</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 {getAction} from "@api/manage" import {downloadFile, 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'
@ -70,8 +67,6 @@ export default {
comments: {}, comments: {},
data() { data() {
return { return {
closable:false,
maskClosable:false,
title: '导入xxxxx', title: '导入xxxxx',
visible: false, visible: false,
model: {}, model: {},
@ -81,11 +76,11 @@ export default {
uploaded: '0', uploaded: '0',
isVisible: 'false', isVisible: 'false',
records: '0', records: '0',
status: '判断文件结构', status: '判断文件结构'
closeable:'false'
}, },
btnState:false, confirmLoading: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
downName:'',
url: url:
{ {
downfile: '', downfile: '',
@ -98,9 +93,7 @@ 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:{}
} }
}, },
@ -137,30 +130,32 @@ 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).then((response) => { // getAction(this.url.downfile)
const url = window.URL.createObjectURL(new Blob([response.data])) // downloadFile( window._CONFIG['downloadUrl'],'temp/ (1).xls').then((response) => {
const link = document.createElement('a') // const url = window.URL.createObjectURL(new Blob([response.data]))
link.href = url // const link = document.createElement('a')
link.setAttribute('download', 'your-document.pdf') // link.href = url
document.body.appendChild(link) // link.setAttribute('download', 'your-document.pdf')
link.click() // document.body.appendChild(link)
}) // link.click()
.catch(error => { // })
console.error(error) // .catch(error => {
}) // console.error(error)
// })
}, },
add() { add() {
}, },
show(data,ws) { show(data) {
this.url.uploadUrl = data.uploadUrl this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl this.url.downfile = data.downUrl
this.datas = data.note this.downName = data.downName
this.title = data.title this.datas=data.note
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
@ -172,18 +167,13 @@ export default {
close() { close() {
this.$emit('close') this.$emit('close')
this.visible = false this.visible = false
this.ws.close()
}, },
handleCancel() { handleCancel() {
console.log(4444) this.close()
if(this.ModalData.closeable == 'false'){ },
this.btnState=!this.btnState
} handleOk() {
this.close()
this.ws.close()
// this.close()
// this.ws.close()
// console.log(4444)
}, },
// //
onClose(e) { onClose(e) {
@ -203,15 +193,10 @@ 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,8 +292,6 @@ 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 {
@ -302,10 +300,6 @@ 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("文件格式不正确");
} }
@ -319,18 +313,10 @@ 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数据为空");
} }
@ -352,9 +338,7 @@ 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("isError", "true"); /* message.put("isVisible", "false");*/
message.put("status","预读入失败,版本号格式错误");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读入失败,版本号格式错误"); return Result.error("预读入失败,版本号格式错误");
} }
@ -370,9 +354,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexVoService.removeAll(voList); tablexVoService.removeAll(voList);
if (voList.size() == 0) { if (voList.size() == 0) {
message.put("isError", "true"); /* message.put("isVisible", "false");*/
message.put("status","导入失败,数据为空");
message.put("closeable","true");
webSocketUtils.sendMessage(loginUser.getId(), message); webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,数据为空"); return Result.error("导入失败,数据为空");
} }
@ -386,20 +368,12 @@ 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();
@ -447,57 +421,28 @@ 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