|
|
@@ -38,14 +38,15 @@ export const calcMarketPriceByInfoPrice = (infoPrice: number, purchaseFeeRate: n
|
|
|
|
|
|
// roundForObj()
|
|
|
// 返回五大项组成的索引
|
|
|
-export const getIndex = (obj: IBaseGlj, pops = ['code', 'name', 'specs', 'unit', 'type']): string => {
|
|
|
+export const getIndex = (obj: IBaseGlj, props = ['code', 'name', 'specs', 'unit', 'type']): string => {
|
|
|
let index = '';
|
|
|
- const arr = [];
|
|
|
- for (const p of pops) {
|
|
|
+ //! 优化:字符串拼接比数组push、join操作快很多,大项目下影响较大,所以使用字符串拼接
|
|
|
+ for (let i = 0; i < props.length; i += 1) {
|
|
|
+ const p = props[i];
|
|
|
const tmpK = obj[p] === undefined || obj[p] === null || obj[p] === '' ? 'null' : obj[p];
|
|
|
- arr.push(tmpK);
|
|
|
+ const str = i === props.length - 1 ? tmpK : `${tmpK}|-|`;
|
|
|
+ index += str;
|
|
|
}
|
|
|
- index = arr.join('|-|');
|
|
|
return index;
|
|
|
};
|
|
|
|