From e3f4c298b072ccc1bcb671f10af9878b967013f0 Mon Sep 17 00:00:00 2001 From: "meilin.huang" <954537473@qq.com> Date: Tue, 4 Jul 2023 14:13:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=E6=8F=8F=E8=BF=B0=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/pagetable/PageTable.vue | 73 +++++++++++++------ .../src/views/ops/machine/FileManage.vue | 2 +- .../src/views/system/syslog/SyslogList.vue | 6 +- server/internal/sys/api/syslog.go | 5 +- .../sys/infrastructure/persistence/syslog.go | 3 +- 5 files changed, 62 insertions(+), 27 deletions(-) diff --git a/mayfly_go_web/src/components/pagetable/PageTable.vue b/mayfly_go_web/src/components/pagetable/PageTable.vue index beef69f7..921ad3ee 100644 --- a/mayfly_go_web/src/components/pagetable/PageTable.vue +++ b/mayfly_go_web/src/components/pagetable/PageTable.vue @@ -11,7 +11,7 @@
- + @@ -63,14 +63,14 @@
+ highlight-current-row v-loading="loadingData" :size="props.size"> @@ -93,7 +93,8 @@ - @@ -109,6 +110,14 @@ import { TableColumn, TableQuery } from './index'; const emit = defineEmits(['update:queryForm', 'update:pageNum', 'update:pageSize', 'update:selectionData', 'pageChange']) const props = defineProps({ + size: { + type: String, + default: "", + }, + inputWidth: { + type: [Number, String], + default: 0, + }, // 是否显示选择列 showSelection: { type: Boolean, @@ -141,6 +150,13 @@ const props = defineProps({ type: [Number], default: 10, }, + // 查询条件配置 + query: { + type: Array, + default: function () { + return []; + } + }, // 绑定的查询表单 queryForm: { type: Object, @@ -148,13 +164,6 @@ const props = defineProps({ return {}; } }, - // 查询条件配置 - query: { - type: Array, - default: function () { - return []; - } - } }) const state = reactive({ @@ -166,6 +175,8 @@ const state = reactive({ defaultQueryCount: 2, // 默认显示的查询参数个数,展开后每行显示个数为该值加1。第一行用最后一列来占用按钮 queryForm: {} as any, loadingData: false, + // 输入框宽度 + inputWidth: "200px" as any, }) const { @@ -173,6 +184,7 @@ const { defaultQueryCount, queryForm, loadingData, + inputWidth, } = toRefs(state) watch(() => props.queryForm, (newValue: any) => { @@ -195,13 +207,19 @@ watch(() => props.data, (newValue: any) => { } }) } - state.loadingData = false; }) onMounted(() => { state.pageNum = props.pageNum; state.pageSize = props.pageSize; state.queryForm = props.queryForm; + + // 如果没传输入框宽度,则根据组件size设置默认宽度 + if (!props.inputWidth) { + state.inputWidth = props.size == "small" ? "150px" : "200px" + } else { + state.inputWidth = props.inputWidth; + } }) const getRowQueryItem = (row: number) => { @@ -231,16 +249,25 @@ const handleSizeChange = () => { } const queryData = () => { + changePageNum(1); execQuery(); } const reset = () => { - // 触发重新调用查询接口即可 - state.queryForm = {}; - emit('update:queryForm', state.queryForm) + // 将查询参数绑定的值置空,并重新粗发查询接口 + for (let qi of props.query) { + state.queryForm[qi.prop] = null; + } + changePageNum(1); + emit('update:queryForm', state.queryForm); execQuery(); } +const changePageNum = (pageNum: number) => { + state.pageNum = pageNum; + emit('update:pageNum', state.pageNum) +} + const execQuery = () => { emit("pageChange") } @@ -286,15 +313,19 @@ defineExpose({ loading }) font-weight: bold; } -.el-input { - width: 200px; -} - .el-select-v2 { - width: 200px; + width: v-bind(inputWidth); } -::v-deep(.el-date-editor) { +.el-input { + width: v-bind(inputWidth); +} + +.el-select { + width: v-bind(inputWidth); +} + +.el-date-editor { width: 380px !important; } \ No newline at end of file diff --git a/mayfly_go_web/src/views/ops/machine/FileManage.vue b/mayfly_go_web/src/views/ops/machine/FileManage.vue index ff1f8fe5..5486ac8b 100755 --- a/mayfly_go_web/src/views/ops/machine/FileManage.vue +++ b/mayfly_go_web/src/views/ops/machine/FileManage.vue @@ -273,7 +273,7 @@ const getFiles = async () => { state.loading = true; state.query.id = props.machineId as any; const res = await files.request(state.query); - state.fileTable = res.list; + state.fileTable = res.list || []; state.total = res.total; } finally { state.loading = false; diff --git a/mayfly_go_web/src/views/system/syslog/SyslogList.vue b/mayfly_go_web/src/views/system/syslog/SyslogList.vue index 71ed0e83..c1a8140f 100755 --- a/mayfly_go_web/src/views/system/syslog/SyslogList.vue +++ b/mayfly_go_web/src/views/system/syslog/SyslogList.vue @@ -5,8 +5,8 @@ @pageChange="search()">