From a41ced621b9b89bdeb8b372e260f662b05b689f8 Mon Sep 17 00:00:00 2001 From: cxx Date: Thu, 9 May 2024 11:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AE=A1=E6=89=B9=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/workflow.js | 36 +++++++------------- app/view/component/workflowEditorDrawer.html | 8 ++++- app/view/page/workflowManagement.html | 34 +++++++++++++++++- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/app/service/workflow.js b/app/service/workflow.js index 49c4670..3c8f139 100644 --- a/app/service/workflow.js +++ b/app/service/workflow.js @@ -32,8 +32,8 @@ appDataSchema.createWorkflowTask = Object.freeze({ additionalProperties: true } }, - workflowId: {type: 'string', minLength: 1, maxLength: 100}, - workflowConfigCustom: {type: 'string', minLength: 1, maxLength: 10000}, + workflowId: { type: 'string', minLength: 1, maxLength: 100 }, + workflowConfigCustom: { type: 'string', minLength: 1, maxLength: 10000 }, }, additionalProperties: true }); @@ -56,16 +56,6 @@ class WorkflowService extends Service { columnName: "formId" }); } - async createWorkflowId() { - const { actionData } = this.ctx.request.body.appData; - const { jianghuKnex } = this.app; - actionData.workflowId = await idGenerateUtil.idPlus({ - knex: jianghuKnex, - startValue: 1000, - tableName: 'workflow', - columnName: "workflowId" - }); - } async assignTplData() { const { actionData } = this.ctx.request.body.appData; @@ -76,13 +66,13 @@ class WorkflowService extends Service { const tplList = await jianghuKnex('form').whereIn('formId', tplIds).select(); let formList = []; const formData = {}; - for( const item of tplList) { + for (const item of tplList) { const cache = JSON.parse(item.formStructure); - for(const i of cache) { + for (const i of cache) { i.tplId = item.tplId } formList = [...formList, ...cache]; - for(const it of cache) { + for (const it of cache) { formData[it.id] = ''; } } @@ -92,18 +82,18 @@ class WorkflowService extends Service { } console.log(actionData); } - + /** * 创建流程审批 */ async createWorkflowTask() { const { actionData } = this.ctx.request.body.appData; - validateUtil.validate(appDataSchema.createWorkflowTask , actionData); + validateUtil.validate(appDataSchema.createWorkflowTask, actionData); const { jianghuKnex } = this.app; const { formItemList, workflowConfigCustom, workflowId } = actionData; - let workflow = await jianghuKnex('workflow', this.ctx).where({workflowId}).first(); - if(!workflow) { + let workflow = await jianghuKnex('workflow', this.ctx).where({ workflowId }).first(); + if (!workflow) { throw new BizError(errorInfoEnum.workflow_not_found); } @@ -124,16 +114,16 @@ class WorkflowService extends Service { */ async getTaskHistory() { const { taskId } = this.ctx.request.body.appData.actionData; - validateUtil.validate(appDataSchema.getTaskHistory , taskId); + validateUtil.validate(appDataSchema.getTaskHistory, taskId); const { jianghuKnex } = this.app; - const taskInfo = await jianghuKnex('task', this.ctx).where({taskId}).first(); - const taskHistoryList = await jianghuKnex('task_history').where({taskId: taskInfo.taskId}).orderBy('id', 'asc').select(); + const taskInfo = await jianghuKnex('task', this.ctx).where({ taskId }).first(); + const taskHistoryList = await jianghuKnex('task_history').where({ taskId: taskInfo.taskId }).orderBy('id', 'asc').select(); // const userList = await jianghuKnex('_view01_user').whereIn('userId', taskInfo.taskViewUserList.split(',')).select(); // taskInfo.workflowConfig = JSON.parse(taskInfo.workflowConfig); // return this.ctx.service.task.getTaskHistoryConfigList(taskInfo.workflowConfig, taskHistoryList, userList); const lineTypeList = taskInfo.taskLineTypeList; - return {taskHistoryList, lineTypeList}; + return { taskHistoryList, lineTypeList }; } /** diff --git a/app/view/component/workflowEditorDrawer.html b/app/view/component/workflowEditorDrawer.html index 4fb51a7..8c004c0 100644 --- a/app/view/component/workflowEditorDrawer.html +++ b/app/view/component/workflowEditorDrawer.html @@ -346,7 +346,13 @@ Vue.component("workflow-editor-drawer", { appData: { pageId: 'workflowManagement', actionId: 'insertItem', - actionData: this.formSubmitData + actionData: this.formSubmitData, + bizIdGenerate: { + tableName: "workflow", + prefix: "W", + type: "idSequence", + bizId: "workflowId", + }, } } })).data.appData.resultData; diff --git a/app/view/page/workflowManagement.html b/app/view/page/workflowManagement.html index 09ca6ed..5ed8eff 100644 --- a/app/view/page/workflowManagement.html +++ b/app/view/page/workflowManagement.html @@ -53,9 +53,12 @@ @@ -179,6 +185,11 @@ case 'openWorkflowEditorDrawer': await this.openWorkflowEditorDrawer(uiActionData); break; + case 'deleteWorkflow': + await this.confirmDeleteItemDialog(); + await this.deleteWorkflow(uiActionData); + await this.doUiAction('getTableData') + break; default: console.error("[doUiAction] uiActionId not find", { uiActionId }); break; @@ -233,6 +244,27 @@ openWorkflowEditorDrawer(item) { this.$refs.workflowEditorDrawer.doUiAction('open', item); + }, + + async confirmDeleteItemDialog() { + if (await window.confirmDialog({title: "删除", content: "确定删除吗?"}) === false) { + throw new Error("[confirmDeleteItemDialog] 否"); + } + }, + + async deleteWorkflow({workflowId}){ + await window.vtoast.loading("删除数据"); + await window.jianghuAxios({ + data: { + appData: { + pageId: 'workflowManagement', + actionId: 'deleteItem', + actionData: {}, + where: {workflowId: workflowId} + } + } + }) + await window.vtoast.success("删除数据成功"); } } })