改太多
This commit is contained in:
1 parent
be5352efed
commit
1cb2a7a35e
48 files changed
+17970
-485
No files matched your search
@@ -0,0 +1,254 @@
|
||||
<template>
|
||||
<div class="container-fluid">
|
||||
<nav>
|
||||
<!--<a href="create.aspx" class="btn btn-primary">新增</a>-->
|
||||
<button class="btn btn-primary" @click.prevent="changeViews()">新增</button>
|
||||
</nav>
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<label class="mb-0">掛單單號</label>
|
||||
<input class="form-control w-auto" style="width:150px;" v-model="search.guaDanOrderNo" />
|
||||
<label class="mb-0">掛單登記人</label>
|
||||
<input class="form-control w-auto" style="width:150px;" v-model="search.guadanUser" />
|
||||
|
||||
<label class="mb-0">開始時間</label>
|
||||
<input class="form-control w-auto" style="width:150px;" type="date" v-model="search.startDate" />
|
||||
|
||||
<label class="mb-0">結束時間</label>
|
||||
<input class="form-control w-auto" style="width:150px;" type="date" v-model="search.endDate" />
|
||||
|
||||
<button class="btn btn-primary" type="button" @click="handleSearch">查詢</button>
|
||||
<button class="btn btn-outline-primary" type="button" @click="clearSearch">清除條件</button>
|
||||
</div>
|
||||
|
||||
<div class="mx-5">
|
||||
<v-data-table :items="items"
|
||||
:headers="headers"
|
||||
:item-class="item => item.is_timeout ? 'row-timeout' : ''"
|
||||
hide-default-footer>
|
||||
<template #item.actions="{item}">
|
||||
<button class="btn btn-primary">查看</button>
|
||||
<!--<a :href="'view.aspx?orderId='+item.guaDanOrderNo" class="btn btn-primary">查看</a>-->
|
||||
<button class="btn btn-secondary"
|
||||
:style="item.guadan_status?.code == 502 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''">編輯</button>
|
||||
<!--<a :href="'create.aspx?orderId='+item.guaDanOrderNo" class="btn btn-secondary"
|
||||
:style="item.guadan_status?.code == 502 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''">編輯</a>-->
|
||||
<button class="btn btn-outline-danger" :style="item.guest_count != 0 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''"
|
||||
@click.prevent="item.guest_count != 0 ? null : deleteGuadanOrder(item)">
|
||||
取消
|
||||
</button>
|
||||
<!--<a class="btn btn-outline-danger"
|
||||
href="#"
|
||||
:style="item.guest_count != 0 ? 'pointer-events: none; opacity: 0.5; cursor: not-allowed;' : ''"
|
||||
@click.prevent="item.guest_count != 0 ? null : deleteGuadanOrder(item)">
|
||||
取消
|
||||
</a>-->
|
||||
|
||||
</template>
|
||||
<template #item.room="{item}">
|
||||
{{item.room.name}}
|
||||
</template>
|
||||
<template #item.bed="{item}">
|
||||
{{item.bed.name}}
|
||||
</template>
|
||||
<template #item.guadan_status="{item}">
|
||||
{{item.guadan_status?.name}}
|
||||
</template>
|
||||
<template #item.start_date="{item}">
|
||||
{{item.start_date | timeString('YYYY/MM/DD')}}
|
||||
</template>
|
||||
<template #item.end_date="{item}">
|
||||
{{item.end_date | timeString('YYYY/MM/DD')}}
|
||||
</template>
|
||||
<template #item.created_at="{item}">
|
||||
{{item.created_at | timeString('YYYY/MM/DD HH:mm')}}
|
||||
</template>
|
||||
<template #item.activity="{item}">
|
||||
{{item.activity?.subject}}
|
||||
</template>
|
||||
<template #item.is_timeout="{item}">
|
||||
{{item.is_timeout ? '已超時': '否'}}
|
||||
</template>
|
||||
</v-data-table>
|
||||
<v-container>
|
||||
<v-row class="align-baseline" wrap="false">
|
||||
<v-col cols="12" md="8">
|
||||
<v-pagination v-model="options.page"
|
||||
:length="pageCount">
|
||||
</v-pagination>
|
||||
</v-col>
|
||||
<v-col class="text-truncate text-right" cols="12" md="2">
|
||||
共 {{ total }} 筆, 頁數:
|
||||
</v-col>
|
||||
<v-col cols="6" md="1">
|
||||
<v-text-field v-model="options.page"
|
||||
type="number"
|
||||
hide-details
|
||||
dense
|
||||
min="1"
|
||||
:max="pageCount"
|
||||
@input="options.page = parseInt($event, 10)"></v-text-field>
|
||||
</v-col>
|
||||
<!-- 每頁條數選擇 -->
|
||||
<v-col cols="12" md="1">
|
||||
<v-select v-model="options.itemsPerPage"
|
||||
:items="[5, 10, 20, 50]"
|
||||
label="每頁條數"
|
||||
dense
|
||||
hide-details
|
||||
style="width: 100px;"></v-select>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
<!-- 更新修改確認彈出視窗 -->
|
||||
<message-modal ref="messageModal"></message-modal>
|
||||
<!-- 刪除確認彈出視窗 -->
|
||||
<confirm-modal ref="confirmModal"></confirm-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
Vue.filter('timeString', function (value, myFormat) {
|
||||
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
|
||||
});
|
||||
module.exports = {
|
||||
props: ['formData'],
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
items: [],
|
||||
headers: [
|
||||
{ text: '登記掛單蓮友', value: 'bookerName' },
|
||||
{ text: '掛單單號', value: 'guaDanOrderNo' },
|
||||
{ text: '起始日期', value: 'start_date', align: 'center' },
|
||||
{ text: '結束日期', value: 'end_date', align: 'center' },
|
||||
{ text: '掛單人數', value: 'guest_count' },
|
||||
{ text: '狀態', value: 'guadan_status', align: 'center' },
|
||||
{ text: '建立時間', value: 'created_at', align: 'center' },
|
||||
{ text: '關聯活動', value: 'activity', align: 'center' },
|
||||
{ text: '超時退房', value: 'is_timeout', align: 'center' },
|
||||
{ text: '操作', value: 'actions', align: 'center' }
|
||||
],
|
||||
options: {
|
||||
page: 1, // 當前頁
|
||||
itemsPerPage: 10, // 每頁條數
|
||||
sortBy: [],
|
||||
sortDesc: []
|
||||
},
|
||||
search: {
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
guadanUser: null,
|
||||
guaDanOrderNo: null,
|
||||
},
|
||||
total: 0,
|
||||
loading: false,
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeViews() {
|
||||
console.log("changeViews");
|
||||
this.$emit('custom-event', { action: 'new', item: "1" });
|
||||
},
|
||||
resetTableOptions() {
|
||||
this.options = {
|
||||
page: 1,
|
||||
itemsPerPage: 10,
|
||||
sortBy: [],
|
||||
sortDesc: []
|
||||
};
|
||||
},
|
||||
handleSearch() {
|
||||
|
||||
let orderNo = this.search.guaDanOrderNo;
|
||||
if (orderNo) {
|
||||
orderNo = orderNo.replace(/\s+/g, '');
|
||||
this.search.guaDanOrderNo = orderNo;
|
||||
}
|
||||
const val = this.search.guadanUser;
|
||||
|
||||
// 驗證是否包含空格
|
||||
if (val && /\s/.test(val)) {
|
||||
this.$refs.messageModal.open({
|
||||
message: '掛單登記人不能包含空格'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 驗證長度
|
||||
if (val && val.length > 10) {
|
||||
this.$refs.messageModal.open({
|
||||
message: '掛單登記人不能超過 10 個字'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.resetTableOptions();
|
||||
},
|
||||
clearSearch() {
|
||||
this.search.startDate = null;
|
||||
this.search.endDate = null;
|
||||
this.search.guadanUser = null;
|
||||
this.search.guaDanOrderNo = null;
|
||||
this.resetTableOptions();
|
||||
},
|
||||
getGuadanOrder() {
|
||||
if (this.loading) return;
|
||||
axios.post(HTTP_HOST + 'api/guadan/list', {
|
||||
startDate: this.search.startDate,
|
||||
endDate: this.search.endDate,
|
||||
guadanUser: this.search.guadanUser,
|
||||
guaDanOrderNo: this.search.guaDanOrderNo,
|
||||
page: this.options.page,
|
||||
pageSize: this.options.itemsPerPage
|
||||
})
|
||||
.then((res) => {
|
||||
this.items = res.data.data;
|
||||
this.total = res.data.total;
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
deleteGuadanOrder(order) {
|
||||
this.$refs.confirmModal.open({
|
||||
message: '確認取消掛單?',
|
||||
onConfirm: () => {
|
||||
axios.post(HTTP_HOST + 'api/guadan/cancel', null, {
|
||||
params: {
|
||||
uuid: order.uuid
|
||||
}
|
||||
}).then((res) => {
|
||||
this.items = this.items.filter(a => a.uuid != order.uuid)
|
||||
this.$refs.messageModal.open({
|
||||
message: '取消成功'
|
||||
})
|
||||
}).catch((error) => {
|
||||
this.$refs.messageModal.open({
|
||||
message: error.response?.data || '取消失敗'
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getGuadanOrder(); // 監聽分頁、排序變化,自動載入數據
|
||||
},
|
||||
deep: true,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getGuadanOrder();
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.options.itemsPerPage)
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in new issue
Block a user