Merge remote-tracking branch 'origin/guadan0905'
This commit is contained in:
@@ -15,6 +15,15 @@
|
||||
<div class="col-sm-4 text-left">
|
||||
<input class="form-control" v-model="guadanorder.order_form.orderNo" readonly />
|
||||
</div>
|
||||
<label class="col-sm-2 col-form-label text-center">關聯活動</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" v-model="guadanorder.order_form.activityNum" >
|
||||
<option :value="null">未關聯</option>
|
||||
<option v-for="activity in activityList" :key="activity.num" :value="activity.num">
|
||||
{{activity.subject}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mt-3">
|
||||
<label class="col-sm-2 col-form-label text-center">
|
||||
@@ -86,14 +95,51 @@
|
||||
{{item.follower?.u_name}}
|
||||
</template>
|
||||
<template #item.actions="{ item }">
|
||||
<v-btn color="red" variant="outlined" size="small" class="me-2" @click="confirmDeleteGuadanOrderGuest(item)">
|
||||
取消
|
||||
</v-btn>
|
||||
<v-btn color="primary" variant="outlined" size="small" @click="editGuadanOrderGuest(item)">
|
||||
<v-icon start>mdi-pencil</v-icon>
|
||||
編輯
|
||||
</v-btn>
|
||||
</template>
|
||||
<div>
|
||||
<!-- 取消預訂 -->
|
||||
<v-btn
|
||||
color="red"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
class="me-2"
|
||||
:disabled="item.statuscode !== '401'"
|
||||
@click="confirmDeleteGuadanOrderGuest(item)"
|
||||
>
|
||||
取消預訂
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="red"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
class="me-2"
|
||||
:disabled="item.statuscode !== '401'"
|
||||
@click="checkinGuadanGuest(item)"
|
||||
>
|
||||
入住
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="red"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
class="me-2"
|
||||
:disabled="item.statuscode !== '402'">
|
||||
續住
|
||||
</v-btn>
|
||||
<!-- 退房 -->
|
||||
<v-btn
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
size="small"
|
||||
:disabled="item.statuscode !== '402'"
|
||||
@click="checkoutGuadanOrderGuest(item)"
|
||||
>
|
||||
<v-icon start>mdi-exit-run</v-icon>
|
||||
退房
|
||||
</v-btn>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
</v-data-table>
|
||||
</fieldset>
|
||||
|
||||
@@ -174,21 +220,6 @@
|
||||
<div class="text-info text-xs mt-1">請從床位清單中選擇</div>
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6">
|
||||
<div class="d-flex flex-column justify-center" style="height: 100%;">
|
||||
<v-select
|
||||
v-model="checkInGuest.inGuest.statusUuid"
|
||||
:items="checkInGuest.status"
|
||||
item-value="uuid"
|
||||
item-text="name"
|
||||
label="选择個人挂单状态"
|
||||
dense
|
||||
outlined
|
||||
></v-select>
|
||||
</div>
|
||||
</v-col>
|
||||
|
||||
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
@@ -768,6 +799,7 @@
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
activityList: [],
|
||||
availableBedCount: {
|
||||
male: 0,
|
||||
female: 0,
|
||||
@@ -782,6 +814,7 @@
|
||||
bookerName: null,
|
||||
bookerPhone: null,
|
||||
bookerFollowerNum: null,
|
||||
activityNum: null,
|
||||
},
|
||||
status_items: [],
|
||||
},
|
||||
@@ -848,7 +881,7 @@
|
||||
bedUuid: null,
|
||||
checkInAt: null,
|
||||
checkOutAt: null,
|
||||
statusUuid: null,
|
||||
statuscode: null,
|
||||
},
|
||||
status: [],
|
||||
},
|
||||
@@ -938,8 +971,14 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getActivityList() {
|
||||
axios.post('/api/activity/GetList?page=1&pageSize=500', { kind: 0, subject: "" })
|
||||
.then((res) => {
|
||||
this.activityList = res.data.list
|
||||
})
|
||||
},
|
||||
getavailablebedcountbytime(startTime, endTime) {
|
||||
axios.get('/api/region/bed/getavailablebedcountbytime',{
|
||||
axios.get('/api/region/bed/getavailablebedcountbytime', {
|
||||
params: {
|
||||
startTime: startTime,
|
||||
endTime: endTime
|
||||
@@ -1117,6 +1156,7 @@
|
||||
this.guadanorder.order_form.bookerPhone = res.data.bookerPhone;
|
||||
this.guadanorder.order_form.bookerFollowerNum = res.data.bookerFollowerNum;
|
||||
this.guadanorder.order_form.uuid = res.data.uuid;
|
||||
this.guadanorder.order_form.activityNum = res.data.activityNum;
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -1203,6 +1243,40 @@
|
||||
//掛單相關方法-------------------end
|
||||
|
||||
//增加蓮友方法-------------------start
|
||||
checkoutGuadanOrderGuest(guest) {
|
||||
this.$refs.confirmModal.open({
|
||||
message: `確定要將 ${guest.follower.u_name || ''} 退房嗎?`,
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
const response = await axios.post(`/api/guadanorderguest/checkout`, null, {
|
||||
params: { uuid: guest.uuid }
|
||||
});
|
||||
|
||||
// 成功提示
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作成功',
|
||||
message: '退房成功!',
|
||||
status: 'success'
|
||||
});
|
||||
|
||||
// 更新狀態並刷新資料
|
||||
guest.statusCode = "403"; // 已退房
|
||||
this.getGuadanOrderGuestByOrderNo();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
// 失敗提示
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作失敗',
|
||||
message: error.response?.data?.message || '退房過程中發生錯誤!',
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
resetInGuest() {
|
||||
this.checkInGuest.inGuest = {
|
||||
uuid: null,
|
||||
@@ -1212,7 +1286,7 @@
|
||||
bedUuid: null,
|
||||
checkInAt: null,
|
||||
checkOutAt: null,
|
||||
statusUuid: null,
|
||||
statuscode: null,
|
||||
};
|
||||
},
|
||||
setInGuest() {
|
||||
@@ -1284,8 +1358,7 @@
|
||||
getGuadanGuestStatus() {
|
||||
axios.get('/api/region/bed/status/list')
|
||||
.then((res) => {
|
||||
this.checkInGuest.status = res.data.filter(item => item.category === 4);
|
||||
console.log(this.checkInGuest.status);
|
||||
this.checkInGuest.status = res.data.filter(item => item.category === 4 && item.code != '404');
|
||||
})
|
||||
},
|
||||
//增加蓮友方法-------------------end
|
||||
@@ -1318,7 +1391,7 @@
|
||||
},
|
||||
selectGuadanOrderGuest(guest) {
|
||||
this.selectGuestModal.currentSelectedGuest = guest;
|
||||
console.log('----------'+ guest)
|
||||
console.log('----------' + guest)
|
||||
this.selectGuestModal.fullNameText = guest.u_name;
|
||||
this.checkInGuest.inGuest.followerNum = guest.num;
|
||||
this.selectGuestModal.showSelectGuestModal = false;
|
||||
@@ -1336,7 +1409,7 @@
|
||||
this.getCurrentSelectBedTextByBedId(guest.bedUuid);
|
||||
this.selectGuestModal.fullNameText = guest.follower?.u_name;
|
||||
this.selectGuestModal.currentSelectedGuest = guest.follower;
|
||||
this.checkInGuest.inGuest.statusUuid = guest.statusUuid;
|
||||
this.checkInGuest.inGuest.statuscode = guest.statuscode;
|
||||
|
||||
},
|
||||
async saveEditGuadanOrderGuest() {
|
||||
@@ -1352,9 +1425,14 @@
|
||||
|
||||
},
|
||||
deleteGuadanOrderGuest(guest) {
|
||||
axios.post('/api/guadanorderguest/delete?uuid=' + guest.uuid).then((res) => {
|
||||
this.guadanguest.items = this.guadanguest.items.filter(i => i.uuid != guest.uuid);
|
||||
})
|
||||
axios.post('/api/guadanorderguest/cancel?uuid=' + guest.uuid)
|
||||
.then((res) => {
|
||||
this.guadanguest.items = this.guadanguest.items.filter(i => i.uuid != guest.uuid);
|
||||
}).catch((error) => {
|
||||
this.$refs.messageModal.open({
|
||||
message: (error.response?.data?.message || error.message)
|
||||
})
|
||||
});
|
||||
},
|
||||
confirmDeleteGuadanOrderGuest(guest) {
|
||||
this.$refs.confirmModal.open({
|
||||
@@ -1364,6 +1442,43 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
async checkinGuadanGuest(guest) {
|
||||
// 先確認操作
|
||||
this.$refs.confirmModal.open({
|
||||
message: '確認入住?',
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
// 發送請求到後端 API
|
||||
const response = await axios.post(`/api/guadanorderguest/checkin`, null, {
|
||||
params: { uuid: guest.uuid }
|
||||
});
|
||||
|
||||
// 成功提示
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作成功',
|
||||
message: '入住成功!',
|
||||
status: 'success'
|
||||
});
|
||||
|
||||
// 更新本地列表,修改狀態為已入住 (402)
|
||||
guest.statusCode = "402";
|
||||
|
||||
// 如果需要刷新整個列表,也可以調用
|
||||
this.getGuadanOrderGuestByOrderNo();
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
// 失敗提示
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作失敗',
|
||||
message: error.response?.data?.message || '入住過程中發生錯誤!',
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//蓮友選擇相關方法---------------end
|
||||
|
||||
//床位選擇相關方法----------------start
|
||||
@@ -1532,6 +1647,7 @@
|
||||
this.loadRegions();
|
||||
this.getGuadanOrderStatus();
|
||||
this.getGuadanGuestStatus();
|
||||
this.getActivityList();
|
||||
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
return {
|
||||
items: [],
|
||||
headers: [
|
||||
{ text: '登记挂单莲友', value: 'bookerName'},
|
||||
{ text: '登记挂单莲友', value: 'bookerName' },
|
||||
{ text: '起始日期', value: 'start_date', align: 'center' },
|
||||
{ text: '結束日期', value: 'end_date', align: 'center' },
|
||||
{ text: '掛單人數', value: 'guest_count' },
|
||||
@@ -81,7 +81,7 @@
|
||||
this.$refs.confirmModal.open({
|
||||
message: '確認取消掛單?',
|
||||
onConfirm: () => {
|
||||
axios.post('/api/guadan/delete', null, {
|
||||
axios.post('/api/guadan/cancel', null, {
|
||||
params: {
|
||||
uuid: order.uuid
|
||||
}
|
||||
|
||||
193
web/admin/guadan/statistics_table.aspx
Normal file
193
web/admin/guadan/statistics_table.aspx
Normal file
@@ -0,0 +1,193 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Templates/TBS5ADM001/MasterPage.master" AutoEventWireup="true" CodeFile="statistics_table.aspx.cs" Inherits="admin_guadan_statistics_table" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="page_nav" Runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<!-- 今日使用情況 -->
|
||||
<div class="section mb-6">
|
||||
<v-card outlined class="pa-1">
|
||||
<v-card-title class="headline grey--text text--darken-2">
|
||||
今日使用情况
|
||||
</v-card-title>
|
||||
<v-divider class="mb-4"></v-divider>
|
||||
<v-card-text>
|
||||
<div class="d-flex flex-wrap justify-space-around">
|
||||
<v-card class="ma-2 pa-3 text-center" color="#e3f2fd" outlined>
|
||||
<div class="subtitle-1 font-weight-bold">总预订人数</div>
|
||||
<div class="headline">{{totalbookers }}</div>
|
||||
</v-card>
|
||||
<v-card class="ma-2 pa-3 text-center" color="#e3f2fd" outlined>
|
||||
<div class="subtitle-1 font-weight-bold">今日预订人数</div>
|
||||
<div class="headline">{{today.todaytotalbookers }}</div>
|
||||
</v-card>
|
||||
<v-card class="ma-2 pa-3 text-center" color="#e3f2fd" outlined>
|
||||
<div class="subtitle-1 font-weight-bold">今日已入住人数</div>
|
||||
<div class="headline">{{today.checkin }}</div>
|
||||
</v-card>
|
||||
<v-card class="ma-2 pa-3 text-center" color="#e3f2fd" outlined>
|
||||
<div class="subtitle-1 font-weight-bold">今日待入住人数</div>
|
||||
<div class="headline">{{today.todaytotalbookers - today.checkin }}</div>
|
||||
</v-card>
|
||||
<v-card class="ma-2 pa-3 text-center" color="#fce4ec" outlined>
|
||||
<div class="subtitle-1 font-weight-bold">空床數</div>
|
||||
<div class="headline">{{ bedcount - today.todaytotalbookers}}</div>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</div>
|
||||
|
||||
<!-- 近期床位使用統計 -->
|
||||
<div class="section container">
|
||||
|
||||
<!-- 日期筛选区 -->
|
||||
<div class="d-flex align-center flex-wrap" style="gap: 12px;">
|
||||
<!-- 开始日期 -->
|
||||
<v-menu
|
||||
ref="menu1"
|
||||
v-model="menu1"
|
||||
:close-on-content-click="false"
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
min-width="auto"
|
||||
>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field
|
||||
v-model="startDate"
|
||||
label="開始日期"
|
||||
prepend-icon="mdi-calendar"
|
||||
readonly
|
||||
v-bind="attrs"
|
||||
v-on="on"
|
||||
dense
|
||||
outlined
|
||||
></v-text-field>
|
||||
</template>
|
||||
<v-date-picker v-model="startDate" @input="menu1 = false"></v-date-picker>
|
||||
</v-menu>
|
||||
|
||||
<!-- 结束日期 -->
|
||||
<v-menu
|
||||
ref="menu2"
|
||||
v-model="menu2"
|
||||
:close-on-content-click="false"
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
min-width="auto"
|
||||
>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-text-field
|
||||
v-model="endDate"
|
||||
label="結束日期"
|
||||
prepend-icon="mdi-calendar"
|
||||
readonly
|
||||
v-bind="attrs"
|
||||
v-on="on"
|
||||
dense
|
||||
outlined
|
||||
></v-text-field>
|
||||
</template>
|
||||
<v-date-picker v-model="endDate" @input="menu2 = false"></v-date-picker>
|
||||
</v-menu>
|
||||
|
||||
<!-- 查询按钮 -->
|
||||
<v-btn
|
||||
color="primary"
|
||||
@click="getList"
|
||||
style="align-self: stretch;"
|
||||
>
|
||||
查詢
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<v-divider class="mb-4"></v-divider>
|
||||
|
||||
<div>
|
||||
<!-- 表格 -->
|
||||
<v-data-table
|
||||
:items="items"
|
||||
:headers="headers"
|
||||
class="elevation-2"
|
||||
dense
|
||||
hide-default-footer
|
||||
:items-per-page="10"
|
||||
>
|
||||
<template #item.date="{ item }">
|
||||
<span>{{ item.date | timeString('YYYY-MM-DD') }}</span>
|
||||
</template>
|
||||
<template #item.bedusagerate="{ item }">
|
||||
{{ ((item.todaytotalbookers / bedcount) * 100).toFixed(2) + '%' }}
|
||||
</template>
|
||||
<template #item.roomcount="{item}">
|
||||
{{roomcount}}
|
||||
</template>
|
||||
<template #item.bedcount="{item}">
|
||||
{{bedcount}}
|
||||
</template>
|
||||
</v-data-table>
|
||||
</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');
|
||||
});
|
||||
new Vue({
|
||||
el: '#app',
|
||||
vuetify: new Vuetify(vuetify_options),
|
||||
data() {
|
||||
return {
|
||||
items: [],
|
||||
headers: [
|
||||
{ text: '日期', value: 'date' },
|
||||
{ text: '房间数量', value: 'roomcount' },
|
||||
{ text: '床位数量', value: 'bedcount' },
|
||||
{ text: '预约人数', value: 'todaytotalbookers' },
|
||||
{ text: '已入住人数', value: 'checkin'},
|
||||
{ text: '可用床位', value: 'availableBeds' },
|
||||
{ text: '床位利用率', value: 'bedusagerate' }
|
||||
],
|
||||
today: {},
|
||||
totalbookers: 0,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
menu1: false,
|
||||
menu2: false,
|
||||
bedcount: 0,
|
||||
roomcount: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getList() {
|
||||
try {
|
||||
const res = await axios.get('/api/guadan/guadanstatisticstable/list', {
|
||||
params: {
|
||||
start: this.startDate || '',
|
||||
end: this.endDate || ''
|
||||
}
|
||||
});
|
||||
this.items = res.data.statistics;
|
||||
this.roomcount = res.data.roomcount;
|
||||
this.bedcount = res.data.bedcount;
|
||||
this.today = res.data.today;
|
||||
this.totalbookers = res.data.totalbookers;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList();
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
14
web/admin/guadan/statistics_table.aspx.cs
Normal file
14
web/admin/guadan/statistics_table.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_guadan_statistics_table : MyWeb.config
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<asp:Literal ID="L_msg" runat="server" />
|
||||
<asp:HiddenField ID="HF_Id" runat="server" />
|
||||
<asp:HiddenField ID="HF_Code" runat="server" />
|
||||
|
||||
<div class="form-group mb-3">
|
||||
<label for="TB_Name">名稱</label>
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
using Model;
|
||||
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_region_bed_bedstatus_create : MyWeb.config
|
||||
{
|
||||
private Model.ezEntities _db = new Model.ezEntities();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) // 加這行
|
||||
if (!IsPostBack)
|
||||
{
|
||||
if (Guid.TryParse(Request.QueryString["statusid"], out Guid id))
|
||||
var code = Request.QueryString["code"];
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
LoadData(id);
|
||||
LoadData(code);
|
||||
L_title.Text = "編輯區域類型";
|
||||
}
|
||||
|
||||
var categoryList = RegionRoomBedStatus.GetCategoryList();
|
||||
// 假设你的下拉控件ID叫 ddlCategory
|
||||
TB_Category.DataSource = categoryList;
|
||||
TB_Category.DataTextField = "Text"; // 显示文字
|
||||
TB_Category.DataValueField = "Value"; // 选项值
|
||||
TB_Category.DataTextField = "Text"; // 顯示文字
|
||||
TB_Category.DataValueField = "Value"; // 選項值
|
||||
TB_Category.DataBind();
|
||||
TB_Category.Items.Insert(0, new ListItem("--请选择分类--", ""));
|
||||
TB_Category.Items.Insert(0, new ListItem("--請選擇分類--", ""));
|
||||
}
|
||||
}
|
||||
private void LoadData(Guid id)
|
||||
|
||||
private void LoadData(string code)
|
||||
{
|
||||
var rt = _db.RegionRoomBedStatus.FirstOrDefault(r => r.Uuid == id);
|
||||
var rt = _db.RegionRoomBedStatus.FirstOrDefault(r => r.Code == code);
|
||||
if (rt == null)
|
||||
{
|
||||
L_msg.Text = "<div class='alert alert-danger'>找不到資料</div>";
|
||||
@@ -37,22 +38,24 @@ public partial class admin_region_bed_bedstatus_create : MyWeb.config
|
||||
return;
|
||||
}
|
||||
|
||||
HF_Id.Value = rt.Uuid.ToString();
|
||||
HF_Code.Value = rt.Code; // ✅ 以 Code 為唯一識別
|
||||
TB_Name.Text = rt.Name;
|
||||
TB_Code.Text = rt.Code;
|
||||
TB_Category.SelectedValue = rt.Category?.ToString();
|
||||
Description.Text = rt.Description;
|
||||
|
||||
}
|
||||
|
||||
protected void BTN_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegionRoomBedStatus rt;
|
||||
if (Guid.TryParse(HF_Id.Value, out Guid id))
|
||||
var code = HF_Code.Value; // ✅ 用隱藏欄位的 Code 判斷
|
||||
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
// 更新
|
||||
rt = _db.RegionRoomBedStatus.FirstOrDefault(r => r.Uuid == id);
|
||||
rt = _db.RegionRoomBedStatus.FirstOrDefault(r => r.Code == code);
|
||||
if (rt == null)
|
||||
{
|
||||
L_msg.Text = "<div class='alert alert-danger'>資料不存在</div>";
|
||||
@@ -63,19 +66,20 @@ public partial class admin_region_bed_bedstatus_create : MyWeb.config
|
||||
{
|
||||
// 新增
|
||||
rt = new RegionRoomBedStatus();
|
||||
rt.Uuid = Guid.NewGuid();
|
||||
rt.Code = TB_Code.Text.Trim(); // ✅ 以 Code 當主鍵
|
||||
_db.RegionRoomBedStatus.Add(rt);
|
||||
}
|
||||
|
||||
rt.Name = TB_Name.Text.Trim();
|
||||
if (rt.Name.Length == 0)
|
||||
if (string.IsNullOrEmpty(rt.Name))
|
||||
{
|
||||
L_msg.Text = "<div class='alert alert-danger'>名稱不能为空</div>";
|
||||
L_msg.Text = "<div class='alert alert-danger'>名稱不能為空</div>";
|
||||
return;
|
||||
}
|
||||
rt.Code = TB_Code.Text.Trim();
|
||||
|
||||
rt.Description = Description.Text.Trim();
|
||||
if(int.TryParse(TB_Category.SelectedValue, out int category))
|
||||
|
||||
if (int.TryParse(TB_Category.SelectedValue, out int category))
|
||||
{
|
||||
rt.Category = category;
|
||||
}
|
||||
@@ -83,16 +87,18 @@ public partial class admin_region_bed_bedstatus_create : MyWeb.config
|
||||
{
|
||||
rt.Category = null;
|
||||
}
|
||||
|
||||
_db.SaveChanges();
|
||||
|
||||
L_msg.Text = "<div class='alert alert-success'>儲存成功</div>";
|
||||
|
||||
// 如果是新增,更新隱藏欄位並切換標題為編輯
|
||||
if (HF_Id.Value == "")
|
||||
// ✅ 如果是新增,更新隱藏欄位並切換標題
|
||||
if (string.IsNullOrEmpty(HF_Code.Value))
|
||||
{
|
||||
HF_Id.Value = rt.Uuid.ToString();
|
||||
HF_Code.Value = rt.Code;
|
||||
L_title.Text = "編輯區域類型";
|
||||
}
|
||||
|
||||
Response.Redirect("index.aspx");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -100,4 +106,4 @@ public partial class admin_region_bed_bedstatus_create : MyWeb.config
|
||||
L_msg.Text = $"<div class='alert alert-danger'>錯誤:{ex.Message}</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
:loading="loading"
|
||||
>
|
||||
<template #item.actions="{item}">
|
||||
<a :href="'create.aspx?statusid='+item.uuid" class="btn btn-primary"><i class="mdi mdi-pencil"></i>修改</a>
|
||||
<a :href="'create.aspx?code='+item.code" class="btn btn-primary"><i class="mdi mdi-pencil"></i>修改</a>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-danger"
|
||||
@@ -46,11 +46,10 @@
|
||||
data() {
|
||||
return {
|
||||
headers: [
|
||||
{ text: 'Id', value: 'id' },
|
||||
{ text: '狀態名稱', value: 'name' },
|
||||
{ text: '狀態代碼', value: 'code' },
|
||||
{ text: '描述', value: 'description' },
|
||||
{ text: '状态分类', value: 'categoryName'},
|
||||
{ text: '状态分类', value: 'categoryName' },
|
||||
{ text: '', value: 'actions' }
|
||||
],
|
||||
items: [],
|
||||
@@ -75,10 +74,10 @@
|
||||
},
|
||||
deleteStatus(item) {
|
||||
axios.post('/api/region/bed/status/delete', null, {
|
||||
params: { id: item.uuid }
|
||||
params: { code: item.code }
|
||||
})
|
||||
.then(() => {
|
||||
this.items = this.items.filter(i => i.uuid != item.uuid);
|
||||
this.items = this.items.filter(i => i.code != item.code);
|
||||
this.$refs.messageModal.open({
|
||||
title: '操作成功',
|
||||
message: '刪除成功!',
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<h2 class="region-title mb-3">{{ region.regionPath }}</h2>
|
||||
|
||||
<div class="row g-3 justify-content-start">
|
||||
<div v-for="room in region.room" :key="room.ruid" class="col-12 col-md-6 col-lg-4">
|
||||
<div v-for="room in region.room" :key="room.ruid" class="col-12 col-md-6 col-lg-6">
|
||||
|
||||
<div class="card h-100 shadow-sm" style="min-height: 300px; max-height: 400px; overflow-y: auto; border-radius: 0.5rem;">
|
||||
<!-- 上部:房間名稱 -->
|
||||
@@ -138,20 +138,26 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">床位名稱</th>
|
||||
<th scope="col">是否可用</th>
|
||||
<th scope="col">使用明細</th>
|
||||
<th scope="col">掛單</th>
|
||||
<th scope="col">當前狀態</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="bed in room.beds" :key="bed.uuid"
|
||||
:class="bed.canuse ? 'table-success' : 'table-danger'">
|
||||
<td>{{ bed.name }}</td>
|
||||
<td :class="!bed.canuse ? 'text-danger' : 'text-success'">
|
||||
{{ bed.canuse ? '是' : '否' }}
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" @click="showBedSchedule(bed)">查看明細</button>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary">
|
||||
快速掛單
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
{{bed.statusname}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -251,6 +257,7 @@
|
||||
{ text: '使用日期', value: 'scheduledate' },
|
||||
{ text: '掛單單號', value: 'guaDanOrderNo' },
|
||||
{ text: '標題', value: 'title' },
|
||||
{ text: '掛單人', value: 'usename' },
|
||||
{ text: '查看掛單', value: 'actions' },
|
||||
],
|
||||
},
|
||||
@@ -381,9 +388,6 @@
|
||||
return { maleBeds, femaleBeds };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
</script>
|
||||
</asp:Content>
|
||||
|
||||
@@ -217,8 +217,8 @@
|
||||
<template #item.isactive="{item}">
|
||||
{{item.isactive ? '啟用' : '停用'}}
|
||||
</template>
|
||||
<template #item.statusuuid="{item}">
|
||||
{{getBedStatusNameById(item.statusuuid)}}
|
||||
<template #item.statuscode="{item}">
|
||||
{{getBedStatusNameById(item.statuscode)}}
|
||||
</template>
|
||||
<template #item.action ="{item}">
|
||||
<button type="button" class="btn btn-primary" @click="editBed(item)">
|
||||
@@ -252,8 +252,8 @@
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">狀態</label>
|
||||
<select class="form-control" v-model="room_bed.newBedForm.statusuuid">
|
||||
<option v-for="status in room_bed.bed_status" :value="status.uuid">
|
||||
<select class="form-control" v-model="room_bed.newBedForm.statuscode">
|
||||
<option v-for="status in room_bed.bed_status" :value="status.code">
|
||||
{{status.name}}
|
||||
</option>
|
||||
</select>
|
||||
@@ -528,7 +528,7 @@
|
||||
bed_headers: [
|
||||
{ text: '床位編號', value: 'uuid' },
|
||||
{ text: '床位名稱', value: 'name' },
|
||||
{ text: '床位狀態', value: 'statusuuid' },
|
||||
{ text: '床位狀態', value: 'statuscode' },
|
||||
{ text: '是否啟用', value: 'isactive' },
|
||||
{ text: '', value: 'action' },
|
||||
],
|
||||
@@ -536,7 +536,7 @@
|
||||
uuid: null,
|
||||
RegionUuid: null,
|
||||
Name: '',
|
||||
statusuuid: null,
|
||||
statuscode: null,
|
||||
IsActive: true,
|
||||
Gender: null,
|
||||
},
|
||||
@@ -664,7 +664,7 @@
|
||||
});
|
||||
},
|
||||
confirmDeleteRegion() {
|
||||
axios.post('/api/region/delete', { uuid: this.form.uuid })
|
||||
axios.post('/api/region/delete', { statuscode: this.form.statuscode })
|
||||
.then(() => {
|
||||
this.showDeleteModal = false;
|
||||
this.$refs.messageModal.open({
|
||||
@@ -716,7 +716,7 @@
|
||||
uuid: null,
|
||||
RoomUuid: this.currentSelectRoom.uuid,
|
||||
Name: '',
|
||||
statusuuid: null,
|
||||
statuscode: null,
|
||||
IsActive: true,
|
||||
Gender: this.currentSelectRoom.gender, // 不設預設值,強制選擇
|
||||
};
|
||||
@@ -791,7 +791,7 @@
|
||||
RegionUuid: bed.regionUuid,
|
||||
RoomUuid: bed.roomUuid,
|
||||
Name: bed.name,
|
||||
statusuuid: bed.statusuuid,
|
||||
statuscode: bed.statuscode,
|
||||
IsActive: bed.isactive,
|
||||
Gender: bed.gender,
|
||||
};
|
||||
@@ -811,7 +811,7 @@
|
||||
...this.room_bed.bed_items[index], // 保留原本未更新欄位
|
||||
roomUuid: updated.RoomUuid,
|
||||
name: updated.Name,
|
||||
statusuuid: updated.statusuuid,
|
||||
statuscode: updated.statuscode,
|
||||
isactive: updated.IsActive
|
||||
});
|
||||
}
|
||||
@@ -839,10 +839,8 @@
|
||||
this.room_bed.bed_status = res.data;
|
||||
})
|
||||
},
|
||||
getBedStatusNameById(id) {
|
||||
console.log(id)
|
||||
//傳入一個Id,獲取該Id對應的名稱
|
||||
const status = this.room_bed.bed_status.find(i => i.uuid == id);
|
||||
getBedStatusNameById(statuscode) {
|
||||
const status = this.room_bed.bed_status.find(i => i.code == statuscode);
|
||||
if (status) {
|
||||
return status.name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user