作者 Cool
1 个管道 的构建 失败 耗费 2 秒

后台用户列表功能优化,新增用户同步新增报考数据

... ... @@ -39,7 +39,7 @@ class User extends Backend
if ($this->request->request('keyField')) {
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
list($where, $sort, $order, $offset, $limit) = $this->buildparams('user.id,user.username,user.nickname.user.password,user.card,user.work_address,user.studynum');
$total = $this->model
->with('group')
->where($where)
... ... @@ -82,6 +82,15 @@ class User extends Backend
if($this->check_identity($params['card'])) {
$this->error('该身份证号已存在');
}
$study = [];
if($params['study_id'] && $params['periodtime']) {
$study = [
'study_id' => $params['study_id'],
'periodtime' => strtotime($params['periodtime'])
];
unset($params['study_id']);
unset($params['periodtime']);
}
$result = false;
Db::startTrans();
try {
... ... @@ -92,6 +101,22 @@ class User extends Backend
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
if($study) {
$res['third_id'] = $params['third_id'];
$res['study_id'] = $params['study_id'];
$res['createtime'] = time();
$res['playtime'] = 0;
$classes_ids = Db::name('classes')->where('study_id',$res['study_id'])->where('is_major',1)->column('id');
foreach ($classes_ids as $v){
$res['class_id'] = $v;
Db::name('study_class')->insertGetId($res);
}
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$study['third_id'] = $this->model->id;
Db::name('third_study')->insertGetId($study);
}
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
... ...
... ... @@ -29,5 +29,7 @@ return [
'Updatetime' => '更新时间',
'Token' => 'Token',
'Status' => '状态',
'Study_id' => '考试科目id',
'Periodtime' => '考试有效期',
'Leave password blank if dont want to change' => '不修改密码请留空',
];
... ...
... ... @@ -90,6 +90,18 @@
<input id="c-expirationtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expirationtime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Study_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-study_id" data-rule="" data-source="study/index" data-field="examname" class="form-control selectpage" name="row[study_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Periodtime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-periodtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[periodtime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -42,7 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'card', title: __('身份证'), operate:false},
{field: 'phone', title: __('手机号'), operate:false},
{field: 'sex', title: __('性别'), searchList: {"1":"男","0":'女'},formatter: Table.api.formatter.flag},
{field: 'work_address', title: __('工作地点'), operate:false},
{field: 'work_address', title: __('工作地点'),operate:'LIKE'},
{field: 'image', title: __('头像'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
// {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
// {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
... ...