创建版本
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\CustomerCost\Models\Adjust;
|
||||
use Gdoo\CustomerCost\Models\CostData;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class AdjustController extends AuditController
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost_adjust',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$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']);
|
||||
$model->where('customer_cost.type_id', 86);
|
||||
|
||||
// 客户权限
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$header['select'][] = 'customer_cost_data.cost_id';
|
||||
$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' => '关闭', 'color' => 'default', 'icon' => 'fa-lock', 'action' => 'close', 'display' => $this->access['close']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Adjust::$tabs;
|
||||
$header['bys'] = Adjust::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 其他费用
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer_cost_adjust';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
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_cost_adjust', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\CustomerCost\Models\Category;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class CategoryController extends DefaultController
|
||||
{
|
||||
public $permission = ['dialog'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost_category',
|
||||
'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('sort', 'asc');
|
||||
|
||||
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'] = Category::$tabs;
|
||||
$header['bys'] = Category::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 新建客户联系人
|
||||
public function createAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$form = Form::make(['code' => 'customer_cost_category', 'id' => $id]);
|
||||
return $this->render([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 创建客户联系人
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示客户联系人
|
||||
public function showAction()
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
$group = Category::find($id);
|
||||
$options = [
|
||||
'table' => 'customer_cost_category',
|
||||
'row' => $group,
|
||||
];
|
||||
$tpl = Form::show($options);
|
||||
return $this->display([
|
||||
'tpl' => $tpl,
|
||||
]);
|
||||
}
|
||||
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form([], [
|
||||
['text','customer_cost_category.name','名称'],
|
||||
['text','customer_cost_category.id','ID'],
|
||||
]);
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = Type::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_cost_category', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\CustomerCost\Models\Compen;
|
||||
use Gdoo\CustomerCost\Models\CostData;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class CompenController extends AuditController
|
||||
{
|
||||
public $permission = ['importExcel'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost_compen',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$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']);
|
||||
$model->where('customer_cost.type_id', 87);
|
||||
|
||||
// 客户权限
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$header['select'][] = 'customer_cost_data.cost_id';
|
||||
$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'] = Compen::$tabs;
|
||||
$header['bys'] = Compen::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 其他费用
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer_cost_compen';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
public function importExcelAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
if ($file->isValid()) {
|
||||
$types = DB::table('customer_order_type')->get()->keyBy('name');
|
||||
|
||||
/*
|
||||
[0] => 客户编码
|
||||
[1] => 客户名称
|
||||
[2] => 金额
|
||||
*/
|
||||
|
||||
$rows = readExcel($file->getPathName());
|
||||
$items = [];
|
||||
|
||||
$codes = [];
|
||||
foreach($rows as $i => $row) {
|
||||
if ($i > 1) {
|
||||
$codes[] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$customers = DB::table('customer')->whereIn('code', $codes)->get()->keyBy('code');
|
||||
foreach($rows as $i => $row) {
|
||||
if ($i > 1) {
|
||||
$customer = $customers[$row[0]];
|
||||
if (empty($customer)) {
|
||||
return $this->json('客户编码'.$row[0].'不存在。');
|
||||
}
|
||||
$item = [
|
||||
'customer_id' => $customer['id'],
|
||||
'customer_id_name' => $customer['name'],
|
||||
'money' => $row[2],
|
||||
];
|
||||
$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_cost_compen', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\CustomerCost\Models\Cost;
|
||||
use Gdoo\CustomerCost\Models\CostData;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class CostController extends AuditController
|
||||
{
|
||||
public $permission = ['dialog', 'serviceSaleOrder', 'useCount'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$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']);
|
||||
|
||||
// 客户权限
|
||||
$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']) {
|
||||
if ($where['field'] == 'customer_cost_data.tax_id') {
|
||||
$customer_ids = DB::table('customer_tax')->where('id', $where['search'])->pluck('customer_id');
|
||||
$model->whereIn('customer_cost_data.customer_id', $customer_ids);
|
||||
} else {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$header['select'][] = 'customer_cost_data.src_id';
|
||||
$header['select'][] = 'customer_cost_data.src_type_id';
|
||||
$header['select'][] = 'customer_cost_data.cost_id';
|
||||
$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['right_buttons'] = [
|
||||
['name' => '关闭', 'color' => 'default', 'icon' => 'fa-lock', 'action' => 'close', 'display' => $this->access['close']],
|
||||
['name' => '费用调整单', 'color' => 'info', 'icon' => 'fa-plus', 'action' => 'create4', 'display' => $this->access['create4']],
|
||||
];
|
||||
|
||||
$header['cols'] = $cols;
|
||||
$header['tabs'] = Cost::$tabs;
|
||||
$header['bys'] = Cost::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 其他费用
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer_cost';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 费用参照到订单
|
||||
public function serviceSaleOrderAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost',
|
||||
'type' => 'dialog',
|
||||
]);
|
||||
$search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$model = DB::table('customer_cost_data')
|
||||
->leftJoin('customer_cost', 'customer_cost.id', '=', 'customer_cost_data.cost_id')
|
||||
->leftJoin('customer', 'customer.id', '=', 'customer_cost_data.customer_id')
|
||||
->leftJoin('customer_cost_category', 'customer_cost_category.id', '=', 'customer_cost.category_id')
|
||||
->whereRaw('(isnull(customer_cost_data.remain_money, 0) > 0 and isnull(customer_cost_data.use_close, 0) = 0)')
|
||||
->where('customer_cost_data.customer_id', $query['customer_id'])
|
||||
->selectRaw("
|
||||
customer_cost_data.*,
|
||||
customer.name as customer_name,
|
||||
customer.code as customer_code,
|
||||
|
||||
customer_cost.sn,
|
||||
|
||||
customer_cost_data.src_sn as fee_src_sn,
|
||||
customer_cost_data.src_type_id as fee_src_type_id,
|
||||
customer_cost_data.src_id as fee_src_id,
|
||||
customer_cost_data.id as fee_data_id,
|
||||
|
||||
customer_cost_category.name as fee_category_id_name,
|
||||
customer_cost.category_id as fee_category_id,
|
||||
|
||||
'99001' as product_code,
|
||||
'20226' as product_id,
|
||||
'折扣额' as product_name,
|
||||
'元' as product_unit,
|
||||
'5' as type_id,
|
||||
'费用' as type_id_name,
|
||||
customer_cost_data.money as total_money,
|
||||
customer_cost_data.use_money,
|
||||
isnull(customer_cost_data.remain_money, 0) as money
|
||||
");
|
||||
|
||||
if ($query['sort'] && $query['order']) {
|
||||
$model->orderBy($query['sort'], $query['order']);
|
||||
}
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
$rows = $model->get();
|
||||
|
||||
$rows->transform(function($row) {
|
||||
$unit = option('product.unit', $row['unit_id']);
|
||||
$row['unit_name'] = $unit;
|
||||
return $row;
|
||||
});
|
||||
return response()->json(['data' => $rows]);
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
// 可用列表
|
||||
public function useCountAction()
|
||||
{
|
||||
$customer_id = Request::get('customer_id');
|
||||
$count = DB::table('customer_cost_data')
|
||||
->where('customer_id', $customer_id)
|
||||
->whereRaw('(isnull(remain_money, 0) > 0 and isnull(use_close, 0) = 0)')
|
||||
->count();
|
||||
return $this->json($count, true);
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
public function batchEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
DB::table('customer_cost_data')->whereIn('id', $ids)->update([
|
||||
$gets['field'] => $gets['search_0'],
|
||||
]);
|
||||
return $this->json('修改完成。', true);
|
||||
}
|
||||
$header = Grid::batchEdit([
|
||||
'code' => 'customer_cost',
|
||||
'columns' => ['customer_id'],
|
||||
]);
|
||||
return view('batchEdit', [
|
||||
'gets' => $gets,
|
||||
'header' => $header
|
||||
]);
|
||||
}
|
||||
|
||||
// 费用关闭
|
||||
public function closeAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
if (empty($gets['close_remark'])) {
|
||||
return $this->json('原因必须填写。');
|
||||
}
|
||||
$cost = CostData::find($gets['id']);
|
||||
$cost->close_remark = $gets['close_remark'];
|
||||
$cost->use_close = $cost->use_close == 1 ? 0 : 1;
|
||||
$cost->save();
|
||||
return $this->json('恭喜你,操作成功。', url_referer('index'));
|
||||
}
|
||||
return $this->render([
|
||||
'gets' => $gets,
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除促销
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'customer_cost', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\CustomerCost\Models\Rebate;
|
||||
use Gdoo\CustomerCost\Models\CostData;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\AuditController;
|
||||
|
||||
class RebateController extends AuditController
|
||||
{
|
||||
public $permission = ['importExcel'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$header = Grid::header([
|
||||
'code' => 'customer_cost_rebate',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$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']);
|
||||
$model->where('customer_cost.type_id', 88);
|
||||
|
||||
// 客户权限
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
$header['select'][] = 'customer_cost_data.cost_id';
|
||||
$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'] = Rebate::$tabs;
|
||||
$header['bys'] = Rebate::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 其他费用
|
||||
public function createAction($action = 'edit')
|
||||
{
|
||||
$id = (int)Request::get('id');
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
$header['code'] = 'customer_cost_rebate';
|
||||
$header['id'] = $id;
|
||||
$header['action'] = $action;
|
||||
|
||||
$form = Form::make($header);
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], 'create');
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
public function importExcelAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$file = Request::file('file');
|
||||
if ($file->isValid()) {
|
||||
$types = DB::table('customer_order_type')->get()->keyBy('name');
|
||||
|
||||
/*
|
||||
[0] => 客户编码
|
||||
[1] => 客户名称
|
||||
[2] => 金额
|
||||
*/
|
||||
|
||||
$rows = readExcel($file->getPathName());
|
||||
$items = [];
|
||||
|
||||
$codes = [];
|
||||
foreach($rows as $i => $row) {
|
||||
if ($i > 1) {
|
||||
$codes[] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
$customers = DB::table('customer')->whereIn('code', $codes)->get()->keyBy('code');
|
||||
foreach($rows as $i => $row) {
|
||||
if ($i > 1) {
|
||||
$customer = $customers[$row[0]];
|
||||
if (empty($customer)) {
|
||||
return $this->json('客户编码'.$row[0].'不存在。');
|
||||
}
|
||||
$item = [
|
||||
'customer_id' => $customer['id'],
|
||||
'customer_id_name' => $customer['name'],
|
||||
'money' => $row[2],
|
||||
];
|
||||
$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_cost_rebate', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php namespace Gdoo\CustomerCost\Controllers;
|
||||
|
||||
use DB;
|
||||
use View;
|
||||
use Request;
|
||||
|
||||
use Gdoo\Customer\Models\CustomerType;
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class ReportController extends DefaultController
|
||||
{
|
||||
/**
|
||||
* 费用使用统计
|
||||
*/
|
||||
public function saleOrderDetailAction()
|
||||
{
|
||||
$sdate = date('Y-m-01');
|
||||
$edate = date('Y-m-d');
|
||||
$search = search_form([],
|
||||
[['form_type' => 'date2', 'name' => '日期', 'field' => 'date', 'value' => [$sdate, $edate], 'options' => []],
|
||||
['form_type' => 'text', 'name' => '订单编号', 'field' => 'm.sn', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '单据编号', 'field' => 'd.fee_src_sn', 'options' => []],
|
||||
[
|
||||
'form_type' =>'dialog',
|
||||
'field' => 'm.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');
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
$fields = [];
|
||||
foreach($search['forms']['field'] as $i => $field) {
|
||||
$fields[$field] = $search['forms']['search'][$i];
|
||||
}
|
||||
|
||||
$model = DB::table('customer_order_data as d')
|
||||
->leftJoin('product', 'product.id', '=', 'd.product_id')
|
||||
->leftJoin('customer_order as m', 'm.id', '=', 'd.order_id')
|
||||
->leftJoin('customer as c', 'c.id', '=', 'm.customer_id')
|
||||
->leftJoin('customer_cost_category as ccc', 'ccc.id', '=', 'd.fee_category_id')
|
||||
->selectRaw("
|
||||
m.sn,
|
||||
d.fee_src_sn,
|
||||
d.fee_src_type_id,
|
||||
Sum(d.money) as money,
|
||||
c.code as customer_code,
|
||||
c.name as customer_name,
|
||||
ccc.name as category_name,
|
||||
".sql_year_month('l.audit_date', 'ts')." as [ym]
|
||||
")
|
||||
->whereRaw('d.fee_src_sn is not null')
|
||||
->groupBy(DB::raw('c.code,c.name,ccc.name,m.sn,d.fee_src_sn,d.fee_src_type_id,'.sql_year_month('l.audit_date', 'ts')));
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
if ($where['field'] == 'date') {
|
||||
continue;
|
||||
}
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
// 销售会计审核日期
|
||||
$rows = $model->leftJoin(DB::raw("(select max(d.updated_at) as audit_date, m.data_id
|
||||
FROM model_run_log as d left join model_run as m on d.run_id = m.id where m.bill_id = 23 and d.run_name = '销售会计'
|
||||
GROUP BY m.data_id
|
||||
) as l
|
||||
"), 'l.data_id', '=', 'm.id')
|
||||
->whereRaw("(".sql_year_month('l.audit_date', 'ts')." BETWEEN ? AND ?)", $fields['date'])
|
||||
->orderBy(DB::raw(sql_year_month('l.audit_date', 'ts')), 'asc')
|
||||
->get()->toArray();
|
||||
|
||||
foreach($rows as &$row) {
|
||||
$money = abs($row['money']);
|
||||
$row['money'] = $money;
|
||||
}
|
||||
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
$header = [
|
||||
'table' => 'customer_cost',
|
||||
'master_table' => 'customer_cost',
|
||||
'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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php namespace Gdoo\CustomerCost\Hooks;
|
||||
|
||||
class CostDataHook
|
||||
{
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
$master = $params['master'];
|
||||
$row = $params['row'];
|
||||
$row['src_id'] = $master['id'];
|
||||
$row['src_sn'] = $master['sn'];
|
||||
$row['src_type_id'] = $master['type_id'];
|
||||
$params['row'] = $row;
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php namespace Gdoo\CustomerCost\Hooks;
|
||||
|
||||
class CostHook
|
||||
{
|
||||
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 onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php namespace Gdoo\CustomerCost\Models;
|
||||
|
||||
class Adjust extends Cost
|
||||
{
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'adjust.index', 'url' => 'customerCost/adjust/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\CustomerCost\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Category extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_cost_category';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'category.index', 'url' => 'customerCost/category/index', 'name' => '费用类别'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php namespace Gdoo\CustomerCost\Models;
|
||||
|
||||
class Compen extends Cost
|
||||
{
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'compen.index', 'url' => 'customerCost/compen/index', 'name' => '合同补损'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php namespace Gdoo\CustomerCost\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Cost extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_cost';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'cost.index', 'url' => 'customerCost/cost/index', 'name' => '费用管理'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Customer\Models\Customer');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php namespace Gdoo\CustomerCost\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class CostData extends BaseModel
|
||||
{
|
||||
protected $table = 'customer_cost_data';
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Customer\Customer');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php namespace Gdoo\CustomerCost\Models;
|
||||
|
||||
class Rebate extends Cost
|
||||
{
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'rebate.index', 'url' => 'customerCost/rebate/index', 'name' => '合同返利'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "客户费用",
|
||||
"version" => "1.0",
|
||||
"description" => "客户费用管理。",
|
||||
"listens" => [
|
||||
'customer_cost' => 'Gdoo\CustomerCost\Hooks\CostHook',
|
||||
'customer_cost_data' => 'Gdoo\CustomerCost\Hooks\CostDataHook',
|
||||
],
|
||||
'dialogs' => [
|
||||
'customer_cost' => [
|
||||
'name' => '客户费用列表',
|
||||
'model' => 'Gdoo\Market\Models\Cost::Dialog',
|
||||
'url' => 'customerCost/cost/dialog',
|
||||
],
|
||||
'customer_cost_data' => [
|
||||
'name' => '客户费用明细表',
|
||||
'model' => 'Gdoo\Market\Models\CostData::Dialog',
|
||||
'url' => 'customerCost/cost/dialog',
|
||||
],
|
||||
'customer_cost_category' => [
|
||||
'name' => '费用类别',
|
||||
'model' => 'Gdoo\Market\Models\Category::Dialog',
|
||||
'url' => 'customerCost/category/dialog',
|
||||
],
|
||||
],
|
||||
"controllers" => [
|
||||
"cost" => [
|
||||
"name" => "客户费用",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"close" => [
|
||||
"name" => "关闭"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
'batchEdit' => [
|
||||
"name" => "批量编辑",
|
||||
],
|
||||
]
|
||||
],
|
||||
"adjust" => [
|
||||
"name" => "费用调整单",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"compen" => [
|
||||
"name" => "合同补损",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"rebate" => [
|
||||
"name" => "合同返利",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"category" => [
|
||||
"name" => "费用类别",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
]
|
||||
],
|
||||
"report" => [
|
||||
"name" => "客户费用报表",
|
||||
"actions" => [
|
||||
"saleOrderDetail" => [
|
||||
"name" => "费用使用明细表"
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,36 @@
|
||||
<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']}}
|
||||
<input type="hidden" name="customer_cost[type_id]" value="86">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table = '{{$form["table"]}}';
|
||||
(function($) {
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.customer_cost_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('customer_cost_data.customer_id', {
|
||||
query(query) {
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,57 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['master_table']}}-grid" 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.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="{{$form['table']}}" name="{{$form['table']}}">
|
||||
{{$form['tpl']}}
|
||||
</form>
|
||||
@@ -0,0 +1,113 @@
|
||||
<div class="wrapper">
|
||||
<table id="position-dialog">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="state" data-checkbox="true"></th>
|
||||
<th data-field="text" data-align="left">名称</th>
|
||||
<th data-field="id" data-width="60" data-align="center">ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
var $table = $('#position-dialog');
|
||||
var params = {{json_encode($get)}};
|
||||
var sid = params.prefix == 1 ? 'sid' : 'id';
|
||||
|
||||
var selected = {};
|
||||
|
||||
function getSelected()
|
||||
{
|
||||
selected = {};
|
||||
var id = $('#'+params.id).val();
|
||||
var text = $('#'+params.id+'_text').val();
|
||||
|
||||
if(id == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
id = id.split(',');
|
||||
text = text.split(',');
|
||||
for (var i = 0; i < id.length; i++) {
|
||||
selected[id[i]] = text[i];
|
||||
}
|
||||
}
|
||||
|
||||
function setSelected() {
|
||||
var id = [], text = [];
|
||||
$.each(selected, function(k, v) {
|
||||
id.push(k);
|
||||
text.push(v);
|
||||
});
|
||||
$('#'+params.id).val(id.join(','));
|
||||
$('#'+params.id+'_text').val(text.join(','));
|
||||
}
|
||||
|
||||
function setRow(row)
|
||||
{
|
||||
if (params.multi == 0) {
|
||||
selected = {};
|
||||
}
|
||||
selected[row[sid]] = row.text;
|
||||
setSelected();
|
||||
}
|
||||
|
||||
function unsetRow(row) {
|
||||
$.each(selected, function(id) {
|
||||
if (id == row[sid]) {
|
||||
delete selected[id];
|
||||
}
|
||||
});
|
||||
setSelected();
|
||||
}
|
||||
|
||||
$table.bootstrapTable({
|
||||
iconSize:'sm',
|
||||
singleSelect: params.multi == 1 ? 0 : 1,
|
||||
showColumns: false,
|
||||
clickToSelect: true,
|
||||
method: 'post',
|
||||
url: '{{url()}}',
|
||||
height: 350,
|
||||
onLoadSuccess: function(res) {
|
||||
|
||||
getSelected();
|
||||
|
||||
$.each(selected, function(j) {
|
||||
for (var i = 0; i < res.data.length; i++) {
|
||||
if (res.data[i][sid] == j) {
|
||||
$table.bootstrapTable('check', i);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onDblClickRow: function(row) {
|
||||
setRow(row);
|
||||
if (sid == 'sid') {
|
||||
$('#modal-dialog-search').dialog('close');
|
||||
} else {
|
||||
$('#modal-dialog-user').dialog('close');
|
||||
}
|
||||
},
|
||||
onCheck: function(row) {
|
||||
setRow(row);
|
||||
},
|
||||
onUncheck: function(row) {
|
||||
unsetRow(row);
|
||||
},
|
||||
onCheckAll: function(rows) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
setRow(rows[i]);
|
||||
}
|
||||
},
|
||||
onUncheckAll: function(rows) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
unsetRow(rows[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -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,89 @@
|
||||
<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']}}
|
||||
<input type="hidden" name="customer_cost[type_id]" value="87">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table = '{{$form["table"]}}';
|
||||
(function($) {
|
||||
|
||||
$('#customer_cost_data_tool').append('<a class="btn btn-sm btn-default" href="javascript:importExcel();">导入</a>');
|
||||
$('#customer_cost_category_id').val(3);
|
||||
$('#customer_cost_category_id_select').val(3);
|
||||
|
||||
// 导入记录
|
||||
function importExcel() {
|
||||
var url = app.url('customerCost/compen/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_cost_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('customer_cost_data.customer_id', {
|
||||
query(query) {
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,57 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['master_table']}}-grid" 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.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,6 @@
|
||||
<div class="wrapper-sm">
|
||||
<form id="customer_cost_data_form-close" name="customer_cost_data_form-close" class="form-horizontal" method="post">
|
||||
<textarea class="form-control" name="close_remark" placeholder="请输入关闭或恢复原因"></textarea>
|
||||
<input value="{{$gets['id']}}" name="id" type="hidden">
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
<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']}}
|
||||
<input type="hidden" name="customer_cost[type_id]" value="46">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table = '{{$form["table"]}}';
|
||||
(function($) {
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.customer_cost_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('customer_cost_data.customer_id', {
|
||||
query(query) {
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,122 @@
|
||||
<div class="wrapper" style="padding-bottom:0;">
|
||||
|
||||
<div id="dialog-customer-toolbar">
|
||||
<form id="dialog-customer-search-form" name="dialog_customer_search_form" class="form-inline" method="get">
|
||||
@include('searchForm')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="m-t">
|
||||
<table id="dialog-customer" class="table-condensed"></table>
|
||||
<div id="dialog-customer-page"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
var selectBox = {};
|
||||
var params = {{json_encode($gets)}};
|
||||
var $table = $("#dialog-customer");
|
||||
|
||||
var model = [
|
||||
{name: "text", index: 'user.name', label: '客户名称', width: 220, align: 'left'},
|
||||
{name: "username", index: 'user.username', label: '客户代码', minWidth: 180, align: 'center'},
|
||||
{name: "id", index: 'user.id', label: 'ID', width: 60, align: 'center'}
|
||||
];
|
||||
|
||||
$table.jqGrid({
|
||||
caption: '',
|
||||
datatype: 'json',
|
||||
mtype: 'POST',
|
||||
url: app.url('customer/customer/dialog'),
|
||||
colModel: model,
|
||||
rowNum: 25,
|
||||
multiboxonly: params.multi == 0 ? true : false,
|
||||
multiselect: true,
|
||||
viewrecords: true,
|
||||
rownumbers: false,
|
||||
height: 340,
|
||||
footerrow: false,
|
||||
postData: params,
|
||||
pager: '#dialog-customer-page',
|
||||
|
||||
gridComplete: function() {
|
||||
// 单选时禁用全选按钮
|
||||
if(params.multi == 0) {
|
||||
$("#cb_" + this.p.id).prop('disabled', true);
|
||||
}
|
||||
$(this).jqGrid('setColsWidth');
|
||||
},
|
||||
loadComplete: function(res) {
|
||||
var me = $(this);
|
||||
me.jqGrid('initPagination', res);
|
||||
// 设置默认选中
|
||||
setSelecteds(res);
|
||||
},
|
||||
// 双击选中
|
||||
ondblClickRow: function(id) {
|
||||
if(params.multi == 1) {
|
||||
$table.jqGrid('setSelection', id);
|
||||
}
|
||||
getSelecteds();
|
||||
},
|
||||
});
|
||||
|
||||
function setSelecteds(res) {
|
||||
var ids = $('#'+params.id).val();
|
||||
ids = ids.split(',');
|
||||
$.each(ids, function(k, v) {
|
||||
if(v) {
|
||||
$table.jqGrid('setSelection', v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getSelecteds(dialog) {
|
||||
var rows = $table.jqGrid('getSelections');
|
||||
if(params.multi == 0) {
|
||||
if(rows.length > 1) {
|
||||
toastrError('只能选择一项。');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var id = [], text = [];
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
id.push(rows[i].id);
|
||||
text.push(rows[i].text);
|
||||
}
|
||||
|
||||
// 回写数据
|
||||
$('#'+params.id).val(id.join(','));
|
||||
$('#'+params.id+'_text').val(text.join(','));
|
||||
|
||||
// 关闭窗口
|
||||
$(dialog).dialog("close");
|
||||
return true;
|
||||
}
|
||||
|
||||
window.selectBox = {getSelecteds: getSelecteds};
|
||||
|
||||
var data = {{json_encode($search['forms'])}};
|
||||
var search = $('#dialog-customer-search-form').searchForm({
|
||||
data: data,
|
||||
init:function(e) {}
|
||||
});
|
||||
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var query = search.serializeArray();
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
|
||||
$table.jqGrid('setGridParam', {
|
||||
postData: params,
|
||||
page: 1
|
||||
}).trigger('reloadGrid');
|
||||
return false;
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,107 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['master_table']}}-grid" 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';
|
||||
|
||||
// 关闭费用
|
||||
action.close = function(data) {
|
||||
var me = this;
|
||||
var grid = config.grid;
|
||||
var selections = grid.api.getSelectedRows();
|
||||
if (selections.length != 1) {
|
||||
toastrError('只能选择一行记录');
|
||||
return;
|
||||
}
|
||||
formDialog({
|
||||
title: '关闭费用',
|
||||
url: app.url('customerCost/cost/close', {id: selections[0].id}),
|
||||
storeUrl: app.url('customerCost/cost/close'),
|
||||
id: 'customer_cost_data_form-close',
|
||||
dialogClass:'modal-sm',
|
||||
success: function(res) {
|
||||
toastrSuccess(res.data);
|
||||
grid.remoteData();
|
||||
$(this).dialog("close");
|
||||
},
|
||||
error: function(res) {
|
||||
toastrError(res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 自定义搜索方法
|
||||
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) {
|
||||
var data = params.data;
|
||||
if (params.node.rowPinned) {
|
||||
return;
|
||||
}
|
||||
if (data == undefined) {
|
||||
return;
|
||||
}
|
||||
if (data.master_id > 0) {
|
||||
|
||||
var index = data.master_sn.indexOf('QTFY');
|
||||
if (index >= 0) {
|
||||
data.src_type_id = 46;
|
||||
}
|
||||
|
||||
if (data.src_type_id == 46) {
|
||||
top.addTab('customerCost/cost/show?id=' + data.master_id, 'customerCost_cost_show', '其他费用');
|
||||
}
|
||||
if (data.src_type_id == 55) {
|
||||
top.addTab('promotion/review/show?id=' + data.src_id, 'promotion_review_show', '促销核销');
|
||||
}
|
||||
if (data.src_type_id == 57) {
|
||||
top.addTab('approach/review/show?id=' + data.src_id, 'approach_review_show', '进店核销');
|
||||
}
|
||||
if (data.src_type_id == 87) {
|
||||
top.addTab('customerCost/compen/show?id=' + data.master_id, 'customerCost_compen_show', '合同补损');
|
||||
}
|
||||
if (data.src_type_id == 88) {
|
||||
top.addTab('customerCost/rebate/show?id=' + data.master_id, 'customerCost_rebate_show', '合同返利');
|
||||
}
|
||||
if (data.src_type_id == 86) {
|
||||
top.addTab('customerCost/adjust/show?id=' + data.master_id, 'customerCost_adjust_show', '费用调整');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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,57 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<div class="wrapper-xs">
|
||||
<form id="dialog-customer_cost-search-form" name="dialog_customer_cost_search_form" class="form-inline search-inline-form" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="ref_customer_cost" class="ag-theme-balham" style="width:100%;height:380px;"></div>
|
||||
|
||||
<script>
|
||||
var $ref_customer_cost = null;
|
||||
var params = JSON.parse('{{json_encode($query)}}');
|
||||
(function($) {
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
grid.remoteParams = params;
|
||||
grid.rowMultiSelectWithClick = false;
|
||||
grid.rowSelection = 'multiple';
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, sortable: false, width: 40},
|
||||
{cellClass:'text-center', sortable: false, field: 'sn', headerName: '单据编号', minWidth: 160},
|
||||
{cellClass:'text-center', sortable: false, field: 'fee_category_id_name', headerName: '费用类型', width: 100},
|
||||
{cellClass:'text-center', sortable: false, field: 'customer_code', headerName: '客户编码', width: 100},
|
||||
{cellClass:'text-center', sortable: false, field: 'customer_name', headerName: '客户名称', width: 100},
|
||||
{cellClass:'text-right', sortable: false, type:'number', field: 'total_money', headerName: '费用金额', width: 100},
|
||||
{cellClass:'text-right', sortable: false, type:'number', field: 'money', headerName: '可用金额', width: 100},
|
||||
{cellClass:'text-right', sortable: false, type:'number', field: 'use_money', headerName: '已用金额', width: 100},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
var gridDiv = document.querySelector("#ref_customer_cost");
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
$ref_customer_cost = grid;
|
||||
|
||||
var data = JSON.parse('{{json_encode($search["forms"])}}');
|
||||
var search = $('#dialog-customer_cost-search-form').searchForm({
|
||||
data: data,
|
||||
init:function(e) {}
|
||||
});
|
||||
|
||||
search.find('#search-submit').on('click', function() {
|
||||
var query = search.serializeArray();
|
||||
$.map(query, function(row) {
|
||||
params[row.name] = row.value;
|
||||
});
|
||||
grid.remoteData(params);
|
||||
return false;
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
<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']}}
|
||||
<input type="hidden" name="customer_cost[type_id]" value="88">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table = '{{$form["table"]}}';
|
||||
(function($) {
|
||||
|
||||
$('#customer_cost-tool').html(' <a class="btn m-b-sm btn-sm btn-default" href="javascript:importExcel();">导入</a> ');
|
||||
|
||||
$('#customer_cost_category_id').val(2);
|
||||
$('#customer_cost_category_id_select').val(2);
|
||||
|
||||
// 导入记录
|
||||
function importExcel() {
|
||||
var url = app.url('customerCost/rebate/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_cost_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'customer_id';
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('customer_cost_data.customer_id', {
|
||||
query(query) {
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,57 @@
|
||||
{{$header["js"]}}
|
||||
<div class="panel no-border" id="{{$header['master_table']}}-controller">
|
||||
@include('headers')
|
||||
<div class="list-jqgrid">
|
||||
<div id="{{$header['master_table']}}-grid" 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.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,105 @@
|
||||
<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: 60},
|
||||
//{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-center', field: 'ym', headerName: '日期', width: 100},
|
||||
{cellClass:'text-center', field: 'sn', headerName: '订单编号', width: 140},
|
||||
{cellClass:'text-center', field: 'category_name', headerName: '单据类型', width: 140},
|
||||
{cellClass:'text-center', field: 'fee_src_sn', headerName: '单据编号', width: 140},
|
||||
{cellClass:'text-right', field: 'money', headerName: '金额', width: 100, type:'number', numberOptions: {places:2}, calcFooter: 'sum'},
|
||||
];
|
||||
|
||||
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>
|
||||
Reference in New Issue
Block a user