| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div class="safety-platform-container">
- <header class="safety-platform-container__header">
- <div class="breadcrumb-title"> 违规行为记录 </div>
- </header>
- <main class="safety-platform-container__main">
- <div class="search-table-container">
- <header>
- <div class="act-search">
- <section class="select-box">
- <SelectableInput ref="selectableInputRef" :options="ACT_TABLE_SEARCH_OPTIONS" />
- <div class="select-box--item">
- <span>违规类型:</span>
- <el-select
- v-model="searchData.violateType"
- placeholder="请选择违规类型"
- class="select-box--select"
- clearable
- >
- <el-option
- v-for="item in ACT_VIOLATION_TYPE_OPTIONS"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- :disabled="item.disabled"
- />
- </el-select>
- </div>
- <div class="select-box--item">
- <span>通知状态:</span>
- <el-select
- v-model="searchData.isNotice"
- placeholder="请选择通知状态"
- class="select-box--select"
- clearable
- >
- <el-option
- v-for="item in ACT_NOTICE_STATE_OPTIONS"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- :disabled="item.disabled"
- />
- </el-select>
- </div>
- <div>
- <span>时间:</span>
- <el-date-picker
- v-model="searchData.searchTime"
- type="datetimerange"
- range-separator="至"
- start-placeholder="开始时间"
- end-placeholder="结束时间"
- />
- </div>
- </section>
- <section class="search-btn">
- <el-button type="primary" @click="handleSearch">查询</el-button>
- <el-button @click="handleReset">重置</el-button>
- <el-button v-if="noticeManagementPermission" @click="handleDownload">导出</el-button>
- </section>
- </div>
- </header>
- <!-- 表格 -->
- <BasicTable
- ref="basicTableRef"
- :tableData="tableData"
- :tableConfig="tableConfig"
- @update:pageSize="handleSizeChange"
- @update:pageNumber="handleCurrentChange"
- >
- <template #violateName="scope">
- <span>{{ scope.row.violateName ? scope.row.violateName + '(' + scope.row.staffNo + ')' : '-' }}</span>
- </template>
- <template #deptName="scope">
- <span>{{ scope.row.deptName || '-' }}</span>
- </template>
- <template #violateType="scope">
- <span>{{ ACT_VIOLATION_TYPE_LABEL[scope.row.violateType] }}</span>
- </template>
- <template #speed="scope">
- <span>{{ scope.row.speed || '-' }}</span>
- </template>
- <template #capturePhotos="scope">
- <ImageViewer :file-list="scope.row.capturePhotos" />
- </template>
- <template #violateLocation="scope">
- <span>{{ scope.row.violateLocation || '-' }}</span>
- </template>
- <template #createSource="scope">
- <span>{{ ACT_NOTICE_DATA_SOURCE_LABEL[scope.row.createSource] }}</span>
- </template>
- <template #isNotice="scope">
- <div class="notice-state">
- <div
- :style="{
- backgroundColor: ACT_NOTICE_STATE_COLOR[scope.row.isNotice],
- width: '6px',
- height: '6px',
- borderRadius: '50%',
- marginRight: '5px',
- }"
- ></div>
- <span>{{ ACT_NOTICE_STATE_LABEL[scope.row.isNotice] }}</span>
- </div>
- </template>
- </BasicTable>
- </div>
- </main>
- </div>
- </template>
- <script setup lang="ts">
- import BasicTable from '@/components/BasicTable.vue';
- import useTableConfig from '@/hooks/useTableConfigHook';
- import SelectableInput from '@/components/formItems/selectableInput/SelectableInput.vue';
- import dayjs from 'dayjs';
- import { ElMessage } from 'element-plus';
- import {
- TABLE_OPTIONS,
- VIOLATION_NOTICE_TABLE_COLUMNS,
- VIOLATION_NOTICE_TABLE_COLUMNS_CHECKONLY,
- } from '../act/configs/tables';
- import {
- ACT_NOTICE_DATA_SOURCE_LABEL,
- ACT_VIOLATION_TYPE,
- ACT_VIOLATION_TYPE_LABEL,
- ACT_TABLE_SEARCH_OPTIONS,
- ACT_VIOLATION_TYPE_OPTIONS,
- ACT_NOTICE_STATE_OPTIONS,
- ACT_NOTICE_STATE,
- ACT_NOTICE_STATE_LABEL,
- ACT_NOTICE_STATE_COLOR,
- NOTICE_MANAGEMENT_PROMISSION_CODE,
- } from '../act/constants';
- import { ref, reactive, onMounted } from 'vue';
- import { useRouter } from 'vue-router';
- import type { QueryPageRequest } from '@/types/basic-query';
- import type { ActTableSearch, ActTableQuery, ActTableData } from '../act/types';
- import { getActTableList, exportActViolation } from '@/api/traffic-violation/traffic-act';
- import { downloadFile } from '@/views/disaster/utils/download';
- import ImageViewer from '../act/components/ImageViewer.vue';
- import { useUserInfoHook } from '@/hooks/useUserInfoHook';
- const { permissions } = useUserInfoHook();
- const noticeManagementPermission = ref<Boolean>(
- Boolean(permissions.find((item: { code: string }) => item.code === NOTICE_MANAGEMENT_PROMISSION_CODE)),
- );
- // 搜索栏
- const selectableInputRef = ref<InstanceType<typeof SelectableInput>>();
- const searchData = reactive<ActTableSearch>({});
- function getQuery() {
- if (!selectableInputRef.value) return;
- tableQuery.queryParam = {
- pageType: 2,
- };
- const selectableSearch = selectableInputRef.value.getValue();
- if (selectableSearch) {
- tableQuery.queryParam[selectableSearch.key as string] = selectableSearch.value;
- }
- if (searchData.isNotice != null) {
- tableQuery.queryParam.isNotice = searchData.isNotice;
- }
- if (searchData.violateType != null) {
- tableQuery.queryParam.violateType = searchData.violateType;
- }
- if (searchData.searchTime) {
- tableQuery.queryParam.startTime = dayjs(searchData.searchTime[0]).format('YYYY-MM-DD HH:MM:ss');
- tableQuery.queryParam.endTime = dayjs(searchData.searchTime[1]).format('YYYY-MM-DD HH:MM:ss');
- }
- }
- function handleSearch() {
- getQuery();
- getTableData();
- }
- function handleReset() {
- selectableInputRef.value?.clearValue();
- searchData.carNumber = undefined;
- searchData.violateName = undefined;
- searchData.deptName = undefined;
- searchData.isNotice = undefined;
- searchData.violateType = undefined;
- searchData.searchTime = undefined;
- }
- 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);
- }
- }
- // 表格
- const basicTableRef = ref<InstanceType<typeof BasicTable>>();
- const { tableConfig, pagination } = useTableConfig(
- noticeManagementPermission.value ? VIOLATION_NOTICE_TABLE_COLUMNS : VIOLATION_NOTICE_TABLE_COLUMNS_CHECKONLY,
- TABLE_OPTIONS,
- );
- const tableData = ref<ActTableData[]>([]);
- const tableQuery = reactive<QueryPageRequest<ActTableQuery>>({
- pageNumber: pagination.pageNumber,
- pageSize: pagination.pageSize,
- queryParam: {
- pageType: 2,
- },
- });
- const handleSizeChange = (value: number) => {
- pagination.pageSize = value;
- tableQuery.pageSize = value;
- getTableData();
- };
- const handleCurrentChange = (value: number) => {
- pagination.pageNumber = value;
- tableQuery.pageNumber = value;
- getTableData();
- };
- async function getTableData() {
- tableConfig.loading = true;
- const res = await getActTableList(tableQuery);
- tableData.value = res.records;
- pagination.total = res.totalRow;
- tableConfig.loading = false;
- }
- onMounted(async () => {
- await getTableData();
- });
- </script>
- <style scoped lang="scss">
- @use '@/styles/page-details-layout.scss' as *;
- @use '@/styles/page-main-layout.scss' as *;
- @use '@/styles/basic-table-action.scss' as *;
- .act-search-input {
- max-width: 500px;
- }
- .act-search {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- }
- .select-box {
- display: flex;
- align-items: center;
- flex-wrap: wrap;
- gap: 32px;
- &--item {
- @include flex-center;
- white-space: nowrap;
- }
- span {
- color: rgba(0, 0, 0, 0.85);
- font-size: 14px;
- }
- .el-select {
- width: 200px;
- }
- }
- .search-btn {
- display: flex;
- }
- .notice-state {
- display: flex;
- align-items: center;
- justify-self: center;
- }
- </style>
|