创建版本
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Auth;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Form;
|
||||
use Gdoo\Model\Grid;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Services\CustomerService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class AccountReportController extends DefaultController
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
// 客户对账单
|
||||
public function indexAction()
|
||||
{
|
||||
$sdate = date('Y-01-01');
|
||||
$edate = date('Y-m-d');
|
||||
$search = search_form([
|
||||
'advanced' => 0,
|
||||
], [
|
||||
['form_type' => 'date2', 'name' => '日期', 'field' => 'date', 'value' => [$sdate, $edate], 'options' => []],
|
||||
['form_type' => 'dialog', 'name' => '客户', 'field' => 'customer_id', 'options' => [
|
||||
'url' => 'customer/customer/dialog', 'query' => ['multi'=>0]
|
||||
]],
|
||||
['form_type' => 'dialog', 'name' => '开票单位', 'field' => 'tax_id', 'options' => [
|
||||
'url' => 'customer/tax/dialog', 'query' => ['multi'=>0]
|
||||
]],
|
||||
], 'model');
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$fields = [];
|
||||
foreach($search['forms']['field'] as $i => $field) {
|
||||
$fields[$field] = $search['forms']['search'][$i];
|
||||
}
|
||||
|
||||
$start_dt = $fields['date'][0];
|
||||
$end_dt = $fields['date'][1];
|
||||
|
||||
$customer_id = (int)$fields['customer_id'];
|
||||
|
||||
$tax_id = $fields['tax_id'];
|
||||
if ($tax_id > 0) {
|
||||
$tax = DB::table('customer_tax')->find($tax_id);
|
||||
$customer_id = $tax['customer_id'];
|
||||
}
|
||||
$taxs = DB::table('customer_tax')->where('customer_id', $customer_id)->get();
|
||||
$tax_names = [];
|
||||
$tax_names2 = [];
|
||||
foreach($taxs as $tax) {
|
||||
$tax_names[$tax['code']] = $tax['name'];
|
||||
$tax_names2[$tax['id']] = $tax['name'];
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
if ($start_dt && $end_dt && $customer_id) {
|
||||
|
||||
$json = collect();
|
||||
$one = [];
|
||||
|
||||
// 获取用友数据
|
||||
$res = plugin_sync_api('acclist/code/'.$taxs->implode('code', ',').'/start_dt/'.$start_dt.'/end_dt/'.$end_dt);
|
||||
if (count($res['data'])) {
|
||||
// 获取初期余额
|
||||
$one = array_shift($res['data']);
|
||||
foreach($res['data'] as $row) {
|
||||
if ($row['dgst'] == '合计') {
|
||||
continue;
|
||||
}
|
||||
$row['tax_name'] = $tax_names[$row['cdwcode']];
|
||||
$json->push($row);
|
||||
}
|
||||
}
|
||||
|
||||
$rows = CustomerService::getAccList($customer_id, $start_dt, $end_dt);
|
||||
$ye = (float)$one['ye'];
|
||||
foreach($rows as $row) {
|
||||
if ($row['dgst'] == '合计') {
|
||||
continue;
|
||||
}
|
||||
if ($row['dgst'] == '期初余额') {
|
||||
$row['ye'] = $row['ye'] + $ye;
|
||||
}
|
||||
$row['tax_name'] = $tax_names2[$row['tax_id']];
|
||||
$json->push($row);
|
||||
}
|
||||
|
||||
// 多字段排序
|
||||
$json = $json->multiSortBy(['orderNum' => 'asc', 'dDate' => 'asc', 'orderD' => 'asc']);
|
||||
|
||||
$ye = 0;
|
||||
$json->transform(function($row) use (&$ye) {
|
||||
if ($row['dgst'] == '期初余额') {
|
||||
$ye = $row['ye'];
|
||||
} else {
|
||||
$ye = $ye + $row['df'] - $row['jf'] - $row['bcsyfy'];
|
||||
}
|
||||
$row['ye'] = $ye;
|
||||
return $row;
|
||||
});
|
||||
|
||||
$json->push([
|
||||
'dgst' => '合计',
|
||||
'orderNum' => 3,
|
||||
'qtfy' => $json->sum('qtfy'),
|
||||
'xzfy' => $json->sum('xzfy'),
|
||||
'bcsyfy' => $json->sum('bcsyfy'),
|
||||
'jf' => $json->sum('jf'),
|
||||
'df' => $json->sum('df'),
|
||||
'sl' => $json->sum('sl'),
|
||||
'ye' => $ye,
|
||||
]);
|
||||
|
||||
$bills = DB::table('model_bill')->get()->keyBy('id');
|
||||
|
||||
foreach($json as $row) {
|
||||
|
||||
$bill = $bills[$row['srcMasterBillType']];
|
||||
$row['bill_name'] = $bill['name'];
|
||||
$row['url'] = $bill['uri'].'/show';
|
||||
$ret[] = $row;
|
||||
}
|
||||
|
||||
}
|
||||
return $this->json($ret, true);
|
||||
}
|
||||
$search['table'] = 'material_plan';
|
||||
return $this->display([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Session;
|
||||
use Request;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Index\Controllers\Controller;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* 经销商业务员登录专用接口
|
||||
*/
|
||||
public function salemanAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
if (empty($gets['username'])) {
|
||||
return $this->json('客户代码不能为空。');
|
||||
}
|
||||
|
||||
$user = User::where('username', $gets['username'])
|
||||
->where('status', 1)
|
||||
->where('group_id', 2)->first();
|
||||
|
||||
if ($user->id > 0) {
|
||||
Auth::login($user, true);
|
||||
Session::put('auth_totp', true);
|
||||
return $this->json('登录成功。', true);
|
||||
} else {
|
||||
return $this->json('登录失败,客户代码无效。');
|
||||
}
|
||||
}
|
||||
return $this->json('登录失败。');
|
||||
}
|
||||
|
||||
public function json($data, $status = false, $type = 'primary')
|
||||
{
|
||||
$json = [];
|
||||
$json['status'] = $status;
|
||||
$json['state'] = $status;
|
||||
$json['info'] = $type;
|
||||
$json['data'] = $data;
|
||||
return response()->json($json);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use Validator;
|
||||
use DB;
|
||||
|
||||
use Gdoo\Customer\Models\Business;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Index\Models\Attachment;
|
||||
|
||||
use Gdoo\Index\Services\NotificationService;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Gdoo\Index\Services\AttachmentService;
|
||||
|
||||
class BusinessController extends DefaultController
|
||||
{
|
||||
public $permission = ['index','salesman','store'];
|
||||
|
||||
// 商机列表
|
||||
public function indexAction()
|
||||
{
|
||||
// 筛选客户
|
||||
$filter = select::customer();
|
||||
$columns = [
|
||||
['text','customer_business.name','客户名称'],
|
||||
];
|
||||
if ($filter['role_type'] == 'salesman') {
|
||||
$columns[] = ['text','customer_business.address','客户地区'];
|
||||
$columns[] = ['text','customer_business.type','客户类型'];
|
||||
}
|
||||
|
||||
if ($filter['role_type'] == 'all') {
|
||||
$columns[] = ['text','user.name','创建者'];
|
||||
$columns[] = ['owner','customer_business.user_id','负责人'];
|
||||
$columns[] = ['text','customer_business.address','客户地区'];
|
||||
$columns[] = ['text','customer_business.type','客户类型'];
|
||||
}
|
||||
|
||||
$search = search_form([
|
||||
'status' => 1,
|
||||
'referer' => 1
|
||||
], $columns);
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
$model = Business::leftJoin('user', 'user.id', '=', 'customer_business.created_id')
|
||||
->select(['customer_business.*']);
|
||||
|
||||
$level = authorise();
|
||||
if ($level < 4) {
|
||||
$model->where('customer_business.user_id', Auth::id());
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($query['order'] && $query['srot']) {
|
||||
$model->orderBy($query['srot'], $query['order']);
|
||||
} else {
|
||||
$model->orderBy('customer_business.id', 'desc');
|
||||
}
|
||||
|
||||
$rows = $model->paginate($query['limit']);
|
||||
|
||||
if (Request::wantsJson()) {
|
||||
return $rows->toJson();
|
||||
}
|
||||
|
||||
$rows = $rows->appends($query);
|
||||
|
||||
return $this->display(array(
|
||||
'rows' => $rows,
|
||||
'search' => $search,
|
||||
));
|
||||
}
|
||||
|
||||
// 客户资料查看
|
||||
public function showAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$row = DB::table('customer_business')
|
||||
->leftJoin('user', 'user.id', '=', 'customer_business.user_id')
|
||||
->where('customer_business.id', $id)
|
||||
->first(['customer_business.*','user.name']);
|
||||
|
||||
// 返回json
|
||||
$row['address'] = str_replace("\n", " ", $row['address']);
|
||||
$attachments = AttachmentService::show($row['attachment']);
|
||||
$row['attachments'] = $attachments['main'];
|
||||
return response()->json($row);
|
||||
}
|
||||
|
||||
// 负责人列表
|
||||
public function salesmanAction()
|
||||
{
|
||||
if (Request::wantsJson()) {
|
||||
$users = User::leftJoin('role', 'role.id', '=', 'user.role_id')
|
||||
->where('role.name', 'salesman')
|
||||
->where('user.status', 1)
|
||||
->get(['user.id', 'user.username', 'user.name']);
|
||||
return $this->json($users);
|
||||
}
|
||||
}
|
||||
|
||||
// 储存商机
|
||||
public function storeAction()
|
||||
{
|
||||
if (Request::isJson()) {
|
||||
$gets = json_decode(Request::getContent(), true);
|
||||
} else {
|
||||
$gets = Request::all();
|
||||
}
|
||||
|
||||
$row = new Business;
|
||||
|
||||
$rules = [
|
||||
'source' => 'required',
|
||||
'user_id' => 'required',
|
||||
'name' => 'required',
|
||||
// 'attachment' => 'min:1|array|required',
|
||||
];
|
||||
|
||||
$v = Validator::make($gets, $rules, Business::$_messages);
|
||||
if ($v->fails()) {
|
||||
return $this->json($v->errors());
|
||||
}
|
||||
|
||||
// 地区
|
||||
if (is_array($gets['address'])) {
|
||||
$gets['address'] = join("\n", $gets['address']);
|
||||
}
|
||||
|
||||
// 保存base64图片数据
|
||||
// $gets['attachment'] = Attachment::base64($gets['attachment'], 'customer');
|
||||
|
||||
if (is_array($gets['attachment'])) {
|
||||
$gets['attachment'] = AttachmentService::base64($gets['attachment'], 'customer');
|
||||
} else {
|
||||
$gets['attachment'] = AttachmentService::files('image', 'customer');
|
||||
}
|
||||
|
||||
$row->fill($gets)->save();
|
||||
|
||||
$user = User::find($gets['user_id']);
|
||||
|
||||
NotificationService::sms([$gets['contacts_phone']], '感谢您对川南公司的关注', '负责您的业务人员是'.$user['name'].',电话'.$user['phone'].'。您可与其沟通或登陆www.cnnzfood.com');
|
||||
|
||||
return $this->json('恭喜你,操作成功。', true);
|
||||
}
|
||||
|
||||
// 删除商机
|
||||
public function destroyAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$id = Request::get('id');
|
||||
$rows = Business::whereIn('id', $id)->get();
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
AttachmentService::remove($row->attachment);
|
||||
$row->delete();
|
||||
}
|
||||
}
|
||||
return $this->success('index', '恭喜你,删除成功。');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Auth;
|
||||
use Paginator;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerComplaint;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\WorkflowController;
|
||||
|
||||
class ComplaintController extends WorkflowController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_complaint',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '显示',
|
||||
'action' => 'show',
|
||||
'display' => $this->access['show'],
|
||||
]];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerComplaint::$tabs;
|
||||
$header['bys'] = CustomerComplaint::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建促销
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int) Request::get('id');
|
||||
$header['action'] = $action;
|
||||
$header['code'] = 'customer_complaint';
|
||||
$header['id'] = $id;
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$form = Form::make($header);
|
||||
$row = $form['row'];
|
||||
$tpl = $action == 'print' ? 'print' : 'create';
|
||||
|
||||
if ($action == 'print') {
|
||||
$this->layout = 'layouts.print_'.$form['print_type'];
|
||||
}
|
||||
|
||||
return $this->display(['form' => $form], $tpl);
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function printAction()
|
||||
{
|
||||
return $this->createAction('print');
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单删除
|
||||
*/
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$id = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_complaint', 'ids' => $id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\Contact;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class ContactController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_contact',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order'])
|
||||
->orderBy('id', 'desc');
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
];
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Contact::$tabs;
|
||||
$header['bys'] = Contact::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_contact','id' => $id, 'action' => $action]);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_contact', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出层信息
|
||||
*/
|
||||
public function dialogAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_contact',
|
||||
]);
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table']);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户圈权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($query['region_id']) {
|
||||
$model->where('customer.region_id', $query['region_id']);
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
|
||||
$rows = $model->paginate($query['limit']);
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
$item['text'] = $item['name'];
|
||||
return $item;
|
||||
});
|
||||
return response()->json($items);
|
||||
}
|
||||
$query['form_id'] = $query['jqgrid'] == '' ? $query['id'] : $query['jqgrid'];
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerApply;
|
||||
use Gdoo\User\Models\User;
|
||||
|
||||
use Gdoo\Index\Controllers\WorkflowController;
|
||||
|
||||
class CustomerApplyController extends WorkflowController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_apply',
|
||||
'referer' => 1,
|
||||
'sort' => 'customer_apply.id',
|
||||
'order' => 'asc',
|
||||
'search' => ['by' => 'todo'],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '显示',
|
||||
'action' => 'show',
|
||||
'display' => $this->access['show'],
|
||||
]/*,[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]*/];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($query['by']) {
|
||||
if ($query['by'] == 'end') {
|
||||
$model->where('customer_apply.status', 1);
|
||||
} else {
|
||||
$model->where('customer_apply.status', '<>', 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_apply');
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
return $item;
|
||||
});
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '导出', 'icon' => 'fa-mail-reply', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerApply::$tabs;
|
||||
$header['bys'] = CustomerApply::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'create')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer_apply';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 审核
|
||||
public function auditAction()
|
||||
{
|
||||
return $this->createAction('audit');
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_apply', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerClass;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class CustomerClassController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$display = $this->access;
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_class',
|
||||
'referer' => 1,
|
||||
'search' => [],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $display['edit'],
|
||||
]];
|
||||
unset($cols['checkbox']);
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy('customer_class.code', 'asc');
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select'])
|
||||
->addSelect(DB::raw('parent_id'));
|
||||
|
||||
$items = $model->get()->toNested('name');
|
||||
$items = Grid::dataFilters($items, $header, function($item) {
|
||||
return $item;
|
||||
});
|
||||
return $this->json($items, true);
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除','icon' => 'fa-remove','action' => 'delete','display' => $display['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerClass::$tabs;
|
||||
$header['bys'] = CustomerClass::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_class', 'id' => $id]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form([], [
|
||||
['text','customer_class.name','名称'],
|
||||
['text','customer_class.code','编码'],
|
||||
['text','customer_class.id','ID'],
|
||||
]);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = CustomerClass::orderBy('code', 'asc');
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
// $model->where('end', 1);
|
||||
$rows = $model->get();
|
||||
return response()->json(['data' => $rows]);
|
||||
}
|
||||
return $this->render([
|
||||
'search' => $search
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$id = Request::get('id');
|
||||
$id = array_filter((array)$id);
|
||||
if (empty($id)) {
|
||||
return $this->json('最少选择一行记录。');
|
||||
}
|
||||
$has = CustomerClass::whereIn('parent_id', $id)->count();
|
||||
if ($has) {
|
||||
return $this->json('存在子节点不允许删除。');
|
||||
}
|
||||
CustomerClass::whereIn('id', $id)->delete();
|
||||
return $this->json('删除成功。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\User\Models\User;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class CustomerController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer',
|
||||
'referer' => 1,
|
||||
'sort' => 'customer.id',
|
||||
'order' => 'asc',
|
||||
'search' => ['by' => 'enabled'],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '显示',
|
||||
'action' => 'show',
|
||||
'display' => $this->access['show'],
|
||||
],[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
if ($query['by']) {
|
||||
if ($query['by'] == 'enabled') {
|
||||
$model->where('customer.status', 1);
|
||||
}
|
||||
if ($query['by'] == 'disabled') {
|
||||
$model->where('customer.status', 0);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
return $item;
|
||||
});
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-mail-reply', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['left_buttons'] = [
|
||||
['name' => '批量编辑', 'color' => 'default', 'icon' => 'fa-pencil-square-o', 'action' => 'batchEdit', 'display' => $this->access['batchEdit']],
|
||||
['name' => '销售产品价格', 'color' => 'default', 'icon' => 'fa-pencil-square-o', 'action' => 'priceEdit', 'display' => $this->access['priceEdit']],
|
||||
];
|
||||
|
||||
$header['right_buttons'] = [
|
||||
['name' => '导入', 'color' => 'default', 'icon' => 'fa-mail-reply', 'action' => 'import', 'display' => $this->access['import']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Customer::$tabs;
|
||||
$header['bys'] = Customer::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'create')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
|
||||
$taxs = [];
|
||||
if ($action == 'show') {
|
||||
$taxs = DB::table('customer_tax')->where('customer_id', $id)->get();
|
||||
}
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
'taxs' => $taxs,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
public function batchEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
DB::table('customer')->whereIn('id', $ids)->update([
|
||||
$gets['field'] => $gets['search_0'],
|
||||
]);
|
||||
return $this->json('修改完成。', true);
|
||||
}
|
||||
$header = Grid::batchEdit([
|
||||
'code' => 'customer',
|
||||
'columns' => ['region3_id', 'region2_id', 'region_id', 'grade_id', 'type_id', 'class2_id', 'class_id', 'department_id', 'status'],
|
||||
]);
|
||||
return view('batchEdit', [
|
||||
'gets' => $gets,
|
||||
'header' => $header
|
||||
]);
|
||||
}
|
||||
|
||||
// 销售产品价格
|
||||
public function priceEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
$product_id = $gets['product_id'];
|
||||
$price = floatval($gets['price']);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
foreach($ids as $id) {
|
||||
// 查找客户价格本
|
||||
$count = DB::table('customer_price')
|
||||
->where('customer_id', $id)
|
||||
->where('product_id', $product_id)
|
||||
->count();
|
||||
|
||||
if ($count == 0) {
|
||||
DB::table('customer_price')->insert([
|
||||
'customer_id' => $id,
|
||||
'product_id' => $product_id,
|
||||
'price' => $price,
|
||||
]);
|
||||
}
|
||||
}
|
||||
// 提交事务
|
||||
DB::commit();
|
||||
return $this->json('更新成功。', true);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
abort_error($e->getMessage());
|
||||
}
|
||||
}
|
||||
return $this->render([
|
||||
'gets' => $gets,
|
||||
]);
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 数据导入
|
||||
public function importAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
return Form::import(['table' => 'customer', 'keys' => ['code', 'username']]);
|
||||
}
|
||||
$tips = '注意:表格里必须包含[客户代码]列。';
|
||||
return $this->render(['tips' => $tips], 'layouts.import');
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出层信息
|
||||
*/
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form(
|
||||
['advanced' => ''], [
|
||||
['form_type' => 'text', 'name' => '客户名称', 'field' => 'customer.name', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '客户编码', 'field' => 'customer.code', 'options' => []],
|
||||
['form_type' =>'dialog', 'field' => 'customer.region_id', 'name' => '销售区域', 'options' => ['url' => 'customer/region/dialog', 'query' => ['layer' => 3]]],
|
||||
], 'model');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'customer',
|
||||
]);
|
||||
$_search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table']);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($query['region_id']) {
|
||||
$model->where('customer.region_id', $query['region_id']);
|
||||
}
|
||||
|
||||
$header['select'][] = 'customer.user_id';
|
||||
$model->select($header['select']);
|
||||
|
||||
// 获取默认收货地址
|
||||
$sqlsrv = $pgsql = '';
|
||||
if ($this->dbType == 'sqlsrv') {
|
||||
$sqlsrv = 'top 1';
|
||||
} else if($this->dbType == 'pgsql') {
|
||||
$pgsql = 'LIMIT 1';
|
||||
}
|
||||
$model->leftJoin(DB::raw('(select '.$sqlsrv.' max(id) as delivery_address_id, customer_id, name as warehouse_contact2, phone as warehouse_phone2, address as warehouse_address2, tel as warehouse_tel2
|
||||
FROM customer_delivery_address
|
||||
where is_default = 1
|
||||
GROUP BY customer_id, name, phone, address, tel
|
||||
'.$pgsql.'
|
||||
) cda
|
||||
'), 'customer.id', '=', 'cda.customer_id');
|
||||
|
||||
$model->addSelect(DB::raw('cda.*'));
|
||||
|
||||
if ($query['suggest']) {
|
||||
if ($query['q']) {
|
||||
$q = $query['q'];
|
||||
$model->whereRaw("(customer.code like '%$q%' or customer.name like '%$q%')");
|
||||
}
|
||||
$rows = $model->limit(15)->get();
|
||||
$data = Grid::dataFilters($rows, $header, function($item) {
|
||||
return $item;
|
||||
});
|
||||
$items['data'] = $data;
|
||||
} else {
|
||||
$rows = $model->paginate($query['limit']);
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
$item['text'] = $item['name'];
|
||||
$item['sid'] = 'u'.$item['user_id'];
|
||||
return $item;
|
||||
});
|
||||
}
|
||||
return response()->json($items);
|
||||
}
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\DeliveryAddress;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class DeliveryAddressController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_delivery_address',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
];
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = DeliveryAddress::$tabs;
|
||||
$header['bys'] = DeliveryAddress::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_delivery_address','id' => $id, 'action' => $action]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_delivery_address', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出层信息
|
||||
*/
|
||||
public function dialogAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_delivery_address',
|
||||
'prefix' => '',
|
||||
]);
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table']);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($query['select2']) && $query['q']) {
|
||||
$model->where('customer_delivery_address.address', 'like', '%'. $query['q'] .'%');
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->whereRaw('customer_delivery_address.customer_id > 0 and customer_delivery_address.customer_id = ?', [$query['customer_id']]);
|
||||
|
||||
$header['select'][] = 'customer_delivery_address.id';
|
||||
$header['select'][] = 'customer_delivery_address.address as text';
|
||||
|
||||
if ($query['related'] == '0') {
|
||||
$header['select'][] = 'customer_delivery_address.address as id';
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
|
||||
$rows = $model->paginate($query['limit']);
|
||||
|
||||
if (isset($query['autocomplete'])) {
|
||||
return response()->json($rows->items());
|
||||
}
|
||||
return response()->json($rows);
|
||||
}
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\CustomerPrice;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Product\Models\Product;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class PriceController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog', 'list', 'referCustomer'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_price',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
$model->where('customer_id_customer.id', '>', 0);
|
||||
$model->where('product_id_product.id', '>', 0);
|
||||
$model->where('product_id_product.status', 1);
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['right_buttons'] = [
|
||||
['name' => '导入', 'icon' => 'fa-mail-reply', 'color' => 'default', 'action' => 'import', 'display' => $this->access['import']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerPrice::$tabs;
|
||||
$header['bys'] = CustomerPrice::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建促销
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_price', 'id' => $id, 'action' => $action]);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 客户价格列表
|
||||
public function listAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if ($gets['customer_id']) {
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_price',
|
||||
]);
|
||||
$model = CustomerPrice::where('customer_id', $gets['customer_id']);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->where('product_id_product.status', 1);
|
||||
$model->orderBy('customer_price.id', 'asc');
|
||||
|
||||
$rows = $model->get($header['select']);
|
||||
$rows = Grid::dataFilters($rows, $header, function($row) {
|
||||
$row['product_name'] = $row['product_id_name'];
|
||||
return $row;
|
||||
});
|
||||
} else {
|
||||
$rows = [];
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
// 参考客户价格
|
||||
public function referCustomerAction()
|
||||
{
|
||||
$search = search_form(
|
||||
['advanced' => ''], [
|
||||
['form_type' => 'dialog', 'name' => '客户', 'field' => 'customer_price.customer_id', 'options' => [
|
||||
'url' => 'customer/customer/dialog', 'query' => ['multi'=>0]
|
||||
]],
|
||||
], 'model');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$active = false;
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$active = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($active) {
|
||||
$model = CustomerPrice::query();
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_price',
|
||||
]);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->where('product_id_product.status', 1);
|
||||
$model->orderBy('customer_price.id', 'asc');
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$rows = $model->get($header['select']);
|
||||
$rows = Grid::dataFilters($rows, $header, function($row) {
|
||||
$row['product_name'] = $row['product_id_name'];
|
||||
return $row;
|
||||
});
|
||||
} else {
|
||||
$rows = [];
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
$search['query']['id'] = 'refer_customer';
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
]);
|
||||
}
|
||||
|
||||
// 数据导入
|
||||
public function importAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
return Form::import(['table' => 'customer_price', 'keys' => ['customer_id', 'product_id']]);
|
||||
}
|
||||
$tips = '注意:表格里必须包含[存货编码,客户代码]列。';
|
||||
return $this->render(['tips' => $tips], 'layouts.import');
|
||||
}
|
||||
|
||||
// 删除促销
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_price', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\CustomerType;
|
||||
use Gdoo\Index\Models\Region;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class ReconcileController extends DefaultController
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
// 单客户查询对账数据
|
||||
public function queryAction()
|
||||
{
|
||||
$search = search_form([
|
||||
'customer' => '',
|
||||
'start_at' => '',
|
||||
'end_at' => '',
|
||||
], []);
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
if ($query['customer']) {
|
||||
$customer = DB::table('customer')
|
||||
->leftJoin('user', 'customer.user_id', '=', 'user.id')
|
||||
->where('customer.id', $query['customer'])
|
||||
->first();
|
||||
|
||||
$ch = curl_init(env('YONYOU_URL').'/yonyou.php?do=ar&start_at='.$query['start_at'].'&end_at='.$query['end_at'].'&customer_code='.$customer['username']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$data = json_decode($res, true);
|
||||
|
||||
$lists = [];
|
||||
foreach ($data as $row) {
|
||||
$cDwCode = $row['cDwCode'];
|
||||
$lists[$cDwCode][] = $row;
|
||||
}
|
||||
|
||||
$res = [];
|
||||
$total_start = $total_end = 0;
|
||||
foreach ($lists as $code => $rows) {
|
||||
$ye = 0;
|
||||
foreach ($rows as $i => $row) {
|
||||
|
||||
$ye = $ye + $row['ye'];
|
||||
$ye = $ye + $row['jf'] - $row['df'];
|
||||
|
||||
if($row['iYear'] && $row['iMonth'] && $row['iDay']) {
|
||||
$date = date('Y-m-d', strtotime($row['iYear'].'-'.$row['iMonth'].'-'.$row['iDay']));
|
||||
$jf = number_format($row['jf'], 2);
|
||||
$df = number_format($row['df'], 2);
|
||||
$res[] = [
|
||||
'code' => $code,
|
||||
'date' => $date,
|
||||
'jmoney' => $jf,
|
||||
'dmoney' => $df,
|
||||
'balance' => number_format($ye, 2),
|
||||
'ccusname' => $row['ccusname'],
|
||||
'digest' => $row['cDigest'],
|
||||
'ddh' => $row['ddh'],
|
||||
'zp' => number_format($row['zp'], 2),
|
||||
];
|
||||
} else {
|
||||
$res[] = [
|
||||
'balance' => number_format($row['ye'], 2),
|
||||
'ccusname' => $row['ccusname'],
|
||||
'code' => $code,
|
||||
'digest' => $row['cDigest'],
|
||||
];
|
||||
$total_start += $row['ye'];
|
||||
}
|
||||
}
|
||||
$res[] = [
|
||||
'balance' => number_format($ye, 2),
|
||||
'ccusname' => $rows[0]['ccusname'],
|
||||
'code' => $code,
|
||||
'digest' => '期末余额'
|
||||
];
|
||||
$total_end += $ye;
|
||||
}
|
||||
|
||||
array_unshift($res, [
|
||||
'balance' => number_format($total_start, 2),
|
||||
'digest' => '总期初余额',
|
||||
'ccusname' => '总期初合计',
|
||||
]);
|
||||
$res[] = [
|
||||
'balance' => number_format($total_end, 2),
|
||||
'digest' => '总期末余额',
|
||||
'ccusname' => '总期末合计',
|
||||
];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
return response()->json($res);
|
||||
}
|
||||
}
|
||||
return $this->display();
|
||||
}
|
||||
|
||||
// 生成对账单
|
||||
public function createAction()
|
||||
{
|
||||
set_time_limit(0);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$rules = [
|
||||
'start_at' => 'required|date',
|
||||
'end_at' => 'required|date',
|
||||
];
|
||||
|
||||
$v = Validator::make($gets, $rules, [], ['start_at' => '开始日期', 'end_at' => '结束日期']);
|
||||
if ($v->fails()) {
|
||||
return $this->json($v->errors()->all());
|
||||
}
|
||||
|
||||
/** 数据同步 **/
|
||||
$ch = curl_init(env('YONYOU_URL').'/yonyou.php?do=ar&start_at='.$gets['start_at'].'&end_at='.$gets['end_at']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$res = json_decode($res, true);
|
||||
|
||||
// 获取客户数据
|
||||
$customers = DB::table('user')
|
||||
->leftJoin('customer', 'customer.user_id', '=', 'user.id')
|
||||
->where('group_id', 2)
|
||||
->pluck('customer.id', 'user.username');
|
||||
|
||||
$rows = [];
|
||||
foreach ($res['data'] as $row) {
|
||||
if ($row['code']) {
|
||||
$rows[$row['code']][] = $row;
|
||||
/*
|
||||
if(empty($customers[$row['code']])) {
|
||||
return $this->json('订单系统不存在此客户代码: ['.$row['code'].']');
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// 总余额
|
||||
$yes = $res['ye'];
|
||||
|
||||
foreach ($rows as $code => $row) {
|
||||
$account_id = DB::table('customer_account')->insertGetId([
|
||||
'sn' => date('Ymd').$code,
|
||||
'date' => date('Ymd'),
|
||||
'code' => $code,
|
||||
'customer_id' => (int)$customers[$code],
|
||||
'start_at' => $gets['start_at'],
|
||||
'end_at' => $gets['end_at'],
|
||||
]);
|
||||
|
||||
// 单客户余额
|
||||
$ye = $yes[$row['zcode']] > 0 ? $yes[$row['zcode']] : 0.00;
|
||||
|
||||
// 写入余额数据
|
||||
DB::table('customer_account_data')->insert([
|
||||
'code' => $code,
|
||||
'account_id' => $account_id,
|
||||
'balance' => $ye,
|
||||
'digest' => '期初余额小计',
|
||||
]);
|
||||
|
||||
foreach ($row as $i => $cell) {
|
||||
$ye = $ye + $cell['jf'] - $cell['df'];
|
||||
|
||||
$data = [
|
||||
'account_id' => $account_id,
|
||||
'sn' => date('Ymd').$i,
|
||||
'date' => $cell['date'],
|
||||
'ycode' => $cell['ycode'],
|
||||
'zcode' => $cell['zcode'],
|
||||
'code' => $cell['code'],
|
||||
'jmoney' => $cell['jf'],
|
||||
'dmoney' => $cell['df'],
|
||||
'balance' => $ye,
|
||||
'digest' => $cell['digest'],
|
||||
];
|
||||
|
||||
DB::table('customer_account_data')->insert($data);
|
||||
}
|
||||
|
||||
DB::table('customer_account_data')->insert([
|
||||
'code' => $code,
|
||||
'account_id' => $account_id,
|
||||
'balance' => $ye,
|
||||
'digest' => '期木余额小计',
|
||||
]);
|
||||
|
||||
// 更新余额
|
||||
DB::table('customer_account')->where('id', $account_id)->update([
|
||||
'balance' => $ye,
|
||||
]);
|
||||
}
|
||||
return $this->json('reload', true);
|
||||
}
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerRegion;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class RegionController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_region',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
'trash_btn' => 0,
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->orderBy('lft', 'asc')
|
||||
->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select'])
|
||||
->addSelect(DB::raw('parent_id'));
|
||||
$rows = $model->get()->toNested('name');
|
||||
|
||||
$users = DB::table('user')->get()->keyBy('id');
|
||||
$items = Grid::dataFilters($rows, $header, function($item) use($users) {
|
||||
$owner_assist = explode(',', $item['owner_assist']);
|
||||
$_rows = [];
|
||||
foreach ($owner_assist as $user_id) {
|
||||
$_rows[] = $users[$user_id]['name'];
|
||||
}
|
||||
$item['owner_assist'] = join(',', $_rows);
|
||||
return $item;
|
||||
});
|
||||
return $this->json($items, true);
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerRegion::$tabs;
|
||||
$header['bys'] = CustomerRegion::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
$header['code'] = 'customer_region';
|
||||
$header['id'] = $id;
|
||||
|
||||
$form = Form::make($header);
|
||||
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form([], [
|
||||
['text','customer_region.name','名称'],
|
||||
['text','customer_region.id','ID'],
|
||||
]);
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = CustomerRegion::leftJoin('user', 'user.id', '=', 'customer_region.owner_user_id')
|
||||
->orderBy('customer_region.lft', 'asc');
|
||||
|
||||
// 客户圈权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
$model->whereIn('customer_region.id', $region['regionIn']);
|
||||
}
|
||||
|
||||
if (isset($query['layer'])) {
|
||||
$model->where('customer_region.layer', $query['layer']);
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$rows = $model->get([
|
||||
'customer_region.*',
|
||||
'customer_region.name as text',
|
||||
'user.name as owner_user_id_name'
|
||||
]);
|
||||
$rows = array_nest($rows);
|
||||
|
||||
$json = [];
|
||||
foreach($rows as $row) {
|
||||
$json[] = $row;
|
||||
}
|
||||
return response()->json(['data' => $json]);
|
||||
}
|
||||
return $this->render([
|
||||
'search' => $search
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_region', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerRegionTask;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class RegionTaskController extends AuditController
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_region_task',
|
||||
'referer' => 1,
|
||||
'sort' => 'customer_region_task_data.id',
|
||||
'order' => 'asc',
|
||||
'search' => [],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '显示',
|
||||
'action' => 'show',
|
||||
'display' => $this->access['show'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->leftJoin('customer_region as region2', 'region2.id', '=', 'region_id_customer_region.parent_id')
|
||||
->leftJoin('user as region2_user', 'region2_user.id', '=', 'region2.owner_user_id');
|
||||
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
if ($where['field'] == 'customer_region_task_data.region2_id') {
|
||||
$where['field'] = 'region2.id';
|
||||
}
|
||||
if ($where['field'] == 'customer_region_task_data.region2_user') {
|
||||
$where['field'] = 'region2_user.id';
|
||||
}
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
$model->whereIn('customer_region_task_data.region_id', $region['regionIn']);
|
||||
}
|
||||
|
||||
$header['select'][] = 'region2.name as region2_id';
|
||||
$header['select'][] = 'region2_user.name as region2_user';
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$rows = Grid::dataFilters($rows, $header);
|
||||
return $rows->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-mail-reply', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['right_buttons'] = [
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerRegionTask::$tabs;
|
||||
$header['bys'] = CustomerRegionTask::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'create')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
$form = Form::make([
|
||||
'code' => 'customer_region_task',
|
||||
'id' => $id,
|
||||
'action' => $action,
|
||||
'select' => '
|
||||
(customer_region_task_data.month1 + customer_region_task_data.month2 + customer_region_task_data.month3) as quarter1,
|
||||
(customer_region_task_data.month4 + customer_region_task_data.month5 + customer_region_task_data.month6) as quarter2,
|
||||
(customer_region_task_data.month7 + customer_region_task_data.month8 + customer_region_task_data.month9) as quarter3,
|
||||
(customer_region_task_data.month10 + customer_region_task_data.month11 + customer_region_task_data.month12) as quarter4
|
||||
',
|
||||
]);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域进度
|
||||
*/
|
||||
public function progressAction()
|
||||
{
|
||||
$year = date('Y');
|
||||
$search = search_form([], [[
|
||||
'form_type' => 'year',
|
||||
'field' => 'date',
|
||||
'name' => '年份',
|
||||
'value' => $year,
|
||||
],[
|
||||
'form_type' =>'dialog',
|
||||
'field' => 'region_id',
|
||||
'name' => '销售团队',
|
||||
'options' => ['url' => 'customer/region/dialog', 'query' => ['layer' => 3]]
|
||||
],
|
||||
], 'model');
|
||||
|
||||
$query = [];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
foreach($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$query[$where['field']] = $where['search'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($query['date'])) {
|
||||
$query['date'] = $year;
|
||||
}
|
||||
|
||||
$region = DB::table('customer_region as r')
|
||||
->where('r.layer', 3);
|
||||
|
||||
$task = DB::table('customer_region_task_data as d')
|
||||
->leftJoin('customer_region_task as m', 'm.id', '=', 'd.task_id')
|
||||
->where('m.status', 1)
|
||||
->whereRaw('m.year = ?', [$query['date']]);
|
||||
|
||||
$delivery = DB::table('stock_delivery_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_delivery as m', 'm.id', '=', 'd.delivery_id')
|
||||
->leftJoin('customer as c', 'c.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('c.region_id, '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('c.region_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
$cancel = DB::table('stock_cancel_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_cancel as m', 'm.id', '=', 'd.cancel_id')
|
||||
->leftJoin('customer as c', 'c.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('c.region_id, '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('c.region_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
$direct = DB::table('stock_direct_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_direct as m', 'm.id', '=', 'd.direct_id')
|
||||
->leftJoin('customer as c', 'c.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('c.region_id, '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('c.region_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
if ($query['region_id']) {
|
||||
$region_ids = explode(',', $query['region_id']);
|
||||
$region->whereIn('r.id', $region_ids);
|
||||
$delivery->whereIn('c.region_id', $region_ids);
|
||||
$cancel->whereIn('c.region_id', $region_ids);
|
||||
$direct->whereIn('c.region_id', $region_ids);
|
||||
$task->whereIn('d.region_id', $region_ids);
|
||||
}
|
||||
|
||||
// 客户圈权限
|
||||
$_region = regionCustomer();
|
||||
if ($_region['authorise']) {
|
||||
$region->whereIn('r.id', $_region['regionIn']);
|
||||
$delivery->whereIn('c.region_id', $_region['regionIn']);
|
||||
$cancel->whereIn('c.region_id', $_region['regionIn']);
|
||||
$direct->whereIn('c.region_id', $_region['regionIn']);
|
||||
$task->whereIn('d.region_id', $_region['regionIn']);
|
||||
}
|
||||
|
||||
$_rows = $cancel->unionAll($delivery)->unionAll($direct)->get();
|
||||
$_tasks = $task->get()->toArray();
|
||||
|
||||
$rows = [];
|
||||
foreach($_rows as $row) {
|
||||
$rows[$row['region_id']]['month'.$row['month']] += $row['money'];
|
||||
}
|
||||
|
||||
$tasks = [];
|
||||
foreach($_tasks as $task) {
|
||||
$tasks[$task['region_id']] = $task;
|
||||
}
|
||||
|
||||
$regions = $region->get(['r.id as region_id', 'r.name as region_name'])->toArray();
|
||||
foreach($regions as &$region) {
|
||||
|
||||
$quarters = [];
|
||||
|
||||
$total_money = 0;
|
||||
$total_task = 0;
|
||||
|
||||
$task = $tasks[$region['region_id']];
|
||||
|
||||
// 计算月进度
|
||||
for ($i=1; $i <= 12; $i++) {
|
||||
$month = $task['month'.$i];
|
||||
|
||||
$region['month'.$i] = $month;
|
||||
|
||||
$money = $rows[$region['region_id']]['month'.$i] / 10000;
|
||||
$money = sprintf('%.4f', $money);
|
||||
|
||||
$total_money += $money;
|
||||
$total_task += $month;
|
||||
|
||||
$quarter = ceil($i / 3);
|
||||
$quarters[$quarter]['money'] += $money;
|
||||
$quarters[$quarter]['task'] += $month;
|
||||
|
||||
$region['month_'.$i.'_money'] = $money;
|
||||
|
||||
if ($month > 0) {
|
||||
$region['month_'.$i.'_rate'] = sprintf('%.2f', ($money / $month) * 100);
|
||||
} else {
|
||||
$region['month_'.$i.'_rate'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total_money > 0 && $total_task > 0) {
|
||||
$region['total_rate'] = sprintf('%.2f', ($total_money / $total_task) * 100);
|
||||
} else {
|
||||
$region['total_rate'] = 0;
|
||||
}
|
||||
|
||||
$region['total_task'] = $total_task;
|
||||
$region['total_money'] = $total_money;
|
||||
|
||||
// 计算季度进度
|
||||
for ($i=1; $i <= 4; $i++) {
|
||||
$quarter = $quarters[$i];
|
||||
$region['quarter_'.$i] = $quarter['task'];
|
||||
$region['quarter_'.$i.'_money'] = sprintf('%.4f', $quarter['money']);
|
||||
if ($quarter['money'] > 0 && $quarter['task'] > 0) {
|
||||
$region['quarter_'.$i.'_rate'] = sprintf('%.2f', ($quarter['money'] / $quarter['task']) * 100);
|
||||
} else {
|
||||
$region['quarter_'.$i.'_rate'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->json($regions, true);
|
||||
}
|
||||
|
||||
$header = [
|
||||
'table' => 'region_task',
|
||||
'master_table' => 'region_task',
|
||||
'buttons' => [],
|
||||
'search_form' => $search,
|
||||
'simple_search_form' => 0,
|
||||
];
|
||||
|
||||
$header['left_buttons'] = [
|
||||
['name' => '导出', 'color' => 'default', 'icon' => 'fa-mail-forward', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
return $this->display([
|
||||
'search' => $search,
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_region_task', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerTask;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class TaskController extends AuditController
|
||||
{
|
||||
public $permission = ['importExcel'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_task',
|
||||
'referer' => 1,
|
||||
'sort' => 'id',
|
||||
'order' => 'desc',
|
||||
'search' => [],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '显示',
|
||||
'action' => 'show',
|
||||
'display' => $this->access['show'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$rows = Grid::dataFilters($rows, $header);
|
||||
return $rows->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-mail-reply', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['right_buttons'] = [
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerTask::$tabs;
|
||||
$header['bys'] = CustomerTask::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'create')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make([
|
||||
'code' => 'customer_task',
|
||||
'id' => $id,
|
||||
'action' => $action,
|
||||
'select' => '
|
||||
(customer_task_data.month1 + customer_task_data.month2 + customer_task_data.month3) as quarter1,
|
||||
(customer_task_data.month4 + customer_task_data.month5 + customer_task_data.month6) as quarter2,
|
||||
(customer_task_data.month7 + customer_task_data.month8 + customer_task_data.month9) as quarter3,
|
||||
(customer_task_data.month10 + customer_task_data.month11 + customer_task_data.month12) as quarter4
|
||||
',
|
||||
]);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域进度
|
||||
*/
|
||||
public function progressAction()
|
||||
{
|
||||
$year = date('Y');
|
||||
$search = search_form([], [[
|
||||
'form_type' => 'year',
|
||||
'field' => 'date',
|
||||
'name' => '年份',
|
||||
'value' => $year,
|
||||
],[
|
||||
'form_type' =>'dialog',
|
||||
'field' => 'customer_id',
|
||||
'name' => '客户',
|
||||
'options' => ['url' => 'customer/customer/dialog', 'query' => []]
|
||||
],[
|
||||
'form_type' =>'dialog',
|
||||
'field' => 'region_id',
|
||||
'name' => '销售团队',
|
||||
'options' => ['url' => 'customer/region/dialog', 'query' => ['layer' => 3]]
|
||||
],
|
||||
], 'model');
|
||||
|
||||
$query = [];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
foreach($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$query[$where['field']] = $where['search'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($query['date'])) {
|
||||
$query['date'] = $year;
|
||||
}
|
||||
|
||||
$customer = DB::table('customer')
|
||||
->leftJoin('customer_region as r', 'r.id', '=', 'customer.region_id');
|
||||
|
||||
$task = DB::table('customer_task_data as d')
|
||||
->leftJoin('customer_task as m', 'm.id', '=', 'd.task_id')
|
||||
->leftJoin('customer', 'customer.id', '=', 'd.customer_id')
|
||||
->where('m.status', 1)
|
||||
->whereRaw('m.year = ?', [$query['date']]);
|
||||
|
||||
$delivery = DB::table('stock_delivery_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_delivery as m', 'm.id', '=', 'd.delivery_id')
|
||||
->leftJoin('customer', 'customer.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('m.customer_id, count(DISTINCT m.id) as [count], '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('m.customer_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
$cancel = DB::table('stock_cancel_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_cancel as m', 'm.id', '=', 'd.cancel_id')
|
||||
->leftJoin('customer', 'customer.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('m.customer_id, 0 as [count], '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('m.customer_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
$direct = DB::table('stock_direct_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('stock_direct as m', 'm.id', '=', 'd.direct_id')
|
||||
->leftJoin('customer', 'customer.id', '=', 'm.customer_id')
|
||||
->whereRaw('d.product_id <> 20226 and isnull(product.product_type, 0) = 1')
|
||||
->whereRaw(sql_year('m.invoice_dt').' = ?', [$query['date']])
|
||||
->selectRaw('m.customer_id, count(DISTINCT m.id) as [count], '.sql_month('m.invoice_dt').' as [month], sum(isnull(d.money, 0) - isnull(d.other_money, 0)) money')
|
||||
->groupBy('m.customer_id', DB::raw(sql_month('m.invoice_dt')));
|
||||
|
||||
if ($query['region_id']) {
|
||||
$region_ids = explode(',', $query['region_id']);
|
||||
$customer->whereIn('customer.region_id', $region_ids);
|
||||
$task->whereIn('customer.region_id', $region_ids);
|
||||
$delivery->whereIn('customer.region_id', $region_ids);
|
||||
$cancel->whereIn('customer.region_id', $region_ids);
|
||||
$direct->whereIn('customer.region_id', $region_ids);
|
||||
}
|
||||
|
||||
if ($query['customer_id']) {
|
||||
$customer_ids = explode(',', $query['customer_id']);
|
||||
$customer->whereIn('customer.id', $customer_ids);
|
||||
$task->whereIn('customer.id', $customer_ids);
|
||||
$delivery->whereIn('customer.id', $customer_ids);
|
||||
$cancel->whereIn('customer.id', $customer_ids);
|
||||
$direct->whereIn('customer.id', $customer_ids);
|
||||
}
|
||||
|
||||
// 客户圈权限
|
||||
$_region = regionCustomer();
|
||||
if ($_region['authorise']) {
|
||||
foreach($_region['whereIn'] as $key => $whereIn) {
|
||||
$customer->whereIn($key, $whereIn);
|
||||
$task->whereIn($key, $whereIn);
|
||||
$delivery->whereIn($key, $whereIn);
|
||||
$cancel->whereIn($key, $whereIn);
|
||||
$direct->whereIn($key, $whereIn);
|
||||
}
|
||||
}
|
||||
$_rows = $cancel->unionAll($delivery)->unionAll($direct)->get();
|
||||
|
||||
$_tasks = $task->get()->toArray();
|
||||
|
||||
$rows = [];
|
||||
foreach($_rows as $row) {
|
||||
$rows[$row['customer_id']]['month'.$row['month']] += $row['money'];
|
||||
$rows[$row['customer_id']]['count'.$row['month']] += $row['count'];
|
||||
}
|
||||
|
||||
$tasks = [];
|
||||
foreach($_tasks as $task) {
|
||||
$tasks[$task['customer_id']] = $task;
|
||||
}
|
||||
|
||||
$customers = $customer->get([
|
||||
'r.name as region_name',
|
||||
'customer.id as customer_id',
|
||||
'customer.name as customer_name',
|
||||
'customer.code as customer_code',
|
||||
'customer.status'
|
||||
])->toArray();
|
||||
|
||||
foreach($customers as &$customer) {
|
||||
|
||||
$quarters = [];
|
||||
|
||||
$task = $tasks[$customer['customer_id']];
|
||||
|
||||
$total_money = 0;
|
||||
$total_task = 0;
|
||||
$total_count = 0;
|
||||
|
||||
// 计算月进度
|
||||
for ($i=1; $i <= 12; $i++) {
|
||||
$month = $task['month'.$i];
|
||||
|
||||
$customer['month'.$i] = $month;
|
||||
|
||||
$money = $rows[$customer['customer_id']]['month'.$i] / 10000;
|
||||
$money = sprintf('%.4f', $money);
|
||||
|
||||
$quarter = ceil($i / 3);
|
||||
$quarters[$quarter]['money'] += $money;
|
||||
$quarters[$quarter]['task'] += $month;
|
||||
|
||||
$total_money += $money;
|
||||
$total_task += $month;
|
||||
|
||||
// 总订单数量
|
||||
$count = $rows[$customer['customer_id']]['count'.$i];
|
||||
$total_count += $count;
|
||||
|
||||
$customer['month_'.$i.'_money'] = $money;
|
||||
if ($money > 0 && $month > 0) {
|
||||
$customer['month_'.$i.'_rate'] = sprintf('%.2f', ($money / $month) * 100);
|
||||
} else {
|
||||
$customer['month_'.$i.'_rate'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total_money > 0 && $total_task > 0) {
|
||||
$customer['total_rate'] = sprintf('%.2f', ($total_money / $total_task) * 100);
|
||||
} else {
|
||||
$customer['total_rate'] = 0;
|
||||
}
|
||||
$customer['total_task'] = $total_task;
|
||||
$customer['total_money'] = $total_money;
|
||||
$customer['total_count'] = $total_count;
|
||||
|
||||
// 计算季度进度
|
||||
for ($i=1; $i <= 4; $i++) {
|
||||
$quarter = $quarters[$i];
|
||||
$customer['quarter_'.$i] = $quarter['task'];
|
||||
$customer['quarter_'.$i.'_money'] = sprintf('%.4f', $quarter['money']);
|
||||
if ($quarter['money'] > 0 && $quarter['task'] > 0) {
|
||||
$customer['quarter_'.$i.'_rate'] = sprintf('%.2f', ($quarter['money'] / $quarter['task']) * 100);
|
||||
} else {
|
||||
$customer['quarter_'.$i.'_rate'] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $this->json($customers, true);
|
||||
}
|
||||
|
||||
$header = [
|
||||
'table' => 'customer_task',
|
||||
'master_table' => 'customer_task',
|
||||
'buttons' => [],
|
||||
'search_form' => $search,
|
||||
'simple_search_form' => 0,
|
||||
];
|
||||
|
||||
$header['left_buttons'] = [
|
||||
['name' => '导出', 'color' => 'default', 'icon' => 'fa-mail-forward', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
return $this->display([
|
||||
'search' => $search,
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
public function importExcelAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
if ($file->isValid()) {
|
||||
$customers = DB::table('customer')->get()->keyBy('code');
|
||||
/*
|
||||
[0] => 合同编号
|
||||
[1] => 客户编码
|
||||
[2] => 数量
|
||||
[3] => 单价
|
||||
[4] => 备注
|
||||
*/
|
||||
$rows = readExcel($file->getPathName(), $file->getClientOriginalExtension());
|
||||
$items = [];
|
||||
foreach($rows as $i => $row) {
|
||||
if ($i > 1) {
|
||||
$customer = $customers[$row[1]];
|
||||
if (empty($customer)) {
|
||||
return $this->json('客户编码'.$row[1].'客户档案不存在。');
|
||||
}
|
||||
$item = [
|
||||
'code' => $row[0],
|
||||
'customer_id' => $customer['id'],
|
||||
'customer_id_name' => $customer['name'],
|
||||
'month1' => $row[4],
|
||||
'month2' => $row[5],
|
||||
'month3' => $row[6],
|
||||
'month4' => $row[7],
|
||||
'month5' => $row[8],
|
||||
'month6' => $row[9],
|
||||
'month7' => $row[10],
|
||||
'month8' => $row[11],
|
||||
'month9' => $row[12],
|
||||
'month10' => $row[13],
|
||||
'month11' => $row[14],
|
||||
'month12' => $row[15],
|
||||
];
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
return $this->json($items, true);
|
||||
}
|
||||
}
|
||||
return view('importExcel');
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_task', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerTax;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class TaxController extends AuditController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_tax',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
'sort' => 'customer_tax.customer_id',
|
||||
'order' => 'desc',
|
||||
'trash_btn' => 0,
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
|
||||
$header['left_buttons'] = [
|
||||
['name' => '批量编辑', 'color' => 'default', 'icon' => 'fa-pencil-square-o', 'action' => 'batchEdit', 'display' => $this->access['batchEdit']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerTax::$tabs;
|
||||
$header['bys'] = CustomerTax::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_tax', 'id' => $id, 'action' => $action]);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction('edit');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form(
|
||||
['advanced' => ''], [
|
||||
['form_type' => 'text', 'name' => '开票名称', 'field' => 'customer_tax.name', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '开票编码', 'field' => 'customer_tax.code', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '客户名称', 'field' => 'customer.name', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '客户编码', 'field' => 'customer.code', 'options' => []]
|
||||
], 'model');
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = CustomerTax::leftJoin('customer', 'customer_tax.customer_id', '=', 'customer.id');
|
||||
|
||||
if (isset($query['customer_id'])) {
|
||||
$model->where('customer_id', $query['customer_id']);
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 客户权限
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select(['customer_tax.*','customer.code as customer_code', 'customer.name as customer_name']);
|
||||
$rows = $model->paginate($query['limit']);
|
||||
return response()->json($rows);
|
||||
}
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
public function batchEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
DB::table('customer_tax')->whereIn('id', $ids)->update([
|
||||
$gets['field'] => $gets['search_0'],
|
||||
]);
|
||||
return $this->json('修改完成。', true);
|
||||
}
|
||||
$header = Grid::batchEdit([
|
||||
'code' => 'customer_tax',
|
||||
'columns' => ['class_id', 'department_id', 'status'],
|
||||
]);
|
||||
return view('batchEdit', [
|
||||
'gets' => $gets,
|
||||
'header' => $header
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_tax', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Session;
|
||||
use Request;
|
||||
|
||||
use Gdoo\User\Models\UserAsset;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\Contact;
|
||||
|
||||
use Gdoo\User\Controllers\TokenController as Controller;
|
||||
use Gdoo\User\Services\UserAssetService;
|
||||
|
||||
class TokenController extends Controller
|
||||
{
|
||||
public function salesmanAction()
|
||||
{
|
||||
if (Request::isJson()) {
|
||||
$gets = json_decode(Request::getContent(), true);
|
||||
} else {
|
||||
$gets = Request::all();
|
||||
}
|
||||
|
||||
$username = trim($gets['username']);
|
||||
$password = trim($gets['password']);
|
||||
|
||||
if ($username == '') {
|
||||
return response()->json(['message'=>'客户代码不能为空。']);
|
||||
}
|
||||
|
||||
if ($password == '') {
|
||||
return response()->json(['message'=>'联系人手机不能为空。']);
|
||||
}
|
||||
|
||||
// 获取登录用户
|
||||
$user = User::where('username', $username)
|
||||
->where('group_id', 2)
|
||||
->where('status', 1)
|
||||
->first();
|
||||
|
||||
if ($user) {
|
||||
// 获取客户档案
|
||||
$customer = Customer::where('user_id', $user->id)->first();
|
||||
|
||||
// 登录的客户业务员信息
|
||||
$contact = Contact::leftJoin('user', 'user.id', '=', 'customer_contact.user_id')
|
||||
->where('customer_contact.customer_id', $customer->id)
|
||||
->where('user.phone', $password)
|
||||
->first(['user.*', 'customer_contact.id as contact_id']);
|
||||
|
||||
if ($contact) {
|
||||
$assets = UserAssetService::getRoleAssets($user->role_id);
|
||||
return response()->json([
|
||||
'token' => $this->createToken($user->id),
|
||||
'contact_id' => $contact->contact_id,
|
||||
'access' => $assets,
|
||||
]);
|
||||
} else {
|
||||
return response()->json(['message'=>'客户代码或联系人手机错误。']);
|
||||
}
|
||||
}
|
||||
return response()->json(['message'=>'客户代码或联系人手机错误。']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerType;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class TypeController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_type',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
'trash_btn' => 0,
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
$cols['actions']['options'] = [[
|
||||
'name' => '编辑',
|
||||
'action' => 'edit',
|
||||
'display' => $this->access['edit'],
|
||||
]];
|
||||
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table($header['table'])->setBy($header);
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
$model->orderBy($header['sort'], $header['order'])
|
||||
->orderBy('id', 'desc');
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->select($header['select']);
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
$items = Grid::dataFilters($rows, $header);
|
||||
return $items->toJson();
|
||||
}
|
||||
|
||||
$header['buttons'] = [
|
||||
['name' => '删除', 'icon' => 'fa-remove', 'action' => 'delete', 'display' => $this->access['delete']],
|
||||
['name' => '导出', 'icon' => 'fa-share', 'action' => 'export', 'display' => 1],
|
||||
];
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = CustomerType::$tabs;
|
||||
$header['bys'] = CustomerType::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_type', 'id' => $id]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form([], [
|
||||
['text','customer_type.name','名称'],
|
||||
['text','customer_type.id','ID'],
|
||||
]);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = CustomerType::orderBy('sort', 'asc');
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
$rows = $model->get(['*', 'name as text']);
|
||||
return response()->json(['data' => $rows]);
|
||||
}
|
||||
return $this->render([
|
||||
'get' => Request::all()
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_type', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php namespace Gdoo\Customer\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class WidgetController extends DefaultController
|
||||
{
|
||||
public $permission = ['birthday'];
|
||||
|
||||
// 生日提醒
|
||||
public function birthdayAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
$model = DB::table('customer');
|
||||
$region = regionCustomer();
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->dbType == 'sqlsrv') {
|
||||
$model->whereRaw('
|
||||
(datediff(dd, getdate(), dateadd(year, datediff(year, head_birthday, getdate()), head_birthday)) between 0 and 7)
|
||||
OR
|
||||
(datediff(dd, getdate(), dateadd(year, datediff(year, head_birthday, getdate())+1, head_birthday)) between 0 and 7)')
|
||||
->selectRaw('id, code, name, head_name, head_phone, head_birthday')
|
||||
->get();
|
||||
} else if($this->dbType == 'pgsql') {
|
||||
$model->whereRaw("
|
||||
(concat(date_part('year', current_date), '-', date_part('month', head_birthday), '-', date_part('day', head_birthday))::date - current_date between 0 and 7)
|
||||
OR
|
||||
(concat(date_part('year', current_date) + 1, '-', date_part('month', head_birthday), '-', date_part('day', head_birthday))::date - current_date between 0 and 7)")
|
||||
->selectRaw("id, code, name, head_name, head_phone, concat(date_part('year', current_date), '-', date_part('month', head_birthday), '-', date_part('day', head_birthday))::date as head_birthday");
|
||||
}
|
||||
|
||||
else if($this->dbType == 'mysql') {
|
||||
$model->whereRaw("
|
||||
(concat(year(now()), DATE_FORMAT(birthday,'-%m-%d')) BETWEEN DATE_FORMAT(now(),'%Y-%m-%d') AND DATE_FORMAT(DATE_ADD(now(), interval 10 day),'%Y-%m-%d'))
|
||||
OR
|
||||
(concat(year(now()) + 1, DATE_FORMAT(birthday,'-%m-%d')) BETWEEN DATE_FORMAT(now(),'%Y-%m-%d') AND DATE_FORMAT(DATE_ADD(now(), interval 10 day),'%Y-%m-%d'))")
|
||||
->selectRaw("id, code, name, head_name, head_phone, concat(year(now()), DATE_FORMAT(birthday,'-%m-%d')) as head_birthday");
|
||||
}
|
||||
|
||||
$rows = $model->get();
|
||||
|
||||
$json['total'] = sizeof($rows);
|
||||
$json['data'] = $rows;
|
||||
return response()->json($json);
|
||||
}
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use Validator;
|
||||
use DB;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\Contact;
|
||||
|
||||
class ContactHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
$master = $params['master'];
|
||||
|
||||
$_user = [
|
||||
'role_id' => 95,
|
||||
'group_id' => 3,
|
||||
'username' => $master['code'],
|
||||
'name' => $master['name'],
|
||||
'phone' => $master['phone'],
|
||||
'status' => 1,
|
||||
];
|
||||
|
||||
$v = Validator::make($_user, [
|
||||
'username' => 'unique:user,username,'.$master['user_id']
|
||||
], [], ['username' => '编码']);
|
||||
if ($v->fails()) {
|
||||
abort_error($v->errors()->first('username'));
|
||||
}
|
||||
|
||||
// 更新用户表
|
||||
$user = User::findOrNew($master['user_id']);
|
||||
// 密码处理
|
||||
if (empty($master['password'])) {
|
||||
unset($master['password']);
|
||||
} else {
|
||||
$user->password = bcrypt($master['password']);
|
||||
$master['password'] = $user['password'];
|
||||
}
|
||||
$user->fill($_user)->save();
|
||||
$master['user_id'] = $user->id;
|
||||
$params['master'] = $master;
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
$ids = $params['ids'];
|
||||
$userIds = Contact::whereIn('id', $ids)->pluck('user_id');
|
||||
User::whereIn('id', $userIds)->delete();
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\CustomerApply;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\CustomerTax;
|
||||
|
||||
class CustomerApplyHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeAudit($params) {
|
||||
$id = $params['id'];
|
||||
$apply = DB::table('customer_apply')->where('id', $id)
|
||||
->selectRaw('
|
||||
type_id,
|
||||
department_id,
|
||||
remark,
|
||||
region_id,
|
||||
class_id,
|
||||
class2_id,
|
||||
province_id,
|
||||
city_id,
|
||||
county_id,
|
||||
address,
|
||||
name,
|
||||
warehouse_address,
|
||||
warehouse_contact,
|
||||
warehouse_phone,
|
||||
warehouse_tel,
|
||||
warehouse_size,
|
||||
head_name,
|
||||
head_phone,
|
||||
manage_name,
|
||||
manage_phone,
|
||||
manage_weixin,
|
||||
finance_name,
|
||||
finance_phone,
|
||||
cost_name,
|
||||
cost_phone,
|
||||
tax_number,
|
||||
bank_name,
|
||||
bank_account,
|
||||
bank_address
|
||||
')->first();
|
||||
|
||||
// 自动处理区域
|
||||
if ($apply['region_id']) {
|
||||
$regions = DB::table('customer_region')->get()->keyBy('id');
|
||||
$region1 = $regions[$apply['region_id']];
|
||||
$region2 = $regions[$region1['parent_id']];
|
||||
$region3 = $regions[$region2['parent_id']];
|
||||
$apply['region2_id'] = $region2['id'];
|
||||
$apply['region3_id'] = $region3['id'];
|
||||
}
|
||||
|
||||
// 新建客户
|
||||
$customer = new Customer;
|
||||
$customer->fill($apply);
|
||||
$customer->save();
|
||||
|
||||
// 新建用户
|
||||
$_user = [
|
||||
'role_id' => 2,
|
||||
'group_id' => 2,
|
||||
'username' => $customer['id'],
|
||||
'name' => $customer['name'],
|
||||
'department_id' => $customer['department_id'],
|
||||
'phone' => $customer['head_phone'],
|
||||
'password' => bcrypt('123456'),
|
||||
'status' => 1,
|
||||
];
|
||||
$user = new User;
|
||||
$user->fill($_user)->save();
|
||||
$customer['user_id'] = $user->id;
|
||||
|
||||
// 重新更新客户数据
|
||||
$customer->code = $customer['id'];
|
||||
$customer->save();
|
||||
|
||||
// 自动新建开票单位
|
||||
CustomerTax::insert([
|
||||
'customer_id' => $customer->id,
|
||||
'class_id' => $customer->class_id,
|
||||
'department_id' => $customer->department_id,
|
||||
'code' => $customer->code,
|
||||
'name' => $customer->name,
|
||||
'bank_name' => $apply['bank_name'],
|
||||
'tax_number' => $apply['tax_number'],
|
||||
'bank_account' => $apply['bank_account'],
|
||||
'bank_address' => $apply['bank_address'],
|
||||
'status' => 1,
|
||||
]);
|
||||
|
||||
// 回写申请的客户编码
|
||||
$_apply = CustomerApply::find($id);
|
||||
$_apply->code = $customer['code'];
|
||||
$_apply->save();
|
||||
|
||||
// 客户档案写入用友
|
||||
$department = DB::table('department')->where('id', $customer['department_id'])->first();
|
||||
$class = DB::table('customer_class')->where('id', $customer['class_id'])->first();
|
||||
$customer['class_code'] = $class['code'];
|
||||
$customer['department_code'] = $department['code'];
|
||||
$customer['headCode'] = $customer['code'];
|
||||
|
||||
$ret = plugin_sync_api('CustomerSync', $customer);
|
||||
if ($ret['success'] == true) {
|
||||
return $params;
|
||||
}
|
||||
abort_error($ret['msg']);
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\CustomerTax;
|
||||
|
||||
class CustomerHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
$master = $params['master'];
|
||||
|
||||
$_user = [
|
||||
'role_id' => 2,
|
||||
'group_id' => 2,
|
||||
'username' => $master['code'],
|
||||
'name' => $master['name'],
|
||||
'department_id' => $master['department_id'],
|
||||
'phone' => $master['head_phone'],
|
||||
'status' => $master['status'],
|
||||
];
|
||||
|
||||
// 更新用户表
|
||||
$user = User::findOrNew($master['user_id']);
|
||||
// 密码处理
|
||||
if (empty($master['password'])) {
|
||||
unset($master['password']);
|
||||
} else {
|
||||
$user['password'] = bcrypt($master['password']);
|
||||
$master['password'] = $user['password'];
|
||||
}
|
||||
$user->fill($_user)->save();
|
||||
$master['user_id'] = $user->id;
|
||||
|
||||
// 自动处理区域
|
||||
if ($master['region_id']) {
|
||||
$regions = DB::table('customer_region')->get()->keyBy('id');
|
||||
$region1 = $regions[$master['region_id']];
|
||||
$region2 = $regions[$region1['parent_id']];
|
||||
$region3 = $regions[$region2['parent_id']];
|
||||
$master['region2_id'] = $region2['id'];
|
||||
$master['region3_id'] = $region3['id'];
|
||||
}
|
||||
$params['master'] = $master;
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
$master = $params['master'];
|
||||
if (empty($master['code'])) {
|
||||
// 自动设置客户编码
|
||||
$customer = Customer::find($master['id']);
|
||||
$customer->code = $customer['id'];
|
||||
$customer->save();
|
||||
|
||||
// 自动设置用户名
|
||||
$user = User::find($customer['user_id']);
|
||||
$user->username = $customer['id'];
|
||||
$user->save();
|
||||
|
||||
// 自动新建开票单位
|
||||
CustomerTax::insert([
|
||||
'customer_id' => $customer->id,
|
||||
'class_id' => $customer->class_id,
|
||||
'department_id' => $customer->department_id,
|
||||
'code' => $customer->code,
|
||||
'name' => $customer->name,
|
||||
'status' => 1,
|
||||
]);
|
||||
|
||||
// 客户档案写入用友
|
||||
$department = DB::table('department')->where('id', $master['department_id'])->first();
|
||||
$class = DB::table('customer_class')->where('id', $customer['class_id'])->first();
|
||||
$customer['class_code'] = $class['code'];
|
||||
$customer['department_code'] = $department['code'];
|
||||
$customer['headCode'] = $customer->code;
|
||||
$ret = plugin_sync_api('CustomerSync', $customer);
|
||||
if ($ret['success'] == true) {
|
||||
return $params;
|
||||
}
|
||||
abort_error($ret['msg']);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
$ids = $params['ids'];
|
||||
$userIds = Customer::whereIn('id', $ids)->pluck('user_id');
|
||||
User::whereIn('id', $userIds)->delete();
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeImport($params)
|
||||
{
|
||||
$row = $params['row'];
|
||||
$ret = $params['ret'];
|
||||
abort_error('客户档案暂时无法导入');
|
||||
// $row['password']
|
||||
if ($ret['id']) {
|
||||
//DB::table($table)->where('id', $ret['id'])->update($row);
|
||||
} else {
|
||||
//$row['id'] = DB::table($table)->insertGetId($row);
|
||||
}
|
||||
//print_r($row);
|
||||
// exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
class CustomerTaskDataHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onQueryForm($params) {
|
||||
$q = $params['q'];
|
||||
$q->orderByRaw('cast(customer_task_data.code as int) asc');
|
||||
|
||||
$params['q'] = $q;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($arguments) {
|
||||
return $arguments;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\DeliveryAddress;
|
||||
|
||||
class DeliveryAddressHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
$master = $params['master'];
|
||||
if ($master['is_default'] == 1) {
|
||||
$customer = Customer::find($master['customer_id']);
|
||||
if ($customer) {
|
||||
$customer->warehouse_contact = $master['name'];
|
||||
$customer->warehouse_tel = $master['tel'];
|
||||
$customer->warehouse_phone = $master['phone'];
|
||||
$customer->warehouse_address = $master['address'];
|
||||
$customer->save();
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\CustomerPrice;
|
||||
|
||||
class PriceHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
$gets = $params['gets'];
|
||||
$_price = $gets['customer_price'];
|
||||
$data = $gets['customer_price_data'];
|
||||
|
||||
$id = 0;
|
||||
|
||||
// 新增或者修改
|
||||
foreach((array)$data['rows'] as $row) {
|
||||
$row['customer_id'] = $_price['customer_id'];
|
||||
$price = CustomerPrice::findOrNew($row['id']);
|
||||
$price->fill($row)->save();
|
||||
$id = $price->id;
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
foreach((array)$data['deleteds'] as $row) {
|
||||
if ($row['id'] > 0) {
|
||||
CustomerPrice::where('id', $row['id'])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$master['id'] = $id;
|
||||
$params['master'] = $master;
|
||||
|
||||
// 终止执行的进程后
|
||||
$params['terminate'] = false;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\Customer\Models\CustomerRegion;
|
||||
|
||||
class RegionHook
|
||||
{
|
||||
static $linkOptions = [];
|
||||
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params) {
|
||||
$master = $params['master'];
|
||||
$master['parent_id'] = (int)$master['parent_id'];
|
||||
$params['master'] = $master;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
CustomerRegion::treeRebuild();
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php namespace Gdoo\Customer\Hooks;
|
||||
|
||||
use DB;
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Customer\Models\Customer;
|
||||
use Gdoo\Customer\Models\CustomerTax;
|
||||
|
||||
class TaxHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
$master = $params['master'];
|
||||
if (empty($master['code'])) {
|
||||
// 自动设置开票编码
|
||||
$customer = Customer::find($master['customer_id']);
|
||||
$code = $customer['code'];
|
||||
$max_id = (int)$customer['tax_max_id'] + 1;
|
||||
|
||||
// 更新开票单位code
|
||||
$tax = CustomerTax::find($master['id']);
|
||||
$tax->code = $code.$max_id;
|
||||
$tax->save();
|
||||
|
||||
$customer->tax_max_id = $max_id;
|
||||
$customer->save();
|
||||
|
||||
// 客户档案写入用友
|
||||
$department = DB::table('department')->where('id', $tax['department_id'])->first();
|
||||
$class = DB::table('customer_class')->where('id', $tax['class_id'])->first();
|
||||
$tax['class_code'] = $class['code'];
|
||||
$tax['department_code'] = $department['code'];
|
||||
$tax['headCode'] = $customer->code;
|
||||
$ret = plugin_sync_api('CustomerSync', $tax);
|
||||
if ($ret['success'] == true) {
|
||||
return $params;
|
||||
}
|
||||
abort_error($ret['msg']);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Business extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_business';
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Contact extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_contact';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'contact.index', 'url' => 'customer/contact/index', 'name' => '客户联系人'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
protected $guarded = ['id', 'user_id'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\User\Models\User');
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Customer\Models\Customer');
|
||||
}
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Customer extends BaseModel
|
||||
{
|
||||
protected $table = 'customer';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'customer.index', 'url' => 'customer/customer/index', 'name' => '客户档案'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\Gdoo\User\Models\User::class);
|
||||
}
|
||||
|
||||
public function region()
|
||||
{
|
||||
return $this->belongsTo(\Gdoo\Customer\Models\Region::class);
|
||||
}
|
||||
|
||||
public function contacts()
|
||||
{
|
||||
return $this->hasMany(\Gdoo\Customer\Models\Contact::class);
|
||||
}
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerApply extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_apply';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'customerApply.index', 'url' => 'customer/customerApply/index', 'name' => '开户申请'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'todo', 'name' => '待审'],
|
||||
['value' => 'end', 'name' => '已审'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerClass extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_class';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'customerClass.index', 'url' => 'customer/customerClass/index', 'name' => '客户分类'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerComplaint extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_complaint';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'complaint.index', 'url' => 'customer/complaint/index', 'name' => '投诉中心'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerPrice extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_price';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'price.index', 'url' => 'customer/price/index', 'name' => '客户销售价格'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerRegion extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_region';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'region.index', 'url' => 'customer/region/index', 'name' => '销售团队'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerRegionTask extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_region_task';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'regionTask.index', 'url' => 'customer/regionTask/index', 'name' => '区域任务'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerTask extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_task';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'task.index', 'url' => 'customer/task/index', 'name' => '客户任务'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerTax extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_tax';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'tax.index', 'url' => 'customer/tax/index', 'name' => '发票单位'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CustomerType extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_type';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'type.index', 'url' => 'customer/type/index', 'name' => '客户类型'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class DeliveryAddress extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_delivery_address';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'deliveryAddress.index', 'url' => 'customer/deliveryAddress/index', 'name' => '收货地址'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'enabled', 'name' => '启用'],
|
||||
['value' => 'disabled', 'name' => '禁用'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
protected $guarded = ['id', 'user_id'];
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php namespace Gdoo\Customer\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Region extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_region';
|
||||
|
||||
/**
|
||||
* 设置字段黑名单
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Customer\Region');
|
||||
}
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)
|
||||
->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
<?php namespace Gdoo\Customer\Services;
|
||||
|
||||
use DB;
|
||||
|
||||
class CustomerService
|
||||
{
|
||||
/**
|
||||
* 获取开票单位锁定金额
|
||||
*
|
||||
* @tax_id 开票单位id
|
||||
*/
|
||||
public static function getLockMoney($tax_id = 0)
|
||||
{
|
||||
return DB::select("select sum(money) money from (
|
||||
select a.order_id, {$tax_id} as tax_id, isnull(a.money, 0) - isnull(b.money, 0) as money
|
||||
from (
|
||||
SELECT sd.order_id, SUM(ISNULL(sd.money, 0)) money
|
||||
FROM customer_order_data sd
|
||||
LEFT JOIN customer_order sm ON sm.id = sd.order_id
|
||||
where isnull(sd.use_close, 0) = 0 and tax_id = {$tax_id}
|
||||
GROUP BY sd.order_id
|
||||
) as a
|
||||
left join (
|
||||
SELECT d.sale_id, ISNULL(sum(d.money), 0) money
|
||||
FROM stock_delivery_data d
|
||||
LEFT JOIN stock_delivery m ON d.delivery_id = m.id
|
||||
WHERE ISNULL(m.status, 0) = 1
|
||||
and d.sale_id in(select distinct a.id from customer_order a where tax_id = {$tax_id})
|
||||
group by d.sale_id
|
||||
) as b on a.order_id = b.sale_id
|
||||
where isnull(a.money, 0) - isnull(b.money, 0) > 0
|
||||
) a");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开票单位锁定金额
|
||||
*
|
||||
* @tax_id 开票单位id
|
||||
*/
|
||||
public static function getAccList($customer_id, $from_dt, $to_dt)
|
||||
{
|
||||
$start_dt = '2018-01-01';
|
||||
|
||||
$sql = "SUM(isnull(df, 0)) - SUM(isnull(jf, 0)) - SUM(isnull(bcsyfy, 0)) as qcye
|
||||
from (
|
||||
--费用部分
|
||||
select
|
||||
sum(case when b.is_cal=0 then d.money else null end) qtfy,--其他费用
|
||||
sum(case when b.is_cal=1 and ISNULL(a.adjust_type, 0)=0 and ISNULL(d.use_close,0)=0 then d.money else null end) xzfy,--本期新增费用
|
||||
sum(case when b.is_cal=1 and ISNULL(a.adjust_type, 0)=1 then d.money else null end) bcsyfy,
|
||||
0 as jf,
|
||||
0 as df, 0 as sl
|
||||
From customer_cost a --with (nolock)
|
||||
left join customer_cost_category b on a.category_id = b.id
|
||||
left join customer_cost_data d on a.id = d.cost_id
|
||||
left join customer c on c.id = d.customer_id
|
||||
left join model_bill t on t.id = d.src_type_id
|
||||
where a.category_id <> 1
|
||||
and a.status = 1
|
||||
and a.date < '$from_dt'
|
||||
and a.date >= '$start_dt'
|
||||
and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(不含费用使用部分)
|
||||
select null qtfy,null xzfy,null bcsyfy,sum(isnull(d.money,0)) as jf,0 as df,SUM(d.quantity) sl
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id = d.delivery_id
|
||||
left join product p on p.id = d.product_id
|
||||
left join customer_cost_category ccc on ccc.id = d.fee_category_id
|
||||
left join model_bill t on t.id= d.fee_src_type_id
|
||||
left join customer c on c.id = m.customer_id
|
||||
where m.invoice_dt < '$from_dt'
|
||||
and m.invoice_dt >= '$start_dt'
|
||||
and left(p.code, 2) <> '99'
|
||||
and m.status = 1 and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
select 0 qtfy, 0 xzfy, 0 bcsyfy,sum(isnull(d.money,0)) as jf,0 as df, SUM(d.quantity) sl
|
||||
from stock_direct m
|
||||
left join stock_direct_data d on m.id = d.direct_id
|
||||
left join product p on p.id = d.product_id
|
||||
left join customer c on c.id = m.customer_id
|
||||
where m.invoice_dt < '$from_dt'
|
||||
and m.invoice_dt >= '$start_dt'
|
||||
--and isnull(d.CustFreesrcBillCode,'')=''
|
||||
--and isnull(d.ApplyProCode,'')=''
|
||||
and left(p.code,2) <> '99'
|
||||
and m.status = 1 and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(使用客户费用部分)
|
||||
select null qtfy,null xzfy,SUM(d.money) bcsyfy,null as jf,0 as df,null as sl
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id=d.delivery_id
|
||||
left join customer_cost_category ccc on ccc.id = d.fee_category_id
|
||||
left join model_bill t on t.id = d.fee_src_type_id
|
||||
left join customer c on c.id = m.customer_id
|
||||
where m.invoice_dt < '$from_dt'
|
||||
and m.invoice_dt >= '$start_dt'
|
||||
and (isnull(d.fee_src_sn, '') <> '') and isnull(d.money, 0) < 0
|
||||
-- and (d.fee_category_id <> 6 or (d.fee_category_id =6 and d.fee_src_type_id =46))
|
||||
and m.status = 1 and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(使用促销申请赠品部分)
|
||||
select 0 qtfy,0 xzfy, SUM(0-d.money) bcsyfy, 0 as jf,0 as df,0 as sl
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id=d.delivery_id
|
||||
left join model_bill t on t.id = 17
|
||||
left join promotion p on p.sn = d.promotion_sn
|
||||
left join customer c on c.id = m.customer_id
|
||||
where m.invoice_dt < '$from_dt'
|
||||
and m.invoice_dt >= '$start_dt'
|
||||
and isnull(d.promotion_sn,'') <> ''
|
||||
and m.status = 1 and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
--退货申请单
|
||||
select 0 qtfy,0 xzfy,0 bcsyfy,sum(d.money) as jf,0 as df, SUM(d.quantity) sl
|
||||
from stock_cancel m
|
||||
left join stock_cancel_data d on m.id=d.cancel_id
|
||||
left join customer c on c.id = m.customer_id
|
||||
where m.invoice_dt < '$from_dt'
|
||||
and m.invoice_dt >= '$start_dt'
|
||||
and c.id = $customer_id
|
||||
) as a";
|
||||
$qcye = DB::query()->selectRaw($sql)->value('qcye');
|
||||
|
||||
// 发生额
|
||||
$sql = "2 orderNum, orderD,dDate,cdwcode,cdwname,cdwabbname,cdlcode,dgst,vtype,qtfy,xzfy,bcsyfy,jf,df,sl,0 ye,srcMasterBillType,srcMasterBID, tax_id
|
||||
from (
|
||||
--费用部分
|
||||
select 1 as orderD,
|
||||
a.date as dDate,
|
||||
c.code as cdwcode,c.name cdwname, c.name as cdwabbname, a.sn as cdlcode,
|
||||
case when isnull(d.src_sn,'') = '' then a.remark else concat(t.name, isnull(d.src_sn,'')) end as dgst,
|
||||
b.name as vtype,
|
||||
case when b.is_cal=0 then d.money else null end qtfy,--其他费用
|
||||
case when b.is_cal=1 and ISNULL(a.adjust_type,0)=0 and ISNULL(d.use_close,0)=0 then d.money else null end xzfy,--本期新增费用
|
||||
case when b.is_cal=1 and ISNULL(a.adjust_type,0)=1 then d.money else null end bcsyfy,
|
||||
0 as jf,
|
||||
null as df, null as sl,
|
||||
d.src_type_id as srcMasterBillType,
|
||||
d.src_id as srcMasterBID,
|
||||
null as tax_id
|
||||
from customer_cost a
|
||||
left join customer_cost_category b on a.category_id = b.id
|
||||
left join customer_cost_data d on a.id=d.cost_id
|
||||
left join customer c on c.id = d.customer_id
|
||||
left join model_bill t on t.id=d.src_type_id
|
||||
where a.category_id <> 1
|
||||
and a.status=1
|
||||
and a.date >= '$from_dt'
|
||||
and a.date >= '$start_dt'
|
||||
and a.date <= '$to_dt'
|
||||
and c.id = $customer_id
|
||||
|
||||
--促销申请部分(物资、赠品)
|
||||
union all
|
||||
select 1 as orderD,
|
||||
".sql_year_month_day('a.created_at', 'ts')." as dDate,
|
||||
c.code as cdwcode,c.name cdwname,c.name as cdwabbname, a.sn as cdlcode,
|
||||
concat('促销申请', case when a.type_id = 1 then '物资' else '赠品' end, a.sn) as dgst,
|
||||
'促销费' as vtype,
|
||||
0,--其他费用
|
||||
undertake_money as xzfy,--本期新增费用
|
||||
0 bcsyfy,
|
||||
0 as jf,
|
||||
0 as df, 0 as sl,
|
||||
17 as srcMasterBillType,
|
||||
a.id as srcMasterBID, a.tax_id
|
||||
from promotion a
|
||||
left join customer c on c.id = a.customer_id
|
||||
where a.status = 1 and a.type_id < 3 -- AND ISNULL(a.use_close, 0) = 0
|
||||
and ".sql_year_month_day('a.created_at', 'ts')." >= '$from_dt'
|
||||
and ".sql_year_month_day('a.created_at', 'ts')." >= '$start_dt'
|
||||
and ".sql_year_month_day('a.created_at', 'ts')." <= '$to_dt'
|
||||
and c.id = $customer_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(不含费用使用部分)
|
||||
select 3 as orderD,
|
||||
m.invoice_dt as dDate,
|
||||
c.code as cdwcode,c.name as cdwname,c.name as cdwabbname,m.sn as cdlcode,
|
||||
'发货' as dgst,
|
||||
'发货单' as vtype,
|
||||
0 qtfy,
|
||||
0 xzfy,
|
||||
0 bcsyfy,
|
||||
sum(isnull(d.money,0)) as jf,0 as df,
|
||||
SUM(d.quantity) sl,
|
||||
43 as srcMasterBillType,
|
||||
m.id as srcMasterBID,
|
||||
m.tax_id
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id=d.delivery_id
|
||||
left join product p on p.id=d.product_id
|
||||
left join customer_cost_category ccc on ccc.id = d.fee_category_id
|
||||
left join customer c on c.id=m.customer_id
|
||||
left join model_bill t on t.id=d.fee_src_type_id
|
||||
where m.invoice_dt >= '$from_dt' and
|
||||
m.invoice_dt <= '$to_dt' and
|
||||
m.invoice_dt >= '$start_dt' and
|
||||
left(p.code,2)<>'99' and
|
||||
m.status >=1 and
|
||||
c.id = $customer_id
|
||||
group by m.invoice_dt,c.code,c.name,m.sn,m.id,m.tax_id
|
||||
|
||||
UNION ALL
|
||||
|
||||
--发货单(不含费用使用部分-直营)
|
||||
select 3 as orderD,
|
||||
m.invoice_dt as dDate,
|
||||
c.code as cdwcode,c.name as cdwname,c.name as cdwabbname,m.sn as cdlcode,
|
||||
'发货' as dgst,
|
||||
'直营发货单' as vtype,
|
||||
0 qtfy,
|
||||
0 xzfy,
|
||||
0 bcsyfy,
|
||||
sum(isnull(d.money,0)) as jf,0 as df,
|
||||
SUM(d.quantity) sl,
|
||||
65 as srcMasterBillType,
|
||||
m.id as srcMasterBID,
|
||||
m.tax_id
|
||||
from stock_direct m
|
||||
left join stock_direct_data d on m.id = d.direct_id
|
||||
left join product p on p.id=d.product_id
|
||||
left join customer c on c.id=m.customer_id
|
||||
where m.invoice_dt >= '$from_dt' and
|
||||
m.invoice_dt <= '$to_dt' and
|
||||
m.invoice_dt >= '$start_dt' and
|
||||
left(p.code,2)<>'99' and
|
||||
m.status = 1 and
|
||||
c.id = $customer_id
|
||||
group by m.invoice_dt,c.code,c.name,m.sn,m.id,m.tax_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(使用客户费用部分)
|
||||
select 4 as orderD,
|
||||
m.invoice_dt as dDate,
|
||||
c.code as cdwcode,c.name as cdwname,c.name as cdwabbname,m.sn as cdlcode,
|
||||
concat('发货使用', t.name, isnull(d.fee_src_sn,'')) as dgst,
|
||||
'发货单' as vtype,
|
||||
0 qtfy,
|
||||
0 xzfy,
|
||||
SUM(d.money) bcsyfy,
|
||||
0 as jf,0 as df,0 as sl,
|
||||
d.fee_src_type_id as srcMasterBillType,
|
||||
d.fee_src_id as srcMasterBID,
|
||||
m.tax_id
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id = d.delivery_id
|
||||
left join customer_cost_category ccc on ccc.ID = d.fee_category_id
|
||||
left join model_bill t on t.id = d.fee_src_type_id
|
||||
left join customer c on c.id=m.customer_id
|
||||
where m.invoice_dt >= '$from_dt' and
|
||||
m.invoice_dt <= '$to_dt' and
|
||||
m.invoice_dt >= '$start_dt' and
|
||||
(isnull(d.fee_src_sn,'') <> '') and isnull(d.money, 0) < 0 and
|
||||
m.status>=1 and
|
||||
c.id = $customer_id
|
||||
group by m.invoice_dt,c.code,c.name,m.sn,d.fee_src_type_id,d.fee_src_id,d.fee_src_sn,t.name,c.name,m.tax_id
|
||||
|
||||
union all
|
||||
|
||||
--发货单(使用促销申请赠品部分)
|
||||
select 4 as orderD,
|
||||
m.invoice_dt as dDate,
|
||||
c.code as cdwcode,c.name as cdwname,c.name as cdwabbname,m.sn as cdlcode,
|
||||
concat('发货使用', t.name, '赠品', isnull(d.fee_src_sn,'')) as dgst,
|
||||
'发货单' as vtype,
|
||||
0 qtfy,
|
||||
0 xzfy,
|
||||
SUM(0 - d.money) bcsyfy,
|
||||
0 as jf,0 as df,0 as sl,
|
||||
t.id as srcMasterBillType,
|
||||
p.id as srcMasterBID,
|
||||
m.tax_id
|
||||
from stock_delivery m
|
||||
left join stock_delivery_data d on m.id=d.delivery_id
|
||||
left join model_bill t on t.id = 17
|
||||
left join promotion p on p.sn=d.promotion_sn
|
||||
left join customer c on c.id=m.customer_id
|
||||
where m.invoice_dt >= '$from_dt' and
|
||||
m.invoice_dt <= '$to_dt' and
|
||||
m.invoice_dt >= '$start_dt' and
|
||||
isnull(d.promotion_sn,'')<>'' and
|
||||
m.status>=1 and
|
||||
c.id = $customer_id
|
||||
group by m.invoice_dt,c.code,c.name,m.sn,t.id,p.id,d.promotion_sn,t.name,d.fee_src_sn,m.tax_id
|
||||
|
||||
union all
|
||||
|
||||
--退货申请单
|
||||
select 4 as orderD,
|
||||
m.invoice_dt as dDate,
|
||||
c.code as cdwcode,c.name as cdwname,c.name as cdwabbname,m.sn as cdlcode,
|
||||
'退货' as dgst,
|
||||
'退货申请单' as vtype,
|
||||
0 qtfy,
|
||||
0 xzfy,
|
||||
0 bcsyfy,
|
||||
sum(d.money) as jf,
|
||||
0 as df,
|
||||
SUM(d.quantity) sl,
|
||||
47 as srcMasterBillType,
|
||||
m.id as srcMasterBID,
|
||||
m.tax_id
|
||||
from stock_cancel m
|
||||
left join stock_cancel_data d on m.id=d.cancel_id
|
||||
left join customer c on c.id=m.customer_id
|
||||
where m.invoice_dt >= '$from_dt' and
|
||||
m.invoice_dt <= '$to_dt' and
|
||||
m.invoice_dt >= '$start_dt' and
|
||||
c.id = $customer_id
|
||||
group by m.invoice_dt,c.code,c.name,m.sn,m.id,m.tax_id
|
||||
) as a";
|
||||
$items = DB::query()->selectRaw($sql)->get();
|
||||
|
||||
$rows = [[
|
||||
'orderNum' => 1,
|
||||
'orderD' => '',
|
||||
'dDate' => '', // 日期
|
||||
'cdwcode' => '', // 客户编码
|
||||
'cdwname' => '', // 客户
|
||||
'cdwabbname' => '',
|
||||
'cdlcode' => '', // 单据号
|
||||
'dgst' => '期初余额', // 摘要
|
||||
'srcMasterBillType' => '', // 单据类型ID
|
||||
'srcMasterBID' => '', // 单据ID
|
||||
'vtype' => '', // 单据
|
||||
'qtfy' => 0, // 其他费用
|
||||
'xzfy' => 0, // 本次新增费用
|
||||
'bcsyfy' => 0, // 其中使用费用金额
|
||||
'jf' => 0, // 发货总金额
|
||||
'sl' => 0, // 发货数量
|
||||
'df' => 0, // 收款金额
|
||||
'ye' => $qcye, // 余额
|
||||
'tax_id' => ''
|
||||
]];
|
||||
|
||||
$ye = $qcye;
|
||||
|
||||
foreach($items as $item) {
|
||||
|
||||
$item['qtfy'] = (float)$item['qtfy'];
|
||||
$item['xzfy'] = (float)$item['xzfy'];
|
||||
$item['bcsyfy'] = (float)$item['bcsyfy'];
|
||||
$item['jf'] = (float)$item['jf'];
|
||||
$item['df'] = (float)$item['df'];
|
||||
$item['sl'] = (float)$item['sl'];
|
||||
|
||||
$ye = $ye + ($item['df'] - $item['jf'] - $item['bcsyfy']);
|
||||
|
||||
$rows[] = [
|
||||
'orderNum' => 2,
|
||||
'orderD' => $item['orderD'],
|
||||
'dDate' => $item['dDate'],
|
||||
'cdwcode' => $item['cdwcode'],
|
||||
'cdwname' => $item['cdwname'],
|
||||
'cdwabbname' => $item['cdwabbname'],
|
||||
'cdlcode' => $item['cdlcode'],
|
||||
'dgst' => $item['dgst'],
|
||||
'srcMasterBillType' => $item['srcMasterBillType'],
|
||||
'srcMasterBID' => $item['srcMasterBID'],
|
||||
'vtype' => $item['vtype'],
|
||||
'qtfy' => $item['qtfy'],
|
||||
'xzfy' => $item['xzfy'],
|
||||
'bcsyfy' => $item['bcsyfy'],
|
||||
'jf' => $item['jf'],
|
||||
'sl' => $item['sl'],
|
||||
'df' => $item['df'],
|
||||
'ye' => $ye,
|
||||
'tax_id' => $item['tax_id']
|
||||
];
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "客户管理",
|
||||
"version" => "1.0",
|
||||
"description" => "潜在客户资料上传,通过手机客户端收集客户资料。",
|
||||
'dialogs' => [
|
||||
'customer_price' => [
|
||||
'name' => '客户销售价格',
|
||||
'model' => 'Gdoo\Customer\Models\Price::Dialog',
|
||||
'url' => 'customer/price/dialog',
|
||||
],
|
||||
'customer_region' => [
|
||||
'name' => '销售团队',
|
||||
'model' => 'Gdoo\Customer\Models\Region::Dialog',
|
||||
'url' => 'customer/region/dialog',
|
||||
],
|
||||
'customer' => [
|
||||
'name' => '客户',
|
||||
'model' => 'Gdoo\Customer\Models\Customer::Dialog',
|
||||
'url' => 'customer/customer/dialog',
|
||||
],
|
||||
'customer_contact' => [
|
||||
'name' => '客户联系人',
|
||||
'model' => 'Gdoo\Customer\Models\Contact::Dialog',
|
||||
'url' => 'customer/contact/dialog',
|
||||
],
|
||||
'customer_type' => [
|
||||
'name' => '客户类型',
|
||||
'model' => 'Gdoo\Customer\Models\CustomerType::Dialog',
|
||||
'url' => 'customer/type/dialog',
|
||||
],
|
||||
'customer_tax' => [
|
||||
'name' => '客户发票单位',
|
||||
'model' => 'Gdoo\Customer\Models\CustomerTax::Dialog',
|
||||
'url' => 'customer/tax/dialog',
|
||||
],
|
||||
'customer_delivery_address' => [
|
||||
'name' => '客户收货地址',
|
||||
'model' => 'Gdoo\Customer\Models\DeliveryAddress::Dialog',
|
||||
'url' => 'customer/deliveryAddress/dialog',
|
||||
],
|
||||
'customer_class' => [
|
||||
'name' => '客户分类',
|
||||
'model' => 'Gdoo\Customer\Models\CustomerClass::Dialog',
|
||||
'url' => 'customer/customerClass/dialog',
|
||||
],
|
||||
],
|
||||
'widgets' => [
|
||||
'widget_customer_birthday' => [
|
||||
'name' => '客户生日',
|
||||
'type' => 1,
|
||||
'url' => 'customer/widget/birthday',
|
||||
'more_url' => 'customer/customer/birthday',
|
||||
],
|
||||
],
|
||||
"listens" => [
|
||||
'customer' => 'Gdoo\Customer\Hooks\CustomerHook',
|
||||
'customer_contact' => 'Gdoo\Customer\Hooks\ContactHook',
|
||||
'customer_tax' => 'Gdoo\Customer\Hooks\TaxHook',
|
||||
'customer_price' => 'Gdoo\Customer\Hooks\PriceHook',
|
||||
'customer_region' => 'Gdoo\Customer\Hooks\RegionHook',
|
||||
'customer_delivery_address' => 'Gdoo\Customer\Hooks\DeliveryAddressHook',
|
||||
'customer_apply' => 'Gdoo\Customer\Hooks\CustomerApplyHook',
|
||||
'customer_task_data' => 'Gdoo\Customer\Hooks\CustomerTaskDataHook',
|
||||
],
|
||||
"controllers" => [
|
||||
"customer" => [
|
||||
"name" => "客户档案",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"batchEdit" => [
|
||||
"name" => "批量编辑"
|
||||
],
|
||||
"priceEdit" => [
|
||||
"name" => "销售产品价格"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"import" => [
|
||||
"name" => "导入"
|
||||
],
|
||||
]
|
||||
],
|
||||
"type" => [
|
||||
"name" => "客户类型",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"customerClass" => [
|
||||
"name" => "客户分类",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"region" => [
|
||||
"name" => "销售团队",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"tax" => [
|
||||
"name" => "开票单位",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"batchEdit" => [
|
||||
"name" => "批量编辑"
|
||||
],
|
||||
]
|
||||
],
|
||||
"contact" => [
|
||||
"name" => "客户联系人",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"task" => [
|
||||
"name" => "客户任务",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"progress" => [
|
||||
"name" => "任务进度"
|
||||
],
|
||||
]
|
||||
],
|
||||
"regionTask" => [
|
||||
"name" => "区域任务",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"progress" => [
|
||||
"name" => "任务进度"
|
||||
],
|
||||
]
|
||||
],
|
||||
"business" => [
|
||||
"name" => "客户商机",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"sms" => [
|
||||
"name" => "短信"
|
||||
],
|
||||
"destroy" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"price" => [
|
||||
"name" => "客户销售价格",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"import" => [
|
||||
"name" => "导入"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"customerApply" => [
|
||||
"name" => "开户申请",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"recall" => [
|
||||
"name" => "撤回"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
]
|
||||
],
|
||||
"complaint" => [
|
||||
"name" => "投诉中心",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"recall" => [
|
||||
"name" => "撤回"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"deliveryAddress" => [
|
||||
"name" => "收货地址",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
"accountReport" => [
|
||||
"name" => "客户对账单",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "客户对账单"
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,149 @@
|
||||
<div class="panel no-border" id="material_plan-controller">
|
||||
|
||||
<div class="wrapper-sm">
|
||||
@include('searchForm7')
|
||||
<a class="btn btn-sm btn-default" data-toggle="material_plan" data-action="filter"><i class="fa fa-search"></i> 筛选</a>
|
||||
<a class="btn btn-sm btn-default" data-toggle="material_plan" data-action="export"><i class="fa fa-share"></i> 导出</a>
|
||||
</div>
|
||||
|
||||
<div class='list-jqgrid'>
|
||||
<div id="material_plan-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.ag-row {
|
||||
display:table;
|
||||
}
|
||||
.rowspan {
|
||||
background-color: #fff;
|
||||
top: -1px;
|
||||
border-top: 1px solid #d9dcde !important;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.rowspan_end {
|
||||
border-bottom: 1px solid #d9dcde !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var searchOpen = false;
|
||||
var table = 'material_plan';
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var cols = [
|
||||
{field: "sn", cellClass: "text-center", suppressSizeToFit: true, headerName: "", type: 'sn', width: 40},
|
||||
{field: "dDate", headerName: "日期", sortable: false, suppressMenu: true, cellClass: "text-center", width: 100},
|
||||
{field: "cdwname", headerName: "客户名称", sortable: false, suppressMenu: true, cellClass: "text-center", width: 180},
|
||||
{field: "tax_name", headerName: "开票单位", sortable: false, suppressMenu: true, cellClass: "text-center", width: 180},
|
||||
{field: "cdlcode", headerName: "单据编号", sortable: false, suppressMenu: true, cellClass: "text-center", width: 120},
|
||||
{field: "vtype", headerName: "单据类型", sortable: false, suppressMenu: true, cellClass: "text-center", width: 120},
|
||||
{field: "dgst", headerName: "摘要", sortable: false, suppressMenu: true, cellClass: "text-left", minWidth: 200},
|
||||
{field: "qtfy", headerName: "其他费用", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "xzfy", headerName: "本次新增费用", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "sl", headerName: "发货数量", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "jf", headerName: "发货总金额", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "bcsyfy", headerName: "使用费用金额", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "df", headerName: "收款金额", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
{field: "ye", headerName: "余额", type: "number", sortable: false, suppressMenu: true, cellClass: "text-right", width: 120},
|
||||
];
|
||||
|
||||
var grid = new agGridOptions();
|
||||
grid.suppressRowTransform = true;
|
||||
var gridDiv = document.querySelector("#material_plan-grid");
|
||||
gridDiv.style.height = getPanelHeight(12);
|
||||
|
||||
grid.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
var data = params.data;
|
||||
if (data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (data.srcMasterBID > 0) {
|
||||
var key = data.url.replace(/\//g,'_');
|
||||
top.addTab(data.url + '?id=' + data.srcMasterBID, key, data.app_name);
|
||||
}
|
||||
};
|
||||
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = search.query;
|
||||
grid.columnDefs = cols;
|
||||
grid.rowSelection = 'single';
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#material_plan-search-form-advanced");
|
||||
search.searchForm({
|
||||
data: data,
|
||||
advanced: 1,
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#material_plan-controller').on('click', '[data-toggle="material_plan"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'filter') {
|
||||
searchBox();
|
||||
}
|
||||
if (data.action == 'export') {
|
||||
LocalExport(grid, '客户对账单');
|
||||
}
|
||||
});
|
||||
|
||||
var searchBox = function() {
|
||||
$(search).dialog({
|
||||
title: '筛选条件',
|
||||
modalClass: 'no-padder',
|
||||
buttons: [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text: "确定",
|
||||
'class': "btn-info",
|
||||
click: function() {
|
||||
var data = search.serializeArray();
|
||||
var params = {};
|
||||
search.queryType = 'advanced';
|
||||
$.map(data, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
params['page'] = 1;
|
||||
grid.remoteData(params);
|
||||
$(this).dialog("close");
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
if (searchOpen == false) {
|
||||
searchBox();
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,73 @@
|
||||
<div class="panel">
|
||||
|
||||
<div class="wrapper">
|
||||
@include('business/query')
|
||||
</div>
|
||||
|
||||
<form method="post" id="myform" name="myform">
|
||||
<div class="table-responsive">
|
||||
<table class="table b-t table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input type="checkbox" class="select-all">
|
||||
</th>
|
||||
<th align="left">客户名称</th>
|
||||
<th align="left">地区</th>
|
||||
<th align="left">资料来源</th>
|
||||
<th>客户类型</th>
|
||||
<th>联系人</th>
|
||||
<th align="center">联系人手机</th>
|
||||
<th>渠道说明</th>
|
||||
<th>产品说明</th>
|
||||
<th>合作说明</th>
|
||||
<th>补充说明</th>
|
||||
<th align="center">名片</th>
|
||||
<th>创建者</th>
|
||||
<th>{{url_order($search,'created_at','日期')}}</th>
|
||||
<th align="center">{{url_order($search,'id','ID')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@if($rows)
|
||||
@foreach($rows as $row)
|
||||
<tr>
|
||||
<td align="center"><input type="checkbox" class="select-row" value="{{$row['id']}}" name="id[]"></td>
|
||||
<td align="left">{{$row->name}}</td>
|
||||
<td align="left" nowrap="true">{{$row->address}}</td>
|
||||
<td align="left">{{$row->source}}</td>
|
||||
<td align="center">{{$row->type}}</td>
|
||||
<td align="center">{{$row->contacts}}</td>
|
||||
<td align="center">{{$row->contacts_phone}}</td>
|
||||
|
||||
<td align="left">{{$row->text_1}}</td>
|
||||
<td align="left">{{$row->text_2}}</td>
|
||||
<td align="left">{{$row->text_3}}</td>
|
||||
<td align="left">{{$row->description}}</td>
|
||||
<td align="center">
|
||||
<button type="button" class="option" data-toggle="dialog-image" data-url="{{url('index/attachment/show',['id'=>$row->attachment])}}" data-title="名片预览">名片</button>
|
||||
</td>
|
||||
<td align="center">{{get_user($row->created_id, 'name')}}</td>
|
||||
|
||||
<td align="center">@datetime($row->created_at)</td>
|
||||
|
||||
<td align="center">{{$row->id}}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,29 @@
|
||||
<form id="search-form" class="form-inline" name="mysearch" action="{{url()}}" method="get">
|
||||
|
||||
<div class="pull-right">
|
||||
@if(isset($access['destroy']))
|
||||
<button type="button" onclick="optionDelete('#myform','{{url('destroy')}}');" class="btn btn-sm btn-danger"><i class="icon icon-remove"></i> 删除</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if(isset($access['add']))
|
||||
<a href="{{url('add')}}" class="btn btn-sm btn-info"><i class="icon icon-plus"></i> 新建</a>
|
||||
@endif
|
||||
|
||||
@include('searchForm')
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#search-form').searchForm({
|
||||
data:{{json_encode($search['forms'])}},
|
||||
init:function(e) {
|
||||
var self = this;
|
||||
e.post = function(i) {
|
||||
self._select({{search_select($types)}}, i);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
|
||||
<div class="alert alert-info alert-dismissable m-b-sm text-sm">
|
||||
本投诉表适用于公司产品质量、售后服务及其他方面的投诉,金额超过1000元的投诉由营销中心客服部打印单据交由副总经理审批。
|
||||
</div>
|
||||
|
||||
{{$form['tpl']}}
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var form_action = '{{$form["action"]}}';
|
||||
(function ($) {
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.customer_task_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
// options.autoColumnsToFit = false;
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1 @@
|
||||
{{$form['tpl']}}
|
||||
@@ -0,0 +1,131 @@
|
||||
<div class="panel b-a" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var search = JSON.parse('{{json_encode($header["search_form"])}}');
|
||||
var columns = [];
|
||||
var params = search.query;
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
|
||||
grid.defaultColDef.suppressMenu = true;
|
||||
grid.defaultColDef.sortable = true;
|
||||
grid.defaultColDef.filter = false;
|
||||
grid.autoColumnsToFit = false;
|
||||
grid.singleClickEdit = true;
|
||||
grid.rowSelection = 'single';
|
||||
grid.suppressCellSelection = false;
|
||||
|
||||
grid.defaultColDef.cellStyle = function(params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
var style = {};
|
||||
var field = params.colDef.field;
|
||||
if (params.data.status == '0' && (field == "customer_code" || field == "customer_name")) {
|
||||
style = {'color':'red'};
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', field: 'sn', type: 'sn', headerName: '序号', width: 50},
|
||||
{cellClass:'text-center', field: 'region_name', headerName: '区域', width: 100},
|
||||
{cellClass:'text-center', field: 'customer_code', headerName: '客户编码', width: 80},
|
||||
{cellClass:'text-left', field: 'customer_name', headerName: '客户名称', width: 180},
|
||||
{cellClass:'text-right', field: 'total_task', headerName: '总任务', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_money', headerName: '累计销售', width: 80, type:'number', numberOptions: {places:4}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_rate', headerName: '总进度', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
];
|
||||
|
||||
for(var i=1; i <= 12;i++) {
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: i + '月',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'month' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'month_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'month_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
for(var i=1; i <= 4;i++) {
|
||||
var dx = {
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
};
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: dx[i] + '季度',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'quarter_' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'quarter_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'quarter_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
gridDiv.style.height = getPanelHeight(12);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
var search_advanced = $('#' + table + '-search-form-advanced').searchForm({
|
||||
data: search.forms,
|
||||
advanced: true,
|
||||
});
|
||||
|
||||
gdoo.grids[table] = {grid: grid};
|
||||
|
||||
var action = new gridAction(table, '客户销售进度');
|
||||
var panel = $('#' + table + '-controller');
|
||||
|
||||
panel.on('click', '[data-toggle="' + table + '"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'filter') {
|
||||
// 过滤数据
|
||||
$('#' + table + '-search-form-advanced').dialog({
|
||||
title: '条件筛选',
|
||||
modalClass: 'no-padder',
|
||||
buttons: [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text: "确定",
|
||||
'class': "btn-info",
|
||||
click: function() {
|
||||
var query = search_advanced.serializeArray();
|
||||
params = {};
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(params);
|
||||
$(this).dialog("close");
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
if (data.action == 'export') {
|
||||
action.export(data, '客户销售进度');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,116 @@
|
||||
<div class="padder">
|
||||
<div class="m-t-sm m-b-sm">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
var grid = new agGridOptions();
|
||||
var selectedData = {};
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = {};
|
||||
//grid.rowMultiSelectWithClick = multiple;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: multiple, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{suppressMenu: true, cellClass:'text-center', sortable: false, field: 'name', headerName: '姓名', minWidth: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'phone', headerName: '手机', width: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 80}
|
||||
];
|
||||
|
||||
grid.onRowClicked1 = function(row) {
|
||||
var id = row.data[sid];
|
||||
if (selectedData[id]) {
|
||||
delete selectedData[id];
|
||||
row.node.setSelected(false);
|
||||
} else {
|
||||
if (multiple == false) {
|
||||
selectedData = {};
|
||||
}
|
||||
selectedData[id] = row.data.name;
|
||||
}
|
||||
writeSelected();
|
||||
};
|
||||
|
||||
grid.onSelectionChanged = function() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
selectedData = {};
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
selectedData[row.id] = row.name;
|
||||
}
|
||||
writeSelected();
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
grid.onRowClicked(row);
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
};
|
||||
|
||||
function initSelected() {
|
||||
selectedData = {};
|
||||
var id = $('#'+params.id).val();
|
||||
var text = $('#'+params.id+'_text').val();
|
||||
if (id && text) {
|
||||
id = id.split(',');
|
||||
text = text.split(',');
|
||||
for (var i = 0; i < id.length; i++) {
|
||||
selectedData[id[i]] = text[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeSelected() {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(selectedData, function(k, v) {
|
||||
id.push(k);
|
||||
text.push(v);
|
||||
});
|
||||
$('#'+params.id).val(id.join(','));
|
||||
$('#'+params.id+'_text').val(text.join(','));
|
||||
}
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
grid.api.forEachNode(function(node) {
|
||||
// 默认选中
|
||||
$.each(selectedData, function(k, v) {
|
||||
if (node.data[sid] == k) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,59 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,14 @@
|
||||
<style>
|
||||
body {
|
||||
background-color: #f0f3f4;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading b-b">
|
||||
<div class="text-sm"><i class="fa text-md fa-list-alt"></i> 职位</div>
|
||||
</div>
|
||||
<div class="form-controller">
|
||||
{{$header['tpl']}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,42 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
|
||||
@if($taxs)
|
||||
<div class="panel m-t-sm">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th align="left">开票名称</th>
|
||||
<th align="center">开票编号</th>
|
||||
<th align="center">纳税人识别号</th>
|
||||
<th align="center">开户银行</th>
|
||||
<th align="center">银行帐号</th>
|
||||
<th align="center">状态</th>
|
||||
</tr>
|
||||
@foreach($taxs as $tax)
|
||||
<tr>
|
||||
<td>{{$tax['name']}}</td>
|
||||
<td align="center">{{$tax['code']}}</td>
|
||||
<td align="center">{{$tax['tax_number']}}</td>
|
||||
<td align="center">{{$tax['bank_name']}}</td>
|
||||
<td align="center">{{$tax['bank_account']}}</td>
|
||||
<td align="center">@if($tax['status'] == '1') 生效 @else 草稿 @endif</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
</script>
|
||||
@@ -0,0 +1,132 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline search-inline-form" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var grid = new agGridOptions();
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.suppressRowClickSelection = true;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: multiple, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{suppressMenu: true, cellClass:'text-left', sortable: false, field: 'name', headerName: '客户名称', minWidth: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'code', headerName: '客户编码', width: 60},
|
||||
{suppressMenu: true, cellClass:'text-center', cellRenderer: statusRenderer, field: 'status', headerName: '状态', width: 60},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
function statusRenderer(row) {
|
||||
if (row.value == 0) {
|
||||
return '<span style="color:red">禁用</span>';
|
||||
}
|
||||
if (row.value == 1) {
|
||||
return '启用';
|
||||
}
|
||||
}
|
||||
|
||||
grid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
var ret = writeSelected();
|
||||
if (ret == true) {
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化选择
|
||||
*/
|
||||
function initSelected() {
|
||||
if (params.is_grid) {
|
||||
} else {
|
||||
var rows = {};
|
||||
var id = $('#'+option.id).val();
|
||||
if (id) {
|
||||
var ids = id.split(',');
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
rows[ids[i]] = ids[i];
|
||||
}
|
||||
}
|
||||
grid.api.forEachNode(function(node) {
|
||||
var key = node.data[sid];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入选中
|
||||
*/
|
||||
function writeSelected() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (params.is_grid) {
|
||||
var list = gdoo.forms[params.form_id];
|
||||
list.api.dialogSelected(params);
|
||||
} else {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(rows, function(k, row) {
|
||||
id.push(row[sid]);
|
||||
text.push(row.name);
|
||||
});
|
||||
$('#'+option.id).val(id.join(','));
|
||||
$('#'+option.id+'_text').val(text.join(','));
|
||||
|
||||
if (event.exist('onSelect')) {
|
||||
return event.trigger('onSelect', multiple ? rows : rows[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
grid.writeSelected = writeSelected;
|
||||
gdoo.dialogs[option.id] = grid;
|
||||
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,88 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
action.priceEdit = function() {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var selections = grid.api.getSelectedRows();
|
||||
var ids = [];
|
||||
$.each(selections, function(i, selection) {
|
||||
ids.push(selection.master_id);
|
||||
});
|
||||
if (ids.length > 0) {
|
||||
formDialog({
|
||||
title: '销售产品价格',
|
||||
dialogClass: 'modal-sm',
|
||||
id: 'price-edit-form',
|
||||
url: app.url(me.bill_url + '/priceEdit', {ids: ids.join(',')}),
|
||||
success: function(res) {
|
||||
toastrSuccess(res.data);
|
||||
grid.remoteData();
|
||||
$(this).dialog("close");
|
||||
},
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastrError('最少选择一行记录。');
|
||||
}
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.autoColumnsToFit = false;
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,15 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="price-edit-form" action="{{url()}}" method="post">
|
||||
<div class="form-group m-b-xs">
|
||||
<div class="select-group input-group">
|
||||
<input class="form-control input-sm" placeholder="请选择产品" data-toggle="dialog-view" readonly="readonly" data-title="产品" data-url="product/product/dialog" data-id="product_id" data-multi="0" style="min-width:153px;cursor:pointer;" id="product_id_text">
|
||||
<input type="hidden" id="product_id" name="product_id">
|
||||
<div class="input-group-btn"><a data-toggle="dialog-clear" data-id="product_id" class="btn btn-sm btn-default"><i class="fa fa-times"></i></a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-b-none">
|
||||
<input name="price" autocomplete="off" placeholder="请输入销售价格" class="form-control input-sm">
|
||||
</div>
|
||||
<input name="ids" type="hidden" value="{{$gets['ids']}}">
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
gdoo.event.set('grid.customer_apply_brand', {
|
||||
ready(me) {
|
||||
me.dataKey = 'sale_money';
|
||||
me.suppressContextMenu = false;
|
||||
}
|
||||
});
|
||||
|
||||
gdoo.event.set('grid.customer_apply_grid', {
|
||||
ready(me) {
|
||||
me.dataKey = 'sale_quantity';
|
||||
me.suppressContextMenu = false;
|
||||
}
|
||||
});
|
||||
|
||||
gdoo.event.set('grid.customer_apply_category', {
|
||||
ready(me) {
|
||||
me.dataKey = 'category_id';
|
||||
me.suppressContextMenu = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.autoColumnsToFit = false;
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,3 @@
|
||||
<form class="form-horizontal form-controller" method="post" id="customer_class" name="customer_class">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
@@ -0,0 +1,122 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline" method="get">
|
||||
@include('searchForm6')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
var grid = new agGridOptions();
|
||||
var selectedData = {};
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.suppressRowClickSelection = true;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: false, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{suppressMenu: true, field: 'name', headerName: '名称', width: 100},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'code', headerName: '编码', width: 80},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
grid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
var ret = writeSelected();
|
||||
if (ret == true) {
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化选择
|
||||
*/
|
||||
function initSelected() {
|
||||
if (params.is_grid) {
|
||||
} else {
|
||||
var rows = {};
|
||||
var id = $('#'+option.id).val();
|
||||
if (id) {
|
||||
var ids = id.split(',');
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
rows[ids[i]] = ids[i];
|
||||
}
|
||||
}
|
||||
grid.api.forEachNode(function(node) {
|
||||
var key = node.data[sid];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入选中
|
||||
*/
|
||||
function writeSelected() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (params.is_grid) {
|
||||
var list = gdoo.forms[params.form_id];
|
||||
list.api.dialogSelected(params);
|
||||
} else {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(rows, function(k, row) {
|
||||
id.push(row[sid]);
|
||||
text.push(row.name);
|
||||
});
|
||||
$('#'+option.id).val(id.join(','));
|
||||
$('#'+option.id+'_text').val(text.join(','));
|
||||
|
||||
if (event.exist('onSelect')) {
|
||||
return event.trigger('onSelect', multiple ? rows : rows[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
grid.writeSelected = writeSelected;
|
||||
gdoo.dialogs[option.id] = grid;
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,64 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['table']}}-grid" class="ag-theme-balham"></div>
|
||||
<div class="ag-theme-balham" id="ag-pagination"></div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var grid = new agGridOptions();
|
||||
|
||||
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(11);
|
||||
|
||||
config.cols[0]['hide'] = true;
|
||||
config.cols[1]['hide'] = true;
|
||||
grid.autoGroupColumnDef = {
|
||||
headerName: '名称',
|
||||
width: 250,
|
||||
cellRendererParams: {
|
||||
checkbox: true,
|
||||
suppressCount: false,
|
||||
}
|
||||
};
|
||||
grid.treeData = true;
|
||||
grid.groupDefaultExpanded = -1;
|
||||
grid.getDataPath = function(data) {
|
||||
return data.tree_path;
|
||||
};
|
||||
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = search.advanced.query;
|
||||
grid.columnDefs = config.cols;
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
|
||||
config.grid = grid;
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
@@ -0,0 +1,116 @@
|
||||
<div class="padder">
|
||||
<div class="m-t-sm m-b-sm">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
var grid = new agGridOptions();
|
||||
var selectedData = {};
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = {};
|
||||
//grid.rowMultiSelectWithClick = multiple;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: multiple, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{suppressMenu: true, cellClass:'text-center', sortable: false, field: 'name', headerName: '姓名', minWidth: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'phone', headerName: '手机', width: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 80}
|
||||
];
|
||||
|
||||
grid.onRowClicked1 = function(row) {
|
||||
var id = row.data[sid];
|
||||
if (selectedData[id]) {
|
||||
delete selectedData[id];
|
||||
row.node.setSelected(false);
|
||||
} else {
|
||||
if (multiple == false) {
|
||||
selectedData = {};
|
||||
}
|
||||
selectedData[id] = row.data.name;
|
||||
}
|
||||
writeSelected();
|
||||
};
|
||||
|
||||
grid.onSelectionChanged = function() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
selectedData = {};
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
selectedData[row.id] = row.name;
|
||||
}
|
||||
writeSelected();
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
grid.onRowClicked(row);
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
};
|
||||
|
||||
function initSelected() {
|
||||
selectedData = {};
|
||||
var id = $('#'+params.id).val();
|
||||
var text = $('#'+params.id+'_text').val();
|
||||
if (id && text) {
|
||||
id = id.split(',');
|
||||
text = text.split(',');
|
||||
for (var i = 0; i < id.length; i++) {
|
||||
selectedData[id[i]] = text[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeSelected() {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(selectedData, function(k, v) {
|
||||
id.push(k);
|
||||
text.push(v);
|
||||
});
|
||||
$('#'+params.id).val(id.join(','));
|
||||
$('#'+params.id+'_text').val(text.join(','));
|
||||
}
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
grid.api.forEachNode(function(node) {
|
||||
// 默认选中
|
||||
$.each(selectedData, function(k, v) {
|
||||
if (node.data[sid] == k) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,59 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
//action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,14 @@
|
||||
<style>
|
||||
body {
|
||||
background-color: #f0f3f4;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading b-b">
|
||||
<div class="text-sm"><i class="fa text-md fa-list-alt"></i> 职位</div>
|
||||
</div>
|
||||
<div class="form-controller">
|
||||
{{$header['tpl']}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,138 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
|
||||
<a href="javascript:referCustomerDialog();" class="btn btn-sm btn-default">
|
||||
参照价格
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
<div class="panel">
|
||||
{{$form['tpl']}}
|
||||
</div>
|
||||
<div id="tab-content-customer_price">
|
||||
<div id="grid_customer_price_data" class="ag-theme-balham ag-bordered" style="width:100%;"></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var $table = null;
|
||||
var customer_id = $('#customer_price_customer_id').val();
|
||||
var params = {customer_id: customer_id};
|
||||
|
||||
(function($) {
|
||||
var options = {};
|
||||
options.columns = [
|
||||
{field:'id', hide: true},
|
||||
{field:'product_id', hide: true},
|
||||
{suppressSizeToFit: true, headerName:'', cellRenderer:'optionCellRenderer', width: 60, sortable: false, cellClass: 'text-center', suppressNavigable: true},
|
||||
{headerName: '存货编码', field:'product_code', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '产品名称',editable: true,suppressNavigable: false, width: 220,
|
||||
cellEditorParams: {
|
||||
form_type: 'dialog',
|
||||
title: '产品',
|
||||
type: 'product',
|
||||
field: 'product_name',
|
||||
url: 'product/product/dialog',
|
||||
query: {
|
||||
form_id: "customer_price_data",
|
||||
id: "product_id",
|
||||
name: "product_name"
|
||||
}
|
||||
},
|
||||
cellEditor: 'dialogCellEditor',
|
||||
field: 'product_name'
|
||||
},
|
||||
{headerName: '规格型号', field:'product_spec', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '产品条码', field:'product_barcode', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '计量单位', field:'product_unit', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName: '销售价格', field:'price', editable: true, cellClass:'text-right', width: 120},
|
||||
{headerName: '备注', field:'remark', editable: true, width: 200},
|
||||
];
|
||||
|
||||
options.table = "customer_price_data";
|
||||
options.title = "订单商品";
|
||||
options.heightTop = 12;
|
||||
|
||||
options.links = {
|
||||
product_id: {
|
||||
product_id: "id",
|
||||
product_name: "name",
|
||||
product_code: "code",
|
||||
product_spec: "spec",
|
||||
product_barcode: "barcode",
|
||||
product_unit: "unit_id_name"
|
||||
}
|
||||
};
|
||||
|
||||
var grid = gridForms("customer_price", "customer_price_data", options);
|
||||
grid.dataKey = 'product_id';
|
||||
|
||||
$.post(app.url('customer/price/list'), params, function(res) {
|
||||
if (res.data.length > 0) {
|
||||
grid.api.setRowData(res.data);
|
||||
}
|
||||
});
|
||||
|
||||
// 选择客户事件
|
||||
gdoo.event.set('customer_price.customer_id', {
|
||||
onSelect(row) {
|
||||
if (row.id) {
|
||||
params['customer_id'] = row.id;
|
||||
$.post(app.url('customer/price/list'), params, function(res) {
|
||||
if (res.data.length > 0) {
|
||||
grid.api.setRowData(res.data);
|
||||
} else {
|
||||
grid.api.setRowData([]);
|
||||
grid.api.memoryStore.create({});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var referCustomerDialog = function () {
|
||||
var buttons = [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}];
|
||||
buttons.push({
|
||||
text: '提交',
|
||||
'class': 'btn-info',
|
||||
click: function () {
|
||||
|
||||
var loading = layer.msg('数据提交中...', {
|
||||
icon: 16, shade: 0.1, time: 1000 * 120
|
||||
});
|
||||
|
||||
var rows = refer_customer.api.getSelectedRows();
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
let row = rows[i];
|
||||
grid.api.memoryStore.create(row);
|
||||
}
|
||||
layer.close(loading);
|
||||
grid.generatePinnedBottomData();
|
||||
$(this).dialog('close');
|
||||
}
|
||||
});
|
||||
$.dialog({
|
||||
title: '参照客户价格',
|
||||
url: '{{url("referCustomer")}}',
|
||||
dialogClass: 'modal-lg',
|
||||
buttons: buttons
|
||||
});
|
||||
};
|
||||
window.referCustomerDialog = referCustomerDialog;
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
var data = params.data;
|
||||
if (data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (data.master_id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,74 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
var grid = new agGridOptions();
|
||||
var selectedData = {};
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.suppressRowClickSelection = true;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{field:'product_id', hide: true},
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{headerName:'存货编码', field:'product_code', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName:'产品名称', field: 'product_name', suppressNavigable: false, width: 220},
|
||||
{headerName:'规格型号', field:'product_spec', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName:'产品条码', field:'product_barcode', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName:'计量单位', field:'product_unit', cellClass:'text-center', suppressNavigable: false, width: 120},
|
||||
{headerName:'销售价格', field:'price', cellClass:'text-right', width: 120},
|
||||
{headerName:'备注', field:'remark', width: 200},
|
||||
];
|
||||
|
||||
grid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
var ret = writeSelected();
|
||||
if (ret == true) {
|
||||
$('#aike-dialog-' + params.dialog_index).dialog('close');
|
||||
}
|
||||
};
|
||||
|
||||
gdoo.dialogs[option.id] = grid;
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,129 @@
|
||||
<div class="panel">
|
||||
<div class="wrapper-sm">
|
||||
|
||||
<form class="form-inline" method="post" id="query-form" name="query-form">
|
||||
|
||||
<div class="form-inline">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<?php $m = date('Y-m-01'); ?>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<label class="control-label">对账客户</label>
|
||||
{{App\Support\Dialog::user('customer', 'customer', '', 0, 0, 135)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<label class="control-label">开始日期</label>
|
||||
<input class="form-control input-sm" data-toggle="date" type="text" name="start_at" id="start_at" placeholder="开始日期" value="{{$m}}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group m-b-xs">
|
||||
<div class="col-sm-12">
|
||||
<label class="control-label">开始日期</label>
|
||||
<input class="form-control input-sm" data-toggle="date" type="text" id="end_at" placeholder="开始日期" name="end_at" value="{{date('Y-m-d', strtotime("$m +1 month -1 day"))}}">
|
||||
<div class="visible-xs-block m-t"></div>
|
||||
<span class="hidden-xs"> </span>
|
||||
<a href="javascript:formQuery();" class="btn btn-sm btn-info"><i class="icon icon-search"></i> 查询</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="list-jqgrid">
|
||||
<table id="account-single"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var $table = null;
|
||||
var params = {};
|
||||
|
||||
(function($) {
|
||||
|
||||
$table = $("#account-single");
|
||||
var model = [
|
||||
{name: "ccusname", hidden: true, index: 'ccusname', label: '客户名称', width: 100, align: 'center'},
|
||||
{name: "date", index: 'date', label: '单据日期', width: 100, align: 'center'},
|
||||
{name: "ddh", index: 'ddh', label: '订单号', width: 120, align: 'left'},
|
||||
{name: "digest", index: 'digest', label: '摘要', width: 220, align: 'left'},
|
||||
{name: "zp", index: 'zp', label: '赠品金额', width: 180, align: 'right'},
|
||||
{name: "jmoney", index: 'jmoney', label: '本期应收金额', width: 180, align: 'right'},
|
||||
{name: "dmoney", index: 'dmoney', label: '本期收回金额', width: 180, align: 'right'},
|
||||
{name: "balance", index: 'balance', label: '余额', width: 180, align: 'right'}
|
||||
];
|
||||
|
||||
$table.jqGrid({
|
||||
caption: '',
|
||||
datatype: 'json',
|
||||
mtype: 'POST',
|
||||
url: app.url('customer/account/query'),
|
||||
colModel: model,
|
||||
rowNum: 1000,
|
||||
multiselect: false,
|
||||
viewrecords: true,
|
||||
rownumbers: true,
|
||||
height: getPanelHeight(),
|
||||
footerrow: false,
|
||||
postData: params,
|
||||
grouping:true,
|
||||
groupingView : {
|
||||
groupField : ['ccusname'],//分组属性
|
||||
groupColumnShow : [false,false],//是否显示分组列
|
||||
groupText : ['<b>{0}</b>'],//表头显示数据(每组中包含的数据量)
|
||||
groupCollapse :false,//加载数据时是否只显示分组的组信息
|
||||
groupSummary : [false,false],//是否显示汇总 如果为true需要在colModel中进行配置summaryType:'max',summaryTpl:'<b>Max: {0}</b>'
|
||||
groupDataSorted : false,//分组中的数据是否排序
|
||||
groupOrder:['desc','desc'] , //分组后组的排列顺序
|
||||
//showSummaryOnHide: true//是否在分组底部显示汇总信息并且当收起表格时是否隐藏下面的分组
|
||||
},
|
||||
|
||||
gridComplete: function() {
|
||||
$(this).jqGrid('setColsWidth');
|
||||
},
|
||||
loadComplete: function(res) {
|
||||
var me = $(this);
|
||||
me.jqGrid('initPagination', res);
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
|
||||
function formQuery()
|
||||
{
|
||||
var query_form = $('#query-form');
|
||||
var query = query_form.serializeArray();
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
params[query[i].name] = query[i].value;
|
||||
}
|
||||
|
||||
$table.jqGrid('setGridParam', {
|
||||
postData: params,
|
||||
page: 1
|
||||
}).trigger('reloadGrid');
|
||||
}
|
||||
|
||||
function getPanelHeight() {
|
||||
var list = $('.list-jqgrid').position();
|
||||
return top.iframeHeight - list.top - 45;
|
||||
}
|
||||
|
||||
// 框架页面改变大小时会调用此方法
|
||||
function iframeResize() {
|
||||
// 框架改变大小时设置Panel高度
|
||||
$table.jqGrid('setPanelHeight', getPanelHeight());
|
||||
// resize jqgrid大小
|
||||
$table.jqGrid('resizeGrid');
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<form class="form-horizontal form-controller" method="post" id="customer_region" name="customer_region">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
@@ -0,0 +1,134 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline search-inline-form" method="get">
|
||||
@include('searchForm6')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
var grid = new agGridOptions();
|
||||
var selectedData = {};
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.suppressRowClickSelection = true;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
|
||||
grid.autoGroupColumnDef = {
|
||||
headerName: '名称',
|
||||
width: 250,
|
||||
cellRendererParams: {
|
||||
checkbox: true,
|
||||
suppressCount: false,
|
||||
}
|
||||
};
|
||||
grid.treeData = true;
|
||||
grid.groupDefaultExpanded = -1;
|
||||
grid.getDataPath = function(data) {
|
||||
return data.tree_path;
|
||||
};
|
||||
grid.columnDefs = [];
|
||||
grid.columnDefs.push(
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
);
|
||||
|
||||
grid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
var ret = writeSelected();
|
||||
if (ret == true) {
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化选择
|
||||
*/
|
||||
function initSelected() {
|
||||
if (params.is_grid) {
|
||||
} else {
|
||||
var rows = {};
|
||||
var id = $('#'+option.id).val();
|
||||
if (id) {
|
||||
var ids = id.split(',');
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
rows[ids[i]] = ids[i];
|
||||
}
|
||||
}
|
||||
grid.api.forEachNode(function(node) {
|
||||
var key = node.data[sid];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入选中
|
||||
*/
|
||||
function writeSelected() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (params.is_grid) {
|
||||
var list = gdoo.forms[params.form_id];
|
||||
list.api.dialogSelected(params);
|
||||
} else {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(rows, function(k, row) {
|
||||
id.push(row[sid]);
|
||||
text.push(row.name);
|
||||
});
|
||||
$('#'+option.id).val(id.join(','));
|
||||
$('#'+option.id+'_text').val(text.join(','));
|
||||
|
||||
if (event.exist('onSelect')) {
|
||||
return event.trigger('onSelect', multiple ? rows : rows[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
grid.writeSelected = writeSelected;
|
||||
gdoo.dialogs[option.id] = grid;
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,78 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border m-b-sm" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
(function ($) {
|
||||
|
||||
var options = new agGridOptions();
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
config.cols[0]['hide'] = true;
|
||||
config.cols[1]['hide'] = true;
|
||||
config.cols[2]['hide'] = true;
|
||||
options.autoGroupColumnDef = {
|
||||
groupSelectsChildren: true,
|
||||
headerName: '名称',
|
||||
width: 250,
|
||||
cellRendererParams: {
|
||||
checkbox: true,
|
||||
suppressCount: true,
|
||||
}
|
||||
};
|
||||
|
||||
options.treeData = true;
|
||||
options.groupDefaultExpanded = -1;
|
||||
|
||||
options.getDataPath = function(data) {
|
||||
return data.tree_path;
|
||||
};
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
var height = getPanelHeight(11);
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
|
||||
gridDiv.style.height = height;
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,30 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var form_action = '{{$form["action"]}}';
|
||||
(function ($) {
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.customer_region_task_data', {
|
||||
init(me) {
|
||||
me.enableCellTextSelection = false;
|
||||
me.enableRangeSelection = true;
|
||||
me.suppressContextMenu = false;
|
||||
},
|
||||
ready(me) {
|
||||
me.dataKey = 'region_id';
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.autoColumnsToFit = false;
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,117 @@
|
||||
<div class="panel b-a" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var search = JSON.parse('{{json_encode($header["search_form"])}}');
|
||||
var columns = [];
|
||||
var params = search.query;
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
|
||||
grid.defaultColDef.suppressMenu = true;
|
||||
grid.defaultColDef.sortable = true;
|
||||
grid.defaultColDef.filter = false;
|
||||
grid.autoColumnsToFit = false;
|
||||
grid.singleClickEdit = true;
|
||||
grid.rowSelection = 'single';
|
||||
grid.suppressCellSelection = false;
|
||||
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', field: 'sn', type: 'sn', headerName: '序号', width: 50},
|
||||
{cellClass:'text-center', field: 'region_name', headerName: '区域', width: 120},
|
||||
{cellClass:'text-right', field: 'total_task', headerName: '总任务', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_money', headerName: '累计销售', width: 80, type:'number', numberOptions: {places:4}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_rate', headerName: '总进度', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
];
|
||||
|
||||
for(var i=1; i <= 12;i++) {
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: i + '月',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'month' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'month_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'month_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
for(var i=1; i <= 4;i++) {
|
||||
var dx = {
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
};
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: dx[i] + '季度',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'quarter_' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'quarter_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'quarter_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
gridDiv.style.height = getPanelHeight(12);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
var search_advanced = $('#' + table + '-search-form-advanced').searchForm({
|
||||
data: search.forms,
|
||||
advanced: true,
|
||||
});
|
||||
|
||||
gdoo.grids[table] = {grid: grid};
|
||||
|
||||
var action = new gridAction(table, '区域销售进度');
|
||||
var panel = $('#' + table + '-controller');
|
||||
|
||||
panel.on('click', '[data-toggle="' + table + '"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'filter') {
|
||||
// 过滤数据
|
||||
$('#' + table + '-search-form-advanced').dialog({
|
||||
title: '条件筛选',
|
||||
modalClass: 'no-padder',
|
||||
buttons: [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text: "确定",
|
||||
'class': "btn-info",
|
||||
click: function() {
|
||||
var query = search_advanced.serializeArray();
|
||||
params = {};
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(params);
|
||||
$(this).dialog("close");
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
if (data.action == 'export') {
|
||||
action.export(data, '区域销售进度');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,77 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var form_action = '{{$form["action"]}}';
|
||||
(function ($) {
|
||||
|
||||
$("#customer_task_data_tool").append('<a class="btn btn-sm btn-default" href="javascript:importExcel();">导入</a>');
|
||||
|
||||
// 发货记录
|
||||
function importExcel() {
|
||||
var url = app.url('customer/task/importExcel');
|
||||
formDialog({
|
||||
title: '导入数据',
|
||||
url: url,
|
||||
id: 'import_excel',
|
||||
dialogClass:'modal-md',
|
||||
onSubmit: function() {
|
||||
var me = this;
|
||||
var form = $('#import_excel');
|
||||
var file = document.querySelector("#import_file").files[0];
|
||||
var formData = new FormData();
|
||||
formData.append('file', file);
|
||||
var loading = layer.msg('数据提交中...', {
|
||||
icon: 16, shade: 0.1, time: 1000 * 120
|
||||
});
|
||||
$.ajax(url, {
|
||||
method: "post",
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
complete: function() {
|
||||
layer.close(loading);
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.status) {
|
||||
grid.api.setRowData([]);
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
var row = res.data[i];
|
||||
grid.api.memoryStore.create(row);
|
||||
}
|
||||
grid.generatePinnedBottomData();
|
||||
$(me).dialog('close');
|
||||
toastrSuccess('导入数据成功。');
|
||||
} else {
|
||||
toastrError(res.data);
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
window.importExcel = importExcel;
|
||||
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.customer_task_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.autoColumnsToFit = false;
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.master_id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,132 @@
|
||||
<div class="panel b-a" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var search = JSON.parse('{{json_encode($header["search_form"])}}');
|
||||
var columns = [];
|
||||
var params = search.query;
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
|
||||
grid.defaultColDef.suppressMenu = true;
|
||||
grid.defaultColDef.sortable = true;
|
||||
grid.defaultColDef.filter = false;
|
||||
grid.autoColumnsToFit = false;
|
||||
grid.singleClickEdit = true;
|
||||
grid.rowSelection = 'single';
|
||||
grid.suppressCellSelection = false;
|
||||
|
||||
grid.defaultColDef.cellStyle = function(params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
var style = {};
|
||||
var field = params.colDef.field;
|
||||
if (params.data.status == '0' && (field == "customer_code" || field == "customer_name")) {
|
||||
style = {'color':'red'};
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', field: 'sn', type: 'sn', headerName: '序号', width: 50},
|
||||
{cellClass:'text-center', field: 'region_name', headerName: '区域', width: 100},
|
||||
{cellClass:'text-center', field: 'customer_code', headerName: '客户编码', width: 80},
|
||||
{cellClass:'text-left', field: 'customer_name', headerName: '客户名称', width: 180},
|
||||
{cellClass:'text-right', field: 'total_count', headerName: '总订单数', width: 80, type:'number', numberOptions: {places:0}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_task', headerName: '总任务', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_money', headerName: '累计销售', width: 80, type:'number', numberOptions: {places:4}, calcFooter: 'sum'},
|
||||
{cellClass:'text-right', field: 'total_rate', headerName: '总进度', width: 80, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
];
|
||||
|
||||
for(var i=1; i <= 12;i++) {
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: i + '月',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'month' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'month_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'month_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
for(var i=1; i <= 4;i++) {
|
||||
var dx = {
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
};
|
||||
grid.columnDefs.push({
|
||||
cellClass:'text-center', headerName: dx[i] + '季度',
|
||||
children: [
|
||||
{cellClass:'text-right', headerName:'任务', width: 60, field:'quarter_' + i, type:'number', numberOptions:{places:2, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'销售', width: 80, field:'quarter_'+i+'_money', type:'number', numberOptions:{places:4, default:'0'}, calcFooter:'sum'},
|
||||
{cellClass:'text-right', headerName:'进度', width: 60, field:'quarter_'+i+'_rate', type:'number', numberOptions:{places:2, default:'0'}}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
gridDiv.style.height = getPanelHeight(12);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
var search_advanced = $('#' + table + '-search-form-advanced').searchForm({
|
||||
data: search.forms,
|
||||
advanced: true,
|
||||
});
|
||||
|
||||
gdoo.grids[table] = {grid: grid};
|
||||
|
||||
var action = new gridAction(table, '客户销售进度');
|
||||
var panel = $('#' + table + '-controller');
|
||||
|
||||
panel.on('click', '[data-toggle="' + table + '"]', function() {
|
||||
var data = $(this).data();
|
||||
if (data.action == 'filter') {
|
||||
// 过滤数据
|
||||
$('#' + table + '-search-form-advanced').dialog({
|
||||
title: '条件筛选',
|
||||
modalClass: 'no-padder',
|
||||
buttons: [{
|
||||
text: "取消",
|
||||
'class': "btn-default",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},{
|
||||
text: "确定",
|
||||
'class': "btn-info",
|
||||
click: function() {
|
||||
var query = search_advanced.serializeArray();
|
||||
params = {};
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(params);
|
||||
$(this).dialog("close");
|
||||
return false;
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
if (data.action == 'export') {
|
||||
action.export(data, '客户销售进度');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
</div>
|
||||
<div class="form-panel-body panel-form-{{$form['action']}}">
|
||||
<form class="form-horizontal form-controller" method="post" id="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
// 选择客户事件
|
||||
gdoo.event.set('customer_tax.customer_id', {
|
||||
query(params) {
|
||||
},
|
||||
onSelect(row) {
|
||||
if (row.id) {
|
||||
$('#customer_tax_class_id').val(row.class_id);
|
||||
$('#customer_tax_class_id_text').val(row.class_id_name);
|
||||
|
||||
$('#customer_tax_department_id').val(row.department_id);
|
||||
$('#customer_tax_department_id_text').val(row.department_id_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,135 @@
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-{{$search['query']['id']}}-search-form" class="form-inline search-inline-form" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="dialog-{{$search['query']['id']}}" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
(function ($) {
|
||||
|
||||
var search = JSON.parse('{{json_encode($search)}}');
|
||||
var params = search.query;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
var grid = new agGridOptions();
|
||||
var multiple = params.multi == 0 ? false : true;
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.suppressRowClickSelection = true;
|
||||
grid.rowSelection = multiple ? 'multiple' : 'single';
|
||||
grid.columnDefs = [
|
||||
{suppressMenu: true, cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: multiple, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{suppressMenu: true, cellClass:'text-left', sortable: false, field: 'name', headerName: '开票名称', minWidth: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'code', headerName: '开票编码', width: 80},
|
||||
{suppressMenu: true, cellClass:'text-left', sortable: false, field: 'customer_name', headerName: '客户名称', minWidth: 160},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'customer_code', headerName: '客户编码', width: 80},
|
||||
{suppressMenu: true, cellClass:'text-center', cellRenderer: statusRenderer, field: 'status', headerName: '状态', width: 60},
|
||||
{suppressMenu: true, cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
function statusRenderer(row) {
|
||||
if (row.value == 0) {
|
||||
return '<span style="color:red">禁用</span>';
|
||||
}
|
||||
if (row.value == 1) {
|
||||
return '启用';
|
||||
}
|
||||
}
|
||||
|
||||
grid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
grid.onRowDoubleClicked = function (row) {
|
||||
var ret = writeSelected();
|
||||
if (ret == true) {
|
||||
$('#gdoo-dialog-' + params.dialog_index).dialog('close');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 初始化选择
|
||||
*/
|
||||
function initSelected() {
|
||||
if (params.is_grid) {
|
||||
} else {
|
||||
var rows = {};
|
||||
var id = $('#'+option.id).val();
|
||||
if (id) {
|
||||
var ids = id.split(',');
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
rows[ids[i]] = ids[i];
|
||||
}
|
||||
}
|
||||
grid.api.forEachNode(function(node) {
|
||||
var key = node.data[sid];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入选中
|
||||
*/
|
||||
function writeSelected() {
|
||||
var rows = grid.api.getSelectedRows();
|
||||
if (params.is_grid) {
|
||||
var list = gdoo.forms[params.form_id];
|
||||
list.api.dialogSelected(params);
|
||||
} else {
|
||||
var id = [];
|
||||
var text = [];
|
||||
$.each(rows, function(k, row) {
|
||||
id.push(row[sid]);
|
||||
text.push(row.name);
|
||||
});
|
||||
console.log('#'+option.id);
|
||||
$('#'+option.id).val(id.join(','));
|
||||
$('#'+option.id+'_text').val(text.join(','));
|
||||
|
||||
if (event.exist('onSelect')) {
|
||||
return event.trigger('onSelect', multiple ? rows : rows[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
grid.writeSelected = writeSelected;
|
||||
gdoo.dialogs[option.id] = grid;
|
||||
|
||||
var gridDiv = document.querySelector("#dialog-{{$search['query']['id']}}");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
// 数据载入成功
|
||||
grid.remoteSuccessed = function() {
|
||||
initSelected();
|
||||
}
|
||||
|
||||
var data = search.forms;
|
||||
var search = $("#dialog-{{$search['query']['id']}}-search-form").searchForm({
|
||||
data: data
|
||||
});
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var params = search.serializeArray();
|
||||
$.map(params, function(row) {
|
||||
data[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(data);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,60 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['master_table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["master_table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
action.dialogType = 'layer';
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['master_table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.autoColumnsToFit = false;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.id > 0) {
|
||||
action.show(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,3 @@
|
||||
<form class="form-horizontal form-controller" method="post" id="customer_type" name="customer_type">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
@@ -0,0 +1,57 @@
|
||||
{{$header["js"]}}
|
||||
|
||||
<div class="panel no-border" id="{{$header['table']}}-controller">
|
||||
@include('headers')
|
||||
<div class='list-jqgrid'>
|
||||
<div id="{{$header['table']}}-grid" style="width:100%;" class="ag-theme-balham"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var table = '{{$header["table"]}}';
|
||||
var config = gdoo.grids[table];
|
||||
var action = config.action;
|
||||
var search = config.search;
|
||||
|
||||
// 自定义搜索方法
|
||||
search.searchInit = function (e) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
var options = new agGridOptions();
|
||||
var gridDiv = document.querySelector("#{{$header['table']}}-grid");
|
||||
gridDiv.style.height = getPanelHeight(48);
|
||||
|
||||
options.remoteDataUrl = '{{url()}}';
|
||||
options.remoteParams = search.advanced.query;
|
||||
options.columnDefs = config.cols;
|
||||
options.onRowDoubleClicked = function (params) {
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (params.data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (params.data.id > 0) {
|
||||
action.edit(params.data);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(gridDiv, options);
|
||||
|
||||
// 读取数据
|
||||
options.remoteData({page: 1});
|
||||
|
||||
// 绑定自定义事件
|
||||
var $gridDiv = $(gridDiv);
|
||||
$gridDiv.on('click', '[data-toggle="event"]', function () {
|
||||
var data = $(this).data();
|
||||
if (data.master_id > 0) {
|
||||
action[data.action](data);
|
||||
}
|
||||
});
|
||||
config.grid = options;
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@include('footers')
|
||||
@@ -0,0 +1,31 @@
|
||||
<div class="list-jqgrid">
|
||||
<div id="customer-birthday-widget" class="ag-theme-balham" style="width:100%;height:200px;"></div>
|
||||
</div>
|
||||
<script>
|
||||
(function ($) {
|
||||
var gridDiv = document.querySelector("#customer-birthday-widget");
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = {};
|
||||
var columnDefs = [
|
||||
{suppressMenu: true, field: "code", headerName: '客户编码', width: 120},
|
||||
{suppressMenu: true, field: "name", headerName: '客户名称', minWidth: 160},
|
||||
{suppressMenu: true, field: "head_name", headerName: '法人', width: 120},
|
||||
{suppressMenu: true, field: "head_phone", headerName: '法人手机', width: 120},
|
||||
{suppressMenu: true, field: "head_birthday", headerName: '法人生日', width: 120},
|
||||
{suppressMenu: true, field: "id", headerName: 'ID', width: 80}
|
||||
];
|
||||
|
||||
grid.onRowDoubleClicked = function(row) {
|
||||
top.addTab('customer/customer/show?id=' + row.data.id, 'customer_customer_show', '客户档案');
|
||||
}
|
||||
|
||||
grid.columnDefs = columnDefs;
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
// 读取数据
|
||||
grid.remoteData({page: 1});
|
||||
|
||||
gdoo.widgets['customer_widget_birthday'] = grid;
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
Reference in New Issue
Block a user