Files
2026-10-30 17:47:01 +08:00

348 lines
15 KiB
Plaintext

<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="shuwen.aspx.cs" Inherits="admin_shuwen_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 d-flex align-items-center gap-2">
<v-text-field v-model="query.start_date" label="活動起始日" type="date" dense outlined></v-text-field>
<v-text-field v-model="query.end_date" label="活動結束日" type="date" dense outlined></v-text-field>
<button class="btn btn-primary" @click.prevent="queryActivity">查詢</button>
<%--<span>查看疏文</span>
<select v-model="currentActivityNum" @change="onActivityChange" class="form-select" style="width: auto;">
<option value="">請選擇要查看的活動</option>
<option v-for="activity in activityList" :value="activity.num" :key="activity.num">
{{activity.subject}}
</option>
</select>--%>
<h4>
<%--<span v-if="currentActivityNum">{{latest ? '當前疏文是最新版本': '當前疏文不是最新版本'}}</span>--%>
</h4>
<%-- </div>--%>
<%-- <div class="">
<a class="btn btn-outline-primary btn-print" @click="updateShuWen" v-if="currentActivityNum&&!latest">{{updateShuWenLoading ? '更新中': '更新疏文'}}</a>
<a :href="'<%=ResolveUrl("~/api/shuwen/download")%>?activitynum='+currentActivityNum" class="btn btn-outline-primary btn-print">下載疏文Word檔</a>
</div>--%>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!--要同時可以選多個活動,因為會拆成捐贈跟報名 ,還要能設定消災跟超薦的區分-->
<template>
<v-container>
<v-row class="mb-0 mt-4">
<v-col cols="12" md="3">
<v-text-field v-model="query.xStart" label="消災列印編號前置" type="text" dense outlined></v-text-field>
</v-col>
<v-col cols="12" md="3">
<v-text-field v-model="query.sStart" label="超薦列印編號前置" type="text" dense outlined></v-text-field>
</v-col>
<v-col cols="12" md="2">
<button class="btn btn-primary" @click.prevent="processShuwen">產生疏文</button>
</v-col>
</v-row>
<v-data-table
v-model="data_table.selected"
:items="data_table.list"
:search-props="search"
item-key="num"
:options.sync="options"
:headers="data_table.header"
:footer-props="data_table.footer"
:server-items-length="data_table.count"
:loading="data_table.loading"
:single-select="data_table.singleSelect"
show-select
hide-default-footer
:page.sync="data_table.page"
:items-per-page.sync="data_table.pageSize"
class="elevation-1">
<template #item.up_time="{ item }" >
{{ item.up_time|timeString('YYYY/MM/DD') }}
</template>
<template #item.u_name="{ item }" >
{{ item.u_name }}
</template>
<template #item.status="{ item }" >
<a v-if="item.f_num != null && item.activity_num != null && item.status == 0" @click="checkIn(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-account"></i>報到</a>
<a v-if="item.f_num != null && item.activity_num != null && item.status == 1" class="btn btn-outline-secondary btn-sm opacity-50" style="pointer-events: none" ><i class="mdi mdi-account-check"></i>已報到</a>
</template>
</v-data-table>
<v-container>
<v-row class="align-baseline" wrap>
<v-col cols="12" md="9">
<v-pagination
v-model="data_table.page"
:length="pageCount">
</v-pagination>
</v-col>
<v-col class="text-truncate text-right" cols="12" md="2">
共 {{ data_table.count }} 筆, 頁數:
</v-col>
<v-col cols="6" md="1">
<v-text-field
v-model="data_table.page"
type="number"
hide-details
dense
min="1"
:max="pageCount"
@input="data_table.page = parseInt($event, 10)"
></v-text-field>
</v-col>
</v-row>
</v-container>
</v-container>
<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>
</template>
<%--<div v-if="currentActivityNum">
<div><h2 style="text-align:center">消災疏文</h2></div>
<div v-for="(item, index) in ShuWenJson?.xiaozai" :key="Object.keys(item)[0] + 'xz' + index">
<h4>報名信眾:{{ item[Object.keys(item)[0]].user.name }}</h4>
<ul>
<li>{{ item[Object.keys(item)[0]]['biaoti'].join(' ') }}</li>
</ul>
<hr />
</div>
<div><h2 style="text-align:center">超薦疏文</h2></div>
<div v-for="(item, index) in ShuWenJson?.chaodu" :key="Object.keys(item)[0] + 'cj' + index">
<h4>報名信眾:{{ item[Object.keys(item)[0]].user.name }}</h4>
<ul>
<li>
<div v-for="cdItem in item[Object.keys(item)[0]].entry">
<p>
{{cdItem.biaoti.join(' ')}}
</p>
<p>
陽上---{{cdItem.yangshang}}
</p>
<hr />
</div></li>
</ul>
<hr/>
</div>
</div>--%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
<script>
Vue.filter('timeString', function (value, myFormat) {
return value == null || value == "" ? "" : moment(value).format(myFormat || 'YYYY-MM-DD, HH:mm:ss');
});
let VueApp = new Vue({
el: '#app',
vuetify: new Vuetify(vuetify_options),
data() {
return {
currentActivityNum: '<%= Request["num"]%>',
activityList: [],
ShuWenJson: {},
ShuWenItem: '',
updateShuWenLoading: false,
latest: false,
options: { multiSort: false },
snackbar: {
show: false,
text: "",
},
data_table: {
loading: false,
list: [],
selected: [],
singleSelect: false,
count: 0,
page: 1,
pageSize: 10,
header: [
{ text: '法會名稱', value: 'subject', align: 'start' },
{ text: '開始日期', value: 'startDate' },
{ text: '結束日期', value: 'endDate' },
//{ text: '', value: 'slot_btn', sortable: false, align: 'end' }
],
footer: {
showFirstLastPage: true,
itemsPerPageOptions: [5, 10, 20, 30],
},
},
query: {
start_date: '',
end_date: '',
xStart: '',//消災
sSatrt: ''//超薦
},
search: {},
}
},
methods: {
processShuwen() {
// console.log(this.data_table.selected)
if (this.query.xStart==="" || this.query.sStart==="") {
this.snackbar.text = "請輸入消災及超薦牌位列印編號前置碼";
this.snackbar.show = true;
return;
}
if (this.data_table.selected.length===0) {
this.snackbar.text = "請勾選要列印的法會";
this.snackbar.show = true;
return;
}
let activityNums = []
this.data_table.selected.forEach((x) => {
activityNums.push(x.num);
});
if (activityNums && activityNums.length>0) {
axios.post(HTTP_HOST + 'api/shuwen/RenderShuWenByGong', {
activitynum: activityNums.join(","),
xStart: this.query.xStart,sStart:this.query.sStart
})
.then(res => {
if (res.status == 200) {
//const blob = new Blob([res.data.filePath]);
//const url = window.URL.createObjectURL(blob);
// 2. Create a hidden anchoring element
const link = document.createElement('a');
link.href = res.data.filePath;
// 3. Define the desired filename
link.setAttribute('download', 'template.docx');
// 4. Append to DOM, click it to trigger save, and clean up
document.body.appendChild(link);
link.click();
// Free up memory and remove temporary elements
link.remove();
//window.URL.revokeObjectURL(url);
}
this.data_table.loading = false;
})
.catch(err => {
if (err.response && err.response.status === 400) {
alert('錯誤訊息:' + err.response.data.Message);
this.snackbar.text = '錯誤訊息:' + err.response.data.Message
} else {
//alert('發生錯誤:' + err.response.data.Message);
//console.log(err);
this.snackbar.text = '發生錯誤:'+err;// + err.response.data.Message
}
this.snackbar.show = true;
});
}
},
queryActivity() {//列出區間內的活動/法會
this.data_table.loading=true
axios.post(HTTP_HOST + 'api/activity/GetListNew', { startDate_solar: this.query.start_date, endDate_solar: this.query.end_date }, { params: { page: 1, pageSize: 10000, sortDesc: false } })
.then(response => {
// console.log("queryActivity:", response.data.list);
this.data_table.list = response.data.list;
this.data_table.count = response.data.count;
})
.catch(error => {
this.snackbar.text = '發生錯誤:' + error.response.data.Message
this.snackbar.show = true;
}).finally(() => {
this.data_table.loading = false;
})
},
initActivity() {
//axios.get(HTTP_HOST + 'api/activity')
// .then(response => {
// this.activityList = response.data;
// })
// .catch(error => {
// console.log(error)
// })
},
onActivityChange() {
this.latest = false
this.getShuWen();
},
updateShuWen() {
this.updateShuWenLoading = true;
axios.get(HTTP_HOST + 'api/shuwen/StartGenerate', {
params: {
activitynum: this.currentActivityNum
}
})
.then(res => {
this.getShuWen();
})
.catch(err => {
alert('發生錯誤:' + (err.response?.data?.Message || '無法啟動任務'));
}).finally(() => {
this.updateShuWenLoading = false;
});
},
getShuWen() {
if (this.currentActivityNum) {
axios.post(HTTP_HOST + 'api/shuwen/RenderShuWenByGong', {
params: {
activitynum: this.currentActivityNum
}
})
.then(res => {
var data = res.data
this.ShuWenItem = data.data
this.latest = data.latest
if (this.ShuWenItem == null) {
this.ShuWenJson = {}
return;
}
this.ShuWenJson = this.ShuWenItem?.shuWenList
? JSON.parse(this.ShuWenItem.shuWenList)
: { xiaozai: [], chaodu: [] }; // 默认空对象
})
.catch(err => {
if (err.response && err.response.status === 400) {
alert('錯誤訊息:' + err.response.data.Message);
} else {
alert('發生錯誤');
}
});
}
}
},
mounted() {
this.initActivity();
if (this.currentActivityNum) {
this.getShuWen()
}
},
computed: {
pageCount() {
return Math.ceil(this.data_table.count / this.data_table.pageSize)
},
}
})
</script>
</asp:Content>