diff --git a/pages/Home_pages/index.vue b/pages/Home_pages/index.vue index 7292c92..7600d6f 100644 --- a/pages/Home_pages/index.vue +++ b/pages/Home_pages/index.vue @@ -84,7 +84,7 @@ diff --git a/pages/Lamiter_pages/Company-[guid].vue b/pages/Lamiter_pages/Company-[guid].vue index 4e3aecb..e5ba81a 100644 --- a/pages/Lamiter_pages/Company-[guid].vue +++ b/pages/Lamiter_pages/Company-[guid].vue @@ -95,7 +95,7 @@ const get_data = async () => { if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`); const data = await response.json(); - company_name.value=data.campant_name + company_name.value=data.company_name } catch (error) { diff --git a/pages/Lamiter_pages/Company_Control_page.vue b/pages/Lamiter_pages/Company_Control_page.vue index cccf0db..b103c2b 100644 --- a/pages/Lamiter_pages/Company_Control_page.vue +++ b/pages/Lamiter_pages/Company_Control_page.vue @@ -15,7 +15,7 @@
企業名稱:
-
{{ company.campant_name }}
+
{{ company.company_name }}
@@ -131,7 +131,7 @@ async function submitCompany() { const companies = ref([]); const get_data = async () => { try { - const response = await fetch('http://localhost:5291/api/Company_detail_table/get_all_campany'); + const response = await fetch(`${$api_host}/api/Company_detail_table/get_all_campany`); if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`); const data = await response.json(); diff --git a/pages/Manage_pages/Health_Control_page.vue b/pages/Manage_pages/Health_Control_page.vue index eced5c3..ab84d13 100644 --- a/pages/Manage_pages/Health_Control_page.vue +++ b/pages/Manage_pages/Health_Control_page.vue @@ -5,18 +5,18 @@

-
-
+
+
- 企業名稱: + 健管師名稱:
-
{{ company.campant_name }}
+
{{ health.health_name }}
- +
@@ -27,37 +27,35 @@
- -
+ +

新增管理師

- - + +
- +
- - + +
- - + +
- +
@@ -70,22 +68,96 @@ import { ref, onMounted } from 'vue' import { useRouter } from "vue-router"; //匯入路徑 const { $api_host } = useNuxtApp(); //匯入API host const router = useRouter(); // 匯入 -const add_Company_view = ref(null); +const add_Health_view = ref(null); definePageMeta({ layout: 'defaultmanager' // 指定自定義的佈局名稱 }) -//新增企業 +//新增健管師 async function add_health_manager() { - add_Company_view.value?.showModal(); + healthName.value = ""; + healthPhone.value = ""; + healthaccount.value = ""; + healthpassword.value = ""; + add_Health_view.value?.showModal(); } -//關閉 <新增企業-彈跳視窗> -function close_add_Company_view() { - add_Company_view.value?.close(); +//關閉 <新增健管師-彈跳視窗> +function close_add_Health_view() { + add_Health_view.value?.close(); } +// 上傳企業基本資料 +const healthName = ref(""); +const healthPhone = ref(""); +const healthaccount = ref(""); +const healthpassword = ref(""); +async function submitCompany() { + + try { + const healthData = { + 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: { + 'Content-Type': 'application/json' + }, + 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('上傳失敗,請檢查後端!'); + } + +} + + + +const company_guid = ref ("") +//獲取資料 +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() +} +// 獲取企業基礎資料 +const get_company_basic_data = async () => { + try { + + const response = await fetch(`${$api_host}/Users/token_check_user`, { + headers: { + Authorization: token, + }, + }); + if (!response.ok) throw new Error(`HTTP 錯誤! 狀態碼: ${response.status}`); + const data = await response.json(); + company_guid.value = data.guid + } catch (error) { + console.error('企業基礎資料失敗:', error); + } +} +// 獲取所有健康管理師資料 +const get_all_health_data = async()=>{ + console.log(company_guid.value) +} + + +// 自啟 +onMounted(get_data); +