Best JavaScript code snippet using jest
resultEvaluation1.js
Source:resultEvaluation1.js
1$(function() {2 // 1.åå§åTable3 var oTable = new TableInit();4 oTable.Init();5 // 2.åå§åButtonçç¹å»äºä»¶6 var oButtonInit = new ButtonInit();7 oButtonInit.Init();8});9//10var TableInit = function() {11 var oTableInit = new Object();12 // åå§åTable13 oTableInit.Init = function() {14 $('#table')15 .bootstrapTable(16 {17 url : 'findResultTable1.action', // 请æ±åå°çURLï¼*ï¼18 method : 'post', // 请æ±æ¹å¼ï¼*ï¼19 contentType : "application/x-www-form-urlencoded; charset=UTF-8",20 dataType : "json", // æ°æ®ç±»å21 toolbar : '#toolbar', // å·¥å
·æé®ç¨åªä¸ªå®¹å¨22 striped : true, // æ¯å¦æ¾ç¤ºè¡é´éè²23 cache : false, // æ¯å¦ä½¿ç¨ç¼åï¼é»è®¤ä¸ºtrueï¼æ以ä¸è¬æ
åµä¸éè¦è®¾ç½®ä¸ä¸è¿ä¸ªå±æ§ï¼*ï¼24 pagination : true, // æ¯å¦æ¾ç¤ºå页ï¼*ï¼25 sortable : true, // æ¯å¦å¯ç¨æåº26 sortOrder : "asc", // æåºæ¹å¼27 queryParamsType : 'limit',28 queryParams : oTableInit.queryParams, // ä¼ éåæ°ï¼*ï¼29 sidePagination : "server", // å页æ¹å¼ï¼client客æ·ç«¯å页ï¼serveræå¡ç«¯å页ï¼*ï¼30 pageNumber : 1, // åå§åå 载第ä¸é¡µï¼é»è®¤ç¬¬ä¸é¡µ31 pageSize : 10, // æ¯é¡µçè®°å½è¡æ°ï¼*ï¼32 pageList: [10, 20, 50], // å¯ä¾éæ©çæ¯é¡µçè¡æ°ï¼*ï¼33 search : false, // æ¯å¦æ¾ç¤ºè¡¨æ ¼æç´¢ï¼æ¤æç´¢æ¯å®¢æ·ç«¯æç´¢ï¼ä¸ä¼è¿æå¡ç«¯ï¼æ以ï¼ä¸ªäººæè§æä¹ä¸å¤§34 strictSearch : false, // å¯ç¨å
¨å¹é
æç´¢ï¼å¦å为模ç³æç´¢35 searchOnEnterKey : false, // æå车触åæç´¢æ¹æ³ï¼å¦åèªå¨è§¦åæç´¢æ¹æ³36 showColumns : true, // æ¯å¦æ¾ç¤ºææçå37 showRefresh : true, // æ¯å¦æ¾ç¤ºå·æ°æé®38 minimumCountColumns : 2, // æå°å
许çåæ°39 clickToSelect : true, // æ¯å¦å¯ç¨ç¹å»éä¸è¡40 // height: 500, //è¡é«ï¼å¦æ没æ设置heightå±æ§ï¼è¡¨æ ¼èªå¨æ ¹æ®è®°å½æ¡æ°è§å¾è¡¨æ ¼é«åº¦41 uniqueId : "", // æ¯ä¸è¡çå¯ä¸æ è¯ï¼ä¸è¬ä¸ºä¸»é®å42 showToggle : true, // æ¯å¦æ¾ç¤ºè¯¦ç»è§å¾åå表è§å¾çåæ¢æé®43 cardView : false, // æ¯å¦æ¾ç¤ºè¯¦ç»è§å¾44 detailView : false, // æ¯å¦æ¾ç¤ºç¶å表45 showExport : true, // æ¯å¦æ¾ç¤ºå¯¼åºæé®46 // exportDataType : "selected", //basic'导åºå½å页,47 // 'all'导åºå
¨é¨, 'selected'导åºéä¸é¡¹.48 buttonsAlign : "right", // æé®ä½ç½®49 // exportTypes:['excel','xlsx'], //导åºæ件类å50 exportTypes : [ 'excel' ],51 Icons : 'glyphicon-export',52 exportOptions : {53 // ignoreColumn : [ 0, 0 ], // 忽ç¥æä¸åçç´¢å¼54 fileName : 'æ°æ®å¯¼åº', // æ件å称设置55 worksheetName : 'sheet1', // è¡¨æ ¼å·¥ä½åºå称56 tableName : 'æ»ä½è¯ä»·ç»æ建议表',57 excelstyles : [ 'background-color', 'color',58 'font-size', 'font-weight' ],59 /* onMsoNumberFormat: DoOnMsoNumberFormat */60 },61 columns : [62 // {63 // //æ¯å¦æ¾ç¤ºå¤éæ¡64 // field : 'Number',65 // title : 'åºå·',66 // align: 'center',67 // width: 50,68 // formatter : function(value, row, index) {69 // //return index + 1;70 // var pageSize = $('#table').bootstrapTable('getOptions').pageSize;//éè¿è¡¨ç#id å¯ä»¥å¾å°æ¯é¡µå¤å°æ¡71 // var pageNumber = $('#table').bootstrapTable('getOptions').pageNumber;//éè¿è¡¨ç#id å¯ä»¥å¾å°å½å第å 页72 // return pageSize * (pageNumber - 1) + index + 1;//è¿åæ¯æ¡çåºå·ï¼ æ¯é¡µæ¡æ° * ï¼å½å页 - 1 ï¼+ åºå·73 // }},74 {title: 'è¯ä»·åç±»', field: 'type'},75 {title: 'è¯ä»·é¡¹ç®', field: 'project'},76 {title: 'æè§å建议', field: 'suggestResult'}77 ],78 onLoadSuccess : function(data) {79 var data = $('#table').bootstrapTable('getData', true);80 mergeTable(data,'type',1, $('#table'));//è¡å并81 // mergeTable1(data,'project',1, $('#table'));//è¡å并82 },83 onLoadError : function() {84 layer.msg("æ°æ®å 载失败ï¼");85 },86 // 注åå è½½å表çäºä»¶ã注æä¸è¿éçä¸ä¸ªåæ°ï¼87 onExpandRow : function(index, row, $detail) {88 oInit.InitSubTable(index, row, $detail);89 },90 });91 };92 //å¾å°æ¥è¯¢çåæ°93 oTableInit.queryParams = function (params) {94 var temp = { //è¿éçé®çåååæ§å¶å¨çåéåå¿
é¡»ä¸ç´ï¼è¿è¾¹æ¹å¨ï¼æ§å¶å¨ä¹éè¦æ¹æä¸æ ·ç95 pageSize: params.limit, //页é¢å¤§å°96 pageNumber : params.offset/params.limit+1, //å½å页é¢,é»è®¤æ¯ä¸é¢è®¾ç½®ç1(pageNumber)97 classId:$("#classId").val()98 };99 return temp;100 };101 return oTableInit;102};103var ButtonInit = function() {104 var oInit = new Object();105 oInit.Init = function() {106 // åå§å页é¢ä¸é¢çæé®äºä»¶107 };108 return oInit;109};110/**111 * å并åå
æ ¼112 * @param data åå§æ°æ®ï¼å¨æå¡ç«¯å®ææåºï¼113 * @param fieldName å并å±æ§å称114 * @param colspan å并å115 * @param target ç®æ è¡¨æ ¼å¯¹è±¡116 */117function mergeTable(data,fieldName,colspan,target){118 //声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å119 var sortMap = {};120 for(var i = 0 ; i < data.length ; i++){121 for(var prop in data[i]){122 if(prop == fieldName){123 var key = data[i][prop]124 if(sortMap.hasOwnProperty(key)){125 sortMap[key] = sortMap[key] * 1 + 1;126 } else {127 sortMap[key] = 1;128 }129 break;130 }131 }132 }133 for(var prop in sortMap){134 // console.log(prop,sortMap[prop])135 }136 var index = 0;137 for(var prop in sortMap){138 var count = sortMap[prop] * 1;139 $(target).bootstrapTable('mergeCells',{index:index, field:'type', colspan: colspan, rowspan: count});140 index += count;141 }142}143// function mergeTable1(data,fieldName,colspan,target){144// //声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å145// var sortMap = {};146// for(var i = 0 ; i < data.length ; i++){147// for(var prop in data[i]){148// if(prop == fieldName){149// var key = data[i][prop]150// if(sortMap.hasOwnProperty(key)){151// sortMap[key] = sortMap[key] * 1 + 1;152// } else {153// sortMap[key] = 1;154// }155// break;156// }157// }158// }159// for(var prop in sortMap){160// // console.log(prop,sortMap[prop])161// }162// var index = 0;163// for(var prop in sortMap){164// var count = sortMap[prop] * 1;165// $(target).bootstrapTable('mergeCells',{index:index, field:'project', colspan: colspan, rowspan: count});166// index += count;167// }...
pipes.js
Source:pipes.js
1const { paginatedMetaExpression, queryDateExpression, parseQueryDate, parseQuerySort } = require('./helpers');2// aggregation pipes3/**4 * pull-pipeline stage 1: matching rules5 * @param {string} collection - MongoDB collection name6 * @param {object} params - express.js param object7 * @param {object} query - express.js query object8 * @return {{$match}}9 */10const pullPipe_1_matching = (collection, params, query) => {11 const $match = params.search ? { $text: { $search: params.search } } : {};12 const _$$date = query.date ? queryDateExpression(...parseQueryDate(query.date)) : null; // tofix: query time zone problem13 if (_$$date) $match['time._created'] = _$$date;14 if (['posts', 'media', 'page'].includes(collection)) {15 $match['time._recycled'] = (params.collection && query.access === 'bin') ? { $ne: null } : { $eq: null };16 if (!params.collection) $match['state.published'] = true;17 if (!params.collection) $match['state.hidden'] = false;18 }19 return { $match };20};21/**22 * pull-pipeline stage 2: fields masking23 * @param {object} params - express.js param object24 * @return {{$project}}25 */26const pullPipe_2_masking = (params) => {27 const $project = {};28 const mask = ['content'];29 if (params.collection) mask.push('featured');30 for (let i = mask.length - 1; i > -1; i -= 1) $project[mask[i]] = 0;31 return { $project };32};33/**34 * pull-pipeline stage 3: fields sorting35 * @param {object} query - express.js query object36 * @param {object} [sort] - preset sorting configurations37 * @return {{$project}}38 */39const pullPipe_3_sorting = (query, sort = {}) => {40 const $sort = { 'state.pinned': -1, 'time._updated': -1, ...sort };41 const sortMap = new Map();42 Object.keys(query)43 .filter(key => ['sort', 'sort:a', 'sort:d'].includes(key))44 .forEach(rule => parseQuerySort(query[rule], rule).forEach(pair => sortMap.set(...pair)));45 //46 if (sortMap.has('pin')) $sort['state.pinned'] = sortMap.get('pin');47 if (sortMap.has('time')) $sort['time._updated'] = sortMap.get('time');48 if (sortMap.has('update')) $sort['time._updated'] = sortMap.get('update');49 if (sortMap.has('post')) $sort['time._created'] = sortMap.get('post');50 if (sortMap.has('author')) $sort['author.nickname'] = sortMap.get('author');51 if (sortMap.has('title')) $sort.title = sortMap.get('title');52 if (sortMap.has('category')) $sort.category = sortMap.get('category');53 if (sortMap.has('tags')) $sort.tags = sortMap.get('tags');54 if (sortMap.has('revise')) $sort._revised = sortMap.get('revise');55 return { $sort };56};57/**58 * pull-pipeline stage 4: grouping with document counting59 * @return {{$group}}60 */61const pullPipe_4_grouping = () => {62 const $group = { _id: null, count: { $sum: 1 }, list: { $push: '$$ROOT' } };63 return { $group };64};65/**66 * pull-pipeline stage 5: paginating projection67 * @param {object} query - express.js query object68 * @param {number} num - preset numbers of document per page69 * @param {object} sort - preset sorting configurations70 * @return {{$project}}71 */72const pullPipe_5_paginating = (query, num, sort) => {73 const $$meta = paginatedMetaExpression(query, num);74 const $project = {75 _id: 0,76 list: { $slice: ['$list', { $multiply: [{ $add: [$$meta.now, -1] }, $$meta.num] }, $$meta.num] },77 meta: {78 count: '$count',79 num: { $literal: $$meta.num },80 now: $$meta.now,81 end: $$meta.end,82 sort: { $literal: pullPipe_3_sorting(query, sort).$sort },83 period: { $literal: queryDateExpression(...parseQueryDate(query.date)) },84 },85 };86 return { $project };87};88// const pushPipe_1_modifying = (body) => {89// const _$$filter = { $filter: { input: '$list', as: 'doc', cond: {90// $and: [{ $in: ['$$doc._id', [ObjectId('5ab33bec53da62203f81676d')] /** body.list.map(i => ObjectId(i)) **/] } /** ,additional matcher **/]}91// }};92// const _$$map = { $map: { input: _$$filter, as: 'doc', in: { $mergeObjects: ['$$doc', body] }}};93// const $project = { list: _$$map };94// return { $project };95// };96//97//98// const pushPipe_2_splitting = () => {99// const $unwind = '$list';100// return { $unwind };101// };102//103//104// const pushPipe_3_destructuring = () => {105// const $replaceRoot = { newRoot: '$list' };106// return { $replaceRoot };107// };108//109//110// const pushPipe_4_overwriting = (collection) => {111// const $out = collection; // todo: note: <CURRENT MONGODB IS NOT SUPPORTED> current (v3.6): overwrite the whole collection (x)112// return { $out };113// };114// query-builder115/**116 * combined all pipeline stages into an Mongo aggregation query117 * @param {string} collection - MongoDB collection name118 * @param {object} params - express.js param object119 * @param {object} query - express.js query object120 * @param {number} num - preset numbers of document per page121 * @param {object} sort - preset sorting configurations122 * @return {array} - Mongo aggregation query123 */124const getAggregationQuery = (collection, params, query, num, sort/** , update **/) => {125 const pullDocuments = [126 pullPipe_1_matching(collection, params, query),127 pullPipe_2_masking(params),128 pullPipe_3_sorting(query, sort),129 pullPipe_4_grouping(),130 pullPipe_5_paginating(query, num, sort),131 ];132 // const pushDocuments = [133 // ...pullDocuments,134 // pushPipe_1_modifying(update),135 // pushPipe_2_splitting(),136 // pushPipe_3_destructuring(),137 // pushPipe_4_overwriting(collection)138 // ];139 return pullDocuments;140 // return update ? pushDocuments : pullDocuments;141};142// exports143module.exports = {144 getAggregationQuery,145};146Object.defineProperty(module.exports, Symbol.for('__TEST__'), {147 value: {148 pullPipe_1_matching,149 pullPipe_2_masking,150 pullPipe_3_sorting,151 pullPipe_4_grouping,152 pullPipe_5_paginating,153 ...module.exports,154 },...
bootstrap-table.mergecells.js
Source:bootstrap-table.mergecells.js
1<script src="~/lib/bootstrap-table/dist/extensions/export/bootstrap-table-export.js"></script>2 <script src="~/lib/tableexport.jquery.plugin/tableExport.js"></script>3 /**4 * å并è¡5 * @@param data åå§æ°æ®ï¼å¨æå¡ç«¯å®ææåºï¼6 * @@param fieldName å并å±æ§å称æ°ç»7 * @@param colspan åæ°8 * @@param target ç®æ è¡¨æ ¼å¯¹è±¡9 */10 function mergeCells(data, fieldName, colspan, target) {11 if (data.length == 0) {12 alert("ä¸è½ä¼ å
¥ç©ºæ°æ®");13 return;14 }15 var numArr = [];16 var value = data[0][fieldName];17 var num = 0;18 for (var i = 0; i < data.length; i++) {19 if (value != data[i][fieldName]) {20 numArr.push(num);21 value = data[i][fieldName];22 num = 1;23 continue;24 }25 num++;26 }27 var merIndex = 0;28 for (var i = 0; i < numArr.length; i++) {29 $(target).bootstrapTable('mergeCells', { index: merIndex, field: fieldName, colspan: colspan, rowspan: numArr[i] })30 merIndex += numArr[i];31 }32}33/**34* å并å35* @@param data åå§æ°æ®ï¼å¨æå¡ç«¯å®ææåºï¼36* @@param fieldName å并å±æ§æ°ç»37* @@param target ç®æ è¡¨æ ¼å¯¹è±¡38*/39function mergeColspan(data, fieldNameArr, target) {40 if (data.length == 0) {41 alert("ä¸è½ä¼ å
¥ç©ºæ°æ®");42 return;43 }44 if (fieldNameArr.length == 0) {45 alert("è¯·ä¼ å
¥å±æ§å¼");46 return;47 }48 var num = -1;49 var index = 0;50 for (var i = 0; i < data.length; i++) {51 num++;52 for (var v in fieldNameArr) {53 index = 1;54 if (data[i][fieldNameArr[v]] != data[i][fieldNameArr[0]]) {55 index = 0;56 break;57 }58 }59 if (index == 0) {60 continue;61 }62 $(target).bootstrapTable('mergeCells', { index: num, field: fieldNameArr[0], colspan: fieldNameArr.length, rowspan: 1 });63 }64}65/**66* å并åå
æ ¼67* @@param target ç®æ è¡¨æ ¼å¯¹è±¡68* @@param data åå§æ°æ®ï¼å¨æå¡ç«¯å®ææåºï¼69* @@param fieldName å并åç
§çå±æ§å称70* @@param fieldList è¦å并çå段éå[ä¸å«fieldName]![]71* @@param colspan å并å¼å§å72*/73function mergeCells2(target, data, fieldName, fieldList, colspan) {74 // 声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å75 var sortMap = {};76 var index = 0;77 var begini = 0;78 var endi = 0;79 // ç»è®¡fieldNameé¿åº¦80 getCount(target, data, 0, data.length, fieldName, index, sortMap);81 for (var prop in sortMap) {82 endi = index + sortMap[prop];83 if (sortMap[prop] > 1) {84 // console.log(fieldName + ":" + prop,sortMap[prop]);85 for (var i = 0; i < fieldList.length; i++) {86 getCount(target, data, begini, endi, fieldList[i], index, null);87 }88 }89 index = begini = endi;90 }91}92function getCount(target, data, begini, endi, fieldName, index, sortMap) {93 // console.log('fieldName:' + fieldName);94 // console.log(begini,endi);95 if (sortMap == null) {96 sortMap = {};97 }98 for (var i = begini; i < endi; i++) {99 for (var prop in data[i]) {100 if (prop == fieldName) {101 var key = data[i][prop];102 if (sortMap.hasOwnProperty(key)) {103 sortMap[key] = sortMap[key] + 1;104 } else {105 sortMap[key] = 1;106 }107 // console.log(fieldName + ":" + key, sortMap[key]);108 break;109 }110 }111 }112 for (var p in sortMap) {113 var count = sortMap[p] * 1;114 // console.log(">>>>>" + ":" + p , count);115 $(target).bootstrapTable('mergeCells', { index: index, field: fieldName, colspan: 1, rowspan: count });116 index += count;117 }118}119$("#mainTable").bootstrapTable({120 onLoadSuccess: function (data) {121 //mergeCells(data, "OrderId", 1, $('#mainTable'));//è¡å并122 mergeCells2($('#mainTable'), data, "OrderId", ["OrderDate", "MovementTypeDescription"], 1);//è¡å并123 //mergeColspan(data, ["FDepName3", "FDepName1", "FDepName2"], $('#table2'));//åå并124 },...
js.js
Source:js.js
1/* æå¡è¯·æ±end*/2//è·åurlä¸çåæ°3;4(function($) {5 $.getUrlParam = function(name) {6 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");7 var r = window.location.search.substr(1).match(reg);8 if(r != null)9 return decodeURI(r[2]);10 return null;11 };12})(jQuery);13//å°è¡¨å设置ææ¥ççæ ·å¼14;15(function() {16 setFormSee = function(opts) {17 $(opts.formEle).find('input[type="text"]').css({18 'border': 'none'19 }).prop('disabled', 'disabled');20 }21 22 $('.disabled-text').css({23 'border': 'none'24 }).prop('disabled', 'disabled');25})();26//表åéªè¯27;28(function() {29 formValidate = function(opts) {30 this.formEle = $(opts.formEle);31 this.init();32 }33 formValidate.prototype.init = function() {34 $.metadata.setType("attr", "validate");35 var v = this.formEle.validate({36 errorPlacement: function(lable, element) {37 element.ligerHideTip();38 if(element.hasClass("l-textarea")) {39 element.ligerTip({40 content: lable.html(),41 target: element[0]42 });43 } else if(element.hasClass("l-text-field")) {44 element.parent().ligerTip({45 content: lable.html(),46 target: element[0]47 });48 } else if(element.hasClass("l-text-combobox")) {49 element.parent().ligerTip({50 content: lable.html(),51 target: element[0]52 });53 } else {54 lable.appendTo(element.parents("td:first"));55 }56 },57 success: function(lable) {58 lable.ligerHideTip();59 lable.remove();60 },61 submitHandler: function() {62 $("form .l-text,.l-textarea").ligerHideTip();63 }64 });65 this.formEle.ligerForm({66 inputWidth: '',67 validate: true68 });69 }70})();71function mergeObj(obj, source) {72 var json = obj || {};73 for(n in source) {74 json[n] = source[n];75 }76 return json;77}78window.USER_INFO = {79 SITE_URL: 'http://119.29.252.75'80}81//å并åå
æ ¼82function mergeCells(data, fieldName, newindex, target) {83 //声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å84 var sortMap = {};85 for(var i = 0; i < data.length; i++) {86 for(var prop in data[i]) {87 if(prop == fieldName) {88 var key = data[i][prop]89 if(sortMap.hasOwnProperty(key)) {90 sortMap[key] = sortMap[key] * 1 + 1;91 } else {92 sortMap[key] = 1;93 }94 break;95 }96 }97 }98 for(var prop in sortMap) {99 console.log(prop, sortMap[prop])100 }101 var index = 0;102 for(var prop in sortMap) {103 var count = sortMap[prop] * 1;104 $(target).bootstrapTable('mergeCells', {105 index: newindex != null ? newindex : index,106 field: fieldName,107 rowspan: count108 });109 if(newindex == null) {110 index += count;111 }112 }113}114function cancelLayer() {115 var index = parent.layer.getFrameIndex(window.name);116 parent.layer.close(index);117}118function printOrder() {119 $(".button-group").addClass("display-none");120 $("textarea").each(function() {121 var value = $(this).val();122 $(this).parent().text(value);123 $(this).remove();124 });125 window.print();126 var index = parent.layer.getFrameIndex(window.name);127 parent.layer.close(index);128}129function showCurrentDate() {130 var myDate = new Date;131 var str = "" + myDate.getFullYear() + "-";132 if(myDate.getMonth() < 10) {133 str += '0' + (myDate.getMonth() + 1) + "-";134 } else {135 str += (myDate.getMonth() + 1) + "-";136 }137 if(myDate.getDate() < 10) {138 str += '0' + myDate.getDate();139 } else {140 str += myDate.getDate();141 }142 return str;...
ywgl.js
Source:ywgl.js
1/*!2 * ä¸å¡ç®¡ç3 * 4 * @author sunxuelong5 * @version 2017-2-86 */7/**8 * å并åå
æ ¼9 * @param data åå§æ°æ®ï¼å¨æå¡ç«¯å®ææåºï¼10 * @param fieldName å并å±æ§å称11 @param flagName æ è®°å±æ§å称12 * @param colspan å并å13 * @param target ç®æ è¡¨æ ¼å¯¹è±¡14 */15 function mergeCells(data,fieldName,flagName,colspan,target){16 //声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å17 var sortMap = {};18 for(var i = 0 ; i < data.length ; i++){19 for(var prop in data[i]){20 if(prop == flagName){21 var key = data[i][prop]22 if(sortMap.hasOwnProperty(key)){23 sortMap[key] = sortMap[key] * 1 + 1;24 } else {25 sortMap[key] = 1;26 }27 break;28 }29 }30 }31 for(var prop in sortMap){32 console.log(prop,sortMap[prop])33 }34 var index = 0;35 for(var prop in sortMap){36 var count = sortMap[prop] * 1;37 var fieldNames=fieldName.split(",");38 $.each(fieldNames,function(i,v){39 $(target).bootstrapTable('mergeCells',{index:index, field:v, colspan: colspan, rowspan: count});40 });41 index += count;42 }43 }44//æ¸
é¤ajaxç¼åå
¼å®¹45$(function(){46 $.ajaxSetup({ cache: false });...
datatable.js
Source:datatable.js
1/**2 * 模æCRUDæ°æ®3 */4export default ({ fetchMock, delay, mock, toSuccess, toError }) => {5 return {6 // è¡¨æ ¼å¸¦å页7 '/api/datatable/getList': options => {8 const body = JSON.parse(options.body);9 const currentPage = body.currentPage;10 const sortMap = body.sortMap;11 const idbase = (currentPage - 1) * 10 + 1;12 let sortField = { 'age|1-100': 1 };13 if (sortMap && sortMap.age) { // 模ææåº14 let i = 60;15 sortField =16 sortMap.age === 'asc'17 ? { 'age|+1': new Array(10).fill(0).map(item => i++) }18 : { 'age|+1': new Array(10).fill(0).map(item => i--) };19 }20 return toSuccess(21 mock({22 currentPage: currentPage,23 showCount: body.showCount,24 totalResult: 100,25 totalPage: 10,26 [`dataList|${body.showCount}`]: [27 {28 'id|+1': idbase,29 name: '@cname',30 address: '@county()',31 'role|1': ['1', '2', '3'],32 ...sortField33 }34 ]35 }),36 40037 );38 },39 // åå°å页40 '/api/datatable/frontPaging': options => {41 return toSuccess(42 mock({43 [`list|33`]: [44 {45 'id|+1': 1,46 name: '@cname',47 address: '@county()',48 'age|1-100': 1,49 'role|1': ['1', '2', '3']50 }51 ]52 }),53 40054 );55 }56 };...
test.js
Source:test.js
1$(function(){2 $("#table").bootstrapTable({3 pagination: true,4 onLoadSuccess : function(data) {5 var data = $('#table').bootstrapTable('getData', true);6 //å并åå
æ ¼7 mergeCells(data, "period_name", 1, $('#table'));8 }9 })10});1112function mergeCells(data,fieldName,colspan,target){13 //声æä¸ä¸ªmap计ç®ç¸åå±æ§å¼å¨data对象åºç°ç次æ°å14 var sortMap = {};15 for(var i = 0 ; i < data.length ; i++){16 for(var prop in data[i]){17 if(prop == fieldName){18 var key = data[i][prop]19 if(sortMap.hasOwnProperty(key)){20 sortMap[key] = sortMap[key] * 1 + 1;21 } else {22 sortMap[key] = 1;23 }24 break;25 }26 }27 }28 for(var prop in sortMap){29 console.log(prop,sortMap[prop])30 }31 var index = 0;32 for(var prop in sortMap){33 var count = sortMap[prop] * 1;34 $(target).bootstrapTable('mergeCells',{index:index, field:fieldName, colspan: colspan, rowspan: count});35 index += count;36 }
...
JavaScript1.js
Source:JavaScript1.js
1var customSortString = function (S, T) {2 if (!S)3 return T;4 if (!T)5 return S;6 let leftover = '';7 let sortMap = new Map();8 S.split('').forEach(item => {9 if (!sortMap.has(item)) {10 sortMap.set(item, []);11 }12 });13 T.split('').forEach(item => {14 if (sortMap.has(item)) {15 sortMap.get(item).push(item);16 }17 else {18 leftover += item;19 }20 });21 let ret = '';22 for (const [key, value] of sortMap) {23 value.forEach(char => {24 ret += (char);25 });26 }27 return ret + leftover;...
LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.
|<p>it('check_object_of_Car', () => {</p><p>
expect(newCar()).toBeInstanceOf(Car);</p><p>
});</p>|
| :- |
Get 100 minutes of automation test minutes FREE!!