新增啟用或未啟用
This commit is contained in:
parent
37b445ea63
commit
e0a5e553c5
@ -10,7 +10,7 @@
|
|||||||
<!-- Sidebar - Brand -->
|
<!-- Sidebar - Brand -->
|
||||||
<a
|
<a
|
||||||
class="sidebar-brand d-flex align-items-center justify-content-center"
|
class="sidebar-brand d-flex align-items-center justify-content-center"
|
||||||
href="index.html"
|
href="/Lamiter_pages/"
|
||||||
>
|
>
|
||||||
<!--<div class="sidebar-brand-icon rotate-n-15">
|
<!--<div class="sidebar-brand-icon rotate-n-15">
|
||||||
<i class="fas fa-laugh-wink"></i>
|
<i class="fas fa-laugh-wink"></i>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<!-- Nav Item - Dashboard -->
|
<!-- Nav Item - Dashboard -->
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="index.html">
|
<a class="nav-link" href="/Lamiter_pages/">
|
||||||
<i class="fas fa-fw fa-tachometer-alt"></i>
|
<i class="fas fa-fw fa-tachometer-alt"></i>
|
||||||
<span>Dashboard</span></a
|
<span>Dashboard</span></a
|
||||||
>
|
>
|
||||||
|
@ -158,10 +158,10 @@
|
|||||||
<!-- Divider -->
|
<!-- Divider -->
|
||||||
<hr class="sidebar-divider d-none d-md-block" />
|
<hr class="sidebar-divider d-none d-md-block" />
|
||||||
|
|
||||||
<!-- Sidebar Toggler (Sidebar) -->
|
<!-- Sidebar Toggler (Sidebar)
|
||||||
<div class="text-center d-none d-md-inline">
|
<div class="text-center d-none d-md-inline">
|
||||||
<button class="rounded-circle border-0" id="sidebarToggle"></button>
|
<button class="rounded-circle border-0" id="sidebarToggle"></button>
|
||||||
</div>
|
</div> -->
|
||||||
</ul>
|
</ul>
|
||||||
<!-- End of Sidebar -->
|
<!-- End of Sidebar -->
|
||||||
|
|
||||||
@ -474,7 +474,7 @@
|
|||||||
<footer class="sticky-footer bg-white">
|
<footer class="sticky-footer bg-white">
|
||||||
<div class="container my-auto">
|
<div class="container my-auto">
|
||||||
<div class="copyright text-center my-auto">
|
<div class="copyright text-center my-auto">
|
||||||
<span>Copyright © Your Website 2020</span>
|
<span>Lamiter</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -5,14 +5,21 @@
|
|||||||
<div style="height:30px;float:right ">
|
<div style="height:30px;float:right ">
|
||||||
<button class="btn btn-outline-warning" @click="edit_show">編輯資料</button>
|
<button class="btn btn-outline-warning" @click="edit_show">編輯資料</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<label for="enableSelect" > 是否啟用 </label>
|
||||||
|
<select class="form-control" id="enableSelect" @change="enable_change" v-model="companyenable"
|
||||||
|
style="width: 80px ;">
|
||||||
|
<option value="Y">Y</option>
|
||||||
|
<option value="N">N</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--編輯企業-彈跳視窗---->
|
<!--編輯企業-彈跳視窗---->
|
||||||
<div>
|
<div>
|
||||||
<dialog ref="edit_Company_view" class="dialog-box">
|
<dialog ref="edit_Company_view" class="dialog-box">
|
||||||
<div><button class="btn btn-danger" style="float:right" @click="close_edit_Company_view">關閉</button>
|
<div><button class="btn btn-danger" style="float:right" @click="close_edit_Company_view">關閉</button>
|
||||||
<h2>編輯企業</h2>
|
<h2>編輯企業</h2>
|
||||||
|
|
||||||
@ -21,38 +28,45 @@
|
|||||||
<!-- 表單內容 -->
|
<!-- 表單內容 -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="companyName">企業名稱:</label>
|
<label for="companyName">企業名稱:</label>
|
||||||
<input id="companyName" v-model="companyName" type="text" class="form-control" placeholder="請輸入企業名稱">
|
<input id="companyName" v-model="companyName" type="text" class="form-control" placeholder="請輸入企業名稱"
|
||||||
|
readonly>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="companyPhone">聯絡電話:</label>
|
<label for="companyPhone">聯絡電話:</label>
|
||||||
<input id="companyPhone" v-model="companyPhone" type="tel" class="form-control" placeholder="請輸入聯絡電話">
|
<input id="companyPhone" v-model="companyPhone" type="tel" class="form-control" placeholder="請輸入聯絡電話">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="companyPhone">預設帳號:</label>
|
<label for="companyaccount">帳號:</label>
|
||||||
<input id="companyPhone" v-model="companyaccount" type="text" class="form-control"
|
<input id="companyaccount" v-model="companyaccount" type="text" class="form-control" readonly>
|
||||||
placeholder="請輸入預設帳號">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="companyPhone">預設密碼:</label>
|
<!--<div class="form-group">
|
||||||
<input id="companyPhone" v-model="companypassword" type="text" class="form-control"
|
<label for="enableSelect">是否啟用</label>
|
||||||
placeholder="請輸入預設密碼">
|
<select class="form-control" id="enableSelect" @change="enable_change" v-model="companyenable"
|
||||||
</div>
|
style="width: 100%">
|
||||||
<div class="form-group">
|
|
||||||
<label>是否啟用</label>
|
|
||||||
<select style="width:100%" >
|
|
||||||
<option value="Y">Y</option>
|
<option value="Y">Y</option>
|
||||||
<option value="N">N</option>
|
<option value="N">N</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>-->
|
||||||
<!-- 操作按鈕 -->
|
<!-- 操作按鈕 -->
|
||||||
<div class="button-group">
|
<div class="button-group">
|
||||||
<button class="btn btn-success" @click="submitCompany">確認</button>
|
<button class="btn btn-success" @click="submit_edit_Company">確認</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</dialog>
|
</dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--確認是否啟用-->
|
||||||
|
<div>
|
||||||
|
<dialog ref="check_enable_view" class="dialog-box" style="width: 20%;" >
|
||||||
|
<label>{{ companyenable === 'Y' ? '確認啟用?' : '確認關閉?' }}</label>
|
||||||
|
<!-- 操作按鈕 -->
|
||||||
|
<div class="button-group">
|
||||||
|
<button class="btn btn-danger" @click = "enable_view_close">返回</button>
|
||||||
|
<button class="btn btn-success" @click="submit_edit_enable">確認</button>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -69,18 +83,22 @@ const router = useRouter(); // 匯入
|
|||||||
const authToken = ref("");
|
const authToken = ref("");
|
||||||
|
|
||||||
|
|
||||||
//編輯企業
|
//編輯企業彈窗
|
||||||
const edit_Company_view = ref(null);
|
const edit_Company_view = ref(null);
|
||||||
async function edit_show() {
|
const edit_show = async () => {
|
||||||
|
await get_data();
|
||||||
edit_Company_view.value?.showModal();
|
edit_Company_view.value?.showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
//關閉 <新增企業-彈跳視窗>
|
//關閉 <新增企業-彈跳視窗>
|
||||||
function close_edit_Company_view() {
|
const close_edit_Company_view = () => {
|
||||||
edit_Company_view.value?.close();
|
edit_Company_view.value?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//關閉確認啟用視窗
|
||||||
|
const enable_view_close = async() =>{
|
||||||
|
check_enable_view.value?.close();
|
||||||
|
}
|
||||||
|
|
||||||
//獲取資料
|
//獲取資料
|
||||||
const get_data = async () => {
|
const get_data = async () => {
|
||||||
@ -90,7 +108,7 @@ const get_data = async () => {
|
|||||||
|
|
||||||
|
|
||||||
// 獲取公司資料
|
// 獲取公司資料
|
||||||
const get_company_data= async () =>{
|
const get_company_data = async () => {
|
||||||
const route = useRoute(); // 取得當前路由資訊
|
const route = useRoute(); // 取得當前路由資訊
|
||||||
const company_guid = route.params.guid; // 提取路由中的 guid 參數
|
const company_guid = route.params.guid; // 提取路由中的 guid 參數
|
||||||
|
|
||||||
@ -108,8 +126,6 @@ const get_company_data= async () =>{
|
|||||||
Authorization: authToken.value, // 假設 authToken 已經在其他地方定義
|
Authorization: authToken.value, // 假設 authToken 已經在其他地方定義
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("✅ 獲取成功", response);
|
|
||||||
return response
|
return response
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("獲取公司資料失敗:", error);
|
console.error("獲取公司資料失敗:", error);
|
||||||
@ -118,12 +134,93 @@ const get_company_data= async () =>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//設置資料
|
//設置資料
|
||||||
const company_name=ref("");
|
//設置公司資料
|
||||||
const set_Company=(data)=>{
|
const company_name = ref("");
|
||||||
company_name.value =data.company_name
|
const companyName = ref("");
|
||||||
|
const companyPhone = ref("");
|
||||||
|
const companyaccount = ref("");
|
||||||
|
const companyenable = ref("");
|
||||||
|
let level =ref()
|
||||||
|
const set_Company = (data) => {
|
||||||
|
company_name.value = data.company_name
|
||||||
|
companyName.value = data.company_name
|
||||||
|
companyaccount.value = data.user_name
|
||||||
|
level = parseInt(data.level, 10);
|
||||||
|
if (level % 2 == 0) {
|
||||||
|
companyenable.value = 'Y'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
companyenable.value = 'N'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//編輯資料
|
||||||
|
//編輯是否啟動
|
||||||
|
const check_enable_view = ref(null);
|
||||||
|
const enable_change = async () => {
|
||||||
|
if (companyenable.value == 'Y'){
|
||||||
|
if (level % 2 != 0){
|
||||||
|
level = level + 1;
|
||||||
|
check_enable_view.value?.showModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (companyenable.value == 'N'){
|
||||||
|
if (level % 2 == 0){
|
||||||
|
level = level - 1;
|
||||||
|
check_enable_view.value?.showModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(level)
|
||||||
|
}
|
||||||
|
|
||||||
|
//上傳編輯啟用訊息
|
||||||
|
const submit_edit_enable = async () => {
|
||||||
|
console.log(level)
|
||||||
|
const route = useRoute(); // 取得當前路由資訊
|
||||||
|
const company_guid = route.params.guid; // 提取路由中的 guid 參數
|
||||||
|
try {
|
||||||
|
const enable_data = {
|
||||||
|
guid: company_guid,
|
||||||
|
level:level.toString()
|
||||||
|
};
|
||||||
|
const response = await fetch(`${$api_host}/api/Company_detail_table/company_enable`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: authToken.value,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(enable_data)
|
||||||
|
});
|
||||||
|
check_enable_view.value?.close();
|
||||||
|
alert('編輯成功!');
|
||||||
|
get_data();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error( error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上傳編輯視窗內容
|
||||||
|
const submit_edit_Company = async () =>{
|
||||||
|
try {
|
||||||
|
const companyData = {
|
||||||
|
company_name: companyName.value,
|
||||||
|
username: companyaccount.value,
|
||||||
|
password: companypassword.value
|
||||||
|
};
|
||||||
|
console.log(companyData)
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
alert('上傳失敗,請檢查後端!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 自啟
|
// 自啟
|
||||||
// 🚀 在 mounted 時獲取 token
|
// 🚀 在 mounted 時獲取 token
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div v-for="company in companies" :key="company.guid" class="col-xl-3 col-md-6 mb-4">
|
<div v-for="company in companies" :key="company.guid" class="col-xl-3 col-md-6 mb-4">
|
||||||
<div class="card border-left-primary shadow h-100 py-2" @click="edit_company(company.guid)">
|
<div :class="['card', 'shadow', 'h-100', 'py-2', company.level == '8' ? 'border-left-primary' : 'border-left-warning']" @click="edit_company(company.guid)">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row no-gutters align-items-center">
|
<div class="row no-gutters align-items-center">
|
||||||
<div class="col mr-2">
|
<div class="col mr-2">
|
||||||
|
@ -4,9 +4,15 @@
|
|||||||
新增健管師
|
新增健管師
|
||||||
</button>
|
</button>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
<div>
|
||||||
|
<p>啟用數量: {{ healther_count.enabled }} 未啟用數量: {{ healther_count.disabled }} 總數: {{ healther_count.total }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div v-for="healther in healthers" :key="healther.guid" class="col-xl-3 col-md-6 mb-4">
|
<div v-for="healther in healthers" :key="healther.guid" class="col-xl-3 col-md-6 mb-4">
|
||||||
<div class="card border-left-primary shadow h-100 py-2" @click="edit_health(healther.guid)">
|
<div :class="['card', 'shadow', 'h-100', 'py-2', healther.level == '6' ? 'border-left-primary' : 'border-left-warning']" @click="go_healther_page(healther.guid)">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row no-gutters align-items-center">
|
<div class="row no-gutters align-items-center">
|
||||||
<div class="col mr-2">
|
<div class="col mr-2">
|
||||||
@ -132,6 +138,8 @@ const get_data = async () => {
|
|||||||
await get_company_basic_data();
|
await get_company_basic_data();
|
||||||
const All_Health_data = await get_all_health_data();
|
const All_Health_data = await get_all_health_data();
|
||||||
set_All_Health_data(All_Health_data);
|
set_All_Health_data(All_Health_data);
|
||||||
|
const All_Count = await get_all_count();
|
||||||
|
set_All_Health_Count(All_Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 獲取企業基礎資料
|
// 獲取企業基礎資料
|
||||||
@ -168,13 +176,54 @@ const get_all_health_data = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//獲取建管師數量
|
||||||
|
const get_all_count = async () => {
|
||||||
|
try {
|
||||||
|
const response = await $fetch(`${$api_host}/api/Health_detail_table/get_company_all_health_count-${company_guid.value}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: authToken.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//設置資料
|
//設置資料
|
||||||
|
//設置健管師資料
|
||||||
const healthers = ref([]);
|
const healthers = ref([]);
|
||||||
const set_All_Health_data = (data) => {
|
const set_All_Health_data = (data) => {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
healthers.value = data
|
healthers.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//設置健管師數量
|
||||||
|
const healther_count = ref({ enabled: 0, disabled: 0, total: 0, });
|
||||||
|
const set_All_Health_Count = (data) => {
|
||||||
|
let all_count = 0;
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
let d = data[i];
|
||||||
|
if (d.level == '5') {
|
||||||
|
healther_count.value.disabled = d.level_count; // 设定未启用数量
|
||||||
|
}
|
||||||
|
if (d.level == '6') {
|
||||||
|
healther_count.value.enabled = d.level_count; // 设定启用数量
|
||||||
|
}
|
||||||
|
all_count += d.level_count; // 累加总数
|
||||||
|
}
|
||||||
|
healther_count.value.total = all_count
|
||||||
|
console.log(healther_count)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//前往詳細頁面
|
||||||
|
const go_healther_page =(guid) =>{
|
||||||
|
router.push("/Manage_pages/health_person-" + guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 自啟
|
// 自啟
|
||||||
|
153
pages/Manage_pages/health_person-[guid].vue
Normal file
153
pages/Manage_pages/health_person-[guid].vue
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1>健管師資料 - {{ healther_name }}</h1>
|
||||||
|
<!-- 你可以根據這個 name 來顯示詳細資料 -->
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<label for="enableSelect" > 是否啟用 </label>
|
||||||
|
<select class="form-control" id="enableSelect" @change="enable_change" v-model="healtherenable"
|
||||||
|
style="width: 80px ;">
|
||||||
|
<option value="Y">Y</option>
|
||||||
|
<option value="N">N</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--確認是否啟用-->
|
||||||
|
<div>
|
||||||
|
<dialog ref="check_enable_view" class="dialog-box" style="width: 20%;" >
|
||||||
|
<label>{{ healtherenable === 'Y' ? '確認啟用?' : '確認關閉?' }}</label>
|
||||||
|
<!-- 操作按鈕 -->
|
||||||
|
<div class="button-group">
|
||||||
|
<button class="btn btn-danger" @click = "enable_view_close">返回</button>
|
||||||
|
<button class="btn btn-success" @click="submit_edit_enable">確認</button>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useRouter } from "vue-router"; //匯入路徑
|
||||||
|
const { $api_host } = useNuxtApp(); //匯入API host
|
||||||
|
const router = useRouter(); // 匯入
|
||||||
|
const authToken = ref("");// 🔐 定義全域 token
|
||||||
|
|
||||||
|
const add_Health_view = ref(null);
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: 'defaultmanager' // 指定自定義的佈局名稱
|
||||||
|
})
|
||||||
|
|
||||||
|
//關閉確認啟用視窗
|
||||||
|
const enable_view_close = async() =>{
|
||||||
|
check_enable_view.value?.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//獲取資料
|
||||||
|
const get_data = async () => {
|
||||||
|
const Healther_data = await get_healther_data();
|
||||||
|
set_Healther(Healther_data);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const get_healther_data =async()=>{
|
||||||
|
const route = useRoute(); // 取得當前路由資訊
|
||||||
|
const health_guid = route.params.guid; // 提取路由中的 guid 參數
|
||||||
|
// 確保 company_guid 存在
|
||||||
|
if (!health_guid) {
|
||||||
|
console.error("沒有找到公司 GUID!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await $fetch(`${$api_host}/api/Health_detail_table/get_health_person-${health_guid}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: authToken.value, // 假設 authToken 已經在其他地方定義
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
console.error("獲取健管師資料失敗:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//設置資料
|
||||||
|
const healther_name=ref('');
|
||||||
|
const healtherenable = ref("");
|
||||||
|
let level =ref()
|
||||||
|
const set_Healther = (data) =>{
|
||||||
|
console.log(data)
|
||||||
|
healther_name.value = data.health_name
|
||||||
|
level = parseInt(data.level, 10);
|
||||||
|
if (level % 2 == 0) {
|
||||||
|
healtherenable.value = 'Y'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
healtherenable.value = 'N'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//編輯資料
|
||||||
|
//編輯是否啟動
|
||||||
|
const check_enable_view = ref(null);
|
||||||
|
const enable_change = async () => {
|
||||||
|
if (healtherenable.value == 'Y'){
|
||||||
|
if (level % 2 != 0){
|
||||||
|
level = level + 1;
|
||||||
|
check_enable_view.value?.showModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (healtherenable.value == 'N'){
|
||||||
|
if (level % 2 == 0){
|
||||||
|
level = level - 1;
|
||||||
|
check_enable_view.value?.showModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(level)
|
||||||
|
}
|
||||||
|
|
||||||
|
//上傳編輯啟用訊息
|
||||||
|
const submit_edit_enable = async () => {
|
||||||
|
console.log(level)
|
||||||
|
const route = useRoute(); // 取得當前路由資訊
|
||||||
|
const health_guid = route.params.guid; // 提取路由中的 guid 參數
|
||||||
|
try {
|
||||||
|
const enable_data = {
|
||||||
|
guid: health_guid,
|
||||||
|
level:level.toString()
|
||||||
|
};
|
||||||
|
const response = await fetch(`${$api_host}/api/Health_detail_table/healther_enable`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: authToken.value,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(enable_data)
|
||||||
|
});
|
||||||
|
check_enable_view.value?.close();
|
||||||
|
alert('編輯成功!');
|
||||||
|
get_data();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error( error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自啟
|
||||||
|
// 🚀 在 mounted 時獲取 token
|
||||||
|
onMounted(() => {
|
||||||
|
if (process.client) {
|
||||||
|
// 讀取 localStorage 並將 token 設置到 reactive 變數中
|
||||||
|
authToken.value = localStorage.getItem("token_TCM") || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
get_data(); // 確保 token 讀取後再調用 API
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user