|
@@ -27,7 +27,7 @@
|
|
|
<PagingTable url="/phone-list/phone" :where="{ listId: (selectedRow || {}).id }" ref="phoneTable" height="50vh">
|
|
<PagingTable url="/phone-list/phone" :where="{ listId: (selectedRow || {}).id }" ref="phoneTable" height="50vh">
|
|
|
<template #filter>
|
|
<template #filter>
|
|
|
<ElButton :icon="Plus" @click="onPhoneEdit()">添加</ElButton>
|
|
<ElButton :icon="Plus" @click="onPhoneEdit()">添加</ElButton>
|
|
|
- <ElButton :icon="Plus" @click="importList()">导入</ElButton>
|
|
|
|
|
|
|
+ <ElButton :icon="Plus" @click="importList()" :loading="importing">导入</ElButton>
|
|
|
</template>
|
|
</template>
|
|
|
<ElTableColumn prop="id" label="#" width="80" />
|
|
<ElTableColumn prop="id" label="#" width="80" />
|
|
|
<ElTableColumn prop="number" label="号码" min-width="120" />
|
|
<ElTableColumn prop="number" label="号码" min-width="120" />
|
|
@@ -116,6 +116,7 @@ function delPhone(row) {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+const importing = ref(false)
|
|
|
function importList() {
|
|
function importList() {
|
|
|
const input = document.createElement('input')
|
|
const input = document.createElement('input')
|
|
|
input.type = 'file'
|
|
input.type = 'file'
|
|
@@ -124,8 +125,14 @@ function importList() {
|
|
|
const file = input.files[0]
|
|
const file = input.files[0]
|
|
|
const formData = new FormData()
|
|
const formData = new FormData()
|
|
|
formData.append('file', file)
|
|
formData.append('file', file)
|
|
|
- await http.post(`/phone-list/${selectedRow.value.id}/import`, formData)
|
|
|
|
|
- ElMessage.success('导入成功')
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ importing.value = true
|
|
|
|
|
+ await http.post(`/phone-list/${selectedRow.value.id}/import`, formData)
|
|
|
|
|
+ ElMessage.success('导入成功')
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ ElMessage.error(e.message || '导入失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ importing.value = false
|
|
|
phoneTable.value.refresh()
|
|
phoneTable.value.refresh()
|
|
|
}
|
|
}
|
|
|
input.click()
|
|
input.click()
|