|
@@ -341,6 +341,39 @@ const gclGatherModel = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function compareCode(str1, str2, symbol = '-') {
|
|
|
+ if (!str1) {
|
|
|
+ return 1;
|
|
|
+ } else if (!str2) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ function compareSubCode(code1, code2) {
|
|
|
+ if (numReg.test(code1)) {
|
|
|
+ if (numReg.test(code2)) {
|
|
|
+ return parseInt(code1) - parseInt(code2);
|
|
|
+ } else {
|
|
|
+ return -1
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (numReg.test(code2)) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1); //code1.localeCompare(code2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const numReg = /^[0-9]+$/;
|
|
|
+ const aCodes = str1.split(symbol), bCodes = str2.split(symbol);
|
|
|
+ for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
|
|
|
+ const iCompare = compareSubCode(aCodes[i], bCodes[i]);
|
|
|
+ if (iCompare !== 0) {
|
|
|
+ return iCompare;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return aCodes.length - bCodes.length;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据树结构 清单汇总
|
|
|
*/
|
|
@@ -353,29 +386,7 @@ const gclGatherModel = (function () {
|
|
|
calculateGatherData();
|
|
|
gatherDealBillsData();
|
|
|
gclList.sort(function (a, b) {
|
|
|
- function compareCode(code1, code2) {
|
|
|
- if (numReg.test(code1)) {
|
|
|
- if (numReg.test(code2)) {
|
|
|
- return _.toNumber(code1) - _.toNumber(code2);
|
|
|
- } else {
|
|
|
- return -1
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (numReg.test(code2)) {
|
|
|
- return 1;
|
|
|
- } else {
|
|
|
- return code1 === code2 ? 0 : (code1 < code2 ? -1 : 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- const numReg = /^[0-9]+$/;
|
|
|
- const aCodes = a.b_code.split('-'), bCodes = b.b_code.split('-');
|
|
|
- for (let i = 0, iLength = Math.min(aCodes.length, bCodes.length); i < iLength; ++i) {
|
|
|
- const iCompare = compareCode(aCodes[i], bCodes[i]);
|
|
|
- if (iCompare !== 0) {
|
|
|
- return iCompare;
|
|
|
- }
|
|
|
- }
|
|
|
+ return compareCode(a.b_code, b.b_code);
|
|
|
});
|
|
|
|
|
|
return gclList;
|