Commit 424166ee authored by 曾沂轮's avatar 曾沂轮

Merge branch 'feature-addChartsApp' into 'master'

Feat: 添加图表应用

See merge request !3
parents a311256e 27af9548
<template>
<div
v-if="reportDatas && !loading"
style="height:100%">
<smart-report
ref="reporting"
:baseUrl="baseUrl"
:data="reportDatas">
</smart-report>
</div>
</template>
<script>
import Api from '@charts/api';
import { baseUrl } from '@config/http.config';
import { getQueryString } from './utils';
export default {
name: 'App',
data() {
return {
pageId: '',
baseUrl: baseUrl + '/charts',
reportDatas: null,
loading: false
};
},
created() {
this.pageId = getQueryString('pageId');
},
mounted() {
this.initDatas();
},
methods: {
initDatas() {
if (!this.pageId) return;
this.loading = true;
Api.getChartViewById(this.pageId).then(res => {
this.loading = false;
const { status, data } = res;
if (status === 0) {
if (data.pageData !== null) {
data.pageData = JSON.parse(data.pageData);
}
this.reportDatas = data;
return false;
} else {
this.$message.warning(res.message || '系统异常!');
}
}).catch(err => {
this.loading = false;
this.$message.error(err.message || '系统故障!');
});
}
}
};
</script>
<style>
html, body {
min-height: 100%;
}
</style>
import config from '@config/config';
const Api = {
...config,
/**
* 获取图表信息
* @param {String} rid
*/
getChartViewById(rid) {
return config.doGetPromise('/charts/chartsView/getChartViewById', {rid: rid});
}
};
export default Api;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" type="image/ico" href="<%= BASE_URL %>favicon.ico">
<title>图表渲染 - Smart Web</title>
<!-- <link rel="stylesheet" href="<%= BASE_URL %>iconfont/iconfont.css"> -->
<style type="text/css">
.maskbox {
border: 2px solid #ff0000;
background: #f8ecda;
opacity: 0.1;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}
</style>
</head>
<body>
<div id="chartsapp"></div>
<!-- built files will be auto injected -->
</body>
</html>
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import ElemetUI from 'element-ui';
import 'element-ui/packages/theme-chalk/lib/index.css';
import SmartCharts from 'smart-charts';
import 'smart-charts/lib/smart-report/smartReport.css';
// import scss
Vue.config.productionTip = false;
Vue.use(ElemetUI, {
size: 'medium',
zIndex: 4000
});
Vue.use(SmartCharts);
/* eslint-disable no-new */
new Vue({
el: '#chartsapp',
components: {
App
},
template: '<App/>'
});
blockquote,body,button,dd,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,html,iframe,input,legend,li,ol,p,pre,td,textarea,th,ul{
margin:0;
padding:0;
}
html, body {
width: 100%;
}
body {
min-width: 1200px;
font-size: 1rem;
font-family: -apple-system,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Microsoft YaHei,Source Han Sans SC,Noto Sans CJK SC,WenQuanYi Micro Hei,sans-serif;
color: #606266;
overflow: auto;
}
iframe {
width: 100%;
height: 100%;
border: 0;
outline: none;
}
a {
color: #0a6fe2;
text-decoration: none;
}
ul, ol, li {
list-style: none;
}
* {
scrollbar-base-color: #cecece;
scrollbar-3dlight-color: #eee;
scrollbar-highlight-color: #eee;
scrollbar-track-color: #f1f1f1;
// scrollbar-arrow-color: #000;
scrollbar-shadow-color: #eee;
// scrollbar-dark-shadow-color: #eee;
box-sizing: border-box;
}
*::-webkit-scrollbar {
width: 6px;
height: 6px;
}
*::-webkit-scrollbar-button {
display: none;
}
*::-webkit-scrollbar-track-piece {
background-color: #f2f2f2;
}
*::-webkit-scrollbar-thumb {
background-color: #C1C1C1;
border-radius: 6px;
}
textarea {
font-family: 'Microsoft YaHei', Arial, Helvetica, sans-serif !important;
}
\ No newline at end of file
/**
* 获取URL参数
* @param {string} name 参数名
*/
export function getQueryString(name) {
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
const r = window.location.search.substr(1).match(reg);
if (r !== null) return unescape(r[2]);
return null;
}
import config from './config'; import config from '@config/config';
const baseUrl = config.baseUrl;
const Api = { const Api = {
...config, ...config,
login(data) { login(data) {
return config.doPostPromise(baseUrl + '/index/login', data); return config.doPostPromise('/index/login', data);
}, },
checkLogin() { checkLogin() {
return config.doGetPromise(baseUrl + '/index/checkLogin', {}, { retry: 0 }); return config.doGetPromise('/index/checkLogin', {}, { retry: 0 });
}, },
logout() { logout() {
return config.doGetPromise(baseUrl + '/index/logout', {}); return config.doGetPromise('/index/logout', {});
}, },
/** /**
...@@ -24,7 +22,7 @@ const Api = { ...@@ -24,7 +22,7 @@ const Api = {
*/ */
getBusinessStartForm(businessDefinitionId, taskId) { getBusinessStartForm(businessDefinitionId, taskId) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/v1.1.0/workflow/workflowForm/getBusinessStartForm', '/v1.1.0/workflow/workflowForm/getBusinessStartForm',
{ {
businessDefinitionId, businessDefinitionId,
taskId taskId
...@@ -40,7 +38,7 @@ const Api = { ...@@ -40,7 +38,7 @@ const Api = {
*/ */
renderFormByTaskId(taskId, linkId, linkKey) { renderFormByTaskId(taskId, linkId, linkKey) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/v1.1.0/workflow/workflowForm/renderFormByTaskId', '/v1.1.0/workflow/workflowForm/renderFormByTaskId',
{ {
taskId: taskId, taskId: taskId,
linkInstanceId: linkId, linkInstanceId: linkId,
...@@ -55,7 +53,7 @@ const Api = { ...@@ -55,7 +53,7 @@ const Api = {
*/ */
renderFinishForm(processId) { renderFinishForm(processId) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/v1.1.0/workflow/workflowForm/renderFinishForm', '/v1.1.0/workflow/workflowForm/renderFinishForm',
{ {
historyProcessInstanceId: processId historyProcessInstanceId: processId
} }
...@@ -67,14 +65,14 @@ const Api = { ...@@ -67,14 +65,14 @@ const Api = {
* @param {string} formid 表单ID * @param {string} formid 表单ID
*/ */
getForm(formid) { getForm(formid) {
return config.doGetPromise(baseUrl + '/v1.1.0/form/getForm', { return config.doGetPromise('/v1.1.0/form/getForm', {
rid: formid rid: formid
}); });
}, },
getAdminDivisionTree() { getAdminDivisionTree() {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/administrativeDivisions/getAdministrativeDivisionTree' '/administrativeDivisions/getAdministrativeDivisionTree'
); );
}, },
...@@ -84,7 +82,7 @@ const Api = { ...@@ -84,7 +82,7 @@ const Api = {
*/ */
getSystemAllModules(id) { getSystemAllModules(id) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/systemModule/privilege/getUserModulesTreeBySystemId', '/systemModule/privilege/getUserModulesTreeBySystemId',
{ systemId: id } { systemId: id }
); );
}, },
...@@ -95,7 +93,7 @@ const Api = { ...@@ -95,7 +93,7 @@ const Api = {
* @param {Number} valid 是否可用, -1:审核中 1:可用(第一次登录,需要修改密码) 2:可用(非第一次登录,不需要修改密码) * @param {Number} valid 是否可用, -1:审核中 1:可用(第一次登录,需要修改密码) 2:可用(非第一次登录,不需要修改密码)
*/ */
getOrganTree(type, valid) { getOrganTree(type, valid) {
return config.doGetPromise(baseUrl + '/organization/manager/getOrganTree', { return config.doGetPromise('/organization/manager/getOrganTree', {
type: type, type: type,
valid: valid valid: valid
}); });
...@@ -104,7 +102,7 @@ const Api = { ...@@ -104,7 +102,7 @@ const Api = {
// 获取代码字典 // 获取代码字典
getChildItemByRootCode(data) { getChildItemByRootCode(data) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/codeDict/getChildItemByRootCode', '/codeDict/getChildItemByRootCode',
data data
); );
}, },
...@@ -115,11 +113,8 @@ const Api = { ...@@ -115,11 +113,8 @@ const Api = {
* @param {FormData} data 表单数据 * @param {FormData} data 表单数据
*/ */
checkAndSubmitTaskByFormData(taskId, data) { checkAndSubmitTaskByFormData(taskId, data) {
return config.doPostPromiseForm( return config.doPostPromiseForm('/v1.1.0/workflow/workflowForm/checkAndSubmitTaskByFormData/' +
baseUrl + taskId, data
'/v1.1.0/workflow/workflowForm/checkAndSubmitTaskByFormData/' +
taskId,
data
); );
}, },
...@@ -128,8 +123,7 @@ const Api = { ...@@ -128,8 +123,7 @@ const Api = {
* @param {string} taskId 流程ID * @param {string} taskId 流程ID
*/ */
getTranformUser(taskId) { getTranformUser(taskId) {
return config.doGetPromise( return config.doGetPromise('/workflow/linkInstance/findLinkInstanceByTaskIdPassto',
baseUrl + '/workflow/linkInstance/findLinkInstanceByTaskIdPassto',
{ {
taskId: taskId taskId: taskId
} }
...@@ -144,7 +138,7 @@ const Api = { ...@@ -144,7 +138,7 @@ const Api = {
*/ */
getRerunPeople(currentTaskId, processDefinitionId, nextLinkKey) { getRerunPeople(currentTaskId, processDefinitionId, nextLinkKey) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/workflow/workflowForm/getRerunPeople', '/workflow/workflowForm/getRerunPeople',
{ {
currentTaskId, currentTaskId,
processDefinitionId, processDefinitionId,
...@@ -158,7 +152,7 @@ const Api = { ...@@ -158,7 +152,7 @@ const Api = {
*/ */
findExecutionIdByTaskId(taskId) { findExecutionIdByTaskId(taskId) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/workflow/execution/findExecutionIdByTaskId', '/workflow/execution/findExecutionIdByTaskId',
{ {
taskId taskId
} }
...@@ -183,7 +177,7 @@ const Api = { ...@@ -183,7 +177,7 @@ const Api = {
anotherAssignee anotherAssignee
) { ) {
return config.doGetPromise( return config.doGetPromise(
baseUrl + '/v1.1.0/workflow/workflowForm/sendback', '/v1.1.0/workflow/workflowForm/sendback',
{ {
executionId, executionId,
linkDefinitionKey, linkDefinitionKey,
......
import config from '../api/config';
const url = config.baseUrl;
export default [ export default [
{ {
name: 'guidance', name: 'guidance',
text: '办理指南', text: '办理指南',
icon: 'el-icon-info', icon: 'el-icon-info',
api: url + '/workflowWebService/getProcessManagementGuide' api: '/workflowWebService/getProcessManagementGuide'
}, },
{ {
name: 'save', name: 'save',
text: '保存', text: '保存',
icon: 'el-icon-tickets', icon: 'el-icon-tickets',
api: url + '/v1.1.0/workflow/workflowForm/saveFormData' api: '/v1.1.0/workflow/workflowForm/saveFormData'
}, },
{ {
name: 'sign', name: 'sign',
text: '接办', text: '接办',
icon: 'el-icon-tickets', icon: 'el-icon-tickets',
api: url + '/workflow/workflowForm/receiveTasks' api: '/workflow/workflowForm/receiveTasks'
// api: url + '/workflowWebService/claimTask' // api: '/workflowWebService/claimTask'
}, },
{ {
name: 'forceSign', name: 'forceSign',
text: '强制接办', text: '强制接办',
icon: 'el-icon-tickets', icon: 'el-icon-tickets',
api: url + '/workflowWebService/forceClaimForm' api: '/workflowWebService/forceClaimForm'
}, },
{ {
name: 'submit', name: 'submit',
text: '提交', text: '提交',
icon: 'el-icon-check', icon: 'el-icon-check',
api: url + '/v1.1.0/workflow/workflowForm/submitTaskOnDialog' api: '/v1.1.0/workflow/workflowForm/submitTaskOnDialog'
}, },
{ {
name: 'isSendBack', name: 'isSendBack',
text: '提交退回', text: '提交退回',
icon: 'el-icon-check', icon: 'el-icon-check',
api: url + '/v1.1.0/workflow/workflowForm/submitSendbackTask/' api: '/v1.1.0/workflow/workflowForm/submitTaskOnDialog'
// api: '/v1.1.0/workflow/workflowForm/submitSendbackTask/'
}, },
/* { /* {
id: 'backSend', id: 'backSend',
...@@ -51,61 +48,61 @@ export default [ ...@@ -51,61 +48,61 @@ export default [
name: 'finish', name: 'finish',
text: '结档', text: '结档',
icon: 'el-icon-edit-outline', icon: 'el-icon-edit-outline',
api: url + '/workflowWebService/finishProcessInstanceByTaskId' api: '/workflowWebService/finishProcessInstanceByTaskId'
}, },
{ {
name: 'refund', name: 'refund',
text: '退件', text: '退件',
icon: 'el-icon-back', icon: 'el-icon-back',
api: url + '/workflow/workflowForm/refundTasks' api: '/workflow/workflowForm/refundTasks'
}, },
{ {
name: 'urge', name: 'urge',
text: '催办', text: '催办',
icon: 'el-icon-share', icon: 'el-icon-share',
api: url + '/workflow/workflowForm/remindTasks' api: '/workflow/workflowForm/remindTasks'
}, },
{ {
name: 'turn', name: 'turn',
text: '转办', text: '转办',
icon: 'el-icon-refresh', icon: 'el-icon-refresh',
api: url + '/workflow/workflowForm/passTasksToSb' api: '/workflow/workflowForm/passTasksToSb'
}, },
{ {
name: 'unsign', name: 'unsign',
text: '撤办', text: '撤办',
icon: 'el-icon-remove-outline', icon: 'el-icon-remove-outline',
api: url + '/workflow/workflowForm/unclaimTasks' api: '/workflow/workflowForm/unclaimTasks'
}, },
{ {
name: 'apply', name: 'apply',
text: '申请挂起', text: '申请挂起',
icon: 'el-icon-document', icon: 'el-icon-document',
api: url + '/workflow/workflowForm/applySuspendTasks' api: '/workflow/workflowForm/applySuspendTasks'
}, },
{ {
name: 'suspend', name: 'suspend',
text: '挂起', text: '挂起',
icon: 'el-icon-goods', icon: 'el-icon-goods',
api: url + '/workflow/workflowForm/suspendProcesses' api: '/workflow/workflowForm/suspendProcesses'
}, },
{ {
name: 'activeSuspend', name: 'activeSuspend',
text: '解除挂起', text: '解除挂起',
icon: 'el-icon-sold-out', icon: 'el-icon-sold-out',
api: url + '/workflow/workflowForm/activateProcesses' api: '/workflow/workflowForm/activateProcesses'
}, },
{ {
name: 'withdraw', name: 'withdraw',
text: '收回', text: '收回',
icon: 'el-icon-arrow-left', icon: 'el-icon-arrow-left',
api: url + '/workflow/workflowForm/withdrawTasks' api: '/workflow/workflowForm/withdrawTasks'
}, },
{ {
name: 'rerun', name: 'rerun',
text: '退回', text: '退回',
icon: 'el-icon-d-arrow-left', icon: 'el-icon-d-arrow-left',
api: url + '/workflowWebService/prepareJumpTo' api: '/workflowWebService/prepareJumpTo'
}, },
{ {
name: 'getdraw', name: 'getdraw',
...@@ -116,6 +113,6 @@ export default [ ...@@ -116,6 +113,6 @@ export default [
name: 'isBRule', name: 'isBRule',
text: '查看限制消息', text: '查看限制消息',
icon: 'el-icon-view', icon: 'el-icon-view',
api: url + '/workflowWebService/getBusinessRuleResults' api: '/workflowWebService/getBusinessRuleResults'
} }
]; ];
...@@ -78,9 +78,7 @@ import { ...@@ -78,9 +78,7 @@ import {
getFinishForm, getFinishForm,
notification, notification,
outerNotice, outerNotice,
openTab, openTab
closeTab,
refreshTab
} from '@form/utils/form'; } from '@form/utils/form';
import Api from '@form/api'; import Api from '@form/api';
import btnsSourceMap from '@form/config/btnsSourceMap'; import btnsSourceMap from '@form/config/btnsSourceMap';
...@@ -146,8 +144,8 @@ export default { ...@@ -146,8 +144,8 @@ export default {
}, },
// 刷新 // 刷新
refresh(taskId) { refresh() {
this.fetch(taskId); this.fetch();
}, },
handleResultHtml(data, key) { handleResultHtml(data, key) {
...@@ -159,12 +157,10 @@ export default { ...@@ -159,12 +157,10 @@ export default {
return {}; return {};
} }
}, },
/**
* 新建工作时,保存的时候后端返回tId
*/
fetch(tId) { fetch(tId) {
let taskId = getTaskId() || this.childrenData.taskId; let taskId = getTaskId() || this.childrenData.taskId;
const linkId = tId ? tId : getLinkId() || this.childrenData.linkId; const linkId = tId ? tId : getLinkId() || this.childrenData.linkId || '';
const linkKey = getLinkKey() || this.childrenData.linkKey; const linkKey = getLinkKey() || this.childrenData.linkKey;
// console.log(taskId, linkId, linkKey) // console.log(taskId, linkId, linkKey)
let apiFn = 'renderFormByTaskId'; let apiFn = 'renderFormByTaskId';
...@@ -421,9 +417,13 @@ export default { ...@@ -421,9 +417,13 @@ export default {
// console.log(res) // console.log(res)
if (res.status === 0) { if (res.status === 0) {
notification('success', '保存成功!'); notification('success', '保存成功!');
if (!res.data.taskId) return false; if (!res.data.taskId) {
this.refresh();
return false;
};
// 携带taskId刷新当前iframe页
this.createTaskId = res.data.taskId; this.createTaskId = res.data.taskId;
this.refresh(res.data.taskId); this.fetch(res.data.taskId);
} else { } else {
notification('warning', res.message || '保存失败,请重试!'); notification('warning', res.message || '保存失败,请重试!');
} }
...@@ -455,13 +455,12 @@ export default { ...@@ -455,13 +455,12 @@ export default {
} else { } else {
// 关闭和刷新标签页 // 关闭和刷新标签页
setTimeout(() => { setTimeout(() => {
refreshTab();
closeTab();
outerNotice({ outerNotice({
type: 'success', type: 'success',
title: '提交成功', title: '提交成功',
message: res.message message: res.message
}); });
this.refresh();
}, 150); }, 150);
} }
} else { } else {
...@@ -488,13 +487,12 @@ export default { ...@@ -488,13 +487,12 @@ export default {
this.submitTaskDialogVisible = false; this.submitTaskDialogVisible = false;
// 关闭标签 // 关闭标签
setTimeout(() => { setTimeout(() => {
refreshTab();
closeTab();
outerNotice({ outerNotice({
type: 'success', type: 'success',
title: '提交成功', title: '提交成功',
message: res.message message: res.message
}); });
this.refresh();
}, 150); }, 150);
} else { } else {
notification('warning', res.message || '提交失败!'); notification('warning', res.message || '提交失败!');
...@@ -596,13 +594,12 @@ export default { ...@@ -596,13 +594,12 @@ export default {
if (res.status === 0) { if (res.status === 0) {
// 关闭和刷新标签页 // 关闭和刷新标签页
setTimeout(() => { setTimeout(() => {
refreshTab();
closeTab();
outerNotice({ outerNotice({
type: 'success', type: 'success',
title: '退件成功!', title: '退件成功!',
message: res.message message: res.message
}); });
this.refresh();
}, 150); }, 150);
} else { } else {
notification('warning', res.message || '退件失败,请重试'); notification('warning', res.message || '退件失败,请重试');
...@@ -655,15 +652,13 @@ export default { ...@@ -655,15 +652,13 @@ export default {
// 转办成功 // 转办成功
handleTransformTaskSave(res) { handleTransformTaskSave(res) {
this.transformDialogVisible = false; this.transformDialogVisible = false;
// 关闭和刷新
refreshTab();
closeTab();
// 外部提示通知 // 外部提示通知
outerNotice({ outerNotice({
type: 'success', type: 'success',
title: '转办成功', title: '转办成功',
message: res.message message: res.message
}); });
this.refresh();
}, },
// 申请挂起、挂起 // 申请挂起、挂起
suspendTask(apiUrl, type) { suspendTask(apiUrl, type) {
...@@ -739,7 +734,16 @@ export default { ...@@ -739,7 +734,16 @@ export default {
this.isLoading = false; this.isLoading = false;
// console.log('receiveTasks', res) // console.log('receiveTasks', res)
if (res.status === 0) { if (res.status === 0) {
this.handleDataReturnErr(res.data, '收回成功'); // 关闭和刷新标签页
setTimeout(() => {
outerNotice({
type: 'success',
title: '收回成功!',
message: res.message
});
this.refresh();
}, 150);
// this.handleDataReturnErr(res.data, '收回成功');
} else { } else {
notification('warning', res.message || '收回失败,请重试'); notification('warning', res.message || '收回失败,请重试');
} }
...@@ -785,7 +789,7 @@ export default { ...@@ -785,7 +789,7 @@ export default {
// 关闭提交后的对话框事件 // 关闭提交后的对话框事件
handleSubmitTaskClose() { handleSubmitTaskClose() {
this.submitTaskDialogVisible = false; this.submitTaskDialogVisible = false;
this.refresh(this.createTaskId); this.fetch(this.createTaskId);
} }
} }
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* smart-page * smart-page
*/ */
import { getQueryString } from '@form/utils/form'; import { getQueryString } from '@form/utils/form';
import config from '@form/api/config'; import config from '@config/config';
export default { export default {
name: 'PageView', name: 'PageView',
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
}, },
"dependencies": { "dependencies": {
"core-js": "^2.6.5", "core-js": "^2.6.5",
"smart-charts": "^1.0.0-alpha",
"smart-web": "^2.2.1", "smart-web": "^2.2.1",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.1.3" "vue-router": "^3.1.3"
......
...@@ -12,6 +12,7 @@ import 'smart-web/packages/styles/lib/main.css'; ...@@ -12,6 +12,7 @@ import 'smart-web/packages/styles/lib/main.css';
import './plugins/expression'; import './plugins/expression';
import './utils/window'; import './utils/window';
import './utils/appinit';
import './api/loginInterceptor'; import './api/loginInterceptor';
Vue.config.productionTip = false; Vue.config.productionTip = false;
......
import Vue from 'vue';
import store from '@/store';
import Utils from '@/utils';
import MyWebSocket from '@/utils/webSocket';
const vm = new Vue();
let webSocket = null;
// 监听用户改变
vm.$watch(function() {
return store.state.userInfo;
}, function(val, oVal) {
if (val && oVal && val.userId === oVal.userId) return false;
if (!webSocket) webSocket = new MyWebSocket(store.state.userInfo);
if (!Utils.isEmptyData(val)) {
webSocket.init();
} else {
webSocket.closeWebSocketConnection();
webSocket = null;
}
});
/**
* 单独消息模块
*/
import { Notification } from 'element-ui';
import { baseUrl } from '@config/http.config';
import store from '@/store';
import router from '@/router';
import Vue from 'vue';
const vm = new Vue();
function webSocket(userInfo) {
this.instantce = null;
this.userInfo = userInfo;
this.$store = store;
this.messageType = [{
id: 'doingWork',
name: '在办工作',
status: [100, 101, 102, 103, 104, 105, 106, 109, 113, 112]
},
{
id: 'returnBox',
name: '退件箱',
status: [108]
},
{
id: 'suspendWork',
name: '已挂工作',
status: [110, 111]
},
{
id: 'finishedWork',
name: '办结工作',
status: [107]
}]; // 消息类型
}
webSocket.prototype = {
/**
* 初始化webSocket
*/
init() {
if (window.WebSocket && this.userInfo && this.userInfo.userId) {
const that = this;
this.instantce = new WebSocket(`ws:${baseUrl}/MessageWebsocket?userId=${this.userInfo.userId}`);
this.instantce.onopen = function(event) {
};
this.instantce.onclose = function(event) {
};
this.instantce.onmessage = function(event) {
if (event.data) that.handleReceiveMessage(event.data);
};
this.instantce.onerror = function(event) {
};
}
},
/**
* 接受消息后的处理
*/
handleReceiveMessage(data) {
data = JSON.parse(data);
this.$store.dispatch('setUnreadMessage', data.count);
if (parseInt(data.count, 10) === 0) return false;
const type = data.content ? this.handleMessageType(data.content.businessType) : 9999;
const h = vm.$createElement;
Notification({
title: data.content ? data.content.title : this.convertTypeToObjectInfo(type).name,
position: 'bottom-right',
type: 'info',
dangerouslyUseHTMLString: true,
duration: 5000,
message: h('div', {
style: {
display: 'flex',
alignItems: 'center'
}
}, [
h('span', null
, data.content ? data.content.content : '您有新的处理任务,请及时处理!'),
h('el-button', {
style: {
marginLeft: '5px'
},
attrs: {
size: 'small',
type: 'text'
},
on: {
click: () => { this.handleLinkToTargetTab(type);}
}
}, '查看')
])
});
},
/**
* 跳转链接
*/
handleLinkToTargetTab(type) {
router.push({name: this.convertTypeToObjectInfo(type).id});
},
/**
* 转换成路由消息数据
*/
convertTypeToObjectInfo(type) {
return this.messageType[type] || { id: 'appMessage', name: '我的消息'};
},
/**
* 处理消息类型
*/
handleMessageType(type) {
type = parseInt(type, 10) || 9999;
let flag = false;
// 找到对应的路由消息下标
for (let i = 0; i < this.messageType.length; i++) {
if (this.messageType[i].status.indexOf(type) >= 0) {
type = i;
flag = true;
}
if (flag) break;
}
return type;
},
/**
* 关闭webSocket
*/
closeWebSocketConnection() {
window.WebSocket && this.instantce && this.instantce.close();
this.instantce = null;
}
};
export default webSocket;
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<script> <script>
import Api from '@/api'; import Api from '@/api';
import { baseUrl, serviceUrl } from '@config/http.config'; import { serviceUrl } from '@config/http.config';
import Logo from './Logo.vue'; import Logo from './Logo.vue';
import AppBreadcrumb from './Breadcrumb'; import AppBreadcrumb from './Breadcrumb';
...@@ -83,49 +83,11 @@ export default { ...@@ -83,49 +83,11 @@ export default {
data() { data() {
return { return {
serviceUrl, serviceUrl,
isLoadingout: false, isLoadingout: false
websocket: null
}; };
}, },
watch: {
userInfo(val) {
if (val) {
this.init();
} else {
window.WebSocket && this.websocket && this.websocket.close();
}
}
},
mounted() {
this.init();
},
beforeDestroy() {
window.WebSocket && this.websocket && this.websocket.close();
},
methods: { methods: {
init() {
if (this.userInfo && this.userInfo.userId && window.WebSocket) {
this.websocket = new WebSocket(`ws:${baseUrl}/MessageWebsocket?userId=${this.userInfo.userId}`);
this.websocket.onopen = function(event) {
// console.log(event)
};
this.websocket.onclose = function(event) {
// console.log(event)
};
this.websocket.onmessage = (event) => {
// state.unreadMessage = event.data
// this.unreadMessage = event.data;
this.$store.dispatch('setUnreadMessage', event.data);
};
this.websocket.onerror = function(event) {
// console.log(event)
};
}
},
/** /**
* 查看消息 * 查看消息
*/ */
......
...@@ -21,6 +21,12 @@ const pages = { ...@@ -21,6 +21,12 @@ const pages = {
template: 'form/form.html', template: 'form/form.html',
filename: 'form.html', filename: 'form.html',
chunks: ['chunk-vendors', 'chunk-commons', 'element-ui', 'smart-form', 'form'] chunks: ['chunk-vendors', 'chunk-commons', 'element-ui', 'smart-form', 'form']
},
charts: {
entry: 'charts/main.js',
template: 'charts/charts.html',
filename: 'charts.html',
chunks: ['chunk-vendors', 'element-ui', 'smart-charts', 'charts']
} }
}; };
...@@ -55,6 +61,11 @@ module.exports = { ...@@ -55,6 +61,11 @@ module.exports = {
name: 'smart-form', // 单独将拆包 name: 'smart-form', // 单独将拆包
priority: 21, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app priority: 21, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
test: /[\\/]node_modules[\\/]smart-form[\\/]/ test: /[\\/]node_modules[\\/]smart-form[\\/]/
},
smartCharts: {
name: 'smart-charts', // 单独将拆包
priority: 21, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
test: /[\\/]node_modules[\\/]smart-charts[\\/]/
}/* , }/* ,
commons: { commons: {
name: 'chunk-comomns', name: 'chunk-comomns',
...@@ -74,6 +85,7 @@ module.exports = { ...@@ -74,6 +85,7 @@ module.exports = {
config.resolve.alias config.resolve.alias
.set('@', resolve('src')) .set('@', resolve('src'))
.set('@form', resolve('form')) .set('@form', resolve('form'))
.set('@charts', resolve('charts'))
.set('@config', resolve('config')); .set('@config', resolve('config'));
const arr = ['app', 'form']; const arr = ['app', 'form'];
...@@ -89,5 +101,5 @@ module.exports = { ...@@ -89,5 +101,5 @@ module.exports = {
}, },
// IE兼容 // IE兼容
transpileDependencies: ['element-ui/src', 'element-ui/packages'] transpileDependencies: ['element-ui/src', 'element-ui/packages', 'smart-web']
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment