import { EventEmitter } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; import { ErrorExModel } from '@uofx/core'; import { Subject } from 'rxjs'; import { BpmFwBaseComponent, BpmFwTaskNodeModel, FieldFillType } from './form-field-base.interface'; export declare abstract class BpmFwWriteComponent extends BpmFwBaseComponent { /** 用於自動取消訂閱 */ protected readonly destroy$: Subject; /** * 表單內所有的欄位 control 集合 * * control 可使用「代碼」取得 * * 請參考 `getTargetFieldValue(...)` 函式 */ parentForm: FormGroup; /** 在表單所有欄位中,自己的 Control */ selfControl: FormControl; /** 驗證後的錯誤代碼 */ errors?: Array; /** 將表單資訊傳遞給欄位 */ taskNodeInfo: BpmFwTaskNodeModel; /** 欄位值 */ value: any; /** 資料目前會跟value一樣 */ displayValue: string; /** value 的資料來源是否為外部給值填入的 */ isFromExternal?: boolean; /** 申請者權限(必填0、非必填1(預設)、不能填寫2、不能填且不能看3) */ applyRequired: FieldFillType; /** [前端UI] 由field layout告訴各個欄位要做什麼邏輯的Subject */ fwSubject$?: Subject; /** [用於明細欄位]目前欄位的"殼"的欄位類型 */ parentFieldTypeId?: string; /** [用於明細欄位]是否為新增 */ isAddItem?: boolean; /** * 表單送出前會呼叫此函式做檢查 * @param {boolean} [checkDefaultValidator=true] 告訴欄位在checkBeforeSubmit是否要檢查預設validator * @return {*} 預設回傳 Promise.resolve(true) * @returns 預設回傳 Promise.resolve(true) */ checkBeforeSubmit(checkDefaultValidator?: boolean): Promise; /** * 拋出欄位值變更 * * 此處送出的值才是真實會存進的 value,selfControl 可以放入作為驗證用的 value */ valueChanges: EventEmitter; /** 欄位工具 */ readonly fieldUtils: IFieldUtil; /** 用來同步表單狀態 */ private syncParentFormStatusToInnerForm; /** * 用來同步表單狀態 * @private * @param {FormControl} innerControl 父表單狀態為 INVALID,且 selfControl 已被修改,則標記子 control 為 dirty * @param {() => void} [afterSync] 如有提供 callback,會在子 control 同步完成後執行 * @memberof BpmFwWriteComponent */ private syncParentFormStatusToInnerCtrl; /** 銷毀訂閱 */ private destroySubscriptions; /** * @deprecated [2026R1 移除] 取得其他欄位的值,請改用 this.pluginUtil.getTargetFieldValue(targetCode) * @param targetCode 目標欄位的代號 * @memberof BpmFwWriteComponent */ protected getTargetFieldValue(targetCode: string): Promise; /** 外掛欄位工具 */ readonly pluginUtils: IPluginUtils; /** * 取得其他欄位的值 * @param targetCode 目標欄位的代號 * @memberof BpmFwWriteComponent */ private getTargetFieldValue2; /** * 遞迴設定控制項為 dirty、touched 並觸發驗證 * * - 可處理 FormGroup、FormArray、FormControl * * @param control 控制項 */ private markControlAsDirty; } /** 欄位工具介面 */ interface IFieldUtil { /** * 欄位裡的 FormGroup 與整張表單 做 statusValues 的同步 * - 父表單狀態為 INVALID,且 selfControl 已被修改,且尚未標記 dirty,則標記子表單為 dirty * - 當子表單狀態變為 INVALID,則會將 selfControl 設定錯誤狀態 * - 記得在使用完後要在 ngOnDestroy() 呼叫 destroySubscriptions() 來取消訂閱 * @param innerForm 要同步狀態的子 FormGroup */ readonly syncParentFormStatusToInnerForm: syncParentFormStatusToInnerFormFn; /** * 欄位裡的 FormControl 與整張表單做 statusValues 的同步 * - 父表單狀態為 INVALID,且 selfControl 已被修改,則標記子 control 為 dirty * - 如有提供 callback,會在子 control 同步完成後執行 * @param innerControl 要同步狀態的子 FormControl */ readonly syncParentFormStatusToInnerCtrl: syncParentFormStatusToInnerCtrlFn; /** * 取消訂閱 */ readonly destroySubscriptions: () => void; } type syncParentFormStatusToInnerFormFn = (innerForm: FormGroup) => void; type syncParentFormStatusToInnerCtrlFn = (innerControl: FormControl, afterSync?: () => void) => void; /** Plugin 工具介面 */ interface IPluginUtils { /** * 取得其他欄位的值 * @param targetCode 目標欄位的代號 */ readonly getTargetFieldValue: getTargetFieldValueFn; } type getTargetFieldValueFn = (targetCode: string) => Promise; export {};