linwu 1 周之前
父節點
當前提交
2a49ac13c8
共有 3 個文件被更改,包括 82 次插入33 次删除
  1. 35 6
      app/home/controller/Officer.php
  2. 46 26
      app/home/view/officer/answer.html
  3. 1 1
      app/home/view/officer/index.html

+ 35 - 6
app/home/controller/Officer.php

@@ -14,7 +14,8 @@ class Officer extends MobileBaseController
 
     public function index()
     {
-        $id = input('id');
+        $id  = input('id', 0);
+        $aid = input('aid', 0);
         if (empty($id)) {
             return '该题库不存在或已删除';
         }
@@ -24,14 +25,39 @@ class Officer extends MobileBaseController
             return '该题库不存在或已删除';
         }
 
+        if ($aid > 0) {
+            $answer     = OfficerAnswerModel::find($aid);
+            $new_answer = OfficerAnswerModel::create([
+                'rid'              => $id,
+                'name'             => $answer['name'],
+                'sex'              => $answer['sex'],
+                'age'              => $answer['age'],
+                'marry'            => $answer['marry'],
+                'education'        => $answer['education'],
+                'major'            => $answer['major'],
+                'seniority'        => $answer['seniority'],
+                'leader'           => $answer['leader'],
+                'industry'         => $answer['industry'],
+                'company'          => $answer['company'],
+                'company_text'     => $answer['company_text'],
+                'job'              => $answer['job'],
+                'job_text'         => $answer['job_text'],
+                'current_position' => $answer['current_position'],
+            ]);
+            $aid = $new_answer['id'];
+        }
+
         return view('', [
             'review' => $review,
+            'aid'    => $aid,
         ]);
     }
 
     public function answer()
     {
-        $id = input('id');
+        $id  = input('id', 0);
+        $aid = input('aid', 0);
+
         if (empty($id)) {
             return '该题库不存在或已删除';
         }
@@ -49,6 +75,7 @@ class Officer extends MobileBaseController
 
         return view('', [
             'id'   => $id,
+            'aid'  => $aid,
             'list' => json_encode($list),
         ]);
     }
@@ -69,7 +96,7 @@ class Officer extends MobileBaseController
         $no    = input('no');
         $index = input('index');
 
-        $option = [];
+        $option       = [];
         $review_title = OfficerReviewTitleModel::where('rid', $id)->where('no', $no)->find();
         foreach ($review_title['option'] as $v) {
             if ($v['score'] == $index) {
@@ -89,10 +116,12 @@ class Officer extends MobileBaseController
 
     public function answerFinish()
     {
-        $aid   = input('aid');
-        $score = OfficerAnswerDetailModel::where('aid', $aid)->sum('score');
+        $id     = input('id');
+        $review = OfficerReviewModel::find($id);
+        $aid    = input('aid');
+        $score  = OfficerAnswerDetailModel::where('aid', $aid)->sum('score');
         OfficerAnswerModel::update(['score' => $score, 'status' => 2], ['id' => $aid]);
-        ajax_return();
+        ajax_return(0, '', $review['next_id']);
     }
 
 //    public function answerPost()

+ 46 - 26
app/home/view/officer/answer.html

@@ -96,23 +96,19 @@
         color: white;
         background: #1D6BD0;
     }
+
     .el-radio:last-child {
-        margin-right:32px;
+        margin-right: 32px;
     }
 </style>
 {/block}
 {block name="body"}
-<div class="step">
-    <el-steps style="width: 600px" :active="active" align-center>
-        <el-step title="基础信息"></el-step>
-        <el-step title="测评试卷"></el-step>
-    </el-steps>
-</div>
-
 <div class="base-info" v-show="active == 0">
+    <h2 style="text-align: center;padding-bottom: 20px;">基础信息</h2>
     {include file="officer/answer_base"/}
 </div>
 <div class="evaluate" v-show="active == 1">
+    <h2 style="text-align: center;padding-bottom: 20px;">测评试卷</h2>
     <div class="title">
         {{list[index].section}}
     </div>
@@ -134,25 +130,27 @@
                     </el-radio-group>
                 </fieldset>
             </el-col>
-<!--            <el-col :span="7" style="height:600px;">-->
-<!--                <div class="title-list">-->
-<!--                    <ul>-->
-<!--                        <li-->
-<!--                                class="num"-->
-<!--                                :class="{finish:answer_detail[item.no] > 0,current:i==index}"-->
-<!--                                :key="item.id"-->
-<!--                                v-for="(item,i) in list"-->
-<!--                                @click="changeTitle(i)"-->
-<!--                        >{{item.no}}-->
-<!--                        </li>-->
-<!--                    </ul>-->
-<!--                </div>-->
-<!--            </el-col>-->
+            <!--            <el-col :span="7" style="height:600px;">-->
+            <!--                <div class="title-list">-->
+            <!--                    <ul>-->
+            <!--                        <li-->
+            <!--                                class="num"-->
+            <!--                                :class="{finish:answer_detail[item.no] > 0,current:i==index}"-->
+            <!--                                :key="item.id"-->
+            <!--                                v-for="(item,i) in list"-->
+            <!--                                @click="changeTitle(i)"-->
+            <!--                        >{{item.no}}-->
+            <!--                        </li>-->
+            <!--                    </ul>-->
+            <!--                </div>-->
+            <!--            </el-col>-->
         </el-row>
     </div>
     <div class="info-btn mt-50">
         <el-button type="primary" size="large" @click="onNext" v-show="index + 1 != list.length">下一题</el-button>
-        <el-button type="primary" size="large" @click="onSubmit" v-loading="loading" v-show="index + 1 == list.length">提交</el-button>
+        <el-button type="primary" size="large" @click="onSubmit" v-loading="loading" v-show="index + 1 == list.length">
+            提交
+        </el-button>
     </div>
 </div>
 {/block}
@@ -161,10 +159,18 @@
     function v_setup() {
         const base = answer_base();
 
+        const aid = {$aid};
+        if (aid > 0) {
+            base.aid = Vue.ref(aid);
+            base.active = Vue.ref(1);
+        } else {
+            base.active = Vue.ref(0);
+        }
         base.list = {$list};
-        base.active = Vue.ref(0);
         base.answer_detail = Vue.ref({});
         base.index = Vue.ref(0);
+
+
         base.selectTile = () => {
             if (base.index.value + 1 == base.list.length) {
                 return false;
@@ -176,6 +182,10 @@
         }
         base.loading = Vue.ref(false);
         base.onNext = () => {
+            if (!base.answer_detail.value[base.list[base.index.value].no]) {
+                ElementPlus.ElMessage.error('必须选择一个选项');
+                return false;
+            }
             postJson("{:url('officer/answerDetailPost')}", {
                 id: {$id},
                 index: base.answer_detail.value[base.list[base.index.value].no],
@@ -189,6 +199,11 @@
                 return false;
             }
 
+            if (!base.answer_detail.value[base.list[base.index.value].no]) {
+                ElementPlus.ElMessage.error('必须选择一个选项');
+                return false;
+            }
+
             postJson("{:url('officer/answerDetailPost')}", {
                 id: {$id},
                 index: base.answer_detail.value[base.list[base.index.value].no],
@@ -196,11 +211,16 @@
                 no: base.list[base.index.value].no,
             }).then(() => {
                 postJson("{:url('officer/answerFinish')}", {
+                    id: {$id},
                     aid: base.aid.value,
-                }).then((data) => {
+                }).then(({data}) => {
                     base.loading.value = false;
                     ElementPlus.ElMessage.success('提交成功');
-                    location.href = "{:url('officer/finish')}";
+                    if (data > 0) {
+                        location.href = "{:url('officer/index')}?id=" + data + "&aid=" + base.aid.value;
+                    } else {
+                        location.href = "{:url('officer/finish')}";
+                    }
                 })
             })
 

+ 1 - 1
app/home/view/officer/index.html

@@ -18,7 +18,7 @@
         let base = {};
 
         base.toStart = () => {
-            location.href = "{:url('officer/answer')}?id={$review.id}"
+            location.href = "{:url('officer/answer')}?id={$review.id}&aid={$aid}"
         }
 
         return base;