Compare commits

..

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

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

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

@ -292,8 +292,6 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
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 {
@ -302,10 +300,6 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
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("文件格式不正确");
}
@ -319,18 +313,10 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//读取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数据为空");
}
@ -352,9 +338,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断版本号长度
String verison = tablexVo.getVerison();
if (verison.length() > 5) {
message.put("isError", "true");
message.put("status","预读入失败,版本号格式错误");
message.put("closeable","true");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("预读入失败,版本号格式错误");
}
@ -370,9 +354,7 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
tablexVoService.removeAll(voList);
if (voList.size() == 0) {
message.put("isError", "true");
message.put("status","导入失败,数据为空");
message.put("closeable","true");
/* message.put("isVisible", "false");*/
webSocketUtils.sendMessage(loginUser.getId(), message);
return Result.error("导入失败,数据为空");
}
@ -386,20 +368,12 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
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<Modulex> 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();
@ -447,57 +421,28 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
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("文件导入成功!");

Loading…
Cancel
Save