index.js 8.2 KB

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