生日和导入
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
孟凡懂 2022-06-20 07:31:27 +08:00
parent 1c51660d71
commit 6d36de177a
17 changed files with 791 additions and 229 deletions

View File

@ -77,7 +77,9 @@ class Dashboard extends Backend
'visittime'=>['<=',Date::unixtime('day', 0,'end')]
);
$visit = Visit::where($visit_where)->where('status',0)->count();
//var_dump(Visit::getlastsql());
//今日生日
$birthday_users = Db::query("select count(*) as num from car_user4s_user where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY(NOW())");
//var_dump(Db::getlastsql(), $birthday_users);
$index_data = [
'totaluser' => User::count(),
'totalvipuser' => User::where('level_id','>','1')->count(),
@ -96,6 +98,7 @@ class Dashboard extends Backend
// return $item['Data_length'] + $item['Index_length'];
// }, $dbTableList)),
// 'totalworkingaddon' => $totalworkingaddon,
'birthday_num' => isset($birthday_users[0]['num']) ? $birthday_users[0]['num'] : 0,
'ins_end' => $ins_end,
'visit' => $visit,
'all_visit' => Visit::count(),

View File

@ -9,6 +9,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
@ -99,18 +100,13 @@ class Log extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
//新建表导入处理
if ($params['newtable']) {
$prefix = Config::get('database.prefix');
$table = $prefix . $params['newtable'];
$check = db()->query("SHOW TABLES LIKE '%{$table}%';");
if ($check) {
$this->error(__($params['newtable'] . '表已经存在'));
}
} else {
if (!$params['table']) $this->error('未选择目标表');
}
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = 'comment';//name
$table = $prefix.'user4s_user';
$params['newtable'] = false;
$params['table'] = $table;
$fileData = $this->fileData($params);
@ -130,52 +126,41 @@ class Log extends Backend
}
}
if ($has_admin_id) {
foreach ($insert as &$val) {
foreach ($insert as $key => &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $this->auth->isLogin() ? $this->auth->id : 0;
}
}
}
foreach ($insert as $key => &$val) {
//处理字段
$cardinfo = $this->checkcardid($val['cardid']);
if ($cardinfo['iscard'] == false) {
unset($insert[$key]);
}else{
$val['birthday'] = $cardinfo['birthday'];
$val['genderdata'] = $cardinfo['sex'];
}
if(empty($val['frameno'])){
unset($insert[$key]);
}else{
$check_frameno = $this->check_frameno($val['frameno']);
if($check_frameno == false){
unset($insert[$key]);
}
}
}
var_dump($insert);exit();
$prefix = Config::get('database.prefix');
$count = 0;
if ($params['update']) {
foreach ($insert as &$val) {
$count += Db::name(str_replace($prefix, "", $params['table']))
$count += Db::name('user4s_user')
->where($params['update'], $val['pid'])
->update($val);
}
} else {
if ($params['to']) {
$file = db('attachment')->where('url', $fileData['path'])->find();
$this->fieldModel = new \app\admin\model\salary\Field;
$fields = $this->fieldModel->where('name', 'not in', ['pid', 'name', 'status', 'create_time', 'update_time', 'deletetime'])->select();
$toData = [];
// dump($fields);
$insertData = [];
foreach ($insert as $key => $val) {
foreach ($fields as $ke => $field) {
if (isset($val[$field['name']])) {
$toData[$ke]['pid'] = $val['pid'];
$toData[$ke]['name'] = $val['name'];
$toData[$ke]['type'] = $field['name'];
$toData[$ke]['type_name'] = $field['desc'];
$toData[$ke]['field_type'] = $field['type'];
$toData[$ke]['je'] = $val[$field['name']];
$toData[$ke]['filename'] = $file['filename'];
$toData[$ke]['sha1'] = $file['sha1'];
$toData[$ke]['createtime'] = time();
}
}
if ($insertData) $insertData = array_merge($insertData, $toData);
else $insertData = $toData;
}
// dump($insertData);
// exit;
Db::name(str_replace($prefix, "", $params['to']))->where('sha1', $file['sha1'])->delete();
$res = Db::name(str_replace($prefix, "", $params['to']))->insertAll($insertData);
} else {
$res = Db::name(str_replace($prefix, "", $params['table']))->insertAll($insert);
}
$res = Db::name('user4s_user')->insertAll($insert);
$count = count($insert);
}
@ -283,11 +268,23 @@ class Log extends Backend
}
}
public function check_frameno($frameno)
{
if(empty($frameno)){
return false;
}
$user = new \app\common\model\user4s\User;
$has_frameno = $user->where(['frameno' =>$frameno])->find();
if (empty($has_frameno->id)) {
return true;
}else{
return false;
}
}
protected function fileData($params)
{
$file = $path = $params['path'];
$row = $params['row'];
$row = 2;
$sheet = 0;
if (!$file) {
$this->error(__('Parameter %s can not be empty', 'file'));
@ -330,8 +327,9 @@ class Log extends Backend
$prefix = Config::get('database.prefix');
//导入文件首行类型,默认是注释,如果需要使用字段名称请使用name
$importHeadType = $params['head_type'];
$table = $params['table'];
$importHeadType = 'comment';//name
$table = $prefix.'user4s_user';
$params['newtable'] = false;
$database = \think\Config::get('database.database');
$fieldArr = [];
$notnull = [];
@ -342,6 +340,7 @@ class Log extends Backend
"SELECT COLUMN_NAME,COLUMN_COMMENT,COLUMN_TYPE,IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?",
[$table, $database]
);
//var_dump($list,$table, $database);
foreach ($list as $k => $v) {
if ($v['COLUMN_NAME'] !== $pk) {
if ($importHeadType == 'comment') {
@ -373,10 +372,12 @@ class Log extends Backend
}
$currentSheet = $PHPExcel->getSheet($sheet); //读取文件中的第一个工作表
$allColumn = $currentSheet->getHighestDataColumn(); //取得最大的列号
$allColumn = 'O'; //todo:取得最大的列号
//var_dump($allColumn);
$allRow = $currentSheet->getHighestRow(); //取得一共有多少行
$maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
$fields = [];
//todo处理表头第一行
for ($currentRow = 1; $currentRow <= 1; $currentRow++) {
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
@ -388,6 +389,34 @@ class Log extends Backend
'field' => $val,
'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val),
);
//手动加入表头字段
// if($val == '身份证' && $currentColumn == 3){
// $val = '性别';
// $fields[] = $val;
// $col[] = array(
// 'title' => $val,
// 'class' => isset($fieldArr[$val]) ? 'success' : '-',
// 'type' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_TYPE'] : '--',
// 'field' => $val,
// 'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val),
// );
// $val = '生日';
// $fields[] = $val;
// $col[] = array(
// 'title' => $val,
// 'class' => isset($fieldArr[$val]) ? 'success' : '-',
// 'type' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_TYPE'] : '--',
// 'field' => $val,
// 'fieldName' => isset($fieldArr[$val]) ? $fieldArr[$val]['COLUMN_NAME'] : '--' //Pinyin::get($val),
// );
// //var_dump($col);exit();
// $count += 2;
// }
// if($currentColumn == $maxColumnNumber){
// $fields[] = '身份证校验';
// $fields[] = '车架号校验';
// }
if (isset($fieldArr[$val])) {
$count += 1;
}
@ -395,14 +424,35 @@ class Log extends Backend
}
for ($currentRow = $row; $currentRow <= $allRow; $currentRow++) {
$values = [];
// $check_cardid = true;
// $check_frameno = true;
for ($currentColumn = 1; $currentColumn <= $maxColumnNumber; $currentColumn++) {
//var_dump($currentSheet->getCellByColumnAndRow($currentColumn, $currentRow));
$val = $currentSheet->getCellByColumnAndRow($currentColumn, $currentRow)->getValue();
//todo:处理日期格式
if($currentColumn == 8 || $currentColumn == 15){
$val = date('Y-m-d',Date::excelToTimestamp($val));
}
$values[] = is_null($val) ? '' : $val;
//todo:手工处理自定义字段
// if($currentColumn == 3){
// $cardinfo = $this->checkcardid($val);
// $check_cardid = $cardinfo['iscard'];
// $values[] = $cardinfo['sex'] == 'female' ?'女':'男';
// $values[] = $cardinfo['birthday'];
// }
// if($currentColumn == 10){
// $check_frameno = $this->check_frameno($val);
// }
// if($currentColumn == $maxColumnNumber){
// $values[] = $check_cardid?'成功':'失败';
// $values[] = $check_frameno?'成功':'失败';
// }
}
$rows = [];
$all = [];
$temp = array_combine($fields, $values);
foreach ($temp as $k => $v) {
if (isset($fieldArr[$k]) && $k !== '') {
$rows[$fieldArr[$k]['COLUMN_NAME']] = $v;
@ -415,6 +465,7 @@ class Log extends Backend
}
$allData[] = $all;
}
return array(
'path' => $path,
'field' => $col,

View File

@ -12,6 +12,13 @@ use think\Db;
use think\exception\PDOException;
use think\exception\ValidateException;
use think\Config;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use fast\Pinyin;
/**
* 用户档案
*
@ -99,7 +106,7 @@ class User extends Backend
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
$id = $this->request->param('id');
if(empty($id)){
if (empty($id)) {
$result = array("code" => 1, "msg" => '用户ID为空');
return json($result);
};
@ -107,7 +114,7 @@ class User extends Backend
if (!$row) {
$result = array("code" => 1, "msg" => __('No Results were found'));
return json($result);
}else{
} else {
//$row->getRelation('category')->visible(['name']);
//$row->getRelation('level')->visible(['name']);
$result = array("code" => 0, "msg" => 'success', "data" => $row);
@ -139,16 +146,29 @@ class User extends Backend
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$cardinfo = $this->checkcardid($params['cardid']);
if ($cardinfo['iscard'] == false) {
$this->model->rollback();
$this->error('身份证号错误');
} else {
$params['birthday'] = $cardinfo['birthday'];
$params['genderdata'] = $cardinfo['sex'];
}
$has_frameno = $this->model->get(['frameno', $params['frameno']]);
if (!empty($has_frameno->id)) {
$this->model->rollback();
$this->error('车架号重复');
}
$result = $this->model->allowField(true)->save($params);
//var_dump($params['need_visit']);
//新加用户期初等级
if($result && $this->model->id){
if($params['need_visit'] == 1){
$log_res = $this->model->afterlog($this->auth->id,$this->model,$this->model->id,'',true);
}else{
$log_res = $this->model->afterlog($this->auth->id,$this->model,$this->model->id,'',false);
if ($result && $this->model->id) {
if ($params['need_visit'] == 1) {
$log_res = $this->model->afterlog($this->auth->id, $this->model, $this->model->id, '', true);
} else {
$log_res = $this->model->afterlog($this->auth->id, $this->model, $this->model->id, '', false);
}
if(!$log_res){
if (!$log_res) {
$this->model->rollback();
$this->error('新增失败');
}
@ -197,8 +217,82 @@ class User extends Backend
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
$result = false;
$this->model->startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
return parent::edit($ids);
$cardinfo = $this->checkcardid($params['cardid']);
if ($cardinfo['iscard'] == false) {
$this->model->rollback();
$this->error('身份证号错误');
} else {
$params['birthday'] = $cardinfo['birthday'];
$params['genderdata'] = $cardinfo['sex'];
}
$has_frameno = $this->model->get(['frameno', $params['frameno']]);
if (!empty($has_frameno->id)) {
$this->model->rollback();
$this->error('车架号重复');
}
$result = $this->model->allowField(true)->save($params);
$result = $row->allowField(true)->save($params);
$this->model->commit();
} catch (ValidateException $e) {
$this->model->rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
$this->model->rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
$this->model->rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
public function check_cardid()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$cardinfo = $this->checkcardid($params['cardid']);
if ($cardinfo['iscard']) {
$this->success('身份证号正确');
}
}
$this->error('身份证号错误');
}
$this->error('获取数据错误');
}
public function check_frameno()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$has_frameno = $this->model->where(['frameno' => $params['frameno']])->find();
//var_dump($has_frameno);
if (empty($has_frameno->id)) {
$this->success('车架号正确');
}
}
$this->error('车架号重复');
}
$this->error('车架号重复');
}
/**
* 删除
@ -274,7 +368,7 @@ class User extends Backend
//记录用户充值、积分、等级记录
$log_data = array(
'user4s_id' => $row->id,
'admin_id'=>$this->auth->id
'admin_id' => $this->auth->id
);
//余额充值
if ($params['balance'] > 0) {
@ -296,10 +390,10 @@ class User extends Backend
$log_data['start'] = $row->integral;
$log_data['end'] = $end;
$log_data['state'] = 1;
if($now > 0){
$log_data['description'] = $params['description'].' 赠送积分:'.$now;
}else{
$log_data['description'] = $params['description'].' 系统后台扣除积分'.$now;
if ($now > 0) {
$log_data['description'] = $params['description'] . ' 赠送积分:' . $now;
} else {
$log_data['description'] = $params['description'] . ' 系统后台扣除积分' . $now;
}
$this->log_model = new \app\common\model\user4s\Log();
$this->log_model->isUpdate(false)->save($log_data);
@ -312,12 +406,12 @@ class User extends Backend
$log_data['start'] = $row->level_id;
$log_data['end'] = $end;
$log_data['description'] = '会员等级变动,由 '.$all_level[$row->level_id].' 更改为:'.$all_level[$end];
$log_data['description'] = '会员等级变动,由 ' . $all_level[$row->level_id] . ' 更改为:' . $all_level[$end];
//var_dump($log_data);
$this->levellog_model->isUpdate(false)->save($log_data);
$user_data['level_id'] = $end;
}
if(isset($user_data['balance']) || isset($user_data['integral']) || isset($user_data['level_id'])){
if (isset($user_data['balance']) || isset($user_data['integral']) || isset($user_data['level_id'])) {
//var_dump($user_data);
//$this->model->get($row->id);
$this->model->save($user_data, ['id' => $row->id]);
@ -338,17 +432,28 @@ class User extends Backend
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
$start_date = strtotime("-1 year");
$end_date = strtotime("+2 month",$start_date);
$end_date = strtotime("+2 month", $start_date);
$ins_where = array(
'insdate'=>['between',[date('Y-m-d',$start_date),date('Y-m-d',$end_date)]]
'insdate' => ['between', [date('Y-m-d', $start_date), date('Y-m-d', $end_date)]]
);
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['category', 'level'])
->where($where)
->where($ins_where)
->where(function ($query) {
for ($y=1; $y<=20; $y++) {
$start_date = strtotime("-".$y." year");
$end_date = strtotime("+2 month", $start_date);
$ins_where = array(
'insdate' => ['between', [date('Y-m-d', $start_date), date('Y-m-d', $end_date)]]
);
$query->whereOr($ins_where);
}
})
->order($sort, $order)
->paginate($limit);
//var_dump($this->model->getLastSql());
@ -357,7 +462,7 @@ class User extends Backend
$row->getRelation('level')->visible(['name']);
}
$result = array("total" => $list->total(), "rows" => $list->items(),"extend" => ['start_date' => date('Y-m-d',$start_date), 'end_date' => date('Y-m-d',$end_date)]);
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d', $start_date), 'end_date' => date('m-d', $end_date)]);
return json($result);
}
@ -390,31 +495,33 @@ class User extends Backend
if (!empty($params['inscom']) && !empty($params['insdate'])) {
$log_data = array(
'user4s_id' => $row->id,
'admin_id'=>$this->auth->id,
'inscom'=>$params['inscom'],
'insdate'=>$params['insdate'],
'star'=>$params['star'],
'description'=>$params['description']
'admin_id' => $this->auth->id,
'instype' => $params['instype'],
'inscom' => $params['inscom'],
'insdate' => $params['insdate'],
'star' => $params['star'],
'description' => $params['description']
);
$this->Inslog_model = new \app\common\model\user4s\Inslog();
$this->Inslog_model->isUpdate(false)->save($log_data);
$user_data = array(
'inscom'=>$params['inscom'],
'insdate'=>$params['insdate'],
'instype' => $params['instype'],
'inscom' => $params['inscom'],
'insdate' => $params['insdate'],
);
$this->model->save($user_data, ['id' => $row->id]);
}else{
$this->error('请填写续保信息',url('user4s/user/expireins',['user4s_id'=>$row->id]));
} else {
$this->error('请填写续保信息', url('user4s/user/expireins', ['user4s_id' => $row->id]));
}
$this->success('续保成功!',url('user4s/user/expireins',['user4s_id'=>$row->id]));
$this->success('续保成功!', url('user4s/user/expireins', ['user4s_id' => $row->id]));
}
//var_dump($col);
$all_star = array(
1=>'★',
2=>'★★',
3=>'★★★',
4=>'★★★★',
5=>'★★★★★',
1 => '★',
2 => '★★',
3 => '★★★',
4 => '★★★★',
5 => '★★★★★',
);
$this->view->assign("now", date('Y-m-d'));
$this->view->assign("all_star", $all_star);
@ -422,4 +529,177 @@ class User extends Backend
return $this->view->fetch();
}
/**
* 过生日用户列表
*/
public function birthday()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
$birthday_users = Db::query("select id from car_user4s_user where MONTH(birthday) = MONTH(NOW()) and DAY(birthday) = DAY(NOW())");
if(empty($birthday_users)){
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]);
return json($result);
}else{
foreach ($birthday_users as $key => $value) {
$birthday_user_ids[] = $value['id'];
}
}
if(empty($birthday_user_ids)){
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]);
return json($result);
}
//var_dump($birthday_user_ids);
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['category', 'level'])
->where($where)
->where('user.id', 'in', $birthday_user_ids)
->order($sort, $order)
->paginate($limit);
//var_dump($this->model->getLastSql());
foreach ($list as $row) {
$row->getRelation('category')->visible(['name']);
$row->getRelation('level')->visible(['name']);
}
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d')]);
return json($result);
}
return $this->view->fetch();
}
/**
* 导入数据界面
*/
public function excel()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
$step = $params['step'];
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
//新建表导入处理
if ($params['newtable']) {
$prefix = Config::get('database.prefix');
$table = $prefix . $params['newtable'];
$check = db()->query("SHOW TABLES LIKE '%{$table}%';");
if ($check) {
$this->error(__($params['newtable'] . '表已经存在'));
}
} else {
if (!$params['table']) $this->error('未选择目标表');
}
$fileData = $this->fileData($params);
$fileData['params'] = http_build_query($params);
$fileData['newtable'] = $params['newtable'];
if (!$step) {
$this->success('匹配到' . $fileData['count'] . '列,开始预览', '', $fileData);
}
$insert = $fileData['insert'];
$fieldArr = $fileData['fieldArr'];
//是否包含admin_id字段
$has_admin_id = false;
foreach ($fieldArr as $name => $key) {
if ($key == 'admin_id') {
$has_admin_id = true;
break;
}
}
if ($has_admin_id) {
foreach ($insert as &$val) {
if (!isset($val['admin_id']) || empty($val['admin_id'])) {
$val['admin_id'] = $this->auth->isLogin() ? $this->auth->id : 0;
}
}
}
$prefix = Config::get('database.prefix');
$count = 0;
if ($params['update']) {
foreach ($insert as &$val) {
$count += Db::name(str_replace($prefix, "", $params['table']))
->where($params['update'], $val['pid'])
->update($val);
}
} else {
if ($params['to']) {
$file = db('attachment')->where('url', $fileData['path'])->find();
$this->fieldModel = new \app\admin\model\salary\Field;
$fields = $this->fieldModel->where('name', 'not in', ['pid', 'name', 'status', 'create_time', 'update_time', 'deletetime'])->select();
$toData = [];
// dump($fields);
$insertData = [];
foreach ($insert as $key => $val) {
foreach ($fields as $ke => $field) {
if (isset($val[$field['name']])) {
$toData[$ke]['pid'] = $val['pid'];
$toData[$ke]['name'] = $val['name'];
$toData[$ke]['type'] = $field['name'];
$toData[$ke]['type_name'] = $field['desc'];
$toData[$ke]['field_type'] = $field['type'];
$toData[$ke]['je'] = $val[$field['name']];
$toData[$ke]['filename'] = $file['filename'];
$toData[$ke]['sha1'] = $file['sha1'];
$toData[$ke]['createtime'] = time();
}
}
if ($insertData) $insertData = array_merge($insertData, $toData);
else $insertData = $toData;
}
// dump($insertData);
// exit;
Db::name(str_replace($prefix, "", $params['to']))->where('sha1', $file['sha1'])->delete();
$res = Db::name(str_replace($prefix, "", $params['to']))->insertAll($insertData);
} else {
$res = Db::name(str_replace($prefix, "", $params['table']))->insertAll($insert);
}
$count = count($insert);
}
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($count !== false) {
$params['status'] = 'normal';
$result = $this->model->allowField(true)->save($params);
$tip = $params['update'] ? '成功更新' : '成功新增';
$this->success($tip . $count . '条记录', '', array('count' => $count));
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("update", $this->request->request('update'));
$this->view->assign("to", $this->request->request('to'));
return $this->view->fetch();
}
}

View File

@ -4,7 +4,8 @@ return [
'Id' => 'ID',
'User4s_id' => '会员',
'Admin_id' => '操作员',
'Inscom' => '保险类型',
'Instype' => '保险类型',
'Inscom' => '保险公司',
'Insdate' => '保险日期',
'Description' => '备注',
'Star' => '满意度',

View File

@ -16,7 +16,10 @@ return [
'Carno' => '车牌号码',
'Model' => '车型',
'Color' => '颜色',
'Inscom' => '保险类型',
'Cardid' => '身份证号',
'Frameno' => '车架号',
'Instype' => '保险类型',
'Inscom' => '保险公司',
'Insdate' => '保险日期',
'Tags' => '标签',
'Description' => '备注',

View File

@ -196,19 +196,19 @@
</div>
<div class="col-sm-3 col-xs-6">
<div class="sm-st clearfix">
<a href="{:url('user4s/visit',['status'=>0])}" class="btn-addtabs addtabs" data-title="回访单">
<span class="sm-st-icon st-blue"><i class="fa fa-comments"></i></span>
<a href="{:url('user4s/user/birthday')}" class="btn-addtabs addtabs" data-title="生日提醒">
<span class="sm-st-icon orange"><i class="fa fa-birthday-cake"></i></span>
<div class="sm-st-info">
<span>{$all_visit}</span>
{:__('全部回访单')}
<span>{$birthday_num}</span>
{:__('生日提醒')}
</div>
</a>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="sm-st clearfix">
<a href="{:url('user4s/user')}" class="btn-addtabs addtabs" data-title="回访单">
<span class="sm-st-icon st-green"><i class="fa fa-user"></i></span>
<a href="{:url('user4s/user')}" class="btn-addtabs addtabs" data-title="客户档案">
<span class="sm-st-icon pink"><i class="fa fa-money"></i></span>
<div class="sm-st-info">
<span>{$sumprice|round=###,2}</span>
{:__('充值总金额')}

View File

@ -1,35 +1,14 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<input class="form-control" name="row[update]" type="hidden" value="{$update}">
<input class="form-control" name="row[to]" type="hidden" value="{$to}">
<input id="c-row" class="form-control" name="row[row]" type="hidden" value=2>
<div class="panel panel-default panel-intro">
<div class="panel-heading">
<div class="panel-lead"><em>导入参数</em></div>
<div class="panel-lead"><em>导入客户档案</em></div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-3">{:__('Table')}:</label>
<div class="col-xs-12 col-sm-8" id="selectable">
{empty name="table"} {:Form::select('row[table]', $tableList, $table, [])}
<!--
<div class="alert alert-warning-light" style="margin-bottom:0;">导入按钮设置示例
</br>
eg:
<code>
&lt;a href="javascript:;" data-table="admin_log"
data-toggle="importguide"
class="btn btn-success {:$auth->check('import/log/add')?'':'hide'}"
title="{:__('导入向导')}"&gt; {:__('导入')}&lt;/a&gt;
</code>
<span id="helpBlock" class="help-block">可导入表请到该插件配置里设置</span>
</div> -->
{else /}
<input id="c-row" class="form-control" name="row[table]" type="hidden" value={$table}>{$table} {/empty}
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<!-- <div class="col-xs-12 col-sm-6 col-md-6">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-3">{:__('Row')}:</label>
<div class="col-xs-12 col-sm-8">
@ -37,19 +16,9 @@
<span id="helpBlock" class="help-block">该行的上一行,为匹配行</span>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-3">{:__('Head_type')}:</label>
<div class="col-xs-12 col-sm-8" id="selecthead_type">
{:Form::select('row[head_type]', ['comment'=>'注释', 'name'=>'字段名'], 'comment', ['data-rule'=>'required'])}
<span id="helpBlock" class="help-block"></span>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-3">{:__('path')}:</label>
@ -61,17 +30,6 @@
</div>
</div>
<div class="hidden">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('NewTable')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-newtable" class="form-control" name="row[newtable]" placeholder="不新建則留空,不需要前缀" type="text">
</div>
</div>
</div>
</div>
<div class="panel-body">

View File

@ -14,15 +14,9 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Genderdata')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('身份证号')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="genderdataList" item="vo"}
<label for="row[genderdata]-{$key}"><input id="row[genderdata]-{$key}" name="row[genderdata]" type="radio" value="{$key}" {in name="key" value="male"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
<input id="c-cardid" data-rule="required;IDcard;remote(user4s/user/check_cardid)" class="form-control" name="row[cardid]" type="text" value="">
</div>
</div>
<div class="form-group">
@ -31,6 +25,12 @@
<input id="c-carno" class="form-control" name="row[carno]" type="text" value="鲁Q">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('车架号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-frameno" data-rule="required;remote(user4s/user/check_frameno)" class="form-control" name="row[frameno]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Balance')}:</label>
<div class="col-xs-12 col-sm-8">
@ -43,12 +43,7 @@
<input id="c-integral" class="form-control" name="row[integral]" type="number" value="0">
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
<div class="col-xs-12 col-sm-8">
<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value=""></div>
</div>
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
<div class="col-xs-12 col-sm-8">
@ -80,16 +75,22 @@
<input id="c-color" class="form-control" name="row[color]" type="text" value="">
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Inscom')}:</label>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('保险类型')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-inscom" class="form-control" name="row[inscom]" type="text">
<input id="c-instype" data-rule="required" class="form-control" name="row[instype]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('保险公司')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-inscom" data-rule="required" class="form-control" name="row[inscom]" type="text" value="">
</div>
</div>
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Insdate')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-insdate" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[insdate]" type="text" value="{:date('Y-m-d')}">
<input id="c-insdate" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[insdate]" type="text" value="{:date('Y-m-d')}">
</div>
</div>
<div class="form-group">

View File

@ -14,54 +14,33 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Genderdata')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('身份证号')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="genderdataList" item="vo"}
<label for="row[genderdata]-{$key}"><input id="row[genderdata]-{$key}" name="row[genderdata]" type="radio" value="{$key}" {in name="key" value="$row.genderdata"}checked{/in} /> {$vo}</label>
{/foreach}
<input id="c-cardid" data-rule="required;IDcard;remote(user4s/user/check_cardid)" class="form-control" name="row[cardid]" type="text" value="{$row.cardid|htmlentities}">
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Carno')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-carno" class="form-control" name="row[carno]" type="text" value="{$row.carno|htmlentities}">
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Balance')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-balance" class="form-control" step="0.01" name="row[balance]" type="number" value="{$row.balance|htmlentities}">
<input id="c-carno" data-rule="required" class="form-control" name="row[carno]" type="text" value="{$row.carno|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Integral')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('车架号')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-integral" class="form-control" name="row[integral]" type="number" value="{$row.integral|htmlentities}">
<input id="c-frameno" data-rule="required;remote(user4s/user/check_frameno)" class="form-control" name="row[frameno]" type="text" value="{$row.frameno|htmlentities}">
</div>
</div>
</div> -->
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
<div class="col-xs-12 col-sm-8">
<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value="{$row.city|htmlentities}"></div>
</div>
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-category_id" data-rule="required" data-source="user4s/category/selectpage" data-params='{"custom[type]":"user4s_user"}' class="form-control selectpage" name="row[category_id]" type="text" value="{$row.category_id|htmlentities}">
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Level_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-level_id" data-rule="required" data-source="user4s/level/selectpage" data-field="name" data-format-item="{name} ({price}元)" class="form-control selectpage" name="row[level_id]" type="text" value="{$row.level_id|htmlentities}">
</div>
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Buydate')}:</label>
<div class="col-xs-12 col-sm-8">
@ -82,15 +61,21 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Inscom')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('保险类型')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-inscom" class="form-control" name="row[inscom]" type="text" value="{$row.inscom|htmlentities}">
<input id="c-instype" data-rule="required" class="form-control" name="row[instype]" type="text" value="{$row.instype|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('保险公司')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-inscom" data-rule="required" class="form-control" name="row[inscom]" type="text" value="{$row.inscom|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Insdate')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-insdate" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[insdate]" type="text" value="{$row.insdate}">
<input id="c-insdate" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[insdate]" type="text" value="{$row.insdate}">
</div>
</div>
<!-- <div class="form-group">

View File

@ -2,7 +2,7 @@
<div class="panel-heading">
{:build_heading(null,FALSE)}
<div class="panel-lead"><em>回访记录</em>本回访单的回访记录</div>
<div class="panel-lead"><em>保险临期</em>近期保险临期的用户</div>
</div>

View File

@ -22,14 +22,15 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user4s/user/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('user4s/user/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="user4s/user/excel" class="btn btn-info btn-excel btn-dialog {:$auth->check('user4s/user/excel')?'':'hide'}" title="{:__('Excel导入')}" ><i class="fa fa-file-excel-o"></i> {:__('Excel导入')}</a>
<div class="dropdown btn-group {:$auth->check('user4s/user/multi')?'':'hide'}">
<!-- <div class="dropdown btn-group {:$auth->check('user4s/user/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>
</div> -->
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('user4s/user/recyclebin')?'':'hide'}" href="user4s/user/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
</div>

View File

@ -17,10 +17,16 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-2">保险类型:</label>
<label class="control-label col-xs-4 col-sm-2">保险公司:</label>
<div class="col-xs-6 col-sm-8">
<label class="control-label">{$row.inscom|htmlentities}</label>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-2">保险类型:</label>
<div class="col-xs-6 col-sm-8">
<label class="control-label">{$row.instype|htmlentities}</label>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4 col-sm-2">购买时间:</label>
@ -37,24 +43,30 @@
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[star]">
{foreach name="all_star" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
<option value="{$key}" {in name="key" value="5"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('续保保险类型')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('续保保险公司')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-inscom" class="form-control" name="row[inscom]" type="text" value="{$row.inscom|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('续保保险类型')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-instype" class="form-control" name="row[instype]" type="text" value="{$row.instype|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('续保保险时间')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('续保保险开始日期')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-insdate" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[insdate]" type="text" value="{$now}">
<span id="helpBlock" class="help-block">本次续保的保险开始时间,方便下次提醒。</span>
<span id="helpBlock" class="help-block text-warning" style="color: #f39c12;">本次续保的保险开始日期,下次将从本日期的下一年的当月当日开始提醒。</span>
</div>
</div>
<div class="form-group">

View File

@ -604,4 +604,97 @@ class Backend extends Controller
//刷新Token
$this->request->token();
}
/**
* 根据身份证号获取信息
* @param $idcard 18位身份证号码
* @return string birthday 出生日期格式yyyy-mm-dd
* @return bool iscard 是否为合法的身份证号码
* @return int flag 0标示成年1标示未成年
* @return int age 年龄
*/
public function checkcardid($IDCard)
{
$result['iscard'] = false;
$result['flag'] = ''; //0标示成年1标示未成年
$result['tdate'] = ''; //生日格式如2012-11-15
if(empty($IDCard)){
$result['iscard'] = false;
return $result;
}
if ($this->isIDCard($IDCard) == false) {
$result['iscard'] = false;
return $result;
}
if (!preg_match("/^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$/", $IDCard)) {
$result['iscard'] = false;
return $result;
} else {
$tyear = intval(substr($IDCard, 6, 4));
$tmonth = intval(substr($IDCard, 10, 2));
$tday = intval(substr($IDCard, 12, 2));
if ($tyear > date("Y") || $tyear < (date("Y") - 100)) {
$flag = 0;
} elseif ($tmonth < 0 || $tmonth > 12) {
$flag = 0;
} elseif ($tday < 0 || $tday > 31) {
$flag = 0;
} else {
$tdate = $tyear . "-" . $tmonth . "-" . $tday;
if ((time() - mktime(0, 0, 0, $tmonth, $tday, $tyear)) > 18 * 365 * 24 * 60 * 60) {
$flag = 0;
} else {
$flag = 1;
}
}
}
$sexint = (int) substr($IDCard, 16, 1);
if (empty($IDCard)) return null;
# 获得出生年月日的时间戳
$date = strtotime(substr($IDCard, 6, 8));
# 获得今日的时间戳
$today = strtotime('today');
# 得到两个日期相差的大体年数
$diff = floor(($today - $date) / 86400 / 365);
# strtotime加上这个年数后得到那日的时间戳后与今日的时间戳相比
$age = strtotime(substr($IDCard, 6, 8) . ' +' . $diff . 'years') > $today ? ($diff + 1) : $diff;
$result['age'] = $age;
$result['iscard'] = true; //0未知错误1身份证格式错误2无错误
$result['isAdult'] = $flag; //0标示成年1标示未成年
$result['birthday'] = $tdate; //生日日期
$result['sex'] = $sexint % 2 === 0 ? 'female' : 'male'; //male=男,female=女
return $result;
}
/**
* 判断字符串是否是身份证号
*/
public function isIDCard($IDCard)
{
if(empty($IDCard)){
return false;
}
# 转化为大写如出现x
$IDCard = strtoupper($IDCard);
# 加权因子
$wi = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
$ai = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
# 按顺序循环处理前17位
$sigma = 0;
# 提取前17位的其中一位并将变量类型转为实数
for ($i = 0; $i < 17; $i++) {
$b = (int)$IDCard{$i};
# 提取相应的加权因子
$w = $wi[$i];
# 把从身份证号码中提取的一位数字和加权因子相乘,并累加
$sigma += $b * $w;
}
# 计算序号
$sIDCard = $sigma % 11;
# 按照序号从校验码串中提取相应的字符。
$check_IDCard = $ai[$sIDCard];
if ($IDCard{17} == $check_IDCard) {
return true;
} else {
return false;
}
}
}

View File

@ -74,6 +74,11 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
'user4s/visit?status=0': [Config.index_data.visit, 'red', 'badge']
});
}
if (Config.index_data.birthday_num > 0) {
top.window.Backend.api.sidebar({
'user4s/user/birthday': [Config.index_data.birthday_num, 'orange', 'badge']
});
}
// if (Config.index_data.all_visit > 0) {
// top.window.Backend.api.sidebar({
// 'user4s/visit': [Config.index_data.all_visit, 'teal', 'label']

View File

@ -92,7 +92,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
$("#import").addClass("disabled");
// $("#createtable").hide();
// $("#updatetable").hide();
if ($("#c-row").val() && $("#selecthead_type select").val() && $("#selectable select").val() && $("#c-rowpath").val()) {
if ($("#c-row").val() && $("#c-rowpath").val()) {
Toastr.success('开始预览结果');
// $("#submit").trigger("click");
@ -121,10 +121,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
});
html += "</tr>"
html += "<tr>"
$.each(columns, function(i, item) {
if (item.class != "success") html += "<td><select id=setop class='form-control' name=row[set][" + i + "]><option class=>请选择</option>" + select + "</select></td>"
else html += "<td class=success></td>"
});
// $.each(columns, function(i, item) {
// if (item.class != "success") html += "<td><select id=setop class='form-control' name=row[set][" + i + "]><option class=>请选择</option>" + select + "</select></td>"
// else html += "<td class=success></td>"
// });
html += "</tr>"
$.each(xlsdata, function(i, item) {
html += "<tr>"
@ -144,14 +144,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
}
}
$("#selectable select").on("change", function() {
$("#c-newtable").val('')
reset()
})
$("#c-newtable").on("change", function() {
$("#selectable select").val("");
reset()
})
// $("#selectable select").on("change", function() {
// $("#c-newtable").val('')
// reset()
// })
// $("#c-newtable").on("change", function() {
// $("#selectable select").val("");
// reset()
// })
$("#c-row").on("change", function() {
reset()
})

View File

@ -33,15 +33,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
//{field: 'user4s_id', title: __('User4s_id'),operate: false},
//{field: 'admin_id', title: __('Admin_id'),operate: false},
{field: 'user.name', title: __('会员姓名'), operate: 'LIKE'},
{field: 'user.name', title: __('会员电话'), operate: 'LIKE',visible: false},
{field: 'inscom', title: __('Inscom'), operate: 'LIKE',editable:true},
{ field: 'user.name', title: __('会员电话'), operate: 'LIKE', visible: false },
{ field: 'inscom', title: __('Inscom'), operate: 'LIKE', editable: true },
{field: 'instype', title: __('Instype'), operate: 'LIKE',editable:true},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{field: 'description', title: __('Description'), operate: 'LIKE',editable:true},
{field: 'star_f', title: __('Star'),operate:false},
{ field: 'createtime_f', title: __('Createtime'), operate: false },
{field: 'createtime', title: __('Createtime'),datetimeFormat:'YYYY-MM-DD', operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false,visible: false},
{ field: 'createtime_f', title: __('续保时间'), operate: false },
{field: 'createtime', title: __('续保时间'),datetimeFormat:'YYYY-MM-DD', operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false,visible: false},
{field: 'admin.id', title: __('Admin.id'),operate: false,visible: false},
{field: 'admin.username', title: __('操作员'), operate: false},
{field: 'admin.nickname', title: __('操作员'), operate: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}

View File

@ -58,7 +58,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
{field: 'id', title: __('会员ID'), operate:false},
{ field: 'name', title: __('Name'), operate: 'LIKE',editable:true },
{ field: 'tel', title: __('Tel'), operate: 'LIKE' ,editable:true},
{ field: 'genderdata', title: __('Genderdata'), operate: false,searchList: { "male": __('Genderdata male'), "female": __('Genderdata female') }, formatter: Table.api.formatter.normal },
{ field: 'cardid', title: __('身份证号'), operate: '=',visible:false },
{ field: 'frameno', title: __('车架号'), operate: '=',visible:false},
// {
// field: 'category_id', title: __('Category_id'), searchList: $.getJSON("user4s/category/searchlist"), formatter: function (value, row, index) {
// return row['category']['name'];
@ -75,21 +76,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
{ field: 'integral', title: __('Integral'), operate: false },
//{field: 'city', title: __('City'), operate: 'LIKE'},
{ field: 'buydate', title: __('Buydate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{ field: 'carno', title: __('Carno'), operate: 'LIKE' ,editable:true},
{ field: 'model', title: __('Model'), operate: 'LIKE' ,editable:true},
{ field: 'carno', title: __('Carno'), operate: false ,editable:true},
{ field: 'model', title: __('Model'), operate: false ,editable:true},
{ field: 'color', title: __('Color'), operate: false ,editable:true},
//{field: 'inscom', title: __('Inscom'), operate: 'LIKE'},
{ field: 'inscom', title: __('保险公司'), operate: false, visible: false },
{field: 'instype', title: __('保险类型'), operate: false,visible:false},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
//{field: 'tags', title: __('Tags'), operate: 'LIKE', formatter: Table.api.formatter.flag},
//{field: 'description', title: __('Description'), operate:false},
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
field: 'admin_id', title: __('Admin_id'), operate: false,visible:false, formatter: function (value, row, index) {
return row['fuzheren'];
}
},
//{ field: 'createtime', title: __('Createtime'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{ field: 'status', title: __('Status'), operate: '=',searchList: { "0": __('Status 0'), "1": __('Status 1') }, formatter: Table.api.formatter.status },
{ field: 'status', title: __('Status'), operate: false,searchList: { "0": __('Status 0'), "1": __('Status 1') }, formatter: Table.api.formatter.status },
//{ field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate },
{
@ -326,7 +328,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
{ field: 'carno', title: __('Carno'), operate: 'LIKE' },
{ field: 'model', title: __('Model'), operate: false },
{ field: 'color', title: __('Color'), operate: false },
{field: 'inscom', title: __('Inscom'), operate: 'LIKE'},
{ field: 'inscom', title: __('Inscom'), operate: 'LIKE' },
{field: 'instype', title: __('Instype'), operate: 'LIKE'},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
@ -374,6 +378,169 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
renewal: function () {
Controller.api.bindevent();
},
birthday: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user4s/user/birthday' + location.search,
table: 'user4s_user',
}
});
var table = $("#table");
//当表格数据加载完成时
table.on('load-success.bs.table', function (e, data) {
//这里可以获取从服务端获取的JSON数据
console.log(data);
//这里我们手动设置底部的值
$("#start_date").text(data.extend.start_date);
});
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
//maintainSelected: true,
columns: [
[
{ checkbox: true },
//{field: 'id', title: __('Id'), operate:false},
{ field: 'name', title: __('Name'), operate: 'LIKE' },
{ field: 'tel', title: __('Tel'), operate: 'LIKE' },
{ field: 'birthday', title: __('生日'), operate: false},
{ field: 'cardid', title: __('Cardid'), operate: false },
{ field: 'buydate', title: __('Buydate'), operate: false},
{ field: 'carno', title: __('Carno'), operate: 'LIKE' },
{ field: 'model', title: __('Model'), operate: false },
{ field: 'color', title: __('Color'), operate: false },
{ field: 'inscom', title: __('Inscom'), operate: 'LIKE' },
{field: 'instype', title: __('Instype'), operate: 'LIKE'},
{ field: 'insdate', title: __('Insdate'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{
field: 'admin_id', title: __('Admin_id'), operate: false, formatter: function (value, row, index) {
return row['fuzheren'];
}
},
// {
// field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
// buttons: [
// {
// name: 'renewal',
// text: __('续保'),
// title: __('续保'),
// classname: 'btn btn-xs btn-danger btn-dialog',
// icon: 'fa fa-dashboard',
// url: 'user4s/user/renewal',
// extend: 'data-area=\'["1000px","800px"]\'',
// callback: function (data) {
// Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
// },
// visible: function (row) {
// //返回true时按钮显示,返回false隐藏
// return true;
// }
// },
// {
// name: 'inslog',
// text: __('续保记录'),
// title: __('续保记录'),
// classname: 'btn btn-xs btn-warning btn-dialog',
// icon: 'fa fa-calendar-check-o',
// url: 'user4s/inslog/index?user4s_id={id}',
// extend: 'data-area=\'["1000px","800px"]\'',
// },
// ],
// formatter: Table.api.formatter.operate
// }
]
],
});
// 为表格绑定事件
Table.api.bindevent(table);
},
excel: function() {
function reset() {
$("#step").val(0);
$("#import").addClass("disabled");
if ($("#c-row").val() && $("#selecthead_type select").val() && $("#selectable select").val() && $("#c-rowpath").val()) {
Toastr.success('开始预览结果');
// $("#submit").trigger("click");
Fast.api.ajax({
url: 'import/log/preview',
data: $("form[role=form]").serialize(),
dataType: 'json',
}, function(data) {
console.log(data)
let columns = data.field
let xlsdata = data.data
let tableField = data.fieldArr
var select = ""
if (xlsdata.length) {
$("#step").val(1);
$("#import").removeClass("disabled");
// Toastr.success("与狼");
}
$.each(tableField, function(i, item) {
select += "<option class=>" + i + "</option>"
});
html = "<tr>"
$.each(columns, function(i, item) {
html += "<th class=" + item.class + ">" + item.field + "</th>"
});
html += "</tr>"
html += "<tr>"
$.each(columns, function(i, item) {
if (item.class != "success") html += "<td><select id=setop class='form-control' name=row[set][" + i + "]><option class=>请选择</option>" + select + "</select></td>"
else html += "<td class=success></td>"
});
html += "</tr>"
$.each(xlsdata, function(i, item) {
html += "<tr>"
$.each(columns, function(i, f) {
html += "<td class=" + f.class + ">" + item[f.field] + "</td>"
});
html += "</tr>"
});
$("#tableset").html(html)
}, function() {
return false;
});
}
}
$("#selectable select").on("change", function() {
$("#c-newtable").val('')
reset()
})
$("#c-newtable").on("change", function() {
$("#selectable select").val("");
reset()
})
$("#c-row").on("change", function() {
reset()
})
$("#c-rowpath").on("change", function() {
reset()
})
$("#selecthead_type select").on("change", function() {
reset()
})
$("#import").on("click", function() {
$("#submit").trigger("click");
})
Controller.api.bindevent();
},
api: {
bindevent: function (table) {
Form.api.bindevent($("form[role=form]"));