|
@@ -5,15 +5,21 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { onMounted, reactive, computed } from "vue";
|
|
|
|
|
|
+import {onMounted, reactive, computed, ref} from "vue";
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
import { getBrowserLang } from "@/utils";
|
|
import { getBrowserLang } from "@/utils";
|
|
import { useTheme } from "@/hooks/useTheme";
|
|
import { useTheme } from "@/hooks/useTheme";
|
|
-import { ElConfigProvider } from "element-plus";
|
|
|
|
|
|
+import {ElConfigProvider, ElNotification} from "element-plus";
|
|
import { LanguageType } from "./stores/interface";
|
|
import { LanguageType } from "./stores/interface";
|
|
import { useGlobalStore } from "@/stores/modules/global";
|
|
import { useGlobalStore } from "@/stores/modules/global";
|
|
import en from "element-plus/es/locale/lang/en";
|
|
import en from "element-plus/es/locale/lang/en";
|
|
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
|
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
|
|
|
+import {Login, Platform} from "@/api/interface";
|
|
|
|
+import {loginApi} from "@/api/modules/login";
|
|
|
|
+import {initDynamicRouter} from "@/routers/modules/dynamicRouter";
|
|
|
|
+import {HOME_URL} from "@/config";
|
|
|
|
+import {useUserStore} from "@/stores/modules/user";
|
|
|
|
+import {getPlatformList} from "@/api/modules/allData";
|
|
|
|
|
|
const globalStore = useGlobalStore();
|
|
const globalStore = useGlobalStore();
|
|
|
|
|
|
@@ -41,6 +47,59 @@ const assemblySize = computed(() => globalStore.assemblySize);
|
|
|
|
|
|
// element button config
|
|
// element button config
|
|
const buttonConfig = reactive({ autoInsertSpace: false });
|
|
const buttonConfig = reactive({ autoInsertSpace: false });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+const loginForm = reactive<Login.ReqLoginForm>({
|
|
|
|
+ rememberMe: false,
|
|
|
|
+ username: "",
|
|
|
|
+ password: ""
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const userStore = useUserStore();
|
|
|
|
+const loginStationsList = async () => {
|
|
|
|
+ loginForm.username = localStorage.getItem('username2')
|
|
|
|
+ loginForm.password = localStorage.getItem('password2')
|
|
|
|
+ if(!loginForm.username||!loginForm.password){
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ const {data} = await loginApi({...loginForm, password: loginForm.password});
|
|
|
|
+ if (!data.user) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ userStore.setToken(Date.now().toString());
|
|
|
|
+ userStore.setUserInfo(data.user)
|
|
|
|
+ userStore.setAsInfo(data.asInfo)
|
|
|
|
+ getStationsList();
|
|
|
|
+ } finally {
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+// 站号列表更新
|
|
|
|
+const getStationsList = async () => {
|
|
|
|
+ const userStore = useUserStore();
|
|
|
|
+ const user = computed(() => userStore.userInfo);
|
|
|
|
+ const Info = computed(() => userStore.asInfo);
|
|
|
|
+
|
|
|
|
+ // 查询自动站列表
|
|
|
|
+ const queryas = ref<Platform>({ pageSize: 20000, pageNum: 1 });
|
|
|
|
+ const { data } = await getPlatformList(queryas.value);
|
|
|
|
+ const array2 = data.list;
|
|
|
|
+
|
|
|
|
+ if (user.value.role_id === '管理员') {
|
|
|
|
+ userStore.setStations(array2);
|
|
|
|
+ } else {
|
|
|
|
+ const codesToMatch = Info.value.map(item => item.as_code);
|
|
|
|
+ const filteredArray = array2.filter(item => codesToMatch.includes(item.as_code));
|
|
|
|
+ userStore.setStations(filteredArray);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ loginStationsList()
|
|
|
|
+})
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
<style>
|
|
<style>
|
|
body {
|
|
body {
|