You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

353 lines
7.8 KiB

  1. <template>
  2. <view class="page">
  3. <view class="inSecTitle">{{ title }}</view>
  4. <view class="inSecTime">{{ time }}</view>
  5. <view class="index_box">
  6. <view class="signSec2Box" v-for="(items, i) in dataList" :key="items.QTitle">
  7. <view v-if="items.QType == 1">
  8. <view class="shenInput">
  9. <view class="shenInputBox">
  10. <view class="signTxt" :class="redEva[i]? 'redEva' : ''">{{ items.QTitle }}</view>
  11. <view class="inputRadioRow">
  12. <view v-for="(item, j) in items.Ask_QuestionItems" :key="item.IID">
  13. <view class="inputRadioCol4">
  14. <view class="inputRadio checkBoxs" :class="answer[i].list.indexOf(j) > -1 ? 'active' : ''" @click="tapRadio(i, j, item.QShowText)"></view>
  15. <text>{{ item.ITitle }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view v-show="answer[i].QShowText" class="shenInput3" style="margin-top: 10px;">
  20. <l-textarea v-model="UText[i]" title="其他" class="" placeholder="请填写备注..." />
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view v-if="items.QType == 2">
  26. <view class="signTextarea">
  27. <view class="signTextareaBox">
  28. <view class="signTxt" :class="redEva[i]? 'redEva' : ''">{{ items.QTitle }}</view>
  29. <view class="inputRadioRow">
  30. <view v-for="(item, j) in items.Ask_QuestionItems" :key="item.IID">
  31. <view class="inputRadioCol2">
  32. <view class="inputCheck checkBoxs" :class="answer[i].list.indexOf(j) > -1 ? 'active' : ''" @click="tapCheck(i, j)"></view>
  33. <text>{{ item.ITitle }}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-show="answer[i].QShowText" class="shenInput3" style="margin-top: 10px;">
  38. <l-textarea v-model="UText[i]" title="其他" class="" placeholder="请填写备注..." />
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="shenRow"><view class="shenBtn" @click="tapbtn">保&nbsp;&nbsp;存</view></view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. title: '',
  53. time: '',
  54. dataList: [],
  55. answer: [],
  56. pageInfo: null,
  57. redEva: [],
  58. qmustFlag: false,
  59. redEvaCopy: [],
  60. flag: false,
  61. UText: []
  62. };
  63. },
  64. methods: {
  65. init() {
  66. this.pageInfo = this.GET_PARAM(); //获取页面传递参数
  67. let _this = this;
  68. _this.LOADING('加载数据中…');
  69. _this.HTTP_GET(
  70. '/learun/ask/paper',
  71. {
  72. VID: _this.pageInfo.VID
  73. },
  74. '加载数据时出错'
  75. )
  76. .then(data => {
  77. this.HIDE_LOADING();
  78. // console.log(data)
  79. if (data) {
  80. _this.title = data.VTitle;
  81. _this.time = data.VStartTime + '-' + data.VStopTime;
  82. _this.dataList = data.Ask_Questions;
  83. console.log(_this.dataList);
  84. _this.dataList.forEach((n, i) => {
  85. _this.answer.push({
  86. list: [],
  87. QShowText: false
  88. });
  89. _this.redEva.push(false);
  90. _this.UText.push('');
  91. });
  92. _this.redEvaCopy = this.COPY(this.redEva);
  93. }
  94. });
  95. },
  96. tapbtn() {
  97. let _this = this;
  98. _this.redEva = this.COPY(this.redEvaCopy);
  99. _this.qmustFlag = false;
  100. _this.flag = false;
  101. let jsons = {
  102. VID: _this.pageInfo.VID,
  103. LessonNo: _this.pageInfo.LessonNo,
  104. EmpNo: _this.pageInfo.EmpNo,
  105. postarray: []
  106. };
  107. _this.dataList.forEach((n, i) => {
  108. let len = _this.answer[i].list.length;
  109. var qmin = n.QMin == null? 0 : n.QMin;
  110. var qmax = n.QMust == null? 1 : n.QMust;
  111. if(n.QMust && len == 0){
  112. _this.redEva[i] = true;
  113. _this.qmustFlag = true;
  114. }
  115. if((qmin && len < qmin) || (qmax && len > qmax)){
  116. _this.redEva[i] = true;
  117. _this.flag = true;
  118. }
  119. if(_this.qmustFlag){
  120. this.TOAST('有必选项未选择', 'success');
  121. return
  122. }
  123. if(_this.flag){
  124. this.TOAST('有选择项少选或多选', 'success');
  125. return
  126. }
  127. _this.answer[i].list.forEach((m, j) => {
  128. jsons.postarray.push({
  129. QID: n.QID,
  130. IID: n.Ask_QuestionItems[m].IID,
  131. UText: _this.answer[i].QShowText? _this.UText[i] : ''
  132. })
  133. })
  134. _this.LOADING('保存数据中…')
  135. // console.log(jsons)
  136. // return
  137. _this.HTTP_GET('/learun/ask/savepaper', jsons, '加载数据时出错').then(res => {
  138. _this.HIDE_LOADING();
  139. console.log(res);
  140. this.TOAST('操作成功', 'success');
  141. this.EMIT('askList')
  142. this.NAV_BACK()
  143. });
  144. })
  145. },
  146. tapCheck(i, num) {
  147. let ind = this.answer[i].list.indexOf(num);
  148. let len = this.answer[i].list.length;
  149. if (ind > -1) {
  150. let QMin = this.dataList[i].QMin == null ? 0 : this.dataList[i].QMin;
  151. if (len <= QMin) {
  152. this.TOAST(`该选项最少选择 ${QMin} 项`, 'success');
  153. return;
  154. }
  155. this.answer[i].list.splice(ind, 1);
  156. } else {
  157. let QMax = this.dataList[i].QMax == null ? 1 : this.dataList[i].QMax;
  158. if (len >= QMax) {
  159. this.TOAST(`该选项最多选择 ${QMax} 项`, 'success');
  160. return;
  161. }
  162. this.answer[i].list.push(num);
  163. }
  164. this.answer[i].QShowText = false;
  165. this.answer[i].list.forEach((n, j) => {
  166. if (this.dataList[i].Ask_QuestionItems[n].QShowText) {
  167. this.answer[i].QShowText = true;
  168. }
  169. });
  170. },
  171. tapRadio(i, num, flag) {
  172. this.answer[i].list.length = 0;
  173. this.answer[i].list.push(num);
  174. this.answer[i].QShowText = flag;
  175. }
  176. },
  177. created() {
  178. this.init();
  179. }
  180. };
  181. </script>
  182. <style lang="less" scoped>
  183. /deep/ .cu-form-group {
  184. min-height: 30px;
  185. border: 0;
  186. }
  187. /deep/ .cu-form-group uni-textarea {
  188. border: 1px solid #cbcbcb;
  189. padding: 5px 10px;
  190. }
  191. .page {
  192. background-color: #fff;
  193. padding-top: 1px;
  194. padding-bottom: 30px;
  195. padding: 1px 15px 30px;
  196. }
  197. .inSecTitle {
  198. font-size: 20px;
  199. text-align: center;
  200. margin: 20px 0 0px;
  201. }
  202. .inSecTime {
  203. font-size: 12px;
  204. text-align: center;
  205. }
  206. .shenInput {
  207. margin-top: 15px;
  208. font-size: 14px;
  209. line-height: 24px;
  210. }
  211. .shenInput3 {
  212. // display: none;
  213. }
  214. .shenInput:before,
  215. .shenInput:after {
  216. display: table;
  217. content: ' ';
  218. }
  219. .shenInput:after {
  220. clear: both;
  221. }
  222. .signTxt {
  223. line-height: 24px;
  224. font-size: 14px;
  225. position: relative;
  226. }
  227. .shenInputBox {
  228. position: relative;
  229. }
  230. .shenInputBox1 {
  231. margin-left: 60px;
  232. }
  233. .inputRadioRow {
  234. overflow: hidden;
  235. }
  236. .inputRadioCol4 {
  237. margin-top: 8px;
  238. }
  239. .inputRadio {
  240. border-radius: 50%;
  241. }
  242. .inputCheck {
  243. border-radius: 2px;
  244. }
  245. .inputRadio.active:after {
  246. content: '';
  247. width: 12px;
  248. height: 12px;
  249. background: #0c86d8;
  250. position: absolute;
  251. left: 0;
  252. right: 0;
  253. bottom: 0;
  254. top: 0;
  255. margin: auto;
  256. border-radius: 50%;
  257. }
  258. .inputCheck.active:after {
  259. content: '';
  260. width: 12px;
  261. height: 12px;
  262. background: #0c86d8;
  263. position: absolute;
  264. left: 0;
  265. right: 0;
  266. bottom: 0;
  267. top: 0;
  268. margin: auto;
  269. border-radius: 2px;
  270. }
  271. .inputRadio,
  272. .inputCheck {
  273. font-style: normal;
  274. display: inline-block;
  275. vertical-align: middle;
  276. width: 20px;
  277. height: 20px;
  278. border: 1px solid #cbcbcb;
  279. margin: 0 10px;
  280. position: relative;
  281. cursor: pointer;
  282. }
  283. .shenInputBox > .span,
  284. .inputRadioCol4 .span,
  285. .inputRadioCol3 .span,
  286. .inputRadioCol2 .span {
  287. display: inline-block;
  288. vertical-align: middle;
  289. }
  290. .shenInput > .span {
  291. display: block;
  292. float: left;
  293. width: 60px;
  294. text-align: right;
  295. padding: 4px 8px 4px 0px;
  296. line-height: 24px;
  297. }
  298. .shenInputBox .inputTxt {
  299. width: 100%;
  300. display: block;
  301. height: 32px;
  302. line-height: 20px;
  303. border: 1px solid #cbcbcb;
  304. padding: 6px 10px;
  305. font-size: 14px;
  306. }
  307. .shenBtnBox .signTxt {
  308. margin-top: 30px;
  309. margin-left: 30px;
  310. }
  311. .shenBtn {
  312. width: 74%;
  313. background: #0c86d8;
  314. text-align: center;
  315. line-height: 40px;
  316. margin: 20px auto 20px;
  317. font-size: 17px;
  318. color: #fff;
  319. border-radius: 2px;
  320. cursor: pointer;
  321. border-radius: 4px;
  322. -webkit-user-select: none;
  323. -moz-user-select: none;
  324. -ms-user-select: none;
  325. user-select: none;
  326. }
  327. .signTextareaBox {
  328. margin-top: 20px;
  329. position: relative;
  330. }
  331. .inputRadioRow {
  332. overflow: hidden;
  333. }
  334. .inputRadioCol2 {
  335. margin-top: 8px;
  336. }
  337. .inputCheck image {
  338. width: 100%;
  339. display: none;
  340. }
  341. .signTextarea {
  342. margin-top: 15px;
  343. font-size: 14px;
  344. line-height: 24px;
  345. }
  346. .redEva {
  347. color: red !important;
  348. }
  349. </style>