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 142 // 判断是否显示
143 143 if (schemaItem?.form?.show !== false) {
144 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 153 let comonentProps = {}
147 154 if (schemaItem.dictType) {
  155 + const options: ComponentOptions[] = []
148 156 if (schemaItem.dictData && schemaItem.dictData === 'number') {
149 157 getIntDictOptions(schemaItem.dictType).forEach((dict) => {
150 158 options.push(dict)
... ... @@ -167,6 +175,7 @@ const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
167 175 // 默认为 input
168 176 component: component,
169 177 componentProps: comonentProps,
  178 + value: defaultValue,
170 179 ...schemaItem.form,
171 180 field: schemaItem.field,
172 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 228 // 默认为 input
229 229 let component = schemaItem?.form?.component || 'Input'
230 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 238 let comonentProps = {}
235 239 if (schemaItem.dictType) {
... ... @@ -253,12 +257,12 @@ const filterFormSchema = (crudSchema: VxeCrudSchema): FormSchema[] => {
253 257 if (!(schemaItem.form && schemaItem.form.component)) component = 'Select'
254 258 }
255 259 const formSchemaItem = {
256   - ...schemaItem.form,
257   - field: schemaItem.field,
258   - label: schemaItem.form?.label || schemaItem.title,
259 260 component: component,
260 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 268 formSchema.push(formSchemaItem)
... ...