glj.ts 1.1 KB

123456789101112131415161718192021222324252627
  1. import { IBaseGlj, IInfoPriceItem, TaxType } from '@sc/types';
  2. export const getInfoMarketPrice = (info: IInfoPriceItem, taxType: TaxType) => {
  3. // 1: 一般计税 2: 简易计税
  4. const fieldArray = ['noTaxPrice']; // 一般计税 - 不含税价 || 简易计税 - 含税价
  5. if (taxType === TaxType.GENERAL) {
  6. fieldArray.push('taxPrice');
  7. } else {
  8. fieldArray.unshift('taxPrice');
  9. }
  10. // 一个放后面,一个放前面
  11. let infoPrice = (info as any)[fieldArray[0]];
  12. if (infoPrice === null || infoPrice === undefined) infoPrice = (info as any)[fieldArray[1]]; // 信息价只有一个价格(含税价/不含税价),则不分计税方式,套用仅有的价格。
  13. return parseFloat(infoPrice);
  14. };
  15. // 返回五大项组成的索引
  16. export const getIndex = (obj: IBaseGlj, pops = ['code', 'name', 'specs', 'unit', 'type']): string => {
  17. let index = '';
  18. const arr = [];
  19. for (const p of pops) {
  20. const tmpK = obj[p] === undefined || obj[p] === null || obj[p] === '' ? 'null' : obj[p];
  21. arr.push(tmpK);
  22. }
  23. index = arr.join('|-|');
  24. return index;
  25. };