新功能更新 fix #1 fix #2 fix #3 fix #4 fix #5
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
孟凡懂 2022-07-09 04:16:14 +08:00
parent efc681ba9f
commit ebc7f2be88
13 changed files with 1358 additions and 5079 deletions

View File

@ -11,6 +11,9 @@ use app\common\controller\Backend;
use app\common\model\Attachment;
use fast\Date;
use think\Db;
use think\Config;
use car\Sms;
/**
* 控制台
@ -29,8 +32,35 @@ class Dashboard extends Backend
try {
\think\Db::execute("SET @@sql_mode='';");
} catch (\Exception $e) {
}
$user_ids=[1,2];
// $list = User::where('id', 'in', $user_ids)->select();
// $list = collection($list)->toarray();
// $list = array_column($list, null, 'id');
// var_dump($list);
// $sms = new Sms(['userid' => 5838, 'account' => '盛世鑫鼎比亚迪', 'password' => '123456']);
// $prefix = Config::get('database.prefix');
// $fieldArr = [];
// $table = $prefix . 'user4s_user';
// $database = Config::get('database.database');
// $pk = Db::getTableInfo($table, 'pk');
// $list = db()->query(
// "SELECT COLUMN_NAME,COLUMN_COMMENT,COLUMN_TYPE,IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?",
// [$table, $database]
// );
// foreach ($list as $k => $v) {
// if ($v['COLUMN_NAME'] !== $pk) {
// $fieldArr[$v['COLUMN_COMMENT']] = $v; //['COLUMN_NAME']
// }
// }
// var_dump($fieldArr);
//$sms->sendsms('15264925507','测试短信啊');
//$sms->getStatus();
// print_r($sms->send($user_ids,'【比亚迪汽车】如果搜[姓名]-将返回[联系方式]-要对数[余额]-进行[积分]-找且[性别]-要[车牌号码],退订回T'));
// $sms->getStatus();
$column = [];
$starttime = Date::unixtime('day', -10);
$endtime = Date::unixtime('day', 0, 'end');
@ -49,13 +79,13 @@ class Dashboard extends Backend
$this->assignconfig('column', array_keys($userlist));
$this->assignconfig('userdata', array_values($userlist));
//var_dump(Log::getlastsql());
$joinlist = Log::where('state','=','0')
$joinlist = Log::where('state', '=', '0')
->where('createtime', 'between time', [$starttime, $endtime])
->where('end','exp',' > start')
->where('end', 'exp', ' > start')
->field('createtime, SUM(end-start) AS price, DATE_FORMAT(FROM_UNIXTIME(createtime), "%Y-%m-%d") AS join_date')
->group('join_date')
->select();
// for ($time = $starttime; $time <= $endtime;) {
// $column[] = date("Y-m-d", $time);
// $time += 86400;
@ -68,31 +98,40 @@ class Dashboard extends Backend
//保险临期
$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)]]
);
$ins_end = User::where($ins_where)->count();
$ins_end = User::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);
}
})->count();
$visit_where = array(
'visittime'=>['<=',Date::unixtime('day', 0,'end')]
'visittime' => ['<=', Date::unixtime('day', 0, 'end')]
);
$visit = Visit::where($visit_where)->where('status',0)->count();
$visit = Visit::where($visit_where)->where('status', 0)->count();
//今日生日
$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(),
'todayprice' => Log::where('state','=','0')->whereTime('createtime', 'today')->where('end','exp',' > start')->sum('end-start'),
'sumprice' =>Log::where('state','=','0')->where('end','exp',' > start')->sum('end-start'),
'totalvipuser' => User::where('level_id', '>', '1')->count(),
'todayprice' => Log::where('state', '=', '0')->whereTime('createtime', 'today')->where('end', 'exp', ' > start')->sum('end-start'),
'sumprice' => Log::where('state', '=', '0')->where('end', 'exp', ' > start')->sum('end-start'),
'totaladmin' => Admin::count(),
'totalcategory' => \app\common\model\Category::count(),
'todayusersignup' => User::whereTime('createtime', 'today')->count(),
'todayusertovip' => Levellog::whereTime('createtime', 'today')->where('end','exp',' > start')->count(),
'todayusertovip' => Levellog::whereTime('createtime', 'today')->where('end', 'exp', ' > start')->count(),
'day7user' => User::whereTime('createtime', '-7 days')->count(),
'day7price' => Log::where('state','=','0')->whereTime('createtime', '-7 days')->where('end','exp',' > start')->sum('end-start'),
'day7price' => Log::where('state', '=', '0')->whereTime('createtime', '-7 days')->where('end', 'exp', ' > start')->sum('end-start'),
'day3user' => User::whereTime('createtime', '-3 days')->count(),
'day3price' => Log::where('state','=','0')->whereTime('createtime', '-3 days')->where('end','exp',' > start')->sum('end-start'),
'day3price' => Log::where('state', '=', '0')->whereTime('createtime', '-3 days')->where('end', 'exp', ' > start')->sum('end-start'),
// 'dbtablenums' => count($dbTableList),
// 'dbsize' => array_sum(array_map(function ($item) {
// return $item['Data_length'] + $item['Index_length'];
@ -105,12 +144,11 @@ class Dashboard extends Backend
'attachmentsize' => Attachment::sum('filesize'),
'picturenums' => Attachment::where('mimetype', 'like', 'image/%')->count(),
'picturesize' => Attachment::where('mimetype', 'like', 'image/%')->sum('filesize'),
];
];
$this->assignconfig('index_data', $index_data);
$this->view->assign($index_data);
return $this->view->fetch();
}
}

View File

@ -4,6 +4,15 @@ namespace app\admin\controller\user4s;
use app\common\controller\Backend;
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 PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style;
/**
* 续保记录
*
@ -69,11 +78,114 @@ class Inslog extends Backend
$item->createtime_f = date('Y-m-d',$item->createtime);
}
$result = array("total" => $list->total(), "rows" => $list->items());
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_data'=>date('Y-m-d',strtotime('-1 month')),'end_data'=>date('Y-m-d')]);
return json($result);
}
return $this->view->fetch();
}
/**
* 对Spreadsheet方法封装锐庆
* @param array $arr 该数组必须为键值对,键是表格单元,值是单元格的值
* @param array $data 该数组如果为一维数组,则填写一行,如果为二维数组,则多行数据
* @param string $name 下载Excel的文件名可忽略
* @param string $type 选择文件类型如果不填写默认下载为xlsx格式如果任意填写数值为xls格式
* @param int $with 设置sheet默认列宽
*/
public function downloadExcel(array $arr, array $data, $name = "", $type = "Xlsx")
{
//文件名处置
if (empty($name)) {
$name = date("Y-m-d H:i:s") . "_" . rand(1000, 9999);
} else {
$name = $name . "_" . date("Y-m-d H:i:s");
}
//内容设置
$preadsheet = new Spreadsheet();
$sheet = $preadsheet->getActiveSheet();
foreach ($arr as $k => $v) {
$sheet->setCellValue($k, $v);
}
$sheet->fromArray($data, null, "A2");
//样式设置
$sheet->getDefaultColumnDimension()->setWidth(20);
//设置下载与后缀
if ($type == "Xlsx") {
header("Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
$suffix = "xlsx";
} else {
header("Content-Type:application/vnd.ms-excel");
$type = "Xls";
$suffix = "xls";
}
header("Content-Disposition:attachment;filename=$name.$suffix");
header("Cache-Control:max-age=0"); //缓存控制
$writer = IOFactory::createWriter($preadsheet, $type);
$writer->save("php://output"); //数据流
}
public function excel()
{
set_time_limit(0);
$all_star = array(
1 => '★',
2 => '★★',
3 => '★★★',
4 => '★★★★',
5 => '★★★★★',
);
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
$start_date = $this->request->get("start_date", '');
$end_date = $this->request->get("end_date", '');
if(empty($start_date) || empty($end_date)){
$this->error('请选择要导出的日期范围');
}
$ins_where = array('inslog.insdate' => ['between', [date('Y-m-d', strtotime($start_date)), date('Y-m-d', strtotime($end_date))]]);
$data = array();
$head = array(
'A1' => '编号',
'B1' => '姓名',
'C1' => '联系方式',
'D1' => '身份证',
'E1' => '生日',
'F1' => '购车日期',
'G1' => '车牌号码',
'H1' => '车架号',
'I1' => '车型',
'J1' => '颜色',
'K1' => '续保保险类型',
'L1' => '续保保险公司',
'M1' => '续保日期',
'N1' => '满意度',
'O1' => '备注',
);
$list = $this->model->with(['user'])->where($ins_where)->select();
//var_dump($this->model->getLastSql());exit();
$logs = collection($list)->toArray();
foreach ($logs as $index => $item) {
//var_dump($item);
$data[] = array(
$item['id'],
$item['user']['name'],
' '.$item['user']['tel'],
' '.$item['user']['cardid'],
date('Y年m月d日',strtotime($item['user']['birthday'])),
date('Y年m月d日',strtotime($item['user']['buydate'])),
$item['user']['carno'],
$item['user']['frameno'],
$item['user']['model'],
$item['user']['color'],
$item['instype'],
$item['inscom'],
date('Y年m月d日',strtotime($item['insdate'])),
$all_star[$item['star']],
$item['description'],
);
}
return $this->downloadExcel($head,$data);
}
}

View File

@ -18,6 +18,10 @@ use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xls;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use fast\Pinyin;
use think\Loader;
use think\Model;
use car\Sms;
use fast\Date;
/**
* 用户档案
@ -299,50 +303,7 @@ class User extends Backend
}
$this->error('车架号重复');
}
/**
* 删除
*/
// public function del($ids = "")
// {
// if (!$this->request->isPost()) {
// $this->error(__("Invalid parameters"));
// }
// $ids = $ids ? $ids : $this->request->post("ids");
// if ($ids) {
// if($ids == 1 || in_array('1',$ids)){
// $this->error(__('默认等级(ID:1)禁止删除,请重新操作!'));
// }
// $pk = $this->model->getPk();
// $adminIds = $this->getDataLimitAdminIds();
// if (is_array($adminIds)) {
// $this->model->where($this->dataLimitField, 'in', $adminIds);
// }
// $list = $this->model->where($pk, 'in', $ids)->select();
// $count = 0;
// $this->model->startTrans();
// try {
// foreach ($list as $k => $v) {
// $count += $v->delete();
// //删除用户记录
// //$log_res = $this->model->afterlog($this->auth->id,$this->model,$v->id,'',false);
// }
// $this->model->commit();
// } catch (PDOException $e) {
// $this->model->rollback();
// $this->error($e->getMessage());
// } catch (Exception $e) {
// $this->model->rollback();
// $this->error($e->getMessage());
// }
// if ($count) {
// $this->success();
// } else {
// $this->error(__('No rows were deleted'));
// }
// }
// $this->error(__('Parameter %s can not be empty', 'ids'));
// }
/**
* 充值
*/
@ -438,36 +399,65 @@ class User extends Backend
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
$start_date = strtotime("-1 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)]]
);
$ins_where = array();
$start = strtotime("-1 year");
$end = strtotime("+2 month", $start);
$start_date = $this->request->get("start_date", '');
$end_date = $this->request->get("end_date", '');
if(!empty($start_date) && !empty($end_date)){
$start = strtotime(date('Y-').$start_date);
$end = strtotime(date('Y-').$end_date);
for ($y=1; $y<=30; $y++) {
$start_dates = strtotime("-".$y." year",$start);
$end_dates = strtotime("-".$y." year", $end);
$ins_where[] = array('insdate' => ['between', [date('Y-m-d', $start_dates), date('Y-m-d', $end_dates)]]);
}
}
if ($this->request->isAjax()) {
// $start_date = $this->request->post("start_date", '');
// $end_date = $this->request->post("end_date", '');
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['category', 'level'])
->where($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);
->where(function ($query) use($ins_where) {
//todo:测试闭包传递参数
if(!empty($ins_where)){
foreach($ins_where as $item){
$query->whereOr($item);
}
}else{
for ($y=1; $y<=30; $y++) {
$start = strtotime("-".$y." year");
$end = strtotime("+2 month", $start);
$ins_where = array(
'insdate' => ['between', [date('Y-m-d', $start), date('Y-m-d', $end)]]
);
$query->whereOr($ins_where);
}
}
})
->order($sort, $order)
->paginate($limit);
//var_dump($this->model->getLastSql());
foreach ($list as $row) {
foreach ($list as &$row) {
$row->getRelation('category')->visible(['name']);
$row->getRelation('level')->visible(['name']);
$tip_start = Date::unixtime('year', 0,'start');
$tip_end = Date::unixtime('year', 0,'end');
//var_dump($tip_start,$tip_end);
if($row->instiptime >=$tip_start && $row->instiptime <=$tip_end){
$row->instip = 1;
}else{
$row->instip = 0;
}
}
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d', $start_date), 'end_date' => date('m-d', $end_date)]);
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d', $start), 'end_date' => date('m-d', $end)],'sql'=>$this->model->getLastSql());
return json($result);
}
@ -533,7 +523,60 @@ class User extends Backend
$this->view->assign('row', $row);
return $this->view->fetch();
}
/**
* 续保提醒
*/
public function instip($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
//$all_level = $this->level_model->where('status', 1)->column('id,name');
if ($this->request->isPost()) {
//记录用户续保提醒
$row->instiptime = time();
$row->save();
$this->success('记录提醒状态成功!', url('user4s/user/expireins'),array('tiptime'=>date('Y-m-d H:i:s')));
}
$this->view->assign('row', $row);
return $this->view->fetch();
}
/**
* 取消续保提醒
*/
public function instipno($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
//$all_level = $this->level_model->where('status', 1)->column('id,name');
if ($this->request->isPost()) {
//记录用户续保提醒
$row->instiptime = 0;
$row->save();
$this->success('取消提醒状态成功', url('user4s/user/expireins'),array('tiptime'=>date('Y-m-d H:i:s')));
}
$this->view->assign('row', $row);
return $this->view->fetch();
}
/**
* 过生日用户列表
*/
@ -545,9 +588,29 @@ class User extends Backend
$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())");
$birthday = $this->request->get("birthday", '');
if(!empty($birthday)){
//halt($birthday);
$search_date = '2022-'.$birthday;
}else{
$filter = $this->request->get("filter", '');
$op = $this->request->get("op", '', 'trim');
$filter = (array)json_decode($filter, true);
$op = (array)json_decode($op, true);
if(!empty($filter['birthday'])){
$search_date = '2022-'.$filter['birthday'];
$_GET['filter']= '{}';
$_GET['op']= '{}';
}else{
$search_date = date('Y-m-d');
}
}
$birthday_users = Db::query("select id from car_user4s_user where MONTH(birthday) = MONTH('".$search_date."') and DAY(birthday) = DAY('".$search_date."')");
if(empty($birthday_users)){
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]);
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d',strtotime($search_date))]);
return json($result);
}else{
foreach ($birthday_users as $key => $value) {
@ -555,27 +618,262 @@ class User extends Backend
}
}
if(empty($birthday_user_ids)){
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d')]);
$result = array("total" => 0, "rows" => [], "extend" => ['start_date' => date('m-d',strtotime($search_date))]);
return json($result);
}
//var_dump($birthday_user_ids);
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
//var_dump($filter,$op);
//var_dump($birthday_user_ids);
list($where, $sort, $order, $offset, $limit) = $this->buildparamsu('{}','{}');
$list = $this->model
->with(['category', 'level'])
->where($where)
->where('user.id', 'in', $birthday_user_ids)
->where('user.birthday', '<>', '0000-00-00')
->order($sort, $order)
->paginate($limit);
//var_dump($this->model->getLastSql());
//echo($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')]);
$result = array("total" => $list->total(), "rows" => $list->items(), "extend" => ['start_date' => date('m-d',strtotime($search_date))]);
return json($result);
}
return $this->view->fetch();
}
protected function buildparamsu($filter,$op,$searchfields = null, $relationSearch = null)
{
$searchfields = is_null($searchfields) ? $this->searchFields : $searchfields;
$relationSearch = is_null($relationSearch) ? $this->relationSearch : $relationSearch;
$search = $this->request->get("search", '');
// $filter = $this->request->get("filter", '');
// $op = $this->request->get("op", '', 'trim');
$sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id');
$order = $this->request->get("order", "DESC");
$offset = $this->request->get("offset/d", 0);
$limit = $this->request->get("limit/d", 999999);
//新增自动计算页码
$page = $limit ? intval($offset / $limit) + 1 : 1;
if ($this->request->has("page")) {
$page = $this->request->get("page/d", 1);
}
$this->request->get([config('paginate.var_page') => $page]);
$filter = (array)json_decode($filter, true);
$op = (array)json_decode($op, true);
$filter = $filter ? $filter : [];
$where = [];
$alias = [];
$bind = [];
$name = '';
$aliasName = '';
if (!empty($this->model) && $this->relationSearch) {
$name = $this->model->getTable();
$alias[$name] = Loader::parseName(basename(str_replace('\\', '/', get_class($this->model))));
$aliasName = $alias[$name] . '.';
}
$sortArr = explode(',', $sort);
foreach ($sortArr as $index => & $item) {
$item = stripos($item, ".") === false ? $aliasName . trim($item) : $item;
}
unset($item);
$sort = implode(',', $sortArr);
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
$where[] = [$aliasName . $this->dataLimitField, 'in', $adminIds];
}
if ($search) {
$searcharr = is_array($searchfields) ? $searchfields : explode(',', $searchfields);
foreach ($searcharr as $k => &$v) {
$v = stripos($v, ".") === false ? $aliasName . $v : $v;
}
unset($v);
$where[] = [implode("|", $searcharr), "LIKE", "%{$search}%"];
}
$index = 0;
foreach ($filter as $k => $v) {
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
continue;
}
$sym = isset($op[$k]) ? $op[$k] : '=';
if (stripos($k, ".") === false) {
$k = $aliasName . $k;
}
$v = !is_array($v) ? trim($v) : $v;
$sym = strtoupper(isset($op[$k]) ? $op[$k] : $sym);
//null和空字符串特殊处理
if (!is_array($v)) {
if (in_array(strtoupper($v), ['NULL', 'NOT NULL'])) {
$sym = strtoupper($v);
}
if (in_array($v, ['""', "''"])) {
$v = '';
$sym = '=';
}
}
switch ($sym) {
case '=':
case '<>':
$where[] = [$k, $sym, (string)$v];
break;
case 'LIKE':
case 'NOT LIKE':
case 'LIKE %...%':
case 'NOT LIKE %...%':
$where[] = [$k, trim(str_replace('%...%', '', $sym)), "%{$v}%"];
break;
case '>':
case '>=':
case '<':
case '<=':
$where[] = [$k, $sym, intval($v)];
break;
case 'FINDIN':
case 'FINDINSET':
case 'FIND_IN_SET':
$v = is_array($v) ? $v : explode(',', str_replace(' ', ',', $v));
$findArr = array_values($v);
foreach ($findArr as $idx => $item) {
$bindName = "item_" . $index . "_" . $idx;
$bind[$bindName] = $item;
$where[] = "FIND_IN_SET(:{$bindName}, `" . str_replace('.', '`.`', $k) . "`)";
}
break;
case 'IN':
case 'IN(...)':
case 'NOT IN':
case 'NOT IN(...)':
$where[] = [$k, str_replace('(...)', '', $sym), is_array($v) ? $v : explode(',', $v)];
break;
case 'BETWEEN':
case 'NOT BETWEEN':
$arr = array_slice(explode(',', $v), 0, 2);
if (stripos($v, ',') === false || !array_filter($arr, function($v){
return $v != '' && $v !== false && $v !== null;
})) {
continue 2;
}
//当出现一边为空时改变操作符
if ($arr[0] === '') {
$sym = $sym == 'BETWEEN' ? '<=' : '>';
$arr = $arr[1];
} elseif ($arr[1] === '') {
$sym = $sym == 'BETWEEN' ? '>=' : '<';
$arr = $arr[0];
}
$where[] = [$k, $sym, $arr];
break;
case 'RANGE':
case 'NOT RANGE':
$v = str_replace(' - ', ',', $v);
$arr = array_slice(explode(',', $v), 0, 2);
if (stripos($v, ',') === false || !array_filter($arr)) {
continue 2;
}
//当出现一边为空时改变操作符
if ($arr[0] === '') {
$sym = $sym == 'RANGE' ? '<=' : '>';
$arr = $arr[1];
} elseif ($arr[1] === '') {
$sym = $sym == 'RANGE' ? '>=' : '<';
$arr = $arr[0];
}
$tableArr = explode('.', $k);
if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
//修复关联模型下时间无法搜索的BUG
$relation = Loader::parseName($tableArr[0], 1, false);
$alias[$this->model->$relation()->getTable()] = $tableArr[0];
}
$where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' TIME', $arr];
break;
case 'NULL':
case 'IS NULL':
case 'NOT NULL':
case 'IS NOT NULL':
$where[] = [$k, strtolower(str_replace('IS ', '', $sym))];
break;
default:
break;
}
$index++;
}
if (!empty($this->model)) {
$this->model->alias($alias);
}
$model = $this->model;
$where = function ($query) use ($where, $alias, $bind, &$model) {
if (!empty($model)) {
$model->alias($alias);
$model->bind($bind);
}
foreach ($where as $k => $v) {
if (is_array($v)) {
call_user_func_array([$query, 'where'], $v);
} else {
$query->where($v);
}
}
};
return [$where, $sort, $order, $offset, $limit, $page, $alias, $bind];
}
/**
* sms
*/
public function sms($ids = null)
{
if ($this->request->isPost()) {
$this->token();
}
if(stripos($ids, ',') >= 1){
$ids = explode(',',$ids);
}else{
$ids = array($ids);
}
$row = $this->model->where('id','in',$ids)->select();
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
//短信info
$sms_config = array(
'userid' => Config::get('site.sms_userid'),
'account' => Config::get('site.sms_user'),
'password' => Config::get('site.sms_passwd'),
);
$sms = new Sms($sms_config);
$sms_info = $sms->getOverage();
if(!$sms_info['status']){
$this->error('短信平台配置错误,请检查配置!'.$sms_info['message']);
}
$this->view->assign("sms_info", $sms_info);
if ($this->request->isPost()) {
$content = $this->request->post("sms_content");
if ($content && is_array($ids)) {
//var_dump($ids);
//halt($content);
$send_status = $sms->send($ids,$content);
if($send_status['code'] == 0){
$this->error(__('发送失败!错误提示:'.$send_status['msg'], ''),'',$send_status);
}else{
$this->success('发送成功!共计:'.$send_status['total'].'个,发送成功:'.$send_status['success'].'个','',$send_status);
}
//var_dump($send_status);
}
$this->error(__('短信内容为空', ''));
}
$this->view->assign("row", collection($row)->toarray());
$this->view->assign("user_num", count($row));
return $this->view->fetch();
}
}

View File

@ -11,6 +11,38 @@
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user4s/inslog/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/inslog/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<div class="form-group" style="position: unset;position: unset;display: inline-block;
margin-bottom: 0;
font-weight: normal;
text-align: center;
vertical-align: middle;
touch-action: manipulation;
width: 240px;">
<!-- <label for="insdate" class="control-label col-xs-4">保险日期</label> -->
<div class="col-xs-12" style="padding-left: 0px;">
<div class="row row-between">
<div class="col-xs-6" style="position: relative;padding-left: 15px;padding-right: 5px;">
<input type="text" class="form-control datetimepicker" name="insdate" value="" placeholder="保险日期" id="start_date" data-index="10" data-date-format="YYYY-MM-DD" ,data-date-use-current="true" autocomplete="off">
</div>
<div class="col-xs-6" style="position: relative;padding-right: 5px;padding-left: 5px;">
<input type="text" class="form-control datetimepicker" name="insdate" value="" placeholder="保险日期" id="end_date" data-index="10" data-date-format="YYYY-MM-DD" ,data-date-use-current="true" autocomplete="off">
</div>
</div>
</div>
</div>
<!-- <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
<i class="fa fa-calendar"></i>
<span class="extend">
统计时间:
</span>
</a> -->
<a href="javascript:;" class="btn btn-primary btn-excel" style="font-size:14px;"><i class="fa fa-cog"></i> {:__('导出')}</a>
<!-- <div class="dropdown btn-group {:$auth->check('user4s/inslog/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>

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>
@ -12,12 +12,75 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
<!-- <div id="customformtpl" style="float: right;">
<form action="" class="form-commonsearch form-horizontal nice-validator n-default n-bootstrap" novalidate="novalidate">
<div style="/* margin-bottom:10px; */background:#ffffff;/* padding:5px 5px; */">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-6">生日查询:</label>
<input type="hidden" class="operate" data-name="birthday" value="=" id="N149023577339">
<div class="col-xs-12 col-sm-6" style="position: relative;">
<input id="c-birthday" class="form-control datetimepicker" data-date-format="MM-DD" data-use-current="true" name="birthday" type="text" value="07-03">
</div>
</div>
</div>
<div class="col-xs-6 col-sm-6 col-md-6">
<div class="form-group">
<div class="col-xs-4">
<input type="submit" class="btn btn-success btn-block" value="提交">
</div>
<div class="col-xs-4">
<input type="reset" class="btn btn-primary btn-block" value="重置">
</div>
</div>
</div>
</div>
</div>
</form>
</div> -->
<div class="input-group date" id="datetimepicker1" style="display: -webkit-inline-box;
margin-bottom: 0;
font-weight: normal;
text-align: center;
vertical-align: middle;
touch-action: manipulation;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 6px 12px;
font-size: 13px;
line-height: 1.42857143;
border-radius: 3px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;">
<span class="input-group-addon" style="font-size:14px;color:dodgerblue;">
<i class="fa fa-calendar"></i>
<span class="extend">
查询生日
</span>
</span>
<input id="m-birthday" class="form-control" data-date-format="MM-DD" data-use-current="true" name="birthday" type="text" value="{:date('m-d')}" style="display: block;width: 60px;float: right;">
</div>
<!-- <input id="m-birthday" class="form-control" data-date-format="MM-DD" data-use-current="true" name="birthday" type="text" value="07-03" style="display: block;width: 80px;float: right;margin-left: 0.2em;"> -->
<a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;display: none;">
<i class="fa fa-calendar"></i>
<span class="extend">
生日:<span id="start_date"></span>
</span>
</a>
<a href="javascript:;" class="btn btn-warning btn-sms btn-disabled disabled {:$auth->check('user4s/user/sms')?'':'hide'}" title="{:__('发送短信')}" data-area=["80%","80%"]><i class="fa fa-commenting-o"></i> {:__('发送短信')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('user4s/user/edit')}"
@ -30,3 +93,34 @@
</div>
</div>
</div>
<script id="customformtpl" type="text/html">
<form action="" class="form-commonsearch form-horizontal">
<div style="background:#ffffff;padding:5px 5px 0px 0px;">
<div class="row">
<div class="col-xs-4 col-sm-3 col-md-2">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-4" style="line-height: 20px;">{:__('生日查询')}:</label>
<input type="hidden" class="operate" data-name="birthday" value="="/>
<div class="col-xs-12 col-sm-8">
<input id="c-birthday" data-rule="required" class="form-control datetimepicker" data-date-format="MM-DD" data-use-current="true" name="birthday" type="text" value="{:date('m-d')}">
</div>
</div>
</div>
<div class="col-xs-4 col-sm-3 col-md-2">
<div class="form-group">
<div class="col-xs-4">
<input type="submit" class="btn btn-success btn-block" value="提交"/>
</div>
<div class="col-xs-4">
<!-- <input type="reset" class="btn btn-primary btn-block" value="重置"/> -->
</div>
<div class="col-xs-4"></div>
</div>
</div>
</div>
</div>
</form>
</script>

View File

@ -12,13 +12,51 @@
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
<i class="fa fa-calendar"></i>
<span class="extend">
统计时间:
</span>
</a>
<div class="form-group" style="position: unset;position: unset;display: inline-block;
margin-bottom: 0;
font-weight: normal;
text-align: center;
vertical-align: middle;
touch-action: manipulation;
width: 200px;">
<!-- <label for="insdate" class="control-label col-xs-4">保险日期</label> -->
<div class="col-xs-12" style="padding-left: 0px;">
<div class="row row-between">
<div class="col-xs-6" style="position: relative;padding-left: 15px;padding-right: 5px;">
<input type="text" class="form-control datetimepicker" name="insdate" value="" placeholder="保险日期" id="start_date" data-index="10" data-date-format="MM-DD" ,data-date-use-current="true" autocomplete="off">
</div>
<div class="col-xs-6" style="position: relative;padding-right: 5px;padding-left: 5px;">
<input type="text" class="form-control datetimepicker" name="insdate" value="" placeholder="保险日期" id="end_date" data-index="10" data-date-format="MM-DD" ,data-date-use-current="true" autocomplete="off">
</div>
</div>
</div>
</div>
<!-- <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
<i class="fa fa-calendar"></i>
<span class="extend">
统计时间:<span id="start_date"></span>
<span id="end_date"></span>
</span>
</a>
</a> -->
<a href="javascript:;" class="btn btn-warning btn-sms btn-disabled disabled {:$auth->check('user4s/user/sms')?'':'hide'}" title="{:__('发送短信')}" data-area=["80%","80%"]><i class="fa fa-commenting-o"></i> {:__('发送短信')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('user4s/user/edit')}"

View File

@ -24,6 +24,8 @@
<a href="user4s/import/index" class="btn btn-info btn-excel btn-dialog {:$auth->check('user4s/user/excel')?'':'hide'}" title="{:__('Excel导入')}" data-area=["80%","90%"]><i class="fa fa-file-excel-o"></i> {:__('Excel导入')}</a>
<a href="javascript:;" class="btn btn-warning btn-sms btn-disabled disabled {:$auth->check('user4s/user/sms')?'':'hide'}" title="{:__('发送短信')}" data-area=["80%","80%"]><i class="fa fa-commenting-o"></i> {:__('发送短信')}</a>
<!-- <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">

View File

@ -20,7 +20,7 @@
<!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('user4s/visit/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/visit/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-warning btn-sms btn-disabled disabled {:$auth->check('user4s/user/sms')?'':'hide'}" title="{:__('发送短信')}" data-area=["80%","80%"]><i class="fa fa-commenting-o"></i> {:__('发送短信')}</a>
<!-- <div class="dropdown btn-group {:$auth->check('user4s/visit/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">

View File

@ -4,7 +4,7 @@ return array (
'name' => '会员管理',
'beian' => '',
'cdnurl' => '',
'version' => '1.0.4',
'version' => '1.0.16',
'timezone' => 'Asia/Shanghai',
'forbiddenip' => '',
'languages' =>
@ -39,4 +39,9 @@ return array (
'category2' => '分类二',
),
'integral_rate' => '1',
'sms_userid' => '5838',
'sms_user' => '盛世鑫鼎比亚迪',
'sms_passwd' => '123456',
'birthday_sms' => '【比亚迪汽车】亲爱的[姓氏][称呼]祝您生日快乐平安健康美好常伴。退订回T',
'expireins_sms' => '【比亚迪汽车】亲爱的[姓氏][称呼],您的车辆保险购买日期为[保险日期]即将到期。咨询续保请联系我们。退订回T',
);

5243
car4s.sql

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
del_url: 'user4s/inslog/del',
multi_url: 'user4s/inslog/multi',
import_url: 'user4s/inslog/import',
table: 'user4s_inslog',
excel_url:'user4s/inslog/excel',
table: 'user4s_inslog' + location.search,
}
});
@ -32,20 +33,25 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
//{field: 'id', title: __('Id'),operate: false},
//{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: 'user.name', title: __('会员姓名'), operate: 'LIKE' },
{ field: 'user.tel', title: __('联系方式'), operate: 'LIKE' },
{ field: 'user.tel', title: __('联系方式'), operate: 'LIKE' },
{ field: 'user.buydate', title: __('User.Buydate'), operate: false, addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false },
{ field: 'user.carno', title: __('User.Carno'), operate: false },
{ field: 'user.frameno', title: __('车架号'), operate: false,visible:false},
{ field: 'user.model', title: __('User.Model'), operate: false,visible:false},
{ field: 'user.color', title: __('User.Color'), operate: false,visible:false },
//{ 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: __('续保时间'), operate: 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.nickname', title: __('操作员'), operate: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
],
@ -67,7 +73,42 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
return params;
},
});
table.on('load-success.bs.table', function (e, data) {
$("#start_date").val(data.extend.start_data);
$("#end_date").val(data.extend.end_data);
});
require(['bootstrap-datetimepicker'], function () {
var options = {
format: 'YYYY-MM-DD',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-history',
clear: 'fa fa-trash',
close: 'fa fa-remove'
},
showTodayButton: true,
showClose: true
};
$('#start_date').parent().css('position', 'relative');
$("#start_date").datetimepicker(options);
$('#end_date').parent().css('position', 'relative');
$("#end_date").datetimepicker(options);
});
$(document).on("click", ".btn-excel", function () {
var start_date = $("#start_date").val();
var end_date = $("#end_date").val();
var url = 'inslog/excel'+'?start_date='+start_date+'&end_date='+end_date;
//Fast.api.open(url, '发送短信');
window.open(url,'_self');
//Fast.api.open(url,title ,options);
});
// 为表格绑定事件
Table.api.bindevent(table);
},

View File

@ -11,6 +11,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
del_url: 'user4s/user/del',
multi_url: 'user4s/user/multi',
import_url: 'user4s/user/import',
sms_url: 'user4s/user/sms',
table: 'user4s_user',
}
});
@ -132,19 +133,57 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
});
// 为表格绑定事件
Table.api.bindevent(table);
//当表格数据加载完成时
// //点击跳转
// $(document).on("click", ".jump", function () {
// var url = $(this).attr('data-url');
// window.open(url);
// });
$(document).on("click", ".btn-sms", function () {
var ids = Table.api.selectedids(table);
var title = $(this).data("original-title") || $(this).attr("title");
var url = $.fn.bootstrapTable.defaults.extend.sms_url+'?ids='+ids.join(',');
var options = {
shadeclose: false,
area: $(this).data("data-area"),
title: title,
callback:function(data){
console.log(data);
}
};
//Fast.api.open(url, '发送短信');
Fast.api.open(url,title ,options);
});
// table.on('Table.api.events.operate', function (e, data) {
// //这里可以获取从服务端获取的JSON数据
// console.log(data);
// console.log(e);
// });
// 为表格绑定事件
Table.api.bindevent(table);
},
sms: function(){
Form.api.bindevent($("form[role=form]"), function (data, ret) {
console.log('OK', data);
if (data.success == data.total) {
Fast.api.close(data);//这里是重点
return true;
} else {
$("#sms_status").html('');
data.status.forEach((item, index, arr) => {
var html = $("#sms_status").html();
if (item.code == 0) {
html = html + '<span class="label label-warning" style="margin-right: 0.2em;">'+item.name+'('+item.msg+')</span>';
} else {
html = html + '<span class="label label-info" style="margin-right: 0.2em;">' + item.name + '(' + item.msg + ')</span>';
}
$("#sms_status").html(html);
return false;
})
}
}, function (data, ret) {
console.log('error',data);
Fast.api.close(data);
});
},
recyclebin: function () {
// 初始化表格参数配置
@ -206,7 +245,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
$('#c-balance').on('change', function () {
var balance = $(this).val();
@ -277,6 +315,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
Table.api.init({
extend: {
index_url: 'user4s/user/expireins' + location.search,
sms_url: 'user4s/user/sms',
table: 'user4s_user',
}
});
@ -287,8 +326,43 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
//这里可以获取从服务端获取的JSON数据
console.log(data);
//这里我们手动设置底部的值
$("#start_date").text(data.extend.start_date);
$("#end_date").text(data.extend.end_date);
$("#start_date").val(data.extend.start_date);
$("#end_date").val(data.extend.end_date);
});
require(['bootstrap-datetimepicker'], function () {
var options = {
format: 'MM-DD',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-history',
clear: 'fa fa-trash',
close: 'fa fa-remove'
},
showTodayButton: true,
showClose: true
};
var dchage = function (e) {
var start_date = $("#start_date").val();
var end_date = $("#end_date").val();
table.bootstrapTable('refresh', { query: { start_date: start_date, end_date: end_date } });
};
$('#start_date').parent().css('position', 'relative');
$("#start_date").datetimepicker(options).on('dp.change', function (e) {
var start_date = $("#start_date").val();
var end_date = $("#end_date").val();
table.bootstrapTable('refresh', { query: { start_date: start_date,end_date:end_date } });
});
$('#end_date').parent().css('position', 'relative');
$("#end_date").datetimepicker(options).on('dp.change', function (e) {
var start_date = $("#start_date").val();
var end_date = $("#end_date").val();
table.bootstrapTable('refresh', { query: { start_date: start_date,end_date:end_date } });
});
});
// 初始化表格
table.bootstrapTable({
@ -315,15 +389,67 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
{ 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: 'insdate', title: __('Insdate'), operate: false, 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: 'instip',
text: __('提醒'),
title: __('提醒'),
classname: 'btn btn-xs btn-success btn-ajax',
icon: 'fa fa-bell-o',
url: 'user4s/user/instip?ids={ids}',
confirm:"确认本次续保时间内已提醒过用户了吗?",
extend: 'data-area=\'["1000px","800px"]\'',
success: function (data,ret) {
//Layer.alert(ret.msg, { title: "保险临期提醒" });
table.bootstrapTable('refresh');
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
if (row.instip == 0) {
return true;
} else {
return false;
}
}
},
{
name: 'instip',
text: __('取消提醒'),
title: __('取消提醒'),
classname: 'btn btn-xs btn-success btn-ajax',
icon: 'fa fa-bell-slash-o',
url: 'user4s/user/instipno?ids={ids}',
confirm:"取消本次续保时间内的提醒状态吗?",
extend: 'data-area=\'["1000px","800px"]\'',
success: function (data,ret) {
//Layer.alert(ret.msg, { title: "保险临期提醒" });
table.bootstrapTable('refresh');
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
if (row.instip == 0) {
return false;
} else {
return true;
}
}
},
{
name: 'renewal',
text: __('续保'),
@ -356,6 +482,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
],
});
$(document).on("click", ".btn-sms", function () {
var ids = Table.api.selectedids(table);
var title = $(this).data("original-title") || $(this).attr("title");
var url = $.fn.bootstrapTable.defaults.extend.sms_url+'?ids='+ids.join(',');
var options = {
shadeclose: false,
area: $(this).data("data-area"),
title: title,
callback:function(data){
console.log(data);
}
};
//Fast.api.open(url, '发送短信');
Fast.api.open(url,title ,options);
});
// 为表格绑定事件
Table.api.bindevent(table);
},
@ -367,6 +509,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
Table.api.init({
extend: {
index_url: 'user4s/user/birthday' + location.search,
sms_url: 'user4s/user/sms',
table: 'user4s_user',
}
});
@ -378,6 +521,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
console.log(data);
//这里我们手动设置底部的值
$("#start_date").text(data.extend.start_date);
$("#m-birthday").val(data.extend.start_date);
//$("#birthday").datetimepicker();
require(['bootstrap-datetimepicker'], function () {
var options = {
format: 'YYYY-MM-DD HH:mm:ss',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-history',
clear: 'fa fa-trash',
close: 'fa fa-remove'
},
showTodayButton: true,
showClose: true
};
$('#m-birthday').parent().css('position', 'relative');
$("#m-birthday").datetimepicker(options).on('dp.change', function (e) {
var birthday = $("#m-birthday").val();
//console.log(e);
//console.log(birthday);
table.bootstrapTable('refresh', {query: {birthday: birthday}});
//$(this, document).trigger("changed");
});
// $('.search',$("form[role=form]")).parent().css('position', 'relative');
// $('.search',$("form[role=form]")).datetimepicker(options);
});
});
// 初始化表格
table.bootstrapTable({
@ -387,23 +562,25 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
fixedColumns: true,
fixedRightNumber: 1,
showToggle: false,
//maintainSelected: true,
// searchFormVisible: true,
// searchFormTemplate: 'customformtpl',
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: 'birthday', title: __('生日'), operate: false, addclass: 'datetimepicker',data: 'data-date-format="MM-DD",data-date-use-current="true"', autocomplete: false},
{ field: 'cardid', title: __('Cardid'), operate: 'LIKE' },
{ 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: 'inscom', title: __('Inscom'), operate: false },
{field: 'instype', title: __('Instype'), operate: false},
{ field: 'insdate', title: __('Insdate'), operate: false, 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'];
@ -444,6 +621,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
],
});
$(document).on("click", ".btn-sms", function () {
var ids = Table.api.selectedids(table);
var title = $(this).data("original-title") || $(this).attr("title");
var url = $.fn.bootstrapTable.defaults.extend.sms_url+'?ids='+ids.join(',');
var options = {
shadeclose: false,
area: $(this).data("data-area"),
title: title,
callback:function(data){
console.log(data);
}
};
//Fast.api.open(url, '发送短信');
Fast.api.open(url,title ,options);
});
// 为表格绑定事件
Table.api.bindevent(table);
},
@ -529,33 +722,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
bindevent: function (table) {
Form.api.bindevent($("form[role=form]"));
},
events: {
operate: {
'click .btn-delone': function (e, value, row, index) {
e.stopPropagation();
e.preventDefault();
var that = this;
var top = $(that).offset().top - $(window).scrollTop();
var left = $(that).offset().left - $(window).scrollLeft() - 260;
if (top + 154 > $(window).height()) {
top = top - 154;
}
if ($(window).width() < 480) {
top = left = undefined;
}
Layer.confirm(
__('22222222222222222?'),
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
function (index) {
var table = $(that).closest('table');
var options = table.bootstrapTable('getOptions');
Table.api.multi("del", row[options.pk], table, that);
Layer.close(index);
}
);
}
}
}
// events: {
// operate: {
// 'click .btn-delone': function (e, value, row, index) {
// e.stopPropagation();
// e.preventDefault();
// var that = this;
// var top = $(that).offset().top - $(window).scrollTop();
// var left = $(that).offset().left - $(window).scrollLeft() - 260;
// if (top + 154 > $(window).height()) {
// top = top - 154;
// }
// if ($(window).width() < 480) {
// top = left = undefined;
// }
// Layer.confirm(
// __('22222222222222222?'),
// {icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true, btn: [__('OK'), __('Cancel')]},
// function (index) {
// var table = $(that).closest('table');
// var options = table.bootstrapTable('getOptions');
// Table.api.multi("del", row[options.pk], table, that);
// Layer.close(index);
// }
// );
// }
// }
// }
}
};
return Controller;

View File

@ -6,6 +6,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
Table.api.init({
extend: {
index_url: 'user4s/visit/index' + location.search,
sms_url: 'user4s/user/sms',
add_url: 'user4s/visit/add',
edit_url: 'user4s/visit/edit',
del_url: 'user4s/visit/del',
@ -212,6 +213,56 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function
}
Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
});
$(document).on("click", ".btn-sms", function () {
var select_data = Table.api.selecteddata(table);
if (select_data == '') {
return false;
} else {
var ids = [];
select_data.forEach((item, index, arr) => {
ids.push(item.user4s_id);
})
}
//var ids = Table.api.selectedids(table);
var title = $(this).data("original-title") || $(this).attr("title");
var url = $.fn.bootstrapTable.defaults.extend.sms_url+'?ids='+ids.join(',');
var options = {
shadeclose: false,
area: $(this).data("data-area"),
title: title,
callback:function(data){
console.log(data);
}
};
//Fast.api.open(url, '发送短信');
Fast.api.open(url,title ,options);
});
},
sms: function(){
Form.api.bindevent($("form[role=form]"), function (data, ret) {
console.log('OK', data);
if (data.success == data.total) {
Fast.api.close(data);//这里是重点
return true;
} else {
$("#sms_status").html('');
data.status.forEach((item, index, arr) => {
var html = $("#sms_status").html();
if (item.code == 0) {
html = html + '<span class="label label-warning" style="margin-right: 0.2em;">'+item.name+'('+item.msg+')</span>';
} else {
html = html + '<span class="label label-info" style="margin-right: 0.2em;">' + item.name + '(' + item.msg + ')</span>';
}
$("#sms_status").html(html);
return false;
})
}
}, function (data, ret) {
console.log('error',data);
Fast.api.close(data);
});
},
recyclebin: function () {
// 初始化表格参数配置