Files
17168ERP/web/admin/stock/index.aspx
2025-08-29 01:27:25 +08:00

475 lines
22 KiB
Plaintext

<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_stock_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="news_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" 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: 'uptime' },
{ text: '進出類型', value: 'category_Txt' },
{ text: '異動原因', value: 'reasonsTxt'},
{ text: '進出倉庫', value: 'kindsTxt'},
{ text: '相關活動', value: 'activity_Txt' },
{ text: '品項', value: 'actItem_Txt' },
{ text: '數量', value: 'qty' },
{ text: '進貨單價', value: 'price' },
{ text: '', value: 'slot_btn', sortable: false, align: 'end' },
],
footer: {
showFirstLastPage: true,
itemsPerPageOptions:[5,10,20,30],
},
},
search: {
kind: '',
category: '',
uptime1: '',
uptime2: '',
activity_num: '',
activity_num_txt: '',
actItem_num: '',
mem_num_txt: '',
debtor: '',
}//
,
search_dialog: {
controls: {
search1: {
id: 'search1',
title: '倉庫',
text_prop: 'kind',
value_prop: 'num',
keys: [
{ id: 'kind', title: '倉庫名稱', value: '' },
],
api_url: HTTP_HOST + 'api/stock/GetKindList',
columns: [
{ id: 'kind', title: '倉庫名稱', value: '' },
],
selected: {},
select(t,data) {
console.log("select search1", t);
data.search.kind=t.num
}
}, search2: {
id: 'search2',
title: '相關活動',
text_prop: 'subject',
value_prop: 'num',
keys: [
{ id: 'subject', title: '活動名稱', value: '' },
{ id: 'kindTxt', title: '活動分類' },
],
api_url: HTTP_HOST + 'api/activity/GetList',
columns: [
{ id: 'subject', title: '活動名稱' },
{ id: 'kindTxt', title: '活動分類' },
],
selected: {},
select(t, data) {
console.log("select search2", t);
//帶出明細
if (t != null) {
}
}
}, 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: '項目名稱' },
{ id: 'kindTxt', title: '項目分類' },
],
selected: {},
select(t, data) {
console.log("select search3", t);
}
},
},
show: false,
current: {},
list: [],
count: 0,
page: 1,
loading: false,
footer: {
showFirstLastPage: true,
disableItemsPerPage: true,
itemsPerPageAllText: '',
itemsPerPageText: '',
},
},
snackbar: {
show: false,
text: "",
}
}
}, mounted() {
this.search_dialog.current = this.search_dialog.controls.search1
},
watch: {
options: {
handler() {
this.getDefault()
this.search_get()
console.log("watch2", this.search_dialog, this.search_dialog.page);
},
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/stock/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/stock/' + 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/stock/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()
},//===
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)
},
},
})
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<uc1:alert runat="server" ID="L_msg" Text="" />
<div id="content" class="container-md">
<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.uptime="{ item }" >
{{ item.uptime|timeString('YYYY/MM/DD') }}
</template>
<template #item.slot_btn="{ item }">
<a :href="'news_reg.aspx?num='+item.num" class="btn btn-outline-secondary btn-sm"><i class="mdi mdi-magnify"></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>
<div class="input-group">
<input type="date" v-model="search.uptime1" class="form-control" autocomplete="off" id="uptime1" runat="server">
<span class="input-group-text" >~</span>
<input type="date" v-model="search.uptime2" class="form-control" autocomplete="off" id="uptime2" runat="server">
</div>
</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>
<asp:DropDownList ID="s_kind" runat="server" CssClass="form-select" v-model="search.kind" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
<%-- 測試--%>
<div class="input-group mb-3 d-none" 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="mb-3">
<label class="form-label">相關活動</label>
<input type="text" v-model="search.activity_num_txt" class="form-control" placeholder="可輸入關鍵字查詢" id="activity_num_txt" runat="server">
</div>
<div class="mb-3">
<label class="form-label">相關活動</label>
<asp:DropDownList ID="s_activity_num" runat="server" CssClass="form-select" v-model="search.activity_num" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">品項</label>
<asp:DropDownList ID="s_actItem_num" runat="server" CssClass="form-select" v-model="search.actItem_num" >
<asp:ListItem Value="" Text="請選擇"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="mb-3">
<label class="form-label">內部負責人 </label>
<input type="text" v-model="search.mem_num_txt" class="form-control" placeholder="可輸入關鍵字查詢" id="mem_num_txt" runat="server">
</div>
<div class="mb-3">
<label class="form-label">外部借出人 </label>
<input type="text" v-model="search.debtor" class="form-control" placeholder="可輸入關鍵字查詢" id="debtor" runat="server">
</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>
<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"
>
{{ 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>