瀏覽代碼

feat: 添加内部人员接口

wyf 7 月之前
父節點
當前提交
c231acee55

+ 36 - 0
src/api/security-confidentiality-person/inner-person.ts

@@ -0,0 +1,36 @@
+import { http } from '@/utils/http/axios';
+import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';
+
+import type {
+  InnerPersonTableQuery,
+  InnerPersonTableData,
+} from '@/views/security-confidentiality/person-management/inner-person/types';
+
+export const getDeptNameList = () => {
+  return http.request<Array<string>>({
+    url: '/personnelManagement/queryEmployeeAccessDeptList',
+    method: 'post',
+  });
+};
+
+export const getInnerPersonRecordList = (params: QueryPageRequest<InnerPersonTableQuery>) => {
+  return http.request<QueryPageResponse<InnerPersonTableData>>({
+    url: '/personnelManagement/queryEmployeeAccessRecordPage',
+    method: 'post',
+    params,
+  });
+};
+
+export const exportInnerPersonRecordList = (data: InnerPersonTableQuery) => {
+  return http.request(
+    {
+      url: '/personnelManagement/exportEmployeeAccessRecordList',
+      method: 'post',
+      data,
+      responseType: 'blob',
+    },
+    {
+      isTransformResponse: false,
+    },
+  );
+};

+ 63 - 62
src/views/security-confidentiality/person-management/inner-person/InnerPerson.vue

@@ -11,23 +11,26 @@
               <SelectableInput ref="selectableInputRef" :options="INNER_PERSON_TABLE_SEARCH_OPTIONS" />
               <div class="select-box--item">
                 <span>部门:</span>
-                <el-cascader
-                  style="width: 265px"
-                  v-model="searchData.todobumen"
-                  :options="deptTree"
-                  :props="cascaderProp"
+                <el-select
+                  style="width: 280px"
+                  v-model="searchData.deptName"
+                  placeholder="请选择部门"
+                  class="select-box--select"
                   clearable
-                  collapse-tags
-                  :show-all-levels="false"
-                  :max-collapse-tags="1"
-                  placeholder="请选择责任部门"
                 >
-                </el-cascader>
+                  <el-option
+                    v-for="item in deptNameList"
+                    :key="item.value"
+                    :value="item.label"
+                    :label="item.label"
+                    :disabled="item.disabled"
+                  />
+                </el-select>
               </div>
               <div class="select-box--item">
                 <span>事件:</span>
                 <el-select
-                  v-model="searchData.todoshijian"
+                  v-model="searchData.eventType"
                   placeholder="请选择通知状态"
                   class="select-box--select"
                   clearable
@@ -82,39 +85,40 @@
   import { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';
   import type { InnerPersonTableData, InnerPersonTableQuery } from './types';
   import { INNER_PERSON_TABLE_SEARCH_OPTIONS, OCCURRENCE_TYPE_OPTIONS } from './constants';
-
-  import { DeptTree } from '@/types/dept/type';
-  import { getAllDepartments } from '@/api/auth/dept';
+  import {
+    exportInnerPersonRecordList,
+    getDeptNameList,
+    getInnerPersonRecordList,
+  } from '@/api/security-confidentiality-person/inner-person';
+  import dayjs from 'dayjs';
+  import { ElMessage } from 'element-plus';
+  import { downloadFile } from '@/views/disaster/utils';
 
   const searchData = reactive<InnerPersonTableQuery>({});
   const searchTime = ref<string[]>([]);
   const selectableInputRef = ref<InstanceType<typeof SelectableInput>>();
 
   function getQuery() {
-    const query = {
-      todoxinming: selectableInputRef.value?.getValue(),
-      ...searchData,
-      startTime: searchTime.value[0],
-      endTime: searchTime.value[1],
-    };
+    if (!selectableInputRef.value) return;
+    tableQuery.queryParam = {};
+    const selectableSearch = selectableInputRef.value.getValue();
+    if (selectableSearch) {
+      tableQuery.queryParam[selectableSearch.key as string] = selectableSearch.value;
+    }
+    if (searchData.deptName != null) {
+      tableQuery.queryParam.deptName = searchData.deptName;
+    }
+    if (searchData.eventType != null) {
+      tableQuery.queryParam.eventType = searchData.eventType;
+    }
+    if (searchTime) {
+      tableQuery.queryParam.startTime = dayjs(searchTime[0]).format('YYYY-MM-DD HH:MM:ss');
+      tableQuery.queryParam.endTime = dayjs(searchTime[1]).format('YYYY-MM-DD HH:MM:ss');
+    }
   }
   async function getTableData() {
     tableConfig.loading = true;
-    const res = await new Promise<QueryPageResponse<InnerPersonTableData>>((resolve) => {
-      resolve({
-        totalRow: 1,
-        records: [
-          {
-            todoxinming: '张三',
-            todokahao: 'aaa',
-            todobumen: '部门1',
-            todoshijian: 1,
-            tododidian: '地点1',
-            todojinchushijian: '2023-01-01 00:00:00',
-          },
-        ],
-      });
-    });
+    const res = await getInnerPersonRecordList(tableQuery);
     tableData.value = res.records;
     pagination.total = res.totalRow;
     tableConfig.loading = false;
@@ -158,36 +162,33 @@
 
   async function handleDownload() {
     getQuery();
-    // try {
-    //   const res = await exportActViolation(tableQuery.queryParam);
-    //   if (res.size === 0) return;
-    //   const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
-    //   const url = window.URL.createObjectURL(blob);
-    //   downloadFile(url, '违规行为记录.xlsx');
-    // } catch (e) {
-    //   ElMessage.error('下载失败');
-    //   console.log(e);
-    // }
+    try {
+      const res = await exportInnerPersonRecordList(tableQuery.queryParam);
+      if (res.size === 0) return;
+      const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
+      const url = window.URL.createObjectURL(blob);
+      downloadFile(url, '内部人员门禁出入记录.xlsx');
+    } catch (e) {
+      ElMessage.error('下载失败');
+      console.log(e);
+    }
   }
 
-  // 获取级联部门数据
-  const deptTree = ref<DeptTree[]>();
-  const loadDeptTreeData = async () => {
-    const result = await getAllDepartments();
-    deptTree.value = result[0].children;
-  };
-
-  const cascaderProp = {
-    multiple: true,
-    expandTrigger: 'hover',
-    checkStrictly: true,
-    emitPath: false,
-    value: 'id',
-    label: 'deptName',
+  // 获取部门名
+  const deptNameList = ref<SelectOption[]>();
+  const loadDeptNameData = async () => {
+    const result = await getDeptNameList();
+    deptNameList.value = result.map((x, index) => {
+      return {
+        label: x,
+        value: index,
+        disabled: false,
+      };
+    });
   };
 
   onMounted(() => {
-    loadDeptTreeData();
+    loadDeptNameData();
     getTableData();
   });
 </script>
@@ -199,7 +200,7 @@
 
   .table-search {
     display: flex;
-    align-items: center;
+    align-items: flex-end;
     justify-content: space-between;
     width: 100%;
   }
@@ -207,7 +208,7 @@
     display: flex;
     align-items: center;
     flex-wrap: wrap;
-    gap: 32px;
+    gap: 20px;
     &--item {
       @include flex-center;
       white-space: nowrap;

+ 7 - 7
src/views/security-confidentiality/person-management/inner-person/configs/table.ts

@@ -6,38 +6,38 @@ export const TABLE_OPTIONS = {
 
 export const INNER_PERSON_TABEL_COLUMNS = [
   {
-    prop: 'todoxinming',
+    prop: 'employeeName',
     label: '姓名',
     align: 'center',
     minWidth: '120px',
   },
   {
-    prop: 'todokahao',
+    prop: 'staffNo',
     label: '卡号',
     align: 'center',
     minWidth: '120px',
   },
   {
-    prop: 'todobumen',
+    prop: 'deptName',
     label: '部门',
     align: 'center',
     minWidth: '120px',
   },
   {
-    prop: 'todoshijian',
+    prop: 'eventType',
     label: '事件',
-    slot: 'todoshijian',
+    slot: 'eventType',
     align: 'center',
     minWidth: '120px',
   },
   {
-    prop: 'tododidian',
+    prop: 'location',
     label: '进出地点',
     align: 'center',
     minWidth: '120px',
   },
   {
-    prop: 'todojinchushijian',
+    prop: 'entryTime',
     label: '进门时间',
     align: 'center',
     minWidth: '120px',

+ 3 - 3
src/views/security-confidentiality/person-management/inner-person/constants.ts

@@ -1,17 +1,17 @@
 export const INNER_PERSON_TABLE_SEARCH_OPTIONS: SelectOption[] = [
   {
     label: '姓名',
-    value: 'todoxinming',
+    value: 'employeeName',
     disabled: false,
   },
   {
     label: '卡号',
-    value: 'todokahao',
+    value: 'staffNo',
     disabled: false,
   },
   {
     label: '进出地点',
-    value: 'tododidian',
+    value: 'location',
     disabled: false,
   },
 ];

+ 11 - 11
src/views/security-confidentiality/person-management/inner-person/types.ts

@@ -1,18 +1,18 @@
 export interface InnerPersonTableQuery {
-  todoxinming?: string | null;
-  todokahao?: string | null;
-  todobumen?: string | null;
-  todoshijian?: number | null;
-  tododidian?: string | null;
+  employeeName?: string | null;
+  staffNo?: string | null;
+  deptName?: string | null;
+  eventType?: number | null;
+  location?: string | null;
   startTime?: string | null;
   endTime?: string | null;
 }
 
 export interface InnerPersonTableData {
-  todoxinming: string;
-  todokahao: string;
-  todobumen: string;
-  todoshijian: number;
-  tododidian: string;
-  todojinchushijian: string;
+  employeeName: string;
+  staffNo: string;
+  deptName: string;
+  eventType: number;
+  location: string;
+  entryTime: string;
 }