|
| 1 | +import Vue, {VueConstructor, VNode} from 'vue' |
| 2 | + |
| 3 | +import {Form} from '@femessage/types/element-ui' |
| 4 | + |
| 5 | +declare module '@femessage/el-form-renderer' { |
| 6 | + class FemessageComponent extends Vue { |
| 7 | + static install(vue: typeof Vue): void |
| 8 | + } |
| 9 | + |
| 10 | + type CombinedVueInstance< |
| 11 | + Instance extends Vue, |
| 12 | + Data, |
| 13 | + Methods, |
| 14 | + Computed, |
| 15 | + Props |
| 16 | + > = Data & Methods & Computed & Props & Instance |
| 17 | + |
| 18 | + type ExtendedVue< |
| 19 | + Instance extends Vue, |
| 20 | + Data, |
| 21 | + Methods, |
| 22 | + Computed, |
| 23 | + Props |
| 24 | + > = VueConstructor< |
| 25 | + CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue |
| 26 | + > |
| 27 | + |
| 28 | + type Combined<Data, Methods, Computed, Props> = Data & |
| 29 | + Methods & |
| 30 | + Computed & |
| 31 | + Props |
| 32 | + |
| 33 | + type ElFormRendererData = { |
| 34 | + value: {[key: string]: any} |
| 35 | + options: {[key: string]: any} |
| 36 | + initValue: null | {[key: string]: any} |
| 37 | + } |
| 38 | + |
| 39 | + type ElFormRendererMethods = { |
| 40 | + resetFields: () => void |
| 41 | + |
| 42 | + getFormValue: () => {[key: string]: any} |
| 43 | + |
| 44 | + updateForm: (newValue: any) => void |
| 45 | + |
| 46 | + setOptions: (id: string, options: any[]) => void |
| 47 | + } |
| 48 | + |
| 49 | + type ElFormRendererComputed = {} |
| 50 | + |
| 51 | + export interface FormContentItem { |
| 52 | + id: string |
| 53 | + label?: string | VNode |
| 54 | + [key: string]: any |
| 55 | + } |
| 56 | + |
| 57 | + export type FormContent = Array<FormContentItem> |
| 58 | + |
| 59 | + type ElFormRendererProps = { |
| 60 | + content: FormContent |
| 61 | + disabled: boolean |
| 62 | + readonly: boolean |
| 63 | + form: {[key: string]: any} |
| 64 | + } |
| 65 | + |
| 66 | + type ElFormRenderer = Combined< |
| 67 | + ElFormRendererData, |
| 68 | + ElFormRendererMethods, |
| 69 | + ElFormRendererComputed, |
| 70 | + ElFormRendererProps |
| 71 | + > |
| 72 | + |
| 73 | + export interface ElFormRendererType |
| 74 | + extends FemessageComponent, |
| 75 | + ElFormRenderer, |
| 76 | + Form {} |
| 77 | + |
| 78 | + const ElFormRendererConstruction: ExtendedVue< |
| 79 | + Vue, |
| 80 | + ElFormRendererData, |
| 81 | + ElFormRendererMethods, |
| 82 | + ElFormRendererComputed, |
| 83 | + ElFormRendererProps |
| 84 | + > |
| 85 | + |
| 86 | + export default ElFormRendererConstruction |
| 87 | +} |
0 commit comments