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. 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"
@click="showProcess( tablexData)">导入实体
@click="showProcess(tablexData)">导入实体
</a-button>
<a-button @click="fanhui" type="primary" icon="rollback">返回</a-button>
@ -245,7 +245,9 @@ export default {
uploaded: '0',
isVisible: 'false',
records: '0',
status: '判断文件结构'
status: '判断文件结构',
isError: 'false',
closeable: 'false'
},
visible: false,
moduleximport: false,
@ -458,6 +460,7 @@ export default {
userRole1: '', //1 2
projectIdx: '',
loadRouteType: false,
ws:{}
}
},
created() {
@ -468,7 +471,6 @@ export default {
this.loginRole(usercode)
//console.log('userole1',this.userRole1)
this.getSuperFieldList()
/* this.showProcess()*/
},
computed: {
modelImportExcelUrl: function () {
@ -507,7 +509,6 @@ export default {
note: ['对应模块id(必填):填写正确的模块名称',
'中文名称(必填):与模块名称相同。',
'英文名称(必填):与模块名称相同,写模块名称的英文名称。',
'结构图(选填):类图或E-R图,可以为空,不填写。',
'实体状态:可填入值为[正常、停用、废弃],若不填写,默认为“正常”状态。',
'版本状态: 可填入值为[当前、历史],若不填写,默认为“当前”状态',
'版本号:请填写小与五位数的正整数'
@ -595,17 +596,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

@ -3,10 +3,10 @@
:title="title"
width="50%"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
:closable="closable"
@cancel="handleCancel"
cancelText="关闭">
:maskClosable="maskClosable"
>
<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,14 +33,14 @@
</a-upload>
</a-form-item>
<a-form-item v-if="ModalData.isVisible==='true'" class="box">
<p>当前状态{{ ModalData.status }}</p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
<a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:"
status="active"
:steps="ModalData.records"/>
<p>当前状态<span :class=" ModalData.isError==='true'?stateFontColor:''">{{ ModalData.status }}</span></p>
<p>总记录数{{ ModalData.records }}</p>
<p>已上传{{ ModalData.uploaded }}</p>
<a-progress
:percent="parseInt(String(ModalData.uploaded/ModalData.records*100))"
title="上传进度:"
status="active"
:steps="ModalData.records"/>
</a-form-item>
<!-- <a-form-model-item label="注意事项" v-if="uploadFinished">-->
<a-form-model-item label="注意事项">
@ -52,11 +52,14 @@
</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 {downloadFile, getAction} from "@api/manage"
import {getAction} from "@api/manage"
import store from '@/store'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {mixinDevice} from '@/utils/mixin'
@ -67,6 +70,8 @@ export default {
comments: {},
data() {
return {
closable:false,
maskClosable:false,
title: '导入xxxxx',
visible: false,
model: {},
@ -76,11 +81,11 @@ export default {
uploaded: '0',
isVisible: 'false',
records: '0',
status: '判断文件结构'
status: '判断文件结构',
closeable:'false'
},
confirmLoading: false,
btnState:false,
form: this.$form.createForm(this),
downName:'',
url:
{
downfile: '',
@ -93,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:{}
}
},
@ -130,32 +137,30 @@ export default {
},
//
handleDownload() {
downloadFile( this.url.downfile,this.downName)
// getAction(this.url.list, params).then((res) =>
// 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)
// })
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)
})
},
add() {
},
show(data) {
show(data,ws) {
this.url.uploadUrl = data.uploadUrl
this.url.downfile = data.downUrl
this.downName = data.downName
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
@ -167,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) {
@ -193,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;
}
</style>

@ -292,6 +292,8 @@ 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 {
@ -300,6 +302,10 @@ 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("文件格式不正确");
}
@ -313,10 +319,18 @@ 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数据为空");
}
@ -338,7 +352,9 @@ public class TablexController extends JeecgController<Tablex, ITablexService> {
//判断版本号长度
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<Tablex, ITablexService> {
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<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();
@ -421,28 +447,57 @@ 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