新建任务
This commit is contained in:
1 parent
ae997fe850
commit
b3fa84e828
6 files changed
+425
-586
No files matched your search
@@ -3,25 +3,61 @@
|
||||
<v-navigation-drawer v-model="isDrawerShown" v-if="isDrawerShown" :permanent="isDrawerShown" fixed temporary right width="90%" class="elevation-24">
|
||||
<!-- 抽屉标题 -->
|
||||
<v-row no-gutters>
|
||||
<span class="text-h7 font-weight-bold pa-4">创建审批</span>
|
||||
<span class="text-h7 font-weight-bold pa-4">【{{taskData.workflowName}}】创建审批</span>
|
||||
</v-row>
|
||||
<!-- {{taskData.workflowForm}} -->
|
||||
<!-- 表单 -->
|
||||
<v-row class="px-4 mt-2">
|
||||
<v-col cols="12" v-for="(formItem, index) in taskData.workflowForm" :key="index" class="pa-2 ma-0">
|
||||
<v-row class="ma-4 mt-2">
|
||||
<v-col cols="12" v-for="(formItem, index) in taskData.workflowForm" :key="index" class="px-2 py-1 ma-0">
|
||||
<span class="jh-input-label">{{ index + 1 }}. {{ formItem.statement }}<span v-show="formItem.isRequire" class="red--text ml-1">*</span></span>
|
||||
<form-component-list :form-item="formItem" :disabled='false' @calc-workflow="getWorkflow"></form-component-list>
|
||||
<form-component-list v-if="isDrawerShown" :form-item="formItem" :disabled='false' @calc-workflow="getWorkflow" ></form-component-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider class="jh-divider"></v-divider>
|
||||
<!-- 审批流 -->
|
||||
<v-row class="px-4 mt-2">
|
||||
{{taskData.workflowConfig}}
|
||||
<v-row class="ma-4 mt-2">
|
||||
<v-col cols="12" class="font-weight-bold pa-0 mx-0 my-2">审批流程</v-col>
|
||||
<v-col cols="12" class="pa-0 ma-0">
|
||||
<div v-for="(node, nodeIndex) in curWorkflow">
|
||||
<div class="node-box">
|
||||
<div class="node-box-stepper" color="#cdcfd1">
|
||||
<v-icon v-if="node.properties.type == 'approvalTask'" color="#cdcfd1">mdi-account-circle</v-icon>
|
||||
<v-icon v-if="node.properties.type == 'noticeTask'" color="#cdcfd1">mdi-send-circle</v-icon>
|
||||
<div v-if="nodeIndex < curWorkflow.length - 1" class="vertical-line"></div>
|
||||
</div>
|
||||
<div class="node-box-item">
|
||||
<div class="item-label font-weight-bold ">
|
||||
{{node.properties.label}}
|
||||
<v-chip class="ml-1 px-1 py-2" x-small v-if="node.properties.approvalType" label outlined color="#4caf50">
|
||||
{{node.properties.approvalType}}
|
||||
</v-chip>
|
||||
</div>
|
||||
<div class="d-flex align-center">
|
||||
<template v-for="(userId, userIndex) in node.properties.userIdList">
|
||||
<div class="item-user-box d-flex justify-space-between px-2 mr-2">
|
||||
<span class="omit">{{ constantObj.userList.find(u => u.userId == userId)?.username || userId }}</span>
|
||||
<v-icon class="ml-1" color="#a4a7aa" @click="doUiAction('deleteNodeUser', {nodeIndex ,userIndex})">mdi-close</v-icon>
|
||||
</div>
|
||||
<v-icon v-if="userIndex != node.properties.userIdList.length && node.properties.approvalType == '依次审批'"
|
||||
class="mr-2" color="#afb1b4" small>
|
||||
mdi-arrow-right-thin
|
||||
</v-icon>
|
||||
</template>
|
||||
<template>
|
||||
<div class="abb-user d-flex justify-center align-center" @click="doUiAction('startAddNodeUser', nodeIndex)">
|
||||
<v-icon color="#4caf50">mdi-plus</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end mx-0 my-8 px-4">
|
||||
<!-- 抽屉操作按钮 -->
|
||||
<div class="d-flex justify-end pr-4">
|
||||
<v-btn color="success" @click="doUiAction()" small>保存</v-btn>
|
||||
<v-btn color="success" @click="doUiAction('createTask')" small>提交</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="isDrawerShown = false" small>取消</v-btn>
|
||||
</div>
|
||||
</v-row>
|
||||
@@ -31,6 +67,48 @@
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
<template>
|
||||
<v-row justify="center">
|
||||
<v-dialog
|
||||
v-model="isAddNodeUserDialogShown"
|
||||
persistent
|
||||
width="30%"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title class="text-h5">
|
||||
添加用户
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-autocomplete
|
||||
class="jh-v-input mr-2"
|
||||
dense filled single-line clearable
|
||||
:items="constantObj.userList"
|
||||
item-text="username"
|
||||
item-value="userId"
|
||||
v-model="addNodeUserId">
|
||||
</v-autocomplete>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="green darken-1"
|
||||
text
|
||||
@click="doUiAction('closeAddNodeUserDialog')"
|
||||
>
|
||||
取消
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="green darken-1"
|
||||
text
|
||||
@click="doUiAction('doAddNodeUser')"
|
||||
>
|
||||
保存
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
</template>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
@@ -55,14 +133,22 @@ Vue.component("create-task-drawer", {
|
||||
},
|
||||
isHelpPageDrawerShown: false,
|
||||
|
||||
defaultWorkflow: {},
|
||||
taskData: {}
|
||||
defaultWorkflowConfig: {},
|
||||
defaultWorkflowForm: [],
|
||||
taskData: {},
|
||||
taskSubmitData: null,
|
||||
isAddNodeUserDialogShown: false,
|
||||
addNodeUserIndex: -1,
|
||||
addNodeUserId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
curWorkflow(){
|
||||
return this.taskData.workflowConfig.nodeList.filter(node => !['start', 'end', 'conditionTask'].includes(node.properties.type))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
@@ -88,6 +174,26 @@ Vue.component("create-task-drawer", {
|
||||
await this.getGroupList();
|
||||
await this.getLabelList();
|
||||
break;
|
||||
case 'deleteNodeUser':
|
||||
await this.deleteNodeUser(uiActionData);
|
||||
break;
|
||||
case 'startAddNodeUser':
|
||||
await this.startAddNodeUser(uiActionData);
|
||||
break;
|
||||
case 'doAddNodeUser':
|
||||
await this.addNodeUser();
|
||||
await this.closeAddNodeUserDialog();
|
||||
break;
|
||||
case 'closeAddNodeUserDialog':
|
||||
await this.closeAddNodeUserDialog();
|
||||
break;
|
||||
case 'createTask':
|
||||
await this.prepareCreateValidate();
|
||||
await this.confirmCreateWorkDialog();
|
||||
await this.prepareDoWorkItem();
|
||||
await this.doCreateWork();
|
||||
await this.doUiAction('close')
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||
break;
|
||||
@@ -104,7 +210,13 @@ Vue.component("create-task-drawer", {
|
||||
formObj.workflowConfig = formObj.workflowConfig ? JSON.parse(formObj.workflowConfig) : null;
|
||||
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
|
||||
formObj.workflowForm.forEach(f => f.answer = []) // 兼容多选
|
||||
this.defaultWorkflow = _.cloneDeep(formObj.workflowConfig);
|
||||
this.defaultWorkflowConfig = _.cloneDeep(formObj.workflowConfig);
|
||||
this.defaultWorkflowForm = _.cloneDeep(formObj.workflowForm);
|
||||
this.defaultWorkflowConfig.nodeList.forEach(node =>{
|
||||
if(['approvalTask', 'noticeTask'].includes(node.properties.type)){
|
||||
node.properties.userIdList = this.getUserByType(node)
|
||||
}
|
||||
})
|
||||
this.taskData = _.cloneDeep(formObj);
|
||||
} else {
|
||||
window.vtoast.fail('[createTaskDrawer] 出错,请联系管理员!');
|
||||
@@ -117,52 +229,64 @@ Vue.component("create-task-drawer", {
|
||||
},
|
||||
|
||||
async closeDrawer() {
|
||||
this.defaultWorkflow = null;
|
||||
this.defaultWorkflowConfig = null;
|
||||
this.defaultWorkflowForm = null;
|
||||
this.taskData = null;
|
||||
this.isDrawerShown = false;
|
||||
},
|
||||
|
||||
// -- 获取数据 >>>>>>>>>>> ---------------
|
||||
/**
|
||||
* 获取user数据
|
||||
*/
|
||||
// 获取user数据
|
||||
async getUserList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
pageId: 'createTaskDrawer',
|
||||
actionId: 'selectUserList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
})).data.appData.resultData;
|
||||
this.constantObj.userList = rows.map(e => {
|
||||
return { username: e.username, userId: e.userId, userId: e.userId }
|
||||
})
|
||||
this.constantObj.userList = await this.handleMultiGroupUser(rows)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取group数据
|
||||
*/
|
||||
async handleMultiGroupUser(userList){
|
||||
let groupByUserId = _.groupBy(userList,'userId');
|
||||
_.forEach(groupByUserId,(val, key)=>{
|
||||
// 合并groupAllName,若只有一个值则转为数组
|
||||
const group = _.map(val, (u) => {
|
||||
return {
|
||||
groupId: u.groupId,
|
||||
groupPath: u.groupPath,
|
||||
groupAllName: u.groupAllName,
|
||||
isMainGroup: u.isMainGroup,
|
||||
roleId: u.roleId,
|
||||
roleName: u.roleName
|
||||
}
|
||||
}).filter(g => g.groupId)
|
||||
// 集成到第一个对象中
|
||||
val[0].group = group
|
||||
groupByUserId[key] = _.pick(val[0], ['userId', 'username', 'directSupervisor', 'group'])
|
||||
})
|
||||
return _.values(groupByUserId)
|
||||
},
|
||||
|
||||
// 获取group数据
|
||||
async getGroupList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
pageId: 'createTaskDrawer',
|
||||
actionId: 'selectGroupList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
})).data.appData.resultData;
|
||||
this.constantObj.groupList = rows.map(e => {
|
||||
return {groupName: e.groupName, groupId: e.groupId}
|
||||
});
|
||||
this.constantObj.groupList = rows
|
||||
},
|
||||
/**
|
||||
* 获取label数据
|
||||
*/
|
||||
// 获取label数据
|
||||
async getLabelList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
@@ -177,9 +301,85 @@ Vue.component("create-task-drawer", {
|
||||
this.constantObj.labelList = rows;
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 获取数据 --------------------
|
||||
|
||||
|
||||
// -- 计算审批流 >>>>>>>>>>> ---------------
|
||||
getUserByType(node){
|
||||
var userList = []
|
||||
var type = node.properties.type == 'approvalTask' ?
|
||||
node.properties.approverType : node.properties.noticerType
|
||||
|
||||
switch (type) {
|
||||
case '指定上级':
|
||||
var num = 0
|
||||
node.properties.user.forEach(u =>{
|
||||
num = u == '直属上级' ? 1 : u[1]
|
||||
userList = userList.concat(this.getDirectSupervisor([`<$ ctx.userInfo.userId $>`], num))
|
||||
})
|
||||
break;
|
||||
case '指定部门负责人':
|
||||
var num = 0
|
||||
node.properties.user.forEach(u =>{
|
||||
num = u == '直接部门负责人' ? 1 : u[1]
|
||||
var groupId = this.constantObj.userList.find(u => u.userId == `<$ ctx.userInfo.userId $>`)?.group.find(g => g.isMainGroup == '是')?.groupId
|
||||
userList = userList.concat(this.getHeadId(groupId, num))
|
||||
})
|
||||
break;
|
||||
case '指定标签':
|
||||
node.properties.user.forEach(u =>{
|
||||
let userIdList = this.constantObj.labelList.find(l => l.labelId == u)?.user.split(',')
|
||||
if(userIdList && userIdList.length > 0) userList = userList.concat(userIdList)
|
||||
})
|
||||
break;
|
||||
case '指定人员':
|
||||
userList = node.properties.user
|
||||
break;
|
||||
case '申请人自选':
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return userList
|
||||
},
|
||||
|
||||
// 获取第n级上级
|
||||
getDirectSupervisor(userIdList = [], num){
|
||||
var directSupervisorList = []
|
||||
if(num > 0 && userIdList.length > 0){
|
||||
while(num > 0){
|
||||
num--
|
||||
directSupervisorList = []
|
||||
userIdList.forEach(userId => {
|
||||
let user = this.constantObj.userList.find(u => u.userId == userId)
|
||||
if(user){
|
||||
directSupervisorList = directSupervisorList.concat(user.directSupervisor ? user.directSupervisor.split(',') : [])
|
||||
}
|
||||
})
|
||||
userIdList = directSupervisorList
|
||||
}
|
||||
}
|
||||
|
||||
return directSupervisorList
|
||||
},
|
||||
getHeadId(groupId, num){
|
||||
var headerId = []
|
||||
|
||||
while(num > 0){
|
||||
num--
|
||||
headerId = []
|
||||
if(!groupId) break
|
||||
var group = this.constantObj.groupList.find(g => g.groupId == groupId)
|
||||
if(group){
|
||||
headerId = group.headId?.split(',') || []
|
||||
}
|
||||
groupId = group.groupPath
|
||||
}
|
||||
|
||||
return headerId
|
||||
},
|
||||
async getWorkflow(){
|
||||
this.taskData.workflowConfig = await this.calcWorkflow(this.defaultWorkflow)
|
||||
this.taskData.workflowConfig = await this.calcWorkflow(this.defaultWorkflowConfig)
|
||||
},
|
||||
|
||||
// 计算审批流
|
||||
@@ -210,12 +410,12 @@ Vue.component("create-task-drawer", {
|
||||
|
||||
// 查找传入节点的下一个节点,直到找到结束节点
|
||||
calcNode(workflow, node){
|
||||
var lineList = workflow.lineList
|
||||
var nodeList = workflow.nodeList
|
||||
var lineList = workflow.lineList,
|
||||
nodeList = workflow.nodeList,
|
||||
nextNode = null,
|
||||
prevLine = null,
|
||||
nextNodeList = []
|
||||
|
||||
var nextNode = null
|
||||
var prevLine = null
|
||||
var nextNodeList = []
|
||||
nextNodeList = _.intersectionWith(nodeList, lineList.filter(line => line.sourceNodeId == node.id),
|
||||
(node, line) => line.targetNodeId == node.id);
|
||||
|
||||
@@ -284,15 +484,145 @@ Vue.component("create-task-drawer", {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return isMatch
|
||||
}
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 计算审批流 --------------------
|
||||
|
||||
// -- 操作审批流 >>>>>>>>>>> ---------------
|
||||
deleteNodeUser({nodeIndex ,userIndex}){
|
||||
this.curWorkflow[nodeIndex].properties.userIdList.splice(userIndex, 1)
|
||||
this.$forceUpdate()
|
||||
},
|
||||
|
||||
startAddNodeUser(nodeIndex){
|
||||
this.addNodeUserIndex = nodeIndex
|
||||
this.isAddNodeUserDialogShown = true
|
||||
},
|
||||
|
||||
addNodeUser(){
|
||||
if(!this.addNodeUserId) return window.vtoast.fail('保存用户失败!')
|
||||
this.curWorkflow[this.addNodeUserIndex].properties.userIdList.push(this.addNodeUserId)
|
||||
window.vtoast.success('保存用户成功!')
|
||||
},
|
||||
|
||||
closeAddNodeUserDialog(){
|
||||
this.isAddNodeUserDialogShown = false
|
||||
this.addNodeUserIndex = -1
|
||||
this.addNodeUserId = null
|
||||
},
|
||||
|
||||
// -- <<<<<<<<<<<<< 操作审批流 --------------------
|
||||
// -- 新建任务 >>>>>>>>>>> ---------------
|
||||
async prepareCreateValidate() {
|
||||
// 检查必填是否已填 TODO:注意文件
|
||||
this.taskData.workflowForm.forEach(f => {
|
||||
if(f.isRequire){
|
||||
if(!f.answer || f.answer && f.answer.length == 0){
|
||||
window.vtoast.fail("请完善表单信息")
|
||||
throw new Error("请完善表单信息")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
async confirmCreateWorkDialog() {
|
||||
if (await window.confirmDialog({ title: "新建任务", content: "确定新建任务吗?" }) === false) {
|
||||
throw new Error("[confirmCreateFormDialog] 否");
|
||||
}
|
||||
},
|
||||
prepareDoWorkItem() {
|
||||
const { workflowInfo, workflowForm, workflowConfig, } = this.taskData
|
||||
const { workflowName, taskTemplateGroup } = workflowInfo
|
||||
var curNode = this.curWorkflow[0]
|
||||
var taskLineType = this.taskData.workflowConfig.lineList.filter(line => line.sourceNodeId == curNode.id)[0]?.properties.type
|
||||
var taskViewUserList = this.curWorkflow.reduce((acc, cur) => acc.concat(cur.properties.userIdList), [] )
|
||||
this.taskSubmitData = {
|
||||
taskTitle: `<$ ctx.userInfo.username $>` + '的' + workflowName,
|
||||
taskStatus: 'running',
|
||||
taskFormInput: JSON.stringify(workflowForm),
|
||||
taskDefaultForm: JSON.stringify(this.defaultWorkflowForm),
|
||||
taskWorkflow: JSON.stringify(workflowConfig),
|
||||
taskDefaultWorkflow: JSON.stringify(this.defaultWorkflowConfig),
|
||||
taskConfigId: curNode.id,
|
||||
taskLineType: taskLineType,
|
||||
taskEditUserList: curNode.properties.userIdList.join(','),
|
||||
taskViewUserList: _.uniq(taskViewUserList).join(','),
|
||||
taskCreateAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
taskInitUser: `<$ ctx.userInfo.userId $>`,
|
||||
taskTemplateGroup,
|
||||
}
|
||||
},
|
||||
|
||||
async doCreateWork() {
|
||||
await window.jhMask.show();
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
actionId: 'createTask',
|
||||
actionData: this.taskSubmitData,
|
||||
bizIdGenerate: {
|
||||
tableName: "task",
|
||||
prefix: "SP",
|
||||
type: "idSequence",
|
||||
bizId: "taskId",
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.jhMask.hide();
|
||||
await window.vtoast.success("申请成功");
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 新建任务 --------------------
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.omit{
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.node-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.node-box .node-box-stepper {
|
||||
padding: 12px 10px 0px 4px;
|
||||
}
|
||||
|
||||
.node-box .node-box-stepper .vertical-line {
|
||||
height: 80%;
|
||||
width: 0px;
|
||||
margin: 0 auto;
|
||||
border: #cdcfd1 solid 1px;
|
||||
}
|
||||
|
||||
.node-box .node-box-item .item-label {
|
||||
margin: 14px 0px 6px;
|
||||
}
|
||||
|
||||
.node-box .node-box-item .item-user-box {
|
||||
width: 84px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
background-color: rgb(242 243 243);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.node-box-item .abb-user {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
background-color: #d9f3da;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.node-box-item .abb-user:hover{
|
||||
background-color: #badebb;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user