Commit 91677ce7 by liyuhang19990520

工具类函数以及比中和认定逻辑修改样式修改

parent 35eee2ff
...@@ -65,7 +65,7 @@ _axios.interceptors.response.use( ...@@ -65,7 +65,7 @@ _axios.interceptors.response.use(
function (response) { function (response) {
NProgress.done(); NProgress.done();
loadingIndex--; loadingIndex--;
console.log('请求后' + loadingIndex) // console.log('请求后' + loadingIndex)
if (loadingIndex <= 0) { if (loadingIndex <= 0) {
clearTimeout(timer) clearTimeout(timer)
timer = setTimeout(() => { timer = setTimeout(() => {
......
...@@ -57,19 +57,19 @@ export default { ...@@ -57,19 +57,19 @@ export default {
* @param {Object} arr * @param {Object} arr
* @param {Object} i * @param {Object} i
*/ */
inArray: function(elem, arr) { inArray: function (elem, arr) {
return arr == null ? -1 : arr.indexOf(elem); return arr == null ? -1 : arr.indexOf(elem);
}, },
/** /**
* 获取某天日期 * 获取某天日期
* @param {Object} day * @param {Object} day
*/ */
getDay: function(day) { getDay: function (day) {
var today = new Date(); var today = new Date();
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day; var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
today.setTime(targetday_milliseconds); today.setTime(targetday_milliseconds);
const doHandleMonth = function(month) { const doHandleMonth = function (month) {
var m = month; var m = month;
if (month.toString().length == 1) { if (month.toString().length == 1) {
m = "0" + month; m = "0" + month;
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
* @param {Object} obj * @param {Object} obj
*/ */
deepClone(obj) { deepClone(obj) {
const isObject = function(obj) { const isObject = function (obj) {
return typeof obj == "object"; return typeof obj == "object";
}; };
...@@ -114,5 +114,66 @@ export default { ...@@ -114,5 +114,66 @@ export default {
cloneObj[key] = isObject(obj[key]) ? this.deepClone(obj[key]) : obj[key]; cloneObj[key] = isObject(obj[key]) ? this.deepClone(obj[key]) : obj[key];
} }
return cloneObj; return cloneObj;
},
//一个数组减去另一个数组中的值
arrToValue(souceArr, targetArr, key) {
if (!key) {
return souceArr.filter((x) => targetArr.indexOf(x) < 0);
} else {
souceArr.filter((x) => {
return targetArr.findIndex(y => y[key] == x[key]) < 0
});
}
},
// 转换字符串,undefined,null等转化为""
praseStrEmpty(str) {
return !str || str === 'undefined' || str === 'null' ? '' : str
},
/**
* 构造树型结构数据
* @param {*} data 数据源
* @param {*} id id字段 默认 'id'
* @param {*} parentId 父节点字段 默认 'parentId'
* @param {*} children 孩子节点字段 默认 'children'
* @param {*} rootId 根Id 默认 0
*/
handleTree(data = [], id = 'id', parentId = 'parentId', children = 'children', rootId) {
rootId =
rootId ||
Math.min.apply(
Math,
data.map(item => {
return item[parentId]
})
) ||
0
//对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data))
//循环所有项
const treeData = cloneData.filter(father => {
let branchArr = cloneData.filter(child => {
//返回每一项的子级数组
return father[id] === child[parentId]
})
branchArr.length > 0 && (father.children = branchArr)
//返回第一层
return father[parentId] === rootId
})
// 排序
treeData
.sort((a, b) => {
return Number(a.code) - Number(b.code)
})
.forEach(m => {
if (m.children && m.children.length) {
m.children.sort((c, d) => {
return Number(c.code) - Number(d.code)
})
}
})
return treeData !== '' ? treeData : data
} }
}; };
...@@ -21,8 +21,9 @@ $phone: var(--phone, #606266); //#ff4242; ...@@ -21,8 +21,9 @@ $phone: var(--phone, #606266); //#ff4242;
padding: 20px; padding: 20px;
box-sizing: border-box; box-sizing: border-box;
position: absolute; position: absolute;
top: calc(50% - 300px); top: 30%;
left: calc(50% - 300px); left: 50%;
transform: translateX(-50%);
z-index: 1000; z-index: 1000;
width: 600px; width: 600px;
height: 152px; height: 152px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment