|
@@ -1,14 +1,15 @@
|
|
|
<template>
|
|
|
- <!-- 地理資訊選單-->
|
|
|
+
|
|
|
+ <!-- 地理資訊-ID選單-->
|
|
|
<el-row style="background-color: #FFFFFF;">
|
|
|
<!-- 第一列:父级菜单 -->
|
|
|
<el-col :span="8">
|
|
|
<div class="list">
|
|
|
<div v-for="(item, index) in items"
|
|
|
- :key="index"
|
|
|
- :class="{'active': activeIndex === index}"
|
|
|
- class="list-item"
|
|
|
- @click="setProvinceActive(index)">
|
|
|
+ :key="index"
|
|
|
+ :class="{'active': activeIndex === index}"
|
|
|
+ class="list-item"
|
|
|
+ @click="setProvinceActive(index)">
|
|
|
{{ item.name }}
|
|
|
{{ item.scCnt }} 校
|
|
|
{{ item.tchCnt }} 人
|
|
@@ -21,10 +22,9 @@
|
|
|
<el-col :span="8">
|
|
|
<div v-if="activeIndex !== null" class="list">
|
|
|
<div v-for="(item, index) in cityItems"
|
|
|
- :key="index"
|
|
|
- :class="{'active': activeIndex2 === index}"
|
|
|
- class="list-item"
|
|
|
- @click="setCityActive(index)">
|
|
|
+ :key="index"
|
|
|
+ :class="{'active': activeIndex2 === index}"
|
|
|
+ class="list-item">
|
|
|
{{ item.name }}
|
|
|
{{ item.scCnt }} 校
|
|
|
{{ item.tchCnt }} 人
|
|
@@ -34,24 +34,24 @@
|
|
|
</el-col>
|
|
|
|
|
|
<!-- 第三列:子级菜单 -->
|
|
|
- <el-col :span="8" v-if="false">
|
|
|
+ <el-col :span="8">
|
|
|
<div v-if="activeIndex2 !== null" class="list2">
|
|
|
|
|
|
<!-- 搜尋框 -->
|
|
|
<el-input v-model="searchQuery"
|
|
|
- placeholder="搜尋字串..."
|
|
|
- size="medium"
|
|
|
- clearable
|
|
|
- style="margin-bottom: 10px;"></el-input>
|
|
|
+ placeholder="搜尋字串..."
|
|
|
+ size="medium"
|
|
|
+ clearable
|
|
|
+ style="margin-bottom: 10px;"></el-input>
|
|
|
|
|
|
<!-- 学校列表 -->
|
|
|
<div class="list" style="height: 450px;">
|
|
|
|
|
|
<div v-for="(subItem, subIndex) in filteredSubItems"
|
|
|
- :key="subIndex"
|
|
|
- :class="{'active': activeIndex3 === subIndex}"
|
|
|
- class="list-item"
|
|
|
- @click="setSchoolActive(subIndex)">
|
|
|
+ :key="subIndex"
|
|
|
+ :class="{'active': activeIndex3 === subIndex}"
|
|
|
+ class="list-item"
|
|
|
+ @click="setSchoolActive(subIndex)">
|
|
|
{{ subItem.name }}
|
|
|
{{ subItem.tchCnt }} 人
|
|
|
<el-button size="small" @click.stop="addToColumn3(subItem)" type="success">加入</el-button>
|
|
@@ -73,8 +73,8 @@
|
|
|
<el-scrollbar style="height: 300px; width:100% ;">
|
|
|
<el-list style="display: flex; flex-direction: column;">
|
|
|
<el-list-item v-for="(item, index) in column3Items"
|
|
|
- :key="index"
|
|
|
- class="el-list-item">
|
|
|
+ :key="index"
|
|
|
+ class="el-list-item">
|
|
|
{{ item.name }}
|
|
|
{{ item.tchCnt }} 人
|
|
|
|
|
@@ -102,10 +102,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
- import { ref, computed, onMounted, provide, inject } from "vue";
|
|
|
+ import { ref, computed, onMounted, provide, inject, getCurrentInstance } from "vue";
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import axios from "axios";
|
|
|
import { CloseBold } from "@element-plus/icons-vue";
|
|
|
+ import Geos_Info_ID from './geos_info_id.vue'; // 引入组件
|
|
|
+ let { proxy } = getCurrentInstance()
|
|
|
|
|
|
// 动态获取的地理資訊和学校数据
|
|
|
const items = ref([]); // 地理列表(父级菜单)
|
|
@@ -121,9 +123,12 @@
|
|
|
// 从父组件注入的接收名单和更新方法
|
|
|
const column3Items = inject("column3Items", ref([])); // 接收名單
|
|
|
|
|
|
+ // 取得服務 url
|
|
|
+ const new_msg_host = inject('new_msg_host');
|
|
|
+
|
|
|
const selectedValue2 = ref([]);
|
|
|
|
|
|
- const Svalue = ref('School')
|
|
|
+ const value = ref('School')
|
|
|
|
|
|
// 選項列表
|
|
|
const options = [
|
|
@@ -131,66 +136,52 @@
|
|
|
{ value: 'ID', label: 'ID' }
|
|
|
]
|
|
|
|
|
|
+ // 过滤子级菜单项(学校)
|
|
|
+ const filteredSubItems = computed(() => {
|
|
|
|
|
|
- // 選項列表
|
|
|
- const options2 = [
|
|
|
- { value: 'School', label: '學校' },
|
|
|
- { value: 'ID', label: 'ID' }
|
|
|
- ]
|
|
|
+ //由於所有關連到的 ref() 變數,都會觸發,要特別小心別呆
|
|
|
|
|
|
- // 计算属性:根据关键字过滤列表
|
|
|
- const filteredItems = computed(() => {
|
|
|
- return items.value.filter((item) => item.includes(query.value));
|
|
|
- });
|
|
|
+ // 如果正在加载或 subItems 为空,则返回空数组
|
|
|
+ if (isLoading.value || subItems.value.length === 0) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 要由 city id,取得學校資料
|
|
|
+ if (activeIndex2.value === null) return [];
|
|
|
|
|
|
-// // 过滤子级菜单项(学校)
|
|
|
-// const filteredSubItems = computed(() => {
|
|
|
-//
|
|
|
-// //由於所有關連到的 ref() 變數,都會觸發,要特別小心別呆
|
|
|
-//
|
|
|
-// // 如果正在加载或 subItems 为空,则返回空数组
|
|
|
-// if (isLoading.value || subItems.value.length === 0) {
|
|
|
-// return [];
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 要由 city id,取得學校資料
|
|
|
-// if (activeIndex2.value === null) return [];
|
|
|
-//
|
|
|
-// // 確保 school list 項目有資料
|
|
|
-// if (subItems.value === null) return [];
|
|
|
-//
|
|
|
-// const query = searchQuery.value.toLowerCase(); // 获取搜索关键字(小写)
|
|
|
-//
|
|
|
-// //debugger;
|
|
|
-//
|
|
|
-// let filteredItems = []; // 初始化一个空的数组
|
|
|
-// // 过滤学校列表
|
|
|
-// filteredItems = subItems.value.filter((item) => {
|
|
|
-//
|
|
|
-// // 打印当前项的信息
|
|
|
-// console.log("当前项:", item);
|
|
|
-//
|
|
|
-// return item.name.toLowerCase().includes(query); // 判断 name 是否包含关键字
|
|
|
-//
|
|
|
-// });
|
|
|
-//
|
|
|
-// //debugger;
|
|
|
-// return filteredItems; // 返回筛选后的数组
|
|
|
-// });
|
|
|
- // 點擊後,取得地理資訊(市)
|
|
|
+ // 確保 school list 項目有資料
|
|
|
+ if (subItems.value === null) return [];
|
|
|
+
|
|
|
+ const query = searchQuery.value.toLowerCase(); // 获取搜索关键字(小写)
|
|
|
+
|
|
|
+ let filteredItems = []; // 初始化一个空的数组
|
|
|
+ // 过滤学校列表
|
|
|
+ filteredItems = subItems.value.filter((item) => {
|
|
|
+
|
|
|
+ // 打印当前项的信息
|
|
|
+ console.log("当前项:", item);
|
|
|
+
|
|
|
+ return item.name.toLowerCase().includes(query); // 判断 name 是否包含关键字
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return filteredItems; // 返回筛选后的数组
|
|
|
+ });
|
|
|
+ // 點擊後,取得地理資訊(City)
|
|
|
const setProvinceActive = (index) => {
|
|
|
|
|
|
if (index === null) return;
|
|
|
|
|
|
- activeIndex.value = index; // 设置当前选中的省(学区)索引
|
|
|
+ activeIndex.value = index; // 设置当前选中的父清單索引
|
|
|
activeIndex2.value = null; // 重置第二级子菜单的选中状态
|
|
|
searchQuery.value = ""; // 清空子菜单的搜索框
|
|
|
- const selectedProvinceId = items.value[index].id; // 获取当前选中省的ID
|
|
|
+ //const selectedProvinceId = items.value[index].id; // 获取当前选中省的ID
|
|
|
|
|
|
- //debugger;
|
|
|
+ const SelectParentId = items.value[index].id; // 获取当前选中的父清單ID
|
|
|
|
|
|
- // 根据选中的省ID获取市数据
|
|
|
- fetchCityDataByProvince(selectedProvinceId);
|
|
|
+ // 根据选中的父ID取得City List
|
|
|
+ //fetchCityDataByProvince(selectedProvinceId);
|
|
|
+ fetchCityDataByParentId(SelectParentId);
|
|
|
};
|
|
|
|
|
|
// 點擊 City 後, 取得所屬 City 的學校列表
|
|
@@ -202,11 +193,13 @@
|
|
|
// 取得地理資訊中的 City ID
|
|
|
const selectedCityId = cityItems.value[index].id;
|
|
|
|
|
|
- // 取得地理資訊中的 Province ID
|
|
|
- const selectProvinceId = items.value[activeIndex.value].id;
|
|
|
+ // 取得地理資訊中的 ParentId
|
|
|
+ //const selectProvinceId = items.value[activeIndex.value].id;
|
|
|
+ const ParentId = items.value[activeIndex.value].id;
|
|
|
|
|
|
// 由地理資訊的 City ID, 取得學校數據
|
|
|
- fetchSchoolDataByCity(selectProvinceId, selectedCityId); // 获取学校数据
|
|
|
+ //fetchSchoolDataByCity(selectProvinceId, selectedCityId); // 获取学校数据
|
|
|
+ fetchSchoolDataByCity(ParentId, selectedCityId); // 获取学校数据
|
|
|
};
|
|
|
|
|
|
const setSchoolActive = (index) => {
|
|
@@ -229,42 +222,95 @@
|
|
|
column3Items.value.splice(index, 1);
|
|
|
};
|
|
|
|
|
|
+ let new_msg_station = "";
|
|
|
// 一開始加載時,获取地理资讯数据
|
|
|
const fetchData = async () => {
|
|
|
|
|
|
- //debugger;
|
|
|
- const requestData = { showSchool: false, countryId: "CN" };
|
|
|
- //const requestData = { showSchool: false, countryId: "TW" };
|
|
|
+ // 設定站台別 (國際站,大陸站) 下面國際站
|
|
|
+ //new_msg_station = ['localhost:5001', 'bi.teammodel.cn', 'bitest.teammodel.cn'].includes(window.location.host) ? 'CN' : 'ORG';
|
|
|
+ new_msg_station = ['bi.teammodel.cn', 'bitest.teammodel.cn'].includes(window.location.host) ? 'CN' : 'ORG';
|
|
|
+ // 記錄站台別
|
|
|
+ provide("new_msg_station", new_msg_station);
|
|
|
+
|
|
|
+ // 預設 type":"school"
|
|
|
+
|
|
|
+ //泛型的設計,最重要的是,一開始的 Request 參數
|
|
|
+
|
|
|
+ // 先取得站台別 (new_msg_station)
|
|
|
+
|
|
|
+ // 依站台別,決定 Resuest 的參數
|
|
|
+
|
|
|
+ const requestData = { showSchool: false, type: "tmid" }; // 地理資訊ID,要輸入參數 , "type":"tmid"
|
|
|
+ //const requestData = { showSchool: false }; // 國際站,不需要輸入特定參數,就可以取得國碼
|
|
|
+ //const requestData = { showSchool: false, countryId: "CN" }; // 大陸站,不需要輸入特定參數,就可以取得省分
|
|
|
+
|
|
|
try {
|
|
|
- const response = await axios.post("https://localhost:5001/notice/get-geos", requestData);
|
|
|
- const { state, data } = response.data;
|
|
|
+
|
|
|
+ const response = await proxy.$api.getGeos(requestData);
|
|
|
+ console.log(response, '发送消息返回');
|
|
|
+
|
|
|
+ if (response.state === 200) {
|
|
|
+ //ElMessage.success('消息发送成功');
|
|
|
+ // 在这里执行后续操作,确保数据已获取
|
|
|
+ const data = response.data; // 假设返回的数据在 `response.data` 中
|
|
|
+ console.log(data, '地理資訊');
|
|
|
+ // 后续逻辑处理
|
|
|
+ } else {
|
|
|
+ ElMessage.error('取得資訊失败,状态码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 父清單,在這裡做泛型的區分(站台別不用分,因為皆不需要Request 參數)
|
|
|
+
|
|
|
+ const { state, data } = response;
|
|
|
if (state === 200) {
|
|
|
items.value = data.map((area) => ({
|
|
|
id: area.id,
|
|
|
name: area.name,
|
|
|
scCnt: area.scCnt,
|
|
|
tchCnt: area.tchCnt,
|
|
|
- receiveType: 2, // 0 学区,1 学校, 2 地理资讯
|
|
|
+ countryId: area.id, // 國碼
|
|
|
+ type: "tmid", //類型 tmid、school
|
|
|
+ receiveType: 2, // receiveType: 0, //1 .學區: area 2 .地理資訊: geo 3 .教育機構類型: unit 4 .學校ID: school 5 .醍摩豆ID: tmid
|
|
|
showID_Tag: false,
|
|
|
}));
|
|
|
}
|
|
|
+
|
|
|
} catch (error) {
|
|
|
console.error("请求失败:", error);
|
|
|
ElMessage.error("网络错误,请检查后重试!");
|
|
|
}
|
|
|
};
|
|
|
- // 根据选中的省ID获取地理資訊(市)
|
|
|
- const fetchCityDataByProvince = async (provinceId) => {
|
|
|
+ // 根据选中的父ID取得 City List
|
|
|
+ //const fetchCityDataByProvince = async (provinceId) => {
|
|
|
+ const fetchCityDataByParentId = async (SelectParentId) => {
|
|
|
|
|
|
+ // 設定 Request 參數,provinceId (大陸站),先不考慮
|
|
|
+ //const requestData = { showSchool: false, provinceId: provinceId };
|
|
|
+ //const requestData = { showSchool: false, countryId: "CN", provinceId };
|
|
|
+
|
|
|
+ // 地理資訊-ID "type":"tmid"
|
|
|
+ // 設定 Request 參數,countryId (國際站)
|
|
|
+ const requestData = { showSchool: false, countryId: SelectParentId, type: "tmid" };
|
|
|
|
|
|
- //ddebugger;
|
|
|
- // 設定 Request 參數,provinceId
|
|
|
- const requestData = { showSchool: false, countryId: "CN", provinceId };
|
|
|
|
|
|
try {
|
|
|
- const response = await axios.post("https://localhost:5001/notice/get-geos", requestData);
|
|
|
|
|
|
- const { state, data } = response.data;
|
|
|
+ const response = await proxy.$api.getGeos(requestData);
|
|
|
+ console.log(response, '发送消息返回');
|
|
|
+
|
|
|
+ if (response.state === 200) {
|
|
|
+ //ElMessage.success('消息发送成功');
|
|
|
+ // 在这里执行后续操作,确保数据已获取
|
|
|
+ const data = response.data; // 假设返回的数据在 `response.data` 中
|
|
|
+ console.log(data, '地理資訊');
|
|
|
+ // 后续逻辑处理
|
|
|
+ } else {
|
|
|
+ ElMessage.error('取得資訊失败,状态码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ //const response = await axios.post("https://localhost:5001/notice/get-geos", requestData);
|
|
|
+
|
|
|
+ const { state, data } = response;
|
|
|
|
|
|
// 成功取得資料的話,進行資料的 Mapping, 組成 City list
|
|
|
if (state === 200) {
|
|
@@ -273,7 +319,10 @@
|
|
|
name: area.name,
|
|
|
scCnt: area.scCnt,
|
|
|
tchCnt: area.tchCnt,
|
|
|
- receiveType: 2,
|
|
|
+ countryId: SelectParentId,
|
|
|
+ cityId: area.id,
|
|
|
+ type: "tmid", //類型 tmid、school
|
|
|
+ receiveType: 2, // receiveType: 0, //1 .學區: area 2 .地理資訊: geo 3 .教育機構類型: unit 4 .學校ID: school 5 .醍摩豆ID: tmid
|
|
|
showID_Tag: false,
|
|
|
}));
|
|
|
}
|
|
@@ -282,18 +331,35 @@
|
|
|
ElMessage.error("网络错误,请检查后重试!");
|
|
|
}
|
|
|
};
|
|
|
- // 取得地理資訊(省)
|
|
|
+ // 取得學校資訊 school list
|
|
|
const isLoading = ref(false); // 加载状态
|
|
|
- const fetchSchoolDataByCity = async (provinceId, cityId) => {
|
|
|
+ //const fetchSchoolDataByCity = async (provinceId, cityId) => {
|
|
|
+ const fetchSchoolDataByCity = async (parentId, cityId) => {
|
|
|
|
|
|
isLoading.value = true; // 开始加载
|
|
|
|
|
|
- const requestData = { showSchool: false, countryId: "CN", provinceId, cityId };
|
|
|
+ //const requestData = { showSchool: false, countryId: "CN", provinceId, cityId };
|
|
|
+
|
|
|
+ // 國際站 // 參數要填 CountryId : TW,"cityId": "01"
|
|
|
+ const requestData = { countryId: parentId, cityId, cityId };
|
|
|
|
|
|
//调用 fetchSchoolDataByCity 时,isLoading 置为 true
|
|
|
|
|
|
try {
|
|
|
|
|
|
+ const response = await proxy.$api.getGeos(requestData);
|
|
|
+ console.log(response, '发送消息返回');
|
|
|
+
|
|
|
+ if (response.state === 200) {
|
|
|
+ //ElMessage.success('消息发送成功');
|
|
|
+ // 在这里执行后续操作,确保数据已获取
|
|
|
+ const data = response.data; // 假设返回的数据在 `response.data` 中
|
|
|
+ console.log(data, '地理資訊');
|
|
|
+ // 后续逻辑处理
|
|
|
+ } else {
|
|
|
+ ElMessage.error('取得資訊失败,状态码错误');
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//const response = await axios.post("https://localhost:5001/notice/get-geos", requestData);
|
|
|
|
|
@@ -305,7 +371,7 @@
|
|
|
name: area.name,
|
|
|
scCnt: area.scCnt,
|
|
|
tchCnt: area.tchCnt,
|
|
|
- receiveType: 2,
|
|
|
+ receiveType: 2, // receiveType: 0, //1 .學區: area 2 .地理資訊: geo 3 .教育機構類型: unit 4 .學校ID: school 5 .醍摩豆ID: tmid
|
|
|
showID_Tag: false,
|
|
|
}));
|
|
|
}
|