Skip to content

Commit

Permalink
update approve activety
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliang-wt committed Apr 28, 2024
1 parent c927c65 commit d52d376
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<template v-else-if="item.type === 'combobox'">
<el-select v-model="listvalue[scope.$index][item.key]"
:disabled="item.isDisabled || props.config.isDisabled">
<el-option v-for="(op, opkey, opindex) in state.comboData[item.key]" :key="opindex" :value="opkey"
<el-option v-for="(op, opkey, opindex) in state.comboData[item.key]" :key="opindex" :value="test(state.comboData[item.key],opkey)"
:label="op"></el-option>
</el-select>
</template>
Expand Down Expand Up @@ -225,6 +225,18 @@
const setBorder = computed(() => {
return Object.hasOwn(props.config, "isBorder") ? props.config.isBorder : false;
});
const test = (a,b)=>{
if (b == 'true') {
return true;
}
else if (b == 'false') {
return false;
}
else {
return b;
}
}
// 获取父组件 配置项(必传)
const getConfig = computed(() => {
return props.config;
Expand Down
34 changes: 17 additions & 17 deletions src/WalkingTec.Mvvm.Core/WorkFlow/ApproveActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace WalkingTec.Mvvm.Core.WorkFlow
[Trigger(
Category = "工作流",
DisplayName = "审批",
Description = "审批流程",Outcomes = new[] {"同意","拒绝"})]
Description = "审批流程", Outcomes = new[] { "同意", "拒绝" })]
public class WtmApproveActivity : Elsa.Services.Activity, IActivityPropertyOptionsProvider
{
[ActivityInput(
UIHint = ActivityInputUIHints.MultiText,
DefaultSyntax = "Json",
SupportedSyntaxes = new[] { "Json", "Liquid" },
SupportedSyntaxes = new[] { "Json", "Liquid", "JavaScript" },
IsDesignerCritical = true,
Label = "审批人ITCode")]
public List<string> ApproveUsers { get; set; }
Expand All @@ -35,7 +35,7 @@ public class WtmApproveActivity : Elsa.Services.Activity, IActivityPropertyOptio
DefaultSyntax = "Json",
SupportedSyntaxes = new[] { "Json", "Liquid" },
IsDesignerCritical = true,
OptionsProvider = typeof(WtmApproveActivity),
OptionsProvider = typeof(WtmApproveActivity),
Label = "角色审批")]
public ICollection<string> ApproveRoles { get; set; }

Expand Down Expand Up @@ -64,7 +64,7 @@ public class WtmApproveActivity : Elsa.Services.Activity, IActivityPropertyOptio
UIHint = ActivityInputUIHints.MultiText,
DefaultSyntax = "Json",
SupportedSyntaxes = new[] { "Json", "Liquid" },
IsDesignerCritical = true,
IsDesignerCritical = true,
OptionsProvider = typeof(WtmApproveActivity),
Label = "特殊审批")]
public ICollection<string> ApproveSpecials { get; set; }
Expand Down Expand Up @@ -149,7 +149,7 @@ protected override IActivityExecutionResult OnExecute(ActivityExecutionContext c
List<ComboSelectListItem> roles = new List<ComboSelectListItem>();
List<ComboSelectListItem> groups = new List<ComboSelectListItem>();
List<ComboSelectListItem> managers = new List<ComboSelectListItem>();
if(ApproveUsers == null)
if (ApproveUsers == null)
{
ApproveUsers = new List<string>();
}
Expand All @@ -160,14 +160,14 @@ protected override IActivityExecutionResult OnExecute(ActivityExecutionContext c
foreach (var item in ApproveSpecials)
{
//发起者自身
if(item == "1")
if (item == "1")
{
if (string.IsNullOrEmpty(submitter)==false)
if (string.IsNullOrEmpty(submitter) == false)
{
ApproveUsers.Add(submitter);
}
}
else if(item == "2")
else if (item == "2")
{
query = $"itcode={submitter}";

Expand Down Expand Up @@ -237,15 +237,15 @@ protected override IActivityExecutionResult OnExecute(ActivityExecutionContext c
}
query += "1=1";
var names = _wtm.CallAPI<List<ComboSelectListItem>>("", $"{_wtm.HostAddress}/_workflowapi/GetWorkflowRoles?{query}").Result;
roles = names.Data??new List<ComboSelectListItem>();
roles = names.Data ?? new List<ComboSelectListItem>();
ApproveUsersFullText.AddRange(roles.Select(x => $"{x.Text}").ToList());
foreach (var item in ApproveRoles)
{
_wtm.DC.Set<FrameworkWorkflow>().Add(new FrameworkWorkflow
{
ActivityId = context.ActivityId,
WorkflowId = context.WorkflowInstance.Id,
UserCode = "r:"+item,
UserCode = "r:" + item,
WorkflowName = context.WorkflowExecutionContext.WorkflowBlueprint.Name,
ModelID = context.ContextId,
ModelType = context.WorkflowExecutionContext.WorkflowContext?.GetType()?.FullName,
Expand Down Expand Up @@ -299,7 +299,7 @@ protected override IActivityExecutionResult OnExecute(ActivityExecutionContext c
SubmitBy = context.WorkflowInstance.Variables.Get("Submitter")?.ToString(),
TagName = this.Tag,
Approvers = users.Select(x => new LoginUserInfo { ITCode = x.Value.ToString(), Name = x.Text }).ToList(),
ApproveRoles = roles.Select(x=> new Support.Json.SimpleRole { ID= Guid.Parse(x.Value.ToString()), RoleName = x.Text }).ToList(),
ApproveRoles = roles.Select(x => new Support.Json.SimpleRole { ID = Guid.Parse(x.Value.ToString()), RoleName = x.Text }).ToList(),
ApproveGroups = groups.Select(x => new Support.Json.SimpleGroup { ID = Guid.Parse(x.Value.ToString()), GroupName = x.Text }).ToList(),
};
notify.OnStart(info);
Expand All @@ -311,16 +311,16 @@ protected override IActivityExecutionResult OnExecute(ActivityExecutionContext c

protected override IActivityExecutionResult OnResume(ActivityExecutionContext context)
{
WtmApproveInput input = context.Input as WtmApproveInput;
WtmApproveInput input = context.Input as WtmApproveInput;
Remark = input?.Remark;
ApprovedBy = input.CurrentUser.Name + "("+ input.CurrentUser.ITCode.ToLower()+")";
if (input?.Action =="同意" || input?.Action =="拒绝")
ApprovedBy = input.CurrentUser.Name + "(" + input.CurrentUser.ITCode.ToLower() + ")";
if (input?.Action == "同意" || input?.Action == "拒绝")
{
var exist = _wtm.DC.Set<FrameworkWorkflow>().IgnoreQueryFilters()
.Where(x=>
.Where(x =>
x.WorkflowId == context.WorkflowInstance.Id
&& x.ActivityId == context.ActivityId
&& x.TenantCode == context.WorkflowInstance.TenantId).ToList();
&& x.ActivityId == context.ActivityId
&& x.TenantCode == context.WorkflowInstance.TenantId).ToList();
_wtm.DC.Set<FrameworkWorkflow>().RemoveRange(exist);
_wtm.DC.SaveChanges();
try
Expand Down
Loading

0 comments on commit d52d376

Please sign in to comment.