岗位批处理

This commit is contained in:
446052889@qq.com 2022-08-11 11:04:22 +08:00
parent 3ffa389d00
commit 30087a6d3b
2 changed files with 369 additions and 2 deletions

View File

@ -0,0 +1,364 @@
<template>
<div class="data-migration">
<div class="top-box">
<div class="title-box">岗位批处理</div>
</div>
<div class="bottom-box">
<div class="empty-box" v-if="info.fileList.length === 0">
<el-empty></el-empty>
<div class="upload-box">
<el-upload
class="upload-demo"
:action="info.uploadAction"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-success="handleSuccess"
:limit="1"
:on-exceed="handleExceed"
:show-file-list="false"
>
<awsui-button type="primary" @click="handleUploadBtn">导入Excel文件</awsui-button>
<template #tip>
<div class="el-upload__tip">
仅支持xls格式文本
</div>
</template>
</el-upload>
</div>
</div>
<div class="file-list-box" v-else>
<el-scrollbar height="400px">
<div v-for="item in info.fileList" :key="item" class="scrollbar-demo-item">
<div>{{ item.name }} <i class="awsui-iconfont" style="cursor: pointer; position: relative; top: 2px;" @click="removeFile">&#xe626;</i></div>
</div>
</el-scrollbar>
</div>
<div class="action-box" v-if="info.fileList.length > 0">
<awsui-button style="cursor: pointer" type="primary" @click="next">执行导入</awsui-button>
</div>
</div>
</div>
<el-dialog
title="日志"
v-model="dlg.visible"
width="800px"
height="520px"
destroy-on-close
@close="dlgClose">
<div style="width: 100%;height: 500px;">
<log-codemirror ref="dataCodemirrorRef" :width="logCodemirror.width" :height="logCodemirror.height" :log-str="logCodemirror.logStr" ></log-codemirror>
<div style="width: 100%;height: 10px;">
<el-progress :percentage="result.totalCount == 0 ? 0 : (Math.floor(result.importingCount / result.totalCount * 100))" color="#287ff4" />
</div>
<div style="width: 100%;height: 10px;text-align: left;">
<span>正在导入第[{{result.importingCount}}]总共[{{result.totalCount}}]</span>
</div>
</div>
<template #footer>
<span class="dialog-footer">
<awsui-button type="primary" @click="downloadLog">下载日志</awsui-button>
<awsui-button @click="dlg.visible = false">关闭</awsui-button>
</span>
</template>
</el-dialog>
</template>
<script lang="ts">
import {defineComponent, getCurrentInstance, reactive, ref, nextTick} from 'vue';
import LogCodemirror from "./log-codemirror";
export default defineComponent({
name: "position-import",
components: {
LogCodemirror,
},
setup() {
const {proxy: $this} = getCurrentInstance();
const dataCodemirrorRef = ref();
let info = reactive({
activeStep: 0,
steps: [{title: "上传"}, {title: "校验"}, {title: "结果"}],
fileList: [],
uploadAction: '',
repositoryName: 'positionExcel',
groupValue: 'upfile',
fileValue: '',
appId: 'com.actionsoft.apps.coe.pal.datamigration',
fileName: ''
});
let dlg = reactive({
visible: false
})
let logCodemirror = reactive({
height: '100%',
width: '100%',
logStr: ''
})
const result = reactive({
path: '',
logId : '',
totalCount : 0,
importingCount: 0,
resultStatus: 0,
interval: null, //
timer:0, //
})
const handleClose = (done: () => void) => {
done();
}
const handlePreview = () => {
}
const handleRemove = () => {
}
const beforeRemove = () => {
}
const handleExceed = () => {
}
const handleSuccess = (res: any, uploadFile: any, uploadFiles: any) => {
console.log(res, '---', uploadFile, '----', uploadFiles)
info.fileName = res.files.name
let tempFileObj = {id: uploadFile.uid, name: res.files.name, downloadUrl: res.data.data.attrs.downloadUrl}
info.fileList.push(tempFileObj)
console.info('fileList', info.fileList)
}
const dlgClose = () => {
if (result.resultStatus == 0) {
$this.$message({message: '导入正在进行中,关闭窗口不影响导入的执行', type: 'warning',})
}
clearResult();
logCodemirror.logStr = '';
}
const clearResult = () => {
if (result.interval != null) {
removeInterval();
}
result.path = '';
result.logId = '';
result.totalCount = 0;
result.importingCount = 0;
result.resultStatus = 0;
result.interval = null; //
result.timer = 0; //
}
const next = () => {
if (info.fileList.length === 0) {
$this.$message({type: 'warning', message: '请上传文件'});
return;
}
dlg.visible = true;
const param = {
url: './jd',
data: {
cmd: 'com.actionsoft.apps.coe.pal.datamigration_position_import',
sid: settingParam.sessionId,
wsId: settingParam.wsId ? settingParam.wsId : '1b19ab87-5727-4621-bc3f-117183b06e59',
groupValue: info.groupValue,
fileValue: info.fileValue,
fileName: info.fileName
}
}
$this.awsuiaxios.post(param)
.then((ro: any) => {
result.path = ro.data.path;
result.logId = ro.data.logId;
result.resultStatus = ro.data.resultStatus;
if (ro.result == 'ok') {
result.totalCount = ro.data.totalCount;
result.importingCount = ro.data.importingCount;
} else {
// $this.$message.error(ro.msg);
}
getImportInfoEvent();
})
.catch((err: any) => {
})
}
//
const getImportInfoEvent = () => {
result.interval = setInterval(queryLog, 1000);
}
const queryLog = () => {
const that = $this;
result.timer = new Date().getTime();
const param = {
url: './jd',
data: {
cmd: 'com.actionsoft.apps.coe.pal.datamigration_position_import_log_query',
sid: settingParam.sessionId,
logId: result.logId,
path: result.path,
timer: result.timer
}
}
that.awsuiaxios.post(param)
.then((ro: any) => {
if (ro.result === 'ok') {
if (parseInt(ro.data.timer) <= result.timer) {
logCodemirror.logStr = ro.data.content;
//
nextTick(()=> {
moveLogEnd();
});
result.resultStatus = ro.data.resultStatus;
if (result.resultStatus != 0) {
removeInterval();
result.importingCount = result.totalCount;// 100%
} else {
result.importingCount = ro.data.importingCount;
}
}
} else {
that.$message.error(ro.msg);
removeInterval();
}
})
.catch((err: any) => {
})
}
// log-codemirror
const moveLogEnd = () => {
dataCodemirrorRef.value.moveTextToEnd();
}
const removeInterval= () => {
clearInterval(result.interval);
}
const downloadLog = () => {
//
const that = $this;
if (result.path == '') {
that.$message({message: '获取日志失败', type: 'warning'});
return;
}
if (result.resultStatus == 0) {
that.$message({message: '正在导入,请稍等', type: 'warning'});
return;
}
const param = {
url:'./jd',
data:{
cmd : "com.actionsoft.apps.coe.pal.datamigration_position_import_log_download",
path: result.path,
logId: result.logId
}
};
that.awsuiaxios.post(param)
.then((ro: any) => {
if (ro.result === 'ok') {
window.open(ro.data.url);
} else {
that.$message.error(ro.msg);
}
})
.catch((err: any) => {
})
}
const removeFile = () => {
info.fileList = [];
}
const handleUploadBtn = () => {
info.fileValue = 'arisXML-' + transDate(new Date());
info.uploadAction = axiosBaseUrl + 'uf?sid=' + settingParam.sessionId + '&repositoryName=' + info.repositoryName + '&groupValue='
+ info.groupValue + '&fileValue=' + info.fileValue + '&appId=' + info.appId;
}
const transDate = (date: Date) => {
var ndate = new Date(date);
let type = 'yyyy-MM-dd-hhmmss';
const o = {
'M+': ndate.getMonth() + 1, //
'd+': ndate.getDate(), //
'h+': ndate.getHours(), //
'm+': ndate.getMinutes(), //
's+': ndate.getSeconds(), //
'q+': Math.floor((ndate.getMonth() + 3) / 3), //
'S': ndate.getMilliseconds() //
}
if (/(y+)/.test(type)) type = type.replace(RegExp.$1, (ndate.getFullYear() + '').substr(4 - RegExp.$1.length))
for (const k in o) {
if (new RegExp('(' + k + ')').test(type)) type = type.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
return type;
}
return {
dataCodemirrorRef,
info,
dlg,
logCodemirror,
result,
handlePreview,
handleRemove,
beforeRemove,
handleExceed,
handleUploadBtn,
handleSuccess,
next,
removeFile,
handleClose,
dlgClose,
downloadLog
}
}
})
</script>
<style lang="less" scoped>
.data-migration {
width: 100%;
height: 100%;
background-color: #F7F7FB;
.top-box {
height: 75px;
margin: 0 35px 0 35px;
display: flex;
justify-content: space-between;
.title-box {
line-height: 75px;
font-size: 18px;
}
.step-box {
width: 45%;
padding: 15px 0;
}
}
.bottom-box {
height: 650px;
margin: 0 35px 0 35px;
background-color: rgb(255, 255, 255);
display: flex;
justify-content: space-around;
align-items: center;
flex-direction: column;
.empty-box {
width: 500px;
height: 500px;
.upload-box {
text-align: center;
}
}
.file-list-box {
width: 100%;
:deep(.el-scrollbar) {
padding: 0 25px;
}
.scrollbar-demo-item {
font-size: 16px;
height: 35px;
margin: 10px;
border-radius: 4px;
background: var(--el-color-primary-light-9);
color: var(--el-color-primary);
line-height: 35px;
}
}
}
}
</style>

View File

@ -47,6 +47,7 @@ import BatchDataImport from '@/components/batch-data-import.vue';
import FormImport from '@/components/form-import.vue';
import PerformanceImport from '@/components/Performance-import.vue';
import SystemImport from '@/components/system-import.vue';
import PositionImport from '@/components/position-import.vue';
export default defineComponent({
name: 'Home',
@ -58,7 +59,8 @@ export default defineComponent({
BatchDataImport,
FormImport,
PerformanceImport,
SystemImport
SystemImport,
PositionImport
},
setup(){
// const { proxy: $this } = getCurrentInstance();
@ -70,7 +72,8 @@ export default defineComponent({
{label:"Aris流程导入",name:"dataMigration",icon:"&#xe741;"},// xml
{label:"流程属性导入",name:"dataImport",icon:"&#xe6a4;"},// word
{label:"IT系统导入",name:"dataItImport",icon:"&#xe730;"},// excel
{label:"模型转换",name:"moduleChange",icon:"&#xe677;"},
{label:"岗位批处理",name:"positionImport",icon:"&#xe730;"},// excel
// {label:"",name:"moduleChange",icon:"&#xe677;"},
{label:"制度导入",name:"systemImport",icon:"&#xe6a4;"},// word
{label:"表单导入",name:"formImport",icon:"&#xe6a4;"},// word
{label:"批处理工具",name:"batchDataImport",icon:"&#xe6a4;"},// word