feat: 搜索栏折叠、优化作业
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
This commit is contained in:
parent
5112e9e77c
commit
51531fa49a
@ -42,6 +42,18 @@ $row_selected_bg: #ebf9ff; // #ffebbc;
|
|||||||
|
|
||||||
.vxe-form {
|
.vxe-form {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
|
|
||||||
|
.search-form-actions {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 隐藏 vxe 内置折叠触发器(已改用 vxe-button)
|
||||||
|
.vxe-form--item-trigger-node {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -102,9 +102,43 @@ const gridRef = ref()
|
|||||||
const defaultSearchFormOptions = {
|
const defaultSearchFormOptions = {
|
||||||
titleBold: true,
|
titleBold: true,
|
||||||
data: {},
|
data: {},
|
||||||
collapseNode: true,
|
collapseStatus: false,
|
||||||
} as VxeFormProps
|
} as VxeFormProps
|
||||||
|
|
||||||
|
const SEARCH_FORM_ROW_SPAN = 24
|
||||||
|
|
||||||
|
/** 第二行及以后的筛选项折叠;操作区显示展开/收起 */
|
||||||
|
function applySearchFormCollapse(items: any[], defaultSpan = 6) {
|
||||||
|
let usedSpan = 0
|
||||||
|
let rowIndex = 0
|
||||||
|
|
||||||
|
return items.map((item) => {
|
||||||
|
if (item.slots?.default === 'action') {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
if (item.collapseNode) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
const span = Number(item.span ?? defaultSpan)
|
||||||
|
if (usedSpan + span > SEARCH_FORM_ROW_SPAN) {
|
||||||
|
rowIndex++
|
||||||
|
usedSpan = span
|
||||||
|
} else {
|
||||||
|
usedSpan += span
|
||||||
|
if (usedSpan >= SEARCH_FORM_ROW_SPAN) {
|
||||||
|
rowIndex++
|
||||||
|
usedSpan = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowIndex >= 1 && item.folding !== false) {
|
||||||
|
return { ...item, folding: true }
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 表格的配置
|
// 表格的配置
|
||||||
const checkedProp = 'checked'
|
const checkedProp = 'checked'
|
||||||
const defaultGridOptions = {
|
const defaultGridOptions = {
|
||||||
@ -153,7 +187,11 @@ const gridOptions = ref(defaultGridOptions)
|
|||||||
|
|
||||||
// 初始化表格
|
// 初始化表格
|
||||||
function initGrid() {
|
function initGrid() {
|
||||||
// 表格的列
|
const userColumns = (props.grid?.columns || []) as any[]
|
||||||
|
const leftFixedColumns = userColumns.filter((col) => col.fixed === 'left')
|
||||||
|
const restColumns = userColumns.filter((col) => col.fixed !== 'left')
|
||||||
|
|
||||||
|
// 表格的列:勾选框 → 左侧固定列(如操作)→ 编辑 → 其余列
|
||||||
const gridColumns = []
|
const gridColumns = []
|
||||||
if (!_hideCheckbox.value) {
|
if (!_hideCheckbox.value) {
|
||||||
gridColumns.push({
|
gridColumns.push({
|
||||||
@ -163,6 +201,7 @@ function initGrid() {
|
|||||||
slots: { header: 'checkbox_header', checkbox: 'checkbox_cell' },
|
slots: { header: 'checkbox_header', checkbox: 'checkbox_cell' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
gridColumns.push(...leftFixedColumns)
|
||||||
if (!_hideEdit.value) {
|
if (!_hideEdit.value) {
|
||||||
gridColumns.push({
|
gridColumns.push({
|
||||||
title: '编辑',
|
title: '编辑',
|
||||||
@ -171,11 +210,13 @@ function initGrid() {
|
|||||||
slots: { default: 'mj_edit_default' },
|
slots: { default: 'mj_edit_default' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
gridColumns.push(...restColumns)
|
||||||
|
|
||||||
// 表格合并
|
// 表格合并
|
||||||
const gridOptionsTmp = { ...defaultGridOptions, data: gridOptions.value.data }
|
const gridOptionsTmp = { ...defaultGridOptions, data: gridOptions.value.data }
|
||||||
|
const { columns: _columns, ...gridRest } = props.grid || {}
|
||||||
gridOptionsTmp.columns = gridColumns as any
|
gridOptionsTmp.columns = gridColumns as any
|
||||||
obj.cover(gridOptionsTmp, props.grid)
|
obj.cover(gridOptionsTmp, gridRest)
|
||||||
|
|
||||||
for (const column of gridOptionsTmp.columns!) {
|
for (const column of gridOptionsTmp.columns!) {
|
||||||
if (column.width || column.minWidth) continue
|
if (column.width || column.minWidth) continue
|
||||||
@ -198,7 +239,7 @@ function initGrid() {
|
|||||||
...defaultSearchFormOptions,
|
...defaultSearchFormOptions,
|
||||||
}
|
}
|
||||||
obj.cover(searchFormOptions, props.searchForm)
|
obj.cover(searchFormOptions, props.searchForm)
|
||||||
searchFormOptions.items = [
|
searchFormOptions.items = applySearchFormCollapse([
|
||||||
{
|
{
|
||||||
field: 'keyword',
|
field: 'keyword',
|
||||||
title: '关键字',
|
title: '关键字',
|
||||||
@ -215,7 +256,7 @@ function initGrid() {
|
|||||||
{
|
{
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
},
|
},
|
||||||
]
|
])
|
||||||
searchFormOptions.data = gridOptions.value.formConfig?.data || {}
|
searchFormOptions.data = gridOptions.value.formConfig?.data || {}
|
||||||
gridOptionsTmp.formConfig = searchFormOptions
|
gridOptionsTmp.formConfig = searchFormOptions
|
||||||
}
|
}
|
||||||
@ -225,6 +266,7 @@ function initGrid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gridOptions.value = gridOptionsTmp
|
gridOptions.value = gridOptionsTmp
|
||||||
|
nextTick(() => syncSearchFormCollapsed())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听配置
|
// 监听配置
|
||||||
@ -445,6 +487,34 @@ function reload() {
|
|||||||
gridRef.value.commitProxy('reload')
|
gridRef.value.commitProxy('reload')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const searchFormCollapsed = ref(false)
|
||||||
|
|
||||||
|
const hasSearchFormFold = computed(() =>
|
||||||
|
!!gridOptions.value.formConfig?.items?.some((item: any) => item.folding),
|
||||||
|
)
|
||||||
|
|
||||||
|
function getSearchFormRef() {
|
||||||
|
const maps = gridRef.value?.getRefMaps?.()
|
||||||
|
if (!maps) return null
|
||||||
|
const formRef = maps.refForm
|
||||||
|
return formRef?.value ?? formRef
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncSearchFormCollapsed() {
|
||||||
|
const formRef = getSearchFormRef()
|
||||||
|
if (formRef?.getCollapseStatus) {
|
||||||
|
searchFormCollapsed.value = formRef.getCollapseStatus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSearchCollapse() {
|
||||||
|
const formRef = getSearchFormRef()
|
||||||
|
if (!formRef?.toggleCollapse) return
|
||||||
|
formRef.toggleCollapse().then(() => {
|
||||||
|
syncSearchFormCollapsed()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 搜索表单重置
|
// 搜索表单重置
|
||||||
function searchFormReset() {
|
function searchFormReset() {
|
||||||
// 清除所有选中
|
// 清除所有选中
|
||||||
@ -629,12 +699,23 @@ defineExpose({
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #action>
|
<template #action>
|
||||||
<vxe-button icon="vxe-icon-repeat" @click="searchFormReset">
|
<div class="search-form-actions">
|
||||||
重置
|
<vxe-button icon="vxe-icon-repeat" @click="searchFormReset">
|
||||||
</vxe-button>
|
重置
|
||||||
<vxe-button type="submit" icon="vxe-icon-search" status="primary">
|
</vxe-button>
|
||||||
搜索
|
<vxe-button type="submit" icon="vxe-icon-search" status="primary">
|
||||||
</vxe-button>
|
搜索
|
||||||
|
</vxe-button>
|
||||||
|
<vxe-button
|
||||||
|
v-if="hasSearchFormFold"
|
||||||
|
:icon="
|
||||||
|
searchFormCollapsed ? 'vxe-icon-arrow-down' : 'vxe-icon-arrow-up'
|
||||||
|
"
|
||||||
|
@click="toggleSearchCollapse"
|
||||||
|
>
|
||||||
|
{{ searchFormCollapsed ? '展开' : '收起' }}
|
||||||
|
</vxe-button>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</VxeGrid>
|
</VxeGrid>
|
||||||
|
|
||||||
|
|||||||
@ -266,6 +266,15 @@ const searchForm = {
|
|||||||
// 表格
|
// 表格
|
||||||
const grid = {
|
const grid = {
|
||||||
columns: [
|
columns: [
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
field: 'operation',
|
||||||
|
width: 300,
|
||||||
|
fixed: 'left',
|
||||||
|
slots: {
|
||||||
|
default: 'operation',
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '年级',
|
title: '年级',
|
||||||
field: 'gradeId',
|
field: 'gradeId',
|
||||||
@ -315,13 +324,6 @@ const grid = {
|
|||||||
default: 'uploadStatus',
|
default: 'uploadStatus',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
minWidth: 380,
|
|
||||||
slots: {
|
|
||||||
default: 'operation',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
beforeLoadData(params) {
|
beforeLoadData(params) {
|
||||||
if (userInfo.value.isOnlyStaff) {
|
if (userInfo.value.isOnlyStaff) {
|
||||||
@ -471,17 +473,22 @@ onMounted(() => {
|
|||||||
<el-button size="small" type="success" @click="createTask(row)">
|
<el-button size="small" type="success" @click="createTask(row)">
|
||||||
布置作业
|
布置作业
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-dropdown trigger="hover">
|
||||||
v-if="row.uploadStatus !== 1"
|
<el-button size="small">更多</el-button>
|
||||||
size="small"
|
<template #dropdown>
|
||||||
type="info"
|
<el-dropdown-menu>
|
||||||
@click="triggerUploadPdf(row)"
|
<el-dropdown-item
|
||||||
>
|
v-if="row.uploadStatus !== 1"
|
||||||
上传试题
|
@click="triggerUploadPdf(row)"
|
||||||
</el-button>
|
>
|
||||||
<el-button size="small" type="danger" @click="deletePaper(row)">
|
上传试题
|
||||||
删除试卷
|
</el-dropdown-item>
|
||||||
</el-button>
|
<el-dropdown-item @click="deletePaper(row)">
|
||||||
|
删除试卷
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MjTable>
|
</MjTable>
|
||||||
@ -509,8 +516,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
.operation-btns {
|
.operation-btns {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: nowrap;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
|
||||||
.el-button + .el-button {
|
.el-button + .el-button {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user