文件日志
This commit is contained in:
parent
b1f769d4b3
commit
4c549ed70b
@ -151,7 +151,7 @@ export function userBatchDelete(data:any) {
|
||||
export function userExport() {
|
||||
return http.request({
|
||||
url: '/user/export',
|
||||
method: 'GET',
|
||||
method: 'GET'
|
||||
},{
|
||||
isTransformResponse: false,
|
||||
});
|
||||
|
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-upload action="#" :id="uuid" class="upload-demo my-upload-file"
|
||||
<el-upload action="#" :id="uuid" class="upload-demo my-upload-images"
|
||||
:class="fileList.length > 0 && !loading ? 'success-file' : ''" :multiple="multiple" ref="uploadRef"
|
||||
:disabled="loading ? true : (self_disabled || fileList.length >= props.limit)" :http-request="handleHttpUpload"
|
||||
:before-upload="beforeUpload" list-type="picture-card" :limit="limit" :file-list="fileList"
|
||||
@ -227,7 +227,7 @@ const beforeUpload: UploadProps["beforeUpload"] = (rawFile) => {
|
||||
}
|
||||
}
|
||||
|
||||
.my-upload-file {
|
||||
.my-upload-images {
|
||||
.el-upload-dragger {
|
||||
padding: var(--el-upload-dragger-padding-vertical);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<el-upload
|
||||
action="#"
|
||||
style="width: 220px"
|
||||
:id="uuid"
|
||||
class="upload-demo my-upload-file"
|
||||
:class="fileList.length>0&&!loading?'success-file':''"
|
||||
@ -13,6 +12,7 @@
|
||||
:on-preview="onPreview"
|
||||
:on-remove="handleRemove"
|
||||
:before-upload="beforeUpload"
|
||||
:show-file-list="showFileList"
|
||||
:drag="isBtn?false:true"
|
||||
:limit="limit"
|
||||
>
|
||||
@ -66,6 +66,10 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showFileList: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
btnTip: {
|
||||
type: String,
|
||||
default: ''
|
||||
|
58
src/views/logger/fileLog/columns.ts
Normal file
58
src/views/logger/fileLog/columns.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { h } from 'vue';
|
||||
import { ElTag } from 'element-plus';
|
||||
|
||||
export const columns = [
|
||||
{
|
||||
type: 'selection',
|
||||
},
|
||||
{
|
||||
label: '日志标题',
|
||||
prop: 'title',
|
||||
},
|
||||
{
|
||||
label: '日志类型',
|
||||
prop: 'type',
|
||||
render(record) {
|
||||
let typeText = ''
|
||||
switch (record.row.type) {
|
||||
case 1:
|
||||
typeText='登录'
|
||||
break;
|
||||
case 2:
|
||||
typeText='注册'
|
||||
break;
|
||||
case 3:
|
||||
typeText='找回密码'
|
||||
break;
|
||||
case 4:
|
||||
typeText='业务'
|
||||
break;
|
||||
case 5:
|
||||
typeText='其他'
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return h('span', typeText || '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '请求耗时',
|
||||
prop: 'consumeTime',
|
||||
},
|
||||
{
|
||||
label: '日志状态',
|
||||
prop: 'status',
|
||||
render(record) {
|
||||
return h('span', record.row.status === 1 ? '已读' : '未读')
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
prop: 'createUser',
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
prop: 'createTime',
|
||||
},
|
||||
];
|
120
src/views/logger/fileLog/edit.vue
Normal file
120
src/views/logger/fileLog/edit.vue
Normal file
@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="props.visible"
|
||||
title="日志详情"
|
||||
|
||||
width="700"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-descriptions column="2">
|
||||
<el-descriptions-item label="日志标题:">{{formData.title}}</el-descriptions-item>
|
||||
<el-descriptions-item label="日志类型:">{{getTyepText(formData.type)}}</el-descriptions-item>
|
||||
<el-descriptions-item label="模板编号:">{{formData.number}}</el-descriptions-item>
|
||||
<el-descriptions-item label="接收人手机:">{{formData.receiveMobile}}</el-descriptions-item>
|
||||
<el-descriptions-item label="接收人类型:">{{getReviceType(formData.receiveType)}}</el-descriptions-item>
|
||||
<el-descriptions-item label="请求耗时:">{{formData.consumeTime}}</el-descriptions-item>
|
||||
<el-descriptions-item label="日志状态:">{{formData.status==1?'已读':'未读'}}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogClose">关闭</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type {FormInstance} from "element-plus";
|
||||
import {getFileLogDetail} from "@/api/logger/fileLog";
|
||||
import {onMounted, reactive, shallowRef} from "vue";
|
||||
import {message} from "@/utils/auth";
|
||||
import {useLockFn} from "@/utils/useLockFn";
|
||||
|
||||
const emit = defineEmits(["success", "update:visible"]);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
const formData = reactive({
|
||||
id: "",
|
||||
title: "",
|
||||
type:'',
|
||||
number:'',
|
||||
receiveMobile:'',
|
||||
receiveType:'',
|
||||
consumeTime:'',
|
||||
status:''
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false
|
||||
},
|
||||
fileId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const dialogClose = () => {
|
||||
emit("update:visible", false);
|
||||
};
|
||||
|
||||
const setFormData = async () => {
|
||||
const data = await getFileLogDetail(props.fileId);
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
const getReviceType =(type)=>{
|
||||
let typeText = ''
|
||||
switch (type) {
|
||||
case 1:
|
||||
typeText='系统用户'
|
||||
break;
|
||||
case 2:
|
||||
typeText='会员用户'
|
||||
break;
|
||||
case 3:
|
||||
typeText='其他'
|
||||
break;
|
||||
default:
|
||||
break
|
||||
}
|
||||
return typeText
|
||||
}
|
||||
const getTyepText =(type)=>{
|
||||
let typeText = ''
|
||||
switch (type) {
|
||||
case 1:
|
||||
typeText='登录'
|
||||
break;
|
||||
case 2:
|
||||
typeText='注册'
|
||||
break;
|
||||
case 3:
|
||||
typeText='找回密码'
|
||||
break;
|
||||
case 4:
|
||||
typeText='业务'
|
||||
break;
|
||||
case 5:
|
||||
typeText='其他'
|
||||
break;
|
||||
default:
|
||||
break
|
||||
}
|
||||
return typeText
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.fileId) {
|
||||
setFormData();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
137
src/views/logger/fileLog/index.vue
Normal file
137
src/views/logger/fileLog/index.vue
Normal file
@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<PageWrapper>
|
||||
<el-card :bordered="false" class="pt-3 mb-3 proCard">
|
||||
<BasicForm @register="register" @submit="handleSubmit" @reset="handleReset"></BasicForm>
|
||||
</el-card>
|
||||
<el-card :bordered="false" class="proCard">
|
||||
<BasicTable
|
||||
:columns="columns"
|
||||
:request="loadDataTable"
|
||||
:row-key="(row) => row.id"
|
||||
ref="tableRef"
|
||||
:actionColumn="actionColumn"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #tableTitle>
|
||||
<UploadFile style="margin-right:20px;" @upload="fileUploadFiles" file-type=".pdf.xlsx.xls.doc.docx.jpeg,.png,.jpg,.gif" name="logger" :multiple="true" :showFileList="false" :isBtn="true"/>
|
||||
<el-button type="danger" @click="handleDelete()" :disabled="!selectionData.length" v-perm="['sys:fileLog:batchDelete']">
|
||||
<template #icon>
|
||||
<el-icon class="el-input__icon">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</template>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</el-card>
|
||||
|
||||
<editDialog
|
||||
v-if="editVisible"
|
||||
:fileId="fileId"
|
||||
v-model:visible="editVisible"
|
||||
@success="reloadTable('noRefresh')"
|
||||
>
|
||||
</editDialog>
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, h,nextTick,defineAsyncComponent } from 'vue';
|
||||
import { ColProps } from 'element-plus';
|
||||
import { schemas } from './querySchemas';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { TableAction } from '@/components/Table';
|
||||
import { getFileLogList,fileLogDelete,fileLogBatchDelete } from '@/api/logger/fileLog';
|
||||
import UploadFile from '@/components/Upload/file.vue';
|
||||
import { columns } from './columns';
|
||||
import {message,confirm} from "@/utils/auth";
|
||||
const editDialog = defineAsyncComponent(() =>
|
||||
import('./edit.vue')
|
||||
)
|
||||
const fileId =ref(0)
|
||||
const editVisible=ref(false)
|
||||
const selectionData = ref([])
|
||||
const tableRef = ref();
|
||||
const formParams = reactive({
|
||||
fileName:'',
|
||||
fileType:''
|
||||
});
|
||||
const actionColumn = reactive({
|
||||
width: 250,
|
||||
label: '操作',
|
||||
prop: 'action',
|
||||
fixed: 'right',
|
||||
render(record) {
|
||||
return h(TableAction, {
|
||||
style: 'button',
|
||||
actions: [
|
||||
{
|
||||
label: '详情',
|
||||
type: 'warning',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
auth: ['sys:fileLog:detail'],
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
onClick: handleDelete.bind(null, record),
|
||||
auth: ['sys:fileLog:delete'],
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const loadDataTable = async (res: any) => {
|
||||
const result = await getFileLogList({ ...formParams, ...res });
|
||||
return result;
|
||||
};
|
||||
|
||||
function reloadTable(noRefresh='') {
|
||||
tableRef.value.reload(noRefresh?{}:{pageNo:1});
|
||||
}
|
||||
const [register, {}] = useForm({
|
||||
labelWidth: 80,
|
||||
layout: 'horizontal',
|
||||
colProps: { span: 6 } as ColProps,
|
||||
submitOnReset:true,
|
||||
schemas
|
||||
});
|
||||
function handleSubmit(values: Recordable) {
|
||||
handleReset()
|
||||
for (const key in values) {
|
||||
formParams[key] = values[key]
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
for (const key in formParams) {
|
||||
formParams[key] ='';
|
||||
}
|
||||
}
|
||||
const handleDetail = async (record: Recordable) => {
|
||||
fileId.value=record.row.id
|
||||
await nextTick();
|
||||
editVisible.value=true
|
||||
};
|
||||
const fileUploadFiles = () => {
|
||||
reloadTable()
|
||||
};
|
||||
async function handleDelete(record: Recordable) {
|
||||
let ids = []
|
||||
if(!record){
|
||||
ids = selectionData.value.map(({id}) => id);
|
||||
}
|
||||
await confirm('确定要删除?');
|
||||
record? await fileLogDelete(record.row.id):await fileLogBatchDelete(ids);
|
||||
message("删除成功");
|
||||
reloadTable()
|
||||
}
|
||||
function onSelectionChange(value){
|
||||
selectionData.value = value
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
34
src/views/logger/fileLog/querySchemas.ts
Normal file
34
src/views/logger/fileLog/querySchemas.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { FormSchema } from '@/components/Form/index';
|
||||
export const schemas: FormSchema[] = [
|
||||
{
|
||||
field: 'fileName',
|
||||
component: 'Input',
|
||||
label: '文件名称',
|
||||
componentProps: {
|
||||
placeholder: '请输入文件名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'fileType',
|
||||
component: 'Select',
|
||||
label: '文件类型',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请选择文件类型',
|
||||
options: [
|
||||
{
|
||||
label: '文档',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
label: '视频',
|
||||
value: '2',
|
||||
},
|
||||
{
|
||||
label: '其他',
|
||||
value: '3',
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
];
|
@ -92,7 +92,6 @@
|
||||
import {downloadByData} from '@/utils/file/download';
|
||||
const userId = ref(0);
|
||||
const tableRef = ref();
|
||||
const basicTableRef = ref();
|
||||
const editVisible = ref(false)
|
||||
const selectionData = ref([])
|
||||
const upload = ref<UploadInstance>();
|
||||
|
Loading…
Reference in New Issue
Block a user