gemercheung преди 5 месеца
родител
ревизия
64537a24da
променени са 3 файла, в които са добавени 33 реда и са изтрити 7 реда
  1. 1 2
      src/request/URL.ts
  2. 11 1
      src/request/organization.ts
  3. 21 4
      src/view/relics-edit.vue

+ 1 - 2
src/request/URL.ts

@@ -47,8 +47,7 @@ export const userScenepage = `/relics/user/page`;
 export const getMsgAuthCode = `/relics/user/getMsgAuthCode`;
 export const changePassword = `/relics/user/changePassword`;
 
-
-
+export const getUserOrg = `/relics/user/getUserOrg`
 ///drawing
 
 export const addOrUpdateDrawing = `/relics/relics/drawing/saveOrUpdate`;

+ 11 - 1
src/request/organization.ts

@@ -26,7 +26,7 @@ export type OrganizationType = {
     city?: string
     area?: string
     province?: string
-    zx?:boolean
+    zx?: boolean
 
 }
 
@@ -105,3 +105,13 @@ export const getAreas = (provinceCode: string, cityCode: string, zx?: boolean) =
     });
 }
 
+export const getUserOrg = () => {
+    return sendFetch<{
+        provinceId: number,
+        cityId: number,
+        areaId: number,
+        zx: boolean
+    }>(URL.getUserOrg, {
+        method: "get",
+    });
+}

+ 21 - 4
src/view/relics-edit.vue

@@ -32,12 +32,14 @@
 import { QuiskExpose } from "@/helper/mount";
 import { Relics, relicsLevelDesc, relicsTypeDesc } from "@/store/relics";
 import { ElMessage } from "element-plus";
-import { computed, ref, watchEffect } from "vue";
-import { getProvinces, getCities, getAreas } from '@/request/organization';
+import { computed, onMounted, ref, watchEffect } from "vue";
+import { getProvinces, getCities, getAreas, getUserOrg } from '@/request/organization';
 import type { CascaderProps, CascaderOption } from 'element-plus'
-import { ElMessageBox } from "element-plus";
+// import { ElMessageBox } from "element-plus";
 const selectedValue = ref([])
 
+
+
 const props = defineProps<{
   relics?: Relics;
   submit: (relics: Relics) => Promise<void>;
@@ -60,8 +62,9 @@ watchEffect(() => {
   } else {
     selectedValue.value = [data.value.provinceId, data.value.cityId, data.value.areaId]
   }
-
 })
+
+
 // 动态加载配置
 const lazyProps = ref<CascaderProps>({
   lazy: true,
@@ -128,6 +131,20 @@ const handleChange = (value: string) => {
   console.log('选中的省市区编码:', value);
 };
 
+const getDefaultUserOrg = async () => {
+  const res = await getUserOrg();
+  if (res) {
+    console.log('存在org的地址')
+    if (res.zx) {
+      selectedValue.value = [res.cityId, res.areaId]
+    } else {
+      selectedValue.value = [res.provinceId, res.cityId, res.areaId]
+    }
+  }
+}
+onMounted(() => {
+  getDefaultUserOrg()
+})
 
 defineExpose<QuiskExpose>({
   title: computed(() => `${props.relics ? "修改" : "添加"}文物`),