migrate to new git
This commit is contained in:
217
web/admin/activity/index.aspx
Normal file
217
web/admin/activity/index.aspx
Normal file
@@ -0,0 +1,217 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_activity_index" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<div class="mb-2 mb-sm-0">
|
||||
<a href="reg.aspx" class="btn btn-primary">
|
||||
<i class="mdi mdi-plus"></i>新增
|
||||
</a>
|
||||
<a @click="deleteAll" class="btn btn-outline-danger" title="刪除勾選的資料" ><i class="mdi mdi-trash-can"></i> 刪除勾選</a>
|
||||
</div>
|
||||
<div class="">
|
||||
|
||||
<asp:LinkButton ID="excel" runat="server" Visible="false" CssClass="btn btn-outline-primary" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
|
||||
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<%--<link href="<%=ResolveUrl("~/js/vuetify_ez.css")%>" rel="stylesheet" />--%>
|
||||
<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 {
|
||||
options: { multiSort: false },
|
||||
data_table: {
|
||||
loading: true,
|
||||
list: [],
|
||||
selected: [],
|
||||
singleSelect: false,
|
||||
count: 0,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
header: [
|
||||
{ text: '活動分類', value: 'kindsTxt' },
|
||||
{ text: '活動名稱', value: 'subject', align: 'start' },
|
||||
{ text: '開始日期', value: 'start_date' },
|
||||
{ text: '結束日期', value: 'end_date' },
|
||||
{ text: '報名截止日期', value: 'due_date' },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' }
|
||||
],
|
||||
footer:{
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
kind: 0,
|
||||
subject: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getDefault()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getDefault(clearpage = false) {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: clearpage ? '1' : page, pageSize: itemsPerPage
|
||||
};
|
||||
this.data_table.loading = true
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/GetList', this.search, { params: params })
|
||||
.then(response => {
|
||||
this.data_table.list = response.data.list
|
||||
this.data_table.count = response.data.count;
|
||||
this.data_table.loading = false
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
},
|
||||
editItem(item) {
|
||||
console.log("edit", item);
|
||||
},
|
||||
deleteItem(item) {
|
||||
if (confirm('是否確定刪除此筆資料?')) {
|
||||
const index = this.data_table.list.indexOf(item)
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/' + item.num)
|
||||
.then(response => {
|
||||
console.log("del", item);
|
||||
this.data_table.list.splice(index, 1);
|
||||
this.data_table.count = this.data_table.list.length
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteAll() {
|
||||
if (confirm('是否確定刪除已勾選的資料?')) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/Delete/' + this.data_table.selected.map(x => x.num))
|
||||
.then(response => {
|
||||
//console.log("delAll");
|
||||
|
||||
//for (var i = 0; i < this.data_table.selected.length; i++) {
|
||||
// const index = this.data_table.list.indexOf(this.data_table.selected[i]);
|
||||
// this.data_table.list.splice(index, 1);
|
||||
//}
|
||||
//this.data_table.selected = [];
|
||||
//this.data_table.count = this.data_table.list.length
|
||||
location.reload();
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
},
|
||||
btn_search() {
|
||||
this.getDefault(true)
|
||||
},
|
||||
btn_all() {
|
||||
clearObjProps(this.search);
|
||||
this.btn_search()
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.data_table.count / this.data_table.pageSize)
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid">
|
||||
<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.start_date="{ item }" >
|
||||
<div v-if="item.startDate_solar !=null && item.startDate_solar !=''"><span class="badge bg-secondary">國曆</span> {{ item.startDate_solar|timeString('YYYY/MM/DD') }} </div>
|
||||
<div v-if="item.startDate_lunar !=null && item.startDate_lunar !=''"><span class="badge bg-secondary">農曆</span> {{ item.startDate_lunar|timeString('YYYY/MM/DD') }} </div>
|
||||
</template>
|
||||
<template #item.end_date="{ item }" >
|
||||
<div v-if="item.endDate_solar !=null && item.endDate_solar !=''"><span class="badge bg-secondary">國曆</span> {{ item.endDate_solar|timeString('YYYY/MM/DD') }} </div>
|
||||
<div v-if="item.endDate_lunar !=null && item.endDate_lunar !=''"><span class="badge bg-secondary">農曆</span> {{ item.endDate_lunar|timeString('YYYY/MM/DD') }} </div>
|
||||
</template>
|
||||
<template #item.due_date="{ item }" >
|
||||
{{ item.dueDate|timeString('YYYY/MM/DD') }}
|
||||
</template>
|
||||
<template #item.slot_btn="{ item }">
|
||||
<a :href="'reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a>
|
||||
<a @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></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>
|
||||
</div>
|
||||
<div id="print_data">
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" runat="Server">
|
||||
<div id="search_panel" alt="查詢公告資料">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">分類</label>
|
||||
<asp:DropDownList ID="s_kind" runat="server" CssClass="form-select" v-model="search.kind" >
|
||||
</asp:DropDownList>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">項目名稱</label>
|
||||
<input type="text" v-model="search.subject" class="form-control" placeholder="可輸入關鍵字查詢">
|
||||
</div>
|
||||
<div class="mb-3 p-2 border-top">
|
||||
<a @click="btn_search" class="btn btn-outline-primary"><i class="mdi mdi-filter"></i> 搜尋</a>
|
||||
<a class="btn btn-outline-secondary" @click="btn_all"><i class="mdi mdi-filter-remove"></i> 所有資料</a>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
70
web/admin/activity/index.aspx.cs
Normal file
70
web/admin/activity/index.aspx.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static TreeView;
|
||||
|
||||
public partial class admin_activity_index : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
BuildKind();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 分類
|
||||
|
||||
|
||||
|
||||
public void BuildKind()
|
||||
{
|
||||
s_kind.Items.Clear();
|
||||
s_kind.Items.Add(new ListItem("", ""));
|
||||
|
||||
//buildMultiKind(s_kind, "activity_kind", 0, "", 1, Model.activity.KindLevelMax);
|
||||
var qry1 = new TreeView().get_data2(_db.activity_kind.Select(o => new TreeItem()
|
||||
{
|
||||
kind = o.kind,
|
||||
num = o.num,
|
||||
root = o.root,
|
||||
range = o.range,
|
||||
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
|
||||
if (qry1.Count() > 0)
|
||||
foreach (var qq in qry1)
|
||||
s_kind.Items.Add(new ListItem(new TreeView().RptDash(qq.Level) + qq.kind, qq.num.ToString()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 匯出Excel
|
||||
|
||||
protected void excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
//請參考訂單系統的匯出
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
476
web/admin/activity/index2.aspx
Normal file
476
web/admin/activity/index2.aspx
Normal file
@@ -0,0 +1,476 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index2.aspx.cs" Inherits="admin_activity_index2" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<div class="mb-2 mb-sm-0">
|
||||
<ul class="nav ps-0">
|
||||
<li class="nav-item pe-3">
|
||||
<select class="form-select" v-model="search.kind" @change="btn_search">
|
||||
<option value="">選擇分類</option>
|
||||
<option v-for="item in itemKindList" :value="item.num">{{item.kind}}</option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="nav-item pe-1">
|
||||
<a href="item_reg.aspx" class="btn btn-primary">
|
||||
<i class="mdi mdi-plus"></i>新增
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item pe-1">
|
||||
<a @click="deleteAll" class="btn btn-outline-danger" title="刪除勾選的資料" ><i class="mdi mdi-trash-can"></i> 刪除勾選</a>
|
||||
</li>
|
||||
</ul>
|
||||
<%-- <div class="input-group mb-3" data-search-control="search1" @click="search_show(search_dialog.controls.search1)">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
id="kind_txt" runat="server" placeholder="品項分類選擇" value="">
|
||||
<input type="hidden" v-model="search.kind">
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>--%>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
|
||||
<asp:LinkButton ID="excel" runat="server" CssClass="btn btn-outline-success" OnClick="excel_Click"><span class="fa-solid fa-file-excel"></span> 匯出Excel</asp:LinkButton>
|
||||
|
||||
</div>
|
||||
</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 {
|
||||
options: { multiSort: false },
|
||||
data_table: {
|
||||
loading: true,
|
||||
list: [],
|
||||
selected: [],
|
||||
singleSelect: false,
|
||||
count: 0,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
header: [
|
||||
{ text: '項目名稱', value: 'subject', align: 'start' },
|
||||
{ text: '項目分類', value: 'kindsTxt' },
|
||||
{ text: '類別', value: 'categoryTxt' },
|
||||
{ text: '預設金額', value: 'price' },
|
||||
{ text: '庫存狀態', value: 'stock' },
|
||||
{ text: '停用', value: 'status' },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' },
|
||||
|
||||
],
|
||||
footer:{
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
kind: '',
|
||||
subject: '',
|
||||
selltime1:'',
|
||||
selltime2: '',
|
||||
uptime1: '',
|
||||
uptime2: '',
|
||||
fileTxt: '',
|
||||
category: '',
|
||||
},
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '品項分類',
|
||||
text_prop: 'kind',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'kind', title: '品項分類', value: '' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/actItem_kind/GetList',
|
||||
columns: [
|
||||
{ id: 'kind', title: '品項分類', value: '' },
|
||||
],
|
||||
selected: {},
|
||||
select(t,data) {
|
||||
data.search.kind = t.num;
|
||||
data.btn_search()
|
||||
console.log("select search1", t);
|
||||
}
|
||||
}
|
||||
},
|
||||
show: false,
|
||||
current: {},
|
||||
list: [],
|
||||
count: 0,
|
||||
page: 1,
|
||||
loading: false,
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
disableItemsPerPage: true,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
},
|
||||
}, snackbar: {
|
||||
show: false,
|
||||
text: "",
|
||||
}, itemKindList:{
|
||||
num: 0,
|
||||
kind:''
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getDefault()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
'options.page'(newVal) {
|
||||
sessionStorage.setItem("actItemPage", newVal);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.initKindList()
|
||||
const navEntries = performance.getEntriesByType("navigation");
|
||||
const isReload = navEntries.length > 0 && navEntries[0].type === "reload";
|
||||
if (isReload) {
|
||||
sessionStorage.removeItem("actItemPage");
|
||||
}
|
||||
else {
|
||||
const actItemPage = parseInt(sessionStorage.getItem("actItemPage"));
|
||||
if (!isNaN(actItemPage) && actItemPage !== 1) {
|
||||
this.options.page = actItemPage;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initKindList() {
|
||||
axios
|
||||
//.get(HTTP_HOST + 'api/activity_kind')
|
||||
.get(HTTP_HOST + 'api/actItem_kind/GetAll')
|
||||
.then(response => {
|
||||
this.itemKindList = response.data
|
||||
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
|
||||
//let params = { page: 1, pageSize: 99999 };
|
||||
////var search = {};//post body
|
||||
////search['kind'] = '';
|
||||
////console.log("activity_kind/GetList",search, params);
|
||||
//axios.post(HTTP_HOST + 'api/activity_kind/GetList', { kind:'' } , { params: params })
|
||||
// .then(response => {
|
||||
// this.itemKindList = response.data.list
|
||||
// })
|
||||
|
||||
|
||||
},
|
||||
getDefault(clearpage = false) {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: clearpage ? '1' :page, pageSize: itemsPerPage
|
||||
};
|
||||
this.data_table.loading = true
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/GetItemList', this.search, { params: params })
|
||||
.then(response => {
|
||||
this.data_table.list = response.data.list
|
||||
this.data_table.count = response.data.count;
|
||||
this.data_table.loading = false
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
},
|
||||
editItem(item) {
|
||||
console.log("edit", item);
|
||||
},
|
||||
deleteItem(item) {
|
||||
|
||||
if (confirm('是否確定刪除此筆資料?')) {
|
||||
const index = this.data_table.list.indexOf(item)
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/DeleteItem/' + item.num)
|
||||
.then(response => {
|
||||
this.getDefault();
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteAll() {
|
||||
if (confirm('是否確定刪除已勾選的資料?')) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/DeleteAllItem/' + this.data_table.selected.map(x => x.num))
|
||||
.then(response => {
|
||||
//console.log("delAll");
|
||||
|
||||
//for (var i = 0; i < this.data_table.selected.length; i++) {
|
||||
// const index = this.data_table.list.indexOf(this.data_table.selected[i]);
|
||||
// this.data_table.list.splice(index, 1);
|
||||
//}
|
||||
//this.data_table.selected = [];
|
||||
//this.data_table.count = this.data_table.list.length
|
||||
location.reload();
|
||||
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
},
|
||||
btn_search() {
|
||||
this.getDefault(true)
|
||||
},
|
||||
btn_all() {
|
||||
clearObjProps(this.search);
|
||||
this.btn_search()
|
||||
},
|
||||
//===
|
||||
search_show(curr) {
|
||||
//console.log("btn_click:", curr, curr.api_url);
|
||||
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;
|
||||
});
|
||||
|
||||
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) => {
|
||||
r.push({
|
||||
text: t.title,
|
||||
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;
|
||||
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(row,this);
|
||||
}
|
||||
this.search_dialog.show = false;
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.data_table.count / this.data_table.pageSize)
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
currency: function (value) {
|
||||
return value == null || value == "" ? "" :
|
||||
('$' + parseFloat(value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").replace(".00", ""));
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid">
|
||||
<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.price="{ item }" >
|
||||
{{item.price | currency }}
|
||||
</template>
|
||||
<template #item.stock="{ item }" >
|
||||
<%--<span v-if="item.stock.cate1Qty>0"> {{item.stock.cate1Qty -item.stock.cate2Qty-item.stock.cate3Qty+item.stock.cate4Qty}}</span>
|
||||
<span v-if="item.stock.cate3Qty-item.stock.cate4Qty>0" class="text-danger"> (租借未還:{{item.stock.cate3Qty-item.stock.cate4Qty}})</span>
|
||||
--%>
|
||||
<%--<span v-if="item.stock.catePQty>0"> {{item.stock.catePQty}}</span>
|
||||
<span v-if="item.stock.cateRQty>0" class="text-danger"> (租借未還:{{item.stock.cateRQty}})</span>--%>
|
||||
|
||||
<span v-if="item.final_stock>0" > {{item.final_stock}}</span>
|
||||
<span v-if="item.rent_stock>0" class="text-danger"> (租借未還:{{item.rent_stock}})</span>
|
||||
</template>
|
||||
<template #item.status="{ item }" >
|
||||
<span v-if="item.status=='N'"><i class='mdi mdi-check'></i></span>
|
||||
</template>
|
||||
|
||||
|
||||
<template #item.slot_btn="{ item }">
|
||||
<a :href="'item_reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-pencil-box-outline"></i>修改</a>
|
||||
<a @click="deleteItem(item)" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-trash-can"></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>
|
||||
</div>
|
||||
<div id="print_data">
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="offCanvasRight" runat="Server">
|
||||
<div id="search_panel" alt="查詢公告資料">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">分類</label>
|
||||
<asp:DropDownList ID="s_kind" runat="server" CssClass="form-select" v-model="search.kind" >
|
||||
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">項目類別</label>
|
||||
<asp:DropDownList ID="s_category" runat="server" CssClass="form-select" v-model="search.category" >
|
||||
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">項目名稱</label>
|
||||
<input type="text" v-model="search.subject" class="form-control" placeholder="可輸入關鍵字查詢" id="s_subject" runat="server">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">文件名稱</label>
|
||||
<input type="text" v-model="search.fileTxt" class="form-control" placeholder="可輸入關鍵字查詢" id="fileTxt" runat="server">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">狀態</label>
|
||||
<select class="form-select" v-model="search.status">
|
||||
<option value="">請選擇</option>
|
||||
<option value="Y">啟用</option>
|
||||
<option value="N">停用</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3 p-2 border-top">
|
||||
<a @click="btn_search" class="btn btn-outline-primary"><i class="mdi mdi-filter"></i> 搜尋</a>
|
||||
<a class="btn btn-outline-secondary" @click="btn_all"><i class="mdi mdi-filter-remove"></i> 所有資料</a>
|
||||
</div>
|
||||
</div>
|
||||
<v-dialog v-model="search_dialog.show" max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
查詢:{{search_dialog.current.title}}
|
||||
<v-btn icon @click="search_dialog.show=false"><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-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"
|
||||
></v-data-table>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-snackbar
|
||||
v-model="snackbar.show"
|
||||
timeout="2000"
|
||||
>p
|
||||
{{ snackbar.text }}
|
||||
<template v-slot:action="{ attrs }">
|
||||
<v-btn
|
||||
text
|
||||
v-bind="attrs"
|
||||
@click="snackbar.show = false"
|
||||
>
|
||||
關閉
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-snackbar>
|
||||
</asp:Content>
|
||||
|
||||
195
web/admin/activity/index2.aspx.cs
Normal file
195
web/admin/activity/index2.aspx.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using static TreeView;
|
||||
|
||||
public partial class admin_activity_index2 : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
BuildKind();
|
||||
InitEnumsOptions<Model.activity.category>(s_category);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 分類
|
||||
|
||||
|
||||
|
||||
public void BuildKind()
|
||||
{
|
||||
s_kind.Items.Clear();
|
||||
s_kind.Items.Add(new ListItem("請選擇", ""));
|
||||
|
||||
//buildMultiKind(s_kind, "actItem_kind", 0, "", 1, Model.activity.ItemLevelMax);
|
||||
var qry1 = new TreeView().get_data2(_db.actItem_kind.Select(o => new TreeItem()
|
||||
{
|
||||
kind = o.kind,
|
||||
num = o.num,
|
||||
root = o.root,
|
||||
range = o.range,
|
||||
}).OrderBy(x => x.root).ThenBy(x => x.kind).ToList(), 0, 0);
|
||||
if (qry1.Count() > 0)
|
||||
foreach (var qq in qry1)
|
||||
s_kind.Items.Add(new ListItem(new TreeView().RptDash(qq.Level) + qq.kind, qq.num.ToString()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 匯出Excel
|
||||
|
||||
protected void excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
using (var doc = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
|
||||
{
|
||||
var wb = doc.AddWorkbookPart();
|
||||
wb.Workbook = new Workbook();
|
||||
var sheets = wb.Workbook.AppendChild(new Sheets());
|
||||
|
||||
//建立第一個頁籤
|
||||
var ws = wb.AddNewPart<WorksheetPart>();
|
||||
ws.Worksheet = new Worksheet();
|
||||
sheets.Append(new Sheet()
|
||||
{
|
||||
Id = wb.GetIdOfPart(ws),
|
||||
SheetId = 1,
|
||||
Name = "品項管理"
|
||||
});
|
||||
|
||||
//設定欄寬
|
||||
var cu = new Columns();
|
||||
cu.Append(
|
||||
new Column { Min = 1, Max = 5, Width = 15, CustomWidth = true },
|
||||
new Column { Min = 6, Max = 7, Width = 10, CustomWidth = true }
|
||||
);
|
||||
ws.Worksheet.Append(cu);
|
||||
|
||||
//建立資料頁
|
||||
var sd = new SheetData();
|
||||
ws.Worksheet.AppendChild(sd);
|
||||
|
||||
//第一列資料
|
||||
var tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue("項目名稱"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("項目分類"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("類別"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("預設金額"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("庫存狀態"), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue("停用"), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
|
||||
//查詢要匯出的資料
|
||||
var fileDt = _db.files.AsEnumerable().Where(f => f.subject.Contains(fileTxt.Value)).Select(f => f.num.ToString());//文件
|
||||
|
||||
var qry = _db.actItems.AsEnumerable();
|
||||
|
||||
//每個品項在每個倉庫的結餘量
|
||||
var stockDt = (
|
||||
from t_min_max in (
|
||||
from stock in _db.stocks
|
||||
group stock by new { stock.kind, stock.actItem_num } into g
|
||||
select new
|
||||
{
|
||||
g.Key.kind,
|
||||
g.Key.actItem_num,
|
||||
min_id = g.Min(x => x.num),
|
||||
max_id = g.Max(x => x.num)
|
||||
}
|
||||
)
|
||||
join t_min in _db.stocks on t_min_max.min_id equals t_min.num
|
||||
join t_max in _db.stocks on t_min_max.max_id equals t_max.num into t_maxGroup
|
||||
from t_max in t_maxGroup.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
t_min_max.kind,
|
||||
t_min_max.actItem_num,
|
||||
final_last = t_min_max.min_id != t_min_max.max_id ? t_max.final_stock ?? 0 : t_min.final_stock ?? 0,
|
||||
rent_last = t_min_max.min_id != t_min_max.max_id ? t_max.rent_stock ?? 0 : t_min.rent_stock ?? 0
|
||||
}
|
||||
).ToList();
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(s_subject.Value))
|
||||
qry = qry.Where(o => o.subject.Contains(s_subject.Value.Trim()));
|
||||
if (!string.IsNullOrEmpty(s_kind.SelectedValue))
|
||||
qry = qry.Where(o => o.kind == Convert.ToInt32(s_kind.SelectedValue));
|
||||
if (!string.IsNullOrEmpty(fileTxt.Value))
|
||||
qry = qry.Where(o => o.actItem_files.Where(f2 => f2.actItem_num == o.num && fileDt.ToArray().Contains(f2.files_num.ToString())).Count() > 0);
|
||||
|
||||
var tdesc = publicFun.enum_desc<Model.activity.category>();
|
||||
qry = qry.OrderByDescending(o => o.num);
|
||||
var list = qry.ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
var stock = new
|
||||
{
|
||||
//catePQty = (item.stocks.Where(o => o.category == (int)Model.stock.type.Purchase || o.category == (int)Model.stock.type.Return).Select(o => o.qty).Sum() ?? 0) - (item.stocks.Where(o => o.category == (int)Model.stock.type.Reduce || o.category == (int)Model.stock.type.Rent).Select(o => o.qty).Sum() ?? 0),
|
||||
//cateRQty = (item.stocks.Where(o => o.category == (int)Model.stock.type.Rent).Select(o => o.qty).Sum() ?? 0) - (item.stocks.Where(o => o.category == (int)Model.stock.type.Return).Select(o => o.qty).Sum() ?? 0),
|
||||
|
||||
final_stock = stockDt.Where(o => o.actItem_num == item.num).Select(o => o.final_last).Sum(),
|
||||
rent_stock = stockDt.Where(o => o.actItem_num == item.num).Select(o => o.rent_last).Sum(),
|
||||
|
||||
};
|
||||
|
||||
//新增資料列
|
||||
tr = new Row();
|
||||
tr.Append(
|
||||
new Cell() { CellValue = new CellValue(item.subject), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.kind.HasValue ? item.actItem_kind.kind : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.category.HasValue ? tdesc[item.category ?? 1] : ""), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.price.HasValue ? ValMoney(item.price.Value) : ""), DataType = CellValues.String },
|
||||
//new Cell() { CellValue = new CellValue((stock.catePQty > 0? stock.catePQty.ToString():"")+(stock.cateRQty > 0?("(租借未還:"+ stock.cateRQty+")"):"")), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue((stock.final_stock > 0? stock.final_stock.ToString():"")+(stock.rent_stock > 0?("(租借未還:"+ stock.rent_stock + ")"):"")), DataType = CellValues.String },
|
||||
new Cell() { CellValue = new CellValue(item.status.Equals("N")? "是":""), DataType = CellValues.String }
|
||||
);
|
||||
sd.AppendChild(tr);
|
||||
}
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Excel, admin_log.LogViewBtn(list.Select(x => x.subject).ToList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HttpContext.Current.Response.Clear();
|
||||
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=品項管理.xlsx");
|
||||
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
95
web/admin/activity/itemKind.aspx
Normal file
95
web/admin/activity/itemKind.aspx
Normal file
@@ -0,0 +1,95 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="itemKind.aspx.cs" Inherits="admin_activity_itemKind" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<link href="../../App_Script/bootstrap_toggle/css/bootstrap-toggle.min.css" rel="stylesheet" />
|
||||
<script src="../../App_Script/bootstrap_toggle/js/bootstrap-toggle.min.js"></script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<nav class="mb-1">
|
||||
<asp:LinkButton ID="ImageButton4" runat="server" CausesValidation="False" OnClick="ImageButton4_Click" CssClass="btn btn-primary"><i class="mdi mdi-plus"></i> 新增主分類</asp:LinkButton>
|
||||
<asp:LinkButton ID="sortButton" runat="server" Visible="false" CssClass="btn btn-primary" OnClick="sortButton_Click">
|
||||
<i class="mdi mdi-sort"></i> 排序選項</asp:LinkButton>
|
||||
</nav>
|
||||
<nav class="mb-1">
|
||||
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
|
||||
<asp:Button ID="add" runat="server" Text="新增" Visible="false" OnClick="add_Click" CssClass="btn btn-primary" />
|
||||
|
||||
<asp:PlaceHolder ID="down_table" runat="server">
|
||||
<asp:LinkButton ID="ImageButton5" runat="server" OnClick="ImageButton5_Click" CssClass="btn btn-outline-secondary" CausesValidation="False">
|
||||
<i class="mdi mdi-arrow-down-right"></i> 建立下一層選項</asp:LinkButton>
|
||||
<asp:LinkButton ID="ImageButton6" runat="server" OnClientClick="return msgconfirm('是否確定刪除這筆資料?<br>注意!資料刪除後將一併刪除此資料的子選項!',this);" OnClick="ImageButton6_Click" CssClass="btn btn-outline-secondary"><i class="mdi mdi-trash-can"></i> 刪除</asp:LinkButton>
|
||||
</asp:PlaceHolder>
|
||||
</nav>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid pb-4">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div class="card shadow-sm my-2" id="sec1">
|
||||
<div class="card-header">選擇分類</div>
|
||||
<div class="card-body">
|
||||
|
||||
<asp:TreeView ID="TreeView2" runat="server" CssClass="aspxTree" ImageSet="Arrows"
|
||||
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
|
||||
</asp:TreeView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8 label-sm-right">
|
||||
<asp:Panel ID="table" runat="server" CssClass="card shadow-sm my-2">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<asp:Label ID="start" runat="server" CssClass="text-danger" Display="Dynamic"></asp:Label>
|
||||
</div>
|
||||
<div>
|
||||
<asp:Label ID="title_msg" runat="server" CssClass="" ForeColor=""></asp:Label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body form-horizontal" role="form">
|
||||
<div>
|
||||
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-2 col-lg-3 col-form-label">* 分類名稱</label>
|
||||
<div class="col-sm-10 col-lg-9">
|
||||
<asp:TextBox ID="item_name" runat="server" CssClass="form-control" MaxLength="100" placeholder="請輸入分類名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="item_name" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-2 col-lg-3 col-form-label">備註</label>
|
||||
<div class="col-sm-10 col-lg-9">
|
||||
<asp:TextBox ID="demo" runat="server" CssClass="form-control" TextMode="MultiLine" Rows="3" placeholder="請輸入備註"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-2 col-lg-3 col-form-label">* 狀態</label>
|
||||
<div class="col-sm-10 col-lg-9">
|
||||
<label class="col-form-control">
|
||||
<input type="checkbox" id="status" runat="server"
|
||||
data-toggle="toggle" data-on="啟用" data-off="停用" data-onstyle="success" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-md-offset-2 col-sm-9 col-md-10">
|
||||
<asp:HiddenField ID="HiddenField1" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
310
web/admin/activity/itemKind.aspx.cs
Normal file
310
web/admin/activity/itemKind.aspx.cs
Normal file
@@ -0,0 +1,310 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Linq;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class admin_activity_itemKind : MyWeb.config
|
||||
{
|
||||
DataTable treeDt = new DataTable();
|
||||
const int LevelMax = Model.activity.ItemLevelMax; //分類層數
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) {
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
if (!isStrNull(Request["num"]))
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q => q.kind).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
title_msg.Text = "修改<span class=\"text-primary\">【" + prod.kind + "】</span>的分類名稱";
|
||||
item_name.Text = prod.kind;
|
||||
demo.Text = prod.demo;
|
||||
status.Checked = ValString(prod.status).Equals("Y");
|
||||
HiddenField1.Value = prod.kind;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect(Request.Url.AbsolutePath );
|
||||
|
||||
}
|
||||
|
||||
edit.Visible = true;
|
||||
add.Visible = false;
|
||||
down_table.Visible = true;
|
||||
start.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
status.Checked = true;
|
||||
table.Visible = false;
|
||||
down_table.Visible = false;
|
||||
if (Convert.ToString(Request["msg"]) == "A") { start.Text = "【資料修改成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "B") { start.Text = "【資料新增成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "C") { start.Text = "【資料刪除成功】"; }
|
||||
else { start.Text = "【請點選下方欲新增、修改或刪除的分類】"; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 建立分類
|
||||
|
||||
|
||||
protected void TreeTopology()
|
||||
{
|
||||
MyWeb.sql sql = new MyWeb.sql();
|
||||
OleDbConnection sqlConn = sql.conn(db, p_name);
|
||||
try
|
||||
{
|
||||
sqlConn.Open();
|
||||
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
|
||||
sqlCmd.CommandText = "SELECT num,kind,root FROM actItem_kind ORDER BY kind,root, range";
|
||||
treeDt = sql.dataTable(sqlCmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sqlConn.Close();
|
||||
sqlConn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildTreeView()
|
||||
{
|
||||
TreeView2.Nodes.Clear();
|
||||
TreeTopology();
|
||||
BuildChild(0, TreeView2.Nodes);
|
||||
treeDt.Dispose();
|
||||
}
|
||||
|
||||
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
|
||||
{
|
||||
DataTable dt = treeDt;
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
if (row["root"].ToString() == RootUid.ToString())
|
||||
{
|
||||
TreeNode NewNode = new TreeNode();
|
||||
if (Convert.ToString(Request["num"]) == row["num"].ToString() & HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
NewNode.Text = "<b><span style=\"color:blue\">" + row["kind"].ToString() + "</span></b>";
|
||||
if (Level +1 > LevelMax)
|
||||
{
|
||||
ImageButton5.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NewNode.Text = row["kind"].ToString();
|
||||
}
|
||||
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString() ;
|
||||
NewNode.Expand();
|
||||
Nodes.Add(NewNode);
|
||||
if (Level + 1 <= LevelMax)
|
||||
{
|
||||
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增分類按鈕事件
|
||||
|
||||
protected void ImageButton5_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "於<span class=\"text-primary\">【" + HiddenField1.Value + "】</span>分類下,新增次分類";
|
||||
item_name.Text = "";
|
||||
demo.Text = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
|
||||
}
|
||||
protected void ImageButton4_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "<span class=\"text-primary\">於根目錄下,新增主分類</span>";
|
||||
table.Visible = true;
|
||||
item_name.Text = "";
|
||||
demo.Text = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
status.Checked = true;
|
||||
HiddenField1.Value = "AddMainItem";
|
||||
BuildTreeView();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
try
|
||||
{
|
||||
Model.actItem_kind actItem_kind = _db.actItem_kind.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (actItem_kind != null)
|
||||
{
|
||||
actItem_kind.kind = item_name.Text;
|
||||
actItem_kind.demo = demo.Text;
|
||||
actItem_kind.status = status.Checked ? "Y" : "N";
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Update, "分類:" + item_name.Text);
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "無此資料";
|
||||
}
|
||||
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
int range = 1;
|
||||
int root = 0;
|
||||
|
||||
if (HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
root = Convert.ToInt32(Request["num"]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
|
||||
if (prod != null)
|
||||
if (prod.range.HasValue)
|
||||
range = prod.range.Value + 1;
|
||||
|
||||
Model.actItem_kind actItem_kind = new Model.actItem_kind();//新增
|
||||
actItem_kind.kind = item_name.Text;
|
||||
actItem_kind.root = root;
|
||||
actItem_kind.range = range;
|
||||
actItem_kind.demo = demo.Text;
|
||||
actItem_kind.status = status.Checked ? "Y" : "N";
|
||||
_db.actItem_kind.Add(actItem_kind);
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Update, "分類:" + item_name.Text);
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料刪除
|
||||
|
||||
protected void ImageButton6_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
int num = Val(Request["num"]);
|
||||
del_product(num);
|
||||
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
|
||||
_db.actItem_kind.Remove(prod);
|
||||
_db.SaveChanges(); //執行
|
||||
}
|
||||
|
||||
|
||||
Del_Ohter_Items(Val(Request["num"]));
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Update, "分類:" + item_name.Text);
|
||||
|
||||
Response.Redirect(Request.Url.AbsolutePath + "?msg=C");
|
||||
}
|
||||
|
||||
public void Del_Ohter_Items(int d_num)
|
||||
{
|
||||
var prod = _db.actItem_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
foreach (var row in prod)
|
||||
{
|
||||
del_product(row.num);
|
||||
Del_Ohter_Items(row.num);
|
||||
}
|
||||
|
||||
//查詢結果全部刪除
|
||||
_db.actItem_kind.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void del_product(int num)
|
||||
{
|
||||
var prod = _db.actItems.AsEnumerable().Where(q => q.kind == num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
//清空分類
|
||||
foreach (var item in prod)
|
||||
item.kind = null;
|
||||
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void sortButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("range.aspx");
|
||||
}
|
||||
}
|
||||
877
web/admin/activity/item_reg.aspx
Normal file
877
web/admin/activity/item_reg.aspx
Normal file
@@ -0,0 +1,877 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="item_reg.aspx.cs" Inherits="admin_activity_item_reg" ValidateRequest="false" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<link href="../../App_Script/bootstrap_toggle/css/bootstrap-toggle.min.css" rel="stylesheet" />
|
||||
<script src="../../App_Script/bootstrap_toggle/js/bootstrap-toggle.min.js"></script>
|
||||
<!--編緝器-->
|
||||
<script type="text/javascript" src="<%=ResolveUrl("~/admin/ckeditor/ckeditor.js") %>"></script>
|
||||
<script type="text/javascript">
|
||||
CKEDITOR.config.toolbar = 'Default';
|
||||
</script>
|
||||
<script>
|
||||
var prod_bom_num = <%= prod_bom_num %>;
|
||||
</script>
|
||||
|
||||
<!--編緝器-->
|
||||
<script>
|
||||
let VueApp = new Vue({
|
||||
el: '#app',
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
this_id: '<%= Request["num"] %>',
|
||||
options: {},
|
||||
optionsDetail: {
|
||||
multiSort: false,
|
||||
itemsPerPage: -1,
|
||||
},
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '項目分類',
|
||||
text_prop: 'kind',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'kind', title: '分類名稱' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/actItem_kind/GetList',
|
||||
columns: [
|
||||
{ id: 'kind', title: '分類名稱' },
|
||||
],
|
||||
selected: {},
|
||||
select(item,t) {
|
||||
console.log("select search1", t);
|
||||
}
|
||||
},
|
||||
search2: {
|
||||
id: 'search2',
|
||||
title: '相關文件',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '文件名稱', value: '' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/FilesSet/GetList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '文件名稱' },
|
||||
],
|
||||
selected: {},
|
||||
select(item,t) {
|
||||
console.log("select search2", t);
|
||||
|
||||
item.files_num_selected.text = t.subject //=====?
|
||||
item.files_num_selected.val = t.num //=====?
|
||||
}
|
||||
},
|
||||
search3: {
|
||||
id: 'search3',
|
||||
title: '子項目',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/activity/GetItemList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
selected: {},
|
||||
select(item,t) {
|
||||
console.log("select search3", item, t);
|
||||
//debugger;
|
||||
item.actItem.subject = t.subject
|
||||
item.actItem.num = t.num
|
||||
item.item_num_selected={
|
||||
text: t.subject,
|
||||
val : t.num
|
||||
}
|
||||
// item.bom_editedItem.actItem.subject = t.subject
|
||||
// item.bom_editedItem.actItem.num = t.num
|
||||
|
||||
// item.bom_editedItem.item_num_selected={
|
||||
// text : t.subject,
|
||||
// val = t.num
|
||||
// }
|
||||
}
|
||||
////新增/修改+關閉時, 會清空/還原
|
||||
},
|
||||
|
||||
},
|
||||
show: false,
|
||||
current: {},
|
||||
list: [],
|
||||
count: 0,
|
||||
page: 1,
|
||||
loading: false,
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
disableItemsPerPage: true,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
},
|
||||
},
|
||||
snackbar: {
|
||||
show: false,
|
||||
text: "",
|
||||
},
|
||||
//相關文件
|
||||
searchDetail: '',
|
||||
headersDetail: [
|
||||
{ text: '文件名稱', value: 'files_num_selected.text', sortable: false },
|
||||
{ text: '', value: 'actions', sortable: false, width: "200px" },
|
||||
],
|
||||
footersDetail: {
|
||||
showFirstLastPage: false,
|
||||
disableItemsPerPage: false,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
'prev-icon': null,
|
||||
'next-icon': null,
|
||||
'disable-pagination': true,
|
||||
'items-per-page-options': []
|
||||
},
|
||||
desserts: [],
|
||||
desserts_count: 0,
|
||||
editedIndex: -1,
|
||||
editedItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
actItem_num: 0,
|
||||
files_num_selected: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
},
|
||||
defaultItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
actItem_num: 0,
|
||||
files_num_selected: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
},
|
||||
//BOM
|
||||
prod_bom_num: prod_bom_num,
|
||||
bom_searchDetail: '',
|
||||
bom_headersDetail: [
|
||||
{ text: '品項', value: 'item_num_selected.text', sortable: false },
|
||||
{ text: '', value: 'actions', sortable: false, width: "200px" },
|
||||
],
|
||||
bom_footersDetail: {
|
||||
showFirstLastPage: false,
|
||||
disableItemsPerPage: false,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
'prev-icon': null,
|
||||
'next-icon': null,
|
||||
'disable-pagination': true,
|
||||
'items-per-page-options': []
|
||||
},
|
||||
bom_list: [],
|
||||
bom_count: 0,
|
||||
bom_editedIndex: -1,
|
||||
bom_editedItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
package_num: 0,
|
||||
//item_num: 0,
|
||||
item_num_selected: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
},
|
||||
bom_defaultItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
package_num: 0,
|
||||
//item_num: 0,
|
||||
item_num_selected: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.search_dialog.current = this.search_dialog.controls.search1
|
||||
//console.log("mounted");
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
//console.log("watch1", this.search_dialog, this.search_dialog.page);
|
||||
this.search_get()
|
||||
console.log("watch2", this.search_dialog, this.search_dialog.page);
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
optionsDetail: {
|
||||
handler() {
|
||||
this.initialize();
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
search_show(curr) {
|
||||
//console.log("btn_click:", curr, curr.api_url);
|
||||
this.search_dialog.current = curr;
|
||||
this.search_clear()
|
||||
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;
|
||||
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;
|
||||
});
|
||||
//necessary parameter===
|
||||
if (this.search_dialog.current.id == 'search1') {
|
||||
if (this.this_id=="")
|
||||
search['status'] = "Y";//啟用
|
||||
}
|
||||
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) => {
|
||||
r.push({
|
||||
text: t.title,
|
||||
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;
|
||||
var editem = this.editedItem;
|
||||
if (curr.id == 'search3') {
|
||||
editem = this.bom_editedItem;
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
console.log("search_select", row, editem);
|
||||
//debugger;
|
||||
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(editem,row);
|
||||
}
|
||||
this.search_dialog.show = false;
|
||||
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
||||
},//文件
|
||||
initialize() {
|
||||
if (this.this_id != '') {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.optionsDetail
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: page, pageSize: itemsPerPage,
|
||||
};
|
||||
//取得相關文件項目
|
||||
var searchItemDetail = {
|
||||
actItem_num: this.this_id,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/GetItemFiles',
|
||||
searchItemDetail, { params: params })
|
||||
.then(response => {
|
||||
this.desserts = response.data.list
|
||||
this.desserts_count = response.data.count
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
//取得BOM子項目
|
||||
var searchItemBom = {
|
||||
item_num: this.this_id,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/GetItemBomList',
|
||||
searchItemBom, { params: params })
|
||||
.then(response => {
|
||||
this.bom_list = response.data.list
|
||||
this.bom_count = response.data.count
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
}
|
||||
|
||||
},
|
||||
editItem(item) {
|
||||
this.editedIndex = this.desserts.indexOf(item);
|
||||
this.editedItem = $.extend(true, {}, item);
|
||||
},
|
||||
deleteItem(item) {
|
||||
//confirm('確定要刪除此筆資料嗎?') && this.desserts.splice(index, 1);
|
||||
if (confirm('確定要刪除此筆資料嗎?')) {
|
||||
const index = this.desserts.indexOf(item);
|
||||
if (item.num > 0) {
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/DeleteFilesItem/' + item.num)
|
||||
.then(response => {
|
||||
console.log("del", item);
|
||||
this.desserts.splice(index, 1)
|
||||
this.desserts_count = this.desserts_count - 1;
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
} else {
|
||||
this.desserts.splice(index, 1)
|
||||
}
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
|
||||
this.spliceNullData();
|
||||
this.close();
|
||||
},
|
||||
spliceNullData() {
|
||||
|
||||
//if new data ,then splice it
|
||||
if (this.editedItem.num == 0) {
|
||||
|
||||
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
if (this.desserts[i].id == this.editedItem.id) {
|
||||
this.desserts.splice(i, 1); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
close() {
|
||||
setTimeout(() => {
|
||||
this.editedItem = $.extend(true, {}, this.defaultItem);
|
||||
this.editedIndex = -1;
|
||||
}, 300)
|
||||
},
|
||||
addNew() {
|
||||
|
||||
this.spliceNullData();
|
||||
|
||||
//addObj.id = this.desserts.length + 1;
|
||||
|
||||
var keysArr = [];
|
||||
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
//console.log(this.desserts[i].id)
|
||||
keysArr.push(parseInt(this.desserts[i].id));
|
||||
}
|
||||
var _c = Math.max.apply(null, keysArr);
|
||||
|
||||
const addObj = $.extend(true, {}, this.defaultItem);
|
||||
addObj.id = (isFinite(_c) ? _c : 0) + 1;
|
||||
this.desserts.unshift(addObj);
|
||||
this.editItem(addObj);
|
||||
},
|
||||
save() {
|
||||
if (this.editedIndex > -1) {
|
||||
if (this.this_id != '') {
|
||||
//chcck necessary params
|
||||
if (this.editedItem.files_num_selected.val != 0 ) {
|
||||
//insert or update data
|
||||
var pro_order_detail =
|
||||
{
|
||||
num: this.editedItem.num,
|
||||
actItem_num: this.this_id,
|
||||
files_num: this.editedItem.files_num_selected.val,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/SaveDetailData', pro_order_detail)
|
||||
.then(response => {
|
||||
this.editedItem.num = response.data;
|
||||
Object.assign(this.desserts[this.editedIndex], this.editedItem)
|
||||
this.close()
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
|
||||
|
||||
} else {
|
||||
this.snackbar.text = "必填項目未填寫完整";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
} else {
|
||||
this.snackbar.text = "單號錯誤";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
titleword() {
|
||||
var e = document.getElementById("<%= category.ClientID%>");
|
||||
const strUser = e.options[e.selectedIndex].text;
|
||||
|
||||
const _kind_txt = $('#<%= kind_txt.ClientID%>').val();
|
||||
const _subject = $('#<%= subject.ClientID%>').val();
|
||||
return "(" + strUser + ")" + " " + _kind_txt + " " + _subject;
|
||||
},
|
||||
bom_editItem(item){
|
||||
this.bom_editedIndex = this.bom_list.indexOf(item);
|
||||
this.bom_editedItem = $.extend(true, {}, item);
|
||||
console.log("bom_editItem:", this.bom_editedIndex, this.bom_editedItem);
|
||||
//debugger;
|
||||
},
|
||||
bom_deleteItem(item){
|
||||
confirm('確定要刪除此筆資料嗎?') && this.bom_list.splice(index, 1);
|
||||
},
|
||||
bom_cancel(){
|
||||
this.bom_spliceNullData();
|
||||
this.bom_close();
|
||||
},
|
||||
bom_spliceNullData() {
|
||||
//if new data ,then splice it
|
||||
if (this.bom_list.num == 0) {
|
||||
for (var i = 0; i < this.bom_list.map(x => x.id).length; i++) {
|
||||
if (this.bom_list[i].id == this.bom_list.id) {
|
||||
this.bom_list.splice(i, 1); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
bom_close() {
|
||||
setTimeout(() => {
|
||||
this.bom_editedItem = $.extend(true, {}, this.bom_defaultItem);
|
||||
this.bom_editedItem = -1;
|
||||
}, 300)
|
||||
},
|
||||
bom_addNew(){
|
||||
this.spliceNullData();
|
||||
|
||||
//addObj.id = this.desserts.length + 1;
|
||||
|
||||
var keysArr = [];
|
||||
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
//console.log(this.desserts[i].id)
|
||||
keysArr.push(parseInt(this.desserts[i].id));
|
||||
}
|
||||
var _c = Math.max.apply(null, keysArr);
|
||||
|
||||
const addObj = $.extend(true, {}, this.bom_defaultItem);
|
||||
addObj.id = (isFinite(_c) ? _c : 0) + 1;
|
||||
addObj.package_num = this.prod_bom_num; ////取得主項目的package_num
|
||||
addObj.actItem = { subject: '', num: 0 };
|
||||
if (!!this.bom_list) this.bom_list?.unshift(addObj);
|
||||
this.bom_editItem(addObj);
|
||||
},
|
||||
bom_save(){
|
||||
if (this.bom_editedIndex > -1) {
|
||||
if (this.this_id != '') {
|
||||
//chcck necessary params
|
||||
if (this.bom_editedItem.item_num_selected.val != 0 ) {
|
||||
//insert or update data
|
||||
var package_num = $(".packageNum input[type=hidden]").val();
|
||||
var bom_detail =
|
||||
{
|
||||
num: this.bom_editedItem.num,
|
||||
package_num: package_num,
|
||||
item_num: this.bom_editedItem.actItem.num,
|
||||
|
||||
};
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/SaveDetailBomList', bom_detail)
|
||||
.then(response => {
|
||||
this.bom_editedItem.num = response.data;
|
||||
Object.assign(this.bom_list[this.bom_editedIndex], this.bom_editedItem)
|
||||
this.bom_close();
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
} else {
|
||||
this.snackbar.text = "必填項目未填寫完整";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
} else {
|
||||
this.snackbar.text = "單號錯誤";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
|
||||
})
|
||||
$(document).ready(function () {
|
||||
setCss();
|
||||
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
|
||||
});
|
||||
|
||||
function EndRequestHandler(sender, args) {
|
||||
setCss();
|
||||
}
|
||||
function setCss() {
|
||||
$(".cyclePanel input").addClass("form-check-input");
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<div class="scroll-nav nav nav-tabs mb-2 mb-sm-0 d-none d-sm-flex">
|
||||
<template v-if="this_id !='' "> {{titleword()}} </template>
|
||||
</div>
|
||||
<div class="">
|
||||
<asp:Button ID="add" runat="server" Text="送出" OnClick="add_Click" CssClass="btn btn-primary" />
|
||||
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
|
||||
<asp:Button ID="goback" runat="server" Text="回列表" Visible="false" CausesValidation="false" OnClick="goback_Click" CssClass="btn btn-outline-secondary" />
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid">
|
||||
|
||||
<div class="card shadow-sm my-2" id="sec2">
|
||||
<div class="card-header py-0">
|
||||
<nav class="navbar py-0">
|
||||
<div class="nav nav-tabs">
|
||||
<button class="nav-link active" id="sec2-tab1" data-bs-toggle="tab" data-bs-target="#sec2-page1"
|
||||
type="button" role="tab" aria-controls="home" aria-selected="true">
|
||||
基本資料</button>
|
||||
<button class="nav-link" id="sec2-tab2" data-bs-toggle="tab" data-bs-target="#sec2-page2"
|
||||
type="button" role="tab" aria-controls="profile" aria-selected="false">
|
||||
相關文件</button>
|
||||
<button class="nav-link" id="sec2-tab3" data-bs-toggle="tab" data-bs-target="#sec2-page3"
|
||||
type="button" role="tab" aria-controls="bom" aria-selected="false">
|
||||
功德項目</button>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active " id="sec2-page1" role="tabpanel" aria-labelledby="sec2-tab1">
|
||||
<div>
|
||||
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">項目類別 *</label>
|
||||
<div class="col-sm-4">
|
||||
<asp:DropDownList ID="category" runat="server" CssClass="form-select">
|
||||
<asp:ListItem Value="">請選擇</asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="category" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
<label class="col-sm-2 col-form-label">項目分類 *</label>
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group mb-3" data-search-control="search1" @click=" search_show(search_dialog.controls.search1)">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
id="kind_txt" runat="server" placeholder="請選擇" value="">
|
||||
<asp:HiddenField ID="kind" runat="server" Value="" />
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="kind_txt" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">料號</label>
|
||||
<div class="col-sm-4">
|
||||
<asp:TextBox ID="PARTNO" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入料號"></asp:TextBox>
|
||||
</div>
|
||||
<label class="col-sm-2 col-form-label">項目名稱 *</label>
|
||||
<div class="col-sm-4">
|
||||
<asp:TextBox ID="subject" MaxLength="100" runat="server" CssClass="form-control" placeholder="請輸入品項名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="subject" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">牌位編號開頭</label>
|
||||
<div class="col-sm-4">
|
||||
<asp:TextBox ID="print_init" MaxLength="20" runat="server" CssClass="form-control" placeholder="請輸入牌位編號開頭"></asp:TextBox>
|
||||
</div>
|
||||
<label class="col-sm-2 col-form-label">預設金額</label>
|
||||
<div class="col-sm-4">
|
||||
<asp:TextBox ID="price" MaxLength="7" runat="server" CssClass="form-control" placeholder="請輸入預設金額"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator ControlToValidate="price" Display="Dynamic" SetFocusOnError="true" ErrorMessage="只能輸入數字" ID="RegularExpressionValidator3" runat="server" ValidationExpression="^(-?\d+)(\.\d+)?$" />
|
||||
</div>
|
||||
</div>
|
||||
<asp:UpdatePanel ID="UpdatePanel1" runat="server" class="row mb-1 label-sm-right">
|
||||
<ContentTemplate>
|
||||
<label class="col-sm-2 col-form-label"></label>
|
||||
<div class="col-sm-4">
|
||||
<asp:CheckBox ID="extend" runat="server" CssClass="cyclePanel" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
|
||||
<label class="form-check-label me-2" for='<%= extend.ClientID %>'>
|
||||
應延續
|
||||
</label>
|
||||
<asp:CheckBox ID="is_reconcile_item" runat="server" CssClass="cyclePanel" />
|
||||
<label class="form-check-label me-2" for='<%= is_reconcile_item.ClientID %>'>
|
||||
核銷項目
|
||||
</label>
|
||||
</div>
|
||||
<asp:PlaceHolder ID="cyclePlaceHolder" runat="server" Visible="false">
|
||||
<label class="col-sm-2 col-form-label">收費週期 *</label>
|
||||
<div class="col-sm-4">
|
||||
<div class="input-group">
|
||||
<asp:TextBox ID="cycle" MaxLength="3" runat="server" CssClass="form-control"></asp:TextBox>
|
||||
<span class="input-group-text">月</span>
|
||||
<asp:RegularExpressionValidator ControlToValidate="cycle" Display="Dynamic" SetFocusOnError="true" ErrorMessage="只能輸入數字" ID="RegularExpressionValidator1" runat="server" ValidationExpression="^(-?\d+)(\.\d+)?$" />
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="cycle" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</asp:PlaceHolder>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">備註</label>
|
||||
<div class="col-sm-10">
|
||||
<asp:TextBox ID="demo" runat="server" CssClass="ckeditor" TextMode="MultiLine"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">自定義欄位預設值</label>
|
||||
<div class="col-sm-10">
|
||||
<asp:TextBox ID="customize_data" runat="server" Rows="3" TextMode="MultiLine" CssClass="form-control" placeholder="一行輸入一個定義欄位預設值,如: $品名:醬油 $金額:100" ToolTip="一行輸入一個定義欄位預設值,格式: $變數名稱:值"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">狀態 *</label>
|
||||
<div class="col-sm-2">
|
||||
<label class="col-form-control">
|
||||
<input type="checkbox" id="status" runat="server"
|
||||
data-toggle="toggle" data-on="啟用" data-off="停用" data-onstyle="success" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade giftItems label-sm-right" id="sec2-page2" role="tabpanel" aria-labelledby="sec2-tab2">
|
||||
<v-card class="mx-auto mt-10" outlined v-if="this_id!=''">
|
||||
<v-data-table
|
||||
:headers="headersDetail"
|
||||
:items="desserts"
|
||||
:footer-props="footersDetail"
|
||||
:search="searchDetail"
|
||||
:options.sync="optionsDetail" class="elevation-1" fixed-header height="350px"
|
||||
<%-- :server-items-length="desserts_count"--%>
|
||||
>
|
||||
<v-divider inset></v-divider>
|
||||
<template v-slot:top>
|
||||
<v-toolbar flat color="white">
|
||||
<div class="d-flex w-100">
|
||||
<v-text-field v-model="searchDetail" append-icon="mdi-magnify" label="查詢" dense outlined single-line hide-details></v-text-field>
|
||||
<v-btn
|
||||
color="primary"
|
||||
class="ml-2 white--text"
|
||||
@click="addNew">
|
||||
<v-icon dark>mdi-plus</v-icon>新增
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
<template v-slot:item.files_num_selected.text="{ item }">
|
||||
<div class="input-group mb-3" data-search-control="search2"
|
||||
@click="search_show(search_dialog.controls.search2)"
|
||||
v-if="item.id === editedItem.id">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
placeholder="文件名稱" v-model="editedItem.files_num_selected.text" >
|
||||
<input type="hidden" v-model="editedItem.files_num_selected.val">
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>
|
||||
<span v-else>{{item.files_num_selected.text}}</span>
|
||||
<span v-if="item.num==0" class="text-danger">(預設資料,未存檔)</span>
|
||||
</template>
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<div v-if="item.id === editedItem.id">
|
||||
<v-icon color="red" class="mr-3" @click="cancel">
|
||||
mdi-window-close
|
||||
</v-icon>
|
||||
<v-icon color="green" @click="save">
|
||||
mdi-content-save
|
||||
</v-icon>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-icon color="green" class="mr-3" @click="editItem(item);">
|
||||
mdi-pencil
|
||||
</v-icon>
|
||||
<v-icon color="red" @click="deleteItem(item)">
|
||||
mdi-delete
|
||||
</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
<div class="mx-auto" v-else >
|
||||
<p class="lead">請先儲存基本資料後再新增相關文件</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade giftItems label-sm-right" id="sec2-page3" role="tabpanel" aria-labelledby="sec2-tab3">
|
||||
<asp:Panel ID="bom_panel" runat="server">
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-2 col-form-label">牌位數量</label>
|
||||
<div class="col-sm-6">
|
||||
<asp:TextBox CssClass="form-control" ID="bom_qty" runat="server"></asp:TextBox>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<asp:button class="btn btn-primary" id="setBom" runat="server"
|
||||
Text="設定子項目" OnClick="setBom_Click" Visible="true"></asp:button>
|
||||
<asp:button class="btn btn-primary" id="saveBom" runat="server"
|
||||
Text="儲存子項目" OnClick="saveBom_Click" Visible="true"></asp:button>
|
||||
</div>
|
||||
<div class="packageNum">
|
||||
<asp:HiddenField ID="packageNum" runat="server"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-form-label">備註</label>
|
||||
<div class="col-sm-10">
|
||||
<asp:TextBox ID="bom_memo" runat="server" Rows="3" TextMode="MultiLine" CssClass="form-control" placeholder="輸入備註" ToolTip=""></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
<v-card class="mx-auto mt-10" outlined v-if="this_id!=''">
|
||||
<v-data-table class="elevation-1" fixed-header height="350px"
|
||||
:headers="bom_headersDetail"
|
||||
:items="bom_list"
|
||||
:footer-props="bom_footersDetail"
|
||||
:search="bom_searchDetail"
|
||||
:options.sync="optionsDetail"
|
||||
<%-- :server-items-length="desserts_count"--%>
|
||||
>
|
||||
<v-divider inset></v-divider>
|
||||
<template v-slot:top>
|
||||
<v-toolbar flat color="white">
|
||||
<div class="d-flex w-100">
|
||||
<v-text-field v-model="bom_searchDetail" append-icon="mdi-magnify" label="查詢" dense outlined single-line hide-details></v-text-field>
|
||||
<v-btn
|
||||
color="primary"
|
||||
class="ml-2 white--text"
|
||||
@click="bom_addNew">
|
||||
<v-icon dark>mdi-plus</v-icon>新增
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
<template v-slot:item.item_num_selected.text="{ item }">
|
||||
<div class="input-group my-3" data-search-control="search3"
|
||||
@click="search_show(search_dialog.controls.search3)"
|
||||
v-if="item.num === bom_editedItem.num">
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
placeholder="名稱" v-model="bom_editedItem.actItem.subject" >
|
||||
<input type="hidden" v-model="bom_editedItem.actItem.num">
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>
|
||||
<span v-else>{{item.actItem.subject}}</span>
|
||||
<span v-if="item.num==0" class="text-danger">(預設資料,未存檔)</span>
|
||||
</template>
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<div v-if="item.num === bom_editedItem.num">
|
||||
<v-icon color="red" class="mr-3" @click="bom_cancel">
|
||||
mdi-window-close
|
||||
</v-icon>
|
||||
<v-icon color="green" @click="bom_save">
|
||||
mdi-content-save
|
||||
</v-icon>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-icon color="green" class="mr-3" @click="bom_editItem(item);">
|
||||
mdi-pencil
|
||||
</v-icon>
|
||||
<v-icon color="red" @click="bom_deleteItem(item)">
|
||||
mdi-delete
|
||||
</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
<div class="mx-auto" v-else >
|
||||
<p class="lead">請先儲存基本資料後再新增相關文件</p>
|
||||
</div>
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<v-dialog v-model="search_dialog.show" max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
查詢:{{search_dialog.current.title}}
|
||||
<v-btn icon @click="search_dialog.show=false"><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"
|
||||
></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>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
249
web/admin/activity/item_reg.aspx.cs
Normal file
249
web/admin/activity/item_reg.aspx.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using static publicFun;
|
||||
|
||||
public partial class admin_activity_item_reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public int prod_bom_num = 0;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
InitEnumsOptions<Model.activity.category>(category);
|
||||
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
BuildKind();
|
||||
status.Checked = true;
|
||||
bom_panel.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
//var qry = _db.actItems.AsEnumerable();
|
||||
var prod = _db.actItems.Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
|
||||
BuildKind();
|
||||
subject.Text = prod.subject;
|
||||
print_init.Text = prod.print_init;
|
||||
PARTNO.Text = prod.partno;
|
||||
//kind.SelectedValue = prod.kind.ToString();
|
||||
if (prod.kind.HasValue)
|
||||
{
|
||||
kind_txt.Value = prod.actItem_kind.kind;
|
||||
kind.Value = prod.kind.ToString();
|
||||
}
|
||||
|
||||
if (prod.category.HasValue) category.SelectedValue = prod.category.ToString();
|
||||
if(!isStrNull(prod.demo))
|
||||
demo.Text = prod.demo.ToString();
|
||||
|
||||
status.Checked = ValString(prod.status).Equals("Y");
|
||||
extend.Checked = ValString(prod.extend).Equals("Y");
|
||||
is_reconcile_item.Checked = ValString(prod.is_reconcile).Equals("Y");
|
||||
setCycle();
|
||||
if (prod.price.HasValue)
|
||||
price.Text = prod.price.Value.ToString();
|
||||
if (prod.cycle.HasValue)
|
||||
cycle.Text = prod.cycle.Value.ToString();
|
||||
|
||||
customize_data.Text = prod.customize_data?.ToString();
|
||||
|
||||
|
||||
edit.Visible = true;
|
||||
goback.Visible = true;
|
||||
add.Visible = false;
|
||||
|
||||
//檢查prod有沒有對應的act_bom項目
|
||||
var prodBom = prod.act_bom.FirstOrDefault();
|
||||
setBom.Visible = prodBom == null;//沒有對應的act_bom項目才能新增
|
||||
saveBom.Visible = prodBom != null;//有對應的act_bom項目才能儲存
|
||||
//bom_qty.Enabled = prodBom != null;//有對應的act_bom項目..
|
||||
bom_qty.Text = (prodBom?.qty??0).ToString();
|
||||
bom_memo.Text = (prodBom?.memo ?? "");
|
||||
packageNum.Value=(prodBom?.num.ToString());
|
||||
prod_bom_num = prodBom?.num ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("index2.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void goback_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("index2.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
|
||||
#region 分類
|
||||
|
||||
|
||||
|
||||
public void BuildKind()
|
||||
{
|
||||
//kind.Items.Clear();
|
||||
//kind.Items.Add(new ListItem("請選擇", ""));
|
||||
|
||||
|
||||
//buildMultiKind(kind, "actItem_kind", 0, "", 1, Model.activity.ItemLevelMax,null ,true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid) {
|
||||
L_msg.Text = "";
|
||||
|
||||
Model.actItem actItem = new Model.actItem();//新增
|
||||
actItem.subject = subject.Text;
|
||||
actItem.print_init = print_init.Text;
|
||||
actItem.partno = PARTNO.Text;
|
||||
//if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; }
|
||||
if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; }
|
||||
if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; }
|
||||
if (!isStrNull(price.Text)) { actItem.price = ValFloat(price.Text); } else { actItem.price = null; }
|
||||
if (extend.Checked && !isStrNull(cycle.Text)) { actItem.cycle = Val(cycle.Text); } else { actItem.cycle = null; }
|
||||
actItem.status = status.Checked ? "Y" : "N";
|
||||
actItem.extend = extend.Checked ? "Y" : "N";
|
||||
actItem.is_reconcile = is_reconcile_item.Checked ? "Y" : "N";
|
||||
actItem.demo = demo.Text;
|
||||
actItem.customize_data = customize_data.Text;
|
||||
|
||||
_db.actItems.Add(actItem);
|
||||
_db.SaveChanges();
|
||||
int _id = actItem.num;
|
||||
if( _id > 0)
|
||||
{
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Insert, subject.Text);
|
||||
|
||||
Response.Redirect("index2.aspx");
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
Model.actItem actItem = _db.actItems.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (actItem != null)
|
||||
{
|
||||
actItem.subject = subject.Text;
|
||||
actItem.print_init = print_init.Text;
|
||||
actItem.partno = PARTNO.Text;
|
||||
//if (!isStrNull(kind.SelectedValue)) { actItem.kind = Val(kind.SelectedValue); } else { actItem.kind = null; }
|
||||
if (!isStrNull(category.SelectedValue)) { actItem.category = Val(category.SelectedValue); } else { actItem.category = null; }
|
||||
if (!isStrNull(kind.Value)) { actItem.kind = Val(kind.Value); } else { actItem.kind = null; }
|
||||
if (!isStrNull(price.Text)) { actItem.price = ValFloat(price.Text); } else { actItem.price = null; }
|
||||
if (extend.Checked && !isStrNull(cycle.Text)) { actItem.cycle = Val(cycle.Text); } else { actItem.cycle = null; }
|
||||
actItem.status = status.Checked ? "Y" : "N";
|
||||
actItem.extend = extend.Checked ? "Y" : "N";
|
||||
actItem.is_reconcile = is_reconcile_item.Checked ? "Y" : "N";
|
||||
actItem.demo = demo.Text;
|
||||
actItem.customize_data = customize_data.Text;
|
||||
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Item, (int)Model.admin_log.Status.Update, subject.Text);
|
||||
|
||||
Response.Redirect("index2.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "查無資料";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 收費週期
|
||||
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
setCycle();
|
||||
}
|
||||
protected void setCycle()
|
||||
{
|
||||
cyclePlaceHolder.Visible = extend.Checked;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
protected void setBom_Click(object sender, EventArgs e)
|
||||
{
|
||||
//新增本頁品項, 對應的actItem
|
||||
if (!isStrNull(Request["num"]))
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = _db.actItems.Where(q => q.num == _num).FirstOrDefault();
|
||||
var prodBom = prod.act_bom.FirstOrDefault();
|
||||
if (prod != null && prodBom == null)
|
||||
{
|
||||
Model.act_bom actBom = new Model.act_bom();
|
||||
actBom.item_num = _num;
|
||||
actBom.qty = Val(bom_qty.Text);
|
||||
actBom.memo = bom_memo.Text;
|
||||
_db.act_bom.Add(actBom);
|
||||
_db.SaveChanges();
|
||||
Response.Redirect("item_reg.aspx?num=" + _num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveBom_Click(object sender, EventArgs e)
|
||||
{
|
||||
//儲存本頁品項, 對應的actItem
|
||||
if (!isStrNull(Request["num"]))
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = _db.actItems.Where(q => q.num == _num).FirstOrDefault();
|
||||
var prodBom = prod.act_bom.FirstOrDefault();
|
||||
if (prod != null && prodBom != null)
|
||||
{
|
||||
prodBom.qty = Val(bom_qty.Text);
|
||||
prodBom.memo = bom_memo.Text;
|
||||
_db.SaveChanges();
|
||||
//Response.Redirect("item_reg.aspx?num=" + _num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
554
web/admin/activity/kind_reg.aspx
Normal file
554
web/admin/activity/kind_reg.aspx
Normal file
@@ -0,0 +1,554 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="kind_reg.aspx.cs" Inherits="admin_activity_kind_reg" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
|
||||
<script>
|
||||
let VueApp = new Vue({
|
||||
el: '#app',
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
this_id: '<%= _this_id %>',
|
||||
options: {},
|
||||
optionsDetail: { multiSort: false },
|
||||
search_dialog: {
|
||||
controls: {
|
||||
search1: {
|
||||
id: 'search1',
|
||||
title: '活動品項',
|
||||
text_prop: 'subject',
|
||||
value_prop: 'num',
|
||||
keys: [
|
||||
{ id: 'subject', title: '項目名稱', value: '' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
api_url: HTTP_HOST + 'api/activity/GetItemList',
|
||||
columns: [
|
||||
{ id: 'subject', title: '項目名稱' },
|
||||
{ id: 'kindTxt', title: '項目分類' },
|
||||
],
|
||||
selected: {},
|
||||
select(item,t) {
|
||||
console.log("select search1", t);
|
||||
|
||||
|
||||
item.actItem_num.text = t.subject
|
||||
item.actItem_num.val = t.num
|
||||
item.price = t.price
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
show: false,
|
||||
current: {},
|
||||
list: [],
|
||||
count: 0,
|
||||
page: 1,
|
||||
loading: false,
|
||||
footer: {
|
||||
showFirstLastPage: true,
|
||||
disableItemsPerPage: true,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
},
|
||||
},
|
||||
snackbar: {
|
||||
show: false,
|
||||
text: "",
|
||||
}//相關項目
|
||||
, searchDetail: '',
|
||||
headersDetail: [
|
||||
{ text: '* 品項名稱', value: 'actitem_num.text', sortable: false },
|
||||
{ text: '預設金額', value: 'price', sortable: false },
|
||||
{ text: '數量', value: 'qty', sortable: false },
|
||||
{ text: '', value: 'actions', sortable: false, width: "200px" },
|
||||
],
|
||||
footersDetail: {
|
||||
showFirstLastPage: false,
|
||||
disableItemsPerPage: false,
|
||||
itemsPerPageAllText: '',
|
||||
itemsPerPageText: '',
|
||||
'prev-icon': null,
|
||||
'next-icon': null,
|
||||
'disable-pagination': true,
|
||||
'items-per-page-options': []
|
||||
},
|
||||
desserts: [],
|
||||
desserts_count: 0,
|
||||
editedIndex: -1,
|
||||
editedItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
activity_kind_num: 0,
|
||||
actItem_num: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
price: 0,
|
||||
qty :0,
|
||||
},
|
||||
defaultItem: {
|
||||
id: 0,
|
||||
num: 0,
|
||||
activity_kind_num: 0,
|
||||
actItem_num: {
|
||||
text: '',
|
||||
val: 0
|
||||
},
|
||||
price: 0,
|
||||
qty: 0,
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.search_dialog.current = this.search_dialog.controls.search1
|
||||
//console.log("mounted");
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
//console.log("watch1", this.search_dialog, this.search_dialog.page);
|
||||
this.search_get()
|
||||
console.log("watch2", this.search_dialog, this.search_dialog.page);
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
optionsDetail: {
|
||||
handler() {
|
||||
this.initialize();
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
search_show(curr) {
|
||||
//console.log("btn_click:", curr, curr.api_url);
|
||||
this.search_dialog.current = curr;
|
||||
this.search_clear()
|
||||
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;
|
||||
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;
|
||||
});
|
||||
//necessary parameter===
|
||||
if (this.search_dialog.current.id == 'search1') {
|
||||
search['categorys'] = "1,2,4";//報名,掛單,贊助
|
||||
}
|
||||
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) => {
|
||||
r.push({
|
||||
text: t.title,
|
||||
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;
|
||||
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;
|
||||
//console.log(row, row["u_name"], row["f_number"], curr.id, target);
|
||||
},//文件
|
||||
initialize() {
|
||||
if (this.this_id != '') {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.optionsDetail
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: page,
|
||||
//pageSize: itemsPerPage == -1 ? this.desserts.length : itemsPerPage,
|
||||
pageSize: itemsPerPage,
|
||||
};
|
||||
var searchItemDetail = {
|
||||
activity_kind_num: this.this_id,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/GetKindDetail',
|
||||
searchItemDetail, { params: params })
|
||||
.then(response => {
|
||||
this.desserts = response.data.list
|
||||
this.desserts_count = response.data.count
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
}
|
||||
|
||||
},
|
||||
editItem(item) {
|
||||
this.editedIndex = this.desserts.indexOf(item);
|
||||
this.editedItem = $.extend(true, {}, item);
|
||||
},
|
||||
deleteItem(item) {
|
||||
if (confirm('確定要刪除此筆資料嗎?')) {
|
||||
const index = this.desserts.indexOf(item);
|
||||
if (item.num > 0) {
|
||||
if (index != -1) {
|
||||
axios
|
||||
.delete(HTTP_HOST + 'api/activity/DeleteActKindDetail/' + item.num)
|
||||
.then(response => {
|
||||
console.log("del", item);
|
||||
this.desserts.splice(index, 1)
|
||||
this.desserts_count = this.desserts_count - 1;
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
} else {
|
||||
this.desserts.splice(index, 1)
|
||||
}
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
//data-search-control need to return to the original value
|
||||
|
||||
this.spliceNullData();
|
||||
this.close();
|
||||
},
|
||||
spliceNullData() {
|
||||
|
||||
//if new data ,then splice it
|
||||
if (this.editedItem.num == 0) {
|
||||
|
||||
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
if (this.desserts[i].id == this.editedItem.id) {
|
||||
this.desserts.splice(i, 1); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
close() {
|
||||
setTimeout(() => {
|
||||
this.editedItem = $.extend(true, {}, this.defaultItem);
|
||||
this.editedIndex = -1;
|
||||
}, 300)
|
||||
},
|
||||
addNew() {
|
||||
|
||||
this.spliceNullData();
|
||||
//addObj.id = this.desserts.length + 1;
|
||||
|
||||
var keysArr = [];
|
||||
for (var i = 0; i < this.desserts.map(x => x.id).length; i++) {
|
||||
//console.log(this.desserts[i].id)
|
||||
keysArr.push(parseInt(this.desserts[i].id));
|
||||
}
|
||||
var _c = Math.max.apply(null, keysArr);
|
||||
|
||||
const addObj = $.extend(true, {}, this.defaultItem);
|
||||
addObj.id = (isFinite(_c) ? _c : 0) + 1;
|
||||
this.desserts.unshift(addObj);
|
||||
this.editItem(addObj);
|
||||
},
|
||||
save() {
|
||||
if (this.editedIndex > -1) {
|
||||
if (this.this_id != '') {
|
||||
//chcck necessary params
|
||||
if (this.editedItem.actItem_num.val != 0 ) {
|
||||
//insert or update data
|
||||
var pro_order_detail =
|
||||
{
|
||||
num: this.editedItem.num,
|
||||
activity_kind_num: this.this_id,
|
||||
actItem_num: this.editedItem.actItem_num.val,
|
||||
price: this.editedItem.price,
|
||||
qty: this.editedItem.qty,
|
||||
}
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/activity/SaveActKindDetail', pro_order_detail)
|
||||
.then(response => {
|
||||
this.editedItem.num = response.data;
|
||||
Object.assign(this.desserts[this.editedIndex], this.editedItem)
|
||||
this.close()
|
||||
})
|
||||
.catch(
|
||||
error => console.log(error)
|
||||
)
|
||||
|
||||
} else {
|
||||
this.snackbar.text = "必填項目未填寫完整";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
} else {
|
||||
this.snackbar.text = "單號錯誤";
|
||||
this.snackbar.show = true
|
||||
}
|
||||
|
||||
}
|
||||
}, customSearch(value, item) {
|
||||
console.log(value, item)
|
||||
},
|
||||
searchData(event) {
|
||||
this.desserts = this.desserts.filter(item => item.actItem_num.text.toLowerCase().includes(event));
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
filters: {
|
||||
currency: function (value) {
|
||||
return value == null || value === "" ? "" :
|
||||
('$' + parseFloat(value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").replace(".00", ""));
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<nav class="mb-1">
|
||||
<asp:LinkButton ID="ImageButton4" runat="server" CausesValidation="False" OnClick="ImageButton4_Click" CssClass="btn btn-primary"><i class="mdi mdi-plus"></i> 新增主分類</asp:LinkButton>
|
||||
<asp:LinkButton ID="sortButton" runat="server" Visible="false" CssClass="btn btn-primary" OnClick="sortButton_Click">
|
||||
<i class="mdi mdi-sort"></i> 排序選項</asp:LinkButton>
|
||||
</nav>
|
||||
<nav class="mb-1">
|
||||
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
|
||||
<asp:Button ID="add" runat="server" Text="新增" Visible="false" OnClick="add_Click" CssClass="btn btn-primary" />
|
||||
|
||||
<asp:PlaceHolder ID="down_table" runat="server">
|
||||
<asp:LinkButton ID="ImageButton5" runat="server" OnClick="ImageButton5_Click" CssClass="btn btn-outline-secondary" CausesValidation="False"><i class="mdi mdi-arrow-down-right"></i> 建立下一層選項</asp:LinkButton>
|
||||
<asp:LinkButton ID="ImageButton6" runat="server" OnClientClick="return msgconfirm('是否確定刪除這筆資料?<br>注意!資料刪除後將一併刪除此資料的子選項!',this);" OnClick="ImageButton6_Click" CssClass="btn btn-outline-secondary"><i class="mdi mdi-trash-can"></i> 刪除</asp:LinkButton>
|
||||
</asp:PlaceHolder>
|
||||
</nav>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid pb-4">
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-lg-3">
|
||||
<div class="card shadow-sm my-2" id="sec1">
|
||||
<div class="card-header">選擇分類</div>
|
||||
<div class="card-body">
|
||||
<asp:TreeView ID="TreeView2" runat="server" CssClass="aspxTree" ImageSet="Arrows"
|
||||
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
|
||||
</asp:TreeView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8 col-lg-9">
|
||||
<asp:Panel ID="table" runat="server" CssClass="card shadow-sm my-2">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<asp:Label ID="start" runat="server" CssClass="text-danger" Display="Dynamic"></asp:Label>
|
||||
</div>
|
||||
<div>
|
||||
<asp:Label ID="title_msg" runat="server" CssClass="" ForeColor=""></asp:Label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body form-horizontal" role="form">
|
||||
<div>
|
||||
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-md-3 col-form-label">* 分類名稱</label>
|
||||
<div class="col-sm-10 col-md-9">
|
||||
<asp:TextBox ID="item_name" runat="server" CssClass="form-control" MaxLength="100" placeholder="請輸入分類名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="item_name" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 label-sm-right">
|
||||
<label class="col-sm-2 col-md-3 col-form-label">預設起始日期 </label>
|
||||
<div class="col-sm-10 col-md-9 col-lg-6">
|
||||
<div class="input-group">
|
||||
<asp:DropDownList ID="calendar" runat="server" CssClass="form-select">
|
||||
<asp:ListItem Value="">請選擇</asp:ListItem>
|
||||
<asp:ListItem Value="國曆">國曆</asp:ListItem>
|
||||
<asp:ListItem Value="農曆">農曆</asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
<input type="text" class="form-control" placeholder="月" aria-label="月" id="month" runat="server">
|
||||
<span class="input-group-text">月</span>
|
||||
<input type="text" class="form-control" placeholder="日" aria-label="日" id="day" runat="server">
|
||||
<span class="input-group-text">日</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3"></div>
|
||||
<div class="col-sm-2 col-md-3"></div>
|
||||
<div class="col-sm-10 col-md-9">
|
||||
<asp:RangeValidator ID="monthRV" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="month" MinimumValue="1" MaximumValue="12" Type="Integer"
|
||||
ErrorMessage="月份應為1~12的數字!"></asp:RangeValidator>
|
||||
<asp:RangeValidator ID="dayRV" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="day" MinimumValue="1" MaximumValue="31" Type="Integer"
|
||||
ErrorMessage="日期應為1~31的數字!"></asp:RangeValidator>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<label class="col-form-label">備註</label>
|
||||
<div class="col-sm-12">
|
||||
<asp:TextBox ID="demo" runat="server" CssClass="form-control" TextMode="MultiLine" Rows="3" placeholder="請輸入備註"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<v-card class="mx-auto mt-10" outlined v-if="this_id!=''">
|
||||
|
||||
<v-data-table
|
||||
:headers="headersDetail"
|
||||
:items="desserts"
|
||||
:footer-props="footersDetail"
|
||||
:search="searchDetail"
|
||||
<%-- :footer-props="{'items-per-page-options':[5,10,15,-1]}"每頁列數--%>
|
||||
:options.sync="optionsDetail" class="elevation-1" fixed-header height="350px"
|
||||
<%-- :server-items-length="desserts_count"--%>
|
||||
|
||||
>
|
||||
<v-divider inset></v-divider>
|
||||
<template v-slot:top>
|
||||
<v-toolbar flat color="white">
|
||||
<div class="d-flex w-100">
|
||||
<v-text-field v-model="searchDetail" append-icon="mdi-magnify" label="查詢" dense outlined single-line hide-details @input="searchData"></v-text-field>
|
||||
<v-btn
|
||||
color="primary"
|
||||
class="ml-2 white--text"
|
||||
@click="addNew">
|
||||
<v-icon dark>mdi-plus</v-icon>新增
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
<template v-slot:item.actitem_num.text="{ item }" >
|
||||
<div class="input-group mb-3" data-search-control="search1" @click="search_show(search_dialog.controls.search1)" v-if="item.id === editedItem.id">
|
||||
|
||||
<input class="form-control search-text" type="text" readonly
|
||||
placeholder="品項名稱" v-model="editedItem.actItem_num.text" >
|
||||
<input type="hidden" v-model="editedItem.actItem_num.val">
|
||||
<button class="btn btn-outline-secondary" type="button">
|
||||
<i class="mdi mdi-view-list-outline"></i>
|
||||
</button>
|
||||
</div>
|
||||
<span v-else>{{item.actItem_num.text}}</span>
|
||||
</template>
|
||||
<template v-slot:item.price="{ item }">
|
||||
<v-text-field v-model="editedItem.price" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field>
|
||||
<span v-else>{{item.price | currency }}</span>
|
||||
</template>
|
||||
<template v-slot:item.qty="{ item }">
|
||||
<v-text-field v-model="editedItem.qty" :hide-details="true" dense single-line v-if="item.id === editedItem.id" ></v-text-field>
|
||||
<span v-else>{{item.qty}}</span>
|
||||
</template>
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<div v-if="item.id === editedItem.id">
|
||||
<v-icon color="red" class="mr-3" @click="cancel">
|
||||
mdi-window-close
|
||||
</v-icon>
|
||||
<v-icon color="green" @click="save">
|
||||
mdi-content-save
|
||||
</v-icon>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-icon color="green" class="mr-3" @click="editItem(item);">
|
||||
mdi-pencil
|
||||
</v-icon>
|
||||
<v-icon color="red" @click="deleteItem(item)">
|
||||
mdi-delete
|
||||
</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-md-offset-2 col-sm-9 col-md-10">
|
||||
<asp:HiddenField ID="HiddenField1" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
<v-dialog v-model="search_dialog.show" max-width="500px">
|
||||
<v-card>
|
||||
<v-card-title class="justify-space-between grey lighten-2">
|
||||
查詢:{{search_dialog.current.title}}
|
||||
<v-btn icon @click="search_dialog.show=false"><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"
|
||||
></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>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
343
web/admin/activity/kind_reg.aspx.cs
Normal file
343
web/admin/activity/kind_reg.aspx.cs
Normal file
@@ -0,0 +1,343 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Linq;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class admin_activity_kind_reg : MyWeb.config
|
||||
{
|
||||
DataTable treeDt = new DataTable();
|
||||
const int LevelMax = Model.activity.KindLevelMax; //分類層數
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public string _this_id = "";
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) {
|
||||
|
||||
BuildTreeView();
|
||||
if (!isStrNull(Request["num"]))
|
||||
{
|
||||
_this_id = ValString(Request["num"]);
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = _db.activity_kind.AsEnumerable().Where(q => q.num == _num).OrderBy(q=>q.kind).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
title_msg.Text = "修改<span class=\"text-primary\">【" + prod.kind + "】</span>的分類名稱";
|
||||
item_name.Text = prod.kind;
|
||||
demo.Text = prod.demo;
|
||||
calendar.SelectedValue = prod.calendar;
|
||||
month.Value = prod.month.HasValue? prod.month.Value.ToString():"";
|
||||
day.Value = prod.day.HasValue ? prod.day.Value.ToString() : "";
|
||||
|
||||
HiddenField1.Value = prod.kind;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect(Request.Url.AbsolutePath );
|
||||
}
|
||||
|
||||
edit.Visible = true;
|
||||
add.Visible = false;
|
||||
down_table.Visible = true;
|
||||
start.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
table.Visible = false;
|
||||
down_table.Visible = false;
|
||||
if (Convert.ToString(Request["msg"]) == "A") { start.Text = "【資料修改成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "B") { start.Text = "【資料新增成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "C") { start.Text = "【資料刪除成功】"; }
|
||||
else { start.Text = "【請點選下方欲新增、修改或刪除的分類】"; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 建立分類
|
||||
|
||||
|
||||
protected void TreeTopology()
|
||||
{
|
||||
MyWeb.sql sql = new MyWeb.sql();
|
||||
OleDbConnection sqlConn = sql.conn(db, p_name);
|
||||
try
|
||||
{
|
||||
sqlConn.Open();
|
||||
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
|
||||
sqlCmd.CommandText = "SELECT num,kind,root FROM activity_kind ORDER BY kind,root, range";
|
||||
treeDt = sql.dataTable(sqlCmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sqlConn.Close();
|
||||
sqlConn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildTreeView()
|
||||
{
|
||||
TreeView2.Nodes.Clear();
|
||||
TreeTopology();
|
||||
BuildChild(0, TreeView2.Nodes);
|
||||
treeDt.Dispose();
|
||||
}
|
||||
|
||||
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
|
||||
{
|
||||
DataTable dt = treeDt;
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
if (row["root"].ToString() == RootUid.ToString())
|
||||
{
|
||||
TreeNode NewNode = new TreeNode();
|
||||
if (Convert.ToString(Request["num"]) == row["num"].ToString() & HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
NewNode.Text = "<b><span style=\"color:blue\">" + row["kind"].ToString() + "</span></b>";
|
||||
if (Level +1 > LevelMax)
|
||||
{
|
||||
ImageButton5.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NewNode.Text = row["kind"].ToString();
|
||||
}
|
||||
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString() ;
|
||||
NewNode.Expand();
|
||||
Nodes.Add(NewNode);
|
||||
if (Level + 1 <= LevelMax)
|
||||
{
|
||||
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增分類按鈕事件
|
||||
|
||||
protected void ImageButton5_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "於<span class=\"text-primary\">【" + HiddenField1.Value + "】</span>分類下,新增次分類";
|
||||
item_name.Text = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
calendar.SelectedValue = "";
|
||||
demo.Text = "";
|
||||
month.Value = "";
|
||||
day.Value = "";
|
||||
_this_id = ValString(Request["num"]);
|
||||
_this_id = "";
|
||||
}
|
||||
protected void ImageButton4_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "<span class=\"text-primary\">於根目錄下,新增主分類</span>";
|
||||
table.Visible = true;
|
||||
item_name.Text = "";
|
||||
calendar.SelectedValue = "";
|
||||
demo.Text = "";
|
||||
month.Value = "";
|
||||
day.Value = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
|
||||
|
||||
HiddenField1.Value = "AddMainItem";
|
||||
BuildTreeView();
|
||||
_this_id = "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
try
|
||||
{
|
||||
Model.activity_kind activity_kind = _db.activity_kind.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (activity_kind != null)
|
||||
{
|
||||
activity_kind.kind = item_name.Text;
|
||||
activity_kind.demo = demo.Text;
|
||||
if (!isStrNull(calendar.SelectedValue)) { activity_kind.calendar = calendar.SelectedValue; } else { activity_kind.calendar = null; };
|
||||
if (!isStrNull(month.Value)) { activity_kind.month = Val(month.Value); } else { activity_kind.month = null; };
|
||||
if (!isStrNull(day.Value)) { activity_kind.day = Val(day.Value); } else { activity_kind.day = null; };
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, "詳細分類:" + item_name.Text);
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "無此資料";
|
||||
}
|
||||
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
int range = 1;
|
||||
int root = 0;
|
||||
|
||||
if (HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
root = Convert.ToInt32(Request["num"]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var prod = _db.activity_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
|
||||
if (prod != null)
|
||||
if (prod.range.HasValue)
|
||||
range = prod.range.Value + 1;
|
||||
|
||||
Model.activity_kind activity_kind = new Model.activity_kind();//新增
|
||||
activity_kind.kind = item_name.Text;
|
||||
activity_kind.demo = demo.Text;
|
||||
activity_kind.root = root;
|
||||
activity_kind.range = range;
|
||||
if (!isStrNull(calendar.SelectedValue)) { activity_kind.calendar = calendar.SelectedValue; } else { activity_kind.calendar = null; };
|
||||
if (!isStrNull(month.Value)) { activity_kind.month = Val(month.Value); } else { activity_kind.month = null; };
|
||||
if (!isStrNull(day.Value)) { activity_kind.day = Val(day.Value); } else { activity_kind.day = null; };
|
||||
|
||||
_db.activity_kind.Add(activity_kind);
|
||||
_db.SaveChanges();
|
||||
int _id = activity_kind.num;
|
||||
if (_id > 0)
|
||||
{
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, "詳細分類:" + item_name.Text);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
}
|
||||
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料刪除
|
||||
|
||||
protected void ImageButton6_Click(object sender, EventArgs e)
|
||||
{
|
||||
int num = Val(Request["num"]);
|
||||
del_product(num);
|
||||
var prod = _db.activity_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
_db.activity_kind.Remove(prod);
|
||||
_db.SaveChanges(); //執行
|
||||
}
|
||||
|
||||
Del_Ohter_Items(Val(Request["num"]));
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Delete, "詳細分類:" + item_name.Text);
|
||||
|
||||
Response.Redirect(Request.Url.AbsolutePath + "?msg=C");
|
||||
}
|
||||
|
||||
public void Del_Ohter_Items(int d_num)
|
||||
{
|
||||
var prod = _db.activity_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
foreach (var row in prod)
|
||||
{
|
||||
del_product(row.num);
|
||||
Del_Ohter_Items(row.num);
|
||||
}
|
||||
//查詢結果全部刪除
|
||||
_db.activity_kind.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public void del_product(int num)
|
||||
{
|
||||
var prod = _db.activities.AsEnumerable().Where(q => q.kind == num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
//清空分類
|
||||
foreach (var item in prod)
|
||||
item.kind = null;
|
||||
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
protected void sortButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("range.aspx");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
75
web/admin/activity/kind_reg2.aspx
Normal file
75
web/admin/activity/kind_reg2.aspx
Normal file
@@ -0,0 +1,75 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="kind_reg2.aspx.cs" Inherits="admin_activity_kind_reg2" %>
|
||||
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="footer_script" runat="Server">
|
||||
<link href="../../App_Script/bootstrap_toggle/css/bootstrap-toggle.min.css" rel="stylesheet" />
|
||||
<script src="../../App_Script/bootstrap_toggle/js/bootstrap-toggle.min.js"></script>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="page_nav" runat="Server">
|
||||
<nav class="mb-1">
|
||||
<asp:LinkButton ID="ImageButton4" runat="server" CausesValidation="False" OnClick="ImageButton4_Click" CssClass="btn btn-primary"><i class="mdi mdi-plus"></i> 新增主類型</asp:LinkButton>
|
||||
|
||||
</nav>
|
||||
<nav class="mb-1">
|
||||
<asp:Button ID="edit" runat="server" Text="修改" Visible="false" OnClick="edit_Click" CssClass="btn btn-primary" />
|
||||
<asp:Button ID="add" runat="server" Text="新增" Visible="false" OnClick="add_Click" CssClass="btn btn-primary" />
|
||||
|
||||
<asp:PlaceHolder ID="down_table" runat="server">
|
||||
<asp:LinkButton ID="ImageButton5" runat="server" OnClick="ImageButton5_Click" CssClass="btn btn-outline-secondary" CausesValidation="False"><i class="mdi mdi-arrow-down-right"></i> 建立下一層選項</asp:LinkButton>
|
||||
<asp:LinkButton ID="ImageButton6" runat="server" OnClientClick="return msgconfirm('是否確定刪除這筆資料?<br>注意!資料刪除後將一併刪除此資料的子選項!',this);" OnClick="ImageButton6_Click" CssClass="btn btn-outline-secondary"><i class="mdi mdi-trash-can"></i> 刪除</asp:LinkButton>
|
||||
</asp:PlaceHolder>
|
||||
</nav>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<uc1:alert runat="server" ID="L_msg" Text="" />
|
||||
<div id="content" class="container-fluid pb-4">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<div class="card shadow-sm my-2" id="sec1">
|
||||
<div class="card-header">選擇類型</div>
|
||||
<div class="card-body">
|
||||
|
||||
<asp:TreeView ID="TreeView2" runat="server" CssClass="aspxTree" ImageSet="Arrows"
|
||||
SkipLinkText="" ShowLines="false" EnableTheming="False" ShowExpandCollapse="True">
|
||||
</asp:TreeView>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<asp:Panel ID="table" runat="server" CssClass="card shadow-sm my-2">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<asp:Label ID="start" runat="server" CssClass="text-danger" Display="Dynamic"></asp:Label>
|
||||
</div>
|
||||
<div>
|
||||
<asp:Label ID="title_msg" runat="server" CssClass="" ForeColor=""></asp:Label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body form-horizontal label-sm-right " role="form">
|
||||
<div>
|
||||
<div class="form-text text-muted">以下 * 欄位為必填欄位</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-2 col-lg-3 col-form-label">* 類型名稱</label>
|
||||
<div class="col-sm-10 col-lg-9">
|
||||
<asp:TextBox ID="item_name" runat="server" CssClass="form-control" MaxLength="100" placeholder="請輸入類型名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="item_name" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-md-offset-2 col-sm-9 col-md-10">
|
||||
<asp:HiddenField ID="HiddenField1" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
307
web/admin/activity/kind_reg2.aspx.cs
Normal file
307
web/admin/activity/kind_reg2.aspx.cs
Normal file
@@ -0,0 +1,307 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Linq;
|
||||
using System.Data.Entity.Infrastructure;
|
||||
|
||||
public partial class admin_activity_kind_reg2 : MyWeb.config
|
||||
{
|
||||
DataTable treeDt = new DataTable();
|
||||
const int LevelMax = Model.news.KindLevelMax; //類型層數
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) {
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
if (!isStrNull(Request["num"]))
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.num == _num).Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
title_msg.Text = "修改<span class=\"text-primary\">【" + prod.kind + "】</span>的類型名稱";
|
||||
item_name.Text = prod.kind;
|
||||
|
||||
HiddenField1.Value = prod.kind;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect(Request.Url.AbsolutePath );
|
||||
|
||||
}
|
||||
|
||||
edit.Visible = true;
|
||||
add.Visible = false;
|
||||
down_table.Visible = true;
|
||||
start.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
table.Visible = false;
|
||||
down_table.Visible = false;
|
||||
if (Convert.ToString(Request["msg"]) == "A") { start.Text = "【資料修改成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "B") { start.Text = "【資料新增成功】"; }
|
||||
else if (Convert.ToString(Request["msg"]) == "C") { start.Text = "【資料刪除成功】"; }
|
||||
else { start.Text = "【請點選下方欲新增、修改或刪除的類型】"; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 建立類型
|
||||
|
||||
|
||||
protected void TreeTopology()
|
||||
{
|
||||
MyWeb.sql sql = new MyWeb.sql();
|
||||
OleDbConnection sqlConn = sql.conn(db, p_name);
|
||||
try
|
||||
{
|
||||
sqlConn.Open();
|
||||
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
|
||||
sqlCmd.CommandText = "SELECT num,kind,root FROM activity_category_kind ORDER BY kind,root, range";
|
||||
treeDt = sql.dataTable(sqlCmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sqlConn.Close();
|
||||
sqlConn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildTreeView()
|
||||
{
|
||||
TreeView2.Nodes.Clear();
|
||||
TreeTopology();
|
||||
BuildChild(0, TreeView2.Nodes);
|
||||
treeDt.Dispose();
|
||||
}
|
||||
|
||||
public void BuildChild(int RootUid, TreeNodeCollection Nodes, int Level=1)
|
||||
{
|
||||
DataTable dt = treeDt;
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
if (row["root"].ToString() == RootUid.ToString())
|
||||
{
|
||||
TreeNode NewNode = new TreeNode();
|
||||
if (Convert.ToString(Request["num"]) == row["num"].ToString() & HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
NewNode.Text = "<b><span style=\"color:blue\">" + row["kind"].ToString() + "</span></b>";
|
||||
if (Level +1 > LevelMax)
|
||||
{
|
||||
ImageButton5.Visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NewNode.Text = row["kind"].ToString();
|
||||
}
|
||||
NewNode.NavigateUrl = Request.Url.AbsolutePath + "?num=" + row["num"].ToString() ;
|
||||
NewNode.Expand();
|
||||
Nodes.Add(NewNode);
|
||||
if (Level + 1 <= LevelMax)
|
||||
{
|
||||
BuildChild((int)row["num"], NewNode.ChildNodes, Level + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增類型按鈕事件
|
||||
|
||||
protected void ImageButton5_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "於<span class=\"text-primary\">【" + HiddenField1.Value + "】</span>類型下,新增次類型";
|
||||
item_name.Text = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
|
||||
}
|
||||
protected void ImageButton4_Click(object sender, EventArgs e)
|
||||
{
|
||||
title_msg.Text = "<span class=\"text-primary\">於根目錄下,新增主類型</span>";
|
||||
table.Visible = true;
|
||||
item_name.Text = "";
|
||||
add.Visible = true;
|
||||
edit.Visible = false;
|
||||
down_table.Visible = false;
|
||||
start.Visible = false;
|
||||
HiddenField1.Value = "AddMainItem";
|
||||
BuildTreeView();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
try
|
||||
{
|
||||
Model.activity_category_kind activity_category_kind = _db.activity_category_kind.Where(q => q.num == _num).FirstOrDefault();//修改
|
||||
if (activity_category_kind != null)
|
||||
{
|
||||
activity_category_kind.kind = item_name.Text;
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, "主類型:" + item_name.Text);
|
||||
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "無此資料";
|
||||
}
|
||||
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
int range = 1;
|
||||
int root = 0;
|
||||
|
||||
if (HiddenField1.Value != "AddMainItem")
|
||||
{
|
||||
root = Convert.ToInt32(Request["num"]);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.root == root).OrderByDescending(q => q.range).FirstOrDefault();
|
||||
if (prod != null)
|
||||
if (prod.range.HasValue)
|
||||
range = prod.range.Value + 1;
|
||||
|
||||
Model.activity_category_kind activity_category_kind = new Model.activity_category_kind();//新增
|
||||
activity_category_kind.kind = item_name.Text;
|
||||
activity_category_kind.root = root;
|
||||
activity_category_kind.range = range;
|
||||
|
||||
_db.activity_category_kind.Add(activity_category_kind);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, "主類型:" + item_name.Text);
|
||||
|
||||
L_msg.Type = alert_type.success;
|
||||
L_msg.Text = "操作成功";
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
BuildTreeView();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料刪除
|
||||
|
||||
protected void ImageButton6_Click(object sender, EventArgs e)
|
||||
{
|
||||
int num = Val(Request["num"]);
|
||||
|
||||
del_product(num);
|
||||
|
||||
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.num == num).FirstOrDefault(); //刪除該筆資料
|
||||
if (prod != null)
|
||||
{
|
||||
_db.activity_category_kind.Remove(prod);
|
||||
_db.SaveChanges(); //執行
|
||||
}
|
||||
|
||||
|
||||
Del_Ohter_Items(Val(Request["num"]));
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Delete, "主類型:" + item_name.Text);
|
||||
|
||||
Response.Redirect(Request.Url.AbsolutePath + "?msg=C");
|
||||
}
|
||||
|
||||
public void Del_Ohter_Items(int d_num)
|
||||
{
|
||||
var prod = _db.activity_category_kind.AsEnumerable().Where(q => q.root == d_num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
foreach (var row in prod)
|
||||
{
|
||||
del_product(row.num);
|
||||
Del_Ohter_Items(row.num);
|
||||
}
|
||||
|
||||
//查詢結果全部刪除
|
||||
_db.activity_category_kind.RemoveRange(prod);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void del_product(int num) //刪除訊息
|
||||
{
|
||||
//EF Model 資料庫拉關聯 , 故刪除類型前,一定要先刪除訊息,否則關聯會出錯
|
||||
var prod = _db.activities.AsEnumerable().Where(q => q.category_kind == num).ToList();
|
||||
if (prod.Count > 0)
|
||||
{
|
||||
|
||||
//改為清空類型
|
||||
foreach (var item in prod)
|
||||
item.kind = null;
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void sortButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("range.aspx");
|
||||
}
|
||||
}
|
||||
1262
web/admin/activity/reg.aspx
Normal file
1262
web/admin/activity/reg.aspx
Normal file
File diff suppressed because it is too large
Load Diff
393
web/admin/activity/reg.aspx.cs
Normal file
393
web/admin/activity/reg.aspx.cs
Normal file
@@ -0,0 +1,393 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
|
||||
public partial class admin_activity_reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
public string _category_kindTxt = "相關";
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
BuildKind();
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
//var qry = _db.activities.AsEnumerable();
|
||||
var prod = _db.activities.Where(q => q.num == _num).FirstOrDefault();
|
||||
|
||||
if (prod != null)
|
||||
{
|
||||
|
||||
BuildKind();
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = prod.GetType().GetProperty(obj.ID).GetValue(prod, null);
|
||||
if (!isStrNull(ObjValue))
|
||||
{
|
||||
var textBox = (TextBox)obj;
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
{
|
||||
textBox.Text = Convert.ToDateTime(ObjValue).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox.Text = ObjValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (obj is DropDownList && ((DropDownList)obj).SelectedIndex == 0)
|
||||
{
|
||||
var ObjValue = prod.GetType().GetProperty(obj.ID).GetValue(prod, null);
|
||||
if (!isStrNull(ObjValue))
|
||||
{
|
||||
var dropDown = (DropDownList)obj;
|
||||
dropDown.SelectedValue = ObjValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
if (prod.kind.HasValue)
|
||||
{
|
||||
kind_txt.Value = prod.activity_kind.kind;
|
||||
kind.Value = prod.kind.Value.ToString();
|
||||
kind_txt2.Text = "<div class='pt-2'>" + prod.activity_kind.kind + "</div>";
|
||||
}
|
||||
if (prod.category_kind.HasValue)
|
||||
{
|
||||
_category_kindTxt = prod.activity_category_kind.kind;
|
||||
category_kind_txt.Value = prod.activity_category_kind.kind;
|
||||
category_kind.Value = prod.category_kind.Value.ToString();
|
||||
}
|
||||
if (prod.startDate_solar.HasValue)
|
||||
{
|
||||
startDate_lunar.Text= publicFun.chagenDate(prod.startDate_solar);
|
||||
}
|
||||
if (prod.endDate_solar.HasValue)
|
||||
{
|
||||
endDate_lunar.Text = publicFun.chagenDate(prod.endDate_solar);
|
||||
}
|
||||
|
||||
if (prod.reg_time.HasValue)
|
||||
{
|
||||
timePanel1.Visible = true;
|
||||
reg_time.Text = prod.reg_time.Value.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
}
|
||||
kindPH.Visible = false;
|
||||
|
||||
|
||||
edit.Visible = true;
|
||||
goback.Visible = true;
|
||||
add.Visible = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void goback_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
|
||||
#region 分類
|
||||
|
||||
|
||||
|
||||
public void BuildKind()
|
||||
{
|
||||
|
||||
}
|
||||
protected void kind_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
//if (isStrNull(Request["num"])) // 只有新增時帶入預設
|
||||
//{
|
||||
// if (!isStrNull(kind.SelectedValue))
|
||||
// {
|
||||
// int _kind = Val(kind.SelectedValue);
|
||||
// //日期
|
||||
// var prop3 = _db.activity_kind.Where(q => q.num == _kind).FirstOrDefault();
|
||||
// if (prop3 != null)
|
||||
// {
|
||||
// ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
|
||||
|
||||
// string _calendar = prop3.calendar;
|
||||
// DateTime _today = DateTime.Now;
|
||||
// if (_calendar == "國曆")
|
||||
// {
|
||||
// DateTime _newDay = Convert.ToDateTime(DateTime.Now.Year + "/" + prop3.month + "/" + prop3.day);
|
||||
// if (_today.Month >= prop3.month && _today.Day >= prop3.day)
|
||||
// {
|
||||
// //過期->預設明年
|
||||
// _newDay = Convert.ToDateTime(DateTime.Now.AddYears(1).Year + "/" + prop3.month + "/" + prop3.day);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //未過期->預設今年
|
||||
// }
|
||||
|
||||
// startDate_solar.Text = _newDay.ToString("yyyy-MM-dd");
|
||||
// endDate_solar.Text = _newDay.ToString("yyyy-MM-dd");
|
||||
|
||||
// DateTime _newDay2 = Convert.ToDateTime(chineseDate.GetYear(_newDay) + "/" + chineseDate.GetMonth(_newDay) + "/" + chineseDate.GetDayOfMonth(_newDay));
|
||||
// startDate_lunar.Text = _newDay2.ToString("yyyy-MM-dd");
|
||||
// endDate_lunar.Text = _newDay2.ToString("yyyy-MM-dd");
|
||||
|
||||
// //TaiwanLunisolarCalendar tlc = new TaiwanLunisolarCalendar();
|
||||
// //DateTime _newDay3 = Convert.ToDateTime(tlc.GetYear(_newDay) + "/" + tlc.GetMonth(_newDay) + "/" + tlc.GetDayOfMonth(_newDay));
|
||||
// // -> TaiwanLunisolarCalendar 民國年農曆
|
||||
|
||||
|
||||
// }
|
||||
// else if (_calendar == "農曆")
|
||||
// {
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// //項目
|
||||
// DataTable dt = createNewDt();
|
||||
// var qry = _db.activity_kind_detail.AsEnumerable().Where(q => q.activity_kind_num == _kind && q.actItem.status == "Y");
|
||||
// var prop = qry.OrderBy(q => q.reg_time).ToList();
|
||||
// if (prop.Count > 0)
|
||||
// {
|
||||
// foreach (var item in prop)
|
||||
// {
|
||||
// DataRow dr = dt.NewRow();
|
||||
// //dr["num"] = item.actItem_num;
|
||||
// dr["num"] = ""; //新增時為空
|
||||
// dr["actItem_num"] = item.actItem_num;
|
||||
// dr["price"] = item.price.HasValue ? item.price.Value.ToString() : "";
|
||||
// dr["qty"] = item.qty.HasValue ? item.qty.Value.ToString() : "";
|
||||
// dt.Rows.Add(dr);
|
||||
// }
|
||||
// }
|
||||
// Repeater1.DataSource = dt;
|
||||
// Repeater1.DataBind();
|
||||
// //var query =
|
||||
// //from c in _db.actItems.AsEnumerable()
|
||||
// //where ((from o in _db.activity_kind_detail.AsEnumerable()
|
||||
// // where o.activity_kind_num == _kind
|
||||
// // select o.actItem_num)
|
||||
// // .Contains(c.num) && c.status=="Y")
|
||||
// //select c;
|
||||
|
||||
// dt = createNewDt2();
|
||||
// var prop2 = qry.Where(q=>q.actItem.spares=="Y").OrderBy(q => q.reg_time).ToList();
|
||||
// if (prop2.Count > 0)
|
||||
// {
|
||||
// foreach (var item in prop2)
|
||||
// {
|
||||
// DataRow dr = dt.NewRow();
|
||||
// dr["num"] = "";
|
||||
// dr["actItem_num"] = item.actItem_num;
|
||||
// dr["qty1"] = item.qty.HasValue ? item.qty.Value.ToString() : "";
|
||||
// dr["qty2"] = "";
|
||||
// dr["demo"] = "";
|
||||
// dt.Rows.Add(dr);
|
||||
// }
|
||||
// }
|
||||
// Repeater2.DataSource = dt;
|
||||
// Repeater2.DataBind();
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Repeater1.DataSource = null;
|
||||
// Repeater1.DataBind();
|
||||
// Repeater2.DataSource = null;
|
||||
// Repeater2.DataBind();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid) {
|
||||
L_msg.Text = "";
|
||||
|
||||
Model.activity activity = new Model.activity();
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = activity.GetType().GetProperty(obj.ID);
|
||||
var textBox = (TextBox)obj;
|
||||
if (!isStrNull(textBox.Text))
|
||||
{
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
ObjValue.SetValue(activity, selectDate(textBox));
|
||||
|
||||
else
|
||||
ObjValue.SetValue(activity, ((TextBox)obj).Text.Trim());
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(activity, null);
|
||||
|
||||
}
|
||||
else if (obj is DropDownList)
|
||||
{
|
||||
var ObjValue = activity.GetType().GetProperty(obj.ID);
|
||||
var dropDown = (DropDownList)obj;
|
||||
if (!isStrNull(dropDown.SelectedValue))
|
||||
{
|
||||
if (!isStrNull(dropDown.Attributes["data-int"]) && ValString(dropDown.Attributes["data-int"]).Equals("Y"))
|
||||
ObjValue.SetValue(activity, Val(dropDown.SelectedValue));
|
||||
else
|
||||
ObjValue.SetValue(activity, dropDown.SelectedValue);
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(activity, null);
|
||||
}
|
||||
}
|
||||
|
||||
// printInit 欄位
|
||||
//var printInitValue = printInit.Text.Trim();
|
||||
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
|
||||
|
||||
activity.kind = Val(kind.Value);
|
||||
activity.category_kind = Val(category_kind.Value);
|
||||
activity.reg_time = DateTime.Now;
|
||||
_db.activities.Add(activity);
|
||||
_db.SaveChanges();
|
||||
int _id = activity.num;
|
||||
if (_id > 0)
|
||||
{
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Insert, subject.Text);
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "Error";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 資料修改
|
||||
|
||||
protected void edit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid)
|
||||
{
|
||||
L_msg.Text = "";
|
||||
|
||||
int _num = Val(Request["num"]);
|
||||
Model.activity activity = _db.activities.Where(q => q.num == _num).FirstOrDefault(); // 修改
|
||||
if (activity != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (Control obj in cardBodyPanel.Controls)
|
||||
{
|
||||
if (obj is TextBox)
|
||||
{
|
||||
var ObjValue = activity.GetType().GetProperty(obj.ID);
|
||||
var textBox = (TextBox)obj;
|
||||
if (!isStrNull(textBox.Text))
|
||||
{
|
||||
if (textBox.TextMode == TextBoxMode.Date)
|
||||
ObjValue.SetValue(activity, selectDate(textBox));
|
||||
else
|
||||
ObjValue.SetValue(activity, ((TextBox)obj).Text.Trim());
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(activity, null);
|
||||
}
|
||||
else if (obj is DropDownList)
|
||||
{
|
||||
var ObjValue = activity.GetType().GetProperty(obj.ID);
|
||||
var dropDown = (DropDownList)obj;
|
||||
if (!isStrNull(dropDown.SelectedValue))
|
||||
{
|
||||
if (!isStrNull(dropDown.Attributes["data-int"]) && ValString(dropDown.Attributes["data-int"]).Equals("Y"))
|
||||
ObjValue.SetValue(activity, Val(dropDown.SelectedValue));
|
||||
else
|
||||
ObjValue.SetValue(activity, dropDown.SelectedValue);
|
||||
}
|
||||
else
|
||||
ObjValue.SetValue(activity, null);
|
||||
}
|
||||
}
|
||||
|
||||
// printInit 欄位
|
||||
//var printInitValue = printInit.Text.Trim();
|
||||
//activity.print_init = !string.IsNullOrEmpty(printInitValue) ? printInitValue : null;
|
||||
|
||||
activity.category_kind = Val(category_kind.Value);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Activity, (int)Model.admin_log.Status.Update, subject.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "查無資料";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
230
web/admin/activity/statistics/activity.aspx
Normal file
230
web/admin/activity/statistics/activity.aspx
Normal file
@@ -0,0 +1,230 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="activity.aspx.cs" Inherits="admin_activity_statistics_activity" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server" />
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server" />
|
||||
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<div class="container mt-1" id="app">
|
||||
<v-container fluid>
|
||||
<v-card class="elevation-2 pa-4 rounded-lg">
|
||||
<!-- 標題 -->
|
||||
<v-row justify="center">
|
||||
<v-col cols="12" class="text-center">
|
||||
<v-icon size="36" color="primary">mdi-account-group</v-icon>
|
||||
<h2 class="font-weight-bold mt-2">參加活動信眾統計表</h2>
|
||||
<v-divider class="my-4"></v-divider>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- 匯出按鈕 -->
|
||||
<v-row class="align-center mb-4">
|
||||
<v-col cols="12" class="text-right">
|
||||
<v-btn color="green darken-2" class="white--text" @click="exportToExcel">
|
||||
<v-icon left>mdi-microsoft-excel</v-icon> 匯出 Excel
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- 全選/取消 -->
|
||||
<v-row class="mb-3" justify="start" align="center" dense>
|
||||
<v-col cols="auto" class="pr-1">
|
||||
<v-btn small color="primary" @click="selectAll">全選</v-btn>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="pl-1">
|
||||
<v-btn small color="primary" @click="deselectAll">取消全選</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-data-table
|
||||
:headers="statistics.summary_headers"
|
||||
:items="statistics.summary_rows"
|
||||
class="elevation-1 rounded-lg"
|
||||
dense
|
||||
hide-default-footer
|
||||
disable-sort
|
||||
>
|
||||
<!-- 勾選欄:主項名稱(對齊左邊) -->
|
||||
<template #item.label="{ item }">
|
||||
<div>
|
||||
<v-checkbox
|
||||
v-model="exportSettings.selectedItems"
|
||||
:value="item.label"
|
||||
hide-details
|
||||
dense
|
||||
class="mr-2 text-center"
|
||||
></v-checkbox>
|
||||
<span class="font-weight-medium">{{ item.label }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 數量欄:對齊右邊 -->
|
||||
<template #item.value="{ item }">
|
||||
<div class="text-center font-weight-bold pr-2">
|
||||
{{ item.value }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 名單勾選欄:置中 -->
|
||||
<template #item.include_followers="{ item }">
|
||||
<div>
|
||||
<v-checkbox
|
||||
v-if="item.canHaveFollowers"
|
||||
v-model="exportSettings.itemFollowers[item.label]"
|
||||
hide-details
|
||||
dense
|
||||
class="ma-0"
|
||||
color="primary"
|
||||
label="含名單"
|
||||
></v-checkbox>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</v-data-table>
|
||||
|
||||
</v-card>
|
||||
</v-container>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="footer_script" Runat="Server">
|
||||
<!-- 匯出套件 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js"></script>
|
||||
|
||||
<script>
|
||||
let VueApp = new Vue({
|
||||
el: "#app",
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
this_id: '<%= Request["num"] %>',
|
||||
exportSettings: {
|
||||
selectedItems: [],
|
||||
itemFollowers: {}
|
||||
},
|
||||
statistics: {
|
||||
summary_rows: [],
|
||||
summary_headers: [
|
||||
{ text: '項目(勾選匯出)', value: 'label', align: 'center' },
|
||||
{ text: '數量', value: 'value', align: 'center' },
|
||||
{ text: '名單', value: 'include_followers', align: 'center' }
|
||||
]
|
||||
},
|
||||
raw_gdz_items: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getGDZCount();
|
||||
},
|
||||
methods: {
|
||||
getGDZCount() {
|
||||
axios.post(HTTP_HOST + 'api/statistics/GDZCount', null, {
|
||||
params: { activity_num: this.this_id }
|
||||
}).then(res => {
|
||||
const raw = res.data;
|
||||
this.raw_gdz_items = raw.gdz_item_counts;
|
||||
|
||||
this.statistics.summary_rows = [
|
||||
{ label: "報名總人數", value: raw.all_count },
|
||||
{ label: "功德主人數", value: raw.all_gdz_count }
|
||||
];
|
||||
|
||||
raw.gdz_item_counts.forEach(item => {
|
||||
this.statistics.summary_rows.push({
|
||||
label: item.item_name,
|
||||
value: item.count,
|
||||
canHaveFollowers: true
|
||||
});
|
||||
this.$set(this.exportSettings.itemFollowers, item.item_name, false);
|
||||
});
|
||||
});
|
||||
},
|
||||
exportToExcel() {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = now.getDate().toString().padStart(2, '0');
|
||||
const hour = now.getHours().toString().padStart(2, '0');
|
||||
const minute = now.getMinutes().toString().padStart(2, '0');
|
||||
const dateStr = `${year}-${month}-${day} ${hour}:${minute}`;
|
||||
const filename = `活動統計明細_${dateStr.replace(/[: ]/g, '_')}.xlsx`;
|
||||
|
||||
const selectedLabels = this.exportSettings.selectedItems;
|
||||
const selectedItems = this.raw_gdz_items.filter(item =>
|
||||
selectedLabels.includes(item.item_name)
|
||||
);
|
||||
|
||||
const aoa = [];
|
||||
|
||||
// 統計時間
|
||||
aoa.push([`統計時間:`, `${dateStr}`]);
|
||||
const totalRow = this.statistics.summary_rows.find(r => r.label === '報名總人數');
|
||||
const gdzRow = this.statistics.summary_rows.find(r => r.label === '功德主人數');
|
||||
if (totalRow) aoa.push([totalRow.label, totalRow.value + '人']);
|
||||
if (gdzRow) aoa.push([gdzRow.label, gdzRow.value + '人']);
|
||||
aoa.push([])
|
||||
aoa.push(['牌位功德項目', '數量', '供花果,供齋', '數量', '金額']);
|
||||
|
||||
selectedItems.forEach(item => {
|
||||
if (!item.item_name.includes('供') && !item.item_name.includes('齋')) {
|
||||
aoa.push([item.item_name, `${item.count}`]);
|
||||
const includeFollowers = this.exportSettings.itemFollowers[item.item_name];
|
||||
if (includeFollowers && Array.isArray(item.followers)) {
|
||||
item.followers.forEach((name, index) => {
|
||||
aoa.push(['', index + 1 + '.' + name]);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
var row = 5
|
||||
selectedItems.forEach(item => {
|
||||
if (item.item_name.includes('供') || item.item_name.includes('齋')) {
|
||||
if (!aoa[row]) aoa[row] = []; // 防止該行不存在
|
||||
//aoa.push([item.item_name + ' 總計金額:' + item.total_price, `${item.count}`]);
|
||||
aoa[row][2] = item.item_name;
|
||||
aoa[row][3] = `${item.count}`;
|
||||
aoa[row][4] = '$' + item.total_price;
|
||||
row++;
|
||||
const includeFollowers = this.exportSettings.itemFollowers[item.item_name];
|
||||
if (includeFollowers && Array.isArray(item.followers)) {
|
||||
item.followers.forEach((name, index) => {
|
||||
//aoa.push(['', index + 1 + '.' + name]);
|
||||
aoa[row][2] = index + 1 + '.' + name
|
||||
const gk = item.amountsByFollower.find(x => x.follower === name);
|
||||
const amount = '$' + gk.amount; // 找不到就回傳 0 或其他預設值
|
||||
aoa[row][4] = amount
|
||||
row++;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
const sheet = XLSX.utils.aoa_to_sheet(aoa);
|
||||
|
||||
const range = XLSX.utils.decode_range(sheet['!ref']);
|
||||
for (let R = range.s.r; R <= range.e.r; ++R) {
|
||||
for (let C = range.s.c; C <= range.e.c; ++C) {
|
||||
const cell_address = XLSX.utils.encode_cell({ r: R, c: C });
|
||||
if (!sheet[cell_address]) continue;
|
||||
if (!sheet[cell_address].s) sheet[cell_address].s = {};
|
||||
sheet[cell_address].s.alignment = { horizontal: 'center', vertical: 'center' };
|
||||
}
|
||||
}
|
||||
|
||||
const workbook = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(workbook, sheet, '統計資料');
|
||||
const wbout = XLSX.write(workbook, { bookType: 'xlsx', type: 'array', cellStyles: true });
|
||||
const blob = new Blob([wbout], { type: 'application/octet-stream' });
|
||||
saveAs(blob, filename);
|
||||
},
|
||||
selectAll() {
|
||||
this.exportSettings.selectedItems = this.statistics.summary_rows
|
||||
.map(row => row.label);
|
||||
},
|
||||
deselectAll() {
|
||||
this.exportSettings.selectedItems = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</asp:Content>
|
||||
14
web/admin/activity/statistics/activity.aspx.cs
Normal file
14
web/admin/activity/statistics/activity.aspx.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class admin_activity_statistics_activity : MyWeb.config
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
144
web/admin/activity/statistics/index.aspx
Normal file
144
web/admin/activity/statistics/index.aspx
Normal file
@@ -0,0 +1,144 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_statistics_index" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
||||
<div class="col-2">
|
||||
<select class="form-select" v-model="selected_activity">
|
||||
<option disabled value="">請選擇活動</option>
|
||||
<option v-for="(item, index) in activity_list" :key="index" :value="item.num">
|
||||
{{item.subject}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<div class="container-fluid mt-1">
|
||||
<div class="text-center text-h5 font-weight-bold my-4">
|
||||
活動統計報表
|
||||
</div>
|
||||
<v-data-table
|
||||
multi-sort
|
||||
:headers="activity_statistics.headers"
|
||||
item-key="id"
|
||||
:loading="activity_statistics.loading"
|
||||
:loading-text="activity_statistics.loadingtext"
|
||||
:options.sync="activity_statistics.options"
|
||||
:items-per-page="activity_statistics.options.itemsPerPage"
|
||||
:server-items-length="activity_statistics.totalItems"
|
||||
:items="activity_statistics.items">
|
||||
<template #item.detail_btn="{item}">
|
||||
<a :href="'activity.aspx?num='+item.id" class="btn btn-outline-secondary btn-sm" target="_blank">詳細統計</a>
|
||||
</template>
|
||||
<template #item.duetime="{item}">
|
||||
{{item.startdate|timeString("YYYY/MM/DD")}}-{{item.enddate|timeString("YYYY/MM/DD")}}
|
||||
</template>
|
||||
</v-data-table>
|
||||
</div>
|
||||
<div class="container-fluid mt-1">
|
||||
<div class="text-center text-h5 font-weight-bold my-4">信眾統計表</div>
|
||||
<p>
|
||||
{{activity_statistics.allGDZCount}}
|
||||
</p>
|
||||
</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 {
|
||||
activity_list: [],
|
||||
selected_activity: '',
|
||||
activity_statistics: {
|
||||
loading: false,
|
||||
loadingtext: "資料載入中...",
|
||||
headers: [
|
||||
{ text: '活動名稱', value: 'activity_name' },
|
||||
{ text: '報名人數', value: 'order_count' },
|
||||
{ text: '應收功德金', value: 'receivable' },
|
||||
{ text: '實收功德金', value: 'received' },
|
||||
{ text: '牌位總數', value: 'pw_count' },
|
||||
{ text: '新增信眾人數', value: '' },//針對當前活動
|
||||
{ text: '流失信眾人數', value: '' },//針對當前活動
|
||||
{ text: '回歸信眾人數', value: '' },//針對當前活動
|
||||
{ text: '連續多次參加信眾人數', value: '' },//針對當前活動
|
||||
{ text: '功德主人數', value: 'gdz_peoples' },
|
||||
{ text: '活動時間', value: 'duetime' },
|
||||
{ text: '活動狀態', value: 'activity_status' },
|
||||
{ text: '', value: 'detail_btn' }
|
||||
],
|
||||
items: [],
|
||||
totalItems: 0,
|
||||
options: {
|
||||
page: 1,
|
||||
itemsPerPage: 5,
|
||||
sortBy: [],
|
||||
sortDesc: [],
|
||||
},
|
||||
|
||||
allGDZCount: 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getActivityList();
|
||||
//this.getActivityStatistics();
|
||||
},
|
||||
methods: {
|
||||
getActivityList() {
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/statistics/activitylist')
|
||||
.then(res => {
|
||||
this.activity_list = res.data
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
})
|
||||
},
|
||||
getActivityStatistics() {
|
||||
this.activity_statistics.loading = true;
|
||||
const { page, itemsPerPage } = this.activity_statistics.options;
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/statistics/activitycountlist', null, { params:{ page: page, pagesize: itemsPerPage }})
|
||||
.then(res => {
|
||||
this.activity_statistics.items = res.data.items;
|
||||
this.activity_statistics.totalItems = res.data.count;
|
||||
console.log(this.activity_statistics.options)
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
})
|
||||
.finally(() => {
|
||||
this.activity_statistics.loading = false;
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selected_activity: {
|
||||
handler(newvalue, oldvalue) {
|
||||
console.log('新值:', newvalue);
|
||||
console.log('舊值:', oldvalue);
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
'activity_statistics.options': {
|
||||
handler() {
|
||||
this.getActivityStatistics();
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
14
web/admin/activity/statistics/index.aspx.cs
Normal file
14
web/admin/activity/statistics/index.aspx.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
public partial class admin_statistics_index : MyWeb.config
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user