Commit e1754866923f9573039cc0462910525ecaedc6d2

Authored by xingyu4j
1 parent 08656ee0

perf: form inputnumber

yudao-ui-admin-vue3/src/hooks/web/useCrudSchemas.ts
@@ -142,9 +142,17 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => { @@ -142,9 +142,17 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
142 // 判断是否显示 142 // 判断是否显示
143 if (schemaItem?.form?.show !== false) { 143 if (schemaItem?.form?.show !== false) {
144 let component = schemaItem?.form?.component || 'Input' 144 let component = schemaItem?.form?.component || 'Input'
145 - const options: ComponentOptions[] = [] 145 + let defaultValue: any = ''
  146 + if (schemaItem.form?.value) {
  147 + defaultValue = schemaItem.form?.value
  148 + } else {
  149 + if (component === 'InputNumber') {
  150 + defaultValue = 0
  151 + }
  152 + }
146 let comonentProps = {} 153 let comonentProps = {}
147 if (schemaItem.dictType) { 154 if (schemaItem.dictType) {
  155 + const options: ComponentOptions[] = []
148 if (schemaItem.dictData && schemaItem.dictData === 'number') { 156 if (schemaItem.dictData && schemaItem.dictData === 'number') {
149 getIntDictOptions(schemaItem.dictType).forEach((dict) => { 157 getIntDictOptions(schemaItem.dictType).forEach((dict) => {
150 options.push(dict) 158 options.push(dict)
@@ -167,6 +175,7 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => { @@ -167,6 +175,7 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
167 // 默认为 input 175 // 默认为 input
168 component: component, 176 component: component,
169 componentProps: comonentProps, 177 componentProps: comonentProps,
  178 + value: defaultValue,
170 ...schemaItem.form, 179 ...schemaItem.form,
171 field: schemaItem.field, 180 field: schemaItem.field,
172 label: schemaItem.form?.label || schemaItem.label 181 label: schemaItem.form?.label || schemaItem.label
yudao-ui-admin-vue3/src/hooks/web/useVxeCrudSchemas.ts
@@ -228,8 +228,12 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => { @@ -228,8 +228,12 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
228 // 默认为 input 228 // 默认为 input
229 let component = schemaItem?.form?.component || 'Input' 229 let component = schemaItem?.form?.component || 'Input'
230 let defaultValue: any = '' 230 let defaultValue: any = ''
231 - if (component === 'InputNumber') {  
232 - defaultValue = 0 231 + if (schemaItem.form?.value) {
  232 + defaultValue = schemaItem.form?.value
  233 + } else {
  234 + if (component === 'InputNumber') {
  235 + defaultValue = 0
  236 + }
233 } 237 }
234 let comonentProps = {} 238 let comonentProps = {}
235 if (schemaItem.dictType) { 239 if (schemaItem.dictType) {
@@ -253,12 +257,12 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => { @@ -253,12 +257,12 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
253 if (!(schemaItem.form && schemaItem.form.component)) component = 'Select' 257 if (!(schemaItem.form && schemaItem.form.component)) component = 'Select'
254 } 258 }
255 const formSchemaItem = { 259 const formSchemaItem = {
256 - ...schemaItem.form,  
257 - field: schemaItem.field,  
258 - label: schemaItem.form?.label || schemaItem.title,  
259 component: component, 260 component: component,
260 componentProps: comonentProps, 261 componentProps: comonentProps,
261 - value: defaultValue 262 + value: defaultValue,
  263 + ...schemaItem.form,
  264 + field: schemaItem.field,
  265 + label: schemaItem.form?.label || schemaItem.title
262 } 266 }
263 267
264 formSchema.push(formSchemaItem) 268 formSchema.push(formSchemaItem)