zhengyiming
7 小时以前 97f29024ce18babeb4b635c5d73f907ac493976e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { fabric } from 'fabric';
 
export const TemplateParamObjectName = 'template-param';
 
export const TemplateParamExtensionKey = [
  'templateParamType',
  'recorder',
  'userType',
  'label',
  'name',
  'required',
  'templateDataParamId',
  'pageNum',
  'bindProperty',
];
 
export class TemplateParam extends fabric.IText {
  type = TemplateParamObjectName;
 
  constructor(text: string, options: TemplateParamOptions) {
    super(text, options);
  }
 
  toObject(propertiesToInclude) {
    //@ts-ignore
    return this.callSuper('toObject', TemplateParamExtensionKey.concat(propertiesToInclude));
  }
}
 
//@ts-ignore
fabric.TemplateParam = TemplateParam;
fabric.Object._fromObject[TemplateParamObjectName] = function (text, objectOptions) {
  console.log('objectOptions: ', objectOptions);
  return new TemplateParam(text, objectOptions);
};
 
export interface TemplateParamOptions extends fabric.ITextOptions {
  templateDataParamId: string;
  pageNum?: number;
 
  templateParamType?: EnumContractTemplateValueType;
  recorder?: EnumContractTemplateValueRecorder;
  userType?: EnumUserType;
  /** 变量名称 */
  label?: string;
  /** 变量代码 */
  name?: string;
  /** 是否必填 */
  required?: boolean;
}
 
export interface TemplateParamExtraData {
  dataParamNameFieldName?: string;
  templateParamFieldName?: string;
  pageNum?: number;
}