Skip to content

Commit

Permalink
wip handle save
Browse files Browse the repository at this point in the history
  • Loading branch information
mioe committed May 22, 2024
1 parent c0e8569 commit 67c4672
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
])
Expand Down
23 changes: 22 additions & 1 deletion src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -189,7 +209,8 @@ onMounted(() => {
</div>
<div class="flex gap-2">
<button
disabled
:disabled="!table.columns.filter(c => c).length"
@click="handleSave"
>
{{ $t('save') }}
</button>
Expand Down

0 comments on commit 67c4672

Please sign in to comment.