index.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. formData: {
  7. id: null,
  8. documentId: null,
  9. cycleName: "",
  10. itemName: "",
  11. questions: [
  12. {
  13. parentLabel: ""
  14. }
  15. ]
  16. },
  17. msgType: "error",
  18. content: null,
  19. socket: null,
  20. questions: [
  21. {
  22. parentLabel: ""
  23. }
  24. ],
  25. commitQuestions: [],
  26. index: 1
  27. };
  28. },
  29. onLoad() {
  30. this.initWS();
  31. this.getDocument();
  32. },
  33. watch: {
  34. questions: {
  35. handler(newValue, oldValue) {
  36. let lastItemIndex = this.questions.length - 1;
  37. let preouisLastItemIndex = this.questions.length - 2;
  38. let lastScore = 100;
  39. for (let i in newValue) {
  40. if (newValue[i].score != null && newValue[i].score != "") {
  41. lastScore = lastScore - parseFloat(newValue[i].score);
  42. if (i == preouisLastItemIndex && lastScore >= 0) {
  43. this.questions[lastItemIndex].score = lastScore;
  44. }
  45. }
  46. }
  47. },
  48. deep: true
  49. }
  50. },
  51. methods: {
  52. initWS() {
  53. let socket = common_vendor.index.connectSocket({
  54. url: "wss://kps.scdayou.com/ws/apo/ws",
  55. //url: 'ws://127.0.0.1:8090/apo/ws',
  56. method: "GET",
  57. success: () => {
  58. console.log("socket success");
  59. }
  60. });
  61. this.socket = socket;
  62. },
  63. dialogToggle(val) {
  64. this.content = val;
  65. this.$refs.alertDialog.open();
  66. },
  67. getDocument() {
  68. var that = this;
  69. common_vendor.index.request({
  70. //url: "http://127.0.0.1:8090/apo/document/current",
  71. url: "https://kps.scdayou.com/apo/document/current",
  72. data: null,
  73. method: "get",
  74. success: function(res) {
  75. that.formData = res.data.data;
  76. if (that.formData.questions != null) {
  77. that.questions = that.formData.questions[0];
  78. }
  79. }
  80. });
  81. },
  82. submit() {
  83. var that = this;
  84. const data = that.formData;
  85. let xQuestions = that.questions;
  86. if (!data.professorNo) {
  87. that.dialogToggle("请输入专家编号");
  88. return;
  89. }
  90. let totalScore = 0;
  91. for (let i in xQuestions) {
  92. if (xQuestions[i].score == null || xQuestions[i].score == "") {
  93. that.dialogToggle("还存在未评分的题目,请完成后提交。");
  94. return;
  95. }
  96. totalScore += parseFloat(xQuestions[i].score);
  97. }
  98. if (totalScore != 100) {
  99. that.dialogToggle("评分之和必须等于100,请检查后再提交。");
  100. return;
  101. }
  102. for (let i in that.questions) {
  103. that.commitQuestions.push(that.questions[i]);
  104. }
  105. that.questions = [];
  106. for (let i = this.index; i < that.formData.questions.length; i++) {
  107. if (that.formData.questions[i].length > 0) {
  108. this.questions = that.formData.questions[i];
  109. this.index = i + 1;
  110. return;
  111. }
  112. }
  113. that.formData.result = that.commitQuestions;
  114. that.formData.questions = [];
  115. common_vendor.index.request({
  116. //url: "http://127.0.0.1:8090/apo/document/commit",
  117. url: "https://kps.scdayou.com/apo/document/commit",
  118. data: that.formData,
  119. method: "post",
  120. success: function(res) {
  121. that.formData = {
  122. professorNo: null,
  123. questions: []
  124. };
  125. that.commitQuestions = [];
  126. that.questions = [];
  127. common_vendor.index.closeSocket(that.socket);
  128. common_vendor.index.navigateTo({
  129. url: "ok"
  130. });
  131. }
  132. });
  133. },
  134. findChildren(item, callback) {
  135. if (item.children.length > 0) {
  136. callback(item.children);
  137. }
  138. }
  139. },
  140. destoryed() {
  141. common_vendor.index.onSocketClose(function(res) {
  142. console.log("WebSocket 已关闭!");
  143. });
  144. },
  145. beforeDestory() {
  146. common_vendor.index.onSocketClose(function(res) {
  147. console.log("WebSocket 已关闭!");
  148. });
  149. }
  150. };
  151. if (!Array) {
  152. const _easycom_uni_title2 = common_vendor.resolveComponent("uni-title");
  153. const _easycom_uni_notice_bar2 = common_vendor.resolveComponent("uni-notice-bar");
  154. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  155. const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  156. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  157. const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
  158. const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  159. const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog");
  160. const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  161. (_easycom_uni_title2 + _easycom_uni_notice_bar2 + _easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_uni_icons2 + _easycom_uni_card2 + _easycom_uni_forms2 + _easycom_uni_popup_dialog2 + _easycom_uni_popup2)();
  162. }
  163. const _easycom_uni_title = () => "../../uni_modules/uni-title/components/uni-title/uni-title.js";
  164. const _easycom_uni_notice_bar = () => "../../uni_modules/uni-notice-bar/components/uni-notice-bar/uni-notice-bar.js";
  165. const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  166. const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
  167. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  168. const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
  169. const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
  170. const _easycom_uni_popup_dialog = () => "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js";
  171. const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
  172. if (!Math) {
  173. (_easycom_uni_title + _easycom_uni_notice_bar + _easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_uni_icons + _easycom_uni_card + _easycom_uni_forms + _easycom_uni_popup_dialog + _easycom_uni_popup)();
  174. }
  175. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  176. return common_vendor.e({
  177. a: $data.formData.itemName != null
  178. }, $data.formData.itemName != null ? {
  179. b: common_vendor.p({
  180. type: "h2",
  181. align: "center",
  182. title: $data.formData.itemName + $data.formData.cycleName
  183. }),
  184. c: common_vendor.p({
  185. ["show-icon"]: true,
  186. text: "以下各评分项之和需等于100"
  187. }),
  188. d: common_vendor.p({
  189. type: "h5",
  190. align: "center",
  191. title: $data.questions[0].parentLabel,
  192. color: "rgb(191,44,35)"
  193. }),
  194. e: common_vendor.o(($event) => $data.formData.professorNo = $event),
  195. f: common_vendor.p({
  196. prefixIcon: "person",
  197. placeholder: "请输入专家编号(必填)",
  198. maxlength: "8",
  199. trim: "all",
  200. modelValue: $data.formData.professorNo
  201. }),
  202. g: common_vendor.p({
  203. name: "professorNo"
  204. }),
  205. h: common_vendor.f($data.questions, (item, index, i0) => {
  206. return {
  207. a: "7cd16330-8-" + i0 + "," + ("7cd16330-7-" + i0),
  208. b: common_vendor.t(index + 1 + "." + item.label),
  209. c: common_vendor.t(item.minScore == null || item.maxScore == null ? "" : item.minScore + "-" + item.maxScore),
  210. d: "7cd16330-10-" + i0 + "," + ("7cd16330-9-" + i0),
  211. e: common_vendor.o(($event) => item.score = $event, index),
  212. f: common_vendor.p({
  213. suffixIcon: "star-filled",
  214. type: "number",
  215. trim: "all",
  216. placeholder: "请输入该项分数",
  217. modelValue: item.score
  218. }),
  219. g: "7cd16330-9-" + i0 + "," + ("7cd16330-7-" + i0),
  220. h: "7cd16330-7-" + i0 + "," + ("7cd16330-6-" + i0),
  221. i: index,
  222. j: "7cd16330-6-" + i0 + ",7cd16330-3"
  223. };
  224. }),
  225. i: common_vendor.p({
  226. type: "help-filled",
  227. size: "20",
  228. color: "green"
  229. }),
  230. j: common_vendor.p({
  231. name: "score"
  232. }),
  233. k: common_vendor.p({
  234. ["is-shadow"]: true,
  235. margin: "5px"
  236. }),
  237. l: common_vendor.sr("form", "7cd16330-3"),
  238. m: common_vendor.p({
  239. modelValue: $data.formData
  240. }),
  241. n: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
  242. o: common_vendor.o(_ctx.dialogClose),
  243. p: common_vendor.p({
  244. type: $data.msgType,
  245. cancelText: "关闭",
  246. title: "提示",
  247. content: $data.content
  248. }),
  249. q: common_vendor.sr("alertDialog", "7cd16330-11"),
  250. r: common_vendor.p({
  251. type: "dialog"
  252. })
  253. } : {});
  254. }
  255. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/development/HbuildWorkspace/KPS/pages/index/index.vue"]]);
  256. wx.createPage(MiniProgramPage);