修服左侧菜单排序不生效 bug

This commit is contained in:
JaguarJack 2020-05-25 14:30:28 +08:00
parent dfcec7394f
commit 0f59685ae3
3 changed files with 14 additions and 15 deletions

View File

@ -74,6 +74,7 @@ class Permissions extends CatchModel
'route', 'icon', 'component', 'redirect', 'route', 'icon', 'component', 'redirect',
'keepalive as keepAlive', 'hide_children_in_menu', 'type', 'permission_mark', 'status' 'keepalive as keepAlive', 'hide_children_in_menu', 'type', 'permission_mark', 'status'
]) ])
->order()
->select(); ->select();
} }

View File

@ -71,11 +71,11 @@ class CatchQuery extends Query
public function withoutField($field, $needAlias = false) public function withoutField($field, $needAlias = false)
{ {
if (empty($field)) { if (empty($field)) {
return $this; return $this;
} }
if (is_string($field)) { if (is_string($field)) {
$field = array_map('trim', explode(',', $field)); $field = array_map('trim', explode(',', $field));
} }
// 过滤软删除字段 // 过滤软删除字段
@ -86,15 +86,14 @@ class CatchQuery extends Query
$field = $fields ? array_diff($fields, $field) : $field; $field = $fields ? array_diff($fields, $field) : $field;
if (isset($this->options['field'])) { if (isset($this->options['field'])) {
$field = array_merge((array) $this->options['field'], $field); $field = array_merge((array) $this->options['field'], $field);
} }
$this->options['field'] = array_unique($field); $this->options['field'] = array_unique($field);
if ($needAlias) { if ($needAlias) {
$alias = $this->getAlias(); $alias = $this->getAlias();
$this->options['field'] = array_map(function ($field) use ($alias) {
$this->options['field'] = array_map(function ($field) use ($alias) {
return $alias . '.' . $field; return $alias . '.' . $field;
}, $this->options['field']); }, $this->options['field']);
} }
@ -190,22 +189,20 @@ class CatchQuery extends Query
*/ */
public function order($field = '', string $order = 'desc', $position = 'backend') public function order($field = '', string $order = 'desc', $position = 'backend')
{ {
// 排序在前
if ($position = 'front') { if ($position = 'front') {
parent::order($field, $order); parent::order($field, $order);
} }
if (in_array('sort', array_keys($this->getFields()))) {
if (property_exists($this, 'field')) { parent::order('sort', $order);
if (in_array('sort', $this->field)) { }
parent::order('sort', 'desc'); // 紧跟权重的排序
}
}
if ($position == 'middle') { if ($position == 'middle') {
parent::order($field, $order); parent::order($field, $order);
} }
parent::order($this->getPk(), 'desc'); parent::order($this->getPk(), $order);
// 最后插入排序
if ($position == 'backend') { if ($position == 'backend') {
parent::order($field, $order); parent::order($field, $order);
} }

View File

@ -0,0 +1 @@
<?php