From ef4b6b99c6fbcc8c68b4a47dd2f720a2a97ea7ab Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 10 Dec 2024 22:24:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(GiForm):=20=E4=BC=98=E5=8C=96=20GiForm?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GiForm/src/GiForm.vue | 76 ++++++++++++---------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/src/components/GiForm/src/GiForm.vue b/src/components/GiForm/src/GiForm.vue index 84e60607..d344a351 100644 --- a/src/components/GiForm/src/GiForm.vue +++ b/src/components/GiForm/src/GiForm.vue @@ -109,49 +109,39 @@ const colVShow = (index: number) => { // 组件的默认props配置 const getComponentBindProps = (item: ColumnsItem) => { const obj: Partial = {} - if (item.type === 'input') { - obj.allowClear = true - obj.placeholder = `请输入${item.label}` - } - if (item.type === 'input-password') { - obj.allowClear = true - obj.placeholder = `请输入${item.label}` - } - if (item.type === 'input-number') { - obj.allowClear = true - obj.placeholder = `请输入${item.label}` - } - if (item.type === 'textarea') { - obj.placeholder = `请输入${item.label}` - obj.maxLength = 200 - } - if (item.type === 'select') { - obj.allowClear = true - obj.placeholder = `请选择${item.label}` - obj.options = dicData[item.field] || item.options - } - if (item.type === 'cascader') { - obj.allowClear = true - obj.placeholder = `请选择${item.label}` - obj.options = dicData[item.field] || item.options - } - if (item.type === 'tree-select') { - obj.allowClear = true - obj.placeholder = `请选择${item.label}` - obj.data = dicData[item.field] || item.data - } - if (item.type === 'radio-group') { - obj.options = dicData[item.field] || item.options - } - if (item.type === 'checkbox-group') { - obj.options = dicData[item.field] || item.options - } - if (item.type === 'date-picker') { - obj.placeholder = '请选择日期' - } - if (item.type === 'time-picker') { - obj.allowClear = true - obj.placeholder = `请选择时间` + switch (item.type) { + case 'input': + case 'input-password': + case 'input-number': + obj.allowClear = true + obj.placeholder = `请输入${item.label}` + break + case 'textarea': + obj.placeholder = `请输入${item.label}` + obj.maxLength = 200 + break + case 'select': + case 'cascader': + obj.allowClear = true + obj.placeholder = `请选择${item.label}` + obj.options = dicData[item.field] || item.options + break + case 'tree-select': + obj.allowClear = true + obj.placeholder = `请选择${item.label}` + obj.data = dicData[item.field] || item.data + break + case 'radio-group': + case 'checkbox-group': + obj.options = dicData[item.field] || item.options + break + case 'date-picker': + obj.placeholder = '请选择日期' + break + case 'time-picker': + obj.allowClear = true + obj.placeholder = `请选择时间` + break } return { ...obj, ...item.props } }