提交 c7295869 编写于 作者: F fancy

流程启动功能完成

上级 af5d383b
......@@ -12,7 +12,11 @@ Page({
navTitle: '创建工作',
currentAppId: '',
applicationList: [],
processList: []
processList: [],
currentProcess: null,
showChooseIdentityDialog: false,
identityList: [],
selectedIdentity: ''
},
/**
......@@ -95,9 +99,85 @@ Page({
})
},
/**
* 选择身份
*/
showChooseIdentityDialog: function(identityList){
this.setData({
showChooseIdentityDialog: true,
identityList: identityList
})
},
/**
* 启动流程实例
* @param {*} identityDn
*/
startProcess: function(identityDn) {
let body = {"identity": identityDn}
api.createWork(this.data.currentProcess.id, body).then(result => {
util.hideLoading()
let work = result[0].taskList[0].work
let activityName = result[0].taskList[0].activityName
if (work) {
wx.navigateBack({
delta: 1,
complete: function() {
wx.navigateTo({
url: '../progress/work-web?work=' +work + '&title=' + encodeURIComponent(activityName)
});
}
})
}
}).catch(err => {
util.hideLoading()
api.o2Error(err);
})
},
/**
* 启动草稿
* @param {*} identityDn
*/
startDraft: function(identityDn) {
let body = {"identity": identityDn}
api.createDraft(this.data.currentProcess.id, body).then(result => {
console.log(result)
console.log(result.work)
util.hideLoading()
if (result.work) {
let draft = JSON.stringify(result.work)
wx.navigateBack({
delta: 1,
complete: function() {
wx.navigateTo({
url: '../progress/work-web?draft=' + encodeURIComponent(draft)
});
}
})
}
}).catch(err => {
util.hideLoading()
api.o2Error(err);
})
},
/**
* 启动
* @param {*} identityDn
*/
start: function(identityDn) {
util.showLoading()
if(this.data.currentProcess && this.data.currentProcess.defaultStartMode && this.data.currentProcess.defaultStartMode === 'draft') {
this.startDraft(identityDn)
}else {
this.startProcess(identityDn)
}
},
bindTapApplication: function(e) {
let index = e.currentTarget.dataset.index;
let app = this.data.applicationList[index];
let index = e.currentTarget.dataset.index
let app = this.data.applicationList[index]
this.setData({
processList: app.processList,
currentAppId: app.id
......@@ -105,6 +185,36 @@ Page({
},
bindTapProcess: function(e) {
let index = e.currentTarget.dataset.index
let process = this.data.processList[index]
this.data.currentProcess = process
util.showLoading()
api.listAvailableIdentityWithProcess(process.id).then(list => {
if (list && list.length > 0) {
if (list.length > 1) {
this.showChooseIdentityDialog(list)
}else {
this.start(list[0].distinguishedName)
}
} else {
util.toast('没有获取到当前用户的身份,无法启动流程!')
}
}).catch(err => {
util.hideLoading()
api.o2Error(err);
})
},
tapDialogButton: function(e) {
this.setData({
showChooseIdentityDialog: false
});
if (e.detail.index == 1) {
this.start(this.data.selectedIdentity)
}
},
identityRadioChange: function(e) {
this.data.selectedIdentity = e.detail.value
}
})
\ No newline at end of file
{
"usingComponents": {
"o2-navi": "../../components/o2-navi/o2-navi"
"o2-navi": "../../components/o2-navi/o2-navi",
"mp-dialog": "/miniprogram_npm/weui-miniprogram/dialog/dialog"
}
}
\ No newline at end of file
......@@ -14,4 +14,21 @@
</view>
</view>
</block>
\ No newline at end of file
</block>
<mp-dialog title="请选择启动流程的身份" show="{{showChooseIdentityDialog}}" bindbuttontap="tapDialogButton" buttons="{{[{text: '取消'}, {text: '确认'}]}}">
<view class="page-section">
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<radio-group bindchange="identityRadioChange">
<label class="weui-cell weui-check__label" wx:for="{{identityList}}" wx:key="{{item.id}}">
<view class="weui-cell__hd">
<radio value="{{item.distinguishedName}}"/>
</view>
<view class="weui-cell__bd">{{item.name}}({{item.unitName}})</view>
</label>
</radio-group>
</view>
</view>
</view>
</mp-dialog>
\ No newline at end of file
......@@ -20,16 +20,34 @@ Page({
*/
onLoad: function (options) {
var title = decodeURIComponent(options.title);
if(!options.workCompleted && !options.work) {
if(!options.workCompleted && !options.work && !options.draft) {
util.toast('参数错误!');
wx.navigateBack({
delta: 1,
});
} else if(!options.workCompleted) {
this.openWorkUrl(options.work, title);
} else {
} else if(options.workCompleted) {
this.openWorkCompletedUrl(options.workCompleted, title);
} else if(options.work) {
this.openWorkUrl(options.work, title);
} else if(options.draft) {
this.openDraft(options.draft, title);
}
},
// 打开工作表单 草稿
openDraft: function(draft, title = '') {
var url = api.workDraftUrl(draft);
var who = wx.getStorageSync('who');
var token = ''
if (who && who.token) {
token = who.token;
url = url + '&x-token=' + token;
}
url = url + '#wechat_redirect';
console.log('草稿页面 url', url);
this.setData({
workUrl: url,
navTitle: title
});
},
// 打开工作表单 未完成的工作
openWorkUrl: function(work, title = '') {
......
......@@ -28,14 +28,14 @@
"disablePlugins": [],
"outputPath": ""
},
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"bundle": false
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.12.2",
......
......@@ -7,6 +7,8 @@ let setDistribute = (distribute) => o2Request.setDistribute(distribute);
let cmsWebUrl = (id) => o2Request.getO2WebBaseUrl() + '/x_desktop/cmsdocMobile.html?id=' + id;
// 未完成的工作表单打开地址
let workWebUrl = (work) => o2Request.getO2WebBaseUrl() + '/x_desktop/workmobilewithaction.html?workid=' + work;
// 草稿 工作地址
let workDraftUrl = (draft) => o2Request.getO2WebBaseUrl + '/x_desktop/workmobilewithaction.html?draft=' + draft;
//工作表单打开地址 已结束
let workCompletedWebUrl = (workcompletedid) => o2Request.getO2WebBaseUrl() + '/x_desktop/workmobilewithaction.html?workcompletedid=' + workcompletedid;
//论坛帖子打开地址 subjectId:帖子id page:评论页码
......@@ -36,8 +38,14 @@ let cmsAttachementUrl = (attId) => o2Request.o2oaCmsServiceBaseUrl() + '/jaxrs/f
/////////////////////流程 //////////////////////////////
//流程应用
// 流程应用
let applicationList = () => o2Request.get(o2Request.o2oaProcessServiceBaseUrl() + '/jaxrs/application/list/complex');
// 获取当前用户在指定流程中可启动流程的身份.
let listAvailableIdentityWithProcess = (processId) => o2Request.get(o2Request.o2oaProcessServiceBaseUrl() + '/jaxrs/process/list/available/identity/process/'+processId);
// 启动草稿
let createDraft = (processId, body) => o2Request.post(o2Request.o2oaProcessServiceBaseUrl() + '/jaxrs/draft/process/'+processId, body);
// 启动流程
let createWork = (processId, body) => o2Request.post(o2Request.o2oaProcessServiceBaseUrl() + '/jaxrs/work/process/'+processId, body);
// 待办列表
let taskList = (lastId, pageSize) => o2Request.get(o2Request.o2oaProcessServiceBaseUrl() + '/jaxrs/task/list/'+lastId+'/next/'+pageSize);
......@@ -91,6 +99,7 @@ module.exports = {
setDistribute,
cmsWebUrl,
workWebUrl,
workDraftUrl,
workCompletedWebUrl,
bbsWebUrl,
workAttachmentUrl,
......@@ -107,6 +116,9 @@ module.exports = {
readList,
readCompletedList,
applicationList,
listAvailableIdentityWithProcess,
createDraft,
createWork,
me,
myAvatarUrl,
uploadMyAvatarUrl,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册