1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129 |
- $(function () {
- layui.use(['layer', 'form', 'table'], function () {
- var layer = layui.layer
- , form = layui.form;
- form.render('select');
- });
- let baseIdx = 0;
- /**
- *模板轮播切换
- **/
- $('.modules-box .btnItem').click(function () {
- let $tplListEl = $('.modules-box .tplList');
- let listW = $tplListEl.width();
- let curLeft = Math.abs($tplListEl.position().left);
- let curTpBoxW = $('.modules-box .tplCut').width();
- let baseW = $('.modules-box .tplItem').eq(0).width() + 10;
- if ($(this).hasClass('leftBtn')) {
- if (baseIdx == 0) {
- return
- }
- baseIdx--
- } else if ($(this).hasClass('rightBtn')) {
- if (curLeft + curTpBoxW == listW || curLeft + curTpBoxW > listW) {
- return
- }
- baseIdx++
- }
- $tplListEl.animate({ left: -(baseIdx * baseW) }, 100)
- })
- /**
- *切换答题卡列表
- **/
- $('body').on('change', 'input[name="cardUse"]', function (e) {
- let idx = $('input[name="cardUse"]:checked').closest('tr').index()
- cardListData.changeCardFun(cardListData.cardListData[idx].multiplex_id);
- })
- /**
- *预览编辑模板
- **/
- $('body').on('click', '.menu', function (e) {
- e.stopPropagation()
- $(this).children('.triangle').css('display', 'flex')
- $(this).children('.menuList').css('display', 'flex')
- })
- $(document).click(function () {
- $('.menu').children('.triangle').css('display', 'none')
- $('.menu').children('.menuList').css('display', 'none')
- })
- /**
- *创建答题卡模板
- **/
- $('body').on('click', '#goAnswerSheet', function (e) {
- let url = cardListData.useCardTool(cardListData.examGroupId)
- if (this.item_collect) {
- window.location.href = `${url}/mixSubjects.html?examGroupId=${cardListData.examGroupId}`
- } else {
- window.location.href = `${url}?isEdit=0&cardType=0&examGroupId=${cardListData.examGroupId}`
- }
- // window.location.href= '/index.php/online/answersheet?isEdit=0&cardType=0&examGroupId='+cardListData.examGroupId;
- })
- /**
- *编辑模板
- **/
- $('body').on('click', '.setEditCard', function (e) {
- if (cardListData.assist_status == 1 || cardListData.assist_status == 2) {
- var that = this;
- layer.tips('后台操作员未完成任务,暂不支持编辑!', that, { tips: [3, '#787878'] });
- } else {
- let idx = $(this).closest('tr').index()
- // 非复用&已上传试卷考试,需要弹层提示
- if (cardListData.isDownLoad == 0 && cardListData.isThird == 1 && cardListData.isUploadPaper == 1) {
- layer.open({
- title: '提示',
- content: '试卷已上传,如更改试题结构,需重新上传试卷,请确认!',
- btn: ['确认', '取消'],
- yes: function (index, layero) {
- cardListData.getCurPositionData(cardListData.cardListData[idx].multiplex_id, 5, cardListData.cardListData[idx].is_copy)
- layer.close(index);
- }
- });
- } else {
- cardListData.getCurPositionData(cardListData.cardListData[idx].multiplex_id, 5, cardListData.cardListData[idx].is_copy)
- }
- }
- })
- /**
- *下载模板
- **/
- $('body').on('click', '.setDownloadCard', function (e) {
- if (cardListData.assist_status == 1 || cardListData.assist_status == 2) {
- var that = this;
- layer.tips('后台操作员未完成任务,暂不支持下载!', that, { tips: [3, '#787878'] });
- } else {
- let idx = $(this).closest('tr').index()
- if (cardListData.isDownLoad == 0 && cardListData.isThird == 1) {
- // 未被下载过的答题卡首次下载,需要弹层提示
- layer.open({
- title: '提示',
- content: '下载后答题卡结构不能调整,是否下载答题卡?',
- btn: ['确认下载', '取消'],
- yes: function (index, layero) {
- cardListData.getCurPositionData(cardListData.cardListData[idx].multiplex_id, 2)
- layer.close(index);
- }
- });
- } else {
- cardListData.getCurPositionData(cardListData.cardListData[idx].multiplex_id, 2)
- }
- }
- })
- /**
- * 打印
- */
- $('body').on('click', '.handlerPrintPdf', function (e) {
- let idx = $(this).closest('tr').index()
- if (cardListData.assist_status == 1 || cardListData.assist_status == 2) {
- var that = this;
- layer.tips('后台操作员未完成任务,暂不支持打印!', that, { tips: [3, '#787878'] });
- } else {
- evaluationClient.BulkPrintPDF(JSON.stringify(cardListData.printParams));
- cardListData.downloadCardFun(cardListData.cardListData[idx].multiplex_id);
- }
- })
- /**
- *查看模板
- **/
- $('body').on('click', '.setPreviewCard', function (e) {
- let idx = $(this).closest('tr').index()
- cardListData.getCurPositionData(cardListData.cardListData[idx].multiplex_id, 4)
- })
- /**
- *复用模板:当前存在可编辑模板时不能复用模板
- **/
- $('body').on('click', '.setReuseCard', function (e) {
- let idx = $(this).closest('tr').index()
- let defaultName = cardListData.cardListData[idx].name;
- let id = cardListData.cardListData[idx].multiplex_id;
- // cardListData.cardListData[idx].multiplex_id
- let hasEditItem = cardListData.cardListData.filter(v => v.is_download == 0).length > 0;
- if (hasEditItem) {
- layer.msg('当前有可编辑答题卡,不允许复用!')
- return;
- }
- layer.open({
- title: '答题卡名称',
- area: ['400px', '250px'],
- content: '答题卡名称:<input type="text" placeholder="请输入答题卡名称" value="' + defaultName + '" maxlength="20" class="layui-input" id="newCardName"><span id="cardErr"></span>'
- , btn: ['确定', '取消']
- , yes: function (index, layero) {
- let curName = $('#newCardName').val().trim();
- if (curName == '') {
- $('#cardErr').html('请输入答题卡名称!')
- } else if (cardListData.cardListData.filter(val => val.name == curName).length > 0) {
- $('#cardErr').html('答题卡名称已存在!')
- } else {
- $('#cardErr').html('')
- cardListData.setReuseCard({
- multiplexId: id,
- name: curName
- })
- layer.close(index);
- }
- return false
- }
- });
- })
- /**
- *隐藏答题卡
- **/
- $('body').on('click', '.setHideCard', function (e) {
- let idx = $(this).closest('tr').index();
- let id = cardListData.cardListData[idx].multiplex_id;
- if ($(this).closest('tr').find('.card-use').is(':checked')) {
- layer.msg('当前应用模板不能隐藏!')
- return
- }
- cardListData.setHideCard(id, cardListData.isHideList == 0 ? 1 : 0);
- })
- /**
- *保存为我的模板
- **/
- $('body').on('click', '.setSaveTpl', function (e) {
- let idx = $(this).closest('tr').index();
- cardListData.saveAsMyTpl(idx);
- })
- /**
- *显示隐藏答题卡列表
- **/
- $('body').on('change', '.show-all', function (e) {
- cardListData.isHideList = $(this).is(':checked') ? 1 : 0;
- cardListData.getCardList();
- })
- /**
- *使用、预览、删除 模板
- **/
- $('body').on('click', '.menuList span', function (e) {
- let idx = $(this).closest('.tplItem').index();
- //存数据
- let tplData = JSON.parse(cardListData.tplList[idx].tpl_data);
- let tplTestFormData = JSON.parse(localStorage.getItem('testFormData')) || {};
- tplData.examGroupId = tplTestFormData.examGroupId;
- // 没有下载答题卡&答题卡列表长度>1时, 拼接multiplexId
- let str = '';
- if ($('input[data-active="1"]').length > 0) {
- let cardIdx = $('input[data-active="1"]').closest('tr').index();
- let id = cardListData.cardListData[cardIdx].multiplex_id;
- str = '&multiplexId=' + id
- }
- if ($(e.target).hasClass('use')) {
- // 使用:当前存在答题卡列表,传入当前应用的multiplex_id
- if ($('.create-card').is(':hidden') && cardListData.isUploadPaper == 1) {
- //已创建过答题卡&已创建过试卷,需要弹层提示
- layer.open({
- title: '提示',
- content: '试卷已上传,如更改试题结构,需重新上传试卷,请确认!',
- btn: ['确认', '取消'],
- yes: function (index, layero) {
- let url = cardListData.useCardTool(tplTestFormData.examGroupId);
- window.location.href = `${url}?examGroupId=${tplTestFormData.examGroupId}&isEdit=0&isCopy=0&cardType=0${str}`;
- layer.close(index);
- // tplData.position.isUseTemp = true;
- // localStorage.setItem('savePrintInfo',JSON.stringify(tplData));
- // window.location.href= '/index.php/online/answersheet?examGroupId='+tplTestFormData.examGroupId+'&isEdit=0&isCopy=0&cardType=0'+str;
- // layer.close(index);
- }
- });
- } else {
- let url = cardListData.useCardTool(tplTestFormData.examGroupId);
- window.location.href = `${url}?examGroupId=${tplTestFormData.examGroupId}&isEdit=0&isCopy=0&cardType=0${str}&tplId=${cardListData.tplList[idx].third_tpl_id}`;
- // tplData.position.isUseTemp = true;
- // localStorage.setItem('savePrintInfo',JSON.stringify(tplData));
- // window.location.href= '/index.php/online/answersheet?examGroupId='+tplTestFormData.examGroupId+'&isEdit=0&isCopy=0&cardType=0'+str;
- }
- } else if ($(e.target).hasClass('preview')) {
- // 预览
- let url = cardListData.useCardTool(tplTestFormData.examGroupId);
- window.location.href = `${url}?examGroupId=${tplTestFormData.examGroupId}&isEdit=1&isPreview=1&isCopy=0&cardType=0${str}&tplId=${cardListData.tplList[idx].third_tpl_id}`;
- // window.location.href= `${url}?examGroupId=${tplTestFormData.examGroupId}&isEdit=1&isPreview=1&isCopy=0&cardType=0${str}`;
- // localStorage.setItem('savePrintInfo',JSON.stringify(tplData));
- // window.location.href= '/index.php/online/answersheet?examGroupId='+tplTestFormData.examGroupId+'&isEdit=1&isPreview=1&isCopy=0&cardType=0'+str;
- } else if ($(e.target).hasClass('del')) {
- // 删除
- let _this = $(this);
- $.post(cardListData.api.delTpl, { third_tpl_id: cardListData.tplList[idx].third_tpl_id }, function (res) {
- var result = JSON.parse(res);
- if (result.success === 1) {
- _this.closest('.tplItem').remove()
- $('#tplLength').text($('.tplItem').length)
- if ($('.tplItem').length > 0) {
- $('#tplListMsg').hide()
- } else {
- $('#tplListMsg').show()
- }
- }
- })
- }
- // cardListData.saveAsMyTpl(idx);
- })
- // 题目审查
- $('body').on('click', '#examine', function (e) {
- let position = JSON.parse(cardListData.curCardTplData.position)
- let topicListObject = Object.values(position.topicListObject)
- const subjectName = { 12: "物理", 13: '化学', 14: '生物', 15: '政治', 16: '历史', 17: '地理' }
- // 大题循环
- let splitLis = []
- for (let index = 0; index < topicListObject.length; index++) {
- let json = { name: topicListObject[index].questionTitleVal, groups: {} }
- // 找出学科相同组
- for (let ind = 0; ind < topicListObject[index].quesNoArr.length; ind++) {
- const element = topicListObject[index].quesNoArr[ind];
- let subject = element.subject;
- if (json.groups[subject] === undefined) {
- json.groups[subject] = [element];
- } else {
- // 判断下一个是不是跟前一个连贯的
- if (element.start - 1 == json.groups[subject].slice(-1)[0].end - 0 && json.groups[subject].slice(-1)[0].subject == element.subject) {
- json.groups[subject][json.groups[subject].length - 1].end = element.end
- } else {
- json.groups[subject].push(element);
- }
- }
- }
- // // 存储的小题
- // let questions = topicListObject[index].questions
- // const result = questions.reduce((acc, cur) => {
- // const index = acc.findIndex(item => item.name === cur.subject);
- // if (index === -1) {
- // acc.push({ name: cur.subject, alias: [String(cur.alias)] });
- // } else {
- // const lastAlias = acc[index].alias[acc[index].alias.length - 1];
- // if (lastAlias && lastAlias.split("-")[1] === String(cur.alias - 1)) {
- // acc[index].alias[acc[index].alias.length - 1] = `${lastAlias.split("-")[0]}-${cur.alias}`;
- // } else {
- // acc[index].alias.push(String(cur.alias));
- // }
- // }
- // return acc;
- // }, []);
- // json.list = result
- splitLis.push(json)
- }
- let html = '<div style="padding:20px"><div class="layui-row">'
- for (let index = 0; index < splitLis.length; index++) {
- html += `<div class="layui-col-md2">${splitLis[index].name}</div>`
- let str = '';
- const element = splitLis[index];
- Object.keys(element.groups).forEach((keys, i) => {
- const list = element.groups[keys];
- str += `<p>${subjectName[keys]} `
- for (let index = 0; index < list.length; index++) {
- if (list[index].start != list[index].end) {
- str += (list[index].start + "~" + list[index].end) + (list.length > 1 && index < list.length - 1 ? ',' : '')
- } else {
- str += list[index].start + (list.length > 1 && index < list.length - 1 ? ',' : '');
- }
- }
- str += `</p>`
- });
- html += `<div class="layui-col-md10">
- ${str}
-
-
-
-
- </div>`
- }
- html += '</div></div>'
- //墨绿深蓝风
- layer.open({
- type: 1,
- area: ['500px', '300px'],
- title: '学科试题',
- skin: 'layui-layer-examine', //样式类名
- closeBtn: 1, //不显示关闭按钮
- shadeClose: true, //开启遮罩关闭
- anim: 2,
- content: html
- });
- })
- cardListData.init();
- })
- function tplNameReplace (num) {
- var str = num.value;
- var value = str.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\.]/g, '');
- num.value = value;
- }
- var locationUrl = window.location.href.substring(0, window.location.href.indexOf('/index.php'));
- var baseLocalUrl = locationUrl
- let loginStatus = ''
- if (!locationUrl.includes('xbas2')) {
- baseLocalUrl = 'http://xbas2.testing.xiaoben.com';
- loginStatus = '/username/zhangxiuxiu/time/1681456191/sig/1ed6d280e52136f2304dba7a1c10c3c9/sessionid/session_456132ef87c57a8db843b7157feb9eaa'//秀秀
- }
- // window.baseUrl = 'http://zsyas2.dev.xueping.com/index.php/vue/';
- let apiBaseUrl = baseLocalUrl + '/index.php';
- window.baseUrl = baseLocalUrl + '/answersheet/';
- var cardListData = {
- item_collect: false,//是否全学科答题卡
- item_collectData: [],//是否全学科答题卡
- printParams: {},
- examGroupId: '',
- isThird: 0,
- isHideList: 0,//1显示隐藏列表,0不显示
- cardListData: [],//答题卡列表
- tplList: [],//模板列表
- curCardTplData: {},//当前模板详细信息
- isDownLoad: 0,//当前考试是否下载/生成过
- isUploadPaper: 0,//当前试卷是否已上传
- api: {
- getList: baseLocalUrl + '/index.php/third/getTemplateByExamGroupId' + loginStatus,//获取答题卡列表
- changeCard: baseLocalUrl + '/index.php/third/changeCard' + loginStatus,
- getOnlinePdf: baseLocalUrl + '/index.php/printTools/getOnlinePdf' + loginStatus,
- downloadCard: baseLocalUrl + '/index.php/third/downloadStatus' + loginStatus,
- // downFileApi:baseLocalUrl+'/third/download'+loginStatus,
- reuseCardApi: baseLocalUrl + '/third/multiplex' + loginStatus,
- getMyTplList: baseLocalUrl + '/third/tplList' + loginStatus,
- hideCard: baseLocalUrl + '/third/hideAnswerCard' + loginStatus,
- saveTpl: baseLocalUrl + '/third/saveTemplateByOnline' + loginStatus,
- delTpl: baseLocalUrl + '/third/delTpl' + loginStatus,
- getCurPosition: baseLocalUrl + '/third/getMultiplex' + loginStatus,
- GetOnlineToken: baseLocalUrl + '/print/GetOnlineToken' + loginStatus,
- },
- init () {
- if (this.searchToObject().isThird == 1) {
- // 第三方
- this.isThird = 1;
- this.examGroupId = JSON.parse(localStorage.getItem('testFormData')).examGroupId
- } else {
- //知心慧学
- this.isThird = 0;
- this.examGroupId = this.searchToObject().examGroupId
- }
- this.getCardList();
- },
- getCardList () {
- // 获取答题卡列表
- let that = this;
- $.ajax({
- url: that.api.getList,
- method: 'POST',
- data: {
- examGroupId: this.examGroupId,
- isHide: this.isHideList
- },
- success: function (data) {
- that.item_collect = JSON.parse(data).item_collect ? true : false;
- if (that.item_collect) {
- that.item_collectData = JSON.parse(data).item_collect;
- }
- if (JSON.parse(data).success === 1) {
- // let list = JSON.parse(data).multiplex;
- // let carData = JSON.parse(data)
- that.cardListData = JSON.parse(data).multiplex || [];
- that.isOnlinePrint = JSON.parse(data).isOnlinePrint;
- cardListData.assist_status = JSON.parse(data).data && JSON.parse(data).data.assist_status
- //当前考试是否被下载过
- that.isDownLoad = JSON.parse(data).data && JSON.parse(data).data.is_download;
- that.isUploadPaper = JSON.parse(data).data && JSON.parse(data).data.paper_uploaded;
- that.getOnlinePdf()
- $('#cardListLength').html(that.cardListData.length);
- if (that.cardListData.length == 0 && that.isHideList == 0) {
- $('.create-card').show();
- $('.cardinfo-box,#tplListModule').hide();
- } else {
- $('.create-card').hide();
- $('.cardinfo-box,#tplListModule').show();
- }
- if ((that.isDownLoad == 0 || !that.isDownLoad) && that.isHideList == 0) {
- that.getMyTpl();
- $('#myModule').show();
- } else {
- $('#myModule').hide();
- }
- let html = '';
- that.cardListData.forEach((val, idx) => {
- // 创建列表
- html += '<tr>\
- <td>'+ val.name + '</td>\
- <td>'+ that.timestampToTime(val.update_time) + '</td>\
- <td><input type="radio" name="cardUse" class="card-use" data-active="'+ val.active + '">应用</td>\
- <td>';
- if (that.isHideList == 0) {
- if (val.is_download == 0) {
- html += '<a href="javascript:;" class="setEditCard">编辑</a>'
- } else {
- html += '<a href="javascript:;" class="setPreviewCard">查看</a>\
- <a href="javascript:;" class="setReuseCard">复用</a>'
- }
- if (val.is_qrcode_online != 1) { // 没有二维码
- html += '<a href="#" class="setDownloadCard">下载</a>'
- if ((typeof evaluationClient != "undefined") && ('BulkPrintPDF' in evaluationClient)) {
- html += '<a href="#" class="handlerPrintPdf">打印</a>'
- }
- }
- if (that.isThird == 1) {
- html += '<a href="#" class="setSaveTpl">保存为我的模板</a>'
- }
- }
- if (val.is_download != 0) {
- html += '<a href="#" class="setHideCard">' + (that.isHideList == 1 ? '显示' : '隐藏') + '</a>'
- }
- html += '</td>\
- </tr>';
- if (val.active == 1) {
- that.getCurPositionData(val.multiplex_id, 1)
- }
- })
- $('#cardListTable tbody').html(html)
- $('#cardListTable tbody input[data-active="1"]').prop('checked', true)
- if (that.isHideList) {
- $('.card-use').prop('disabled', true)
- }
- } else {
- if (JSON.parse(data).message) {
- layer.msg(JSON.parse(data).message);
- }
- }
- }
- })
- },
- getOnlinePdf () {
- let that = this;
- $.ajax({
- url: this.api.getOnlinePdf,
- method: 'POST',
- data: {
- examGroupId: cardListData.examGroupId
- },
- success: function (data) {
- if (JSON.parse(data).success === 1) {
- cardListData.printParams = JSON.parse(data).data
- if (!('studentIds' in cardListData.printParams.params)) {
- cardListData.printParams.params.studentIds = []
- }
- }
- }
- })
- },
- changeCardFun (id) {
- let that = this;
- $.ajax({
- url: this.api.changeCard,
- method: 'POST',
- data: {
- multiplexId: id
- },
- success: function (data) {
- layer.msg(JSON.parse(data).msg)
- that.getCurPositionData(id, 1)
- }
- })
- },
- downloadCardFun (id) {
- let that = this;
- $.ajax({
- url: this.api.downloadCard,
- method: 'POST',
- data: {
- multiplexId: id
- },
- success: function (data) {
- that.getCardList()
- }
- })
- },
- getCurPositionData (id, type, tplTitle, positionTxt) {
- // type:1应用 2下载 3 保存我的模板 4查看 5编辑
- // tplTitle 保存模板title||编辑isCopy
- // positionTxt 存储position对应txt文件
- let that = this;
- $.ajax({
- url: this.api.getCurPosition,
- method: 'POST',
- data: {
- multiplexId: id
- },
- success: function (data) {
- if (JSON.parse(data).status == 0) {
- let positionData = JSON.parse(data).data;
- if (type == 1) {
- that.curCardTplData = positionData;
- that.createCurCard();
- } else if (type == 2) {
- that.downloadCardFun(id);
- location.href = baseLocalUrl + '/third/download?url=' + positionData.online_card_pdf + '&title=' + positionData.name
- } else if (type == 3) {
- let position = JSON.parse(positionData.position)
- total_score = position.totalScore;
- total_topics = that.calcTotalScore(position.topicListObject).count;
- $.ajax({
- url: that.api.saveTpl,
- method: 'POST',
- data: {
- title: tplTitle,
- total_score,
- total_topics,
- tpl_data: positionTxt
- },
- success: function (saveData) {
- if (JSON.parse(saveData).success === 1) {
- layer.msg('保存答题卡成功');
- that.getMyTpl();
- } else {
- layer.msg(JSON.parse(saveData).message);
- }
- }
- })
- } else if (type == 4) {
- let cardType = that.isThird == 0 ? 1 : 0
- let url = that.useCardTool(cardListData.examGroupId)
- // 无Token信息 跳转本地
- if (that.item_collect) {
- if(positionData.new_answer_sheet_subject==1){
- window.location.href = `${url}/subjects13.html?examGroupId=${cardListData.examGroupId}&isPreview=1&multiplexId=${positionData.multiplex_id}`
- }else{
- window.location.href = `${url}/mixSubjects.html?examGroupId=${cardListData.examGroupId}&isPreview=1&multiplexId=${positionData.multiplex_id}`
- }
- } else {
- window.location.href = `${url}?examGroupId=${cardListData.examGroupId}&isEdit=1&isPreview=1&cardType=${cardType}&multiplexId=${positionData.multiplex_id}`
- }
- // window.location.href= `${url}?examGroupId=${cardListData.examGroupId}&isEdit=1&isPreview=1&cardType=${cardType}&multiplexId=${positionData.multiplex_id}`
- // if(cardListData.isThird == 1){
- // localStorage.setItem('savePrintInfo',JSON.stringify(positionData))
- // }
- // window.location.href= '/index.php/online/answersheet?examGroupId='+cardListData.examGroupId+'&&isEdit=1&isPreview=1&cardType='+cardType+'&multiplexId='+positionData.multiplex_id;
- } else if (type == 5) {
- let cardType = cardListData.isThird == 0 ? 1 : 0
- let url = that.useCardTool(cardListData.examGroupId)
- if (that.item_collect) {
- if(positionData.new_answer_sheet_subject==1){
- window.location.href = `${url}/subjects13.html?examGroupId=${cardListData.examGroupId}&multiplexId=${positionData.multiplex_id}&isCopy=${tplTitle}`
- }else{
- window.location.href = `${url}/mixSubjects.html?examGroupId=${cardListData.examGroupId}&multiplexId=${positionData.multiplex_id}&isCopy=${tplTitle}`
- }
- } else {
- window.location.href = `${url}?examGroupId=${cardListData.examGroupId}&isEdit=1&cardType=${cardType}&multiplexId=${positionData.multiplex_id}&isCopy=${tplTitle}`
- }
- // window.location.href= `${url}?examGroupId=${cardListData.examGroupId}&isEdit=1&cardType=${cardType}&multiplexId=${positionData.multiplex_id}&isCopy=${tplTitle}`
- // if(cardListData.isThird == 1){
- // localStorage.setItem('savePrintInfo',JSON.stringify(positionData))
- // }
- // window.location.href= '/index.php/online/answersheet?examGroupId='+cardListData.examGroupId+'&isEdit=1&cardType='+cardType+'&multiplexId='+positionData.multiplex_id+'&isCopy='+tplTitle;
- }
- }
- }
- })
- },
- useCardTool (examGroupId) {
- let item_collect = this.item_collect;
- let url = 'http://xbcard.testing.xiaoben.com'
- if (window.location.href.includes('dev.xiaoben.com')) {
- url = 'http://xbcard.dev.xiaoben.com'
- } else if (window.location.href.includes('schcur.com')) {
- url = 'http://xbcard.schcur.com'
- }
- // let token='731768365816463360'
- $.ajax({
- url: cardListData.api.GetOnlineToken,
- type: 'POST',
- dataType: 'json',
- async: false,
- success: function (res) {
- if (res.status == 1 && res.data != undefined) {
- let token = res.data;
- $.cookie('cardToken', null, { path: '/', domain: url.substring(url.indexOf('card.') + 4) });
- $.cookie("cardToken", token, { path: '/', expires: 1, domain: url.substring(url.indexOf('card.') + 4) });
- // if(item_collect){
- // window.location.href=`${url}mixSubjects.html?examGroupId=${examGroupId}&cardType=1`;
- // } else {
- // window.location.href=`${url}?examGroupId=${examGroupId}&cardType=1`;
- // }
- } else {
- if (res.msg != undefined) {
- layer.msg(res.msg)
- } else {
- layer.msg('token读取失败');
- }
- }
- }
- });
- return url;
- },
- createCurCard () {
- let data = this.curCardTplData;
- let collectData = this.item_collectData;
- $('.card-name').html(data.name)
- $('.card-time').html(this.timestampToTime(data.update_time))
- let position = JSON.parse(data.position);
- // 版式
- $('#cardType').html(this.getCardInfo(position).cardTypeHtml)
- // 考号
- $('#codeType').html(this.getCardInfo(position).codeTypeHtml)
- // 装订线
- $('#lineType').html(position.cardSetting.hasBindingLine == 1 ? '有' : '无')
- let topicListHtml = '';
- // 题目信息
- if (this.item_collect) {
- let totalScore = 0;
- let totalCount = 0;
- collectData.forEach((it, ind) => {
- totalCount += it.topic_count == '2选1' ? 1 : it.topic_count;
- totalScore += it.total_score;
- topicListHtml += '<li class="clearfix">\
- <div class="fl">'
- topicListHtml += this.numberConvert(ind + 1) + '、' + it.topic_type_name
- topicListHtml += '</div>\
- <div class="fl">'+ it.topic_basic_name + '</div>\
- <div class="fl">'+ it.topic_count + '题</div>\
- <div class="fl">共'+ it.total_score + '分</div>\
- </li>'
- })
- $('#totalScore').html(totalScore)
- $('#totalCount').html(totalCount)
- $('#cardTopicInfo').html(topicListHtml)
- } else {
- for (let topicType in position.topicListObject) {
- let curTopicItem = position.topicListObject[topicType];
- if (!curTopicItem.isQuestionText) {
- topicListHtml += '<li class="clearfix">\
- <div class="fl">'
- if (this.isThird == 1) {
- topicListHtml += curTopicItem.questionTitleReadonly
- } else {
- topicListHtml += curTopicItem.bigTopicNum + '、' + PaperAndTopicConfig.topicTypeObj[curTopicItem.questionCreateTypeId] + '题'
- }
- topicListHtml += '</div>\
- <div class="fl">'+ PaperAndTopicConfig.topicTypeObj[curTopicItem.questionCreateTypeId] + '</div>\
- <div class="fl">'+ this.calcQuestionsLen(position.topicListObject, topicType).count + '题</div>\
- <div class="fl">共'+ this.calcQuestionsLen(position.topicListObject, topicType).score + '分</div>\
- </li>'
- }
- };
- $('#totalScore').html(this.calcTotalScore(position.topicListObject).score)
- $('#totalCount').html(this.calcTotalScore(position.topicListObject).count)
- $('#cardTopicInfo').html(topicListHtml)
- }
- if ('batchSettings' in position.cardSetting && position.cardSetting.batchSettings) {
- $('#examine').show()
- }
- },
- getCardInfo (position) {
- // 版式、考号
- let codeTypeHtml = '';
- if (position.useQrCode == 1) {
- codeTypeHtml = '系统二维码'
- } else {
- position.cardSetting.examinationNumberType.forEach((val, idx) => {
- if (idx > 0) {
- codeTypeHtml += '、';
- }
- if (val == 1) {
- codeTypeHtml += '填涂考号'
- } else {
- codeTypeHtml += '条形码'
- }
- });
- }
- let cardTypeHtml = '';
- cardTypeHtml += position.paper;
- cardTypeHtml += position.cardSetting.direction == 2 ? '-竖版-' : '-横版-';
- cardTypeHtml += utilsJs.sectionToChinese(position.cardSetting.column) + '栏'
- return {
- codeTypeHtml,
- cardTypeHtml,
- }
- },
- getMyTpl () {
- // 获取我的模板
- let that = this;
- $.ajax({
- url: this.api.getMyTplList,
- method: 'GET',
- data: {},
- success: function (res) {
- let result = JSON.parse(res);
- if (result.success === 1 && result.thisTpls) {
- that.tplList = [];
- jQuery.each(result.thisTpls, function (i, item) {
- let tpl_data = JSON.parse(item.tpl_data)
- let num = parseInt(tpl_data.online_card_version && tpl_data.online_card_version.replace('.', '').replace('.', ''))
- if (num >= 310) {
- that.tplList.push(item)
- }
- })
- if (that.tplList.length > 0) {
- $('#tplListMsg').hide();
- } else {
- $('#tplListMsg').show()
- }
- $('#tplLength').html(that.tplList.length)
- that.renderTplList(that.tplList)
- }
- }
- })
- },
- renderTplList (tplList) {
- let html = ''
- tplList.forEach(value => {
- let val = JSON.parse(value.tpl_data)
- html += '<div class="tplItem">\
- <div class="top itemModule">\
- <h3>\
- <strong>'+ value.title + '</strong>\
- <div class="menu">\
- <strong><b></b><b></b><b></b></strong>\
- <i class="triangle" style="display: none;"></i>\
- <div class="menuList" style="display: none;">\
- <span class="use" data-id="65">使用</span>\
- <span class="preview" data-id="65">预览</span>\
- <span class="del" data-id="65">删除</span>\
- </div>\
- </div>\
- </h3>\
- <span>总分:'+ value.total_score + '分</span>\
- <span>题量:'+ value.total_topics + '小题</span>\
- </div>\
- <div class="bottom itemModule">\
- <h3>其他信息</h3>\
- <span>版式:'+ this.getCardInfo(val).cardTypeHtml + '</span>\
- <span>考号:'+ this.getCardInfo(val).codeTypeHtml + '</span>\
- </div>\
- </div>'
- })
- $('.tplList').html(html)
- },
- setReuseCard (data) {
- // 复用答题卡
- let that = this;
- $.ajax({
- url: this.api.reuseCardApi,
- method: 'POST',
- data: data,
- success: function (data) {
- if (JSON.parse(data).status == 1) {
- layer.msg(JSON.parse(data).msg);
- that.getCardList()
- } else {
- layer.msg(JSON.parse(data).msg);
- }
- }
- })
- },
- setHideCard (id, isHide) {
- // 隐藏答题卡
- let that = this;
- $.ajax({
- url: this.api.hideCard,
- method: 'POST',
- data: {
- multiplexId: id,
- isHide: isHide
- },
- success: function (data) {
- if (JSON.parse(data).status == 1) {
- layer.msg('设置成功');
- that.getCardList()
- } else {
- layer.msg(JSON.parse(data).msg);
- }
- }
- })
- },
- saveAsMyTpl (idx) {
- // 保存为我的模板
- let that = this;
- layer.open({
- title: '保存模板',
- area: ['350px', '200px'],
- content: '模板名称:<input type="text" placeholder="请输入模板名称" maxlength="20" class="layui-input" id="tplName" onkeyup="tplNameReplace(this)">'
- , btn: ['确定', '取消']
- , yes: function (index, layero) {
- tplTitle = $('#tplName').val();
- $('.hgc_inputItem .error')[tplTitle ? 'hide' : 'show']()
- if (tplTitle) {
- that.getCurPositionData(that.cardListData[idx].multiplex_id, 3, tplTitle, that.cardListData[idx].position)
- }
- layer.close(index);
- }
- });
- },
- calcQuestionsLen: function (buildQuestions, modelId) {
- let count = 0, score = 0;
- // for(let modelId in buildQuestions){
- if (buildQuestions[modelId].questionCreateTypeId == 17) {
- count = buildQuestions[modelId].questions[0].total + '选' + buildQuestions[modelId].questions[0].required;
- let tempTpLen = 0;
- buildQuestions[modelId].questions.forEach((val, i) => {
- if (val.smTopicLen === undefined && tempTpLen < buildQuestions[modelId].questions[0].required) {
- // 不是小题 && 并且不能超过选择个数
- tempTpLen++;
- score += parseFloat(buildQuestions[modelId].questions[i].fullScore)
- } else if (i < val.smTopicLen) {
- score += parseFloat(val.fullScore)
- }
- });
- //
- } else {
- buildQuestions[modelId].questions.forEach(function (val, index) {
- if (val) {
- score += parseFloat(val.fullScore)
- if (!val.smallQtNo) {
- count++;
- }
- } else {
- buildQuestions[modelId].questions.splice(index, 1)
- }
- })
- // count += buildQuestions[modelId].questions.length
- }
- // }
- return { count: count, score: score };
- },
- calcTotalScore: function (buildQuestions) {
- let count = 0, score = 0;
- for (let modelId in buildQuestions) {
- if (buildQuestions[modelId].questionCreateTypeId == 17) {
- count += parseFloat(buildQuestions[modelId].questions[0].required);
- let tempTpLen = 0;
- buildQuestions[modelId].questions.forEach((val, i) => {
- if (val.smTopicLen === undefined && tempTpLen < buildQuestions[modelId].questions[0].required) {
- tempTpLen++;
- score += parseFloat(buildQuestions[modelId].questions[i].fullScore)
- } else if (i < val.smTopicLen) {
- score += parseFloat(val.fullScore)
- }
- });
- // score += parseFloat(buildQuestions[modelId].questions[0].fullScore)
- } else if (!modelId.includes('Text')) {
- buildQuestions[modelId].questions.forEach(function (val, index) {
- if (val) {
- score += parseFloat(val.fullScore)
- if (!val.smallQtNo) {
- count++;
- }
- } else {
- buildQuestions[modelId].questions.splice(index, 1)
- }
- })
- // count += buildQuestions[modelId].questions.length
- }
- }
- return { count: count, score: score };
- },
- searchToObject () {
- //location.search 转成 key:value格式
- var pairs = window.location.search.substring(1).split("&"),
- obj = {},
- pair,
- i;
- for (i in pairs) {
- if (pairs[i] === "") continue;
- pair = pairs[i].split("=");
- obj[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
- }
- return obj;
- },
- timestampToTime (timestamp) {
- var date = new Date(timestamp * 1000);
- var Y = date.getFullYear() + '-';
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
- var D = date.getDate() + ' ';
- var h = date.getHours();
- var m = date.getMinutes();
- var s = date.getSeconds();
- return Y + this.addZero(M) + this.addZero(D) + this.addZero(h) + ':' + this.addZero(m) + ':' + this.addZero(s);
- },
- addZero (n) {
- return n < 10 ? '0' + n : '' + n
- },
- // numberConvert(num){
- // let chinese = '';
- // var arr = [...num.toString()];
- // for(var i=0;i<arr.length;i++){
- // switch (arr[i]) {
- // case '0': chinese += "零"; break;
- // case '1': chinese += "一" ; break;
- // case '2': chinese += "二" ; break;
- // case '3': chinese += "三" ; break;
- // case '4': chinese += "四" ; break;
- // case '5': chinese += "五" ; break;
- // case '6': chinese += "六" ; break;
- // case '7': chinese += "七" ; break;
- // case '8': chinese += "八" ; break;
- // case '9': chinese += "九" ; break;
- // }
- // }
- // return chinese;
- // }
- //阿拉伯数字转换为简写汉字
- numberConvert (Num) {
- for (i = Num.length - 1; i >= 0; i--) {
- Num = Num.replace(",", "")//替换Num中的“,”
- Num = Num.replace(" ", "")//替换Num中的空格
- }
- if (isNaN(Num)) { //验证输入的字符是否为数字
- //alert("请检查小写金额是否正确");
- return;
- }
- //字符处理完毕后开始转换,采用前后两部分分别转换
- part = String(Num).split(".");
- newchar = "";
- //小数点前进行转化
- for (i = part[0].length - 1; i >= 0; i--) {
- if (part[0].length > 10) {
- //alert("位数过大,无法计算");
- return "";
- }//若数量超过拾亿单位,提示
- tmpnewchar = ""
- perchar = part[0].charAt(i);
- switch (perchar) {
- case "0": tmpnewchar = "零" + tmpnewchar; break;
- case "1": tmpnewchar = "一" + tmpnewchar; break;
- case "2": tmpnewchar = "二" + tmpnewchar; break;
- case "3": tmpnewchar = "三" + tmpnewchar; break;
- case "4": tmpnewchar = "四" + tmpnewchar; break;
- case "5": tmpnewchar = "五" + tmpnewchar; break;
- case "6": tmpnewchar = "六" + tmpnewchar; break;
- case "7": tmpnewchar = "七" + tmpnewchar; break;
- case "8": tmpnewchar = "八" + tmpnewchar; break;
- case "9": tmpnewchar = "九" + tmpnewchar; break;
- }
- switch (part[0].length - i - 1) {
- case 0: tmpnewchar = tmpnewchar; break;
- case 1: if (perchar != 0) tmpnewchar = tmpnewchar + "十"; break;
- case 2: if (perchar != 0) tmpnewchar = tmpnewchar + "百"; break;
- case 3: if (perchar != 0) tmpnewchar = tmpnewchar + "千"; break;
- case 4: tmpnewchar = tmpnewchar + "万"; break;
- case 5: if (perchar != 0) tmpnewchar = tmpnewchar + "十"; break;
- case 6: if (perchar != 0) tmpnewchar = tmpnewchar + "百"; break;
- case 7: if (perchar != 0) tmpnewchar = tmpnewchar + "千"; break;
- case 8: tmpnewchar = tmpnewchar + "亿"; break;
- case 9: tmpnewchar = tmpnewchar + "十"; break;
- }
- newchar = tmpnewchar + newchar;
- }
- //替换所有无用汉字,直到没有此类无用的数字为止
- while (newchar.search("零零") != -1 || newchar.search("零亿") != -1 || newchar.search("亿万") != -1 || newchar.search("零万") != -1) {
- newchar = newchar.replace("零亿", "亿");
- newchar = newchar.replace("亿万", "亿");
- newchar = newchar.replace("零万", "万");
- newchar = newchar.replace("零零", "零");
- }
- //替换以“一十”开头的,为“十”
- if (newchar.indexOf("一十") == 0) {
- newchar = newchar.substr(1);
- }
- //替换以“零”结尾的,为“”
- if (newchar.lastIndexOf("零") == newchar.length - 1) {
- newchar = newchar.substr(0, newchar.length - 1);
- }
- return newchar;
- }
- }
|