|
7 | 7 | </template>
|
8 | 8 |
|
9 | 9 | <script>
|
10 |
| - import {inject} from 'vue'; |
11 |
| - import axios from 'axios'; |
| 10 | +import {inject} from 'vue'; |
| 11 | +import axios from 'axios'; |
12 | 12 |
|
13 |
| - export default { |
14 |
| - name: "VueCsvImportSubmit", |
15 |
| - props: { |
16 |
| - url: { |
17 |
| - type: String, |
18 |
| - required: true, |
19 |
| - } |
| 13 | +export default { |
| 14 | + name: "VueCsvImportSubmit", |
| 15 | + props: { |
| 16 | + url: { |
| 17 | + type: String, |
| 18 | + required: true, |
20 | 19 | },
|
21 |
| - setup(props) { |
22 |
| - const VueCsvImportData = inject('VueCsvImportData'); |
23 |
| - const buildMappedCsv = inject('buildMappedCsv'); |
24 |
| - const labels = VueCsvImportData.language; |
| 20 | + config: { |
| 21 | + type: Object, |
| 22 | + required: false, |
| 23 | + default: {} |
| 24 | + } |
| 25 | + }, |
| 26 | + setup(props) { |
| 27 | + const VueCsvImportData = inject('VueCsvImportData'); |
| 28 | + const buildMappedCsv = inject('buildMappedCsv'); |
| 29 | + const labels = VueCsvImportData.language; |
25 | 30 |
|
26 |
| - const submit = function () { |
27 |
| - buildMappedCsv(); |
| 31 | + const submit = function () { |
| 32 | + buildMappedCsv(); |
28 | 33 |
|
29 |
| - axios.post(props.url, {[VueCsvImportData.inputName]: VueCsvImportData.value}).then(response => { |
30 |
| - emit('send-success', response); |
31 |
| - }).catch(response => { |
32 |
| - emit('send-error', response); |
33 |
| - }).finally(response => { |
34 |
| - emit('send-complete', response); |
35 |
| - }); |
36 |
| - }; |
| 34 | + axios.post(props.url, {[VueCsvImportData.inputName]: VueCsvImportData.value}, props.config).then(response => { |
| 35 | + emit('send-success', response); |
| 36 | + }).catch(response => { |
| 37 | + emit('send-error', response); |
| 38 | + }).finally(response => { |
| 39 | + emit('send-complete', response); |
| 40 | + }); |
| 41 | + }; |
37 | 42 |
|
38 |
| - return { |
39 |
| - submit, |
40 |
| - VueCsvImportData, |
41 |
| - labels |
42 |
| - } |
43 |
| - }, |
44 |
| - }; |
| 43 | + return { |
| 44 | + submit, |
| 45 | + VueCsvImportData, |
| 46 | + labels |
| 47 | + } |
| 48 | + }, |
| 49 | +}; |
45 | 50 | </script>
|
0 commit comments