Skip to content

formatOrderBy

formatOrderBy(sort): string

将 ProTable sorter 提供的数据结构格式化为知晓云支持的排序语句

参数

NameType
sortRecord<string, SortOrder>

返回值

string

示例

ts
function getBannerList(formData, sort) {
 const orderBy = formatOrderBy(sort)

 const {limit, offset, navigate_path: navigatePath} = formData
 const {query} = io

 Object.entries(pick(formData, ['published', 'navigate_type'])).forEach(([field, value]) => {
   if (!isNil(value)) {
     query.compare(field, '=', value)
   }
 })

 if (navigatePath) {
   query.contains('navigate_path', navigatePath)
 }

 return io.banner.find({limit, offset, query, expand: 'edited_by', orderBy}).then(formatTableData)
}

<Table request={getBannerList} />

源码

pro-table-utils.js