From fab7a6c58d586300d58e1b6837927e1569b57aa5 Mon Sep 17 00:00:00 2001 From: Vben Date: Thu, 11 Mar 2021 22:01:08 +0800 Subject: [PATCH] fix(table): ensure that editable cell values are echoed correctly close #335 --- mock/demo/select-demo.ts | 2 +- .../Table/src/components/editable/EditableCell.vue | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mock/demo/select-demo.ts b/mock/demo/select-demo.ts index da6d462c820..d962d27b30e 100644 --- a/mock/demo/select-demo.ts +++ b/mock/demo/select-demo.ts @@ -15,7 +15,7 @@ const demoList = (() => { export default [ { url: '/basic-api/select/getDemoOptions', - timeout: 4000, + timeout: 2000, method: 'get', response: ({ query }) => { console.log(query); diff --git a/src/components/Table/src/components/editable/EditableCell.vue b/src/components/Table/src/components/editable/EditableCell.vue index 9cd6e4158c3..d4055f59223 100644 --- a/src/components/Table/src/components/editable/EditableCell.vue +++ b/src/components/Table/src/components/editable/EditableCell.vue @@ -13,7 +13,6 @@ :popoverVisible="getRuleVisible" :rule="getRule" :ruleMessage="ruleMessage" - allowClear size="small" ref="elRef" @change="handleChange" @@ -183,14 +182,16 @@ async function handleChange(e: any) { const component = unref(getComponent); - if (e?.target && Reflect.has(e.target, 'value')) { + if (!e) { + currentValueRef.value = e; + } else if (e?.target && Reflect.has(e.target, 'value')) { currentValueRef.value = (e as ChangeEvent).target.value; - } - if (component === 'Checkbox') { + } else if (component === 'Checkbox') { currentValueRef.value = (e as ChangeEvent).target.checked; } else if (isString(e) || isBoolean(e) || isNumber(e)) { currentValueRef.value = e; } + table.emit?.('edit-change', { column: props.column, value: unref(currentValueRef),