@lambo-design/variant-form 2.2.9-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +41 -0
- package/package.json +64 -0
- package/src/assets/ft-images/t1.png +0 -0
- package/src/assets/ft-images/t2.png +0 -0
- package/src/assets/ft-images/t3.png +0 -0
- package/src/assets/ft-images/t4.png +0 -0
- package/src/assets/ft-images/t5.png +0 -0
- package/src/assets/ft-images/t6.png +0 -0
- package/src/assets/ft-images/t7.png +0 -0
- package/src/assets/ft-images/t8.png +0 -0
- package/src/assets/vform-logo.png +0 -0
- package/src/components/code-editor/index.vue +134 -0
- package/src/components/form-designer/designer.js +962 -0
- package/src/components/form-designer/form-widget/container-widget/container-wrapper.vue +107 -0
- package/src/components/form-designer/form-widget/container-widget/containerMixin.js +93 -0
- package/src/components/form-designer/form-widget/container-widget/grid-col-widget.vue +314 -0
- package/src/components/form-designer/form-widget/container-widget/grid-widget.vue +93 -0
- package/src/components/form-designer/form-widget/container-widget/index.js +24 -0
- package/src/components/form-designer/form-widget/container-widget/tab-widget.vue +123 -0
- package/src/components/form-designer/form-widget/container-widget/table-cell-widget.vue +347 -0
- package/src/components/form-designer/form-widget/container-widget/table-widget.vue +116 -0
- package/src/components/form-designer/form-widget/field-widget/button-widget.vue +87 -0
- package/src/components/form-designer/form-widget/field-widget/cascader-widget.vue +120 -0
- package/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue +105 -0
- package/src/components/form-designer/form-widget/field-widget/color-widget.vue +99 -0
- package/src/components/form-designer/form-widget/field-widget/date-range-widget.vue +104 -0
- package/src/components/form-designer/form-widget/field-widget/date-widget.vue +103 -0
- package/src/components/form-designer/form-widget/field-widget/divider-widget.vue +83 -0
- package/src/components/form-designer/form-widget/field-widget/fieldMixin.js +613 -0
- package/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue +313 -0
- package/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue +331 -0
- package/src/components/form-designer/form-widget/field-widget/html-text-widget.vue +82 -0
- package/src/components/form-designer/form-widget/field-widget/index.js +10 -0
- package/src/components/form-designer/form-widget/field-widget/input-widget.vue +112 -0
- package/src/components/form-designer/form-widget/field-widget/number-widget.vue +103 -0
- package/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue +280 -0
- package/src/components/form-designer/form-widget/field-widget/radio-widget.vue +105 -0
- package/src/components/form-designer/form-widget/field-widget/rate-widget.vue +102 -0
- package/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue +123 -0
- package/src/components/form-designer/form-widget/field-widget/select-widget.vue +123 -0
- package/src/components/form-designer/form-widget/field-widget/slider-widget.vue +100 -0
- package/src/components/form-designer/form-widget/field-widget/slot-widget.vue +102 -0
- package/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue +196 -0
- package/src/components/form-designer/form-widget/field-widget/static-text-widget.vue +83 -0
- package/src/components/form-designer/form-widget/field-widget/switch-widget.vue +101 -0
- package/src/components/form-designer/form-widget/field-widget/textarea-widget.vue +99 -0
- package/src/components/form-designer/form-widget/field-widget/time-range-widget.vue +104 -0
- package/src/components/form-designer/form-widget/field-widget/time-widget.vue +103 -0
- package/src/components/form-designer/form-widget/index.vue +272 -0
- package/src/components/form-designer/index.vue +500 -0
- package/src/components/form-designer/refMixinDesign.js +28 -0
- package/src/components/form-designer/setting-panel/form-setting.vue +354 -0
- package/src/components/form-designer/setting-panel/index.vue +367 -0
- package/src/components/form-designer/setting-panel/option-items-setting.vue +234 -0
- package/src/components/form-designer/setting-panel/property-editor/allowCreate-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/appendButton-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/appendButtonDisabled-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/automaticDropdown-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/border-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/buttonIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/buttonStyle-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/clearable-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/columnWidth-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid/colHeight-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid/gutter-editor.vue +81 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-offset-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-pull-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-push-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-responsive-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-span-editor.vue +48 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showBlankRow-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showRowNumber-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/sub-form-labelAlign-editor.vue +36 -0
- package/src/components/form-designer/setting-panel/property-editor/container-tab/tab-customClass-editor.vue +119 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellHeight-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellWidth-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/wordBreak-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/customClass-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/disabled-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/displayStyle-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/editable-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/endPlaceholder-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/eventMixin.js +12 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onAppendButtonClick-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onBeforeUpload-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onBlur-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onChange-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onCreated-editor.vue +31 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onFileRemove.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onFocus-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onInput-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onMounted-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onRemoteQuery-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowAdd-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowChange-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowDelete-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowInsert-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadError-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadSuccess-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onValidate-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/button-type-editor.vue +32 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/circle-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/icon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/plain-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/round-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/cascader-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/cascader-multiple-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/checkStrictly-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/showAllLevels-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-checkbox/checkbox-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-color/color-defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-format-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-type-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-valueFormat-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-format-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-type-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-valueFormat-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-divider/contentPosition-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-file-upload/file-upload-fileTypes-editor.vue +44 -0
- package/src/components/form-designer/setting-panel/property-editor/field-html-text/htmlContent-editor.vue +29 -0
- package/src/components/form-designer/setting-panel/property-editor/field-number/controlsPosition-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-picture-upload/picture-upload-fileTypes-editor.vue +44 -0
- package/src/components/form-designer/setting-panel/property-editor/field-radio/radio-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/allowHalf-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/highThreshold-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/lowThreshold-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-max-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/showScore-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/showText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-select/select-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/range-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/showStops-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/vertical-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/fontSize-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/preWrap-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/textContent-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/activeColor-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/activeText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveColor-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/switch-defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/switchWidth-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time/time-format-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-format-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/fileMaxSize-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/filterable-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/hidden-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/index.js +10 -0
- package/src/components/form-designer/setting-panel/property-editor/label-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/labelAlign-editor.vue +42 -0
- package/src/components/form-designer/setting-panel/property-editor/labelHidden-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/labelIconClass-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/labelIconPosition-editor.vue +37 -0
- package/src/components/form-designer/setting-panel/property-editor/labelTooltip-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/labelWidth-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/limit-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/max-editor.vue +39 -0
- package/src/components/form-designer/setting-panel/property-editor/maxLength-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/min-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/minLength-editor.vue +41 -0
- package/src/components/form-designer/setting-panel/property-editor/multiple-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/multipleSelect-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/name-editor.vue +89 -0
- package/src/components/form-designer/setting-panel/property-editor/optionItems-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/placeholder-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/precision-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/prefixIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/propertyMixin.js +55 -0
- package/src/components/form-designer/setting-panel/property-editor/readonly-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/remote-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/required-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/requiredHint-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/rows-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/showFileList-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/showPassword-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/showWordLimit-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/size-editor.vue +38 -0
- package/src/components/form-designer/setting-panel/property-editor/startPlaceholder-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/step-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/suffixIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/textAlign-editor.vue +35 -0
- package/src/components/form-designer/setting-panel/property-editor/type-editor.vue +33 -0
- package/src/components/form-designer/setting-panel/property-editor/uploadTip-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/uploadURL-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/validation-editor.vue +48 -0
- package/src/components/form-designer/setting-panel/property-editor/validationHint-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/withCredentials-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor-factory.js +173 -0
- package/src/components/form-designer/setting-panel/propertyRegister.js +215 -0
- package/src/components/form-designer/toolbar-panel/index.vue +886 -0
- package/src/components/form-designer/widget-panel/index.vue +394 -0
- package/src/components/form-designer/widget-panel/templatesConfig.js +58 -0
- package/src/components/form-designer/widget-panel/widgetsConfig.js +934 -0
- package/src/components/form-render/container-item/container-item-wrapper.vue +37 -0
- package/src/components/form-render/container-item/containerItemMixin.js +221 -0
- package/src/components/form-render/container-item/grid-col-item.vue +126 -0
- package/src/components/form-render/container-item/grid-item.vue +59 -0
- package/src/components/form-render/container-item/index.js +24 -0
- package/src/components/form-render/container-item/sub-form-item.vue +417 -0
- package/src/components/form-render/container-item/tab-item.vue +99 -0
- package/src/components/form-render/container-item/table-cell-item.vue +72 -0
- package/src/components/form-render/container-item/table-item.vue +70 -0
- package/src/components/form-render/index.vue +721 -0
- package/src/components/form-render/refMixin.js +30 -0
- package/src/components/svg-icon/index.vue +49 -0
- package/src/components/v-table/index.vue +106 -0
- package/src/extension/extension-helper.js +23 -0
- package/src/extension/extension-loader.js +116 -0
- package/src/extension/samples/alert/alert-widget.vue +72 -0
- package/src/extension/samples/card/card-item.vue +100 -0
- package/src/extension/samples/card/card-widget.vue +132 -0
- package/src/extension/samples/extension-schema.js +36 -0
- package/src/extension/samples/extension-sfc-generator.js +50 -0
- package/src/iconfont/iconfont.css +29 -0
- package/src/iconfont/iconfont.eot +0 -0
- package/src/iconfont/iconfont.js +1 -0
- package/src/iconfont/iconfont.json +37 -0
- package/src/iconfont/iconfont.svg +35 -0
- package/src/iconfont/iconfont.ttf +0 -0
- package/src/iconfont/iconfont.woff +0 -0
- package/src/iconfont/iconfont.woff2 +0 -0
- package/src/icons/index.js +3 -0
- package/src/icons/svg/alert.svg +1 -0
- package/src/icons/svg/button.svg +1 -0
- package/src/icons/svg/card.svg +1 -0
- package/src/icons/svg/cascader-field.svg +1 -0
- package/src/icons/svg/checkbox-field.svg +1 -0
- package/src/icons/svg/color-field.svg +1 -0
- package/src/icons/svg/custom-component.svg +1 -0
- package/src/icons/svg/data-table.svg +1 -0
- package/src/icons/svg/date-field.svg +1 -0
- package/src/icons/svg/date-range-field.svg +1 -0
- package/src/icons/svg/divider.svg +1 -0
- package/src/icons/svg/document.svg +1 -0
- package/src/icons/svg/drag.svg +1 -0
- package/src/icons/svg/file-upload-field.svg +1 -0
- package/src/icons/svg/github.svg +1 -0
- package/src/icons/svg/grid.svg +1 -0
- package/src/icons/svg/html-text.svg +1 -0
- package/src/icons/svg/node-tree.svg +1 -0
- package/src/icons/svg/number-field.svg +1 -0
- package/src/icons/svg/picture-upload-field.svg +1 -0
- package/src/icons/svg/radio-field.svg +1 -0
- package/src/icons/svg/rate-field.svg +1 -0
- package/src/icons/svg/redo.svg +1 -0
- package/src/icons/svg/rich-editor-field.svg +1 -0
- package/src/icons/svg/section.svg +1 -0
- package/src/icons/svg/select-field.svg +1 -0
- package/src/icons/svg/slider-field.svg +1 -0
- package/src/icons/svg/slot-component.svg +1 -0
- package/src/icons/svg/slot-field.svg +1 -0
- package/src/icons/svg/static-text.svg +1 -0
- package/src/icons/svg/sub-form.svg +1 -0
- package/src/icons/svg/switch-field.svg +1 -0
- package/src/icons/svg/tab.svg +1 -0
- package/src/icons/svg/table.svg +1 -0
- package/src/icons/svg/text-field.svg +1 -0
- package/src/icons/svg/textarea-field.svg +1 -0
- package/src/icons/svg/time-field.svg +1 -0
- package/src/icons/svg/time-range-field.svg +1 -0
- package/src/icons/svg/undo.svg +1 -0
- package/src/icons/svg/vue-sfc.svg +1 -0
- package/src/lang/en-US.js +354 -0
- package/src/lang/en-US_extension.js +26 -0
- package/src/lang/en-US_render.js +38 -0
- package/src/lang/zh-CN.js +354 -0
- package/src/lang/zh-CN_extension.js +26 -0
- package/src/lang/zh-CN_render.js +38 -0
- package/src/styles/global.scss +108 -0
- package/src/styles/index.scss +15 -0
- package/src/utils/beautifierLoader.js +77 -0
- package/src/utils/code-generator.js +91 -0
- package/src/utils/config.js +9 -0
- package/src/utils/debug-console.js +7 -0
- package/src/utils/directive.js +74 -0
- package/src/utils/emitter.js +34 -0
- package/src/utils/format.js +214 -0
- package/src/utils/i18n.js +95 -0
- package/src/utils/sfc-generator.js +583 -0
- package/src/utils/smart-vue-i18n/index.js +56 -0
- package/src/utils/smart-vue-i18n/utils.js +47 -0
- package/src/utils/util.js +376 -0
- package/src/utils/validators.js +127 -0
- package/src/utils/vue2js-generator.js +144 -0
- package/src/utils/vue3js-generator.js +70 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import {deepClone} from "@/utils/util"
|
|
2
|
+
import FormValidators from '@/utils/validators'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
inject: ['refList', 'formConfig', 'getGlobalDsv', 'globalOptionData', 'globalModel', 'getOptionData'],
|
|
6
|
+
|
|
7
|
+
computed: {
|
|
8
|
+
subFormName() {
|
|
9
|
+
return !!this.parentWidget ? this.parentWidget.options.name : ''
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
subFormItemFlag() {
|
|
13
|
+
return !!this.parentWidget ? this.parentWidget.type === 'sub-form' : false
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
formModel: {
|
|
17
|
+
cache: false,
|
|
18
|
+
get() {
|
|
19
|
+
return this.globalModel.formModel
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
methods: {
|
|
26
|
+
|
|
27
|
+
//--------------------- 组件内部方法 begin ------------------//
|
|
28
|
+
getPropName() {
|
|
29
|
+
if (this.subFormItemFlag && !this.designState) {
|
|
30
|
+
return this.subFormName + "." + this.subFormRowIndex + "." + this.field.options.name + ""
|
|
31
|
+
} else {
|
|
32
|
+
return this.field.options.name
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
initFieldModel() {
|
|
37
|
+
if (!this.field.formItemFlag) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!!this.subFormItemFlag && !this.designState) { //SubForm子表单组件需要特殊处理!!
|
|
42
|
+
let subFormData = this.formModel[this.subFormName]
|
|
43
|
+
if (((subFormData === undefined) || (subFormData[this.subFormRowIndex] === undefined) ||
|
|
44
|
+
(subFormData[this.subFormRowIndex][this.field.options.name] === undefined)) &&
|
|
45
|
+
(this.field.options.defaultValue !== undefined)) {
|
|
46
|
+
this.fieldModel = this.field.options.defaultValue
|
|
47
|
+
subFormData[this.subFormRowIndex][this.field.options.name] = this.field.options.defaultValue
|
|
48
|
+
} else if (subFormData[this.subFormRowIndex][this.field.options.name] === undefined) {
|
|
49
|
+
this.fieldModel = null
|
|
50
|
+
subFormData[this.subFormRowIndex][this.field.options.name] = null
|
|
51
|
+
} else {
|
|
52
|
+
this.fieldModel = subFormData[this.subFormRowIndex][this.field.options.name]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* 主动触发子表单内field-widget的onChange事件!! */
|
|
56
|
+
setTimeout(() => { //延时触发onChange事件, 便于更新计算字段!!
|
|
57
|
+
this.handleOnChangeForSubForm(this.fieldModel, this.oldFieldValue, subFormData, this.subFormRowId)
|
|
58
|
+
}, 800)
|
|
59
|
+
this.oldFieldValue = deepClone(this.fieldModel)
|
|
60
|
+
|
|
61
|
+
this.initFileList() //处理图片上传、文件上传字段
|
|
62
|
+
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if ((this.formModel[this.field.options.name] === undefined) &&
|
|
67
|
+
(this.field.options.defaultValue !== undefined)) {
|
|
68
|
+
this.fieldModel = this.field.options.defaultValue
|
|
69
|
+
} else if (this.formModel[this.field.options.name] === undefined) { //如果formModel为空对象,则初始化字段值为null!!
|
|
70
|
+
this.formModel[this.field.options.name] = null
|
|
71
|
+
} else {
|
|
72
|
+
this.fieldModel = this.formModel[this.field.options.name]
|
|
73
|
+
}
|
|
74
|
+
this.oldFieldValue = deepClone(this.fieldModel)
|
|
75
|
+
this.initFileList() //处理图片上传、文件上传字段
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
initFileList() { //初始化上传组件的已上传文件列表
|
|
79
|
+
if ( ((this.field.type !== 'picture-upload') && (this.field.type !== 'file-upload')) || (this.designState === true) ) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!!this.fieldModel) {
|
|
84
|
+
if (Array.isArray(this.fieldModel)) {
|
|
85
|
+
this.fileList = deepClone(this.fieldModel)
|
|
86
|
+
} else {
|
|
87
|
+
this.fileList.splice(0, 0, deepClone(this.fieldModel))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
initEventHandler() {
|
|
93
|
+
this.$on('setFormData', (newFormData) => {
|
|
94
|
+
//console.log('formModel of globalModel----------', this.globalModel.formModel)
|
|
95
|
+
if (!this.subFormItemFlag) {
|
|
96
|
+
this.setValue(newFormData[this.field.options.name])
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
this.$on('field-value-changed', (values) => {
|
|
101
|
+
if (!!this.subFormItemFlag) {
|
|
102
|
+
let subFormData = this.formModel[this.subFormName]
|
|
103
|
+
this.handleOnChangeForSubForm(values[0], values[1], subFormData, this.subFormRowId)
|
|
104
|
+
} else {
|
|
105
|
+
this.handleOnChange(values[0], values[1])
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
/* 监听重新加载选项事件 */
|
|
110
|
+
this.$on('reloadOptionItems', (widgetNames) => {
|
|
111
|
+
if ((widgetNames.length === 0) || (widgetNames.indexOf(this.field.options.name) > -1)) {
|
|
112
|
+
this.initOptionItems(true)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
handleOnCreated() {
|
|
118
|
+
if (!!this.field.options.onCreated) {
|
|
119
|
+
let customFunc = new Function(this.field.options.onCreated)
|
|
120
|
+
customFunc.call(this)
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
handleOnMounted() {
|
|
125
|
+
if (!!this.field.options.onMounted) {
|
|
126
|
+
let mountFunc = new Function(this.field.options.onMounted)
|
|
127
|
+
mountFunc.call(this)
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
registerToRefList(oldRefName) {
|
|
132
|
+
if ((this.refList !== null) && !!this.field.options.name) {
|
|
133
|
+
if (this.subFormItemFlag && !this.designState) { //处理子表单元素(且非设计状态)
|
|
134
|
+
if (!!oldRefName) {
|
|
135
|
+
delete this.refList[oldRefName + '@row' + this.subFormRowId]
|
|
136
|
+
}
|
|
137
|
+
this.refList[this.field.options.name + '@row' + this.subFormRowId] = this
|
|
138
|
+
} else {
|
|
139
|
+
if (!!oldRefName) {
|
|
140
|
+
delete this.refList[oldRefName]
|
|
141
|
+
}
|
|
142
|
+
this.refList[this.field.options.name] = this
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
unregisterFromRefList() { //销毁组件时注销组件ref
|
|
148
|
+
if ((this.refList !== null) && !!this.field.options.name) {
|
|
149
|
+
let oldRefName = this.field.options.name
|
|
150
|
+
if (this.subFormItemFlag && !this.designState) { //处理子表单元素(且非设计状态)
|
|
151
|
+
delete this.refList[oldRefName + '@row' + this.subFormRowId]
|
|
152
|
+
} else {
|
|
153
|
+
delete this.refList[oldRefName]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
initOptionItems(keepSelected) {
|
|
159
|
+
if (this.designState) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if ((this.field.type === 'radio') || (this.field.type === 'checkbox')
|
|
164
|
+
|| (this.field.type === 'select') || (this.field.type === 'cascader')) {
|
|
165
|
+
/* 异步更新option-data之后globalOptionData不能获取到最新值,改用provide的getOptionData()方法 */
|
|
166
|
+
const newOptionItems = this.getOptionData()
|
|
167
|
+
if (!!newOptionItems && newOptionItems.hasOwnProperty(this.field.options.name)) {
|
|
168
|
+
if (!!keepSelected) {
|
|
169
|
+
this.reloadOptions(newOptionItems[this.field.options.name])
|
|
170
|
+
} else {
|
|
171
|
+
this.loadOptions(newOptionItems[this.field.options.name])
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
refreshDefaultValue() {
|
|
178
|
+
if ((this.designState === true) && (this.field.options.defaultValue !== undefined)) {
|
|
179
|
+
this.fieldModel = this.field.options.defaultValue
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
clearFieldRules() {
|
|
184
|
+
if (!this.field.formItemFlag) {
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
this.rules.splice(0, this.rules.length) //清空已有
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
buildFieldRules() {
|
|
192
|
+
if (!this.field.formItemFlag && this.field.options.hidden) {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.rules.splice(0, this.rules.length) //清空已有
|
|
197
|
+
if (!!this.field.options.required) {
|
|
198
|
+
this.rules.push({
|
|
199
|
+
required: true,
|
|
200
|
+
//trigger: ['blur', 'change'],
|
|
201
|
+
trigger: ['blur'], /* 去掉change事件触发校验,change事件触发时formModel数据尚未更新,导致radio/checkbox必填校验出错!! */
|
|
202
|
+
message: this.field.options.requiredHint || this.i18nt('render.hint.fieldRequired'),
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!!this.field.options.validation) {
|
|
207
|
+
let vldName = this.field.options.validation
|
|
208
|
+
if (!!FormValidators[vldName]) {
|
|
209
|
+
this.rules.push({
|
|
210
|
+
validator: FormValidators[vldName],
|
|
211
|
+
trigger: ['blur', 'change'],
|
|
212
|
+
label: this.field.options.label,
|
|
213
|
+
errorMsg: this.field.options.validationHint
|
|
214
|
+
})
|
|
215
|
+
} else {
|
|
216
|
+
this.rules.push({
|
|
217
|
+
validator: FormValidators['regExp'],
|
|
218
|
+
trigger: ['blur', 'change'],
|
|
219
|
+
regExp: vldName,
|
|
220
|
+
label: this.field.options.label,
|
|
221
|
+
errorMsg: this.field.options.validationHint
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!!this.field.options.onValidate) {
|
|
227
|
+
let customFn = (rule, value, callback) => {
|
|
228
|
+
let tmpFunc = new Function('rule', 'value', 'callback', this.field.options.onValidate)
|
|
229
|
+
return tmpFunc.call(this, rule, value, callback)
|
|
230
|
+
}
|
|
231
|
+
this.rules.push({
|
|
232
|
+
validator: customFn,
|
|
233
|
+
trigger: ['blur', 'change'],
|
|
234
|
+
label: this.field.options.label
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 禁用字段值变动触发表单校验
|
|
241
|
+
*/
|
|
242
|
+
disableChangeValidate() {
|
|
243
|
+
if (!this.rules) {
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
this.rules.forEach(rule => {
|
|
248
|
+
if (!!rule.trigger) {
|
|
249
|
+
rule.trigger.splice(0, rule.trigger.length)
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 启用字段值变动触发表单校验
|
|
256
|
+
*/
|
|
257
|
+
enableChangeValidate() {
|
|
258
|
+
if (!this.rules) {
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
this.rules.forEach(rule => {
|
|
263
|
+
if (!!rule.trigger) {
|
|
264
|
+
rule.trigger.push('blur')
|
|
265
|
+
rule.trigger.push('change')
|
|
266
|
+
}
|
|
267
|
+
})
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
disableOptionOfList(optionList, optionValue) {
|
|
271
|
+
if (!!optionList && (optionList.length > 0)) {
|
|
272
|
+
optionList.forEach(opt => {
|
|
273
|
+
if (opt.value === optionValue) {
|
|
274
|
+
opt.disabled = true
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
enableOptionOfList(optionList, optionValue) {
|
|
281
|
+
if (!!optionList && (optionList.length > 0)) {
|
|
282
|
+
optionList.forEach(opt => {
|
|
283
|
+
if (opt.value === optionValue) {
|
|
284
|
+
opt.disabled = false
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
//--------------------- 组件内部方法 end ------------------//
|
|
291
|
+
|
|
292
|
+
//--------------------- 事件处理 begin ------------------//
|
|
293
|
+
|
|
294
|
+
emitFieldDataChange(newValue, oldValue) {
|
|
295
|
+
this.$emit('field-value-changed', [newValue, oldValue])
|
|
296
|
+
|
|
297
|
+
/* 必须用dispatch向指定父组件派发消息!! */
|
|
298
|
+
this.dispatch('VFormRender', 'fieldChange',
|
|
299
|
+
[this.field.options.name, newValue, oldValue, this.subFormName, this.subFormRowIndex])
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
syncUpdateFormModel(value) {
|
|
303
|
+
if (!!this.designState) {
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (!!this.subFormItemFlag) {
|
|
308
|
+
let subFormData = this.formModel[this.subFormName] || [{}]
|
|
309
|
+
let subFormDataRow = subFormData[this.subFormRowIndex]
|
|
310
|
+
subFormDataRow[this.field.options.name] = value
|
|
311
|
+
} else {
|
|
312
|
+
this.formModel[this.field.options.name] = value
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
handleChangeEvent(value) { /* input的清除输入小按钮会同时触发handleChangeEvent、handleInputCustomEvent!! */
|
|
317
|
+
this.syncUpdateFormModel(value)
|
|
318
|
+
this.emitFieldDataChange(value, this.oldFieldValue)
|
|
319
|
+
|
|
320
|
+
//number组件一般不会触发focus事件,故此处需要手工赋值oldFieldValue!!
|
|
321
|
+
this.oldFieldValue = deepClone(value) /* oldFieldValue需要在initFieldModel()方法中赋初值!! */
|
|
322
|
+
|
|
323
|
+
/* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */
|
|
324
|
+
this.dispatch('VFormRender', 'fieldValidation', [this.getPropName()])
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
handleFocusCustomEvent(event) {
|
|
328
|
+
this.oldFieldValue = deepClone(this.fieldModel) //保存修改change之前的值
|
|
329
|
+
|
|
330
|
+
if (!!this.field.options.onFocus) {
|
|
331
|
+
let customFn = new Function('event', this.field.options.onFocus)
|
|
332
|
+
customFn.call(this, event)
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
handleBlurCustomEvent(event) {
|
|
337
|
+
if (!!this.field.options.onBlur) {
|
|
338
|
+
let customFn = new Function('event', this.field.options.onBlur)
|
|
339
|
+
customFn.call(this, event)
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
handleInputCustomEvent(value) {
|
|
344
|
+
this.syncUpdateFormModel(value)
|
|
345
|
+
|
|
346
|
+
/* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */
|
|
347
|
+
this.dispatch('VFormRender', 'fieldValidation', [this.getPropName()])
|
|
348
|
+
|
|
349
|
+
if (!!this.field.options.onInput) {
|
|
350
|
+
let customFn = new Function('value', this.field.options.onInput)
|
|
351
|
+
customFn.call(this, value)
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
emitAppendButtonClick() {
|
|
356
|
+
if (!!this.designState) { //设计状态不触发点击事件
|
|
357
|
+
return
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (!!this.field.options.onAppendButtonClick) {
|
|
361
|
+
let customFn = new Function(this.field.options.onAppendButtonClick)
|
|
362
|
+
customFn.call(this)
|
|
363
|
+
} else {
|
|
364
|
+
/* 必须调用mixins中的dispatch方法逐级向父组件发送消息!! */
|
|
365
|
+
this.dispatch('VFormRender', 'appendButtonClick', [this])
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
handleOnChange(val, oldVal) { //自定义onChange事件
|
|
370
|
+
if (!!this.field.options.onChange) {
|
|
371
|
+
let changeFn = new Function('value', 'oldValue', this.field.options.onChange)
|
|
372
|
+
changeFn.call(this, val, oldVal)
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
handleOnChangeForSubForm(val, oldVal, subFormData, rowId) { //子表单自定义onChange事件
|
|
377
|
+
if (!!this.field.options.onChange) {
|
|
378
|
+
let changeFn = new Function('value', 'oldValue', 'subFormData', 'rowId', this.field.options.onChange)
|
|
379
|
+
changeFn.call(this, val, oldVal, subFormData, rowId)
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
handleButtonWidgetClick() {
|
|
384
|
+
if (!!this.designState) { //设计状态不触发点击事件
|
|
385
|
+
return
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (!!this.field.options.onClick) {
|
|
389
|
+
let changeFn = new Function(this.field.options.onClick)
|
|
390
|
+
changeFn.call(this)
|
|
391
|
+
} else {
|
|
392
|
+
this.dispatch('VFormRender', 'buttonClick', [this]);
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
remoteQuery(keyword) {
|
|
397
|
+
if (!!this.field.options.onRemoteQuery) {
|
|
398
|
+
let remoteFn = new Function('keyword', this.field.options.onRemoteQuery)
|
|
399
|
+
remoteFn.call(this, keyword)
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
//--------------------- 事件处理 end ------------------//
|
|
404
|
+
|
|
405
|
+
//--------------------- 以下为组件支持外部调用的API方法 begin ------------------//
|
|
406
|
+
/* 提示:用户可自行扩充这些方法!!! */
|
|
407
|
+
|
|
408
|
+
getFormRef() { /* 获取VFrom引用,必须在VForm组件created之后方可调用 */
|
|
409
|
+
return this.refList['v_form_ref']
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
getWidgetRef(widgetName, showError) {
|
|
413
|
+
let foundRef = this.refList[widgetName]
|
|
414
|
+
if (!foundRef && !!showError) {
|
|
415
|
+
this.$message.error(this.i18nt('render.hint.refNotFound') + widgetName)
|
|
416
|
+
}
|
|
417
|
+
return foundRef
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
getFieldEditor() { //获取内置的el表单组件
|
|
421
|
+
return this.$refs['fieldEditor']
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
/*
|
|
425
|
+
注意:VFormRender的setFormData方法不会触发子表单内field-widget的setValue方法,
|
|
426
|
+
因为setFormData方法调用后,子表单内所有field-widget组件已被清空,接收不到setFormData事件!!
|
|
427
|
+
* */
|
|
428
|
+
setValue(newValue) {
|
|
429
|
+
/* if ((this.field.type === 'picture-upload') || (this.field.type === 'file-upload')) {
|
|
430
|
+
this.fileList = newValue
|
|
431
|
+
} else */ if (!!this.field.formItemFlag) {
|
|
432
|
+
let oldValue = deepClone(this.fieldModel)
|
|
433
|
+
this.fieldModel = newValue
|
|
434
|
+
this.initFileList()
|
|
435
|
+
|
|
436
|
+
this.syncUpdateFormModel(newValue)
|
|
437
|
+
this.emitFieldDataChange(newValue, oldValue)
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
getValue() {
|
|
442
|
+
/* if ((this.field.type === 'picture-upload') || (this.field.type === 'file-upload')) {
|
|
443
|
+
return this.fileList
|
|
444
|
+
} else */ {
|
|
445
|
+
return this.fieldModel
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
resetField() {
|
|
450
|
+
if (!!this.subFormItemFlag) { //跳过子表单组件
|
|
451
|
+
return
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
let defaultValue = this.field.options.defaultValue
|
|
455
|
+
this.setValue(defaultValue)
|
|
456
|
+
|
|
457
|
+
//清空上传组件文件列表
|
|
458
|
+
if ((this.field.type === 'picture-upload') || (this.field.type === 'file-upload')) {
|
|
459
|
+
this.$refs['fieldEditor'].clearFiles()
|
|
460
|
+
this.fileList.splice(0, this.fileList.length)
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
setWidgetOption(optionName, optionValue) { //通用组件选项修改API
|
|
465
|
+
if (this.field.options.hasOwnProperty(optionName)) {
|
|
466
|
+
this.field.options[optionName] = optionValue
|
|
467
|
+
//TODO: 是否重新构建组件??有些属性修改后必须重新构建组件才能生效,比如字段校验规则。
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
setReadonly(flag) {
|
|
472
|
+
this.field.options.readonly = flag
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
setDisabled(flag) {
|
|
476
|
+
this.field.options.disabled = flag
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
setAppendButtonVisible(flag) {
|
|
480
|
+
this.field.options.appendButton = flag
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
setAppendButtonDisabled(flag) {
|
|
484
|
+
this.field.options.appendButtonDisabled = flag
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
setHidden(flag) {
|
|
488
|
+
this.field.options.hidden = flag
|
|
489
|
+
|
|
490
|
+
if (!!flag) { //清除组件校验规则
|
|
491
|
+
this.clearFieldRules()
|
|
492
|
+
} else { //重建组件校验规则
|
|
493
|
+
this.buildFieldRules()
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
|
|
497
|
+
setRequired(flag) {
|
|
498
|
+
this.field.options.required = flag
|
|
499
|
+
this.buildFieldRules()
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
setLabel(newLabel) {
|
|
503
|
+
this.field.options.label = newLabel
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
focus() {
|
|
507
|
+
if (!!this.getFieldEditor() && !!this.getFieldEditor().focus) {
|
|
508
|
+
this.getFieldEditor().focus()
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
clearSelectedOptions() { //清空已选选项
|
|
513
|
+
if ((this.field.type !== 'checkbox') && (this.field.type !== 'radio') && (this.field.type !== 'select')) {
|
|
514
|
+
return
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if ((this.field.type === 'checkbox') ||
|
|
518
|
+
((this.field.type === 'select') && this.field.options.multiple)) {
|
|
519
|
+
this.fieldModel = []
|
|
520
|
+
} else {
|
|
521
|
+
this.fieldModel = ''
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 加载选项,并清空字段值
|
|
527
|
+
* @param options
|
|
528
|
+
*/
|
|
529
|
+
loadOptions(options) {
|
|
530
|
+
this.field.options.optionItems = deepClone(options)
|
|
531
|
+
//this.clearSelectedOptions() //清空已选选项
|
|
532
|
+
},
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* 重新加载选项,不清空字段值
|
|
536
|
+
* @param options
|
|
537
|
+
*/
|
|
538
|
+
reloadOptions(options) {
|
|
539
|
+
this.field.options.optionItems = deepClone(options)
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* 返回radio/checkbox/select/cascader的选项数据
|
|
544
|
+
* @returns 选择项数组
|
|
545
|
+
*/
|
|
546
|
+
getOptions() {
|
|
547
|
+
return this.field.options.optionItems
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
disableOption(optionValue) {
|
|
551
|
+
this.disableOptionOfList(this.field.options.optionItems, optionValue)
|
|
552
|
+
},
|
|
553
|
+
|
|
554
|
+
enableOption(optionValue) {
|
|
555
|
+
this.enableOptionOfList(this.field.options.optionItems, optionValue)
|
|
556
|
+
},
|
|
557
|
+
|
|
558
|
+
setUploadHeader(name, value) {
|
|
559
|
+
this.$set(this.uploadHeaders, name, value)
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
setUploadData(name, value) {
|
|
563
|
+
this.$set(this.uploadData, name, value)
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
setToolbar(customToolbar) {
|
|
567
|
+
this.customToolbar = customToolbar
|
|
568
|
+
},
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* 是否子表单内嵌的组件
|
|
572
|
+
* @returns {boolean}
|
|
573
|
+
*/
|
|
574
|
+
isSubFormItem() {
|
|
575
|
+
return !!this.parentWidget ? this.parentWidget.type === 'sub-form' : false
|
|
576
|
+
},
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* 动态增加自定义css样式
|
|
580
|
+
* @param className
|
|
581
|
+
*/
|
|
582
|
+
addCssClass(className) {
|
|
583
|
+
if (!this.field.options.customClass) {
|
|
584
|
+
this.field.options.customClass = [className]
|
|
585
|
+
} else {
|
|
586
|
+
this.field.options.customClass.push(className)
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* 动态移除自定义css样式
|
|
592
|
+
* @param className
|
|
593
|
+
*/
|
|
594
|
+
removeCssClass(className) {
|
|
595
|
+
if (!this.field.options.customClass) {
|
|
596
|
+
return
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
let foundIdx = -1
|
|
600
|
+
this.field.options.customClass.map((cc, idx) => {
|
|
601
|
+
if (cc === className) {
|
|
602
|
+
foundIdx = idx
|
|
603
|
+
}
|
|
604
|
+
})
|
|
605
|
+
if (foundIdx > -1) {
|
|
606
|
+
this.field.options.customClass.splice(foundIdx, 1)
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
|
|
610
|
+
//--------------------- 以上为组件支持外部调用的API方法 end ------------------//
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
}
|