260 lines
7.1 KiB
Vue

<template>
<div class="main">
<el-form
ref="formRef"
:inline="true"
:model="form"
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto"
>
<el-form-item
:label="t('menus.QueryStatistics.tag.account')"
prop="username"
>
<el-input
v-model="form.username"
placeholder="请输入用户账号~"
clearable
class="!w-[150px]"
/>
</el-form-item>
<el-form-item
:label="t('menus.QueryStatistics.tag.nickName')"
prop="nickname"
>
<el-input
v-model="form.nickname"
placeholder="请输入用户名称~"
clearable
class="!w-[150px]"
/>
</el-form-item>
<el-form-item
v-if="hasAuth('code:btn:logAdmin')"
:label="t('menus.maintenance.tag.department')"
prop="department_id"
>
<el-cascader
v-model="form.department_id"
class="!w-[150px]"
:options="departments"
:props="{
value: 'id',
label: 'name',
emitPath: false,
checkStrictly: true
}"
clearable
filterable
placeholder="请选择所属部门~"
>
<template #default="{ node, data }">
<span>{{ data.name }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
<el-form-item
:label="t('menus.QueryStatistics.tag.queryDateRange')"
prop="timeRange"
>
<el-date-picker
v-model="form.timeRange"
:shortcuts="getPickerShortcuts()"
type="datetimerange"
range-separator=""
start-placeholder="开始日期时间"
end-placeholder="结束日期时间"
value-format="x"
unlink-panels
/>
</el-form-item>
<el-form-item>
<el-button
type="primary"
:icon="useRenderIcon('ri:search-line')"
:loading="loading"
@click="onSearch"
>
{{ t("buttons:Search") }}
</el-button>
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
{{ t("buttons:Reset") }}
</el-button>
</el-form-item>
</el-form>
<PureTableBar
:title="t('menus.QueryStatistics.tag.queryLogs')"
:columns="columns"
@refresh="onSearch"
>
<template #buttons>
<el-popconfirm
v-if="hasAuth('code:btn:export')"
title="确定要导出所有日志数据吗?"
@confirm="onExportQueryAll"
>
<template #reference>
<el-button
type="primary"
:icon="useRenderIcon(Export)"
:disabled="!hasAuth('code:btn:export')"
>
{{ t("buttons:ExportAll") }}
</el-button>
</template>
</el-popconfirm>
</template>
<template v-slot="{ size, dynamicColumns }">
<div
v-if="selectedNum > 0"
v-motion-fade
class="bg-[var(--el-fill-color-light)] w-full h-[46px] mb-2 pl-4 flex items-center"
>
<div class="flex-auto">
<span
style="font-size: var(--el-font-size-base)"
class="text-[rgba(42,46,54,0.5)] dark:text-[rgba(220,220,242,0.5)]"
>
已选 {{ selectedNum }}
</span>
<el-button type="primary" text @click="onSelectionCancel">
{{ t("buttons:Deselect") }}
</el-button>
</div>
<el-popconfirm
v-if="hasAuth('code:btn:export')"
title="是否确认批量导出日志数据?"
@confirm="onbatchExport"
>
<template #reference>
<el-button
type="primary"
text
class="mr-1"
:disabled="selectedNum < 0 || !hasAuth('code:btn:export')"
>
{{ t("buttons:ExportInBatches") }}
</el-button>
</template>
</el-popconfirm>
</div>
<pure-table
ref="tableRef"
row-key="id"
align-whole="center"
table-layout="auto"
:loading="loading"
:size="size"
adaptive
:adaptiveConfig="{ offsetBottom: 108 }"
:data="dataList"
:columns="dynamicColumns"
:pagination="{ ...pagination, size }"
:header-cell-style="{
background: 'var(--el-fill-color-light)',
color: 'var(--el-text-color-primary)'
}"
@selection-change="handleSelectionChange"
@page-size-change="handleSizeChange"
@page-current-change="handleCurrentChange"
>
<template #operation="{ row }">
<el-button
class="reset-margin"
link
type="primary"
:size="size"
:disabled="!hasAuth('code:btn:logInfo')"
:icon="useRenderIcon(View)"
@click="onClickDetails(row)"
>
{{ t("buttons:Details") }}
</el-button>
</template>
</pure-table>
</template>
</PureTableBar>
</div>
</template>
<script setup lang="ts">
defineOptions({
name: "CodeQueryLog"
});
import { ref } from "vue";
import View from "@iconify-icons/ep/view";
import Refresh from "@iconify-icons/ep/refresh";
import Export from "@iconify-icons/ri/download-2-line";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { isString } from "@pureadmin/utils";
import { useRouter } from "vue-router";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { $t } from "@/plugins/i18n";
const router = useRouter();
import { useI18n } from "vue-i18n";
import { useQueryLog } from "./utils/hook";
import { QueryCodeLogInfo } from "types/code";
import { hasAuth } from "@/utils/auth";
const formRef = ref();
const tableRef = ref();
const { t } = useI18n();
const {
form,
loading,
columns,
dataList,
departments,
pagination,
selectedNum,
onSearch,
resetForm,
handleCurrentChange,
handleSelectionChange,
handleSizeChange,
onSelectionCancel,
getPickerShortcuts,
onExportQueryAll,
onbatchExport
} = useQueryLog(tableRef);
/**处理详情 */
const onClickDetails = (row: QueryCodeLogInfo) => {
let params = { detailsId: row.id };
Object.keys(params).forEach(param => {
if (!isString(params[param])) {
params[param] = params[param].toString();
}
});
useMultiTagsStoreHook().handleTags("push", {
path: "/code/log/details/:detailsId",
name: "QueryCodedetails",
params: params,
meta: {
title: $t("menus:QueryCodedetails")
},
dynamicLevel: 1
});
router.push({
name: "QueryCodedetails",
params: params
});
};
</script>
<style scoped lang="scss">
:deep(.el-dropdown-menu__item i) {
margin: 0;
}
.main-content {
margin: 24px 24px 0 !important;
}
.search-form {
:deep(.el-form-item) {
margin-bottom: 12px;
}
}
</style>