migrate to new git
This commit is contained in:
223
web/admin/files/index.aspx
Normal file
223
web/admin/files/index.aspx
Normal file
@@ -0,0 +1,223 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="index.aspx.cs" Inherits="admin_files_index" %>
|
||||
|
||||
<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">
|
||||
|
||||
|
||||
<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: 'start_date' },
|
||||
{ text: '最後編輯日期', value: 'end_date' },
|
||||
{ text: '', value: 'slot_btn', sortable: false, align: 'end' }
|
||||
],
|
||||
footer:{
|
||||
showFirstLastPage: true,
|
||||
itemsPerPageOptions:[5,10,20,30],
|
||||
},
|
||||
},
|
||||
search: {
|
||||
subject: '',
|
||||
reg_time1: '',
|
||||
reg_time2: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
handler() {
|
||||
this.getDefault()
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getDefault() {
|
||||
const { sortBy, sortDesc, page, itemsPerPage } = this.options
|
||||
const params = {
|
||||
sortBy: sortBy[0], sortDesc: sortDesc[0],
|
||||
page: page, pageSize: itemsPerPage
|
||||
};
|
||||
this.data_table.loading = true
|
||||
axios
|
||||
.post(HTTP_HOST + 'api/FilesSet/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/FilesSet/' + 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/FilesSet/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
|
||||
|
||||
})
|
||||
.catch(error => console.log(error))
|
||||
}
|
||||
},
|
||||
btn_search() {
|
||||
this.page = 1;
|
||||
this.getDefault()
|
||||
},
|
||||
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">
|
||||
<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 }" >
|
||||
{{ item.reg_time|timeString('YYYY/MM/DD') }}
|
||||
</template>
|
||||
<template #item.end_date="{ item }" >
|
||||
{{ item.modify_time|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>
|
||||
|
||||
58
web/admin/files/index.aspx.cs
Normal file
58
web/admin/files/index.aspx.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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;
|
||||
|
||||
public partial class admin_files_index : MyWeb.config
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 匯出Excel
|
||||
|
||||
protected void excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
//請參考訂單系統的匯出
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
72
web/admin/files/reg.aspx
Normal file
72
web/admin/files/reg.aspx
Normal file
@@ -0,0 +1,72 @@
|
||||
<%@ Page Title="後端管理" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="reg.aspx.cs" Inherits="admin_files_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">
|
||||
<!--編緝器-->
|
||||
<script type="text/javascript" src="<%=ResolveUrl("~/admin/ckeditor/ckeditor.js") %>"></script>
|
||||
<script type="text/javascript">
|
||||
CKEDITOR.config.toolbar = 'Default';
|
||||
</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">
|
||||
</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-3">
|
||||
<div class="card-header">
|
||||
文件格式設定
|
||||
</div>
|
||||
<asp:Panel ID="cardBodyPanel" runat="server" CssClass="card-body">
|
||||
<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-10 col-lg-5 mb-2">
|
||||
<asp:TextBox ID="subject" MaxLength="50" runat="server" CssClass="form-control" placeholder="請輸入列印文件名稱"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="subject" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true"></asp:RequiredFieldValidator>
|
||||
</div>
|
||||
<label class="col-sm-2 col-form-label">建立日期 *</label>
|
||||
<div class="col-sm-10 col-lg-3">
|
||||
<asp:TextBox ID="reg_time" runat="server" CssClass="form-control" TextMode="Date"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="reg_time" 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-10 col-lg-3">
|
||||
<asp:TextBox ID="paperset" runat="server" CssClass="form-control" placeholder="請輸入樣板紙張設定,如: tblt-m " ToolTip="如未設定則預設為tablet-l"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row mb-1">
|
||||
<label class="col-form-label">內容 *</label>
|
||||
<div class="">
|
||||
<asp:TextBox ID="word" runat="server" CssClass="ckeditor" TextMode="MultiLine"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="v_word" ControlToValidate="word" runat="server" ErrorMessage="必填!" Display="Dynamic" SetFocusOnError="true" EnableClientScript="False"></asp:RequiredFieldValidator>
|
||||
<asp:Panel ID="modifyPanel" runat="server" CssClass="text-secondary" Visible="false">最後修改日期:<asp:Literal ID="modify_time" runat="server"></asp:Literal></asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-form-label">自定義欄位需求</label>
|
||||
<div class="">
|
||||
<asp:TextBox ID="customize_data" runat="server" CssClass="form-control" TextMode="MultiLine" Rows="3" placeholder="一行輸入一個定義欄位預設值,如: $右標題:OO活動 $祈福姓名:王OO" ToolTip="一行輸入一個定義欄位預設值,格式: $變數名稱:值"></asp:TextBox>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</asp:Content>
|
||||
145
web/admin/files/reg.aspx.cs
Normal file
145
web/admin/files/reg.aspx.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
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_files_reg : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
if (isStrNull(Request["num"]))
|
||||
{
|
||||
reg_time.Text = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
int _num = Val(Request["num"]);
|
||||
var qry = _db.files.AsEnumerable();
|
||||
var prod = qry.Where(q => q.num == _num).FirstOrDefault();
|
||||
if (prod != null)
|
||||
{
|
||||
subject.Text = prod.subject;
|
||||
reg_time.Text = prod.reg_time.Value.ToString("yyyy-MM-dd");
|
||||
modify_time.Text = "";
|
||||
if (prod.modify_time.HasValue)
|
||||
{
|
||||
modify_time.Text = prod.modify_time.Value.ToString("yyyy/MM/dd");
|
||||
}
|
||||
paperset.Text = prod.paperset;
|
||||
word.Text = prod.word;
|
||||
customize_data.Text = prod.customize_data;
|
||||
|
||||
modifyPanel.Visible = true;
|
||||
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 資料新增
|
||||
|
||||
protected void add_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Page.IsValid) {
|
||||
L_msg.Text = "";
|
||||
|
||||
Model.file files = new Model.file();
|
||||
files.subject= subject.Text.Trim();
|
||||
files.reg_time= ValDate (reg_time.Text);
|
||||
files.modify_time = DateTime.Now;
|
||||
files.paperset = paperset.Text;
|
||||
files.word = word.Text;
|
||||
files.customize_data = customize_data.Text;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
_db.files.Add(files);
|
||||
_db.SaveChanges();
|
||||
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Files, (int)Model.admin_log.Status.Insert, subject.Text);
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//L_msg.Text = ex.Message;
|
||||
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.file files = _db.files.Where(q => q.num == _num).FirstOrDefault();
|
||||
if (files != null)
|
||||
{
|
||||
files.subject = subject.Text.Trim();
|
||||
files.reg_time = ValDate(reg_time.Text);
|
||||
files.modify_time = DateTime.Now;
|
||||
files.paperset = paperset.Text;
|
||||
files.word = word.Text;
|
||||
files.customize_data = customize_data.Text;
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_db.SaveChanges();
|
||||
Model.admin_log admin_log = new Model.admin_log();
|
||||
admin_log.writeLog(admin.info.u_id, (int)Model.admin_log.Systems.Files, (int)Model.admin_log.Status.Update, subject.Text);
|
||||
|
||||
Response.Redirect("index.aspx?page=" + Convert.ToString(Request["page"]));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
L_msg.Type = alert_type.danger;
|
||||
L_msg.Text = "操作失敗";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user