import { FieldBase, FieldConfig } from "./interface"; import { ProgramConfig } from "../index"; const SupportInputTypes: Set = new Set(); SupportInputTypes.add('date-YY'); SupportInputTypes.add('daterange-YY'); SupportInputTypes.add('date-M1'); SupportInputTypes.add('daterange-M1'); SupportInputTypes.add('date'); SupportInputTypes.add('daterange'); SupportInputTypes.add('datetime-HH'); SupportInputTypes.add('datetimerange-HH'); SupportInputTypes.add('datetime-mm'); SupportInputTypes.add('datetimerange-mm'); SupportInputTypes.add('datetime'); SupportInputTypes.add('datetimerange'); SupportInputTypes.add('timestamp'); SupportInputTypes.add('time-HH'); SupportInputTypes.add('timerange-HH'); SupportInputTypes.add('time-mm'); SupportInputTypes.add('timerange-mm'); SupportInputTypes.add('time'); SupportInputTypes.add('timerange'); SupportInputTypes.add('timerange-HH-unorder'); SupportInputTypes.add('timerange-mm-unorder'); SupportInputTypes.add('timerange-unorder'); SupportInputTypes.add('text'); SupportInputTypes.add('textarea'); SupportInputTypes.add('text-view'); SupportInputTypes.add('QRCode'); SupportInputTypes.add('html'); SupportInputTypes.add('steps'); SupportInputTypes.add('progress'); SupportInputTypes.add('password'); SupportInputTypes.add('preselect'); SupportInputTypes.add('select'); SupportInputTypes.add('multiselect'); SupportInputTypes.add('checkbox'); SupportInputTypes.add('radio'); SupportInputTypes.add('yes-no-select'); SupportInputTypes.add('yes-no-radio'); SupportInputTypes.add('yes-no-switch'); SupportInputTypes.add('caselect'); SupportInputTypes.add('relation'); SupportInputTypes.add('file'); SupportInputTypes.add('direct-file'); SupportInputTypes.add('picture'); SupportInputTypes.add('chemstruc'); SupportInputTypes.add('sql-code-editor'); SupportInputTypes.add('video');//没支持上 SupportInputTypes.add('takeVideo');//没支持上 SupportInputTypes.add('signature');//签名组件 SupportInputTypes.add('non-download-file'); SupportInputTypes.add('decimal'); SupportInputTypes.add('float'); SupportInputTypes.add('double'); SupportInputTypes.add('int'); SupportInputTypes.add('relselect'); SupportInputTypes.add('relselectvalue');//弃用 SupportInputTypes.add('entity-select-value'); SupportInputTypes.add('refselect'); SupportInputTypes.add('field-history'); SupportInputTypes.add("relselect-extdis"); SupportInputTypes.add('range'); SupportInputTypes.add('intrange'); SupportInputTypes.add('decimalrange'); SupportInputTypes.add('texttags'); // SupportInputTypes.add('relation_existion'); SupportInputTypes.add('entity-select'); SupportInputTypes.add('table-entity-select'); SupportInputTypes.add('modal-entity-select'); SupportInputTypes.add('color'); SupportInputTypes.add('url'); SupportInputTypes.add('pc-icon-selector'); SupportInputTypes.add('app-icon-selector'); SupportInputTypes.add('hidden'); SupportInputTypes.add('lab-tree-select'); SupportInputTypes.add('tree-entity-select-value'); SupportInputTypes.add('tree-entity-select'); SupportInputTypes.add('ltree-entity-select-value'); SupportInputTypes.add('ltree-entity-select'); SupportInputTypes.add('field-history'); SupportInputTypes.add('relfile'); SupportInputTypes.add('QRCode'); SupportInputTypes.add('single-checkbox'); SupportInputTypes.add("relimage"); function ControlTypeSupportor() { } ControlTypeSupportor.isSupport = function (type: string): boolean { if (type) { if (ProgramConfig.getCustomViewControl(type)) { return true; } else { return SupportInputTypes.has(type); } } else { return false; } }; ControlTypeSupportor.getSupportControlType = function (fieldConfig: FieldBase): string { if (this.isSupport(fieldConfig.extControlType)) { return fieldConfig.extControlType; } else if (this.isSupport(fieldConfig.controlType)) { return fieldConfig.controlType; } else { return 'text'; } }; ControlTypeSupportor.isUploadControl = function (fieldConfig: FieldBase): boolean { let type = this.getSupportControlType(fieldConfig); if (type == "file" || type == "video" || type == "picture" || type == "non-download-file") { return true; } else { return false; } }; ControlTypeSupportor.isMultiSelect = function (fieldConfig: FieldBase): boolean { let type = this.getSupportControlType(fieldConfig); if (type == "multiselect") { return true; } else { return false; } }; ControlTypeSupportor.isMultiUploadControl = function (fieldConfig: FieldBase): boolean { let type = this.getSupportControlType(fieldConfig); if (type == "relfile") { return true; } else { return false; } }; ControlTypeSupportor.getControlType = function (fieldConfig: FieldConfig, fieldValue: any) { let itemType: string; itemType = this.getSupportControlType(fieldConfig); //对关系属性之文件进行特殊处理 if (!!fieldValue && typeof (fieldValue) == 'string' && fieldValue.indexOf('@R@') === -1 && ["relselect-extdis", "relselect"].includes(itemType) && fieldValue.indexOf('download-files/') != -1) { itemType = "file"; } return itemType; } export default ControlTypeSupportor;