回访单
This commit is contained in:
parent
8da31ba095
commit
862710f9ee
@ -3,6 +3,10 @@
|
||||
namespace app\admin\controller\user4s;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use Exception;
|
||||
use think\Db;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 回访单
|
||||
@ -22,7 +26,8 @@ class Visit extends Backend
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\common\model\user4s\Visit;
|
||||
|
||||
$this->user_model = new \app\common\model\user4s\User();
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
|
||||
@ -49,16 +54,14 @@ class Visit extends Backend
|
||||
return $this->selectpage();
|
||||
}
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
//var_dump($this->request->request());
|
||||
$list = $this->model
|
||||
->with(['visittype','user','admin'])
|
||||
->with(['visittype', 'user', 'admin'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
foreach ($list as $row) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
@ -67,5 +70,73 @@ class Visit extends Backend
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$user4s_id = $this->request->get("user4s_id/d");
|
||||
if ($user4s_id > 0) {
|
||||
$user4s=$this->user_model->get($user4s_id);
|
||||
//var_dump($user4s);
|
||||
if(isset($user4s->id)){
|
||||
$this->view->assign("user4s", $user4s);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::add();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
public function edit($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'));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,12 @@
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('User4s_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{if $user4s.id > 0}
|
||||
<input type="hidden" name="row[user4s_id]" value="{$user4s.id}">
|
||||
<input id="c-user4s_id" class="form-control disabled" type="text" value="{$user4s.name}" readonly>
|
||||
{else}
|
||||
<input id="c-user4s_id" data-rule="required" data-source="user4s/user/index" class="form-control selectpage" name="row[user4s_id]" type="text" value="">
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -15,7 +20,7 @@
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Visittime')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-visittime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[visittime]" type="text" value="{:date('Y-m-d H:i:s')}">
|
||||
<input id="c-visittime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[visittime]" type="text" value="{:date('Y-m-d')}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -3,19 +3,19 @@
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('User4s_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-user4s_id" data-rule="required" data-source="user4s/index" class="form-control selectpage" name="row[user4s_id]" type="text" value="{$row.user4s_id|htmlentities}">
|
||||
<input id="c-user4s_id" data-rule="required" data-source="user4s/user/index" class="form-control selectpage" name="row[user4s_id]" type="text" value="{$row.user4s_id|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Type_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-type_id" data-rule="required" data-source="type/index" class="form-control selectpage" name="row[type_id]" type="text" value="{$row.type_id|htmlentities}">
|
||||
<input id="c-type_id" data-rule="required" data-source="user4s/visittype/index" class="form-control selectpage" name="row[type_id]" type="text" value="{$row.type_id|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Visittime')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-visittime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[visittime]" type="text" value="{:$row.visittime?datetime($row.visittime):''}">
|
||||
<input id="c-visittime" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[visittime]" type="text" value="{:$row.visittime?datetime($row.visittime):''}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -1,5 +1,13 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-heading">
|
||||
{:build_heading(null,FALSE)}
|
||||
<ul class="nav nav-tabs" data-field="status">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li class="{:$Think.get.status === (string)$key || $key == 0 ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
@ -7,7 +15,7 @@
|
||||
<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-success btn-add {:$auth->check('user4s/visit/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add2 {:$auth->check('user4s/visit/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<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> -->
|
||||
|
||||
|
@ -25,13 +25,23 @@ class Visit extends Model
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'visittime_text'
|
||||
'visittime_text',
|
||||
'status_text',
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['0' => __('进行中'), '1' => __('已办结')];
|
||||
}
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
||||
$list = $this->getStatusList();
|
||||
return isset($list[$value]) ? $list[$value] : '';
|
||||
}
|
||||
|
||||
public function getVisittimeTextAttr($value, $data)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
columns: [
|
||||
[
|
||||
{ checkbox: true },
|
||||
//{field: 'id', title: __('Id'), operate:false},
|
||||
{field: 'id', title: __('会员ID'), operate:false},
|
||||
{ field: 'name', title: __('Name'), operate: 'LIKE' },
|
||||
{ field: 'tel', title: __('Tel'), operate: 'LIKE' },
|
||||
{ field: 'genderdata', title: __('Genderdata'), operate: false,searchList: { "male": __('Genderdata male'), "female": __('Genderdata female') }, formatter: Table.api.formatter.normal },
|
||||
@ -87,7 +87,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
return row['fuzheren'];
|
||||
}
|
||||
},
|
||||
//{ field: 'createtime', title: __('Createtime'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
|
||||
//{ 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 },
|
||||
|
||||
@ -96,7 +96,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
|
||||
buttons: [
|
||||
{
|
||||
name: 'push',
|
||||
name: 'recharge',
|
||||
text: __('充值消费'),
|
||||
title: __('充值消费'),
|
||||
classname: 'btn btn-xs btn-danger btn-dialog',
|
||||
@ -112,7 +112,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'push',
|
||||
name: 'rechargelog',
|
||||
text: __('消费记录'),
|
||||
title: __('消费记录'),
|
||||
classname: 'btn btn-xs btn-warning btn-dialog',
|
||||
@ -120,14 +120,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
url: 'user4s/log/index?user4s_id={id}',
|
||||
extend: 'data-area=\'["1000px","800px"]\'',
|
||||
},
|
||||
// {
|
||||
// name: 'push',
|
||||
// text: __('推送'),
|
||||
// title: __('推送'),
|
||||
// classname: 'btn btn-xs btn-warning btn-ajax',
|
||||
// icon: 'fa fa-paper-plane-o',
|
||||
// url: 'soft_order/push'
|
||||
// },
|
||||
{
|
||||
name: 'visit',
|
||||
text: __('回访单'),
|
||||
title: __('回访单'),
|
||||
classname: 'btn btn-xs btn-info btn-addtabs',
|
||||
icon: 'fa fa-comments-o',
|
||||
url: 'user4s/visit/index?user4s_id={id}',
|
||||
extend: 'data-area=\'["1000px","800px"]\'',
|
||||
},
|
||||
// {
|
||||
// name: 'addtabs',
|
||||
// text: __('日志'),
|
||||
|
@ -32,7 +32,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
//{ field: 'id', title: __('Id') },
|
||||
//{ field: 'type_id', title: __('Type_id') },
|
||||
{field: 'visittype.name', title: __('Type_id'), operate: 'LIKE'},
|
||||
//{ field: 'user4s_id', title: __('User4s_id') },
|
||||
{ field: 'user4s_id', title: __('会员ID'),visible:false},
|
||||
{ field: 'user.name', title: __('会员姓名'), operate: 'LIKE' },
|
||||
{field: 'user.carno', title: __('User.carno'), operate: 'LIKE'},
|
||||
//{ field: 'user.buydate', title: __('User.buydate'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
|
||||
@ -42,17 +42,96 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
//{ field: 'user.insdate', title: __('User.insdate'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
|
||||
//{ field: 'user.description', title: __('User.description'), operate: 'LIKE' },
|
||||
|
||||
{field: 'visittime', title: __('Visittime'), operate:'BETWEEN', addclass:'datetimepicker',data:'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'visittime', title: __('Visittime'), operate:'BETWEEN', addclass:'datetimepicker',data:'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete:false, formatter: Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
|
||||
//{field: 'admin.nickname', title: __('操作员'), operate: 'LIKE'},
|
||||
{ field: 'createtime', title: __('Createtime'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"', autocomplete: false, formatter: Table.api.formatter.datetime },
|
||||
{ field: 'createtime', title: __('Createtime'), operate: 'BETWEEN', addclass: 'datetimepicker',data: 'data-date-format="YYYY-MM-DD",data-date-use-current="true"',datetimeFormat:'YYYY-MM-DD', autocomplete: false, formatter: Table.api.formatter.datetime },
|
||||
{field: 'description', title: __('Description'), operate: 'LIKE'},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
{ field: 'status', title: __('Status'), operate: '=',searchList: { "0": __('进行中'), "1": __('已办结') }, formatter: Table.api.formatter.status },
|
||||
//{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
|
||||
buttons: [
|
||||
{
|
||||
name: 'recharge',
|
||||
text: __('回访记录'),
|
||||
title: __('回访记录'),
|
||||
classname: 'btn btn-xs btn-info btn-dialog',
|
||||
icon: 'fa fa-cny',
|
||||
url: 'user4s/user/recharge',
|
||||
extend: 'data-area=\'["1000px","800px"]\'',
|
||||
callback: function (data) {
|
||||
Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
|
||||
},
|
||||
visible: function (row) {
|
||||
//返回true时按钮显示,返回false隐藏
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'rechargelog',
|
||||
text: __('结单'),
|
||||
title: __('结单'),
|
||||
classname: 'btn btn-xs btn-danger btn-dialog',
|
||||
icon: 'fa fa-calendar-check-o',
|
||||
url: 'user4s/log/index?user4s_id={id}',
|
||||
extend: 'data-area=\'["1000px","800px"]\'',
|
||||
},
|
||||
// {
|
||||
// name: 'visit',
|
||||
// text: __('回访单'),
|
||||
// title: __('回访单'),
|
||||
// classname: 'btn btn-xs btn-info btn-dialog',
|
||||
// icon: 'fa fa-comments-o',
|
||||
// url: 'user4s/visit/index?user4s_id={id}',
|
||||
// extend: 'data-area=\'["1000px","800px"]\'',
|
||||
// },
|
||||
// {
|
||||
// name: 'addtabs',
|
||||
// text: __('日志'),
|
||||
// title: __('订单任务日志'),
|
||||
// classname: 'btn btn-xs btn-info btn-addtabs',
|
||||
// icon: 'fa fa-list-ol',
|
||||
// url: 'soft_log/?ids={row.id}&ref=addtabs'
|
||||
// }
|
||||
],
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
queryParams: function (params) {
|
||||
//这里可以追加搜索条件
|
||||
var filter = JSON.parse(params.filter);
|
||||
var op = JSON.parse(params.op);
|
||||
//这里可以动态赋值,比如从URL中获取admin_id的值,filter.admin_id=Fast.api.query('admin_id');
|
||||
filter.user4s_id = Fast.api.query('user4s_id');
|
||||
op.user4s_id = "=";
|
||||
if (filter.user4s_id == null || filter.user4s_id == "") {
|
||||
delete filter.user4s_id;
|
||||
delete op.user4s_id;
|
||||
}
|
||||
|
||||
params.filter = JSON.stringify(filter);
|
||||
params.op = JSON.stringify(op);
|
||||
console.log(params);
|
||||
return params;
|
||||
},
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
// 添加按钮事件
|
||||
$(document).on('click', '.btn-add2', function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
var user4s_id =Fast.api.query('user4s_id');
|
||||
var url = $.fn.bootstrapTable.defaults.extend.add_url;
|
||||
if(user4s_id !== ''){
|
||||
url = url + '?user4s_id=' + user4s_id;
|
||||
}
|
||||
if (url.indexOf("{ids}") !== -1) {
|
||||
url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
|
||||
}
|
||||
Fast.api.open(url, $(this).data("original-title") || $(this).attr("title") || __('Add'), $(this).data() || {});
|
||||
});
|
||||
},
|
||||
recyclebin: function () {
|
||||
// 初始化表格参数配置
|
||||
|
Loading…
Reference in New Issue
Block a user