migrate to new git
This commit is contained in:
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>
|
||||
|
||||
Reference in New Issue
Block a user