...
|
...
|
@@ -6,6 +6,7 @@ use app\admin\model\item\ronda\Rel; |
|
|
use app\common\controller\Backend;
|
|
|
use mysql_xdevapi\DocResult;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
use think\exception\DbException;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
...
|
...
|
@@ -231,4 +232,56 @@ class Screen extends Backend |
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量修改
|
|
|
*/
|
|
|
public function multi($ids = NULL){
|
|
|
if (!$this->request->isPost()) {
|
|
|
$this->error(__("Invalid parameters"));
|
|
|
}
|
|
|
$ids = $ids ? $ids : $this->request->post("ids");
|
|
|
$ids = $ids ?: $this->request->post('ids');
|
|
|
if (empty($ids)) {
|
|
|
$this->error(__('Parameter %s can not be empty', 'ids'));
|
|
|
}
|
|
|
|
|
|
if (false === $this->request->has('params')) {
|
|
|
$this->error(__('No rows were updated'));
|
|
|
}
|
|
|
parse_str($this->request->post('params'), $values);
|
|
|
$values = $this->auth->isSuperAdmin() ? $values : array_intersect_key($values, array_flip(is_array($this->multiFields) ? $this->multiFields : explode(',', $this->multiFields)));
|
|
|
if (empty($values)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
|
|
}
|
|
|
$count = 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$list = $this->model->where($this->model->getPk(), 'in', $ids)->select();
|
|
|
$res = $this->model->where('is_view',1)->find()->toArray();
|
|
|
foreach ($list as $item) {
|
|
|
//注意:修改区域!!!!!!!!!!!!
|
|
|
if ($values['is_view'] == 1) {
|
|
|
if (!empty($res)){
|
|
|
$this->error('当前已有显示内容,不能重复选择');
|
|
|
}else{
|
|
|
$values['is_view'] = 1;
|
|
|
}
|
|
|
}
|
|
|
$count += $item->allowField(true)->isUpdate(true)->save($values);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($count) {
|
|
|
$this->success();
|
|
|
}
|
|
|
$this->error(__('No rows were updated'));
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|