123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const _sfc_main = {
- data() {
- return {
- formData: {
- id: null,
- documentId: null,
- cycleName: "",
- itemName: "",
- questions: [
- {
- parentLabel: ""
- }
- ]
- },
- msgType: "error",
- content: null,
- socket: null,
- questions: [
- {
- parentLabel: ""
- }
- ],
- commitQuestions: [],
- index: 1
- };
- },
- onLoad() {
- this.initWS();
- this.getDocument();
- },
- watch: {
- questions: {
- handler(newValue, oldValue) {
- let lastItemIndex = this.questions.length - 1;
- let preouisLastItemIndex = this.questions.length - 2;
- let lastScore = 100;
- for (let i in newValue) {
- if (newValue[i].score != null && newValue[i].score != "") {
- lastScore = lastScore - parseFloat(newValue[i].score);
- if (i == preouisLastItemIndex && lastScore >= 0) {
- this.questions[lastItemIndex].score = lastScore;
- }
- }
- }
- },
- deep: true
- }
- },
- methods: {
- initWS() {
- let socket = common_vendor.index.connectSocket({
- url: "wss://kps.scdayou.com/ws/apo/ws",
- //url: 'ws://127.0.0.1:8090/apo/ws',
- method: "GET",
- success: () => {
- console.log("socket success");
- }
- });
- this.socket = socket;
- },
- dialogToggle(val) {
- this.content = val;
- this.$refs.alertDialog.open();
- },
- getDocument() {
- var that = this;
- common_vendor.index.request({
- //url: "http://127.0.0.1:8090/apo/document/current",
- url: "https://kps.scdayou.com/apo/document/current",
- data: null,
- method: "get",
- success: function(res) {
- that.formData = res.data.data;
- if (that.formData.questions != null) {
- that.questions = that.formData.questions[0];
- }
- }
- });
- },
- submit() {
- var that = this;
- const data = that.formData;
- let xQuestions = that.questions;
- if (!data.professorNo) {
- that.dialogToggle("请输入专家编号");
- return;
- }
- let totalScore = 0;
- for (let i in xQuestions) {
- if (xQuestions[i].score == null || xQuestions[i].score == "") {
- that.dialogToggle("还存在未评分的题目,请完成后提交。");
- return;
- }
- totalScore += parseFloat(xQuestions[i].score);
- }
- if (totalScore != 100) {
- that.dialogToggle("评分之和必须等于100,请检查后再提交。");
- return;
- }
- for (let i in that.questions) {
- that.commitQuestions.push(that.questions[i]);
- }
- that.questions = [];
- for (let i = this.index; i < that.formData.questions.length; i++) {
- if (that.formData.questions[i].length > 0) {
- this.questions = that.formData.questions[i];
- this.index = i + 1;
- return;
- }
- }
- that.formData.result = that.commitQuestions;
- that.formData.questions = [];
- common_vendor.index.request({
- //url: "http://127.0.0.1:8090/apo/document/commit",
- url: "https://kps.scdayou.com/apo/document/commit",
- data: that.formData,
- method: "post",
- success: function(res) {
- that.formData = {
- professorNo: null,
- questions: []
- };
- that.commitQuestions = [];
- that.questions = [];
- common_vendor.index.closeSocket(that.socket);
- common_vendor.index.navigateTo({
- url: "ok"
- });
- }
- });
- },
- findChildren(item, callback) {
- if (item.children.length > 0) {
- callback(item.children);
- }
- }
- },
- destoryed() {
- common_vendor.index.onSocketClose(function(res) {
- console.log("WebSocket 已关闭!");
- });
- },
- beforeDestory() {
- common_vendor.index.onSocketClose(function(res) {
- console.log("WebSocket 已关闭!");
- });
- }
- };
- if (!Array) {
- const _easycom_uni_title2 = common_vendor.resolveComponent("uni-title");
- const _easycom_uni_notice_bar2 = common_vendor.resolveComponent("uni-notice-bar");
- const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
- const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
- const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
- const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card");
- const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
- const _easycom_uni_popup_dialog2 = common_vendor.resolveComponent("uni-popup-dialog");
- const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
- (_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)();
- }
- const _easycom_uni_title = () => "../../uni_modules/uni-title/components/uni-title/uni-title.js";
- const _easycom_uni_notice_bar = () => "../../uni_modules/uni-notice-bar/components/uni-notice-bar/uni-notice-bar.js";
- const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
- const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
- const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
- const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js";
- const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
- const _easycom_uni_popup_dialog = () => "../../uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.js";
- const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
- if (!Math) {
- (_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)();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: $data.formData.itemName != null
- }, $data.formData.itemName != null ? {
- b: common_vendor.p({
- type: "h2",
- align: "center",
- title: $data.formData.itemName + $data.formData.cycleName
- }),
- c: common_vendor.p({
- ["show-icon"]: true,
- text: "以下各评分项之和需等于100"
- }),
- d: common_vendor.p({
- type: "h5",
- align: "center",
- title: $data.questions[0].parentLabel,
- color: "rgb(191,44,35)"
- }),
- e: common_vendor.o(($event) => $data.formData.professorNo = $event),
- f: common_vendor.p({
- prefixIcon: "person",
- placeholder: "请输入专家编号(必填)",
- maxlength: "8",
- trim: "all",
- modelValue: $data.formData.professorNo
- }),
- g: common_vendor.p({
- name: "professorNo"
- }),
- h: common_vendor.f($data.questions, (item, index, i0) => {
- return {
- a: "7cd16330-8-" + i0 + "," + ("7cd16330-7-" + i0),
- b: common_vendor.t(index + 1 + "." + item.label),
- c: common_vendor.t(item.minScore == null || item.maxScore == null ? "" : item.minScore + "-" + item.maxScore),
- d: "7cd16330-10-" + i0 + "," + ("7cd16330-9-" + i0),
- e: common_vendor.o(($event) => item.score = $event, index),
- f: common_vendor.p({
- suffixIcon: "star-filled",
- type: "number",
- trim: "all",
- placeholder: "请输入该项分数",
- modelValue: item.score
- }),
- g: "7cd16330-9-" + i0 + "," + ("7cd16330-7-" + i0),
- h: "7cd16330-7-" + i0 + "," + ("7cd16330-6-" + i0),
- i: index,
- j: "7cd16330-6-" + i0 + ",7cd16330-3"
- };
- }),
- i: common_vendor.p({
- type: "help-filled",
- size: "20",
- color: "green"
- }),
- j: common_vendor.p({
- name: "score"
- }),
- k: common_vendor.p({
- ["is-shadow"]: true,
- margin: "5px"
- }),
- l: common_vendor.sr("form", "7cd16330-3"),
- m: common_vendor.p({
- modelValue: $data.formData
- }),
- n: common_vendor.o((...args) => $options.submit && $options.submit(...args)),
- o: common_vendor.o(_ctx.dialogClose),
- p: common_vendor.p({
- type: $data.msgType,
- cancelText: "关闭",
- title: "提示",
- content: $data.content
- }),
- q: common_vendor.sr("alertDialog", "7cd16330-11"),
- r: common_vendor.p({
- type: "dialog"
- })
- } : {});
- }
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "F:/development/HbuildWorkspace/KPS/pages/index/index.vue"]]);
- wx.createPage(MiniProgramPage);
|