mirror of
				https://github.com/vform666/variant-form3-vite.git
				synced 2025-11-01 01:01:48 +08:00 
			
		
		
		
	1. 修复vite打包axios报错的bug;
2. 适配form、form-item的size属性。
This commit is contained in:
		| @@ -7,7 +7,7 @@ export default { | |||||||
|  |  | ||||||
|   computed: { |   computed: { | ||||||
|     widgetSize() { |     widgetSize() { | ||||||
|       return this.field.options.size || 'medium' |       return this.field.options.size || 'default' | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     subFormName() { |     subFormName() { | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ | |||||||
|           return this.designer.formConfig.size |           return this.designer.formConfig.size | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return 'medium' |         return 'default' | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       customClass() { |       customClass() { | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ | |||||||
|   import {addWindowResizeHandler, deepClone, getQueryParam} from "@/utils/util" |   import {addWindowResizeHandler, deepClone, getQueryParam} from "@/utils/util" | ||||||
|   import {MOCK_CASE_URL, VARIANT_FORM_VERSION} from "@/utils/config" |   import {MOCK_CASE_URL, VARIANT_FORM_VERSION} from "@/utils/config" | ||||||
|   import i18n, { changeLocale } from "@/utils/i18n" |   import i18n, { changeLocale } from "@/utils/i18n" | ||||||
|   import axios from "axios" |   import axios from 'axios' | ||||||
|  |  | ||||||
|   export default { |   export default { | ||||||
|     name: "VFormDesigner", |     name: "VFormDesigner", | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| <template> | <template> | ||||||
|   <div> |   <div> | ||||||
|     <el-form :model="formConfig" size="mini" label-position="left" label-width="120px" |     <el-form :model="formConfig" size="small" label-position="left" label-width="120px" | ||||||
|              class="setting-form" @submit.prevent> |              class="setting-form" @submit.prevent> | ||||||
|       <el-collapse v-model="formActiveCollapseNames" class="setting-collapse"> |       <el-collapse v-model="formActiveCollapseNames" class="setting-collapse"> | ||||||
|         <el-collapse-item name="1" :title="i18nt('designer.setting.basicSetting')"> |         <el-collapse-item name="1" :title="i18nt('designer.setting.basicSetting')"> | ||||||
| @@ -158,9 +158,9 @@ | |||||||
|         formSizes: [ |         formSizes: [ | ||||||
|           {label: 'default', value: ''}, |           {label: 'default', value: ''}, | ||||||
|           {label: 'large', value: 'large'}, |           {label: 'large', value: 'large'}, | ||||||
|           {label: 'medium', value: 'medium'}, |           //{label: 'medium', value: 'medium'}, | ||||||
|           {label: 'small', value: 'small'}, |           {label: 'small', value: 'small'}, | ||||||
|           {label: 'mini', value: 'mini'}, |           //{label: 'mini', value: 'mini'}, | ||||||
|         ], |         ], | ||||||
|  |  | ||||||
|         showEditFormCssDialogFlag: false, |         showEditFormCssDialogFlag: false, | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
|         <el-scrollbar class="setting-scrollbar" :style="{height: scrollerHeight}"> |         <el-scrollbar class="setting-scrollbar" :style="{height: scrollerHeight}"> | ||||||
|  |  | ||||||
|           <template v-if="!!designer.selectedWidget && !designer.selectedWidget.category"> |           <template v-if="!!designer.selectedWidget && !designer.selectedWidget.category"> | ||||||
|             <el-form :model="optionModel" size="mini" label-position="left" label-width="120px" class="setting-form" |             <el-form :model="optionModel" size="small" label-position="left" label-width="120px" class="setting-form" | ||||||
|                      @submit.prevent> |                      @submit.prevent> | ||||||
|               <el-collapse v-model="widgetActiveCollapseNames" class="setting-collapse"> |               <el-collapse v-model="widgetActiveCollapseNames" class="setting-collapse"> | ||||||
|                 <el-collapse-item name="1" v-if="showCollapse(commonProps)" :title="i18nt('designer.setting.commonSetting')"> |                 <el-collapse-item name="1" v-if="showCollapse(commonProps)" :title="i18nt('designer.setting.commonSetting')"> | ||||||
| @@ -34,7 +34,7 @@ | |||||||
|           </template> |           </template> | ||||||
|  |  | ||||||
|           <template v-if="(!!designer.selectedWidget && !!designer.selectedWidget.category)"> |           <template v-if="(!!designer.selectedWidget && !!designer.selectedWidget.category)"> | ||||||
|             <el-form :model="optionModel" size="mini" label-position="left" label-width="120px" class="setting-form" |             <el-form :model="optionModel" size="small" label-position="left" label-width="120px" class="setting-form" | ||||||
|                      @submit.prevent> |                      @submit.prevent> | ||||||
|               <el-collapse v-model="widgetActiveCollapseNames" class="setting-collapse"> |               <el-collapse v-model="widgetActiveCollapseNames" class="setting-collapse"> | ||||||
|                 <el-collapse-item name="1" v-if="showCollapse(commonProps)" :title="i18nt('designer.setting.commonSetting')"> |                 <el-collapse-item name="1" v-if="showCollapse(commonProps)" :title="i18nt('designer.setting.commonSetting')"> | ||||||
|   | |||||||
| @@ -7,10 +7,10 @@ | |||||||
|         <template #item="{ element: option, index: idx }"> |         <template #item="{ element: option, index: idx }"> | ||||||
|           <li> |           <li> | ||||||
|             <el-radio :label="option.value"> |             <el-radio :label="option.value"> | ||||||
|               <el-input v-model="option.value" size="mini" style="width: 100px"></el-input> |               <el-input v-model="option.value" size="small" style="width: 100px"></el-input> | ||||||
|               <el-input v-model="option.label" size="mini" style="width: 100px"></el-input> |               <el-input v-model="option.label" size="small" style="width: 100px"></el-input> | ||||||
|               <i class="iconfont icon-drag drag-option"></i> |               <i class="iconfont icon-drag drag-option"></i> | ||||||
|               <el-button circle plain size="mini" type="danger" @click="deleteOption(option, idx)" |               <el-button circle plain size="small" type="danger" @click="deleteOption(option, idx)" | ||||||
|                          icon="el-icon-minus" class="col-delete-button"></el-button> |                          icon="el-icon-minus" class="col-delete-button"></el-button> | ||||||
|             </el-radio> |             </el-radio> | ||||||
|           </li> |           </li> | ||||||
| @@ -24,10 +24,10 @@ | |||||||
|         <template #item="{ element: option, index: idx }"> |         <template #item="{ element: option, index: idx }"> | ||||||
|           <li> |           <li> | ||||||
|             <el-checkbox :label="option.value"> |             <el-checkbox :label="option.value"> | ||||||
|               <el-input v-model="option.value" size="mini" style="width: 100px"></el-input> |               <el-input v-model="option.value" size="small" style="width: 100px"></el-input> | ||||||
|               <el-input v-model="option.label" size="mini" style="width: 100px"></el-input> |               <el-input v-model="option.label" size="small" style="width: 100px"></el-input> | ||||||
|               <i class="iconfont icon-drag drag-option"></i> |               <i class="iconfont icon-drag drag-option"></i> | ||||||
|               <el-button circle plain size="mini" type="danger" @click="deleteOption(option, idx)" |               <el-button circle plain size="small" type="danger" @click="deleteOption(option, idx)" | ||||||
|                          icon="el-icon-minus" class="col-delete-button"></el-button> |                          icon="el-icon-minus" class="col-delete-button"></el-button> | ||||||
|             </el-checkbox> |             </el-checkbox> | ||||||
|           </li> |           </li> | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ | |||||||
|         <el-input-number v-model.number="colItem.options.span" :min="1" :max="24" |         <el-input-number v-model.number="colItem.options.span" :min="1" :max="24" | ||||||
|                          @change="(newValue, oldValue) => spanChanged(selectedWidget, colItem, colIdx, newValue, oldValue)" |                          @change="(newValue, oldValue) => spanChanged(selectedWidget, colItem, colIdx, newValue, oldValue)" | ||||||
|                          class="cell-span-input"></el-input-number> |                          class="cell-span-input"></el-input-number> | ||||||
|         <el-button circle plain size="mini" type="danger" @click="deleteCol(selectedWidget, colIdx)" |         <el-button circle plain size="small" type="danger" @click="deleteCol(selectedWidget, colIdx)" | ||||||
|                    icon="el-icon-minus" class="col-delete-button"></el-button> |                    icon="el-icon-minus" class="col-delete-button"></el-button> | ||||||
|       </li> |       </li> | ||||||
|       <div> |       <div> | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ | |||||||
|                          style="margin-right: 8px">{{i18nt('designer.setting.paneActive')}}</el-checkbox> |                          style="margin-right: 8px">{{i18nt('designer.setting.paneActive')}}</el-checkbox> | ||||||
|             <el-input type="text" v-model="tpItem.options.label" style="width: 155px"></el-input> |             <el-input type="text" v-model="tpItem.options.label" style="width: 155px"></el-input> | ||||||
|             <i class="iconfont icon-drag drag-option"></i> |             <i class="iconfont icon-drag drag-option"></i> | ||||||
|             <el-button circle plain size="mini" type="danger" @click="deleteTabPane(selectedWidget, tpIdx)" |             <el-button circle plain size="small" type="danger" @click="deleteTabPane(selectedWidget, tpIdx)" | ||||||
|                        icon="el-icon-minus" class="col-delete-button"></el-button> |                        icon="el-icon-minus" class="col-delete-button"></el-button> | ||||||
|           </li> |           </li> | ||||||
|         </template> |         </template> | ||||||
|   | |||||||
| @@ -24,9 +24,9 @@ | |||||||
|         widgetSizes: [ |         widgetSizes: [ | ||||||
|           {label: 'default', value: ''}, |           {label: 'default', value: ''}, | ||||||
|           {label: 'large', value: 'large'}, |           {label: 'large', value: 'large'}, | ||||||
|           {label: 'medium', value: 'medium'}, |           //{label: 'medium', value: 'medium'}, | ||||||
|           {label: 'small', value: 'small'}, |           {label: 'small', value: 'small'}, | ||||||
|           {label: 'mini', value: 'mini'}, |           //{label: 'mini', value: 'mini'}, | ||||||
|         ], |         ], | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -193,7 +193,7 @@ | |||||||
|   import {genSFC} from "@/utils/sfc-generator"; |   import {genSFC} from "@/utils/sfc-generator"; | ||||||
|   import loadBeautifier from "@/utils/beautifierLoader"; |   import loadBeautifier from "@/utils/beautifierLoader"; | ||||||
|   import { saveAs } from 'file-saver' |   import { saveAs } from 'file-saver' | ||||||
|   import axios from "axios" |   import axios from 'axios' | ||||||
|  |  | ||||||
|   export default { |   export default { | ||||||
|     name: "ToolbarPanel", |     name: "ToolbarPanel", | ||||||
|   | |||||||
| @@ -93,7 +93,7 @@ | |||||||
|   import {formTemplates} from './templatesConfig' |   import {formTemplates} from './templatesConfig' | ||||||
|   import {addWindowResizeHandler} from "@/utils/util" |   import {addWindowResizeHandler} from "@/utils/util" | ||||||
|   import i18n from "@/utils/i18n" |   import i18n from "@/utils/i18n" | ||||||
|   import axios from "axios" |   import axios from 'axios' | ||||||
|  |  | ||||||
|   import ftImg1 from '@/assets/ft-images/t1.png' |   import ftImg1 from '@/assets/ft-images/t1.png' | ||||||
|   import ftImg2 from '@/assets/ft-images/t2.png' |   import ftImg2 from '@/assets/ft-images/t2.png' | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|       <el-row class="header-row"> |       <el-row class="header-row"> | ||||||
|         <div class="action-header-column"> |         <div class="action-header-column"> | ||||||
|           <span class="action-label">{{i18nt('render.hint.subFormAction')}}</span> |           <span class="action-label">{{i18nt('render.hint.subFormAction')}}</span> | ||||||
|           <el-button :disabled="actionDisabled" round type="primary" size="mini" class="action-button" @click="addSubFormRow" |           <el-button :disabled="actionDisabled" round type="primary" size="small" class="action-button" @click="addSubFormRow" | ||||||
|                      :title="i18nt('render.hint.subFormAddActionHint')"> |                      :title="i18nt('render.hint.subFormAddActionHint')"> | ||||||
|             {{i18nt('render.hint.subFormAddAction')}}<i class="el-icon-plus el-icon-right"></i></el-button> |             {{i18nt('render.hint.subFormAddAction')}}<i class="el-icon-plus el-icon-right"></i></el-button> | ||||||
|         </div> |         </div> | ||||||
|   | |||||||
| @@ -123,7 +123,7 @@ | |||||||
|           return this.formConfig.size |           return this.formConfig.size | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return 'medium' |         return 'default' | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       customClass() { |       customClass() { | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ | |||||||
|       }, |       }, | ||||||
|       tableSize: { |       tableSize: { | ||||||
|         type: String, |         type: String, | ||||||
|         default: 'medium' |         default: 'default' | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|     methods: { |     methods: { | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| import { createApp } from 'vue' | import { createApp } from 'vue' | ||||||
| import axios from "axios" | import axios from 'axios' | ||||||
| import App from './App.vue' | import App from './App.vue' | ||||||
| import ElementPlus from 'element-plus' | import ElementPlus from 'element-plus' | ||||||
| import 'element-plus/dist/index.css' | import 'element-plus/dist/index.css' | ||||||
|   | |||||||
| @@ -426,7 +426,7 @@ function genTemplate(formConfig, widgetList, vue3Flag = false) { | |||||||
|  |  | ||||||
|   const formTemplate = |   const formTemplate = | ||||||
| `  <el-form :model="${formConfig.modelName}" ref="${formConfig.refName}" :rules="${formConfig.rulesName}" | `  <el-form :model="${formConfig.modelName}" ref="${formConfig.refName}" :rules="${formConfig.rulesName}" | ||||||
|     label-position="${formConfig.labelPosition}" label-width="${formConfig.labelWidth}px" size="${formConfig.size || 'medium'}" |     label-position="${formConfig.labelPosition}" label-width="${formConfig.labelWidth}px" size="${formConfig.size || 'default'}" | ||||||
|     ${submitAttr}> |     ${submitAttr}> | ||||||
|   ${!!childrenList ? childrenList.join('\n') : ''} |   ${!!childrenList ? childrenList.join('\n') : ''} | ||||||
| </el-form>` | </el-form>` | ||||||
|   | |||||||
| @@ -15,7 +15,8 @@ export default defineConfig({ | |||||||
|     vueJsx({}), |     vueJsx({}), | ||||||
|  |  | ||||||
|     //解决引入commonjs模块后打包出现的{'default' is not exported by XXX}错误!! |     //解决引入commonjs模块后打包出现的{'default' is not exported by XXX}错误!! | ||||||
|     commonjs(), |     commonjs({requireReturnsDefault: true}),  /* 配置requireReturnsDefault属性, | ||||||
|  |     解决打包后引入VForm出现的"Axios is not a constructor"错!! */ | ||||||
|  |  | ||||||
|     //可视化Bundle |     //可视化Bundle | ||||||
|     visualizer(), |     visualizer(), | ||||||
| @@ -38,8 +39,6 @@ export default defineConfig({ | |||||||
|  |  | ||||||
|   optimizeDeps: { |   optimizeDeps: { | ||||||
|     include: ['@/../lib/vuedraggable/dist/vuedraggable.umd.js', 'quill'], |     include: ['@/../lib/vuedraggable/dist/vuedraggable.umd.js', 'quill'], | ||||||
|     exclude: ['axios'], |  | ||||||
|     //include: ['quill'] |  | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   css: { |   css: { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user