Pārlūkot izejas kodu

feat(records): change

gemercheung 1 gadu atpakaļ
vecāks
revīzija
69721b8b04

+ 15 - 2
src/app/map/App.vue

@@ -6,8 +6,10 @@
         <el-button :type="currentType(0) ? 'primary' : 'default'" @click="handleSelect(0)">地图</el-button>
         <el-button :type="currentType(1) ? 'primary' : 'default'" @click="handleSelect(1)">卡片</el-button>
       </el-button-group>
-
     </div>
+    <el-form-item label="所属架构:" class="filter">
+        <com-company v-model="state.deptId" />
+      </el-form-item>
   </div>
   <div ref="mapEl" class="map-container" v-show="currentType(0)"></div>
   <div class="card-container" v-show="currentType(1)">
@@ -34,10 +36,14 @@ import { onMounted, ref, computed } from "vue";
 import AMapLoader from "@amap/amap-jsapi-loader";
 import axios from 'axios';
 import { getFuseCodeLink } from "../../view/case/help";
-import comCompany from "@/components/company-select/index.vue";
+import comCompany from "./company-select/index.vue";
+import { reactive } from "vue";
 
 const current = ref(0);
 const list = ref<any>([])
+const state = reactive({
+  deptId: ''
+})
 
 const currentType = computed(() => (type: number) => current.value === type)
 const handleSelect = (type: number) => {
@@ -179,6 +185,8 @@ body {
 .tabbar .nav {
   display: flex;
   background: white;
+  justify-content: center;
+  align-items: center;
 }
 
 .tabbar .nav .nav_item {
@@ -209,4 +217,9 @@ body {
   cursor: pointer;
   gap: 10px;
 }
+
+.filter {
+  margin: 0;
+  margin-left: 20px;
+}
 </style>

+ 56 - 0
src/app/map/company-select/index.vue

@@ -0,0 +1,56 @@
+<template>
+  <el-cascader
+    style="width: 100%"
+    v-model="state.path"
+    :disabled="disabled"
+    placeholder="承办单位:"
+    :options="state.options"
+    :props="{ expandTrigger: 'hover', checkStrictly: true }"
+  />
+</template>
+
+<script setup lang="ts">
+import { useTreeSelect, Props, TreeOption } from "@/hook/treeSelect";
+import { getOrganizationTree } from "./organization";
+import { watchEffect } from "vue";
+
+
+const emit = defineEmits<{
+  (e: "update:data", data: TreeOption | null): void;
+  (e: "update:modelValue", value: string): void;
+  (e: "update:label", value: string): void;
+  (e: "update:path", path: string[]): void;
+}>();
+const props = defineProps<Props>();
+
+const state = useTreeSelect(
+  props,
+  getOrganizationTree,
+  (val) => emit("update:modelValue", val),
+  {
+    label: "name",
+    level: "level",
+  }
+);
+
+watchEffect(() => {
+  emit("update:data", state.currentOption);
+});
+watchEffect(() => {
+  emit("update:label", state.label);
+});
+watchEffect(() => {
+  emit("update:path", state.path);
+});
+</script>
+
+<style scoped>
+.aaa::after {
+  content: "";
+  position: absolute;
+  left: 0;
+  right: 0;
+  top: 0;
+  bottom: 0;
+}
+</style>

+ 56 - 0
src/app/map/company-select/organization.ts

@@ -0,0 +1,56 @@
+import {
+  addTreeitem,
+  axios,
+  delTreeitem,
+  editTreeitem,
+  getTreeselect,
+} from "@/request";
+
+
+export enum DeptType {
+  corps = 1,
+  detachment = 2,
+  brigade = 3,
+}
+
+export type Organization = {
+  ancestors: string;
+  children?: Organization[];
+  deptType: DeptType;
+  id: string;
+  leader: string;
+  level: number;
+  name: string;
+  parentId: string;
+  parentName: string;
+  phone: string;
+  remark: string;
+};
+
+export const getOrganizationTree = async (type?: string) =>
+  (await axios.get<Organization[]>(getTreeselect, { headers: { share: 1 }, params: { type } })).data;
+
+export const addOrganization = async (
+  dept: Omit<Organization, "id">,
+  deptIds: string[]
+) => {
+  await axios.post(addTreeitem, {
+    superior: "sheq",
+    ...dept,
+    deptIdList: deptIds.join(","),
+  });
+};
+
+export const setOrganization = async (
+  dept: Organization,
+  deptIds: string[]
+) => {
+  await axios.post(editTreeitem, {
+    superior: "sheq",
+    ...dept,
+    deptIdList: deptIds.join(","),
+  });
+};
+
+export const delOrganization = async (deptId: string) =>
+  axios.post(delTreeitem + deptId);