增加自动化排序功能

This commit is contained in:
piexlmax
2022-10-30 20:27:22 +08:00
parent c300e16de9
commit 192c0e529d
6 changed files with 54 additions and 6 deletions

View File

@@ -86,6 +86,9 @@
:data="tableData"
row-key="ID"
@selection-change="handleSelectionChange"
{{- if .NeedSort}}
@sort-change="sortChange"
{{- end}}
>
<el-table-column type="selection" width="55" />
<el-table-column align="left" label="日期" width="180">
@@ -93,21 +96,21 @@
</el-table-column>
{{- range .Fields}}
{{- if .DictType}}
<el-table-column align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<template #default="scope">
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
</template>
</el-table-column>
{{- else if eq .FieldType "bool" }}
<el-table-column align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<template #default="scope">{{"{{"}} formatBoolean(scope.row.{{.FieldJson}}) {{"}}"}}</template>
</el-table-column>
{{- else if eq .FieldType "time.Time" }}
<el-table-column align="left" label="{{.FieldDesc}}" width="180">
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" width="180">
<template #default="scope">{{"{{"}} formatDate(scope.row.{{.FieldJson}}) {{"}}"}}</template>
</el-table-column>
{{- else }}
<el-table-column align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
{{- end }}
{{- end }}
<el-table-column align="left" label="按钮组">
@@ -240,9 +243,19 @@ const pageSize = ref(10)
const tableData = ref([])
const searchInfo = ref({})
{{- if .NeedSort}}
// 排序
const sortChange = ({ prop, order }) => {
searchInfo.value.sort = prop
searchInfo.value.order = order
getTableData()
}
{{- end}}
// 重置
const onReset = () => {
searchInfo.value = {}
getTableData()
}
// 搜索