修复主键非ID时的排序错误

pull/131/MERGE
Karson 2019-06-08 09:49:30 +08:00
parent 843a10fadd
commit f9d14aa693
2 changed files with 8 additions and 5 deletions

View File

@ -147,12 +147,14 @@ class Ajax extends Backend
$field = $this->request->post("field"); $field = $this->request->post("field");
//操作的数据表 //操作的数据表
$table = $this->request->post("table"); $table = $this->request->post("table");
//主键
$pk = $this->request->post("pk");
//排序的方式 //排序的方式
$orderway = $this->request->post("orderway", "", 'strtolower'); $orderway = $this->request->post("orderway", "", 'strtolower');
$orderway = $orderway == 'asc' ? 'ASC' : 'DESC'; $orderway = $orderway == 'asc' ? 'ASC' : 'DESC';
$sour = $weighdata = []; $sour = $weighdata = [];
$ids = explode(',', $ids); $ids = explode(',', $ids);
$prikey = 'id'; $prikey = $pk ? $pk : (Db::name($table)->getPk() ?: 'id');
$pid = $this->request->post("pid"); $pid = $this->request->post("pid");
//限制更新的字段 //限制更新的字段
$field = in_array($field, ['weigh']) ? $field : 'weigh'; $field = in_array($field, ['weigh']) ? $field : 'weigh';
@ -160,9 +162,9 @@ class Ajax extends Backend
// 如果设定了pid的值,此时只匹配满足条件的ID,其它忽略 // 如果设定了pid的值,此时只匹配满足条件的ID,其它忽略
if ($pid !== '') { if ($pid !== '') {
$hasids = []; $hasids = [];
$list = Db::name($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field('id,pid')->select(); $list = Db::name($table)->where($prikey, 'in', $ids)->where('pid', 'in', $pid)->field("{$prikey},pid")->select();
foreach ($list as $k => $v) { foreach ($list as $k => $v) {
$hasids[] = $v['id']; $hasids[] = $v[$prikey];
} }
$ids = array_values(array_intersect($ids, $hasids)); $ids = array_values(array_intersect($ids, $hasids));
} }

View File

@ -277,7 +277,8 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
pid: pid, pid: pid,
field: Table.config.dragsortfield, field: Table.config.dragsortfield,
orderway: options.sortOrder, orderway: options.sortOrder,
table: options.extend.table table: options.extend.table,
pk: options.pk
} }
}; };
Fast.api.ajax(params, function (data, ret) { Fast.api.ajax(params, function (data, ret) {
@ -409,7 +410,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
}); });
Layer.photos({ Layer.photos({
photos: { photos: {
"start":$(this).index(".img-center"), "start": $(this).index(".img-center"),
"data": data "data": data
}, },
anim: 5 //0-6的选择指定弹出图片动画类型默认随机请注意3.0之前的版本用shift参数 anim: 5 //0-6的选择指定弹出图片动画类型默认随机请注意3.0之前的版本用shift参数