convert.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import config from 'submodule/utils/config'
  2. const convert = {
  3. getTradeTypeStr(tradeType) {
  4. const map = config.tradeType
  5. return map.find((f) => f.value === String(tradeType))?.label
  6. },
  7. getTypeStr(typeName, value) {
  8. const map = config[typeName]
  9. return map.find((f) => f.value == value)?.label
  10. },
  11. getCheckItem(obj, filterFunc = (f) => true) {
  12. let arr = []
  13. if (typeof obj === 'string') {
  14. obj = config[obj]
  15. }
  16. if (obj.push) {
  17. arr = obj
  18. } else {
  19. arr = Object.keys(obj).map((m) => {
  20. return {
  21. value: m,
  22. label: obj[m]
  23. }
  24. })
  25. }
  26. arr.forEach((f) => (f.checked = false))
  27. arr.unshift({
  28. value: '-1',
  29. label: '全部',
  30. checked: true
  31. })
  32. return arr.filter(filterFunc)
  33. },
  34. // 空值显示
  35. nullView(data) {
  36. return !data && data !== 0 ? '--' : data
  37. },
  38. nullViewStr: '--' // '—',
  39. }
  40. // 空
  41. convert.isNull = (val) => {
  42. return convert.nullView(val) === '--'
  43. }
  44. // 非空
  45. convert.unNull = (val) => {
  46. return convert.nullView(val) !== '--'
  47. }
  48. convert.getOrderStatusStr = (settleStatus) => {
  49. const map = config.settleStatus
  50. return convert.nullView(map.find((f) => f.value === String(settleStatus))?.label)
  51. }
  52. export default convert