Browse Source

增加择岗意愿的选择

sandm 2 năm trước cách đây
mục cha
commit
83b1c0b8b2

+ 189 - 1
app/Http/Controllers/Web/Recruit/IndexController.php

@@ -20,6 +20,7 @@ use App\Models\RecruitAppointDetail;
 use App\Models\RecruitArticle;
 use Illuminate\Support\Facades\Cache;
 use App\Services\Common\BaiduService;
+use App\Models\RecruitAppointSelect;
 
 class IndexController extends WebBaseController
 {
@@ -2020,11 +2021,198 @@ class IndexController extends WebBaseController
 
     public function post_select(Request $request)
     {
+//        $user = $this->getUser();
+//        if (!empty($user)) {
+//            $uid = $user->id;
+//        } else {
+//            return redirect(route('login'));
+//        }
+//
+//        $recruit_id = $request->input('recruit_id');
+//        $appoint_id = $request->input('appoint_id');
+//
+//        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
+//
+//        if(!$info){
+//            return $this->showMessage('抱歉,您无需择岗!', route('recruit.show',array('id',$recruit_id)), true, '上一页', '2');
+//        }
+        $option_list = [
+            [
+                'id' => 1,
+                'name' => '青阳街道'
+            ],
+            [
+                'id' => 2,
+                'name' => '梅岭街道'
+            ],
+            [
+                'id' => 3,
+                'name' => '西园街道'
+            ],
+            [
+                'id' => 4,
+                'name' => '罗山街道'
+            ],
+            [
+                'id' => 5,
+                'name' => '灵源街道'
+            ],
+            [
+                'id' => 6,
+                'name' => '新塘街道'
+            ],
+            [
+                'id' => 7,
+                'name' => '陈埭镇'
+            ],
+            [
+                'id' => 8,
+                'name' => '池店镇'
+            ],
+            [
+                'id' => 9,
+                'name' => '安海镇'
+            ],
+            [
+                'id' => 10,
+                'name' => '磁灶镇'
+            ],
+            [
+                'id' => 11,
+                'name' => '内坑镇'
+            ],
+            [
+                'id' => 12,
+                'name' => '紫帽镇'
+            ],
+            [
+                'id' => 13,
+                'name' => '东石镇'
+            ],
+            [
+                'id' => 14,
+                'name' => '永和镇'
+            ],
+            [
+                'id' => 15,
+                'name' => '英林镇'
+            ],
+            [
+                'id' => 16,
+                'name' => '金井镇'
+            ],
+            [
+                'id' => 17,
+                'name' => '龙湖镇'
+            ],
+            [
+                'id' => 18,
+                'name' => '深沪镇'
+            ],
+            [
+                'id' => 19,
+                'name' => '西滨镇'
+            ]
+        ];
+        $select_list = [];
+        $recruit_id = $request->input('recruit_id');
+        $appoint_id = $request->input('appoint_id');
+        $uid = $request->input('uid');
+        $info = RecruitAppointSelect::where('uid',$uid)->first();
+        if(!$info){
+            $info = new \stdClass();
+            $info->status = 0;
+            $info->recruit_id = 8;
+            $info->appoint_id = rand(0,999999);
+            $info->uid = rand(0,999999);
+        }else{
+            $result = json_decode($info->result,true);
+            foreach ($option_list as $k => $v){
+                if(in_array($v['name'],$result)){
+                    $select_list[$k] = $v;
+                    unset($option_list[$k]);
+                }
+            }
+        }
 
-        $view_data = [];
+        $view_data = ['info' => $info,'options_list' => json_encode($option_list),'select_list' => json_encode($select_list)];
         return view('app.recruit.post_select',$view_data);
     }
 
+    /**
+     * 放弃择岗
+     */
+    public function give_up_post(Request $request)
+    {
+        //以下为测试环境
+        $recruit_id = $request->input('recruit_id');
+        $appoint_id = $request->input('appoint_id');
+        $uid = $request->input('uid');
+        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
+        if($info){
+            return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
+        }
+        RecruitAppointSelect::create(['recruit_id'=>$recruit_id,'appoint_id'=>$appoint_id,'uid'=>$uid,'status'=>-1]);
+        return ['status' => 1, 'msg' => "放弃择岗成功!"];
+
+
+        //以下为正式环境再放开
+        $user = $this->getUser();
+        if (!empty($user)) {
+            $uid = $user->id;
+        } else {
+            return redirect(route('login'));
+        }
+
+        $recruit_id = $request->input('recruit_id');
+        $appoint_id = $request->input('appoint_id');
+
+        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
+
+        if($info == null){
+            return ['status' => 0, 'msg' => "抱歉,您无需择岗!"];
+        }
+
+        if($info->status != 0){
+            return ['status' => 0, 'msg' => "抱歉,您不是待择岗状态!"];
+        }
+
+        $info->status = -1;
+
+        $info->save();
+
+        return ['status' => 1, 'msg' => "放弃择岗成功!"];
+    }
+
+    public function comfirm_post(Request $request)
+    {
+        //以下为测试环境
+        $recruit_id = $request->input('recruit_id');
+        $appoint_id = $request->input('appoint_id');
+        $uid = $request->input('uid');
+        $info = RecruitAppointSelect::where('uid',$uid)->where('recruit_id',$recruit_id)->where('appoint_id',$appoint_id)->first();
+        if($info){
+            return ['status' => 0, 'msg' => "测试数据重复,请重新点击生成测试数据!"];
+        }
+        $data = [
+            'recruit_id' => $recruit_id,
+            'appoint_id' => $recruit_id,
+            'uid' => $uid,
+            'status' => 1
+        ];
+        $result = [];
+        $select = $request->input('select');
+        if(is_array($select) && count($select) > 0){
+            foreach ($select as $v) {
+                array_push($result,$v['name']);
+            }
+        }
+        $data['result'] = json_encode($result);
+        RecruitAppointSelect::create($data);
+
+        return ['status' => 1, 'msg' => "提交择岗意愿成功,请耐心等待结果!"];
+    }
+
 
     public function interviewer_random(Request $request)
     {

+ 17 - 0
app/Models/RecruitAppointSelect.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class RecruitAppointSelect extends Model
+{
+
+    use SoftDeletes;
+    protected $table = 'recruit_appoint_select';
+
+    protected $guarded = [];
+
+
+}

+ 255 - 18
public/themes/default/views/app/recruit/post_select.blade.php

@@ -6,9 +6,70 @@
 
 @push('css')
     <style >
-        .container {
-            width: 1000px;
-            margin: 20px auto;
+        .op_block{
+            position: relative;
+            margin-top: 30px;
+        }
+        .draggable_content {
+            width: 60%;
+            float: left;
+            margin: 20px 0 0;
+        }
+        .tips{
+            float: right;
+            width: 35%;
+            margin: 20px 0 0;
+            border: 1px solid #ccc;
+        }
+        .tips_body{
+            padding: 20px;
+        }
+        .tips_body p{
+            line-height: 30px;
+            margin-bottom: 10px;
+            font-size: 20px;
+        }
+        .draggable_content h2{
+            line-height: 50px;
+            text-align: center;
+            border-bottom: 1px solid #ccc;
+        }
+        .draggable_content .select{
+            border: 1px solid #ccc;
+            width: 45%;
+            margin-right: 30px;
+            float: left;
+        }
+        .draggable_content .options{
+            width: 50%;
+            float: left;
+            border: 1px solid #ccc;
+        }
+        .list-group{
+            padding: 20px;
+        }
+        .list-group-item{
+            border-radius: 10px;
+            border: 1px dashed #0a9fd9;
+            line-height: 30px;
+            margin-bottom: 10px;
+            padding: 10px 30px;
+        }
+        .operation{
+            width: 100%;
+            float: left;
+            text-align: center;
+            margin-top: 30px;
+        }
+        .mask {
+            position: absolute;
+            top: 0px;
+            left: 0px;
+            background-color: #777;
+            z-index: 9;
+            filter: alpha(opacity=60);
+            opacity:0.5;
+            -moz-opacity:0.5;
         }
     </style>
 @endpush
@@ -16,20 +77,78 @@
 @push('js')
     <link href="{{ theme_asset('app/css/common.css') }}" rel="stylesheet">
     <link href="{{theme_asset('app/css/recruit/recruit.css')}}" rel="stylesheet" type="text/css"/>
-
+    <link rel="stylesheet" href="{{ theme_asset('app/css/element.css') }}">
 
 @endpush
 
 @section('content')
     <div id="app">
-        <div class="container">
-            <h2>晋江市公开招聘第十三批村务(社区)专职工作者</h2>
-            <draggable  :list="list" :disabled="!enabled" class="list-group" ghost-class="ghost"
-                        :move="checkMove" @start="dragging = true" @end="dragging = false">
-                <div class="list-group-item" v-for="element in list" :key="element.name" v-text="element.name">
+        <div class="recruit_container clearfix">
+            <div class="recruit_show_content" style="margin-top: 10px;width: 100%">
+                <div class="title" style="text-align: center"><h2>晋江市公开招聘第十三批村务(社区)专职工作者择岗系统</h2></div>
+                <div>
+                    <div class="operation">
+                        <el-button type="success" @click="rand()">生成随机测试数据</el-button> <el-button type="success" @click="enter()">进入指定测试数据</el-button>
+                    </div>
+                    <p style="text-align: center;line-height: 30px">当前测试数据:uid->{{ $info->uid }};recruit_id->{{ $info->recruit_id }};appoint_id->{{ $info->appoint_id }}</p>
+                </div>
+                <div role="alert" class="el-message el-message--error" style="position:relative" v-if="status == -1">
+                    <i class="el-message__icon el-icon-error"></i>
+                    <p class="el-message__content">您已放弃择岗</p>
+                </div>
+                <div role="alert" class="el-message el-message--success" style="position:relative" v-if="status == 1">
+                    <i class="el-message__icon el-icon-success"></i>
+                    <p class="el-message__content">您已提交择岗意向,请耐心等待结果!</p>
+                </div>
+                <div class="op_block clearfix" ref="opblock">
+                    <div class="draggable_content">
+                        <div class="select">
+                            <h2>意向镇(街道)</h2>
+                            <draggable  :list="select_list" :disabled="!enabled" class="list-group" ghost-class="ghost" @start="dragging = true" @end="dragging = false" v-bind="dragOptions">
+                                <div class="list-group-item" v-for="element in select_list" :key="element.name" v-text="element.name">
 
+                                </div>
+                            </draggable>
+                        </div>
+                        <div class="options">
+                            <h2>可选镇(街道)</h2>
+                            <draggable  :list="options_list" :disabled="!enabled" class="list-group" ghost-class="ghost" @start="dragging = true" @end="dragging = false" v-bind="dragOptions">
+                                <div class="list-group-item" v-for="element in options_list" :key="element.name" v-text="element.name">
+
+                                </div>
+                            </draggable>
+                        </div>
+                    </div>
+                    <div class="tips">
+                        <h2 style="text-align: center;line-height: 50px;border-bottom: 1px solid #ccc">
+                            择岗系统操作说明
+                        </h2>
+                        <div class="tips_body">
+                            <p>
+                                1.意向选择:请在右侧,按您的意向顺序,将可选镇(街道)中的选项拖曳进意向镇(街道)中。
+                            </p>
+                            <p>
+                                2.意向排序:鼠标左键单击(点住),拖动排序,完成后松开。
+                            </p>
+                            <p>
+                                3.意向可选择1个或多个,请根据自身情况选择。
+                            </p>
+                            <p>
+                                4.每个人有且仅有一次意向选择机会,提交后无法更改,请考虑好后再行提交。
+                            </p>
+                            <p>
+                                5.放弃择岗后将跳过择岗环节,后续无法再次参加。
+                            </p>
+                        </div>
+                    </div>
+                    <div class="operation" v-if="status == 0">
+                        <el-button type="warning" @click="giveup()">放弃择岗</el-button> <el-button type="success" @click="post()">提交择岗</el-button>
+                    </div>
+                    <div id="mask" class="mask" :style="switch_mask" ></div>
                 </div>
-            </draggable>
+
+            </div>
+
         </div>
     </div>
 
@@ -37,24 +156,142 @@
 
 @section('script')
     <script src="{{theme_asset('app/js/vue.min.js')}}"></script>
+    <script src="{{theme_asset('app/js/qs.min.js')}}"></script>
     <script src="{{theme_asset('app/js/axios.js')}}"></script>
     <script src="{{theme_asset('app/js/Sortable.min.js')}}"></script>
     <script src="{{theme_asset('app/js/vuedraggable.umd.min.js')}}"></script>
+    <script src="{{theme_asset('app/js/element.js')}}"></script>
     <script>
+        let recruit_id = '{{ $info->recruit_id }}';
+        let appoint_id = '{{ $info->appoint_id }}';
+        let status = '{{ $info->status }}';
+
         const app = new Vue({
             el: '#app',
             data: {
                 enabled: true,
-                list: [
-                    { name: "1 - John", id: 0 },
-                    { name: "2 - Joao", id: 1 },
-                    { name: "3 - Jean", id: 2 }
-                ],
-                dragging: false
+                select_list: eval({!! $select_list !!}),
+                options_list: eval({!! $options_list !!}),
+                dragging: false,
+                loading: true,
+                post_data: {
+                    recruit_id: recruit_id,
+                    appoint_id: appoint_id,
+                    uid: '{{ $info->uid }}'
+                },
+                status: status,
+                switch_mask:{}
             },
             methods: {
-                checkMove: function(e) {
-                    window.console.log("Future index: " + e.draggedContext.futureIndex);
+                post: function() {
+                    var msg = "您正在提交择岗的操作!";
+                    this.$confirm(msg, '警告', {
+                        confirmButtonText: '确认放弃',
+                        cancelButtonText: '我再想想',
+                        type: 'warning'
+                    }).then(() => {
+                        this.loading = this.$loading({
+                            lock: false,
+                            text: '加载中',
+                            spinner: 'el-icon-loading',
+                            background: 'rgba(0, 0, 0, 0.7)'
+                        });
+
+                        this.post_data._token = '{{csrf_token()}}';
+                        this.post_data.select = this.select_list;
+
+                        axios.post("{{route('recruit.comfirm_post')}}",Qs.stringify(this.post_data)).then(response => {
+
+                            if(response.data.status){
+                                this.$alert(response.data.msg, '提交成功', {
+                                    confirmButtonText: '确定',
+                                    callback: action => {
+                                        window.location.reload();
+                                    }
+                                });
+                            }else{
+                                this.$message.error(response.data.msg);
+                                this.loading.close();
+                                return false;
+                            }
+                        });
+                    }).catch(() => {
+
+                    });
+                },
+                giveup: function(){
+                    var msg = "您正在进行放弃择岗的操作!";
+                    this.$confirm(msg, '警告', {
+                        confirmButtonText: '确认放弃',
+                        cancelButtonText: '我再想想',
+                        type: 'warning'
+                    }).then(() => {
+                        this.loading = this.$loading({
+                            lock: false,
+                            text: '加载中',
+                            spinner: 'el-icon-loading',
+                            background: 'rgba(0, 0, 0, 0.7)'
+                        });
+
+                        this.post_data._token = '{{csrf_token()}}';
+
+                        axios.post("{{route('recruit.give_up_post')}}",Qs.stringify(this.post_data)).then(response => {
+
+                            if(response.data.status){
+                                this.$alert(response.data.msg, '提交成功', {
+                                    confirmButtonText: '确定',
+                                    callback: action => {
+                                        window.location.reload();
+                                    }
+                                });
+                            }else{
+                                this.$message.error(response.data.msg);
+                                this.loading.close();
+                                return false;
+                            }
+                        });
+                    }).catch(() => {
+
+                    });
+                },
+                showMask: function(){
+                    this.switch_mask.width = '100%';
+                    this.switch_mask.height = '1400px';
+                },
+                rand: function(){
+                    let href = location.protocol + '//' + location.host + location.pathname;
+                    window.location.href = href;
+                },
+                enter: function(){
+                    this.$prompt('请输入用户ID', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        inputPattern: /^-?\d+$/,
+                        inputErrorMessage: '用户ID不正确'
+                    }).then(({ value }) => {
+                        let href = location.protocol + '//' + location.host + location.pathname + '?uid='+value
+                        window.location.href = href;
+                    }).catch(() => {
+
+                    });
+                }
+            },
+            computed: {
+                dragOptions() {
+                    return {
+                        animation: 200,
+                        group: "description",
+                        disabled: false,
+                        ghostClass: "ghost"
+                    };
+                }
+            },
+            created(){
+                if(this.status == -1){
+                    this.showMask()
+                }
+                if(this.status != 0){
+                    this.enabled = false;
                 }
             }
         })

+ 0 - 3
public/themes/default/views/app/talent/jjhc/yqfk.blade.php

@@ -35,9 +35,6 @@
         .define-table th{
             font-weight:bold;background:#ccc;
         }
-        ————————————————
-        版权声明:本文为CSDN博主「NFA_YY」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
-                                             原文链接:https://blog.csdn.net/NFA_YY/article/details/75089564
     </style>
 @endpush
 

+ 2 - 1
routes/web.php

@@ -115,7 +115,8 @@ Route::group([
     $router->post('upload', 'Web\Recruit\ApiController@upload')->name('recruit.api.upload');//招考相关程序上传图片
     $router->post('save_sign_up', 'Web\Recruit\IndexController@saveSignUp')->name('recruit.save_sign_up');
     $router->get('post_select','Web\Recruit\IndexController@post_select')->name('recruit.post_select');
-
+    $router->post('give_up_post','Web\Recruit\IndexController@give_up_post')->name('recruit.give_up_post');
+    $router->post('comfirm_post','Web\Recruit\IndexController@comfirm_post')->name('recruit.comfirm_post');
 
     $router->any('/{route?}', function () {
         return view('recruit');