跳轉到

目前支援欄位

欄位輸入方式使用 formHelper.FieldAdd,其中 '欄位數值' 建議透過 FieldHelper 小工具輸入,可有效避免格式錯誤問題。

formHelper.FieldAdd(欄位代號, 欄位數值);
參數 型態 說明
code string 欄位代號,在欄位設計時給予每個欄位的代號
value object 欄位數值,依各欄位類型有不同的格式

不要使用不支援的欄位

🚨 請勿對不在此列表中的欄位類型輸入任何值,這會導致未知的異常。

基本欄位

單行文字

FieldHelper.Base.Text("單行")

多行文字

FieldHelper.Base.Text("多行\n多行")

數值

FieldHelper.Base.Number(123)

日期

yyyy/MM/dd

日期時間

yyyy/MM/dd HH:mm

明細欄位

FieldHelper.Base.Grid(new List<RowModel>()
{
    new RowModel()
    .Column("C024", FieldHelper.Base.Text("這是第一行文字"))
    .Column("C025", FieldHelper.Base.Number(1))
    new RowModel()
    .Column("C024", FieldHelper.Base.Text("這是第二行文字"))
    .Column("C025", FieldHelper.Base.Number(2))
});

Column 方法參數:

參數 型態 說明
Code string column 欄位代號
Value object column 欄位數值,可以使用 FieldHelper 協助填入數值

複選清單

表單代號起單、檔案起單共用
FieldHelper.Base.MultiSelection(new List<SelectionValueModel>()
{
    // 純複選
    new SelectionValueModel("選項1"),
    // 文字填答
    new SelectionValueModel("選項2", "文字填答內容"),
    // 其他
    new SelectionValueModel("其他填寫內容", true)
})
以表單代號起單為範例
var formHelper = new FormHelper(formCode);

formHelper.FieldAdd("C002", FieldHelper.Base.MultiSelection(new List<SelectionValueModel>()
{
    // 純複選
    new SelectionValueModel("選項1"),
    // 文字填答
    new SelectionValueModel("選項2", "文字填答內容"),
    // 其他
    new SelectionValueModel("其他填寫內容", true)
}));
以表單代號起單為範例-外部資料來源
var items = new List<ExternalSourceItemModel>()
{
    new ExternalSourceItemModel("computer", "電腦"),
    new ExternalSourceItemModel("mouse", "滑鼠"),
    new ExternalSourceItemModel("keyboard", "鍵盤")
};

// 選擇的項目
var selected = new List<ExternalSourceItemModel>()
{
    new ExternalSourceItemModel("computer", "電腦"),
    new ExternalSourceItemModel("keyboard", "鍵盤")
};

formHelper.FieldAdd("C002", FieldHelper.Base.MultiSelection(items, selected));

SelectionValueModel 參數

參數 型態 說明
Value string 選項值 / 其他欄位資訊 (if IsOther = true)
FillText string 擴充文字 (需開啟欄位設定才會有效)
IsOther bool 是否是其他欄位,預設為 false

ExternalSourceItemModel 參數

參數 型態 說明
Key string 須為唯一值不與其他選項重複
Value string 選項的顯示名稱

單選清單

表單代號起單、檔案起單共用
// 純單選
FieldHelper.Base.SingleSelection(new SelectionValueModel("選項3"))
// 文字填答
FieldHelper.Base.SingleSelection(new SelectionValueModel("選項1", "文字填答內容"))
// 其他
FieldHelper.Base.SingleSelection(new SelectionValueModel("其他填寫內容", true))
以表單代號起單為範例
var formHelper = new FormHelper(formCode);

// 純單選
formHelper.FieldAdd("C002", FieldHelper.Base.SingleSelection(new SelectionValueModel("選項3")));
// 文字填答
formHelper.FieldAdd("C002", FieldHelper.Base.SingleSelection(new SelectionValueModel("選項1", "文字填答內容")));
// 其他
formHelper.FieldAdd("C002", FieldHelper.Base.SingleSelection(new SelectionValueModel("其他填寫內容", true)));
以表單代號起單為範例-外部資料來源
// 選項清單
var items = new List<ExternalSourceItemModel>()
{
    new ExternalSourceItemModel("computer", "電腦"),
    new ExternalSourceItemModel("mouse", "滑鼠"),
    new ExternalSourceItemModel("keyboard", "鍵盤")
};

// 選擇的項目
var selected = new ExternalSourceItemModel("computer", "電腦");

formHelper.FieldAdd("C002", FieldHelper.Base.SingleSelection(items, selected));

SelectionValueModel 參數

參數 型態 說明
Value string 選項值 / 其他欄位資訊 (if IsOther = true)
FillText string 擴充文字 (需開啟欄位設定才會有效)
IsOther bool 是否是其他欄位,預設為 false

ExternalSourceItemModel 參數

參數 型態 說明
Key string 須為唯一值不與其他選項重複
Value string 選項的顯示名稱

下拉選單

表單代號起單、檔案起單共用
//直接輸入選項值
FieldHelper.Base.Dropdowns("選項1")
以表單代號起單為範例
var formHelper = new FormHelper(formCode);

 formHelper.FieldAdd("C002", FieldHelper.Base.Dropdowns("選項1"));
以表單代號起單為範例-外部資料來源
// 選項清單
var items = new List<ExternalSourceItemModel>()
{
    new ExternalSourceItemModel("computer", "電腦"),
    new ExternalSourceItemModel("mouse", "滑鼠"),
    new ExternalSourceItemModel("keyboard", "鍵盤")
};

// 選擇的項目
var selected = new ExternalSourceItemModel("mouse", "滑鼠");

formHelper.FieldAdd("C002", FieldHelper.Base.Dropdowns(items, selected));

SelectionValueModel 參數

參數 型態 說明
Value string 選項值 / 其他欄位資訊 (if IsOther = true)
FillText string 擴充文字 (需開啟欄位設定才會有效)
IsOther bool 是否是其他欄位,預設為 false

ExternalSourceItemModel 參數

參數 型態 說明
Key string 須為唯一值不與其他選項重複
Value string 選項的顯示名稱

文字編輯

FieldHelper.Base.HtmlText("<p><span>Hello</span></p>")

上傳檔案

上傳檔案的格式範例請參考夾帶檔案附件

FieldHelper.Base.FileUpload(new List<FileModel>() { fileItem })

文件檢視器

格式範例同參考夾帶檔案附件

FieldHelper.Base.FilesViewer(new List<FileModel>() { fileItem })

組織欄位

選擇部門

FieldHelper.Org.Depts(new List<DeptModel>()
{
    new DeptModel("ede"),
    new DeptModel("ede", true) //包含子部門
})
DeptModel 建構子參數

參數 型態 說明
Code string 部門代碼
ContainsChildren bool 是否包含子部門,預設 false

選擇人員

FieldHelper.Org.Empls(new List<AccountModel>()
{
    new AccountModel("Justin", "RD"),
    new AccountModel("Justin", "RD", "ede-b") //兼職
})
AccountModel 建構子參數

參數 型態 說明
Account string 人員帳號
DeptCode string 部門代碼,此人員所屬的部門
CorpCode string 申請者原公司代碼(如為其他公司兼職才需要填),預設為 null

任意選

AllOrgModel 物件提供七種類型的 method

FieldHelper.Org.Any(new List<AllOrgModel>()
{
    new AllOrgModel().SetDept("RD"),
    new AllOrgModel().SetDeptEmployee("Justin", "RD"),
    new AllOrgModel().SetJobTitle("title2"),
    new AllOrgModel().SetJobFunction("func8"),
    new AllOrgModel().SetDeptJobTitle("RD", "title2"),
    new AllOrgModel().SetDeptJobFunc("RD", "func8"),
    new AllOrgModel().SetDeptSupervisor("RD"),
})

部門

SetJobTitle(部門代碼, 是否包含子部門)
參數 型態 說明
Code string 部門代碼
ContainsChildren bool 是否包含子部門,預設 false

員工

AccountModel 格式參考選擇人員

SetJobTitle(人員帳號, 部門代碼, 申請者原公司代碼)

參數 型態 說明
Account string 人員帳號
DeptCode string 部門代碼,此人員所屬的部門
CorpCode string 申請者原公司代碼(如為其他公司兼職才需要填),預設為 null

職稱

SetJobTitle(職稱代碼)

職務

SetJobFunction(職務代碼)

部門 + 職稱

SetDeptJobTitle(部門代碼, 職稱代碼)

部門 + 職務

SetDeptJobFunc(部門代碼, 職務代碼)

部門主管

SetDeptSupervisor(部門代碼)

附加欄位

外掛欄位

格式為 object,自行根據外掛欄位設計給相對應的數值

FieldHelper.Additional.Plugin(new
  {
      name: "Admin",
      age: 30
  }
)