import config from 'submodule/utils/config' const convert = { getTradeTypeStr(tradeType) { const map = config.status.tradeType return map.find((f) => f.value === String(tradeType))?.label }, getTypeStr(typeName, value) { const map = config.status[typeName] return map.find((f) => f.value == value)?.label }, getCheckItem(obj, filterFunc = (f) => true) { let arr = [] if (typeof obj === 'string') { obj = config[obj] } if (obj.push) { arr = obj } else { arr = Object.keys(obj).map((m) => { return { value: m, label: obj[m] } }) } arr.forEach((f) => (f.checked = false)) arr.unshift({ value: '-1', label: '全部', checked: true }) return arr.filter(filterFunc) }, // 空值显示 nullView(data) { return !data && data !== 0 ? '--' : data }, nullViewStr: '--' // '—', } // 空 convert.isNull = (val) => { return convert.nullView(val) === '--' } // 非空 convert.unNull = (val) => { return convert.nullView(val) !== '--' } convert.getOrderStatusStr = (settleStatus) => { const map = config.status.settleStatus return convert.nullView(map.find((f) => f.value === String(settleStatus))?.label) } export default convert