UNPKG

@beisen-phoenix/lookup

Version:

---

45 lines (39 loc) 1.67 kB
import fetch from '@beisen/platform-fetch'; import isEqual from 'lodash/isEqual'; import isEmpty from 'lodash/isEmpty'; export function callFetch(url, params, succCallBack, errorCallBack) { fetch(url, { method: 'POST', params: params }).then(succCallBack, errorCallBack); } //判断props数据是否改变,无变化返回null,有变化返回json对象 export function getUpdateData(data, now, pre) { var ret = {}; (data || []).map(function (n) { if (!isEqual(now[n], pre[n])) { ret[n] = now[n]; } }); return isEmpty(ret) ? null : ret; } //按弹层高度计算规则,计算弹层的高度 export var calculateModalHeight = function calculateModalHeight(height, diff) { return (height || window.innerHeight) * 0.9 - diff; }; //判断弹窗是否出现滚动条,并返回高度 export var resetCalculateHeight = function resetCalculateHeight(className) { var adjustValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; //此判断仅限于lookup嵌入到Modal内的计算 var mainContainer = document.querySelector(className); var mainContainerDiv = mainContainer && mainContainer.parentElement || null; var searchFormDiv = mainContainer.querySelector('.phoenix-search-form'); if (mainContainerDiv) { var scrollY = mainContainerDiv.clientHeight - searchFormDiv.clientHeight - adjustValue; if (mainContainerDiv.scrollHeight >= mainContainerDiv.clientHeight) { return { scrollY: scrollY }; } } }; // 对象属性为undefined时返回空 export var getValueUseKey = function getValueUseKey(obj, key) { return typeof key === 'undefined' ? '' : obj[key]; };