Browse Source

Merge pull request #1350 from colinin/wecom-selector-control

feat(wechat): Optimize the option control
pull/1351/head
yx lin 5 months ago
committed by GitHub
parent
commit
1cfa26034f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 125
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Approvals/Models/SelectorControlConfig.cs
  2. 40
      aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Approvals/Models/SelectorControlValue.cs

125
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Approvals/Models/SelectorControlConfig.cs

@ -43,32 +43,58 @@ public class SelectorConfig
[JsonProperty("options")] [JsonProperty("options")]
[JsonPropertyName("options")] [JsonPropertyName("options")]
public List<SelectorOption> Options { get; set; } public List<SelectorOption> Options { get; set; }
/// <summary>
/// 关联控件
/// </summary>
[NotNull]
[JsonProperty("op_relations")]
[JsonPropertyName("op_relations")]
public List<SelectorOptionRelation> OptionRelations { get; set; }
/// <summary>
/// 关联外部选项
/// </summary>
[NotNull]
[JsonProperty("external_option")]
[JsonPropertyName("external_option")]
public SelectorOptionExternal ExternalOption { get; set; }
public SelectorConfig() public SelectorConfig()
{ {
} }
private SelectorConfig(string type, List<SelectorOption> options) private SelectorConfig(
string type,
List<SelectorOption> options,
List<SelectorOptionRelation> optionRelations = null,
SelectorOptionExternal optionExternal = null)
{ {
Type = type; Type = type;
Options = options; Options = options;
OptionRelations = optionRelations;
ExternalOption = optionExternal;
} }
public static SelectorConfig Single(List<SelectorOption> options) public static SelectorConfig Single(
List<SelectorOption> options,
List<SelectorOptionRelation> optionRelations = null,
SelectorOptionExternal optionExternal = null)
{ {
return new SelectorConfig("single", options); return new SelectorConfig("single", options, optionRelations, optionExternal);
} }
public static SelectorConfig Multiple(List<SelectorOption> options) public static SelectorConfig Multiple(
List<SelectorOption> options,
List<SelectorOptionRelation> optionRelations = null,
SelectorOptionExternal optionExternal = null)
{ {
return new SelectorConfig("multi", options); return new SelectorConfig("multi", options, optionRelations, optionExternal);
} }
} }
public class SelectorOption public class SelectorOption
{ {
/// <summary> /// <summary>
/// 时间展示类型:day-日期;hour-日期+时间 ,和对应模板控件属性一致 /// 选项key
/// </summary> /// </summary>
[NotNull] [NotNull]
[JsonProperty("key")] [JsonProperty("key")]
@ -120,3 +146,90 @@ public class SelectorOptionValue
Lang = lang; Lang = lang;
} }
} }
public class SelectorOptionRelation
{
/// <summary>
/// 选项key
/// </summary>
[NotNull]
[JsonProperty("key")]
[JsonPropertyName("key")]
public string Key { get; set; }
/// <summary>
/// 关联控件列表
/// </summary>
[NotNull]
[JsonProperty("relation_list")]
[JsonPropertyName("relation_list")]
public List<SelectorRelation> Relations { get; set; }
public SelectorOptionRelation()
{
}
public SelectorOptionRelation(string key, List<SelectorRelation> relations)
{
Key = key;
Relations = relations;
}
}
public class SelectorRelation
{
/// <summary>
/// 控件Id
/// </summary>
[NotNull]
[JsonProperty("related_control_id")]
[JsonPropertyName("related_control_id")]
public string ControlId { get; set; }
/// <summary>
/// 操作方法
/// </summary>
/// <remarks>
/// 1 - 显示对应控件
/// </remarks>
[NotNull]
[JsonProperty("action")]
[JsonPropertyName("action")]
public int Action { get; set; }
public SelectorRelation()
{
}
public SelectorRelation(string controlId, int action = 1)
{
ControlId = controlId;
Action = action;
}
}
public class SelectorOptionExternal
{
/// <summary>
/// 关联外部选项
/// </summary>
[NotNull]
[JsonProperty("use_external_option")]
[JsonPropertyName("use_external_option")]
public bool UseExternalOption { get; set; }
/// <summary>
/// 外部选项页面地址
/// </summary>
[NotNull]
[JsonProperty("external_url")]
[JsonPropertyName("external_url")]
public string ExternalUrl { get; set; }
public SelectorOptionExternal()
{
}
public SelectorOptionExternal(string externalUrl)
{
ExternalUrl = externalUrl;
UseExternalOption = true;
}
}

40
aspnet-core/framework/wechat/LINGYUN.Abp.WeChat.Work/LINGYUN/Abp/WeChat/Work/Approvals/Models/SelectorControlValue.cs

@ -1,6 +1,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace LINGYUN.Abp.WeChat.Work.Approvals.Models; namespace LINGYUN.Abp.WeChat.Work.Approvals.Models;
@ -83,13 +84,50 @@ public class SelectorValueOption
[JsonProperty("key")] [JsonProperty("key")]
[JsonPropertyName("key")] [JsonPropertyName("key")]
public string Key { get; set; } public string Key { get; set; }
/// <summary>
/// 选项值,若配置了多语言则会包含中英文的选项值
/// </summary>
[NotNull]
[JsonProperty("key")]
[JsonPropertyName("key")]
public List<SelectorValueOptionValue> Value { get; set; }
public SelectorValueOption() public SelectorValueOption()
{ {
} }
public SelectorValueOption(string key) public SelectorValueOption(string key, List<SelectorValueOptionValue> value)
{ {
Key = key; Key = key;
Value = value;
}
}
public class SelectorValueOptionValue
{
/// <summary>
/// 选项值
/// </summary>
[NotNull]
[StringLength(40)]
[JsonProperty("text")]
[JsonPropertyName("text")]
public string Text { get; set; }
/// <summary>
/// 多语言名称
/// </summary>
[NotNull]
[JsonProperty("lang")]
[JsonPropertyName("lang")]
public string Lang { get; set; }
public SelectorValueOptionValue()
{
}
public SelectorValueOptionValue(string text, string lang = "zh_CN")
{
Text = text;
Lang = lang;
} }
} }
Loading…
Cancel
Save