Jelajahi Sumber

feat: 车辆出入记录联调

wyf 7 bulan lalu
induk
melakukan
71d7c433d0

+ 26 - 0
src/api/security-confidentiality-vehicle/index.ts

@@ -0,0 +1,26 @@
+import { http } from '@/utils/http/axios';
+import type { QueryPageRequest, QueryPageResponse } from '@/types/basic-query';
+
+import type { VehicleTableQuery, VehicleTableData } from '@/views/security-confidentiality/vehicle-management/types';
+
+export function getVehicleRecordList(data: QueryPageRequest<VehicleTableQuery>) {
+  return http.request<QueryPageResponse<VehicleTableData>>({
+    url: '/vehicleEntryRecord/queryVehicleEntryRecordPage',
+    method: 'POST',
+    data,
+  });
+}
+
+export function exportVehicleRecordList(data: VehicleTableQuery) {
+  return http.request(
+    {
+      url: '/vehicleEntryRecord/exportVehicleEntryRecord',
+      method: 'post',
+      data,
+      responseType: 'blob',
+    },
+    {
+      isTransformResponse: false,
+    },
+  );
+}

+ 3 - 3
src/views/security-confidentiality/access-control/AccessControl.vue

@@ -108,8 +108,8 @@
     tableQuery.queryParam = {
       fieldType: selectableSearch?.key as number | null,
       fieldContent: selectableSearch?.value,
-      startTime: searchTime.value[0],
-      endTime: searchTime.value[1],
+      startTime: searchTime.value ? searchTime.value[0] : undefined,
+      endTime: searchTime.value ? searchTime.value[1] : undefined,
     };
   }
   async function getTableData() {
@@ -194,7 +194,7 @@
   };
 
   onMounted(() => {
-    getTableData();
+    handleSearch();
   });
 </script>
 

+ 60 - 27
src/views/security-confidentiality/vehicle-management/VehicleManagement.vue

@@ -35,6 +35,21 @@
           @update:pageSize="handleSizeChange"
           @update:pageNumber="handleCurrentChange"
         >
+          <template #carNum="scope">
+            <span>{{ scope.row.carNum ? scope.row.carNum : '-' }}</span>
+          </template>
+          <template #carOwnerName="scope">
+            <span>{{ scope.row.carOwnerName || '-' }}</span>
+          </template>
+          <template #deptName="scope">
+            <span>{{ scope.row.deptName || '-' }}</span>
+          </template>
+          <template #entryLocation="scope">
+            <span>{{ scope.row.entryLocation || '-' }}</span>
+          </template>
+          <template #eventTime="scope">
+            <span>{{ scope.row.eventTime || '-' }}</span>
+          </template>
         </BasicTable>
       </div>
     </main>
@@ -46,24 +61,35 @@
   import useTableConfig from '@/hooks/useTableConfigHook';
   import ActionButton from '@/components/ActionButton.vue';
   import SelectableInput from '@/components/formItems/selectableInput/SelectableInput.vue';
+  import { downloadFile } from '@/views/disaster/utils';
+  import dayjs from 'dayjs';
+  import { ElMessage } from 'element-plus';
   import { ref, reactive, onMounted } from 'vue';
-  import { Plus } from '@element-plus/icons-vue';
-  import { VEHICLE_TABLE_SEARCH_OPTIONS } from './constant';
+  import { VEHICLE_TABLE_SEARCH_OPTIONS } from './constants';
   import { TABLE_OPTIONS, VEHICLE_TABEL_COLUMNS } from './configs/tables';
+  import { getVehicleRecordList, exportVehicleRecordList } from '@/api/security-confidentiality-vehicle';
   import type { VehicleTableData, VehicleTableQuery } from './types';
   import type { QueryPageRequest } from '@/types/basic-query';
 
-  const searchData = reactive<VehicleTableQuery>({});
-  const searchTime = ref<string[]>([]);
+  const searchTime = ref<string[]>([
+    dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss'),
+    dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss'),
+  ]);
   const selectableInputRef = ref<InstanceType<typeof SelectableInput>>();
   function getQuery() {
-    // TODO
+    const selectableSearch = selectableInputRef.value?.getValue();
+    tableQuery.queryParam = {
+      fieldType: selectableSearch?.key as number | null,
+      fieldContent: selectableSearch?.value,
+      startTime: searchTime.value ? searchTime.value[0] : undefined,
+      endTime: searchTime.value ? searchTime.value[1] : undefined,
+    };
   }
   async function getTableData() {
     tableConfig.loading = true;
-    // const res = await getInnerPersonRecordList(tableQuery);
-    // tableData.value = res.records;
-    // pagination.total = res.totalRow;
+    const res = await getVehicleRecordList(tableQuery);
+    tableData.value = res.records;
+    pagination.total = res.totalRow;
     tableConfig.loading = false;
   }
   function handleSearch() {
@@ -73,49 +99,56 @@
 
   function handleReset() {
     selectableInputRef.value?.clearValue();
-    for (const key in searchData) {
-      if (searchData.hasOwnProperty(key)) {
-        searchData[key] = undefined;
+    for (const key in tableQuery.queryParam) {
+      if (tableQuery.queryParam.hasOwnProperty(key)) {
+        tableQuery.queryParam[key] = undefined;
       }
     }
-    searchTime.value = [];
+    searchTime.value = [
+      dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss'),
+      dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss'),
+    ];
     handleSearch();
   }
 
   async function handleDownload() {
-    // getQuery();
-    // 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);
-    // }
+    getQuery();
+    try {
+      const res = await exportVehicleRecordList(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 { tableConfig, pagination } = useTableConfig(VEHICLE_TABEL_COLUMNS, TABLE_OPTIONS);
   const tableData = ref<VehicleTableData[]>([]);
 
-  const tableQuery = ref<QueryPageRequest<VehicleTableQuery>>({
+  const tableQuery = reactive<QueryPageRequest<VehicleTableQuery>>({
     pageNumber: pagination.pageNumber,
     pageSize: pagination.pageSize,
-    queryParam: searchData,
+    queryParam: {},
   });
 
   const handleSizeChange = (value: number) => {
     pagination.pageSize = value;
-    tableQuery.value.pageSize = value;
+    tableQuery.pageSize = value;
     getTableData();
   };
   const handleCurrentChange = (value: number) => {
     pagination.pageNumber = value;
-    tableQuery.value.pageNumber = value;
+    tableQuery.pageNumber = value;
     getTableData();
   };
+
+  onMounted(() => {
+    handleSearch();
+  });
 </script>
 
 <style scoped lang="scss">

+ 7 - 7
src/views/security-confidentiality/vehicle-management/configs/tables.ts

@@ -48,11 +48,11 @@ export const VEHICLE_TABEL_COLUMNS = [
     align: 'center',
     minWidth: '120px',
   },
-  {
-    prop: 'actions',
-    slot: 'actions',
-    label: '操作',
-    align: 'center',
-    minWidth: '120px',
-  },
+  // {
+  //   prop: 'actions',
+  //   slot: 'actions',
+  //   label: '操作',
+  //   align: 'center',
+  //   minWidth: '120px',
+  // },
 ];