流程属性导入日志改造

This commit is contained in:
anhc 2022-08-09 11:14:03 +08:00
parent f80513ac9c
commit 1436309c4b

View File

@ -45,13 +45,39 @@
</div> </div>
</div> </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> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent,getCurrentInstance,reactive,ref } from 'vue'; import {defineComponent, getCurrentInstance, nextTick, reactive, ref} from 'vue';
import LogCodemirror from "./log-codemirror";
export default defineComponent({ export default defineComponent({
name: "data-import", name: "data-import",
components:{LogCodemirror},
setup() { setup() {
const { proxy: $this } = getCurrentInstance(); const { proxy: $this } = getCurrentInstance();
let info = reactive({ let info = reactive({
@ -70,17 +96,18 @@ export default defineComponent({
const beforeRemove = () => {} const beforeRemove = () => {}
const handleExceed = () => {} const handleExceed = () => {}
const handleSuccess = (res: any,uploadFile: any,uploadFiles: any) => { const handleSuccess = (res: any,uploadFile: any,uploadFiles: any) => {
console.log(res,'---',uploadFile,'----',uploadFiles) // console.log(res,'---',uploadFile,'----',uploadFiles)
info.fileName = res.files.name info.fileName = res.files.name
let tempFileObj = {id: uploadFile.uid,name: res.files.name,downloadUrl: res.data.data.attrs.downloadUrl} let tempFileObj = {id: uploadFile.uid,name: res.files.name,downloadUrl: res.data.data.attrs.downloadUrl}
info.fileList.push(tempFileObj) info.fileList.push(tempFileObj)
console.info('fileList',info.fileList) // console.info('fileList',info.fileList)
} }
const next = () => { const next = () => {
if (info.fileList.length === 0) { if (info.fileList.length === 0) {
$this.$message({type:'warning',message:'请上传文件'}); $this.$message({type:'warning',message:'请上传文件'});
return; return;
} }
dlg.visible = true;
let param = { let param = {
url: './jd', url: './jd',
data: { data: {
@ -89,15 +116,21 @@ export default defineComponent({
wsId: settingParam.wsId ? settingParam.wsId : '6f4e292c-1b90-4dd2-8c20-7da159cb20a5', wsId: settingParam.wsId ? settingParam.wsId : '6f4e292c-1b90-4dd2-8c20-7da159cb20a5',
groupValue: info.groupValue, groupValue: info.groupValue,
fileValue: info.fileValue, fileValue: info.fileValue,
fileName: info.fileName
} }
} }
$this.awsuiaxios.post(param) $this.awsuiaxios.post(param)
.then((ro: any) => { .then((ro: any) => {
console.log(ro) result.path = ro.data.path;
if (ro.result === 'ok') { result.logId = ro.data.logId;
$this.$message({type:'warning',message:'流程数据导入成功'}); 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) => {}) .catch((err: any) => {})
} }
@ -106,6 +139,121 @@ export default defineComponent({
info.uploadAction = axiosBaseUrl +'uf?sid='+settingParam.sessionId+'&repositoryName='+info.repositoryName+'&groupValue=' info.uploadAction = axiosBaseUrl +'uf?sid='+settingParam.sessionId+'&repositoryName='+info.repositoryName+'&groupValue='
+ info.groupValue+'&fileValue='+info.fileValue+'&appId='+ info.appId; + info.groupValue+'&fileValue='+info.fileValue+'&appId='+ info.appId;
} }
const dataCodemirrorRef = ref();
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 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 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_data_migrate_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) => {
})
}
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_data_migrate_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) => {
})
}
return { return {
info, info,
handlePreview, handlePreview,
@ -114,7 +262,13 @@ export default defineComponent({
handleExceed, handleExceed,
handleUploadBtn, handleUploadBtn,
handleSuccess, handleSuccess,
next next,
dataCodemirrorRef,
dlg,
logCodemirror,
result,
downloadLog,
dlgClose
} }
} }
}) })