From e054df919fc73b9fd7aa663a9f716f3ba6af1635 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Thu, 7 Dec 2023 15:58:29 +0800 Subject: [PATCH] =?UTF-8?q?BpmButton.vue=E5=B0=86=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E4=BF=A1=E6=81=AF=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AF=B9=E8=AF=9D=E6=A1=86=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/modules/gen/crud/controller.xml | 5 ++++ .../templates/modules/gen/crud/vueForm.xml | 28 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/controller.xml b/modules/core/src/main/resources/templates/modules/gen/crud/controller.xml index d95c69c7..d8d3ddeb 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/controller.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/controller.xml @@ -301,6 +301,11 @@ public class ${ClassName}Controller extends BaseController { @RequestMapping(value = "delete") @ResponseBody public String delete(${ClassName} ${className}) { + <% if(toBoolean(table.optionMap['isBpmForm'])){ %> + if (!${ClassName}.STATUS_DRAFT.equals(${className}.getStatus())){ + return renderResult(Global.FALSE, text("只能删除草稿状态的数据!")); + } + <% } %> ${className}Service.delete(${className}); return renderResult(Global.TRUE, text("删除${functionNameSimple}成功!")); } diff --git a/modules/core/src/main/resources/templates/modules/gen/crud/vueForm.xml b/modules/core/src/main/resources/templates/modules/gen/crud/vueForm.xml index 347170f3..a6a3d829 100644 --- a/modules/core/src/main/resources/templates/modules/gen/crud/vueForm.xml +++ b/modules/core/src/main/resources/templates/modules/gen/crud/vueForm.xml @@ -50,8 +50,10 @@ bpmEntityKey="id" formKey="${table.optionMap['bpmFormKey']}" completeText="提交" + :completeModal="true" :loading="loadingRef" :auth="'${permissionPrefix}:edit'" + @validate="handleValidate" @complete="handleSubmit" @success="handleSuccess" @close="closeDrawer" @@ -215,7 +217,7 @@ for (c in table.columnList){ }, <% }else{ %> component: 'Input', - <% } + <% } var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = []; if(isNotEmpty(fieldValid)){ var t = type.name(fieldValid); @@ -278,7 +280,7 @@ for (c in table.columnList){ } } else { %> rules: [<% - if(c.isRequired == '1'){ + if(c.isRequired == '1'){ %>{ required: true }, <% } for (var rule in rules){ @@ -340,7 +342,7 @@ for (c in table.columnList){ }, <% } - if(toBoolean(table.optionMap['isBpmForm'])){ + if(false && toBoolean(table.optionMap['isBpmForm'])){ %> { label: t('审批意见'), @@ -612,20 +614,36 @@ for (c in table.columnList){ <% if(updateSchemas.~size > 0){ %> updateSchema([ <% for(updateSchema in updateSchemas){ - print(updateSchema + '\n'); + print(updateSchema + '\n'); } %> ]); <% } %> setDrawerProps({ loading: false }); }); + <% if(toBoolean(table.optionMap['isBpmForm'])){ %> - async function handleSubmit() { + async function handleValidate(_event: any, formData: any) { try { const data = await validate(); + formData(true, data); // 将表单数据传递给 BpmButton + } catch (error: any) { + if (error && error.errorFields) { + showMessage(t('common.validateError')); + } + console.log('error', error); + } + } + <% } %> + + async function handleSubmit(<% if(toBoolean(table.optionMap['isBpmForm'])){ %>event: any<% } %>) { + try { <% if(toBoolean(table.optionMap['isBpmForm'])){ %> + const data = event.formData; // 接受 BpmButton 传递过来的表单数据 data.bpm = Object.assign(data.bpm || {}, record.value.bpm); // 流程信息 data.status = record.value.status; // 提交状态 loadingRef.value = true; + <% } else { %> + const data = await validate(); <% } %> setDrawerProps({ confirmLoading: true }); const params: any = {