课件搜索调整

This commit is contained in:
Yjhon 2022-03-29 17:29:50 +08:00
parent 6ada0ac0c2
commit 942a557287
2 changed files with 85 additions and 85 deletions

View File

@ -1,56 +1,56 @@
import _ from 'lodash'
export function timeFix() {
const time = new Date()
const hour = time.getHours()
return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
const time = new Date()
const hour = time.getHours()
return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
}
export function welcome() {
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
const index = Math.floor(Math.random() * arr.length)
return arr[index]
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
const index = Math.floor(Math.random() * arr.length)
return arr[index]
}
/**
* 触发 window.resize
*/
export function triggerWindowResizeEvent() {
const event = document.createEvent('HTMLEvents')
event.initEvent('resize', true, true)
event.eventType = 'message'
window.dispatchEvent(event)
const event = document.createEvent('HTMLEvents')
event.initEvent('resize', true, true)
event.eventType = 'message'
window.dispatchEvent(event)
}
export function handleScrollHeader(callback) {
let timer = 0
let timer = 0
let beforeScrollTop = window.pageYOffset
callback = callback || function () { }
window.addEventListener(
'scroll',
event => {
clearTimeout(timer)
timer = setTimeout(() => {
let direction = 'up'
const afterScrollTop = window.pageYOffset
const delta = afterScrollTop - beforeScrollTop
if (delta === 0) {
return false
}
direction = delta > 0 ? 'down' : 'up'
callback(direction)
beforeScrollTop = afterScrollTop
}, 50)
},
false
)
let beforeScrollTop = window.pageYOffset
callback = callback || function() {}
window.addEventListener(
'scroll',
event => {
clearTimeout(timer)
timer = setTimeout(() => {
let direction = 'up'
const afterScrollTop = window.pageYOffset
const delta = afterScrollTop - beforeScrollTop
if (delta === 0) {
return false
}
direction = delta > 0 ? 'down' : 'up'
callback(direction)
beforeScrollTop = afterScrollTop
}, 50)
},
false
)
}
export function isIE() {
const bw = window.navigator.userAgent
const compare = (s) => bw.indexOf(s) >= 0
const ie11 = (() => 'ActiveXObject' in window)()
return compare('MSIE') || ie11
const bw = window.navigator.userAgent
const compare = (s) => bw.indexOf(s) >= 0
const ie11 = (() => 'ActiveXObject' in window)()
return compare('MSIE') || ie11
}
/**
@ -59,65 +59,65 @@ export function isIE() {
* @param timeout
*/
export function removeLoadingAnimate(id = '', timeout = 1500) {
if (id === '') {
return
}
setTimeout(() => {
document.body.removeChild(document.getElementById(id))
}, timeout)
if (id === '') {
return
}
setTimeout(() => {
document.body.removeChild(document.getElementById(id))
}, timeout)
}
export function listToTree(list, tree, parentId) {
list.map(item => {
const index = _.findIndex(list, ['id', item.pid])
if(index === -1){
item.pid = 0
}
})
list.forEach(item => {
if (item.pid === parentId) {
const child = {
...item,
scopedSlots: {
icon: 'icon'
},
children: []
}
listToTree(list, child.children, item.id)
if (child.children.length <= 0) {
delete child.children
}
tree.push(child)
}
})
return tree
list.map(item => {
const index = _.findIndex(list, ['id', item.pid])
if (index === -1) {
item.pid = 0
}
})
list.forEach(item => {
if (item.pid === parentId) {
const child = {
...item,
scopedSlots: {
icon: 'icon'
},
children: []
}
listToTree(list, child.children, item.id)
if (child.children.length <= 0) {
delete child.children
}
tree.push(child)
}
})
return tree
}
// 词典集合转树
export function dictToTree(list, tree, parentId) {
list.forEach(item => {
if (item.parentid === parentId) {
let item_ = {};
item_.title = item.name;
item_.value = item.value;
item_.key = item.id;
const child = { ...item_, children: [] };
list.forEach(item => {
if (item.parentid === parentId) {
let item_ = {};
item_.title = item.name;
item_.value = item.value;
item_.key = item.id;
const child = {...item_, children: [] };
dictToTree(list, child.children, item.value);
dictToTree(list, child.children, item.value);
if (child.children.length <= 0) {
delete child.children
} else {
child.selectable = false;
}
if (child.children.length <= 0) {
delete child.children
} else {
// child.selectable = false;
}
tree.push(child)
}
})
return tree
tree.push(child)
}
})
return tree
}
//拿地址路径中的参数,不能用$route取的就用这个取
export function getUrlKey(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
}

View File

@ -9,7 +9,7 @@
<!-- :disabled="tabDis" -->
</a-menu>
<!-- :defaultExpandedKeys="defaultExpandedKeys :replaceFields="replaceFields"" -->
<a-tree :treeData="treeData" @select="onSelect" :defaultExpandAll="true" >
<a-tree :treeData="treeData" @select="onSelect" :defaultExpandAll="true" :replaceFields="replaceFields">
<a-icon slot="switcherIcon" type="down" />
</a-tree>
</a-col>
@ -88,7 +88,7 @@ export default {
menuKey: ['sys'], //
//
queryParam: { name: '', classType: 1, type: 1, tags: [] },
// replaceFields: { children: 'children', title: 'name', key: 'value', value: 'id' },
replaceFields: { children: 'children', title: 'title', key: 'value', value: 'key' },
expandedKeys: [],
autoExpandParent: true,
dictCourseTag: [], //