682 lines
29 KiB
Plaintext
682 lines
29 KiB
Plaintext
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="shuwen.aspx.cs" Inherits="admin_print_shuwen" %>
|
|
|
|
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
|
</asp:Content>
|
|
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
|
<div class="mb-2 mb-sm-0">
|
|
<label>請選擇需要列印的活動(法會)</label>
|
|
<div class="input-group mb-3" data-search-control="search2" @click="search_show(search_dialog.controls.search2)">
|
|
<input class="form-control search-text" type="text" readonly
|
|
id="activity_txt" runat="server" placeholder="活動(法會)" value="">
|
|
<asp:HiddenField ID="activity" runat="server" Value="" />
|
|
<button class="btn btn-outline-secondary" type="button">
|
|
<i class="mdi mdi-view-list-outline"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</asp:Content>
|
|
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
|
<div id="content" class="container-md">
|
|
<v-tabs
|
|
v-model="tab"
|
|
background-color="primary"
|
|
centered
|
|
dark
|
|
icons-and-text>
|
|
<v-tabs-slider></v-tabs-slider>
|
|
|
|
<v-tab href="#疏文">
|
|
疏文
|
|
<v-icon>mdi-book-open-outline</v-icon>
|
|
</v-tab>
|
|
|
|
<v-tab href="#打齋">
|
|
打齋
|
|
<v-icon>mdi-bowl-mix-outline</v-icon>
|
|
</v-tab>
|
|
|
|
<v-tab href="#點燈">
|
|
點燈
|
|
<v-icon>mdi-dome-light</v-icon>
|
|
</v-tab>
|
|
<v-tab href="#供佛">
|
|
供佛
|
|
<v-icon>mdi-weather-cloudy</v-icon>
|
|
</v-tab>
|
|
<v-tab href="#供僧">
|
|
供僧
|
|
<v-icon>mdi-account-circle-outline</v-icon>
|
|
</v-tab>
|
|
<v-tab href="#供花果">
|
|
供花果
|
|
<v-icon>mdi-flower</v-icon>
|
|
</v-tab>
|
|
<v-tab href="#普桌">
|
|
普桌
|
|
<v-icon>mdi-desk</v-icon>
|
|
</v-tab>
|
|
</v-tabs>
|
|
|
|
<v-tabs-items v-model="tab">
|
|
<v-tab-item
|
|
value="疏文">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="getShuwen('消')">消災疏文</button>
|
|
<button type="button" class="btn btn-primary" @click.prevent="getShuwen('超')">超薦疏文</button>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="打齋">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('齋')">列印</button>(請先勾選歸屬打齋功德項目)
|
|
<v-data-table
|
|
v-model="fast.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="fast.header"
|
|
:loading="fast.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
<%-- <template #item.print="{item}">
|
|
<v-icon color="blue" class="mr-2" @click="print(item);" >
|
|
mdi-printer
|
|
</v-icon>
|
|
</template>--%>
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="點燈">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('燈')">列印</button>(請先勾選歸屬點燈功德項目)
|
|
<v-data-table
|
|
v-model="lighter.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="lighter.header"
|
|
:loading="lighter.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="供佛">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('佛')">列印</button>(請先勾選歸屬供佛功德項目)
|
|
<v-data-table
|
|
v-model="buda.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="buda.header"
|
|
:loading="buda.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="供僧">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('僧')">列印</button>(請先勾選歸屬供僧功德項目)
|
|
<v-data-table
|
|
v-model="monk.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="monk.header"
|
|
:loading="monk.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="供花果">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('花')">列印</button>(請先勾選歸屬供花果功德項目)
|
|
<v-data-table
|
|
v-model="fruit.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="fruit.header"
|
|
:loading="fruit.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
<v-tab-item
|
|
value="普桌">
|
|
<v-card flat>
|
|
<v-card-text>
|
|
<button type="button" class="btn btn-primary" @click.prevent="print('普')">列印</button>(請先勾選歸屬普桌功德項目)
|
|
<v-data-table
|
|
v-model="desk.selected"
|
|
:items="actItems"
|
|
item-key="num"
|
|
:headers="desk.header"
|
|
:loading="desk.loading"
|
|
hide-default-footer
|
|
:items-per-page="-1"
|
|
show-select
|
|
class="elevation-1">
|
|
</v-data-table>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-tab-item>
|
|
|
|
</v-tabs-items>
|
|
|
|
</div>
|
|
|
|
<v-dialog v-model="search_dialog.show" max-width="700px">
|
|
<v-card>
|
|
<v-card-title class="justify-space-between grey lighten-2">
|
|
查詢:{{search_dialog.current.title}}
|
|
<v-btn icon @click="search_dialog.show=false; search_dialog.page = 1;"><v-icon>mdi-close</v-icon></v-btn>
|
|
</v-card-title>
|
|
<v-card-text >
|
|
<v-row>
|
|
<v-col v-for="item in search_dialog.current.keys"
|
|
:cols="search_dialog.current.keys.length>1?6:12" >
|
|
<v-text-field v-model="item.value" :label="item.title" v-if="item.visible===undefined || item.visible==true "></v-text-field>
|
|
</v-col>
|
|
<v-col cols="12" class="text-end">
|
|
<v-btn color="primary" elevation="0" @click="search_get()">查詢</v-btn>
|
|
<v-btn elevation="0" @click="search_clear()">清除條件</v-btn>
|
|
</v-col>
|
|
</v-row>
|
|
<v-data-table
|
|
:headers="search_headers()"
|
|
:items="search_dialog.list"
|
|
:footer-props="search_dialog.footer"
|
|
:items-per-page="10"
|
|
:server-items-length="search_dialog.count"
|
|
:page.sync="search_dialog.page"
|
|
:options.sync="options"
|
|
@click:row="search_select"
|
|
:loading="search_dialog.loading"
|
|
></v-data-table>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-snackbar
|
|
v-model="snackbar.show"
|
|
timeout="2000"
|
|
>
|
|
{{ snackbar.text }}
|
|
<template v-slot:action="{ attrs }">
|
|
<v-btn
|
|
text
|
|
v-bind="attrs"
|
|
@click="snackbar.show = false"
|
|
>
|
|
關閉
|
|
</v-btn>
|
|
</template>
|
|
</v-snackbar>
|
|
</asp:Content>
|
|
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
|
|
</asp:Content>
|
|
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
|
|
<script>
|
|
let VueApp = new Vue({
|
|
el: '#app',
|
|
vuetify: new Vuetify(vuetify_options),
|
|
data() {
|
|
return {
|
|
tab: "疏文",
|
|
canPrint: false,
|
|
options: {},
|
|
activity_list: [],
|
|
actItems: [],
|
|
snackbar: {
|
|
show: false,
|
|
text: "",
|
|
},
|
|
fast: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '編號', value: 'num' },
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
lighter: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
buda: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
monk: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
fruit: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
desk: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
order_no: "",
|
|
header: [
|
|
{ text: '功德項目', value: 'subject' },
|
|
],
|
|
},
|
|
order_data: {
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
header: [
|
|
{ text: '功德項目', value: 'act_item_selected.text' },
|
|
{ text: '數量', value: 'files' },
|
|
{ text: '列印', value: 'print' }
|
|
],
|
|
|
|
},
|
|
print_data: {
|
|
item: [],
|
|
loading: false,
|
|
list: [],
|
|
selected: [],
|
|
count: 0,
|
|
header: [
|
|
{ text: '報名單號', value: 'order_no' },
|
|
{ text: '列印編號', value: 'print_id' },
|
|
{ text: '已列印', value: 'isPrinted' }
|
|
],
|
|
print_dialog: { show: false }
|
|
},
|
|
search_dialog: {
|
|
controls: {
|
|
search2: {
|
|
id: 'search2',
|
|
title: '活動(法會)',
|
|
text_prop: 'subject',
|
|
value_prop: 'num',
|
|
keys: [
|
|
{ id: 'num', title: '編號', value: '' },
|
|
{ id: 'subject', title: '活動(法會)名稱', value: '' },
|
|
],
|
|
api_url: HTTP_HOST + 'api/activity/GetList',
|
|
columns: [
|
|
{ id: 'num', title: '編號' },
|
|
{ id: 'subject', title: '活動(法會)名稱' },
|
|
],
|
|
selected: {},
|
|
select(item, t) {
|
|
|
|
|
|
}
|
|
},
|
|
},
|
|
show: false,
|
|
current: {},
|
|
list: [],
|
|
count: 0,
|
|
page: 1,
|
|
loading: false,
|
|
footer: {
|
|
showFirstLastPage: true,
|
|
disableItemsPerPage: true,
|
|
itemsPerPageAllText: '',
|
|
itemsPerPageText: '',
|
|
//'items-per-page-options': [10, 20, 30, 40, 50, 100]
|
|
},
|
|
},
|
|
selected_activity: '-1',
|
|
search: {
|
|
kind: 0,
|
|
subject: '',
|
|
},
|
|
snackbar: {
|
|
show: false,
|
|
text: "",
|
|
},
|
|
}
|
|
},
|
|
computed: {
|
|
processedItems() {
|
|
return this.print_data.list.map(item => ({
|
|
...item,
|
|
compositeKey: `${item.order_no}_${item.num.toString()}_${item.print_id}`
|
|
}))
|
|
}
|
|
},
|
|
methods: {
|
|
print(item) {
|
|
let curr = this.search_dialog.current;
|
|
let target = $(`[data-search-control=${curr.id}]`)
|
|
let searchData = { activity_num: target.children("input:hidden").val(), mode: item, actItems: [] }
|
|
if (searchData.activity_num == null || searchData.activity_num=="") {
|
|
this.snackbar.text = "請先選擇法會"
|
|
this.snackbar.show = true
|
|
return false;
|
|
}
|
|
switch (item) {
|
|
case "齋":
|
|
Object.assign(searchData.actItems, this.fast.selected.map(item => item.num))
|
|
break
|
|
case "佛":
|
|
Object.assign(searchData.actItems, this.buda.selected.map(item => item.num))
|
|
break
|
|
case "僧":
|
|
Object.assign(searchData.actItems, this.monk.selected.map(item => item.num))
|
|
break
|
|
case "花":
|
|
Object.assign(searchData.actItems, this.fruit.selected.map(item => item.num))
|
|
break
|
|
case "普":
|
|
Object.assign(searchData.actItems, this.desk.selected.map(item => item.num))
|
|
break
|
|
case "燈":
|
|
Object.assign(searchData.actItems, this.lighter.selected.map(item => item.num))
|
|
break
|
|
}
|
|
if (searchData.actItems.length == 0) {
|
|
this.snackbar.text = "請勾選歸屬功德項目"
|
|
this.snackbar.show = true
|
|
return false;
|
|
}
|
|
axios
|
|
.post(HTTP_HOST + 'api/shuwen/PrintItemReport', searchData, { responseType: 'blob' })
|
|
.then(response => {
|
|
// 1. Create a dynamic URL object from the binary blob
|
|
const blob = new Blob([response.data], {
|
|
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
});
|
|
const fileUrl = window.URL.createObjectURL(blob);
|
|
|
|
// 2. Create a temporary 'a' element to trigger download
|
|
const link = document.createElement('a');
|
|
link.href = fileUrl;
|
|
|
|
// 3. Set desired file name
|
|
link.setAttribute('download', `${searchData.activity_num}_${searchData.mode}.docx`);
|
|
|
|
// 4. Append, click and cleanup
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
window.URL.revokeObjectURL(fileUrl); // Free up memory allocation
|
|
})
|
|
|
|
},
|
|
getShuwen(mode) {
|
|
let curr = this.search_dialog.current;
|
|
let target = $(`[data-search-control=${curr.id}]`)
|
|
let searchData = { activity_num: target.children("input:hidden").val(), mode: mode }
|
|
if (searchData.activity_num == null || searchData.activity_num == "") {
|
|
this.snackbar.text = "請選擇法會"
|
|
this.snackbar.show = true
|
|
return false;
|
|
}
|
|
try {
|
|
axios
|
|
.post(HTTP_HOST + 'api/shuwen/GetShuwenData', searchData, { responseType: 'blob' })
|
|
.then(response => {
|
|
// 1. Create a dynamic URL object from the binary blob
|
|
const blob = new Blob([response.data], {
|
|
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
});
|
|
const fileUrl = window.URL.createObjectURL(blob);
|
|
|
|
// 2. Create a temporary 'a' element to trigger download
|
|
const link = document.createElement('a');
|
|
link.href = fileUrl;
|
|
|
|
// 3. Set desired file name
|
|
link.setAttribute('download', `${searchData.activity_num}_${searchData.mode}.docx`);
|
|
|
|
// 4. Append, click and cleanup
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
window.URL.revokeObjectURL(fileUrl); // Free up memory allocation
|
|
})
|
|
|
|
} catch (error) {
|
|
console.error('Error downloading the file:', error);
|
|
alert('Failed to download file.');
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
getItemCount(item) {
|
|
//console.log("getItemCount:",item[0]?.list.length)
|
|
return item[0]?.list.length
|
|
},
|
|
search_show(curr) {
|
|
this.search_dialog.current = curr;
|
|
this.search_clear()
|
|
//this.search_get()//清除完自動會重抓, 故取消
|
|
this.search_dialog.show = true;
|
|
|
|
},
|
|
search_clear() {
|
|
if (!this.search_dialog.current.keys) return;
|
|
this.search_dialog.current.keys.forEach((t, i) => { t.value = '' })
|
|
this.search_get()
|
|
},
|
|
search_get() {
|
|
if (!this.search_dialog.current.keys) return;
|
|
let api_url = this.search_dialog.current.api_url;
|
|
let keys = this.search_dialog.current.keys;
|
|
//const { page, itemsPerPage } = this.options
|
|
//const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
|
this.search_dialog.page = this.options.page ?? 1
|
|
let params = { page: this.search_dialog.page, pageSize: 10 };//url params
|
|
var search = {};//post body
|
|
keys.forEach((t, i) => {
|
|
search[t.id] = t.value;
|
|
});
|
|
if (this.search_dialog.current.id == 'search5') {
|
|
search['num'] = this.activity_id;
|
|
}
|
|
if (this.search_dialog.current.id == 'search4') {
|
|
search['num'] = this.follower_id;
|
|
}
|
|
if (this.search_dialog.current.id == 'search6') {
|
|
search['num'] = this.follower_id;
|
|
}
|
|
if (this.search_dialog.current.id == 'search7' || this.search_dialog.current.id == 'search8') {
|
|
search['num'] = this.follower_id;
|
|
}
|
|
//console.log("search_get", api_url, search, params, this.options);
|
|
this.search_dialog.loading = true
|
|
axios.post(api_url, search, { params: params })
|
|
.then(response => {
|
|
this.search_dialog.list = response.data.list
|
|
this.search_dialog.count = response.data.count
|
|
this.search_dialog.loading = false
|
|
})
|
|
.catch(error => {
|
|
console.log(error)
|
|
this.search_dialog.list = []
|
|
this.search_dialog.count = 0
|
|
this.search_dialog.loading = false
|
|
this.snackbar.text = "錯誤:" + error
|
|
this.snackbar.show = true
|
|
})
|
|
},
|
|
search_headers() {
|
|
if (!this.search_dialog.current.columns) return;
|
|
r = [];
|
|
this.search_dialog.current.columns.forEach((t, i) => {
|
|
//console.log("search_headers:", t, i);
|
|
r.push({
|
|
text: t.title,
|
|
width: t.width,
|
|
align: 'start',
|
|
sortable: false,
|
|
value: t.id,
|
|
})
|
|
})
|
|
return r
|
|
},
|
|
search_select(row) {
|
|
let curr = this.search_dialog.current;
|
|
let target = $(`[data-search-control=${curr.id}]`);
|
|
curr.selected = row;
|
|
//牌位
|
|
if (curr.id == 'search7') {
|
|
this.editedItem.f_num_tablet = curr.selected[curr.text_prop];
|
|
} else if (curr.id == 'search8') {
|
|
this.editedItem.from_id_tablet = curr.selected[curr.text_prop];
|
|
} else {
|
|
target.children("input.search-text").val(curr.selected[curr.text_prop])//text
|
|
target.children("input:hidden").val(curr.selected[curr.value_prop])//value
|
|
}
|
|
if (curr.select instanceof Function) {
|
|
curr.select(this.editedItem, row);
|
|
}
|
|
this.search_dialog.show = false;
|
|
this.search_dialog.page = 1;
|
|
this.get_activity()
|
|
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
|
},
|
|
getActItem() {
|
|
const params = {
|
|
page: 1, pageSize: 1000
|
|
};
|
|
axios
|
|
.post(HTTP_HOST + 'api/activity/GetItemList', {}, { params: params })
|
|
.then(response => {
|
|
console.log("getActItem:", response);
|
|
if (response.status == 200) {
|
|
Object.assign(this.actItems, response.data.list)
|
|
}
|
|
})
|
|
},
|
|
|
|
get_activity() {
|
|
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
|
const params = {
|
|
sortBy: "", sortDesc: false,
|
|
page: page, pageSize: itemsPerPage
|
|
};
|
|
//const params = {
|
|
// page: 1, pageSize: 10
|
|
//};
|
|
let curr = this.search_dialog.current;
|
|
let target = $(`[data-search-control=${curr.id}]`)
|
|
this.search = { num: target.children("input:hidden").val() }
|
|
this.order_data.loading = true
|
|
axios
|
|
.post(HTTP_HOST + 'api/activity/GetActRelaList', this.search, { params: params })
|
|
.then(response => {
|
|
//console.log("GetActRelaList:", response);
|
|
this.order_data.list = response.data.list
|
|
this.order_data.list.forEach(val => {
|
|
|
|
val.files.forEach(y => {
|
|
y.list.forEach(z => {
|
|
if (z.printed_files.includes(y.num.toString())) {
|
|
z.isPrinted = true
|
|
}
|
|
}
|
|
)
|
|
|
|
})
|
|
|
|
//if(val.files.list) val.files.num
|
|
});
|
|
this.order_data.count = response.data.count;
|
|
this.order_data.loading = false
|
|
})
|
|
.catch(error => console.log(error))
|
|
},
|
|
},
|
|
mounted() {
|
|
//this.get_activity()
|
|
this.getActItem();
|
|
},
|
|
watch: {
|
|
options: {
|
|
handler() {
|
|
this.search_get()
|
|
},
|
|
deep: true,
|
|
},
|
|
//selected_activity(newValue, oldValue) {
|
|
// const params = {
|
|
// page: 1, pageSize: 100
|
|
// };
|
|
// //console.log("selected_activity:", newValue)
|
|
// if (newValue !== oldValue) {
|
|
// axios
|
|
// .post(HTTP_HOST + 'api/orderdetail/GetList', { activity_num: this.selected_activity }, { params: params })
|
|
// .then(response => {
|
|
// this.order_data.list = response.data.list
|
|
// })
|
|
// .catch(error => console.log(error))
|
|
// }
|
|
//},
|
|
//'order_data.selected'(newValue, oldValue) {
|
|
// console.log(newValue)
|
|
//}
|
|
}
|
|
})
|
|
</script>
|
|
</asp:Content>
|
|
|