Skip to content

Commit 7499028

Browse files
committed
修复含有分类字段数据的批量导入数据校验异常
1 parent cb9e8e0 commit 7499028

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

app/vuecmf/common.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,22 @@ function makeToken(string $username, string $pwd , string $ip): string
104104
* @param string $pid_field 父级字段名
105105
* @param string $search_field 过滤字段名
106106
* @param string $order_field 排序字段名
107+
* @param int $total 总条数
107108
* @return array
108109
*/
109-
function getTreeList($model, int $pid, string $keywords, string $pid_field = 'pid', string $search_field = 'title', string $order_field = 'sort_num'): array
110+
function getTreeList($model, int $pid, string $keywords, string $pid_field = 'pid', string $search_field = 'title', string $order_field = 'sort_num', int &$total = 0): array
110111
{
111112
$query = $model->where($pid_field, $pid);
112113
!empty($keywords) && $query->whereLike($search_field, '%'.$keywords.'%');
113114
!empty($order_field) && $query->order($order_field);
114115
$res = $query->select()->toArray();
116+
$total += count($res);
115117
foreach ($res as &$val){
116-
$child = getTreeList($model,$val['id'], $keywords, $pid_field, $search_field, $order_field);
118+
$child = getTreeList($model, $val['id'], $keywords, $pid_field, $search_field, $order_field, $total);
117119
$val[$pid_field] == 0 && $val[$pid_field] = '';
118-
!empty($child) && $val['children'] = $child;
120+
!empty($child['data']) && $val['children'] = $child['data'];
119121
}
120-
return $res;
122+
return ['data' => $res, 'total' => $total];
121123
}
122124

123125

@@ -191,4 +193,3 @@ function getTreeIdPath(string &$id_path, $model, int $pid = 0, string $pid_field
191193

192194
return $id_path;
193195
}
194-

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"casbin/casbin": "^3.16",
1818
"topthink/think-multi-app": "^1.0",
1919
"casbin/think-authz": "^1.5",
20-
"vuecmf/framework": "^2.0.3"
20+
"vuecmf/framework": "^2.0.4"
2121
},
2222
"require-dev": {
2323
"symfony/var-dumper": "^4.2",

0 commit comments

Comments
 (0)