代码整理

This commit is contained in:
ChenXinXin committed 2024-05-20 17:05:50 +08:00
1 parent 0f1c3b51e5
commit 1f99dcd134
6 files changed
+97 -111

No files matched your search

+10 -5
View File
@@ -49,6 +49,7 @@ class TaskService extends Service {
await jianghuKnex('task', this.ctx).jhInsert(actionData); await jianghuKnex('task', this.ctx).jhInsert(actionData);
// 如果首节点是抄送节点,继续往下走
if (taskConfigId.startsWith('noticeTask-')) { if (taskConfigId.startsWith('noticeTask-')) {
var data = { var data = {
...actionData, ...actionData,
@@ -56,7 +57,7 @@ class TaskService extends Service {
taskWorkflow: JSON.parse(taskWorkflow), taskWorkflow: JSON.parse(taskWorkflow),
taskFormInput: JSON.parse(taskFormInput), taskFormInput: JSON.parse(taskFormInput),
} }
// 往下走
await this.submitNode(data, '同意', 1, 'createTask') await this.submitNode(data, '同意', 1, 'createTask')
} }
} }
@@ -79,14 +80,18 @@ class TaskService extends Service {
await this.submitNode(updateItem, '同意', 1, 'createTask') await this.submitNode(updateItem, '同意', 1, 'createTask')
} }
/**
* @ target: 提交节点
* @ params:
* taskData: 审批单信息
* type: 审批操作:同意/拒绝
* times: 首次进入该方法,0:首次;1:迭代进入的
* action: 新建/审核审批, createTask:新建审批单;updateTask:审核审批单
*/
async submitNode(taskData, type, times, action) { async submitNode(taskData, type, times, action) {
const { jianghuKnex } = this.app; const { jianghuKnex } = this.app;
const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext({ taskData: taskData, type: type, times: times, action: action }) const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext({ taskData: taskData, type: type, times: times, action: action })
console.log('updateTaskData------', updateTaskData);
console.log('historyInsertData------', historyInsertData);
console.log('noticeInsertData------', noticeInsertData);
await jianghuKnex.transaction(async trx => { await jianghuKnex.transaction(async trx => {
if (updateTaskData) await trx("task", this.ctx).where({ taskId: taskData.taskId }).jhUpdate(updateTaskData); if (updateTaskData) await trx("task", this.ctx).where({ taskId: taskData.taskId }).jhUpdate(updateTaskData);
if (noticeInsertData.length > 0) await trx("notice_push", this.ctx).jhInsert(noticeInsertData); if (noticeInsertData.length > 0) await trx("notice_push", this.ctx).jhInsert(noticeInsertData);
+48 -56
View File
@@ -807,18 +807,55 @@ Vue.component("process-flow", {
this.isPassValidate = true this.isPassValidate = true
const { lineList, nodeList } = this.workflowConfig; const { lineList, nodeList } = this.workflowConfig;
// 不允许没有审核节点
if(!nodeList.some(node => node.properties.type == 'approvalTask')){
this.isPassValidate = false
this.disPassValidateText += "不允许存在无审批人的审批流程!\n"
}else{
// 检查条件节点是否选了条件 检查审核/抄送节点是否选了类型
for (var index = 0; index < nodeList.length; index++) {
const element = nodeList[index];
if(['conditionTask'].includes(element.properties.type)){
if(!element.properties?.priority){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有设置优先级!\n`
}else{
if(element.properties?.priority != -1 && element.properties?.conditionList?.length <= 0){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有设置条件组!\n`
}
}
}else if(['approvalTask'].includes(element.properties.type)){
if(!element.properties.approvalType || !element.properties.approverType){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}else if(element.properties.approverType != '申请人自选'){
if(!(element.properties.user && element.properties.user?.length > 0)){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}
}
}else if(['noticeTask'].includes(element.properties.type)){
if(!element.properties.noticerType){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}else if(element.properties.noticerType != '申请人自选'){
if(!(element.properties.user && element.properties.user?.length > 0)){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}
}
}
}
}
// 不允许单节点回环 // 不允许单节点回环
if(lineList.filter(l => l.sourceNodeId == l.targetNodeId).length > 0){ if(lineList.filter(l => l.sourceNodeId == l.targetNodeId).length > 0){
this.isPassValidate = false this.isPassValidate = false
this.disPassValidateText += "不允许单节点回环!\n" this.disPassValidateText += "不允许单节点回环!\n"
} }
// 不允许没有审核节点
if(!nodeList.some(node => node.properties.type == 'approvalTask')){
this.isPassValidate = false
this.disPassValidateText += "不允许存在无审批人的审批流程!\n"
}
// 不允许孤立节点 => 除了开始节点和结束节点外,每个节点都有入线和出线 // 不允许孤立节点 => 除了开始节点和结束节点外,每个节点都有入线和出线
var lineBySourceNodeId = _.groupBy(lineList, 'sourceNodeId'), var lineBySourceNodeId = _.groupBy(lineList, 'sourceNodeId'),
lineByTargetNodeId = _.groupBy(lineList, 'targetNodeId'), lineByTargetNodeId = _.groupBy(lineList, 'targetNodeId'),
@@ -868,6 +905,11 @@ Vue.component("process-flow", {
if(_.some(node, i => i.properties.type != "conditionTask")){ if(_.some(node, i => i.properties.type != "conditionTask")){
this.isPassValidate = false this.isPassValidate = false
this.disPassValidateText += "不允许条件节点和审批/通知节点存在同一层级!\n" this.disPassValidateText += "不允许条件节点和审批/通知节点存在同一层级!\n"
}else{
if(!_.some(node, i => i.properties?.priority == -1)){
this.isPassValidate = false
this.disPassValidateText += "不允许存在某层条件节点没有默认条件优先级!\n"
}
} }
}else{ }else{
if(node.length > 1){ if(node.length > 1){
@@ -878,57 +920,7 @@ Vue.component("process-flow", {
} }
} }
// 不允许有条件节点的优先级没有默认优先级节点, 允许存在多个默认节点,读取顺序按放置时间的先后顺序
var conditionNodeLineBySourceNodeId = _.groupBy(lineList.filter(i => i.targetNodeId.startsWith('conditionTask-')), 'sourceNodeId');
for (const key in conditionNodeLineBySourceNodeId) {
if (Object.hasOwnProperty.call(conditionNodeLineBySourceNodeId, key)) {
const element = conditionNodeLineBySourceNodeId[key];
// 拿到同一层的条件节点
var conditionNode = element.map(l => nodeList.find(n => n.id === l.targetNodeId))
if(!_.some(conditionNode, i => i.properties?.priority == -1)){
this.isPassValidate = false
this.disPassValidateText += "不允许存在某层条件节点没有默认条件优先级!\n"
}
}
}
// 检查条件节点是否选了条件 检查审核/抄送节点是否选了类型
for (var index = 0; index < nodeList.length; index++) {
const element = nodeList[index];
if(['conditionTask'].includes(element.properties.type)){
if(!element.properties?.priority){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有设置优先级!\n`
}else{
if(element.properties?.priority != -1 && element.properties?.conditionList.length <= 0){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有设置条件组!\n`
}
}
}else if(['approvalTask'].includes(element.properties.type)){
if(!element.properties.approvalType || !element.properties.approverType){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}else if(element.properties.approverType != '申请人自选'){
if(!(element.properties.user && element.properties.user?.length > 0)){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}
}
}else if(['noticeTask'].includes(element.properties.type)){
if(!element.properties.noticerType){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}else if(element.properties.noticerType != '申请人自选'){
if(!(element.properties.user && element.properties.user?.length > 0)){
this.isPassValidate = false
this.disPassValidateText += `${element.properties.label}节点没有完善信息!\n`
}
}
}
}
if(!this.isPassValidate){ if(!this.isPassValidate){
await window.vtoast.fail('流程设置:' + this.disPassValidateText); await window.vtoast.fail('流程设置:' + this.disPassValidateText);
@@ -169,10 +169,8 @@
}, },
}) })
).data.appData.resultData.rows; ).data.appData.resultData.rows;
this.isLoading = false;
this.userList = rows; this.userList = rows;
console.log('this.userList',this.userList ); this.isLoading = false;
}, },
async buildTreeData() { async buildTreeData() {
let data = [...this.userList]; let data = [...this.userList];
-18
View File
@@ -77,7 +77,6 @@
</v-col> </v-col>
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0"> <v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
<span class="jh-input-label title-label">审批过程时,当审批人账号被禁用</span> <span class="jh-input-label title-label">审批过程时,当审批人账号被禁用</span>
<!-- 自动同意、自动交接给指定人员 -->
<v-radio-group v-model="workflowInfo['abnormalType']" dense> <v-radio-group v-model="workflowInfo['abnormalType']" dense>
<v-radio <v-radio
label="自动同意" label="自动同意"
@@ -124,20 +123,12 @@
</v-col> </v-col>
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0"> <v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
<span class="jh-input-label title-label">审批过程时,一人多节点自动审批配置</span> <span class="jh-input-label title-label">审批过程时,一人多节点自动审批配置</span>
<!-- 仅首个节点需要审批,其余自动同意 -->
<!-- 仅连续审批时自动同意 -->
<!-- 每个节点都需要审批 -->
<v-radio-group v-model="workflowInfo['autoApproval']" dense> <v-radio-group v-model="workflowInfo['autoApproval']" dense>
<v-radio <v-radio
label="仅首个节点需要审批,其余自动同意" label="仅首个节点需要审批,其余自动同意"
value="1" value="1"
dense dense
></v-radio> ></v-radio>
<!-- <v-radio
label="仅连续审批时自动同意"
value="2"
dense
></v-radio> -->
<v-radio <v-radio
label="每个节点都需要审批" label="每个节点都需要审批"
value="2" value="2"
@@ -146,13 +137,6 @@
</v-radio> </v-radio>
</v-col> </v-col>
<!-- <v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">备注</span>
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="workflowInfo['workflowRemark']">
</v-text-field>
</v-col> -->
</v-row> </v-row>
</v-form> </v-form>
</div> </div>
@@ -163,7 +147,6 @@
<script type="module"> <script type="module">
Vue.component("workflow-basic-info", { Vue.component("workflow-basic-info", {
template: '#workflow-basic-info', template: '#workflow-basic-info',
// vuetify: new Vuetify(),
props: { props: {
workflowInfo: { workflowInfo: {
type: Object, type: Object,
@@ -239,7 +222,6 @@ Vue.component("workflow-basic-info", {
} }
.title-label{ .title-label{
/* font-weight: 600 !important; */
font-size: 14px; font-size: 14px;
} }
+31 -22
View File
@@ -54,6 +54,7 @@
</template> </template>
<!-- 表格操作按钮 --> <!-- 表格操作按钮 -->
<template v-slot:item.action="{ item }"> <template v-slot:item.action="{ item }">
<template v-if="!isMobile">
<span role="button" class="primary--text font-weight-medium font-size-2" @click="doUiAction('viewItem', { item })"> <span role="button" class="primary--text font-weight-medium font-size-2" @click="doUiAction('viewItem', { item })">
<v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>预览 <v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>预览
</span> </span>
@@ -61,9 +62,24 @@
<v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>修改 <v-icon size="16" class="primary--text">mdi-note-edit-outline</v-icon>修改
</span> </span>
</template> </template>
<!-- <template v-slot:item.afficheTitle="{ item }"> <!-- 手机端 -->
<a @click="doUiAction('viewItem', { item })">{{item.afficheTitle}}</a> <v-menu offset-y v-if="isMobile">
</template> --> <template v-slot:activator="{ on, attrs }">
<span role="button" class="success--text font-weight-medium font-size-2"
v-bind="attrs" v-on="on">
操作<v-icon size="14" class="success--text">mdi-chevron-down</v-icon>
</span>
</template>
<v-list dense>
<v-list-item @click="doUiAction('viewItem', { item })">
<v-list-item-title>预览</v-list-item-title>
</v-list-item>
<v-list-item v-if="item.afficheStatus==='草稿'" @click="doUiAction('startUpdateItem', { item })">
<v-list-item-title>修改</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</template>
<!-- 没有数据 --> <!-- 没有数据 -->
<template v-slot:loading> <template v-slot:loading>
<div class="jh-no-data">数据加载中</div> <div class="jh-no-data">数据加载中</div>
@@ -132,9 +148,9 @@
<!-- 抽屉操作按钮 --> <!-- 抽屉操作按钮 -->
<v-row class="justify-end mx-0 mt-8 px-6"> <v-row class="justify-end mx-0 mt-8 px-6">
<v-btn color="success" @click="doUiAction('createItem', {afficheStatus: '已发送'})" small>发送</v-btn> <v-btn color="success" @click="doUiAction('createItem', {afficheStatus: '已发送'})" small :loading="isCreateLoading">发送</v-btn>
<v-btn color="success" class="ml-2" @click="doUiAction('createItem', {afficheStatus: '草稿'})" small>存为草稿</v-btn> <v-btn color="success" class="ml-2" @click="doUiAction('createItem', {afficheStatus: '草稿'})" small :loading="isCreateLoading">存为草稿</v-btn>
<v-btn class="elevation-0 ml-2" @click="isCreateDrawerShown = false" small>取消</v-btn> <v-btn class="elevation-0 ml-2" @click="isCreateDrawerShown = false" small :loading="isCreateLoading">取消</v-btn>
</v-row> </v-row>
</v-form> </v-form>
<select-org-user-dialog <select-org-user-dialog
@@ -256,20 +272,8 @@
template: "#app-template", template: "#app-template",
vuetify: new Vuetify(), vuetify: new Vuetify(),
data: () => ({ data: () => ({
// 面包屑
breadcrumbs: [
{
text: "首页",
disabled: true,
},
{
text: "通知管理",
disabled: true,
},
],
isHelpPageDrawerShown: false, isHelpPageDrawerShown: false,
isHelpPageDrawerLoaded: false, isHelpPageDrawerLoaded: false,
isMobile: window.innerWidth < 500,
// 表格相关数据 // 表格相关数据
isTableZebraLineShown: true, isTableZebraLineShown: true,
validationRules: { validationRules: {
@@ -282,7 +286,6 @@
{ text: "已发送", value: "已发送" }, { text: "已发送", value: "已发送" },
], ],
}, },
currentSceneId: null,
serverSearchInput: { serverSearchInput: {
}, },
@@ -300,6 +303,8 @@
isCreateDrawerShown: false, isCreateDrawerShown: false,
createItem: {}, createItem: {},
createActionData: {}, createActionData: {},
isCreateLoading: false,
deleteItem: {}, deleteItem: {},
deleteItemId: null, deleteItemId: null,
@@ -309,9 +314,6 @@
userList: [], userList: [],
isViewDrawerShown: false, isViewDrawerShown: false,
isMoreMenuShown: false,
isDialogShown: false, isDialogShown: false,
}), }),
watch: { watch: {
@@ -321,6 +323,11 @@
} }
}, },
}, },
computed: {
isMobile() {
return window.innerWidth < 600;
},
},
async created() { }, async created() { },
mounted() { mounted() {
this.doUiAction("initPageData"); this.doUiAction("initPageData");
@@ -447,6 +454,7 @@
}, },
async doCreateItem() { async doCreateItem() {
this.isCreateLoading = true
await window.vtoast.loading("新增数据"); await window.vtoast.loading("新增数据");
const result = await window.jianghuAxios({ const result = await window.jianghuAxios({
data: { data: {
@@ -464,6 +472,7 @@
}, },
}); });
await window.vtoast.success("新增数据成功"); await window.vtoast.success("新增数据成功");
this.isCreateLoading = false
}, },
async closeCreateDrawer() { async closeCreateDrawer() {
this.isCreateDrawerShown = false; this.isCreateDrawerShown = false;
+7 -7
View File
@@ -72,7 +72,7 @@
</div> </div>
<div class="jianghu-doc-contentDoc-main-doc"> <div class="jianghu-doc-contentDoc-main-doc">
<div class="markdown-body editormd-preview-container jianghu-markdown" id="doc-content"> <div class="markdown-body editormd-preview-container jianghu-markdown" id="doc-content">
<h1 id="links-0">{{article.taskTitle}}</h1> <h1 id="links-0">{{article.afficheTitle}}</h1>
<!-- 封面 --> <!-- 封面 -->
<template v-if="article.articleCoverImage"> <template v-if="article.articleCoverImage">
<div class="items-center-box" style="margin-bottom: 20px"> <div class="items-center-box" style="margin-bottom: 20px">
@@ -90,7 +90,7 @@
<video :src="resourceUrl(article.articleVideoUrl)" style="width: 100%; height: auto" controls <video :src="resourceUrl(article.articleVideoUrl)" style="width: 100%; height: auto" controls
preload="none"></video> preload="none"></video>
</template> </template>
<md2html :article-content="article.taskContent"></md2html> <md2html :article-content="article.afficheContent"></md2html>
</div> </div>
</div> </div>
@@ -181,9 +181,9 @@
}, },
setLocationParams() { setLocationParams() {
const urlParams = new URLSearchParams(location.search); const urlParams = new URLSearchParams(location.search);
const taskId = urlParams.get('taskId'); const afficheId = urlParams.get('afficheId');
if (taskId) { if (afficheId) {
this.taskId = taskId; this.afficheId = afficheId;
} else { } else {
setTimeout(() => { setTimeout(() => {
window.vtoast.fail('页面路径缺少参数'); window.vtoast.fail('页面路径缺少参数');
@@ -198,7 +198,7 @@
pageId: 'afficheViewer', pageId: 'afficheViewer',
actionId: 'selectItemList', actionId: 'selectItemList',
where: { where: {
taskId: this.taskId afficheId: this.afficheId
}, },
} }
} }
@@ -206,7 +206,7 @@
this.isLoading = false this.isLoading = false
const article = result.data.appData.resultData.rows[0] || {} const article = result.data.appData.resultData.rows[0] || {}
// article.taskContent = article.taskContent.replaceAll('__appId__', '<$ ctx.app.config.appId $>') // article.afficheContent = article.afficheContent.replaceAll('__appId__', '<$ ctx.app.config.appId $>')
this.article = article; this.article = article;
}, },
resourceUrl(path) { resourceUrl(path) {