diff --git a/src/App.vue b/src/App.vue index 705d321..bed1e41 100644 --- a/src/App.vue +++ b/src/App.vue @@ -25,17 +25,17 @@ const sysField = reactive([ { name: 'phone', type: 'phone', - id: '09195a3e-96d3-4de4-b5df-dd358398fdcd', + id: 'phonepho-nephoneph-onep-honephonepho', }, { name: 'birthday', type: 'date', - id: '99b2f8ec-adf1-44e6-b242-fd9005d6f73c', + id: 'birthday-birt-dayb-irth-daybirthdayb', }, { name: 'name', type: 'string', - id: '0c45dac3-d904-435a-9573-e58f9854cd91', + id: 'namename-name-name-name-namenamename', }, ]) diff --git a/src/components/Table.vue b/src/components/Table.vue index 4787607..1ec2509 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -157,6 +157,26 @@ const handleRemoveSelectedRows = () => { onResetCheckbox() } +const handleSave = async() => { + console.log('🦕 handleSave') + const badColumnIdx = table.columns.map((col, idx) => col ? null : idx).filter(colIdx => colIdx) + const cloneCsv = JSON.parse(JSON.stringify(csv.value)) + .map(row => row.filter((_el, elIdx) => !badColumnIdx.includes(elIdx))) + const headerCsv = table.columns.filter(col => col).map(col => col.id) + const data = [ + headerCsv, + ...cloneCsv, + ] + + await fetch('/test1', { + method: 'POST', + headers: { + 'Content-Type': 'application/json;charset=utf-8', + }, + body: JSON.stringify(data), + }) +} + onUpdated(() => { console.log('🦕 onUpdated') if (!table.checkboxes.length) { @@ -189,7 +209,8 @@ onMounted(() => {