forked from zhurui/management
1 line
15 KiB
JSON
1 line
15 KiB
JSON
|
{"remainingRequest":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js!C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\utils\\mergeCell.js","dependencies":[{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\utils\\mergeCell.js","mtime":1614735254000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/web.dom.iterable\";\n\n/**\n * 构建合并列数据\n * 思路:遍历所有数据,将需要合并的列的内容作为key,数据id作为value,然后依次遍历获取对应的合并列的行数\n * @param\tdataList\t列表数据\n * @param\tlabel1\t\t第1列合并的字段名称\n * @param label2\t\t第2列合并的字段名称\n * @param label3\t\t第3列合并的字段名称\n * @param label4\t\t第4列合并的字段名称\n */\nexport function buildMerge(dataList) {\n var label1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'label1';\n var label2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'label2';\n var label3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'label3';\n var label4 = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'label4';\n\n // 当列表数据没有主键时,添加主键\n if (dataList.length > 0 && (dataList[0].id !== 0 || dataList[0].id !== '0')) {\n dataList.forEach(function (item, index) {\n item.id = [index];\n });\n }\n\n var firstObj = {},\n secondObj = {},\n thirdObj = {},\n fourthObj = {};\n var firstObjKey = '',\n secondObjKey = '',\n thirdObjKey = '',\n fourthObjKey = ''; // 本示例合并的前四列,对应的字段分别:label1、label2、label3、label4\n // 如果你需要合并其他的字段,需修改此处字段名称\n\n for (var i = 0, len = dataList.length; i < len; i++) {\n firstObjKey = dataList[i][label1];\n secondObjKey = dataList[i][label2];\n thirdObjKey = dataList[i][label3];\n fourthObjKey = dataList[i][label4];\n if (!firstObj[firstObjKey]) firstObj[firstObjKey] = new Array(dataList[i].id);else {\n firstObj[firstObjKey].push(dataList[i].id);\n }\n if (!secondObj[secondObjKey]) secondObj[secondObjKey] = new Array(dataList[i].id);else {\n secondObj[secondObjKey].push(dataList[i].id);\n }\n if (!thirdObj[thirdObjKey]) thirdObj[thirdObjKey] = new Array(dataList[i].id);else {\n thirdObj[thirdObjKey].push(dataList[i].id);\n }\n if (!fourthObj[fourthObjKey]) fourthObj[fourthObjKey] = new Array(dataList[i].id);else {\n fourthObj[fourthObjKey].push(dataList[i].id);\n }\n }\n\n computeFirstSpan(dataList, firstObj, secondObj, thirdObj, fourthObj);\n} // 计算第一列合并总数\n\nfunction computeFirstSpan(dataList, firstObj, secondObj, thirdObj, fourthObj) {\n var _loop = function _loop(obj) {\n var fristData = dataList.filter(function (d) {\n return d.id === firstObj[obj][0];\n })[0]; // 获取第一条数据,对其添加 'firstSpan' 属性,并设置值\n\n if (fristData) fristData['firstSpan'] = firstObj[obj].length;\n computeSecondSpan(dataList, firstObj[obj], secondObj, thirdObj, fourthObj);\n };\n\n // 遍历计算第一列合并行数\n for (var obj in firstObj) {\n _loop(obj);\n }\n} // 计算第二列合并总数\n\n\nfunction computeSecondSpan(dataList, classList, secondObj, thirdObj, fourthObj) {\n var secondList = []; // 遍历计算第二列合并行数\n\n var _loop2 = function _loop2(obj) {\n // 判断两个id数组,取其并集,并集的长度就是合并列的行数\n var secondIds = secondObj[obj].filter(function (val) {\n return classList.indexOf(val) > -1;\n });\n var fristData = dataList.filter(function (d) {\n return d.id === secondIds[
|