Browse Source

修正BUG

moshaorui 4 months ago
parent
commit
aa132103d0

+ 2 - 2
.env.dev

@@ -23,7 +23,7 @@ SESSION_DRIVER=file
 SESSION_LIFETIME=120
 
 MEMCACHED_HOST=127.0.0.1
-
+#redis未用到
 REDIS_HOST=127.0.0.1
 REDIS_PASSWORD=null
 REDIS_PORT=6379
@@ -57,7 +57,7 @@ VITE_PUSHER_PORT="${PUSHER_PORT}"
 VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
 VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
 
-
+#oss
 OSS_ACCESS_KEY_ID=LTAI5tCYd6zdBrSN9W9hZRUd
 OSS_ACCESS_KEY_SECRET=q0pp2qlDXdxi490qMDbDuWBd7SPMNn
 OSS_BUCKET=mietubl-dev

+ 1 - 1
app/Admin/Actions/Grid/InquiryAssignment.php

@@ -26,7 +26,7 @@ class InquiryAssignment extends BatchAction
     {
         $assignment = admin_trans_label('assignment');
 
-        $button = '<button type="button" class="btn btn-success"">'.$assignment.'</button>';
+        $button = '<button type="button" class="btn btn-success">'.$assignment.'</button>';
         // 实例化表单类
         return Modal::make()
             ->lg()

+ 87 - 0
app/Admin/Actions/Tools/InquiryHandle.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace App\Admin\Actions\Tools;
+
+use App\Admin\Repositories\DistInquiry;
+use Dcat\Admin\Grid\Tools\AbstractTool;
+use Dcat\Admin\Widgets\Modal;
+use Illuminate\Http\Request;
+
+class InquiryHandle extends AbstractTool
+{
+
+    protected $style = 'btn btn-success';
+
+    /**
+     * 按钮文本
+     *
+     * @return string|void
+     */
+    public function title()
+    {
+        return admin_trans_label('process');
+    }
+
+    /**
+     *  确认弹窗,如果不需要则返回空即可
+     *
+     * @return array|string|void
+     */
+    public function confirm()
+    {
+        // 只显示标题
+//        return '您确定要发送新的提醒消息吗?';
+
+        // 显示标题和内容
+        return ['Are you sure you want to process this document?', ''];
+    }
+
+    /**
+     * 处理请求
+     * 如果你的类中包含了此方法,则点击按钮后会自动向后端发起ajax请求,并且会通过此方法处理请求逻辑
+     *
+     * @param Request $request
+     */
+    public function handle(Request $request)
+    {
+        $keys = $request->input('_key');
+        if (is_array($keys) && count($keys) > 0) {
+            $result = DistInquiry::distSetStatusProcessed($keys);
+            if ($result === false) {
+                return $this->response()->error('Failed to process!')->refresh();
+            }
+            return $this->response()->success('Success')->refresh();
+        } else {
+            return $this->response()->error('No data selected!')->refresh();
+        }
+        // 你的代码逻辑
+
+    }
+
+
+
+    public function actionScript(){
+        $warning = __('No data selected!');
+
+        return <<<JS
+function (data, target, action) {
+    var key = {$this->getSelectedKeysScript()}
+
+    if (key.length === 0) {
+        Dcat.warning('{$warning}');
+        return false;
+    }
+
+    // 设置主键为复选框选中的行ID数组
+    action.options.key = key;
+}
+JS;
+    }
+
+
+    public function getSelectedKeysScript()
+    {
+        return "Dcat.grid.selected('{$this->parent->getName()}')";
+    }
+
+}

+ 0 - 1
app/Admin/Controllers/BaseProductController.php

@@ -106,7 +106,6 @@ class BaseProductController extends AdminController
             $show->field('enabled')->using(config('dictionary.enabled'));
             $show->field('created_at');
             $show->field('updated_at');
-
         });
     }
 

+ 13 - 1
app/Admin/Controllers/DistAppearanceController.php

@@ -93,6 +93,7 @@ class DistAppearanceController extends AdminController
             $show->field('enabled')->using(config('dictionary.enabled'));
             $show->field('created_at');
             $show->field('updated_at');
+            $show->disableDeleteButton();
         });
     }
 
@@ -114,7 +115,18 @@ class DistAppearanceController extends AdminController
                 ->maxSize(config('admin.upload.oss_image.max_size'))
                 ->dir('images/appearance/'.date("Ymd"));//
             $form->textarea('describe');
-            $form->switch('enabled')->default(1);
+            $form->switch('enabled')->default(0);
+            $form->saving(function (Form $form) {
+                if ($form->isCreating() && $form->input('enabled') == 1) {
+                    return $form->response()->error('Please create the template first, then import it, and finally enable it.');
+                }
+                if (!$form->isCreating()) {
+                    if ($form->input('enabled') == 1 && $form->model()->imported == 0) {
+                        return $form->response()->error('Please select the import option first, then enable it.');
+                    }
+                }
+            });
+            $form->disableDeleteButton();
         });
     }
 }

+ 21 - 0
app/Admin/Repositories/DistInquiry.php

@@ -40,4 +40,25 @@ class DistInquiry extends EloquentRepository
         }
     }
 
+
+
+    /*
+     * 供应商把询价单设置为已处理
+     */
+    public static function distSetStatusProcessed($ids)
+    {
+        $result = true;
+        foreach ($ids as $id) {
+            $id = intval($id);
+            $row = Model::find($id);
+            if ($row && $row->dist_id == getDistributorId() && $row->status == 1) {
+                $row->status = 2;
+                $row->save();
+            } else {
+                $result = false;
+            }
+        }
+        return $result;
+    }
+
 }

+ 140 - 0
app/Distributor/Controllers/DistInquiryController.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Admin\Actions\Grid\InquiryAssignment;
+use App\Admin\Actions\Tools\InquiryHandle;
+use App\Admin\Repositories\DistInquiry;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Show;
+
+class DistInquiryController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->header('Inquiry Management')
+            ->description('all')
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+
+
+    //屏蔽删除
+    public function destroy($id)
+    {
+        abort(404);
+    }
+
+    //屏蔽创建
+    public function create(Content $content)
+    {
+        abort(404);
+    }
+
+    //屏蔽编辑
+    public function edit($id, Content $content)
+    {
+        abort(404);
+    }
+
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $status = isset($_GET['status']) ? intval($_GET['status']) : -1;
+        return Grid::make(DistInquiry::with(['distributor']), function (Grid $grid) use ($status) {
+            $grid->model()->where('dist_id', getDistributorId())->where('status','>',0);
+            //指定视图,去掉删除按钮
+            $grid->view('admin.grid.table');
+            //字段
+            $grid->column('id')->sortable();
+            $grid->column('order_number');
+            $grid->column('company_name');
+            $grid->column('customer_name');
+            $grid->column('email');
+            $grid->column('consulting_products');
+            //$grid->column('distributor.username', 'Distributor Username');
+            //$grid->column('distributor.company_name', admin_trans_label('distributor_company_name'));
+            $grid->column('status')->using(config('dictionary.inquiryStatus'))->label([
+                0 => 'default',
+                1 => 'info',
+                2 => 'success',
+            ]);
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+            //筛选
+            $grid->filter(function (Grid\Filter $filter) {
+                $inquiryStatus = config('dictionary.inquiryStatus');
+                unset($inquiryStatus[0]);
+                $filter->panel();
+                $filter->expand();
+                $filter->equal('order_number')->width(2);
+                $filter->equal('company_name')->width(2);
+                $filter->equal('customer_name')->width(2);
+                $filter->equal('status')->select($inquiryStatus)->width(2);
+            });
+            //排序
+            $grid->model()->orderBy("id",'desc');
+            //按钮
+            $grid->disableCreateButton();
+            $grid->disableEditButton();
+            $grid->disableDeleteButton();
+            $grid->disableBatchDelete();
+            $grid->showViewButton();
+            if ($status == 1) {
+                //批量操作
+                $grid->tools([new InquiryHandle()]);
+            }
+
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistInquiry(), function (Show $show) {
+            if ($show->model()->dist_id !== getDistributorId()) {
+                abort(404);
+            }
+            $show->field('id');
+            $show->field('order_number');
+            $show->field('whats_app');
+            $show->field('company_name');
+            $show->field('customer_name');
+            $show->field('email');
+            $show->field('consulting_products');
+            $show->field('freight_forwarder');
+            $show->field('business_model');
+            $show->field('ip_address');
+            $show->field('status')->using(config('dictionary.inquiryStatus'));
+            $show->field('allocate_time');
+            //$show->field('distributor.company_name',admin_trans_label('distributor_company_name'));
+            $show->field('content');
+            $show->field('created_at');
+            $show->field('updated_at');
+            //按钮
+            $show->disableDeleteButton();
+            $show->disableEditButton();
+
+        });
+    }
+
+}

+ 7 - 2
app/Distributor/routes.php

@@ -1,5 +1,6 @@
 <?php
 
+use App\Distributor\Controllers\DistInquiryController;
 use Illuminate\Routing\Router;
 use Illuminate\Support\Facades\Route;
 use Dcat\Admin\Admin;
@@ -16,8 +17,6 @@ Route::group([
     'namespace'  => config('admin.route.namespace'),
     'middleware' => config('admin.route.middleware'),
 ], function (Router $router) {
-
-
     //主页
     $router->get('/', 'HomeController@index');
     //产品
@@ -34,6 +33,12 @@ Route::group([
 
     //产品导入
     $router->resource('import-product', 'importProductController');
+
+    //询价管理
+    $router->get('/dist-inquiry', [DistInquiryController::class, 'index']);
+    $router->get('/dist-inquiry/{id}', [DistInquiryController::class, 'show']);
+
+
 });
 
 

+ 1 - 0
lang/zh_CN/global.php

@@ -97,6 +97,7 @@ return [
         'parameter_name'        => '参数名称',
         'assignment'            => '分配',
         'images'                => '图片',
+        'process'               => '处理',
     ],
     'options' => [
         //

+ 1 - 1
lang/zh_CN/menu.php

@@ -27,7 +27,7 @@ return [
         'site_management'    => '站点管理',
         'distro_management'    => '分销商管理',
         'users_management'    => '用户管理',
-        'inquiry_management'    => '询管理',
+        'inquiry_management'    => '询管理',
         'appearance'    => '外观管理',
     ],
 ];

File diff suppressed because it is too large
+ 0 - 12
resources/views/welcome.blade.php


Some files were not shown because too many files changed in this diff