diff --git a/app/AdminAgent/Controllers/WorkorderController.php b/app/AdminAgent/Controllers/WorkorderController.php index 7d7591d..668273c 100755 --- a/app/AdminAgent/Controllers/WorkorderController.php +++ b/app/AdminAgent/Controllers/WorkorderController.php @@ -41,12 +41,17 @@ class WorkorderController extends AdminController ->orderByDesc('updated_at') ->get(); + // 先这么处理吧 + if ($workorderId == 0 && !empty($workorder)) { + return redirect('/admin-agent/workorder_item?workorder_id='.$workorder[0]->id); + } + foreach ($workorder as $v) { $item = WorkorderItem::query()->where('workorder_id',$v->id)->orderByDesc('updated_at')->first(); $arr = [ 'workorder_id' => $v->id, 'unread' => true, - 'avatar' => $v->publisher_type == DemandTraits::$col[0] ? $v->point->avatar : $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher_type == DemandTraits::$col[0] ? $v->point->avatar : $v->publisher->avatar), 'name' => $v->publisher_type == DemandTraits::$col[0] ? $v->point->name : $v->publisher->name, 'content' => $v->title, 'last_message' => $item ? ($item->type == 1 ? $item->content : '【 图片 】') : '', @@ -64,13 +69,24 @@ class WorkorderController extends AdminController $arr = [ 'type' => $v->publisher_type == DemandTraits::$col[0] ? 'my' : 'op', 'it_type' => $v->type, - 'avatar' => $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher->avatar), 'name' => $v->publisher->name, 'content' => $v->content, + 'created_at_text' => $v->created_at, ]; $msgList [] = $arr; } + $currentWorkorder = \App\Models\Workorder::find($workorderId); + array_unshift($msgList, [ + 'type' => 'op', + 'it_type' => 1, + 'avatar' => Storage::url($currentWorkorder->publisher->avatar), + 'name' => $currentWorkorder->publisher->name, + 'content' => $currentWorkorder->content, + 'created_at_text' => $currentWorkorder->created_at, + ]); + $data = [ 'user_list' => $userList, 'msg_list' => $msgList, diff --git a/app/AdminGuide/Controllers/WorkorderController.php b/app/AdminGuide/Controllers/WorkorderController.php index c87cf81..97958fb 100755 --- a/app/AdminGuide/Controllers/WorkorderController.php +++ b/app/AdminGuide/Controllers/WorkorderController.php @@ -41,12 +41,18 @@ class WorkorderController extends AdminController }) ->orderByDesc('updated_at') ->get(); + + // 先这么处理吧 + if ($workorderId == 0 && !empty($workorder)) { + return redirect('/admin-agent/workorder_item?workorder_id='.$workorder[0]->id); + } + foreach ($workorder as $v) { $item = WorkorderItem::query()->where('workorder_id',$v->id)->orderByDesc('updated_at')->first(); $arr = [ 'workorder_id' => $v->id, 'unread' => true, - 'avatar' => $v->publisher_type == DemandTraits::$col[2] ? $v->point->avatar : $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher_type == DemandTraits::$col[2] ? $v->point->avatar : $v->publisher->avatar), 'name' => $v->publisher_type == DemandTraits::$col[2] ? $v->point->name : $v->publisher->name, 'content' => $v->title, 'last_message' => $item ? ($item->type == 1 ? $item->content : '【 图片 】') : '', @@ -64,13 +70,24 @@ class WorkorderController extends AdminController $arr = [ 'type' => $v->publisher_type == DemandTraits::$col[2] ? 'my' : 'op', 'it_type' => $v->type, - 'avatar' => $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher->avatar), 'name' => $v->publisher->name, 'content' => $v->content, + 'created_at_text' => $v->created_at, ]; $msgList [] = $arr; } + $currentWorkorder = \App\Models\Workorder::find($workorderId); + array_unshift($msgList, [ + 'type' => 'op', + 'it_type' => 1, + 'avatar' => Storage::url($currentWorkorder->publisher->avatar), + 'name' => $currentWorkorder->publisher->name, + 'content' => $currentWorkorder->content, + 'created_at_text' => $currentWorkorder->created_at, + ]); + $data = [ 'user_list' => $userList, 'msg_list' => $msgList, diff --git a/app/AdminSupplier/Controllers/WorkorderController.php b/app/AdminSupplier/Controllers/WorkorderController.php index 3c5c692..e8a6640 100755 --- a/app/AdminSupplier/Controllers/WorkorderController.php +++ b/app/AdminSupplier/Controllers/WorkorderController.php @@ -41,12 +41,17 @@ class WorkorderController extends AdminController ->orderByDesc('updated_at') ->get(); + // 先这么处理吧 + if ($workorderId == 0 && !empty($workorder)) { + return redirect('/admin-agent/workorder_item?workorder_id='.$workorder[0]->id); + } + foreach ($workorder as $v) { $item = WorkorderItem::query()->where('workorder_id',$v->id)->orderByDesc('updated_at')->first(); $arr = [ 'workorder_id' => $v->id, 'unread' => true, - 'avatar' => $v->publisher_type == DemandTraits::$col[1] ? $v->point->avatar : $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher_type == DemandTraits::$col[1] ? $v->point->avatar : $v->publisher->avatar), 'name' => $v->publisher_type == DemandTraits::$col[1] ? $v->point->name : $v->publisher->name, 'content' => $v->title, 'last_message' => $item ? ($item->type == 1 ? $item->content : '【 图片 】') : '', @@ -64,13 +69,24 @@ class WorkorderController extends AdminController $arr = [ 'type' => $v->publisher_type == DemandTraits::$col[1] ? 'my' : 'op', 'it_type' => $v->type, - 'avatar' => $v->publisher->avatar, + 'avatar' => Storage::url($v->publisher->avatar), 'name' => $v->publisher->name, 'content' => $v->content, + 'created_at_text' => $v->created_at, ]; $msgList [] = $arr; } + $currentWorkorder = \App\Models\Workorder::find($workorderId); + array_unshift($msgList, [ + 'type' => 'op', + 'it_type' => 1, + 'avatar' => Storage::url($currentWorkorder->publisher->avatar), + 'name' => $currentWorkorder->publisher->name, + 'content' => $currentWorkorder->content, + 'created_at_text' => $currentWorkorder->created_at, + ]); + $data = [ 'user_list' => $userList, 'msg_list' => $msgList, diff --git a/app/Models/Agent.php b/app/Models/Agent.php index 1cdb5a0..523ccc6 100644 --- a/app/Models/Agent.php +++ b/app/Models/Agent.php @@ -43,4 +43,14 @@ class Agent extends BaseModel { return $this->morphOne('App\Models\DemandBidding', 'biddingUser'); } + + public function workoorder() + { + return $this->morphOne('App\Models\Workorder', 'publisher'); + } + + public function workoorderitem() + { + return $this->morphOne('App\Models\WorkorderItem', 'publisher'); + } } diff --git a/app/Models/Guide.php b/app/Models/Guide.php index 310ea5d..eae6bd9 100644 --- a/app/Models/Guide.php +++ b/app/Models/Guide.php @@ -31,4 +31,14 @@ class Guide extends BaseModel { return $this->morphOne('App\Models\DemandBidding', 'biddingUser'); } + + public function workoorder() + { + return $this->morphOne('App\Models\Workorder', 'publisher'); + } + + public function workoorderitem() + { + return $this->morphOne('App\Models\WorkorderItem', 'publisher'); + } } diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index f4a2a9e..24e6b60 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -48,4 +48,9 @@ class Supplier extends BaseModel { return $this->morphOne('App\Models\Workorder', 'point'); } + + public function workoorderitem() + { + return $this->morphOne('App\Models\WorkorderItem', 'publisher'); + } } diff --git a/database/migrations/2021_09_10_144727_update_workorder_table.php b/database/migrations/2021_09_10_144727_update_workorder_table.php new file mode 100644 index 0000000..e10a2e3 --- /dev/null +++ b/database/migrations/2021_09_10_144727_update_workorder_table.php @@ -0,0 +1,40 @@ +text('content')->nullable()->change(); + }); + + Schema::table('workorder_item', function (Blueprint $table) { + $table->text('content')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('workorder', function (Blueprint $table) { + $table->string('content')->change(); + }); + + Schema::table('workorder_item', function (Blueprint $table) { + $table->string('content')->change(); + }); + } +} diff --git a/public/js/helper.js b/public/js/helper.js new file mode 100644 index 0000000..582d23c --- /dev/null +++ b/public/js/helper.js @@ -0,0 +1,4 @@ +function viewImage(ele) { + $('#viewImage').find('img').attr('src', $(ele).attr('src')); + $('#viewImage').modal(); +} diff --git a/resources/views/admin/pages/index.blade.php b/resources/views/admin/pages/index.blade.php index eed6264..3fbc3e6 100644 --- a/resources/views/admin/pages/index.blade.php +++ b/resources/views/admin/pages/index.blade.php @@ -1,134 +1,145 @@