Compare commits
20 Commits
feature/la
...
main
Author | SHA1 | Date | |
---|---|---|---|
dfc94db91a | |||
96114b44ab | |||
3a642e957b | |||
513506fb80 | |||
ac6504c2ae | |||
f70c058dec | |||
ff4a04285d | |||
c40bd7d1b3 | |||
a3b9f47e96 | |||
cac89d0af0 | |||
1d7e046413 | |||
2b5a7cc4f8 | |||
5f19a71c69 | |||
e2e9fcb1ce | |||
3303be4196 | |||
9692b3a0e8 | |||
6b26a5231f | |||
f1992edb8e | |||
e0a5e553c5 | |||
37b445ea63 |
33
.gitea/workflows/develop.yml
Normal file
33
.gitea/workflows/develop.yml
Normal file
@ -0,0 +1,33 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: "frontend_runner"
|
||||
steps:
|
||||
- name: develop
|
||||
shell: powershell
|
||||
run: |
|
||||
echo "Git clone_start"
|
||||
|
||||
# 設定變數
|
||||
$projectPath = "D:\Code\Project\TCM"
|
||||
$frontendPath = "D:\Code\Project\TCM\Frontend"
|
||||
$apiPath = "D:\Code\Server\TCM\View"
|
||||
|
||||
cd D:\Code\Project\TCM
|
||||
if (Test-Path "Frontend") { Remove-Item -Recurse -Force "Frontend" } # 刪除原資料
|
||||
if (-not (Test-Path "Frontend")) {New-Item -Path "Frontend" -ItemType Directory -Force} # 建立資料夾
|
||||
echo " Cloneing ..."
|
||||
git clone -b develop http://leovip125.ddns.net:8418/TCM/Frontend.git
|
||||
echo "Clone End"
|
||||
|
||||
# Node.js 發布
|
||||
echo "發布 start"
|
||||
|
||||
echo "發布 end"
|
||||
|
||||
|
||||
|
33
.gitea/workflows/main.yml
Normal file
33
.gitea/workflows/main.yml
Normal file
@ -0,0 +1,33 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: "frontend_runner"
|
||||
steps:
|
||||
- name: main
|
||||
shell: powershell
|
||||
run: |
|
||||
echo "Git clone_start"
|
||||
|
||||
# 設定變數
|
||||
$projectPath = "D:\Code\Project\TCM_main"
|
||||
$frontendPath = "D:\Code\Project\TCM_main\Frontend"
|
||||
$viewPath = "D:\Code\Server\TCM_main\View"
|
||||
|
||||
cd D:\Code\Project\TCM_main
|
||||
if (Test-Path "Frontend") { Remove-Item -Recurse -Force "Frontend" } # 刪除原資料
|
||||
if (-not (Test-Path "Frontend")) {New-Item -Path "Frontend" -ItemType Directory -Force} # 建立資料夾
|
||||
echo " Cloneing ..."
|
||||
git clone -b main http://leovip125.ddns.net:8418/TCM/Frontend.git
|
||||
echo "Clone End"
|
||||
|
||||
# Node.js 發布
|
||||
echo "發布 start"
|
||||
|
||||
echo "發布 end"
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
export let api_host = 'http://localhost:5291';
|
@ -10,7 +10,7 @@
|
||||
<!-- Sidebar - Brand -->
|
||||
<a
|
||||
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">
|
||||
<i class="fas fa-laugh-wink"></i>
|
||||
@ -30,10 +30,10 @@
|
||||
|
||||
<!-- Nav Item - Dashboard -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="index.html">
|
||||
<NuxtLink class="nav-link" href="/Lamiter_pages/">
|
||||
<i class="fas fa-fw fa-tachometer-alt"></i>
|
||||
<span>Dashboard</span></a
|
||||
>
|
||||
<span>Dashboard</span>
|
||||
</NuxtLink>
|
||||
</li>
|
||||
|
||||
<!-- Divider -->
|
||||
@ -63,7 +63,7 @@
|
||||
>
|
||||
<div class="bg-white py-2 collapse-inner rounded">
|
||||
<h6 class="collapse-header">企業設定</h6>
|
||||
<a class="collapse-item" href="/Lamiter_pages/Company_Control_page">企業管理</a>
|
||||
<NuxtLink class="collapse-item" href="/Lamiter_pages/Company_Control_page">企業管理</NuxtLink>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -535,7 +535,8 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useHead } from "#app";
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const config = useRuntimeConfig();
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入
|
||||
|
||||
useHead({
|
||||
@ -563,43 +564,52 @@ useHead({
|
||||
],
|
||||
});
|
||||
//登出
|
||||
async function logout() {
|
||||
const logout = async ()=> {
|
||||
localStorage.removeItem("token_TCM");
|
||||
router.push("/").then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
// 🔐 Token 狀態管理(確保 SSR 不報錯)
|
||||
const authToken = useState("authToken", () => process.client ? localStorage.getItem("token_TCM") || "" : "");
|
||||
|
||||
var token; // 加上分號
|
||||
const token_check = ()=>{
|
||||
// 检查本地存储中是否存在JWT令牌
|
||||
token = localStorage.getItem("token_TCM");
|
||||
console.log(token);
|
||||
// 確認有無token
|
||||
if (token != null) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $api_host + "/Users/token_check_user",
|
||||
// 🔍 檢查 Token
|
||||
const token_check = async () => {
|
||||
if (!process.client) return; // 確保只在 client-side 執行
|
||||
|
||||
const token = localStorage.getItem("token_TCM");
|
||||
console.log("Token:", token);
|
||||
|
||||
if (!token) {
|
||||
console.log("無 Token,轉跳首頁");
|
||||
router.push("/Home_pages/");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${$api_host}/Users/token_check_user`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
success: function (response) {
|
||||
// 若層級為8 則無法登入
|
||||
if(response.level<=8 ){
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.log(xhr);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log("pass");
|
||||
|
||||
if (!response.ok) throw new Error("Token 驗證失敗");
|
||||
|
||||
const data = await response.json();
|
||||
console.log("驗證成功:", data);
|
||||
|
||||
// 若 level ≤ 8 則轉跳首頁
|
||||
if (data.level <= 8) {
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Token 驗證失敗", error);
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 自啟
|
||||
// 🔄 在頁面載入時執行
|
||||
onMounted(token_check);
|
||||
</script>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<!-- Sidebar - Brand -->
|
||||
<a
|
||||
class="sidebar-brand d-flex align-items-center justify-content-center"
|
||||
href="index.html"
|
||||
href="/"
|
||||
>
|
||||
<!--<div class="sidebar-brand-icon rotate-n-15">
|
||||
<i class="fas fa-laugh-wink"></i>
|
||||
@ -30,10 +30,10 @@
|
||||
|
||||
<!-- Nav Item - Dashboard -->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="index.html">
|
||||
<NuxtLink class="nav-link" to="/Manage_pages">
|
||||
<i class="fas fa-fw fa-tachometer-alt"></i>
|
||||
<span>Dashboard</span></a
|
||||
>
|
||||
<span>Dashboard</span>
|
||||
</NuxtLink>
|
||||
</li>
|
||||
|
||||
<!-- Divider -->
|
||||
@ -63,7 +63,7 @@
|
||||
>
|
||||
<div class="bg-white py-2 collapse-inner rounded">
|
||||
<h6 class="collapse-header">企業設定</h6>
|
||||
<a class="collapse-item" href="/Manage_pages/Health_Control_page">健康管理師管理</a>
|
||||
<NuxtLink class="collapse-item" href="/Manage_pages/Health_Control_page">健康管理師管理</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@ -158,10 +158,10 @@
|
||||
<!-- Divider -->
|
||||
<hr class="sidebar-divider d-none d-md-block" />
|
||||
|
||||
<!-- Sidebar Toggler (Sidebar) -->
|
||||
<!-- Sidebar Toggler (Sidebar)
|
||||
<div class="text-center d-none d-md-inline">
|
||||
<button class="rounded-circle border-0" id="sidebarToggle"></button>
|
||||
</div>
|
||||
</div> -->
|
||||
</ul>
|
||||
<!-- End of Sidebar -->
|
||||
|
||||
@ -474,7 +474,7 @@
|
||||
<footer class="sticky-footer bg-white">
|
||||
<div class="container my-auto">
|
||||
<div class="copyright text-center my-auto">
|
||||
<span>Copyright © Your Website 2020</span>
|
||||
<span>Lamiter</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
@ -531,57 +531,57 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useHead,useState } from "#app";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
const { $api_host } = useNuxtApp();
|
||||
const router = useRouter();
|
||||
import { useHead } from "#app";
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const config = useRuntimeConfig();
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入
|
||||
|
||||
useHead({
|
||||
title: "Manager",
|
||||
meta: [
|
||||
{ charset: "utf-8" },
|
||||
{ "http-equiv": "X-UA-Compatible", content: "IE=edge" },
|
||||
{ name: "viewport", content: "width=device-width, initial-scale=1, shrink-to-fit=no" },
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1, shrink-to-fit=no",
|
||||
},
|
||||
{ name: "description", content: "" },
|
||||
{ name: "author", content: "" },
|
||||
],
|
||||
link: [
|
||||
{ rel: "stylesheet", href: "/vendor/fontawesome-free/css/all.min.css" },
|
||||
{ rel: "stylesheet", href: "/vendor/fontawesome-free/css/all.min.css" }, // 確保 `styles.css` 位於 public/css 資料夾中
|
||||
{ rel: "stylesheet", href: "/css/sb-admin-2.min.css" },
|
||||
],
|
||||
script: [
|
||||
//{ src: 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js', crossorigin: 'anonymous' },
|
||||
{ src: "/vendor/jquery/jquery.min.js" },
|
||||
{ src: "/vendor/bootstrap/js/bootstrap.bundle.min.js" },
|
||||
{ src: "/vendor/jquery-easing/jquery.easing.min.js" },
|
||||
{ src: "/js/sb-admin-2.min.js" },
|
||||
],
|
||||
});
|
||||
|
||||
// 🔐 Token 狀態管理(確保 SSR 不報錯)
|
||||
const authToken = useState("authToken", () => process.client ? localStorage.getItem("token_TCM") || "" : "");
|
||||
|
||||
// 🔐 登出
|
||||
//登出
|
||||
async function logout() {
|
||||
if (process.client) {
|
||||
localStorage.removeItem("token_TCM");
|
||||
}
|
||||
localStorage.removeItem("token_TCM");
|
||||
router.push("/").then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
// 🔍 Token 驗證
|
||||
const token_check = async () => {
|
||||
if (!process.client) return; // 確保只在瀏覽器端執行
|
||||
// 🔐 Token 狀態管理(確保 SSR 不報錯)
|
||||
const authToken = useState("authToken", () => process.client ? localStorage.getItem("token_TCM") || "" : "");
|
||||
|
||||
const token = authToken.value;
|
||||
// 🔍 檢查 Token
|
||||
const token_check = async () => {
|
||||
if (!process.client) return; // 確保只在 client-side 執行
|
||||
|
||||
const token = localStorage.getItem("token_TCM");
|
||||
console.log("Token:", token);
|
||||
|
||||
if (!token) {
|
||||
console.log("未登入,跳轉回首頁");
|
||||
//router.push("/Home_pages/");
|
||||
console.log("無 Token,轉跳首頁");
|
||||
router.push("/Home_pages/");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -593,22 +593,22 @@ const token_check = async () => {
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`);
|
||||
if (!response.ok) throw new Error("Token 驗證失敗");
|
||||
|
||||
const data = await response.json();
|
||||
console.log("用戶驗證結果:", data);
|
||||
console.log("驗證成功:", data);
|
||||
|
||||
// 若層級為 8 則無法登入
|
||||
// 若 level ≤ 6 則轉跳首頁
|
||||
if (data.level <= 6) {
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("驗證失敗:", error);
|
||||
console.error("Token 驗證失敗", error);
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
};
|
||||
|
||||
// 🚀 自動執行
|
||||
// 🔄 在頁面載入時執行
|
||||
onMounted(token_check);
|
||||
</script>
|
||||
|
||||
</script>
|
||||
|
@ -2,5 +2,9 @@
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2024-11-01',
|
||||
devtools: { enabled: true },
|
||||
plugins: ['~/plugins/api-host.js']
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
apiHost: 'http://localhost:5291',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -87,7 +87,9 @@
|
||||
import { useHead,useState } from "#app";
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const config = useRuntimeConfig();
|
||||
const $api_host = config.public.apiHost;
|
||||
|
||||
const router = useRouter(); // 匯入
|
||||
|
||||
definePageMeta({
|
||||
|
@ -5,14 +5,21 @@
|
||||
<div style="height:30px;float:right ">
|
||||
<button class="btn btn-outline-warning" @click="edit_show">編輯資料</button>
|
||||
</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>
|
||||
<dialog ref="edit_Company_view" class="dialog-box">
|
||||
<!--編輯企業-彈跳視窗---->
|
||||
<div>
|
||||
<dialog ref="edit_Company_view" class="dialog-box">
|
||||
<div><button class="btn btn-danger" style="float:right" @click="close_edit_Company_view">關閉</button>
|
||||
<h2>編輯企業</h2>
|
||||
|
||||
@ -21,38 +28,45 @@
|
||||
<!-- 表單內容 -->
|
||||
<div class="form-group">
|
||||
<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 class="form-group">
|
||||
<label for="companyPhone">聯絡電話:</label>
|
||||
<input id="companyPhone" v-model="companyPhone" type="tel" class="form-control" placeholder="請輸入聯絡電話">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="companyPhone">預設帳號:</label>
|
||||
<input id="companyPhone" v-model="companyaccount" type="text" class="form-control"
|
||||
placeholder="請輸入預設帳號">
|
||||
<label for="companyaccount">帳號:</label>
|
||||
<input id="companyaccount" v-model="companyaccount" type="text" class="form-control" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="companyPhone">預設密碼:</label>
|
||||
<input id="companyPhone" v-model="companypassword" type="text" class="form-control"
|
||||
placeholder="請輸入預設密碼">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>是否啟用</label>
|
||||
<select style="width:100%" v-model="Enable_ON">
|
||||
|
||||
<!--<div class="form-group">
|
||||
<label for="enableSelect">是否啟用</label>
|
||||
<select class="form-control" id="enableSelect" @change="enable_change" v-model="companyenable"
|
||||
style="width: 100%">
|
||||
<option value="Y">Y</option>
|
||||
<option value="N">N</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>-->
|
||||
<!-- 操作按鈕 -->
|
||||
<div class="button-group">
|
||||
<button class="btn btn-success" @click="submitCompany">確認</button>
|
||||
<button class="btn btn-success" @click="submit_edit_Company">確認</button>
|
||||
</div>
|
||||
|
||||
</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>
|
||||
|
||||
@ -63,49 +77,159 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const config = useRuntimeConfig();//匯入 API
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入
|
||||
// 🔐 定義全域 token
|
||||
const authToken = ref("");
|
||||
|
||||
|
||||
|
||||
//編輯企業
|
||||
//編輯企業彈窗
|
||||
const edit_Company_view = ref(null);
|
||||
async function edit_show() {
|
||||
|
||||
const edit_show = async () => {
|
||||
await get_data();
|
||||
edit_Company_view.value?.showModal();
|
||||
}
|
||||
|
||||
//關閉 <新增企業-彈跳視窗>
|
||||
function close_edit_Company_view() {
|
||||
const close_edit_Company_view = () => {
|
||||
edit_Company_view.value?.close();
|
||||
}
|
||||
|
||||
const company_name=ref("");
|
||||
//關閉確認啟用視窗
|
||||
const enable_view_close = async() =>{
|
||||
check_enable_view.value?.close();
|
||||
}
|
||||
|
||||
//獲取資料
|
||||
const get_data = async () => {
|
||||
const now_route = useRoute(); // 取得當前路由資訊
|
||||
const company_guid = now_route.params.guid
|
||||
const Company_data = await get_company_data()
|
||||
set_Company(Company_data);
|
||||
};
|
||||
|
||||
|
||||
// 獲取公司資料
|
||||
const get_company_data = async () => {
|
||||
const route = useRoute(); // 取得當前路由資訊
|
||||
const company_guid = route.params.guid; // 提取路由中的 guid 參數
|
||||
|
||||
// 確保 company_guid 存在
|
||||
if (!company_guid) {
|
||||
console.error("沒有找到公司 GUID!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${$api_host}/api/Company_detail_table/get_campany-${company_guid}`, {
|
||||
const response = await $fetch(`${$api_host}/api/Company_detail_table/get_campany-${company_guid}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken.value, // 假設 authToken 已經在其他地方定義
|
||||
},
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`);
|
||||
|
||||
const data = await response.json();
|
||||
company_name.value=data.company_name
|
||||
|
||||
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error("獲取公司資料失敗:", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//設置資料
|
||||
//設置公司資料
|
||||
const company_name = ref("");
|
||||
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('上傳失敗,請檢查後端!');
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// 自啟
|
||||
onMounted(get_data);
|
||||
// 🚀 在 mounted 時獲取 token
|
||||
onMounted(() => {
|
||||
if (process.client) {
|
||||
// 讀取 localStorage 並將 token 設置到 reactive 變數中
|
||||
authToken.value = localStorage.getItem("token_TCM") || "";
|
||||
}
|
||||
|
||||
get_data(); // 確保 token 讀取後再調用 API
|
||||
});
|
||||
</script>
|
@ -8,7 +8,7 @@
|
||||
|
||||
<div class="row">
|
||||
<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="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!--新增企業-彈跳視窗-->
|
||||
<div>
|
||||
@ -69,24 +69,28 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup >
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const config = useRuntimeConfig();
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入
|
||||
// 🔐 定義全域 token
|
||||
const authToken = ref("");
|
||||
|
||||
|
||||
|
||||
const add_Company_view = ref(null);
|
||||
|
||||
//新增企業
|
||||
async function add_company() {
|
||||
companyName.value ="";
|
||||
const add_company = async () => {
|
||||
companyName.value = "";
|
||||
companyPhone.value = "";
|
||||
companyaccount.value ="";
|
||||
companyaccount.value = "";
|
||||
companypassword.value = "";
|
||||
add_Company_view.value?.showModal();
|
||||
}
|
||||
//關閉 <新增企業-彈跳視窗>
|
||||
function close_add_Company_view() {
|
||||
const close_add_Company_view = () => {
|
||||
add_Company_view.value?.close();
|
||||
}
|
||||
|
||||
@ -96,68 +100,91 @@ const companyName = ref("");
|
||||
const companyPhone = ref("");
|
||||
const companyaccount = ref("");
|
||||
const companypassword = ref("");
|
||||
async function submitCompany() {
|
||||
|
||||
const submitCompany = async () => {
|
||||
|
||||
try {
|
||||
const companyData = {
|
||||
lastname:companyName.value,
|
||||
username: companyaccount.value,
|
||||
password: companypassword.value
|
||||
lastname: companyName.value,
|
||||
username: companyaccount.value,
|
||||
password: companypassword.value
|
||||
};
|
||||
console.log(companyData)
|
||||
|
||||
const response = await fetch(`${$api_host}/api/Company_detail_table/Add_campany`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authToken.value,
|
||||
},
|
||||
body: JSON.stringify(companyData)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
add_Company_view.value?.close();
|
||||
alert('上傳成功!');
|
||||
get_data();
|
||||
} catch (error) {
|
||||
alert('上傳失敗,請檢查後端!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 检查本地存储中是否存在JWT令牌
|
||||
const token = localStorage.getItem("token_TCM");
|
||||
//獲取資料
|
||||
const companies = ref([]);
|
||||
const get_data = async () => {
|
||||
try {
|
||||
const response = await fetch(`${$api_host}/api/Company_detail_table/get_all_campany`,{
|
||||
method:'GET',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`);
|
||||
|
||||
const data = await response.json();
|
||||
companies.value = data; // 更新公司列表
|
||||
} catch (error) {
|
||||
console.error('獲取公司資料失敗:', error);
|
||||
}
|
||||
|
||||
//獲取資料
|
||||
const get_data = async () => {
|
||||
const All_Companies = await get_All_Companies();//獲取公司資訊
|
||||
set_All_Companies_data(All_Companies);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 📌 獲取公司資訊
|
||||
const get_All_Companies = async () => {
|
||||
if (!process.client) return; // 確保只在 client-side 執行
|
||||
|
||||
//const token = localStorage.getItem("token_TCM");
|
||||
try {
|
||||
const response = await $fetch(`${$api_host}/api/Company_detail_table/get_all_campany`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken.value,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("✅ 獲取成功", response);
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error("🔴 獲取公司資料失敗", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 設定資料
|
||||
const companies = ref([]);
|
||||
const set_All_Companies_data = (data) => {
|
||||
console.log(data)
|
||||
companies.value = data; // 更新公司列表
|
||||
}
|
||||
|
||||
|
||||
|
||||
//編輯資料
|
||||
async function edit_company(guid){
|
||||
const edit_company = async (guid) => {
|
||||
console.log(guid)
|
||||
router.push("/Lamiter_pages/Company-"+guid);
|
||||
router.push("/Lamiter_pages/Company-" + guid);
|
||||
}
|
||||
|
||||
|
||||
// 自啟
|
||||
onMounted(get_data);
|
||||
// 🚀 在 mounted 時獲取 token
|
||||
onMounted(() => {
|
||||
if (process.client) {
|
||||
// 讀取 localStorage 並將 token 設置到 reactive 變數中
|
||||
authToken.value = localStorage.getItem("token_TCM") || "";
|
||||
}
|
||||
|
||||
get_data(); // 確保 token 讀取後再調用 API
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
@ -1,11 +1,346 @@
|
||||
<template>
|
||||
<div>lamiter 的首頁</div>
|
||||
<div>
|
||||
<!-- Main Content -->
|
||||
<div id="content">
|
||||
<!-- Begin Page Content -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800"> Lamiter 的首頁</h1>
|
||||
<a href="#" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
|
||||
class="fas fa-download fa-sm text-white-50"></i> Generate Report</a>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-primary shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Earnings (Monthly)</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">$40,000</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-calendar fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-success shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
|
||||
Earnings (Annual)</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">$215,000</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-info shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Tasks
|
||||
</div>
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">50%</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="progress progress-sm mr-2">
|
||||
<div class="progress-bar bg-info" role="progressbar"
|
||||
style="width: 50%" aria-valuenow="50" aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pending Requests Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-warning shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
|
||||
Pending Requests</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">18</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-comments fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- Area Chart -->
|
||||
<div class="col-xl-8 col-lg-7">
|
||||
<div class="card shadow mb-4">
|
||||
<!-- Card Header - Dropdown -->
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Earnings Overview</h6>
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
|
||||
aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-header">Dropdown Header:</div>
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card Body -->
|
||||
<div class="card-body">
|
||||
<div class="chart-area">
|
||||
<canvas id="myAreaChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pie Chart -->
|
||||
<div class="col-xl-4 col-lg-5">
|
||||
<div class="card shadow mb-4">
|
||||
<!-- Card Header - Dropdown -->
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Revenue Sources</h6>
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
|
||||
aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-header">Dropdown Header:</div>
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card Body -->
|
||||
<div class="card-body">
|
||||
<div class="chart-pie pt-4 pb-2">
|
||||
<canvas id="myPieChart"></canvas>
|
||||
</div>
|
||||
<div class="mt-4 text-center small">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-primary"></i> Direct
|
||||
</span>
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-success"></i> Social
|
||||
</span>
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-info"></i> Referral
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
|
||||
<!-- Content Column -->
|
||||
<div class="col-lg-6 mb-4">
|
||||
|
||||
<!-- Project Card Example -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Projects</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="small font-weight-bold">Server Migration <span class="float-right">20%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-danger" role="progressbar" style="width: 20%"
|
||||
aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Sales Tracking <span class="float-right">40%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-warning" role="progressbar" style="width: 40%"
|
||||
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Customer Database <span
|
||||
class="float-right">60%</span></h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar" role="progressbar" style="width: 60%" aria-valuenow="60"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Payout Details <span class="float-right">80%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-info" role="progressbar" style="width: 80%"
|
||||
aria-valuenow="80" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Account Setup <span
|
||||
class="float-right">Complete!</span></h4>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-success" role="progressbar" style="width: 100%"
|
||||
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Color System -->
|
||||
<div class="row">
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-primary text-white shadow">
|
||||
<div class="card-body">
|
||||
Primary
|
||||
<div class="text-white-50 small">#4e73df</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-success text-white shadow">
|
||||
<div class="card-body">
|
||||
Success
|
||||
<div class="text-white-50 small">#1cc88a</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-info text-white shadow">
|
||||
<div class="card-body">
|
||||
Info
|
||||
<div class="text-white-50 small">#36b9cc</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-warning text-white shadow">
|
||||
<div class="card-body">
|
||||
Warning
|
||||
<div class="text-white-50 small">#f6c23e</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-danger text-white shadow">
|
||||
<div class="card-body">
|
||||
Danger
|
||||
<div class="text-white-50 small">#e74a3b</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-secondary text-white shadow">
|
||||
<div class="card-body">
|
||||
Secondary
|
||||
<div class="text-white-50 small">#858796</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-light text-black shadow">
|
||||
<div class="card-body">
|
||||
Light
|
||||
<div class="text-black-50 small">#f8f9fc</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-dark text-white shadow">
|
||||
<div class="card-body">
|
||||
Dark
|
||||
<div class="text-white-50 small">#5a5c69</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 mb-4">
|
||||
|
||||
<!-- Illustrations -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Illustrations</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<img class="img-fluid px-3 px-sm-4 mt-3 mb-4" style="width: 25rem;"
|
||||
src="/img/undraw_posting_photo.svg" alt="...">
|
||||
</div>
|
||||
<p>Add some quality, svg illustrations to your project courtesy of <a target="_blank"
|
||||
rel="nofollow" href="https://undraw.co/">unDraw</a>, a
|
||||
constantly updated collection of beautiful svg images that you can use
|
||||
completely free and without attribution!</p>
|
||||
<a target="_blank" rel="nofollow" href="https://undraw.co/">Browse Illustrations on
|
||||
unDraw →</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Approach -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Development Approach</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>SB Admin 2 makes extensive use of Bootstrap 4 utility classes in order to reduce
|
||||
CSS bloat and poor page performance. Custom CSS classes are used to create
|
||||
custom components and custom utility classes.</p>
|
||||
<p class="mb-0">Before working with this theme, you should become familiar with the
|
||||
Bootstrap framework, especially the utility classes.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
|
||||
</div>
|
||||
<!-- End of Main Content -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import { onMounted } from "vue";
|
||||
const { $api_host } = useNuxtApp();
|
||||
const config = useRuntimeConfig();//匯入 API
|
||||
const $api_host = config.public.apiHost;
|
||||
|
||||
definePageMeta({
|
||||
layout: "default", // 指定自定義的佈局名稱
|
||||
|
@ -4,16 +4,22 @@
|
||||
新增健管師
|
||||
</button>
|
||||
<br /><br />
|
||||
<div>
|
||||
<p>啟用數量: {{ healther_count.enabled }} 未啟用數量: {{ healther_count.disabled }} 總數: {{ healther_count.total }}
|
||||
</p>
|
||||
</div>
|
||||
<br /><br />
|
||||
|
||||
<div class="row">
|
||||
<div v-for="healther in healthers" :key="health.guid" class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-primary shadow h-100 py-2" @click="edit_health(health.guid)">
|
||||
<div v-for="healther in healthers" :key="healther.guid" class="col-xl-3 col-md-6 mb-4">
|
||||
<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="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
健管師名稱:
|
||||
</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ health.health_name }}</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ healther.health_name }}</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-user-tie fa-2x text-gray-300"></i> <!-- 改為人圖標 -->
|
||||
@ -66,8 +72,11 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const config = useRuntimeConfig();//匯入 API
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入
|
||||
const authToken = ref("");// 🔐 定義全域 token
|
||||
|
||||
const add_Health_view = ref(null);
|
||||
|
||||
definePageMeta({
|
||||
@ -75,7 +84,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
//新增健管師
|
||||
async function add_health_manager() {
|
||||
const add_health_manager = async () => {
|
||||
healthName.value = "";
|
||||
healthPhone.value = "";
|
||||
healthaccount.value = "";
|
||||
@ -84,7 +93,7 @@ async function add_health_manager() {
|
||||
}
|
||||
|
||||
//關閉 <新增健管師-彈跳視窗>
|
||||
function close_add_Health_view() {
|
||||
const close_add_Health_view = () => {
|
||||
add_Health_view.value?.close();
|
||||
}
|
||||
|
||||
@ -93,31 +102,30 @@ const healthName = ref("");
|
||||
const healthPhone = ref("");
|
||||
const healthaccount = ref("");
|
||||
const healthpassword = ref("");
|
||||
async function submitCompany() {
|
||||
const submitHealth = async () => {
|
||||
|
||||
try {
|
||||
const healthData = {
|
||||
lastname: companyName.value,
|
||||
username: companyaccount.value,
|
||||
password: companypassword.value
|
||||
lastname: healthName.value,
|
||||
username: healthaccount.value,
|
||||
password: healthpassword.value,
|
||||
company_guid: company_guid.value
|
||||
};
|
||||
console.log(companyData)
|
||||
console.log(healthData)
|
||||
|
||||
const response = await fetch(`${$api_host}/api/Company_detail_table/Add_campany`, {
|
||||
const response = await $fetch(`${$api_host}/api/Health_detail_table/Add_health`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authToken.value,
|
||||
},
|
||||
body: JSON.stringify(companyData)
|
||||
body: JSON.stringify(healthData)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
add_Company_view.value?.close();
|
||||
add_Health_view.value?.close();
|
||||
alert('上傳成功!');
|
||||
get_data();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('上傳失敗,請檢查後端!');
|
||||
}
|
||||
|
||||
@ -125,42 +133,115 @@ async function submitCompany() {
|
||||
|
||||
|
||||
|
||||
const company_guid = ref ("")
|
||||
const company_guid = ref("") //企業GUID
|
||||
//獲取資料
|
||||
const get_data = async () => {
|
||||
const authToken = useState("authToken", () => process.client ? localStorage.getItem("token_TCM") || "" : "");
|
||||
console.log(authToken)
|
||||
await get_company_basic_data()
|
||||
await get_all_health_data()
|
||||
await get_company_basic_data();
|
||||
const All_Health_data = await get_all_health_data();
|
||||
set_All_Health_data(All_Health_data);
|
||||
const All_Count = await get_all_count();
|
||||
set_All_Health_Count(All_Count);
|
||||
}
|
||||
|
||||
// 獲取企業基礎資料
|
||||
const get_company_basic_data = async () => {
|
||||
try {
|
||||
|
||||
const response = await fetch(`${$api_host}/Users/token_check_user`, {
|
||||
const response = await $fetch(`${$api_host}/Users/token_check_user`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: token,
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken.value,
|
||||
},
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`);
|
||||
const data = await response.json();
|
||||
company_guid.value = data.guid
|
||||
company_guid.value = response.guid
|
||||
} catch (error) {
|
||||
console.error('企業基礎資料失敗:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 獲取所有健康管理師資料
|
||||
const get_all_health_data = async()=>{
|
||||
console.log(company_guid.value)
|
||||
const get_all_health_data = async () => {
|
||||
|
||||
try {
|
||||
const response = await $fetch(`${$api_host}/api/Health_detail_table/get_company_all_health-${company_guid.value}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: authToken.value,
|
||||
},
|
||||
});
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
//獲取建管師數量
|
||||
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 set_All_Health_data = (data) => {
|
||||
console.log(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);
|
||||
}
|
||||
|
||||
|
||||
// 自啟
|
||||
onMounted(get_data);
|
||||
// 🚀 在 mounted 時獲取 token
|
||||
onMounted(() => {
|
||||
if (process.client) {
|
||||
// 讀取 localStorage 並將 token 設置到 reactive 變數中
|
||||
authToken.value = localStorage.getItem("token_TCM") || "";
|
||||
}
|
||||
|
||||
get_data(); // 確保 token 讀取後再調用 API
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
/* 簡單美化對話框 */
|
||||
.dialog-box {
|
||||
|
154
pages/Manage_pages/health_person-[guid].vue
Normal file
154
pages/Manage_pages/health_person-[guid].vue
Normal file
@ -0,0 +1,154 @@
|
||||
<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 config = useRuntimeConfig();//匯入 API
|
||||
const $api_host = config.public.apiHost;
|
||||
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>
|
@ -1,11 +1,345 @@
|
||||
<template>
|
||||
<div>
|
||||
Manager 的首頁
|
||||
<!-- Main Content -->
|
||||
<div id="content">
|
||||
<!-- Begin Page Content -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800"> Manager 的首頁</h1>
|
||||
<a href="#" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
|
||||
class="fas fa-download fa-sm text-white-50"></i> Generate Report</a>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-primary shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Earnings (Monthly)</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">$40,000</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-calendar fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-success shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
|
||||
Earnings (Annual)</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">$215,000</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Earnings (Monthly) Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-info shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Tasks
|
||||
</div>
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800">50%</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="progress progress-sm mr-2">
|
||||
<div class="progress-bar bg-info" role="progressbar"
|
||||
style="width: 50%" aria-valuenow="50" aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pending Requests Card Example -->
|
||||
<div class="col-xl-3 col-md-6 mb-4">
|
||||
<div class="card border-left-warning shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
|
||||
Pending Requests</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">18</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="fas fa-comments fa-2x text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- Area Chart -->
|
||||
<div class="col-xl-8 col-lg-7">
|
||||
<div class="card shadow mb-4">
|
||||
<!-- Card Header - Dropdown -->
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Earnings Overview</h6>
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
|
||||
aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-header">Dropdown Header:</div>
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card Body -->
|
||||
<div class="card-body">
|
||||
<div class="chart-area">
|
||||
<canvas id="myAreaChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pie Chart -->
|
||||
<div class="col-xl-4 col-lg-5">
|
||||
<div class="card shadow mb-4">
|
||||
<!-- Card Header - Dropdown -->
|
||||
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Revenue Sources</h6>
|
||||
<div class="dropdown no-arrow">
|
||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"
|
||||
aria-labelledby="dropdownMenuLink">
|
||||
<div class="dropdown-header">Dropdown Header:</div>
|
||||
<a class="dropdown-item" href="#">Action</a>
|
||||
<a class="dropdown-item" href="#">Another action</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Something else here</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card Body -->
|
||||
<div class="card-body">
|
||||
<div class="chart-pie pt-4 pb-2">
|
||||
<canvas id="myPieChart"></canvas>
|
||||
</div>
|
||||
<div class="mt-4 text-center small">
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-primary"></i> Direct
|
||||
</span>
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-success"></i> Social
|
||||
</span>
|
||||
<span class="mr-2">
|
||||
<i class="fas fa-circle text-info"></i> Referral
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Content Row -->
|
||||
<div class="row">
|
||||
|
||||
<!-- Content Column -->
|
||||
<div class="col-lg-6 mb-4">
|
||||
|
||||
<!-- Project Card Example -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Projects</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="small font-weight-bold">Server Migration <span class="float-right">20%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-danger" role="progressbar" style="width: 20%"
|
||||
aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Sales Tracking <span class="float-right">40%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-warning" role="progressbar" style="width: 40%"
|
||||
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Customer Database <span
|
||||
class="float-right">60%</span></h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar" role="progressbar" style="width: 60%" aria-valuenow="60"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Payout Details <span class="float-right">80%</span>
|
||||
</h4>
|
||||
<div class="progress mb-4">
|
||||
<div class="progress-bar bg-info" role="progressbar" style="width: 80%"
|
||||
aria-valuenow="80" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<h4 class="small font-weight-bold">Account Setup <span
|
||||
class="float-right">Complete!</span></h4>
|
||||
<div class="progress">
|
||||
<div class="progress-bar bg-success" role="progressbar" style="width: 100%"
|
||||
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Color System -->
|
||||
<div class="row">
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-primary text-white shadow">
|
||||
<div class="card-body">
|
||||
Primary
|
||||
<div class="text-white-50 small">#4e73df</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-success text-white shadow">
|
||||
<div class="card-body">
|
||||
Success
|
||||
<div class="text-white-50 small">#1cc88a</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-info text-white shadow">
|
||||
<div class="card-body">
|
||||
Info
|
||||
<div class="text-white-50 small">#36b9cc</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-warning text-white shadow">
|
||||
<div class="card-body">
|
||||
Warning
|
||||
<div class="text-white-50 small">#f6c23e</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-danger text-white shadow">
|
||||
<div class="card-body">
|
||||
Danger
|
||||
<div class="text-white-50 small">#e74a3b</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-secondary text-white shadow">
|
||||
<div class="card-body">
|
||||
Secondary
|
||||
<div class="text-white-50 small">#858796</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-light text-black shadow">
|
||||
<div class="card-body">
|
||||
Light
|
||||
<div class="text-black-50 small">#f8f9fc</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-4">
|
||||
<div class="card bg-dark text-white shadow">
|
||||
<div class="card-body">
|
||||
Dark
|
||||
<div class="text-white-50 small">#5a5c69</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6 mb-4">
|
||||
|
||||
<!-- Illustrations -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Illustrations</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<img class="img-fluid px-3 px-sm-4 mt-3 mb-4" style="width: 25rem;"
|
||||
src="/img/undraw_posting_photo.svg" alt="...">
|
||||
</div>
|
||||
<p>Add some quality, svg illustrations to your project courtesy of <a target="_blank"
|
||||
rel="nofollow" href="https://undraw.co/">unDraw</a>, a
|
||||
constantly updated collection of beautiful svg images that you can use
|
||||
completely free and without attribution!</p>
|
||||
<a target="_blank" rel="nofollow" href="https://undraw.co/">Browse Illustrations on
|
||||
unDraw →</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Approach -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Development Approach</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>SB Admin 2 makes extensive use of Bootstrap 4 utility classes in order to reduce
|
||||
CSS bloat and poor page performance. Custom CSS classes are used to create
|
||||
custom components and custom utility classes.</p>
|
||||
<p class="mb-0">Before working with this theme, you should become familiar with the
|
||||
Bootstrap framework, especially the utility classes.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
|
||||
</div>
|
||||
<!-- End of Main Content -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
definePageMeta({
|
||||
layout: 'defaultmanager' // 指定自定義的佈局名稱
|
||||
})
|
||||
|
||||
definePageMeta({
|
||||
layout: 'defaultmanager' // 指定自定義的佈局名稱
|
||||
})
|
||||
|
||||
</script>
|
@ -1,26 +1,24 @@
|
||||
<template></template>
|
||||
|
||||
<script setup>
|
||||
import { useHead } from "#app"; //匯入Head
|
||||
import { ref } from "vue";
|
||||
import { onMounted } from "vue"; //開機自啟
|
||||
import { useRouter } from "vue-router"; //匯入路徑
|
||||
const { $api_host } = useNuxtApp(); //匯入API host
|
||||
const router = useRouter(); // 匯入
|
||||
import { useHead } from "#app"; // 匯入 Head
|
||||
import { ref, onMounted } from "vue"; // 開機自啟
|
||||
import { useRouter } from "vue-router"; // 匯入路由
|
||||
const config = useRuntimeConfig();
|
||||
const $api_host = config.public.apiHost;
|
||||
const router = useRouter(); // 匯入路由
|
||||
|
||||
definePageMeta({
|
||||
layout: false, // 禁用 layout
|
||||
});
|
||||
|
||||
// 設置 Head
|
||||
useHead({
|
||||
title: "Lamiter",
|
||||
meta: [
|
||||
{ charset: "utf-8" },
|
||||
{ "http-equiv": "X-UA-Compatible", content: "IE=edge" },
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width, initial-scale=1, shrink-to-fit=no",
|
||||
},
|
||||
{ name: "viewport", content: "width=device-width, initial-scale=1, shrink-to-fit=no" },
|
||||
{ name: "description", content: "" },
|
||||
{ name: "author", content: "" },
|
||||
],
|
||||
@ -28,12 +26,11 @@ useHead({
|
||||
{
|
||||
rel: "stylesheet",
|
||||
href: "https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i",
|
||||
}, // 確保 `styles.css` 位於 public/css 資料夾中
|
||||
},
|
||||
{ rel: "stylesheet", href: "/css/sb-admin-2.min.css" },
|
||||
{ rel: "stylesheet", href: "/vendor/fontawesome-free/css/all.min.css" },
|
||||
],
|
||||
script: [
|
||||
//{ src: 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js', crossorigin: 'anonymous' },
|
||||
{ src: "/vendor/jquery/jquery.min.js" },
|
||||
{ src: "/vendor/bootstrap/js/bootstrap.bundle.min.js" },
|
||||
{ src: "/vendor/jquery-easing/jquery.easing.min.js" },
|
||||
@ -41,44 +38,49 @@ useHead({
|
||||
],
|
||||
});
|
||||
|
||||
console.log($api_host);
|
||||
var token; // 加上分號
|
||||
// 🔐 Token 狀態管理(確保 SSR 不報錯)
|
||||
const authToken = useState("authToken", () => process.client ? localStorage.getItem("token_TCM") || "" : "");
|
||||
|
||||
//檢查token
|
||||
function token_check() {
|
||||
// 检查本地存储中是否存在JWT令牌
|
||||
token = localStorage.getItem("token_TCM");
|
||||
console.log(token);
|
||||
// 確認有無token
|
||||
if (token != null) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $api_host + "/Users/token_check_user",
|
||||
// 🔍 檢查 Token
|
||||
async function token_check() {
|
||||
if (!process.client) return; // 確保在 client-side 執行
|
||||
|
||||
const token = localStorage.getItem("token_TCM");
|
||||
console.log("Token:", token);
|
||||
|
||||
if (!token) {
|
||||
console.log("無 Token,轉跳首頁");
|
||||
router.push("/Home_pages/").then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${$api_host}/Users/token_check_user`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
success: function (response) {
|
||||
// 若層級為10 為BOSS
|
||||
if(response.level>=9){
|
||||
router.push("/Lamiter_pages/");
|
||||
}
|
||||
// 若層級為9 為管理階層上層
|
||||
if(response.level==8){
|
||||
router.push("/Manage_pages/");
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.log("false");
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log("pass");
|
||||
|
||||
if (!response.ok) throw new Error("Token 驗證失敗");
|
||||
|
||||
const data = await response.json();
|
||||
console.log("驗證成功:", data);
|
||||
|
||||
if (data.level >= 9) {
|
||||
router.push("/Lamiter_pages/");
|
||||
} else if (data.level == 8) {
|
||||
router.push("/Manage_pages/");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Token 驗證失敗", error);
|
||||
router.push("/Home_pages/");
|
||||
}
|
||||
}
|
||||
|
||||
//開機自啟
|
||||
onMounted(() => {
|
||||
token_check();
|
||||
});
|
||||
// 🔄 開機執行
|
||||
onMounted(token_check);
|
||||
</script>
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
export default defineNuxtPlugin(nuxtApp => {
|
||||
// 定義 api_host 為全局變數
|
||||
nuxtApp.provide('api_host', 'http://localhost:5291');
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user