|
@@ -311,11 +311,39 @@ $(document).ready(() => {
|
|
$('#generate-data').modal('hide');
|
|
$('#generate-data').modal('hide');
|
|
},
|
|
},
|
|
loadParentNode: function () {
|
|
loadParentNode: function () {
|
|
|
|
+ const compareCode = function (str1, str2, symbol = '-') {
|
|
|
|
+ if (!str1) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else if (!str2) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const path1 = str1.split(symbol);
|
|
|
|
+ const path2 = str2.split(symbol);
|
|
|
|
+ const reg = /^[0-9]*$/;
|
|
|
|
+ for (let i = 0, iLen = Math.min(path1.length, path2.length); i < iLen; i++) {
|
|
|
|
+ if (reg.test(path1[i]) && reg.test(path2[i])) {
|
|
|
|
+ const num1 = parseInt(path1[i]);
|
|
|
|
+ const num2 = parseInt(path2[i]);
|
|
|
|
+ if (num1 !== num2) {
|
|
|
|
+ return num1 - num2;
|
|
|
|
+ }
|
|
|
|
+ } else if (path1[i] < path2[i]) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else if (path1[i] > path2[i]) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return path1.length - path2.length;
|
|
|
|
+ };
|
|
const history = compareObj.cacheList.find(function (l) {
|
|
const history = compareObj.cacheList.find(function (l) {
|
|
return l.lib_id === compareObj.data.lib_id && l.className === compareObj.data.className;
|
|
return l.lib_id === compareObj.data.lib_id && l.className === compareObj.data.className;
|
|
});
|
|
});
|
|
if (!history) {
|
|
if (!history) {
|
|
postData(window.location.pathname + '/parent', compareObj.data, function (result) {
|
|
postData(window.location.pathname + '/parent', compareObj.data, function (result) {
|
|
|
|
+ result.sort(function (x, y) {
|
|
|
|
+ return compareCode(x.code, y.code);
|
|
|
|
+ });
|
|
compareObj.cacheList.push({lib_id: compareObj.data.lib_id, className: compareObj.data.className, xList: result});
|
|
compareObj.cacheList.push({lib_id: compareObj.data.lib_id, className: compareObj.data.className, xList: result});
|
|
compareObj.generateXList(result);
|
|
compareObj.generateXList(result);
|
|
});
|
|
});
|
|
@@ -399,4 +427,13 @@ $(document).ready(() => {
|
|
}
|
|
}
|
|
compareObj.load();
|
|
compareObj.load();
|
|
});
|
|
});
|
|
|
|
+ $('#export-excel').click(function () {
|
|
|
|
+ const excelIo = new GC.Spread.Excel.IO();
|
|
|
|
+ const date = new Date();
|
|
|
|
+ const fileName = '单元对比.' + date.Format("yyyy.MM.dd.hh.mm.ss") + '.xlsx';
|
|
|
|
+ const sJson = JSON.stringify(spread.toJSON());
|
|
|
|
+ excelIo.save(sJson, function(blob) {
|
|
|
|
+ saveAs(blob, fileName);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
});
|
|
});
|