answer.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. {extend name="public/base"/}
  2. {block name="css"}
  3. <style>
  4. .title {
  5. text-indent: 2em;
  6. background: white;
  7. padding: 0 10px 20px 10px;
  8. font-size: 14px;
  9. }
  10. </style>
  11. {/block}
  12. {block name="body"}
  13. <van-nav-bar
  14. class="nav-theme"
  15. :fixed="true"
  16. :placeholder="true"
  17. >
  18. <template #title>
  19. <span class="text-white">人资测评系统</span>
  20. </template>
  21. </van-nav-bar>
  22. <van-steps :active="active">
  23. <van-step>基础信息</van-step>
  24. <van-step v-for="(item,key) in list" :key="item.id">{{key + 1}}</van-step>
  25. </van-steps>
  26. <div v-show="active==0">
  27. {include file="officer/answer_base"/}
  28. </div>
  29. <div v-for="(item,index) in list" :key="'list_' + item.id" v-show="active==index+1">
  30. <div class="title">{{item.name}}</div>
  31. <van-radio-group v-model="answer_detail[title_item.no]" style="margin-top:10px" :key="'title_' + title_item.id" v-for="(title_item,title_index) in item.title_list">
  32. <van-cell-group>
  33. <van-cell :title="title_item.no + '.' + title_item.title"></van-cell>
  34. <van-cell :title="option_item.title" clickable @click="answer_detail[title_item.no] = option_index" :key="'option_' + title_item.id + '_' + option_index" v-for="(option_item,option_index) in title_item.option">
  35. <template #right-icon>
  36. <van-radio :name="option_index" ></van-radio>
  37. </template>
  38. </van-cell>
  39. </van-cell-group>
  40. </van-radio-group>
  41. <div style="margin: 16px;display: flex;align-items: center;justify-content: space-around;">
  42. <div style="width:40%">
  43. <van-button type="success" size="large" @click="onStep(index)">
  44. 上一步
  45. </van-button>
  46. </div>
  47. <div style="width:40%">
  48. <van-button type="primary" size="large" @click="onStep(index+2)" v-show="list.length > index+1">
  49. 下一步
  50. </van-button>
  51. <van-button type="primary" size="large" @click="onSubmit" v-show="list.length <= index+1">
  52. 提交
  53. </van-button>
  54. </div>
  55. </div>
  56. </div>
  57. {/block}
  58. {block name="script"}
  59. <script>
  60. function v_setup() {
  61. let base = answer_base();
  62. base.list = {$list};
  63. let sum = 0;
  64. for (let item of base.list) {
  65. sum += item.title_list.length;
  66. }
  67. base.active = Vue.ref(0);
  68. base.onStep = (active) => {
  69. base.active.value = active;
  70. window.scrollTo({
  71. top: 0,
  72. behavior: 'smooth', // 平滑滚动
  73. });
  74. }
  75. base.onSubmit = () => {
  76. for (let i = 0; i < sum; i++) {
  77. if (base.answer_detail.value[i+1] === undefined) {
  78. vant.showToast(`第${i+1}题未填写`);
  79. return false;
  80. }
  81. }
  82. base.answer.value.rid = {$id};
  83. vant.showLoadingToast({
  84. message: '正在提交中...',
  85. forbidClick: true,
  86. duration: 0,
  87. });
  88. postJson("{:url('officer/answerPost')}",{id:{$id},answer:base.answer.value,answer_detail:base.answer_detail.value}).then((data) => {
  89. vant.closeToast();
  90. vant.showToast('提交成功');
  91. location.href = "{:url('officer/finish')}";
  92. })
  93. }
  94. base.answer_detail = Vue.ref({});
  95. return base;
  96. }
  97. </script>
  98. {/block}