124 lines
4.5 KiB
Vue
124 lines
4.5 KiB
Vue
<template>
|
|
<div class="container-fluid">
|
|
<v-card>
|
|
<v-card-title class="bg-primary white--text text-center">
|
|
<h4>Excel匯入</h4>
|
|
<div class="ms-auto">
|
|
<!--<v-btn @click.prevent="batchSave()">儲存</v-btn>
|
|
<v-btn @click.prevent="back01()">返回</v-btn>-->
|
|
</div>
|
|
</v-card-title>
|
|
<v-card-text>
|
|
<v-select :items="data_table.list"
|
|
label="選擇法會"
|
|
item-text="subject"
|
|
item-value="num" v-model="selected">
|
|
</v-select>
|
|
<v-file-input v-model="selectedFiles" truncate-length="15" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" label="請選擇要匯入的excel" outlined dense></v-file-input>
|
|
<v-btn @click.prevent="importList">匯入</v-btn>
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
<v-dialog v-model="message_dialog.show" class="dialog_width">
|
|
<template>
|
|
<v-card>
|
|
<v-card-title>
|
|
{{ message_dialog.message }}
|
|
</v-card-title>
|
|
<v-card-text>
|
|
<v-btn @click.prevent="message_dialog.show=false" v-if="!message_dialog.show_confirm">關閉</v-btn>
|
|
</v-card-text>
|
|
</v-card>
|
|
</template>
|
|
</v-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
module.exports = {
|
|
props: {
|
|
num: {
|
|
type: Number
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
options: { multiSort: false },
|
|
search_options: { multiSort: false },
|
|
message_dialog: { show: false, show_confirm: false, message: "" },
|
|
data_table: {
|
|
loading: true,
|
|
list: [],
|
|
selected: [],
|
|
singleSelect: false,
|
|
count: 0,
|
|
page: 1,
|
|
pageSize: -1,
|
|
},
|
|
selected: null,
|
|
search: { subject: "" },
|
|
selectedFiles:[],
|
|
}
|
|
},
|
|
activated() {
|
|
this.getActivity()
|
|
},
|
|
watch: {
|
|
selected: {
|
|
handler() {
|
|
this.getProOrder()
|
|
},
|
|
deep: true,
|
|
},
|
|
},
|
|
methods: {
|
|
importList() {
|
|
if (!this.selectedFiles || this.selectedFiles.length === 0) return;
|
|
|
|
const formData = new FormData();
|
|
|
|
// If multiple files are enabled, loop through and append each file
|
|
for (let i = 0; i < this.selectedFiles.length; i++) {
|
|
formData.append('files', this.selectedFiles[i]);
|
|
}
|
|
|
|
//try {
|
|
// const response = await axios.post('/api/upload', formData, {
|
|
// headers: {
|
|
// 'Content-Type': 'multipart/form-data'
|
|
// }
|
|
// });
|
|
// console.log('Upload success:', response.data);
|
|
//} catch (error) {
|
|
// console.error('Upload failed:', error);
|
|
//}
|
|
},
|
|
back01() {//返回
|
|
this.$emit('custom-event', { action: 'signup1', item: this.num });
|
|
},
|
|
getActivity() {//撈法會資料
|
|
//const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
|
const params = {
|
|
sortBy: "startDate_solar", sortDesc: true,
|
|
page: 1, pageSize: -1
|
|
};
|
|
this.data_table.loading = true
|
|
const self = this
|
|
axios
|
|
.post(HTTP_HOST + 'api/activity/GetListNew', this.search, { params: params })
|
|
.then(response => {
|
|
this.data_table.list = response.data.list
|
|
this.data_table.list = this.data_table.list.filter(x => x.num != self.num)
|
|
|
|
this.data_table.count = response.data.count;
|
|
this.data_table.loading = false
|
|
})
|
|
.catch(error => console.log(error))
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style>
|
|
.v-dialog {
|
|
width: 80% !important;
|
|
}
|
|
</style> |