创建版本
This commit is contained in:
@@ -0,0 +1,350 @@
|
||||
<?php namespace Gdoo\Promotion\Controllers;
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use URL;
|
||||
use DB;
|
||||
use ZipArchive;
|
||||
use Session;
|
||||
|
||||
use Gdoo\Promotion\Models\Promotion;
|
||||
use Gdoo\Promotion\Models\PromotionMaterial as Material;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
use Exception;
|
||||
|
||||
class MaterialController extends DefaultController
|
||||
{
|
||||
public $permission = ['detail', 'dialog', 'store', 'archive', 'download'];
|
||||
|
||||
// 促销核销列表
|
||||
public function indexAction()
|
||||
{
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'promotion_material',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => '-1'],
|
||||
]);
|
||||
|
||||
$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('promotion_material_file as f', 'f.material_id', '=', 'promotion_material.id');
|
||||
|
||||
$model->orderBy($header['sort'], $header['order']);
|
||||
|
||||
foreach ($search['where'] as $where) {
|
||||
if ($where['active']) {
|
||||
$model->search($where);
|
||||
}
|
||||
}
|
||||
|
||||
if ($query['by'] >= 0) {
|
||||
$model->where('promotion_material.status', $query['by']);
|
||||
}
|
||||
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$header['select'][] = 'promotion_material.promotion_id';
|
||||
$header['select'][] = 'f.path';
|
||||
$header['select'][] = 'f.created_by';
|
||||
$header['select'][] = 'f.created_at';
|
||||
|
||||
$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-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'] = Material::$tabs;
|
||||
$header['bys'] = Material::$bys;
|
||||
$header['js'] = Grid::js($header);
|
||||
|
||||
return $this->display([
|
||||
'header' => $header,
|
||||
]);
|
||||
}
|
||||
|
||||
// 促销核销明细
|
||||
public function detailAction()
|
||||
{
|
||||
$search = search_form([
|
||||
'status' => '',
|
||||
'promotion_id' => 0,
|
||||
]);
|
||||
|
||||
$query = $search['query'];
|
||||
|
||||
$promotion = Promotion::where('id', $query['promotion_id'])->first();
|
||||
|
||||
$model = Material::leftJoin('promotion', 'promotion.id', '=', 'promotion_material.promotion_id')
|
||||
->where('promotion_material.promotion_id', $query['promotion_id']);
|
||||
|
||||
if (is_numeric($query['status'])) {
|
||||
$model->where('promotion_material.status', $query['status']);
|
||||
}
|
||||
|
||||
$rows = $model->orderBy('promotion_material.id', 'desc')
|
||||
->get(['promotion_material.*','promotion.sn'])
|
||||
->toArray();
|
||||
|
||||
$items = [];
|
||||
$audits = [];
|
||||
|
||||
foreach ($rows as $i => $row) {
|
||||
$files = DB::table('promotion_material_file')->where('material_id', $row['id'])->get();
|
||||
$images = [];
|
||||
foreach ($files as $file) {
|
||||
$path_file = upload_path().'/'.$file['path'];
|
||||
if (is_file($path_file)) {
|
||||
$images[] = ['url' => url('uploads/'.$file['path']), 'name' => ''];
|
||||
}
|
||||
}
|
||||
$audits[$row['status']] ++;
|
||||
$items[$row['id']] = $images;
|
||||
$rows[$i]['images'] = $images;
|
||||
}
|
||||
|
||||
$changes = [
|
||||
0 => ['btn' => 'default', 'text' => '未审核'],
|
||||
1 => ['btn' => 'success', 'text' => '已审合格'],
|
||||
2 => ['btn' => 'danger', 'text' => '已审不合格'],
|
||||
];
|
||||
|
||||
$tabs = [
|
||||
'name' => 'status',
|
||||
'items' => [
|
||||
['id' => '', 'name' => '全部'],
|
||||
['id' => 0, 'name' => '未审核'],
|
||||
['id' => 1, 'name' => '已审合格'],
|
||||
['id' => 2, 'name' => '已审不合格']
|
||||
]
|
||||
];
|
||||
|
||||
return $this->display([
|
||||
'tabs' => $tabs,
|
||||
'items' => $items,
|
||||
'rows' => $rows,
|
||||
'audits' => $audits,
|
||||
'promotion' => $promotion,
|
||||
'changes' => $changes,
|
||||
'search' => $search,
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取核销列表
|
||||
public function dialogAction()
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
$customer_id = $user->customer->id;
|
||||
|
||||
$rows = Promotion::with('datas')->where('material_id', '!=', 2)
|
||||
->where('status', 0)
|
||||
->where('customer_id', $customer_id)
|
||||
->where('number', '!=', '')
|
||||
->get(['id', 'number as text','data_4', 'data_19', 'start_at', 'end_at']);
|
||||
|
||||
foreach ($rows as &$row) {
|
||||
$row->products = $row->datas->implode('product_name', ',');
|
||||
}
|
||||
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
$id = Request::get('id');
|
||||
$row = Material::with('promotion')
|
||||
->where('id', $id)
|
||||
->first();
|
||||
|
||||
// 获取核销图片
|
||||
$_files = explode(',', $row['files']);
|
||||
$files = DB::table('promotion_material_file')->whereIn('id', $_files)->get();
|
||||
|
||||
foreach ($files as $file) {
|
||||
$file = upload_path().'/'.$file['path'].'/'.$file['file'];
|
||||
// 生成缩略图
|
||||
thumb($file, 80, 80);
|
||||
}
|
||||
|
||||
$row['images'] = $files;
|
||||
$row['upload_url'] = URL::to('/uploads');
|
||||
|
||||
if (Request::wantsJson()) {
|
||||
return response()->json($row);
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'row' => $row,
|
||||
]);
|
||||
}
|
||||
|
||||
// 促销核销审核
|
||||
public function auditAction()
|
||||
{
|
||||
$id = (array)Request::get('id');
|
||||
$status = Request::get('status');
|
||||
$rows = DB::table('promotion_material')
|
||||
->whereIn('id', $id)->get()->toArray();
|
||||
|
||||
if (is_array($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
$row['status'] = $status;
|
||||
DB::table('promotion_material')->where('id', $row['id'])->update($row);
|
||||
}
|
||||
}
|
||||
return $this->json('操作成功。', true);
|
||||
}
|
||||
|
||||
// 促销核销审核
|
||||
public function archiveAction()
|
||||
{
|
||||
$id = (array)Request::get('id');
|
||||
|
||||
$rows = DB::table('promotion_material')
|
||||
->whereIn('id', $id)->get();
|
||||
|
||||
$zip_file = upload_path('promotion/material/archive.zip');
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($zip_file, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$files = DB::table('promotion_material_file')->where('material_id', $row['id'])->get();
|
||||
foreach ($files as $i => $file) {
|
||||
$path_file = upload_path().'/'.$file['path'];
|
||||
if (is_file($path_file)) {
|
||||
$zip->addFile($path_file, $row['name'].'_'.$row['location'].'_'.$i.'.'.$file['type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
return $this->json('', true);
|
||||
}
|
||||
|
||||
// 促销核销审核
|
||||
public function downloadAction()
|
||||
{
|
||||
$sn = Request::get('sn');
|
||||
if(empty($sn)) {
|
||||
return $this->json('促销编号不能为空。');
|
||||
}
|
||||
return response()->download(upload_path('promotion/material/archive.zip'), $sn.'_'.date('Y-m-d').'.zip');
|
||||
}
|
||||
|
||||
public function storeAction()
|
||||
{
|
||||
// 上传文件
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
|
||||
$promotion = DB::table('promotion')
|
||||
->where('id', $gets['promotion_id'])
|
||||
->first();
|
||||
|
||||
if (empty($promotion)) {
|
||||
return $this->json('促销编号不能为空。');
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$material_id = DB::table('promotion_material')->insertGetId($gets);
|
||||
$images = Request::file('images');
|
||||
$path = 'promotion/material/'.date('Y/m');
|
||||
$upload_path = upload_path().'/'.$path;
|
||||
|
||||
$rows = [];
|
||||
foreach ($images as $image) {
|
||||
if ($image->isValid()) {
|
||||
// 文件后缀名
|
||||
$extension = $image->getClientOriginalExtension();
|
||||
// 文件新名字
|
||||
$filename = date('dhis_').str_random(4).'.'.$extension;
|
||||
$filename = mb_strtolower($filename);
|
||||
if ($image->move($upload_path, $filename)) {
|
||||
|
||||
// 修改图片大小
|
||||
imageResize($upload_path.'/'.$filename, 1024, 1024);
|
||||
|
||||
$rows[] = DB::table('promotion_material_file')->insertGetId([
|
||||
'material_id' => $material_id,
|
||||
'path' => $path. '/'. $filename,
|
||||
'name' => $filename,
|
||||
'type' => $extension,
|
||||
'status' => 1,
|
||||
'size' => $image->getClientSize(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
return $this->json('照片保存成功。', true);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
DB::rollBack();
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除核销
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$var1 = (array)Request::get('id');
|
||||
$ids = [];
|
||||
foreach($var1 as $id) {
|
||||
$ids[] = floatval($id);
|
||||
}
|
||||
$rows = Material::whereIn('id', $ids)->get();
|
||||
foreach ($rows as $row) {
|
||||
$files = DB::table('promotion_material_file')->where('material_id', $row['id'])->pluck('id');
|
||||
attachment_delete('promotion_material_file', $files);
|
||||
$row->delete();
|
||||
}
|
||||
return $this->json('促销核销删除成功。', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
<?php namespace Gdoo\Promotion\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Promotion\Models\Promotion;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Services\BadgeService;
|
||||
use Gdoo\Promotion\Services\PromotionService;
|
||||
|
||||
use Gdoo\Index\Controllers\WorkflowController;
|
||||
|
||||
class PromotionController extends WorkflowController
|
||||
{
|
||||
public $permission = ['dialog', 'serviceSaleOrder', 'useCount', 'product'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'promotion',
|
||||
'referer' => 1,
|
||||
'search' => ['by' => ''],
|
||||
]);
|
||||
|
||||
$cols = $header['cols'];
|
||||
|
||||
// 自定义列
|
||||
$customFields = [
|
||||
'zp_money' => [
|
||||
'headerName' => '赠品金额(元)',
|
||||
'field' => 'zp_money',
|
||||
'calcFooter' => 'sum',
|
||||
'width' => 100,
|
||||
'suppressMenu' => true,
|
||||
'type' => 'number',
|
||||
'cellStyle' => ['text-align' => 'right'],
|
||||
]
|
||||
];
|
||||
$cols = Grid::addColumns($cols, 'master_cash_amount', $customFields);
|
||||
|
||||
$cols['master_product']['cellRenderer'] = 'htmlCellRenderer';
|
||||
$cols['master_cash_amount']['cellRenderer'] = 'htmlCellRenderer';
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
if ($region['authorise']) {
|
||||
foreach ($region['whereIn'] as $key => $where) {
|
||||
$model->whereIn($key, $where);
|
||||
}
|
||||
}
|
||||
|
||||
$model->leftJoin(DB::raw('(SELECT sum(fact_verification_cost) as master_cash_amount, min(date) as master_cash_date, apply_id FROM promotion_review where status = 1 group by apply_id) as b'), 'promotion.id', '=', 'b.apply_id');
|
||||
$header['select'][] = 'b.master_cash_amount';
|
||||
$header['select'][] = 'b.master_cash_date';
|
||||
|
||||
$model->select($header['select']);
|
||||
$model->addSelect(DB::raw("case when promotion.type_id = 2 then promotion.undertake_money else 0 end as zp_money"));
|
||||
|
||||
$rows = $model->paginate($query['limit'])->appends($query);
|
||||
|
||||
$items = Grid::dataFilters($rows, $header, function($item) {
|
||||
$item['master_cash_amount'] = '<a href="javascript:;" data-toggle="event" data-action="fee_detail" data-master_id="'.$item['master_id'].'" class="option">'.$item['master_cash_amount'].'</a>';
|
||||
$item['master_product'] = '<a href="javascript:;" data-toggle="event" data-action="product" data-master_id="'.$item['master_id'].'" class="option">明细</a>';
|
||||
return $item;
|
||||
});
|
||||
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'] = Promotion::$tabs;
|
||||
$header['bys'] = Promotion::$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'] = 'promotion';
|
||||
$header['id'] = $id;
|
||||
|
||||
// 客户权限
|
||||
$header['region'] = ['field' => 'customer_id'];
|
||||
$header['authorise'] = ['action' => 'index', 'field' => 'created_id'];
|
||||
|
||||
// 获取核销单
|
||||
$review = DB::table('promotion_review')->where('apply_id', $id)->first();
|
||||
$header['joint'] = [
|
||||
['name' => '关联订单', 'action' => 'sale_order', 'field' => 'order_id'],
|
||||
['name' => '核销单', 'action' => 'promotion_review', 'field' => 'id'],
|
||||
['name' => '核销资料', 'action' => 'material', 'field' => 'id'],
|
||||
];
|
||||
|
||||
$form = Form::make($header);
|
||||
$tpl = $action == 'print' ? 'print' : 'create';
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
'review' => $review,
|
||||
], $tpl);
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 审核促销
|
||||
public function auditAction()
|
||||
{
|
||||
return $this->createAction('audit');
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function printAction()
|
||||
{
|
||||
$id = (int) Request::get('id');
|
||||
$template_id = (int) Request::get('template_id');
|
||||
$header['action'] = 'print';
|
||||
$header['code'] = 'promotion';
|
||||
$header['id'] = $id;
|
||||
$header['template_id'] = $template_id;
|
||||
$this->layout = 'layouts.print2';
|
||||
$form = Form::make($header);
|
||||
$form['template']['name'] = '促销申请';
|
||||
print_prince($this->display([
|
||||
'form' => $form,
|
||||
], 'print'));
|
||||
}
|
||||
|
||||
// 赠品促销参照到订单
|
||||
public function serviceSaleOrderAction()
|
||||
{
|
||||
$search = search_form(
|
||||
['advanced' => ''], [
|
||||
['form_type' => 'text', 'name' => '促销编号', 'field' => 'promotion_sn', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '客户名称', 'field' => 'customer_id_customer.name', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'promotion',
|
||||
]);
|
||||
$_search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
if ($query['master']) {
|
||||
|
||||
$model = DB::table('promotion');
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->where('promotion.customer_id', $query['customer_id'])
|
||||
->whereRaw('promotion.id in (select promotion_id from ('.PromotionService::getSurplusPromotionSql().') as sp where type_id in (1, 2))')
|
||||
->where('promotion.customer_id', $query['customer_id'])
|
||||
->whereRaw('isnull(promotion.is_close, 0) = 0');
|
||||
|
||||
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->selectRaw('
|
||||
promotion.*,
|
||||
promotion.status as master_status,
|
||||
promotion.id as master_id,
|
||||
customer_id_customer.code as customer_code,
|
||||
customer_id_customer.name as customer_name,
|
||||
customer_id_customer.warehouse_contact,
|
||||
customer_id_customer.warehouse_phone,
|
||||
customer_id_customer.warehouse_address
|
||||
');
|
||||
$rows = $model->get();
|
||||
$rows = Grid::dataFilters($rows, $header, function($row) {
|
||||
if ($row['type_id'] == 1) {
|
||||
$row['type_name'] = '物资促销';
|
||||
} else if($row['type_id'] == 2) {
|
||||
$row['type_name'] = '赠品促销';
|
||||
}
|
||||
return $row;
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$sql = "temp.price,
|
||||
temp.quantity,
|
||||
temp.ysy_num,
|
||||
temp.wsy_num,
|
||||
temp.product_id,
|
||||
temp.id,
|
||||
temp.promotion_sn,
|
||||
temp.promotion_id,
|
||||
temp.type_id,
|
||||
temp.customer_id,
|
||||
temp.promotion_data_id,
|
||||
temp.customer_name,
|
||||
temp.customer_code,
|
||||
p.code AS product_code,
|
||||
p.name AS product_name,
|
||||
p.spec AS product_spec,
|
||||
u.name AS product_unit,
|
||||
p.weight,
|
||||
|
||||
temp.promotion_id as fee_src_id,
|
||||
temp.promotion_sn as fee_src_sn,
|
||||
temp.id as promotion_data_id
|
||||
|
||||
FROM (SELECT isnull(a.price, 0) AS price,
|
||||
isnull(a.quantity, 0) AS quantity,
|
||||
isnull(d.quantity, 0) AS ysy_num,
|
||||
isnull(a.quantity, 0) - isnull(d.quantity, 0) AS wsy_num,
|
||||
a.product_id,
|
||||
a.id,
|
||||
b.sn AS promotion_sn,
|
||||
b.id AS promotion_id,
|
||||
b.type_id,
|
||||
b.customer_id,
|
||||
d.promotion_data_id,
|
||||
c.name AS customer_name,
|
||||
c.code AS customer_code
|
||||
FROM promotion_data a
|
||||
LEFT JOIN promotion b ON a.promotion_id = b.id
|
||||
LEFT JOIN customer c ON b.customer_id = c.id
|
||||
LEFT JOIN ( SELECT sum(isnull(customer_order_data.delivery_quantity, 0)) AS quantity,
|
||||
customer_order_data.promotion_data_id
|
||||
FROM customer_order_data
|
||||
WHERE (customer_order_data.promotion_data_id IS NOT NULL)
|
||||
GROUP BY customer_order_data.promotion_data_id
|
||||
) d ON a.id = d.promotion_data_id
|
||||
) temp
|
||||
LEFT JOIN product p ON temp.product_id = p.id
|
||||
LEFT JOIN product_unit u ON p.unit_id = u.id";
|
||||
$model = DB::query()->selectRaw($sql);
|
||||
$model->whereRaw('isnull(temp.wsy_num, 0) > 0')
|
||||
->whereIn('type_id', [1, 2])
|
||||
->where('customer_id', $query['customer_id'])
|
||||
->whereIn('promotion_id', (array)$query['ids']);
|
||||
|
||||
if ($query['sort'] && $query['order']) {
|
||||
$model->orderBy($query['sort'], $query['order']);
|
||||
}
|
||||
|
||||
/*
|
||||
'17' as fee_src_type_id,
|
||||
'6' as fee_category_id,
|
||||
'赠品' as fee_category_id_name,
|
||||
'2' as type_id,
|
||||
'赠品' as type_id_name
|
||||
*/
|
||||
|
||||
$rows = $model->get();
|
||||
$rows->transform(function ($row) {
|
||||
// 赠品
|
||||
if ($row['type_id'] == 2) {
|
||||
$row['fee_src_type_id'] = 17;
|
||||
$row['fee_category_id'] = 6;
|
||||
$row['fee_category_id_name'] = '赠品';
|
||||
$row['type_id'] = 2;
|
||||
$row['type_id_name'] = '赠品';
|
||||
// 物料
|
||||
} else if ($row['type_id'] == 1) {
|
||||
$row['fee_src_type_id'] = 17;
|
||||
$row['fee_category_id'] = 7;
|
||||
$row['fee_category_id_name'] = '物料';
|
||||
$row['type_id'] = 4;
|
||||
$row['type_id_name'] = '物料';
|
||||
}
|
||||
return $row;
|
||||
});
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
// 产品明细
|
||||
public function productAction()
|
||||
{
|
||||
$query = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$rows = DB::table('promotion_data')
|
||||
->leftJoin('product', 'product.id', '=', 'promotion_data.product_id')
|
||||
->where('promotion_id', $query['id'])
|
||||
->orderBy('product.code', 'asc')
|
||||
->get(['product.*']);
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
return $this->render(['query' => $query]);
|
||||
}
|
||||
|
||||
public function closeAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$row = DB::table('promotion')->where('id', $gets['id'])->first();
|
||||
DB::table('promotion')->where('id', $gets['id'])->update([
|
||||
'is_close' => !$row['is_close']
|
||||
]);
|
||||
return $this->json('操作成功。', true);
|
||||
}
|
||||
}
|
||||
|
||||
// 可用列表
|
||||
public function useCountAction()
|
||||
{
|
||||
$customer_id = Request::get('customer_id');
|
||||
|
||||
$count = DB::table('promotion')
|
||||
->where('promotion.customer_id', $customer_id)
|
||||
->whereRaw('isnull(promotion.is_close, 0) = 0 and promotion.id in (select promotion_id from ('.PromotionService::getSurplusPromotionSql().') as sp where type_id in (1,2))')
|
||||
->count('promotion.id');
|
||||
|
||||
return $this->json($count, true);
|
||||
}
|
||||
|
||||
// 核销对话框
|
||||
public function dialogAction()
|
||||
{
|
||||
$search = search_form(
|
||||
['advanced' => ''], [
|
||||
['form_type' => 'text', 'name' => '客户名称', 'field' => 'customer_id_customer.name', 'options' => []],
|
||||
['form_type' => 'text', 'name' => '促销编号', 'field' => 'promotion.sn', 'options' => []],
|
||||
], 'model');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'promotion',
|
||||
]);
|
||||
|
||||
$_search = $header['search_form'];
|
||||
$query = $search['query'];
|
||||
|
||||
if (Request::method() == 'POST') {
|
||||
|
||||
if ($query['master']) {
|
||||
|
||||
$model = DB::table('promotion');
|
||||
|
||||
foreach ($header['join'] as $join) {
|
||||
$model->leftJoin($join[0], $join[1], $join[2], $join[3]);
|
||||
}
|
||||
|
||||
$model->whereRaw('NOT EXISTS (select apply_id from promotion_review where apply_id = promotion.id and apply_id IS NOT NULL)')
|
||||
->where('promotion.need_review', 1)
|
||||
->where('promotion.status', 1)
|
||||
->whereRaw('isnull(promotion.is_close, 0) = 0')
|
||||
->orderBy('promotion.id', 'desc');
|
||||
|
||||
if ($query['sort'] && $query['order']) {
|
||||
$model->orderBy($query['sort'], $query['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->selectRaw('
|
||||
promotion.sn,
|
||||
promotion.created_at as apply_dt,
|
||||
promotion.start_dt,
|
||||
promotion.end_dt,
|
||||
promotion.promote_scope,
|
||||
'.sql_float_varchar('promotion.apply_fee', 20).' AS apply_money,
|
||||
'.sql_float_varchar('promotion.undertake_money', 20).' AS undertake_money,
|
||||
'.sql_float_varchar('promotion.undertake_money', 20).' AS verification_cost,
|
||||
promotion.status as master_status,
|
||||
promotion.id as master_id,
|
||||
promotion.id,
|
||||
promotion.customer_id,
|
||||
customer_id_customer.region_id,
|
||||
customer_id_region_id_customer_region.name as region_name,
|
||||
customer_id_customer.code as customer_code,
|
||||
customer_id_customer.name as customer_name,
|
||||
customer_id_customer.warehouse_contact,
|
||||
customer_id_customer.warehouse_phone,
|
||||
customer_id_customer.warehouse_address
|
||||
');
|
||||
|
||||
$rows = $model->get();
|
||||
$rows = Grid::dataFilters($rows, $header);
|
||||
|
||||
} else {
|
||||
|
||||
$model = DB::table('promotion_data')
|
||||
->leftJoin('product', 'product.id', '=', 'promotion_data.product_id')
|
||||
->leftJoin('promotion', 'promotion.id', '=', 'promotion_data.promotion_id')
|
||||
->leftJoin('product_unit', 'product_unit.id', '=', 'product.unit_id');
|
||||
|
||||
$model->whereRaw('NOT EXISTS (select apply_id from promotion_review where apply_id = promotion.id and apply_id IS NOT NULL)')
|
||||
->whereIn('promotion.id', (array)$query['ids']);
|
||||
|
||||
if ($query['sort'] && $query['order']) {
|
||||
$model->orderBy($query['sort'], $query['order']);
|
||||
}
|
||||
|
||||
$model->selectRaw("
|
||||
promotion_data.*,
|
||||
promotion.id as promotion_id,
|
||||
promotion.sn as promotion_sn,
|
||||
product.code as product_code,
|
||||
product.name as product_name,
|
||||
product.spec as product_spec,
|
||||
product.barcode as product_barcode,
|
||||
product.unit_id as unit_id,
|
||||
product_unit.name as product_unit,
|
||||
product.weight,
|
||||
promotion.id as apply_id,
|
||||
'1' as apply_type_id,
|
||||
promotion_data.id as apply_data_id
|
||||
");
|
||||
$rows = $model->get();
|
||||
}
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
|
||||
return $this->render([
|
||||
'search' => $search,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
public function batchEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
DB::table('promotion')->whereIn('id', $ids)->update([
|
||||
$gets['field'] => $gets['search_0'],
|
||||
]);
|
||||
return $this->json('修改完成。', true);
|
||||
}
|
||||
$header = Grid::batchEdit([
|
||||
'code' => 'promotion',
|
||||
'columns' => ['customer_id', 'tax_id'],
|
||||
]);
|
||||
return view('batchEdit', [
|
||||
'gets' => $gets,
|
||||
'header' => $header
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除促销
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'promotion', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php namespace Gdoo\Promotion\Controllers;
|
||||
|
||||
use DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
use Gdoo\User\Models\User;
|
||||
use Gdoo\Promotion\Models\PromotionReview;
|
||||
|
||||
use Gdoo\Model\Grid;
|
||||
use Gdoo\Model\Form;
|
||||
|
||||
use Gdoo\Index\Controllers\WorkflowController;
|
||||
|
||||
class ReviewController extends WorkflowController
|
||||
{
|
||||
public $permission = ['dialog', 'reference', 'useCount', 'feeDetail'];
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// 客户权限
|
||||
$region = regionCustomer('customer_id_customer');
|
||||
|
||||
$header = Grid::header([
|
||||
'code' => 'promotion_review',
|
||||
'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']);
|
||||
|
||||
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']],
|
||||
['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'] = PromotionReview::$tabs;
|
||||
$header['bys'] = PromotionReview::$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['action'] = $action;
|
||||
$header['code'] = 'promotion_review';
|
||||
$header['id'] = $id;
|
||||
|
||||
$header['joint'] = [
|
||||
['name' => '申请单', 'action' => 'apply', 'field' => 'apply_id'],
|
||||
['name' => '兑现明细', 'action' => 'cash_detail', 'field' => 'apply_id'],
|
||||
];
|
||||
|
||||
$form = Form::make($header);
|
||||
$tpl = $action == 'print' ? 'print' : 'create';
|
||||
return $this->display([
|
||||
'form' => $form,
|
||||
], $tpl);
|
||||
}
|
||||
|
||||
// 编辑促销
|
||||
public function editAction()
|
||||
{
|
||||
return $this->createAction();
|
||||
}
|
||||
|
||||
// 审核促销
|
||||
public function auditAction()
|
||||
{
|
||||
return $this->createAction('audit');
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function showAction()
|
||||
{
|
||||
return $this->createAction('show');
|
||||
}
|
||||
|
||||
// 显示促销
|
||||
public function printAction()
|
||||
{
|
||||
$this->layout = 'layouts.print2';
|
||||
print_prince($this->createAction('print'));
|
||||
}
|
||||
|
||||
// 批量编辑
|
||||
public function batchEditAction()
|
||||
{
|
||||
$gets = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = explode(',', $gets['ids']);
|
||||
DB::table('promotion_review')->whereIn('id', $ids)->update([
|
||||
$gets['field'] => $gets['search_0'],
|
||||
]);
|
||||
return $this->json('修改完成。', true);
|
||||
}
|
||||
$header = Grid::batchEdit([
|
||||
'code' => 'promotion_review',
|
||||
'columns' => ['customer_id', 'tax_id'],
|
||||
]);
|
||||
return view('batchEdit', [
|
||||
'gets' => $gets,
|
||||
'header' => $header
|
||||
]);
|
||||
}
|
||||
|
||||
// 兑现明细
|
||||
public function feeDetailAction()
|
||||
{
|
||||
$query = Request::all();
|
||||
if (Request::method() == 'POST') {
|
||||
$rows = DB::table('promotion_review')->where('apply_id', $query['id'])->orderBy('id', 'desc')->get();
|
||||
return $this->json($rows, true);
|
||||
}
|
||||
return $this->render(['query' => $query]);
|
||||
}
|
||||
|
||||
// 删除促销
|
||||
public function deleteAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$ids = Request::get('id');
|
||||
return Form::remove(['code' => 'promotion_review', 'ids' => $ids]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php namespace Gdoo\Promotion\Hooks;
|
||||
|
||||
class PromotionHook
|
||||
{
|
||||
public function onAfterForm($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeStore($params)
|
||||
{
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeAudit($params) {
|
||||
// 流程结束写入生效日期
|
||||
$master = $params['master'];
|
||||
$master['actived_dt'] = date('Y-m-d');
|
||||
$params['master'] = $master;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onFormFieldFilter($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onAfterStore($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php namespace Gdoo\Promotion\Hooks;
|
||||
|
||||
use DB;
|
||||
use Exception;
|
||||
|
||||
class ReviewHook
|
||||
{
|
||||
public function onBeforeForm($params) {
|
||||
$row = $params['row'];
|
||||
$promotion = DB::table('promotion')->where('id', $row['promotion_id'])->first();
|
||||
$row['field021'] = $promotion['field021'];
|
||||
$row['field022'] = $promotion['field022'];
|
||||
$row['field023'] = $promotion['field023'];
|
||||
$row['field024'] = $promotion['field024'];
|
||||
$row['field025'] = $promotion['field025'];
|
||||
$row['field026'] = $promotion['field026'];
|
||||
$row['field027'] = $promotion['field027'];
|
||||
$row['field028'] = $promotion['field028'];
|
||||
$row['field029'] = $promotion['field029'];
|
||||
|
||||
$params['row'] = $row;
|
||||
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'];
|
||||
// 生效费用
|
||||
$row = DB::table('promotion_review')->where('id', $id)->first();
|
||||
if ($row['use_order'] == 1) {
|
||||
// 生成费用类型
|
||||
$categorys = [1 => 4, 3 => 5];
|
||||
$master = [
|
||||
'sn' => $row['sn'],
|
||||
'date' => $row['date'],
|
||||
'category_id' => $categorys[$row['pay_type']],
|
||||
'type_id' => 55,
|
||||
'remark' => $row['remark'],
|
||||
'status' => 1,
|
||||
];
|
||||
$cost_id = DB::table('customer_cost')->insertGetId($master);
|
||||
DB::table('customer_cost_data')->insert([
|
||||
'cost_id' => $cost_id,
|
||||
'customer_id' => $row['customer_id'],
|
||||
'money' => $row['fact_verification_cost'],
|
||||
'remain_money' => $row['fact_verification_cost'],
|
||||
'src_id' => $row['id'],
|
||||
'src_sn' => $row['sn'],
|
||||
'src_type_id' => 55,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeAbort($params) {
|
||||
$id = $params['id'];
|
||||
$review = DB::table('promotion_review')->where('id', $id)->first();
|
||||
$cost_count = DB::table('customer_cost')->where('sn', $review['sn'])->count();
|
||||
if ($cost_count > 0) {
|
||||
abort_error('客户费用单号['.$review['sn'].']已经存在无法弃审。');
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function onBeforeDelete($params) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class Promotion extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'promotion', 'url' => 'promotion/promotion/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');
|
||||
}
|
||||
|
||||
public function datas()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Promotion\Models\PromotionData');
|
||||
}
|
||||
|
||||
public function cashs()
|
||||
{
|
||||
return $this->hasMany('Gdoo\Promotion\Models\PromotionCash');
|
||||
}
|
||||
|
||||
public static $materials = [
|
||||
['id' => 0, 'name' => '待审核', 'color' => 'default'],
|
||||
['id' => 1, 'name' => '不合格', 'color' => 'info'],
|
||||
['id' => 2, 'name' => '已审核', 'color' => 'success']
|
||||
];
|
||||
|
||||
public static $cashs = [
|
||||
['id' => 1, 'name' => '现配', 'color' => 'default'],
|
||||
['id' => 2, 'name' => '凭兑', 'color' => 'info'],
|
||||
];
|
||||
|
||||
public static $status = [
|
||||
['id' => 0, 'name' => '待审', 'color' => 'default'],
|
||||
['id' => 1, 'name' => '已审', 'color' => 'info'],
|
||||
];
|
||||
|
||||
public function scopeDialog($q, $value)
|
||||
{
|
||||
return $q->whereIn('id', $value)->pluck('sn', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use DB;
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
use Gdoo\Promotion\Models\Promotion;
|
||||
use Gdoo\Promotion\Models\PromotionCashData;
|
||||
|
||||
class PromotionCash extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_cash';
|
||||
|
||||
public function datas()
|
||||
{
|
||||
return $this->hasMany(PromotionCashData::class, 'cash_id');
|
||||
}
|
||||
|
||||
public function promotion()
|
||||
{
|
||||
return $this->belongsTo(Promotion::class);
|
||||
}
|
||||
|
||||
// 促销兑现单生成客户订单
|
||||
public function makeCustomerOrder($cashId)
|
||||
{
|
||||
// 客户订单数
|
||||
$cash = PromotionCash::with('datas')->find($cashId);
|
||||
|
||||
$total_num = DB::table('order')->count('id');
|
||||
|
||||
$master['customer_id'] = $cash->promotion->customer_id;
|
||||
$master['flow_step_id'] = 1;
|
||||
$master['number'] = 'CXDX-'.date('Y-m').'-'.($total_num + 1);
|
||||
$master['add_time'] = time();
|
||||
$orderId = DB::table('order')->insertGetId($master);
|
||||
|
||||
foreach ($cash->datas as $data) {
|
||||
$row = [
|
||||
'order_id' => $orderId,
|
||||
'customer_id' => $cash->promotion->customer_id,
|
||||
'product_id' => $data['product_id'],
|
||||
'price' => $data['price'],
|
||||
'amount' => $data['quantity'],
|
||||
'type' => $data['type_id'],
|
||||
'content' => $data['remark'],
|
||||
];
|
||||
DB::table('order_data')->insert($row);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
use Gdoo\Promotion\Models\PromotionCash;
|
||||
|
||||
class PromotionCashData extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_cash_data';
|
||||
|
||||
public function cash()
|
||||
{
|
||||
return $this->belongsTo(PromotionCash::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class PromotionData extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_data';
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class PromotionMaterial extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_material';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'promotion', 'url' => 'promotion/material/index', 'name' => '资料列表'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '-1', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
|
||||
public function promotion()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Promotion\Models\Promotion');
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo('Gdoo\Customer\Models\Contact');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php namespace Gdoo\Promotion\Models;
|
||||
|
||||
use Gdoo\Index\Models\BaseModel;
|
||||
|
||||
class PromotionReview extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_review';
|
||||
|
||||
public static $tabs = [
|
||||
'name' => 'tab',
|
||||
'items' => [
|
||||
['value' => 'review', 'url' => 'promotion/review/index', 'name' => '促销核销'],
|
||||
]
|
||||
];
|
||||
|
||||
public static $bys = [
|
||||
'name' => 'by',
|
||||
'items' => [
|
||||
['value' => '', 'name' => '全部'],
|
||||
['value' => 'divider'],
|
||||
['value' => 'day', 'name' => '今日创建'],
|
||||
['value' => 'week', 'name' => '本周创建'],
|
||||
['value' => 'month', 'name' => '本月创建'],
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php namespace Gdoo\Promotion\Services;
|
||||
|
||||
use Gdoo\Index\Services\BadgeService;
|
||||
|
||||
class PromotionService
|
||||
{
|
||||
/**
|
||||
* 获取待办的促销申请
|
||||
*/
|
||||
public static function getBadge()
|
||||
{
|
||||
return BadgeService::getModelTodo('promotion');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取为使用的促销sql
|
||||
*
|
||||
*/
|
||||
public static function getSurplusPromotionSql()
|
||||
{
|
||||
return "SELECT * FROM (SELECT
|
||||
isnull(d.quantity, 0) AS ysy_num,
|
||||
isnull(a.quantity, 0) - isnull(d.quantity, 0) AS wsy_num,
|
||||
b.type_id,
|
||||
b.id AS promotion_id
|
||||
FROM promotion_data a
|
||||
LEFT JOIN promotion b ON a.promotion_id = b.id
|
||||
LEFT JOIN customer c ON b.customer_id = c.id
|
||||
LEFT JOIN (
|
||||
SELECT sum(isnull(customer_order_data.delivery_quantity, 0)) AS quantity,
|
||||
customer_order_data.promotion_data_id
|
||||
FROM customer_order_data
|
||||
WHERE customer_order_data.promotion_data_id IS NOT NULL
|
||||
GROUP BY customer_order_data.promotion_data_id) d ON a.id = d.promotion_data_id
|
||||
) as temp
|
||||
WHERE isnull(temp.wsy_num, 0) > 0";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "促销管理",
|
||||
"version" => "1.0",
|
||||
"description" => "促销管理。",
|
||||
"listens" => [
|
||||
'promotion' => 'Gdoo\Promotion\Hooks\PromotionHook',
|
||||
'promotion_review' => 'Gdoo\Promotion\Hooks\ReviewHook',
|
||||
],
|
||||
'dialogs' => [
|
||||
'promotion' => [
|
||||
'name' => '促销申请',
|
||||
'model' => 'Gdoo\Promotion\Models\Promotion::Dialog',
|
||||
'url' => 'promotion/promotion/dialog',
|
||||
],
|
||||
],
|
||||
'badges' => [
|
||||
'promotion_promotion_index' => 'Gdoo\Promotion\Services\PromotionService::getBadge',
|
||||
],
|
||||
"controllers" => [
|
||||
"promotion" => [
|
||||
"name" => "促销管理",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表"
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"recall" => [
|
||||
"name" => "撤回"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"close" => [
|
||||
"name" => "关闭"
|
||||
],
|
||||
"batchEdit" => [
|
||||
"name" => "批量编辑"
|
||||
],
|
||||
]
|
||||
],
|
||||
"review" => [
|
||||
"name" => "促销核销",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表",
|
||||
],
|
||||
"show" => [
|
||||
"name" => "查看"
|
||||
],
|
||||
"create" => [
|
||||
"name" => "新建"
|
||||
],
|
||||
"edit" => [
|
||||
"name" => "编辑"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"recall" => [
|
||||
"name" => "撤回"
|
||||
],
|
||||
"abort" => [
|
||||
"name" => "弃审"
|
||||
],
|
||||
"print" => [
|
||||
"name" => "打印"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
],
|
||||
"batchEdit" => [
|
||||
"name" => "批量编辑"
|
||||
],
|
||||
]
|
||||
],
|
||||
"material" => [
|
||||
"name" => "促销素材",
|
||||
"actions" => [
|
||||
"index" => [
|
||||
"name" => "列表",
|
||||
],
|
||||
"show" => [
|
||||
"name" => "显示"
|
||||
],
|
||||
"audit" => [
|
||||
"name" => "审核"
|
||||
],
|
||||
"delete" => [
|
||||
"name" => "删除"
|
||||
]
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"indexes": {
|
||||
"idx_object_id": {
|
||||
"columns": [
|
||||
"source_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "",
|
||||
"type": "",
|
||||
"default": "",
|
||||
"notnull": "",
|
||||
"length": "",
|
||||
"unsigned": "",
|
||||
"autoincrement": "",
|
||||
"comment": ""
|
||||
},
|
||||
"name": {
|
||||
"name": "",
|
||||
"type": "",
|
||||
"default": "",
|
||||
"notnull": "",
|
||||
"length": "",
|
||||
"unsigned": "",
|
||||
"autoincrement": "",
|
||||
"comment": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
<style>
|
||||
.content-body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="vue-app">
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right"></div>
|
||||
@if(isset($access['audit']))
|
||||
<div class="btn-group">
|
||||
<button type="button" data-toggle="audit-checkall" class="btn btn-sm btn-default"><i class="fa fa-check-square"></i> 全选</button>
|
||||
<button class="btn btn-sm btn-default" data-toggle="dropdown"><i class="fa fa-navicon"></i> 批量操作 <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a data-toggle="audit-stores" data-value="0">未审核</a></li>
|
||||
<li><a data-toggle="audit-stores" data-value="1">已审合格</a></li>
|
||||
<li><a data-toggle="audit-stores" data-value="2">已审不合格</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<button type="button" data-toggle="audit-download" class="btn btn-sm btn-info">
|
||||
<i class="fa fa-cloud-download"></i> 批量下载
|
||||
</button>
|
||||
@endif
|
||||
|
||||
<div class="btn-group hidden-xs">
|
||||
<a class="btn btn-sm btn-default" data-toggle="closetab" data-id="promotion_material_show"><i class="fa fa-sign-out"></i> 退出</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-panel-body panel-form-show">
|
||||
|
||||
<form class="form-horizontal form-controller" method="post" id="promotion" name="promotion">
|
||||
|
||||
<div style="background-color:#fff">
|
||||
<div class="panel-heading text-center b-b">
|
||||
<h3 class="m-xs m-l-none">
|
||||
{{$promotion->sn}}
|
||||
</h3>
|
||||
<small>
|
||||
客户: {{$promotion->customer->name}}
|
||||
|
||||
创建时间: @datetime($promotion['created_at'])
|
||||
|
||||
门店数量(未审核:{{(int)$audits[0]}} / 已审合格:{{(int)$audits[1]}} / 已审不合格:{{(int)$audits[2]}})
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="padder m-t">
|
||||
<div class="row" id="stores">
|
||||
@foreach($rows as $i => $row)
|
||||
<div class="col-sm-4 col-md-3 m-b">
|
||||
<div class="panel b-a">
|
||||
<div class="panel-heading">
|
||||
<div class="m-t-xs">
|
||||
<span class="pull-right">
|
||||
<div class="btn-group">
|
||||
@if(isset($access['audit']))
|
||||
<button class="btn btn-xs audit-{{$row['id']}} btn-{{$changes[$row['status']]['btn']}}" data-toggle="dropdown">{{$changes[$row['status']]['text']}} <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a data-toggle="audit-store" data-id="{{$row['id']}}" data-value="0">未审核</a></li>
|
||||
<li><a data-toggle="audit-store" data-id="{{$row['id']}}" data-value="1">已审合格</a></li>
|
||||
<li><a data-toggle="audit-store" data-id="{{$row['id']}}" data-value="2">已审不合格</a></li>
|
||||
</ul>
|
||||
@else
|
||||
<span class="label label-{{$changes[$row['status']]['btn']}}">{{$changes[$row['status']]['text']}}</span>
|
||||
@endif
|
||||
</div>
|
||||
</span>
|
||||
@if(isset($access['audit']))
|
||||
<label class="i-checks">
|
||||
<input type="checkbox" name="stores[]" value="{{$row['id']}}"><i></i>
|
||||
{{$row['name']}}
|
||||
</label>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center wrapper">
|
||||
<a href="javascript:;" style="height:220px;">
|
||||
<img style="width:100%;height:220px;" alt="店名:{{$row['name']}}, 位置:{{$row['location']}}" lay-src="{{$row['images'][0]['url']}}">
|
||||
<span style="display:none;">
|
||||
@foreach($row['images'] as $image)
|
||||
<img data-original="{{$image['url']}}" alt="店名:{{$row['name']}}, 位置:{{$row['location']}}" lay-src="{{$row['images'][0]['url']}}">
|
||||
@endforeach
|
||||
</span>
|
||||
|
||||
<div class="red m-t-xs">点击查看更多照片({{count($row['images'])}})</div>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="list-group no-radius">
|
||||
<li class="list-group-item">
|
||||
<div class="text-left">
|
||||
<div>店名:{{$row['name']}}</div>
|
||||
<div>位置:{{$row['location']}}</div>
|
||||
<div>提交人:{{$row['created_by']}}</div>
|
||||
<div>时间:@datetime($row['created_at'])</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<link href="{{$asset_url}}/vendor/layui/css/layui.css" rel="stylesheet">
|
||||
<script src="{{$asset_url}}/vendor/layui/layui.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var changes = JSON.parse('{{json_encode($changes)}}');
|
||||
var items = JSON.parse('{{json_encode($items)}}');
|
||||
|
||||
var vue = new Vue({
|
||||
el: '#vue-app',
|
||||
data: {
|
||||
viewerData: [{
|
||||
url: '',
|
||||
name: ''
|
||||
}],
|
||||
},
|
||||
methods: {},
|
||||
mounted() {
|
||||
var galley_id = "stores";
|
||||
var galley = document.getElementById(galley_id);
|
||||
var viewer = new Viewer(galley, {
|
||||
navbar: false,
|
||||
url: "data-original",
|
||||
});
|
||||
vueMounted();
|
||||
}
|
||||
});
|
||||
|
||||
function vueMounted() {
|
||||
layui.use('flow', function() {
|
||||
var flow = layui.flow;
|
||||
flow.lazyimg();
|
||||
});
|
||||
|
||||
// 门店审核
|
||||
$('[data-toggle="audit-store"]').on('click', function(e) {
|
||||
var data = $(this).data();
|
||||
var obj = $('.audit-' + data.id);
|
||||
obj.removeClass('btn-default btn-success btn-danger');
|
||||
|
||||
var change = changes[data.value];
|
||||
obj.html(change.text + ' <span class="caret"></span>');
|
||||
obj.addClass('btn-' + change.btn);
|
||||
|
||||
$.post('{{url("audit")}}', {
|
||||
id: [data.id],
|
||||
status: data.value
|
||||
}, function(res) {
|
||||
if (res.status) {
|
||||
$.toastr('success', res.data);
|
||||
} else {
|
||||
$.toastr('error', res.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 批量操作
|
||||
$('[data-toggle="audit-stores"]').on('click', function(e) {
|
||||
var data = $(this).data();
|
||||
var ids = [];
|
||||
$('#stores').find("input[type='checkbox']:checked").each(function() {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
|
||||
if (ids.length == 0) {
|
||||
$.toastr('error', '门店没有选择。');
|
||||
return;
|
||||
}
|
||||
|
||||
$.post('{{url("audit")}}', {
|
||||
id: ids,
|
||||
status: data.value
|
||||
}, function(res) {
|
||||
if (res.status) {
|
||||
$.each(ids, function(k, v) {
|
||||
var change = changes[data.value];
|
||||
var obj = $('.audit-' + v);
|
||||
obj.html(change.text + ' <span class="caret"></span>');
|
||||
obj.removeClass('btn-default btn-success btn-danger');
|
||||
obj.addClass('btn-' + change.btn);
|
||||
});
|
||||
$.toastr('success', res.data);
|
||||
} else {
|
||||
$.toastr('error', res.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 批量下载
|
||||
$('[data-toggle="audit-download"]').on('click', function(e) {
|
||||
var data = $(this).data();
|
||||
var ids = [];
|
||||
$('#stores').find("input[type='checkbox']:checked").each(function() {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
|
||||
if (ids.length == 0) {
|
||||
$.toastr('error', '门店没有选择。');
|
||||
return;
|
||||
}
|
||||
|
||||
var index = layer.msg('照片压缩中...', {
|
||||
icon: 16,
|
||||
shade: 0.1,
|
||||
time: 6000 * 10
|
||||
});
|
||||
$.post('{{url("archive")}}', {
|
||||
id: ids
|
||||
}, function(res) {
|
||||
layer.close(index);
|
||||
if (res.status) {
|
||||
$.messager.alert('照片下载', '<div class="text-center"><a href="' + app.url('promotion/material/download', {
|
||||
sn: '{{$promotion->sn}}'
|
||||
}) + '">点击下载核销照片</a></div>');
|
||||
} else {
|
||||
$.toastr('error', res.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 全选
|
||||
$('[data-toggle="audit-checkall"]').on('click', function(e) {
|
||||
$('#stores').find("input[type='checkbox']").each(function() {
|
||||
if ($(this).prop('checked')) {
|
||||
$(this).prop('checked', false);
|
||||
} else {
|
||||
$(this).prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,82 @@
|
||||
{{$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';
|
||||
|
||||
action.fee_detail = function(data) {
|
||||
viewDialog({
|
||||
title: '兑现明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('promotion/review/feeDetail', {id: data.master_id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
action.product = function(data) {
|
||||
viewDialog({
|
||||
title: '产品明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('promotion/promotion/product', {id: data.master_id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 自定义搜索方法
|
||||
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.promotion_id > 0) {
|
||||
top.addTab('promotion/material/detail?promotion_id=' + params.data.promotion_id, 'promotion_material_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,30 @@
|
||||
<form id="search-form" class="form-inline" name="mysearch" action="{{url()}}" method="get">
|
||||
|
||||
<div class="pull-right">
|
||||
@if(isset($access['delete']))
|
||||
<a class="btn btn-sm btn-danger" href="javascript:optionDelete('#myform','{{url('delete')}}');"><i class="icon icon-remove"></i> 删除</a>
|
||||
@endif
|
||||
</div>
|
||||
<!--
|
||||
@if(isset($access['audit']))
|
||||
@if($search['query']['status'] == 1)
|
||||
<a class="btn btn-sm btn-info" href="javascript:optionDelete('#myform','{{url('audit')}}', '确定要反审核吗');"><i class="icon icon-ban-circle"></i> 反审核</a>
|
||||
@else
|
||||
<a class="btn btn-sm btn-info" href="javascript:optionDelete('#myform','{{url('audit')}}', '确定要审核吗');"><i class="icon icon-ok"></i> 审核</a>
|
||||
@endif
|
||||
@endif
|
||||
-->
|
||||
@include('searchForm')
|
||||
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#search-form').searchForm({
|
||||
data: {{json_encode($search['forms'])}},
|
||||
init: function(e) {
|
||||
var me = this;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="panel" style="box-shadow:none">
|
||||
<div class="panel-heading b-b b-light text-center">
|
||||
<h4 class="m-xs m-l-none">{{$row['name']}}</h4>
|
||||
<small class="text-muted">位置: {{$row['location']}}</small>
|
||||
</div>
|
||||
<div class="panel-body text-base">
|
||||
<div class="table-responsive">
|
||||
<table class="m-b-none">
|
||||
@foreach($row['images'] as $image)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="text-center"><img src="{{$upload_url}}/{{$image['path']}}" max-width="100%" /></div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,181 @@
|
||||
@if(is_weixin())
|
||||
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
|
||||
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
|
||||
@endif
|
||||
|
||||
<div class="form-panel">
|
||||
<div class="form-panel-header">
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
{{$form['btn']}}
|
||||
|
||||
<a href="javascript:costDetailDialog();" class="btn btn-sm btn-default">
|
||||
费用申请明细
|
||||
</a>
|
||||
|
||||
@if($form['access']['close'])
|
||||
<a href="javascript:closeDialog();" class="btn btn-sm btn-default">
|
||||
关闭(打开)
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if($form["row"]["status"] == 1)
|
||||
@if(is_weixin())
|
||||
<a href="javascript:;" id="upload" class="btn btn-sm btn-default">
|
||||
核销资料
|
||||
</a>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
</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 table = '{{$form["table"]}}';
|
||||
var review_id = '{{$review["id"]}}';
|
||||
var id = '{{$form["row"]["id"]}}';
|
||||
var actived_dt = '{{$form["row"]["actived_dt"]}}';
|
||||
var customer_id = '{{$form["row"]["customer_id"]}}';
|
||||
var grid = null;
|
||||
|
||||
document.addEventListener('UniAppJSBridgeReady', function() {
|
||||
$('#upload').on('click', function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/app/promotionMaterial/index?promotion_id={{$form["row"]["id"]}}'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function costDetailDialog() {
|
||||
viewDialog({
|
||||
title: '费用申请明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('approach/approach/serviceCostDetail', {date: actived_dt, customer_id: customer_id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
$.post(app.url('promotion/promotion/close'), {id: id}, function(res) {
|
||||
toastrSuccess(res.data);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function undertake_ratio() {
|
||||
var v1 = $('#promotion_pro_total_cost').val();
|
||||
var v2 = $('#promotion_undertake_money').val();
|
||||
var v3 = (toNumber(v2) / toNumber(v1)) * 100;
|
||||
$('#promotion_undertake_ratio').val(v3 > 100 ? 100 : v3.toFixed(2));
|
||||
}
|
||||
|
||||
function get_customer_id() {
|
||||
var customer_id = $('#promotion_customer_id').val();
|
||||
return customer_id;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#promotion_pro_total_cost,#promotion_area_money').bind('input propertychange', function() {
|
||||
var area_money = $('#promotion_area_money').val();
|
||||
$('#promotion_undertake_money').val(area_money);
|
||||
undertake_ratio();
|
||||
});
|
||||
|
||||
$('#promotion_undertake_money').bind('input propertychange', function() {
|
||||
undertake_ratio();
|
||||
});
|
||||
|
||||
$('#approach_field001').prop('checked', true);
|
||||
$('#approach_field004').prop('checked', true);
|
||||
|
||||
$('#promotion_field010').prop('checked', true);
|
||||
$(document).on('click', '[data-toggle="joint"]', function(event) {
|
||||
var data = $(this).data();
|
||||
// 关联订单
|
||||
if (data.action == 'sale_order') {
|
||||
top.addTab('order/order/show?id=' + data.id, 'order_order_show', '客户订单(联查)');
|
||||
}
|
||||
// 联查核销单
|
||||
if (data.action == 'promotion_review' && review_id > 0) {
|
||||
top.addTab('promotion/review/show?id=' + review_id, 'promotion_review_show', '促销核销(联查)');
|
||||
}
|
||||
// 联查资料
|
||||
if (data.action == 'material') {
|
||||
top.addTab('promotion/material/detail?promotion_id=' + data.id, 'promotion_material_show', '促销资料(联查)');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.promotion_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'product_id';
|
||||
},
|
||||
editable: {
|
||||
product_name(params) {
|
||||
var customer_id = $('#promotion_customer_id').val();
|
||||
if (customer_id.trim() == '') {
|
||||
toastrError('请先选择客户');
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('promotion_data.product_id', {
|
||||
query(query) {
|
||||
var customer_id = $('#promotion_customer_id').val();
|
||||
query.customer_id = customer_id;
|
||||
query.query_type = 'customer_price';
|
||||
},
|
||||
open(params) {
|
||||
params.url = 'product/product/serviceCustomer';
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
row.price = selectedRow.price;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('promotion.order_id', {
|
||||
open(params) {
|
||||
params.title = '关联订单';
|
||||
params.url = 'order/order/servicePromotion';
|
||||
},
|
||||
query(query) {
|
||||
query.customer_id = $('#promotion_customer_id').val();
|
||||
query.type_id = $('#promotion_type_id').val();
|
||||
query.order_id = $('#promotion_order_id').val();
|
||||
},
|
||||
onSelect(row) {
|
||||
$('#promotion_order_id_text').val(row.sn);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// 选择客户事件
|
||||
gdoo.event.set('promotion.customer_id', {
|
||||
onSelect(row) {
|
||||
if (row.id) {
|
||||
$('#customer_region_region_id').val(row.region_id);
|
||||
$('#customer_region_region_id_text').val(row.region_id_name || '');
|
||||
$('#promotion_phone').val(row.tel);
|
||||
$('#promotion_fax').val(row.fax);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,187 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<div class="wrapper-xs">
|
||||
<div id="dialog-promotion-toolbar">
|
||||
<form id="dialog-promotion-search-form" name="dialog_promotion_search_form" class="form-inline" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ref_promotion" class="ag-theme-balham" style="width:100%;height:180px;"></div>
|
||||
|
||||
<div class="m-t-xs">
|
||||
<div id="ref_promotion_data" class="ag-theme-balham" style="width:100%;height:240px;"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var $ref_promotion = null;
|
||||
var $ref_promotion_data = null;
|
||||
var params = JSON.parse('{{json_encode($query)}}');
|
||||
(function($) {
|
||||
params['master'] = 1;
|
||||
|
||||
var option = gdoo.formKey(params);
|
||||
var event = gdoo.event.get(option.key);
|
||||
event.trigger('query', params);
|
||||
|
||||
var mGridDiv = document.querySelector("#ref_promotion");
|
||||
var mGrid = new agGridOptions();
|
||||
mGrid.remoteDataUrl = '{{url()}}';
|
||||
mGrid.remoteParams = params;
|
||||
mGrid.rowMultiSelectWithClick = false;
|
||||
mGrid.rowSelection = 'multiple';
|
||||
mGrid.autoColumnsToFit = false;
|
||||
mGrid.defaultColDef.suppressMenu = true;
|
||||
mGrid.defaultColDef.sortable = false;
|
||||
mGrid.columnDefs = [
|
||||
{cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, width: 40},
|
||||
{cellClass:'text-center', field: 'sn', headerName: '单据编号', minWidth: 160},
|
||||
{cellClass:'text-center', field: 'apply_dt', type: 'datetime', headerName: '单据日期', width: 120},
|
||||
{cellClass:'text-center', field: 'master_status', cellRenderer: 'htmlCellRenderer', headerName: '状态', width: 160},
|
||||
{cellClass:'text-center', field: 'customer_code', headerName: '客户编码', width: 120},
|
||||
{field:'customer_name', headerName: '客户名称', width: 160},
|
||||
{cellClass:'text-center',field:'region_name', headerName: '销售团队', width: 120},
|
||||
{cellClass:'text-right',field:'apply_money', headerName: '申请费用', width: 100},
|
||||
{cellClass:'text-right',field:'verification_cost', headerName: '批复费用', width: 100},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
mGrid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
var rows = mGrid.api.getSelectedRows();
|
||||
var ids = [];
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
ids.push(rows[i].id);
|
||||
}
|
||||
params.ids = ids;
|
||||
sGrid.remoteData(params);
|
||||
};
|
||||
|
||||
mGrid.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];
|
||||
}
|
||||
}
|
||||
mGrid.api.forEachNode(function(node) {
|
||||
var key = node.data['id'];
|
||||
if (rows[key] != undefined) {
|
||||
node.setSelected(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入选中
|
||||
*/
|
||||
function writeSelected() {
|
||||
var rows = mGrid.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['id']);
|
||||
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;
|
||||
}
|
||||
mGrid.writeSelected = writeSelected;
|
||||
gdoo.dialogs[option.id] = mGrid;
|
||||
|
||||
new agGrid.Grid(mGridDiv, mGrid);
|
||||
|
||||
// 读取数据
|
||||
mGrid.remoteData();
|
||||
$ref_promotion = mGrid;
|
||||
|
||||
params['master'] = 0;
|
||||
var sGridDiv = document.querySelector("#ref_promotion_data");
|
||||
var sGrid = new agGridOptions();
|
||||
sGrid.remoteDataUrl = '{{url()}}';
|
||||
sGrid.remoteParams = params;
|
||||
sGrid.rowSelection = 'multiple';
|
||||
sGrid.defaultColDef.suppressMenu = true;
|
||||
sGrid.defaultColDef.sortable = false;
|
||||
sGrid.suppressRowClickSelection = true;
|
||||
sGrid.getRowClass = function(params) {
|
||||
params.node.setSelected(true);
|
||||
};
|
||||
|
||||
sGrid.columnDefs = [
|
||||
{cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, width: 40},
|
||||
{cellClass:'text-center', field: 'product_code', headerName: '产品编码', width: 100},
|
||||
{field: 'product_name', headerName: '商品名称', minWidth: 180},
|
||||
{cellClass:'text-center', field: 'product_spec', headerName: '商品规格', width: 120},
|
||||
{cellClass:'text-center', field: 'product_barcode', headerName: '商品条码', width: 140},
|
||||
{cellClass:'text-center', field: 'product_unit', headerName: '计量单位', width: 80},
|
||||
{cellClass:'text-right', field: 'price', headerName: '单价(元)', width: 80},
|
||||
{cellClass:'text-right', field: 'money', headerName: '金额(元)', width: 80},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
sGrid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(sGridDiv, sGrid);
|
||||
// 读取数据
|
||||
sGrid.remoteData();
|
||||
$ref_promotion_data = sGrid;
|
||||
|
||||
var data = JSON.parse('{{json_encode($search["forms"])}}');
|
||||
var search = $('#dialog-promotion-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;
|
||||
});
|
||||
|
||||
params['master'] = 1;
|
||||
mGrid.remoteData(params);
|
||||
|
||||
params['master'] = 0;
|
||||
sGrid.remoteData(params);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,82 @@
|
||||
{{$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';
|
||||
|
||||
action.fee_detail = function(data) {
|
||||
viewDialog({
|
||||
title: '兑现明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('promotion/review/feeDetail', {id: data.master_id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
action.product = function(data) {
|
||||
viewDialog({
|
||||
title: '产品明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('promotion/promotion/product', {id: data.master_id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 自定义搜索方法
|
||||
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.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,33 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<div id="approach_product" class="ag-theme-balham" style="width:100%;height:320px;"></div>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
var gridDiv = document.querySelector("#approach_product");
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
|
||||
var params = JSON.parse('{{json_encode($query)}}');
|
||||
|
||||
grid.remoteParams = params;
|
||||
grid.rowMultiSelectWithClick = false;
|
||||
grid.rowSelection = 'multiple';
|
||||
// grid.autoColumnsToFit = false;
|
||||
grid.defaultColDef.suppressMenu = true;
|
||||
grid.defaultColDef.sortable = false;
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', headerName: '', type: 'sn', width: 40},
|
||||
{cellClass:'text-left', field: 'name', headerName: '产品名称', minWidth: 140},
|
||||
{cellClass:'text-center', field: 'spec', headerName: '规格型号', width: 100},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,122 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<div class="wrapper-xs">
|
||||
<div id="dialog-promotion-toolbar">
|
||||
<form id="dialog-promotion-search-form" name="dialog_promotion_search_form" class="search-inline-form form-inline" method="get">
|
||||
@include('searchForm3')
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="ref_promotion" class="ag-theme-balham" style="width:100%;height:140px;"></div>
|
||||
|
||||
<div class="m-t-xs">
|
||||
<div id="ref_promotion_data" class="ag-theme-balham" style="width:100%;height:240px;"></div>
|
||||
</div>
|
||||
<script>
|
||||
var $ref_promotion = null;
|
||||
var $ref_promotion_data = null;
|
||||
var params = JSON.parse('{{json_encode($query)}}');
|
||||
(function($) {
|
||||
params['master'] = 1;
|
||||
var mGridDiv = document.querySelector("#ref_promotion");
|
||||
var mGrid = new agGridOptions();
|
||||
mGrid.remoteDataUrl = '{{url()}}';
|
||||
mGrid.remoteParams = params;
|
||||
mGrid.rowMultiSelectWithClick = false;
|
||||
mGrid.rowSelection = 'multiple';
|
||||
mGrid.autoColumnsToFit = false;
|
||||
mGrid.defaultColDef.suppressMenu = true;
|
||||
mGrid.defaultColDef.sortable = false;
|
||||
mGrid.columnDefs = [
|
||||
{cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, width: 40},
|
||||
{cellClass:'text-center', field: 'sn', headerName: '促销编号', minWidth: 160},
|
||||
{cellClass:'text-center', field: 'type_name', headerName: '促销类型', width: 80},
|
||||
{cellClass:'text-center', field: 'created_at', type: 'datetime', headerName: '单据日期', width: 120},
|
||||
{cellClass:'text-center', field: 'master_status', cellRenderer: 'htmlCellRenderer', headerName: '状态', width: 160},
|
||||
{cellClass:'text-center', field: 'customer_code', headerName: '客户编码', width: 160},
|
||||
{field:'customer_name', headerName: '客户名称', width: 160},
|
||||
{field:'warehouse_contact', headerName: '收货人', width: 160},
|
||||
{field:'warehouse_phone', headerName: '收货人电话', width: 160},
|
||||
{field:'warehouse_address', headerName: '收货地址', width: 260},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
mGrid.onSelectionChanged = function() {
|
||||
var rows = mGrid.api.getSelectedRows();
|
||||
var ids = [];
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
ids.push(rows[i].id);
|
||||
}
|
||||
params.ids = ids;
|
||||
sGrid.remoteData(params);
|
||||
};
|
||||
|
||||
new agGrid.Grid(mGridDiv, mGrid);
|
||||
// 读取数据
|
||||
mGrid.remoteData();
|
||||
$ref_promotion = mGrid;
|
||||
|
||||
params['master'] = 0;
|
||||
var sGridDiv = document.querySelector("#ref_promotion_data");
|
||||
var sGrid = new agGridOptions();
|
||||
sGrid.remoteDataUrl = '{{url()}}';
|
||||
sGrid.remoteParams = params;
|
||||
sGrid.rowMultiSelectWithClick = true;
|
||||
sGrid.rowSelection = 'multiple';
|
||||
sGrid.autoColumnsToFit = false;
|
||||
sGrid.defaultColDef.suppressMenu = true;
|
||||
sGrid.defaultColDef.sortable = false;
|
||||
sGrid.suppressRowClickSelection = true;
|
||||
sGrid.getRowClass = function(params) {
|
||||
params.node.setSelected(true);
|
||||
};
|
||||
sGrid.columnDefs = [
|
||||
{cellClass:'text-center', checkboxSelection: true, headerCheckboxSelection: true, suppressSizeToFit: true, width: 40},
|
||||
{cellClass:'text-center', field: 'product_code', headerName: '存货编码', width: 100},
|
||||
{field: 'product_name', headerName: '商品名称', minWidth: 180},
|
||||
{cellClass:'text-center', field: 'product_spec', headerName: '商品规格', width: 140},
|
||||
{cellClass:'text-center', field: 'product_unit', headerName: '计量单位', width: 80},
|
||||
{cellClass:'text-center', field: 'ky_num', type:'number', headerName: '现存量', width: 80},
|
||||
{cellClass:'text-right', field: 'quantity', type:'number', headerName: '促销数量', width: 80},
|
||||
{cellClass:'text-right', field: 'ysy_num', type:'number', headerName: '已发数量', width: 80},
|
||||
{cellClass:'text-right', field: 'wsy_num', type:'number', headerName: '可用数量', width: 80},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
sGrid.onRowClicked = function(row) {
|
||||
var selected = row.node.isSelected();
|
||||
if (selected === false) {
|
||||
row.node.setSelected(true, true);
|
||||
}
|
||||
};
|
||||
|
||||
new agGrid.Grid(sGridDiv, sGrid);
|
||||
// 读取数据
|
||||
sGrid.remoteData();
|
||||
$ref_promotion_data = sGrid;
|
||||
|
||||
var data = JSON.parse('{{json_encode($search["forms"])}}');
|
||||
var search = $('#dialog-promotion-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;
|
||||
});
|
||||
|
||||
params['master'] = 1;
|
||||
mGrid.remoteData(params);
|
||||
|
||||
params['master'] = 0;
|
||||
sGrid.remoteData(params);
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,141 @@
|
||||
<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 table = '{{$form["table"]}}';
|
||||
var grid = null;
|
||||
|
||||
function get_customer_id() {
|
||||
var customer_id = $('#promotion_review_customer_id').val();
|
||||
return customer_id;
|
||||
}
|
||||
|
||||
$(function($) {
|
||||
|
||||
$(document).on('click', '[data-toggle="joint"]', function(event) {
|
||||
var data = $(this).data();
|
||||
// 联查进店申请
|
||||
if (data.action == 'apply') {
|
||||
top.addTab('promotion/promotion/show?id=' + data.id, 'promotion_promotion_show', '促销申请(联查)');
|
||||
}
|
||||
// 联查费用明细
|
||||
if (data.action == 'cash_detail') {
|
||||
viewDialog({
|
||||
title: '兑现明细',
|
||||
dialogClass: 'modal-md',
|
||||
url: app.url('promotion/review/feeDetail', {id: data.id}),
|
||||
close: function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// grid初始化事件
|
||||
gdoo.event.set('grid.promotion_review_data', {
|
||||
ready(me) {
|
||||
grid = me;
|
||||
grid.dataKey = 'product_id';
|
||||
},
|
||||
editable: {
|
||||
product_name(params) {
|
||||
var customer_id = $('#promotion_review_apply_id').val();
|
||||
if (customer_id.trim() == '') {
|
||||
toastrError('请先选择申请编号');
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('promotion_review_data.product_id', {
|
||||
query(query) {
|
||||
var customer_id = $('#promotion_review_customer_id').val();
|
||||
query.customer_id = customer_id;
|
||||
query.query_type = 'customer_price';
|
||||
},
|
||||
onSelect(row, selectedRow) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$('#promotion_review_pay_type').on('change', function() {
|
||||
if (this.value == 1 || this.value == 3) {
|
||||
$('#promotion_review_use_order').val(1);
|
||||
} else {
|
||||
$('#promotion_review_use_order').val(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('promotion_review.apply_id', {
|
||||
open(params, query) {
|
||||
var customer_name = $('#promotion_review_customer_id_text').val();
|
||||
query.field_0 = 'customer_id_customer.name';
|
||||
query.condition_0 ='like';
|
||||
query.search_0 = customer_name;
|
||||
},
|
||||
query(query) {
|
||||
},
|
||||
onSelect() {
|
||||
var promotion = $ref_promotion.api.getSelectedRows()[0];
|
||||
var rows = $ref_promotion_data.api.getSelectedRows();
|
||||
|
||||
if (promotion == undefined) {
|
||||
toastrError('请先选择促销申请');
|
||||
return false;
|
||||
}
|
||||
$('#promotion_review_apply_start_dt').val(promotion.start_dt);
|
||||
$('#promotion_review_apply_end_dt').val(promotion.end_dt);
|
||||
|
||||
$('#promotion_review_apply_scope').val(promotion.promote_scope);
|
||||
$('#promotion_review_apply_money').val(promotion.apply_money);
|
||||
$('#promotion_review_area_money').val(promotion.undertake_money);
|
||||
$('#promotion_review_fact_verification_cost').val(promotion.verification_cost);
|
||||
|
||||
$('#promotion_review_apply_id').val(promotion.id);
|
||||
$('#promotion_review_apply_id_text').val(promotion.sn);
|
||||
|
||||
$('#promotion_review_customer_id').val(promotion.customer_id);
|
||||
$('#promotion_review_customer_id_text').val(promotion.customer_name);
|
||||
|
||||
$('#customer_region_region_id').val(promotion.region_id);
|
||||
$('#customer_region_region_id_text').val(promotion.region_name);
|
||||
|
||||
grid.api.setRowData([]);
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
grid.api.memoryStore.create(row);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// 子表对话框
|
||||
gdoo.event.set('promotion_review.customer_id', {
|
||||
query(query) {
|
||||
},
|
||||
onSelect(row) {
|
||||
$('#customer_region_region_id').val(row.region_id);
|
||||
$('#customer_region_region_id_text').val(row.region_id_name);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,34 @@
|
||||
<style>
|
||||
.modal-body { overflow:hidden; }
|
||||
</style>
|
||||
|
||||
<div id="approach_fee_detail" class="ag-theme-balham" style="width:100%;height:280px;"></div>
|
||||
|
||||
<script>
|
||||
(function($) {
|
||||
var gridDiv = document.querySelector("#approach_fee_detail");
|
||||
var grid = new agGridOptions();
|
||||
grid.remoteDataUrl = '{{url()}}';
|
||||
|
||||
var params = JSON.parse('{{json_encode($query)}}');
|
||||
|
||||
grid.remoteParams = params;
|
||||
grid.rowMultiSelectWithClick = false;
|
||||
grid.rowSelection = 'multiple';
|
||||
// grid.autoColumnsToFit = false;
|
||||
grid.defaultColDef.suppressMenu = true;
|
||||
grid.defaultColDef.sortable = false;
|
||||
grid.columnDefs = [
|
||||
{cellClass:'text-center', headerName: '', type: 'sn', width: 40},
|
||||
{cellClass:'text-center', field: 'sn', headerName: '单据编号', minWidth: 140},
|
||||
{cellClass:'text-center', field: 'date', headerName: '兑现日期', width: 100},
|
||||
{cellClass:'text-right', field:'fact_verification_cost', headerName: '兑现金额', width: 100},
|
||||
{cellClass:'text-center', field: 'id', headerName: 'ID', width: 60}
|
||||
];
|
||||
|
||||
new agGrid.Grid(gridDiv, grid);
|
||||
// 读取数据
|
||||
grid.remoteData();
|
||||
|
||||
})(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.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']}}
|
||||
Reference in New Issue
Block a user