From 06539bb26b270209a06bac5ee8547fba5a370011 Mon Sep 17 00:00:00 2001 From: wyw <571921741@qq.com> Date: Fri, 6 Mar 2026 11:29:24 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E5=9C=B0=E5=9D=80=20?= =?UTF-8?q?=EF=BC=88=E5=BC=80=E5=8F=91=E7=9B=B8=E5=85=B3=EF=BC=8C=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E7=8E=AF=E5=A2=83=E5=BA=94=E8=AF=A5=E6=98=AF=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=9C=B0=E5=9D=80=EF=BC=89=202=E3=80=81?= =?UTF-8?q?=E8=80=83=E8=AF=95=E7=95=8C=E9=9D=A2=20=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E8=AF=BE=E4=BB=B6=E8=80=83=E5=AE=8C=E5=86=8D?= =?UTF-8?q?=E5=8F=A6=E4=B8=80=E4=B8=AA=EF=BC=88=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=8F=82=E6=95=B0=EF=BC=89=203=E3=80=81?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E8=AF=95=E5=8D=B7=20=E4=BC=98=E5=8C=96=204?= =?UTF-8?q?=E3=80=81=E4=BD=8D=E6=8E=A9=E7=A0=81=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=AD=94=E6=A1=88=20=E8=8E=B7=E5=8F=96=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=A1=B9=205=E3=80=81=E6=B7=BB=E5=8A=A0=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=9C=B0=E5=9D=80=20=E7=94=A8=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E7=BB=84=E4=BB=B6=20=E6=98=BE=E7=A4=BA=E9=99=84?= =?UTF-8?q?=E4=BB=B6=20=E6=95=B0=E6=8D=AE=E8=A3=85=E7=AE=B1=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/common.js | 12 +- pages/apply/subPages/SE/7answerPageEdit.vue | 242 ++++++++++++-------- utils/common.js | 31 +++ 3 files changed, 181 insertions(+), 104 deletions(-) diff --git a/config/common.js b/config/common.js index ea2fa7f..9cc73a7 100644 --- a/config/common.js +++ b/config/common.js @@ -73,10 +73,12 @@ const getServiceHost = api => { BI: 5179 }, { WB: 5179 - },{ + }, { TL: 5179 }, - { SK: 5180 } + { + SK: 5180 + } ] let port = 5112 for (let i = 0; i < apimodules.length; i++) { @@ -105,6 +107,7 @@ if (process.env.CUSTOM_PLATFORM === "dev") { uni_app_web_url: "", // uni_app_web_api_url: "http://localhost", // 请求接口的地址 uni_app_web_source_url: "http://localhost:5199", // 资源地址 + uni_app_web_video_source_url: "http://localhost:5199", // 视频资源地址 uni_app_web_local_api_url: "http://localhost", // 请求接口的地址 } } else if (process.env.CUSTOM_PLATFORM === "test") { @@ -118,6 +121,7 @@ if (process.env.CUSTOM_PLATFORM === "dev") { uni_app_web_url: "", // uni_app_web_api_url: "http://121.41.2.71", // 请求接口的地址 uni_app_web_source_url: "http://121.41.2.71:5199", // 资源地址 + uni_app_web_video_source_url: "http://localhost:5199", // 视频资源地址 uni_app_web_local_api_url: "http://121.41.2.71", // 请求接口的地址 } } else @@ -131,8 +135,10 @@ if (process.env.CUSTOM_PLATFORM === "dev") { uni_app_web_url: "", uni_app_web_api_url: APP_ENV === 'release' ? "http://124.117.209.78" : "http://121.41.2.71", uni_app_web_source_url: APP_ENV === 'release' ? "http://124.117.209.78:5199" : "http://121.41.2.71:5199", + uni_app_web_video_source_url: APP_ENV === 'release' ? "http://124.117.209.78:5199" : + "https://sps.cxtc.com:3199", // 视频资源地址 uni_app_web_local_api_url: APP_ENV === 'release' ? "http://124.117.209.78" : - "http://121.41.2.71" //打包测试: 121.41.2.71 开发可 localhost + "http://localhost" //打包测试: 121.41.2.71 开发可 localhost } diff --git a/pages/apply/subPages/SE/7answerPageEdit.vue b/pages/apply/subPages/SE/7answerPageEdit.vue index 2022524..acb2780 100644 --- a/pages/apply/subPages/SE/7answerPageEdit.vue +++ b/pages/apply/subPages/SE/7answerPageEdit.vue @@ -44,49 +44,35 @@ - + - - - - + + + + - + + v-for="(item, index) in perPaper"> + {{(index+1)+'. '+ item.Nav_Test.NAME+getType(item.Nav_Test.TYPE)}} - - - + @@ -138,7 +124,8 @@ guid, initFilter, initFilterGroup, - getSelectedOptions + getSelectedOptions, + getFileShow } from '../../../../utils/common' import { getRequest, @@ -150,13 +137,13 @@ model: { ORG_ID: "", }, - papers: [], + papers: [], //wyw 引入课件后 变成 perPaper 的总和 20260306 viewAll: false, record: null, notify: null, UserList: [], SelUsrID: null, - config: null, + configE: null, score: 0, END_TIME: null, readonly: true, @@ -180,8 +167,19 @@ EDIT_ID: '', SelUsrNAME: '', ORG_ID: uni.getStorageSync('orgId'), - filepath: 'https://sps.cxtc.com:3199/BT/VIDEO/20251226/251226100216835841.mp4' + isCourEdit: false, //是否 有课件的考试 + isViedo: false, + isViedoEnd: true, + filepath: '', + filepathf: [], + btnText: '提交', //'下一题' + perPaper: [], //每次的答题 wyw 20260306 + listPath: [], + indexCour: -1 //课件 + } + // https: //sps.cxtc.com:3199/BT/VIDEO/20251226/251226100216835841.mp4 + // https: //sps.cxtc.com:3199/BT/VIDEO/20251226/12345.mp4 }, onLoad(option) { this.TaskID = option.taskID ? option.taskID : ''; @@ -228,7 +226,7 @@ if (!this.TaskID) { scort = 'TEXT_ID' } - const json = initFilter(this.ORG_ID, "", scort, 1) + const json = initFilter(this.ORG_ID, this.TaskID, scort, 1) if (this.TaskID) { extendRule(json, 'TEXT_ID', 1, this.model.ID); } else { @@ -247,13 +245,20 @@ extendInclude(json, 'Nav_User'); getRequest(json, "/SE/SETrainRecord/GetUserPapers").then(res => { this.model = res - + if (this.tableKey == '1' && res.listPath != null && res.listPath.length > 0) { + this.isCourEdit = true //考试 有 课件 + this.listPath = res.listPath + } + if (res.listPath.length > 1) { + this.btnText = '下一题' + } if (res && res.Nav_Papers && res.Nav_Papers.length > 0) { let papers = res.Nav_Papers.sort((a, b) => { return a.Nav_Test.TYPE - b.Nav_Test.TYPE }); - let config = res.Nav_Config; + + let configE = res.Nav_Config; let record = res.Nav_Papers[0].Nav_Record; let notify = record ? record.Nav_Notify : null; let hasAnswered = false; @@ -265,6 +270,7 @@ this.papers = papers; this.papers.forEach(item => { if (item.Nav_Test.TYPE == 2) { + //查看试卷时 多选的绑定答案做数据处理 item.ANSWER3 = getSelectedOptions(item.ANSWER) } let test = {} @@ -280,59 +286,46 @@ name: item.Nav_Test.OPTION_C, value: 4 }, ) - if (item.Nav_Test.OPTION_D != undefined && item.Nav_Test.OPTION_D != "") { + if (item.Nav_Test.OPTION_D != undefined && item.Nav_Test.OPTION_D != + "") { this.radiolist2[item.ID].push({ name: item.Nav_Test.OPTION_D, value: 8 }) } - if (item.Nav_Test.OPTION_E != undefined && item.Nav_Test.OPTION_E != "") { + if (item.Nav_Test.OPTION_E != undefined && item.Nav_Test.OPTION_E != + "") { this.radiolist2[item.ID].push({ name: item.Nav_Test.OPTION_E, value: 16 }) } } - // if (item.Nav_Test.TYPE == 0) { - // if (item.ANSWER == 1) { - // item.ANSWER = "正确"; - // } else if (item.ANSWER == 2) { - // item.ANSWER = "错误"; - // } - // if (item.Nav_Test.ANSWER == 1) { - // item.Nav_Test.ANSWER = "正确"; - // } else if (item.ANSWER == 2) { - // item.Nav_Test.ANSWER = "错误"; - // } - // } else if (item.Nav_Test.TYPE == 1) { - // switch (item.ANSWER) { - // case 1: - // item.ANSWER = item.Nav_Test.OPTION_A; - // break; - // case 2: - // item.ANSWER = item.Nav_Test.OPTION_B; - // break; - // case 4: - // item.ANSWER = item.Nav_Test.OPTION_C; - // break; - // case 8: - // item.ANSWER = item.Nav_Test.OPTION_D; - // break; - // case 16: - // item.ANSWER = item.Nav_Test.OPTION_E; - // break; - // } - // } else if (item.Nav_Test.TYPE == 2) { - // item.ANSWER = this.findSelectedOptions(item.ANSWER, item.Nav_Test.OPTION_A, - // item.Nav_Test.OPTION_B, item.Nav_Test.OPTION_C, item.Nav_Test - // .OPTION_D, item.Nav_Test.OPTION_E); - // } }) - this.config = config; + this.configE = configE; this.record = record; this.notify = notify; this.readonly = hasAnswered; this.score = this.papers[0].SCORE; + if (this.isCourEdit) { + this.submit() + } else { + this.perPaper = this.papers //提供显示 + } + // this.filepath = res.listPath[0] + // this.perPaper = this.papers.filter(e => e.FILE_PATH == this.filepath) + // //如果是课件 对数据进行二次处理 + // if (this.isCourEdit) { + // if (this.filepath.indexOf('/VIDEO/') > -1) { + // this.isViedo = true + // this.isViedoEnd = false + // this.filepath = config.uni_app_web_video_source_url + this.filepath + // this.filepathf = [] + // } else { + // this.isViedo = false + // this.filepathf = getFileShow(this.filepath) + // } + // } } else { uni.$showMsgFunc('未能成功获取此用户的在线试卷,请稍后重试!', () => {}, 'error', 1000) @@ -372,16 +365,16 @@ }, getType(type) { let ret = ''; - let config = this.config; + let configE = this.configE; switch (type) { case 0: - ret = `【是非题】(${config && config.C_TEST_SCORE || 1}分)`; + ret = `【是非题】(${configE && configE.C_TEST_SCORE || 1}分)`; break; case 1: - ret = `【单选题】(${config && config.S_TEST_SCORE || 1}分)`; + ret = `【单选题】(${configE && configE.S_TEST_SCORE || 1}分)`; break; case 2: - ret = `【多选题】(${config && config.M_TEST_SCORE || 1}分)`; + ret = `【多选题】(${configE && configE.M_TEST_SCORE || 1}分)`; break; } return ret; @@ -415,8 +408,8 @@ item.ANSWER = 16; } }, - checkboxChange(arr, item,itemID) { - let indexArr = this.findCommonElementsIndices(arr, this.radiolist2[itemID])//item.ID + checkboxChange(arr, item, itemID) { + let indexArr = this.findCommonElementsIndices(arr, this.radiolist2[itemID]) //item.ID item.ANSWER3 = arr; item.ANSWER = 0; indexArr.forEach(index => { @@ -437,7 +430,7 @@ const commonElements = []; for (let i = 0; i < arr1.length; i++) { for (let j = 0; j < arr2.length; j++) { - if (arr1[i] === arr2[j].value) {//name + if (arr1[i] === arr2[j].value) { //name commonElements.push(j); break } @@ -446,32 +439,79 @@ return commonElements; }, submit() { - let data = { - Nav_Config: JSON.parse(JSON.stringify(this.config)), - Nav_Papers: JSON.parse(JSON.stringify(this.papers)), - TaskID: this.TaskID, - ORG_ID: this.ORG_ID, - TEXT_ID: this.EDIT_ID, //this.props.data.id - } - for (let i = 0; i < data.Nav_Papers.length; i++) { - if (data.Nav_Papers[i].ANSWER == 0) { - uni.$showMsgFunc(`第${i + 1}题尚未选择答题,请完成所有答题后再进行提交`, () => {}, 'error', 2000) - return; - } - } - getRequest(data, "/SE/SETrainRecord/SavePapers").then(res => { - if (res && res.IsOperateSuccessful) { - var icon = 'success' - var duration = 1000 - if (!res.IsPass) { - icon = 'error' - duration = 2000 + if (this.indexCour > -1) { //首次加载不进来 + for (let i = 0; i < this.perPaper.length; i++) { + if (this.perPaper[i].ANSWER == 0) { + uni.$showMsgFunc(`第${i + 1}题尚未选择答题,请完成所有答题后再进行提交`, () => {}, 'error', 2000) + return; + } else if (this.perPaper[i].Nav_Test.TYPE == 2 && (this.perPaper[i].ANSWER == 1 || this.perPaper[i] + .ANSWER == 2 || this.perPaper[i].ANSWER == 4 || this.perPaper[i].ANSWER == 8 || this + .perPaper[ + i].ANSWER == 16)) { + uni.$showMsgFunc(`第${i + 1}题为多选题,请完善答题后再进行提交`, () => {}, 'error', 2000) + return; } - uni.$showMsgFunc(res.Msg, () => { - uni.navigateBack() - }, icon, duration) } - }) + var replaceModel = {} + this.papers.forEach(e => { + replaceModel = this.perPaper.filter(ep => e.ID == ep.ID) + if (replaceModel != null) { + e = replaceModel + } + }) + } + if (this.btnText == '提交' && this.indexCour > -1) { + //提交 + let data = { + Nav_Config: JSON.parse(JSON.stringify(this.configE)), + Nav_Papers: JSON.parse(JSON.stringify(this.papers)), + TaskID: this.TaskID, + ORG_ID: this.ORG_ID, + TEXT_ID: this.EDIT_ID, //this.props.data.id + } + getRequest(data, "/SE/SETrainRecord/SavePapers").then(res => { + if (res && res.IsOperateSuccessful) { + var icon = 'success' + var duration = 1000 + if (!res.IsPass) { + icon = 'error' + duration = 2000 + } + uni.$showMsgFunc(res.Msg, () => { + uni.navigateBack() + }, icon, duration) + } + }) + } else { + this.indexCour++ + //下一题 + if (this.indexCour == this.listPath.length - 1) { + this.btnText = '提交' //最后一题 + } else { + this.btnText = '下一题' + } + this.filepath = this.listPath[this.indexCour] + this.perPaper = this.papers.filter(e => e.FILE_PATH == this.filepath) + + if (this.filepath.indexOf('/VIDEO/') > -1) { + this.isViedo = true + this.isViedoEnd = false + this.filepath = config.uni_app_web_video_source_url + this.filepath + this.filepathf = [] + } else if (this.filepath.indexOf('.mp4') > -1 || this.filepath + .indexOf('.avi') > -1) { + //暂时不应该进来 + this.isViedo = true + this.isViedoEnd = false + this.filepath = config.uni_app_web_source_url + this.filepath + this.filepathf = [] + } else { + this.isViedo = false + this.isViedoEnd = true + this.filepath = this.filepath + this.filepathf = getFileShow(this.filepath) + } + } }, onTimeUpdate(e) { const currentTime = e.detail.currentTime; @@ -485,7 +525,7 @@ }, //播放结束 onEnd() { - this.isVodeoEnd = true + this.isViedoEnd = true }, } } diff --git a/utils/common.js b/utils/common.js index 59e75dd..74a658b 100644 --- a/utils/common.js +++ b/utils/common.js @@ -2088,4 +2088,35 @@ export function getArryPropShow(arry, propPath, htmlPerAdd) { }); } return arryShow; +} + +//位掩码 获取选项 +export function getSelectedOptions(answer, maxOption = 32) { + const selected = []; + let value = 1; // 从 2^0 = 1 开始 + + // 遍历所有可能的选项(直到超过 answer 或达到上限) + while (value <= answer && value <= maxOption) { + if ((answer & value) !== 0) { + selected.push(value); + } + value *= 2; // 下一个 2 的幂:1 → 2 → 4 → 8 ... + } + return selected; +} +//适应 组件 对附件的显示 +export function getFileShow(FILE_PATH, FILE_NAME) { + const result = [] + if (!FILE_NAME) { + var listPath = FILE_PATH.split('/') + FILE_NAME = listPath[listPath.length - 1] + } + result.push({ + Nav_ImgFile: { + FILE_PATH: FILE_PATH, + FILE_NAME: FILE_NAME, + } + }) + return result; + } \ No newline at end of file