Merge branch 'develop' of https://gitee.com/siwa-team/dawa-vue into develop
This commit is contained in:
commit
c5b3af31e7
|
@ -1,56 +1,56 @@
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
export function timeFix() {
|
export function timeFix() {
|
||||||
const time = new Date()
|
const time = new Date()
|
||||||
const hour = time.getHours()
|
const hour = time.getHours()
|
||||||
return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
|
return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function welcome() {
|
export function welcome() {
|
||||||
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
|
const arr = ['休息一会儿吧', '准备吃什么呢?', '要不要打一把 DOTA', '我猜你可能累了']
|
||||||
const index = Math.floor(Math.random() * arr.length)
|
const index = Math.floor(Math.random() * arr.length)
|
||||||
return arr[index]
|
return arr[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触发 window.resize
|
* 触发 window.resize
|
||||||
*/
|
*/
|
||||||
export function triggerWindowResizeEvent() {
|
export function triggerWindowResizeEvent() {
|
||||||
const event = document.createEvent('HTMLEvents')
|
const event = document.createEvent('HTMLEvents')
|
||||||
event.initEvent('resize', true, true)
|
event.initEvent('resize', true, true)
|
||||||
event.eventType = 'message'
|
event.eventType = 'message'
|
||||||
window.dispatchEvent(event)
|
window.dispatchEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleScrollHeader(callback) {
|
export function handleScrollHeader(callback) {
|
||||||
let timer = 0
|
let timer = 0
|
||||||
|
|
||||||
let beforeScrollTop = window.pageYOffset
|
let beforeScrollTop = window.pageYOffset
|
||||||
callback = callback || function () { }
|
callback = callback || function() {}
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
'scroll',
|
'scroll',
|
||||||
event => {
|
event => {
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
let direction = 'up'
|
let direction = 'up'
|
||||||
const afterScrollTop = window.pageYOffset
|
const afterScrollTop = window.pageYOffset
|
||||||
const delta = afterScrollTop - beforeScrollTop
|
const delta = afterScrollTop - beforeScrollTop
|
||||||
if (delta === 0) {
|
if (delta === 0) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
direction = delta > 0 ? 'down' : 'up'
|
direction = delta > 0 ? 'down' : 'up'
|
||||||
callback(direction)
|
callback(direction)
|
||||||
beforeScrollTop = afterScrollTop
|
beforeScrollTop = afterScrollTop
|
||||||
}, 50)
|
}, 50)
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIE() {
|
export function isIE() {
|
||||||
const bw = window.navigator.userAgent
|
const bw = window.navigator.userAgent
|
||||||
const compare = (s) => bw.indexOf(s) >= 0
|
const compare = (s) => bw.indexOf(s) >= 0
|
||||||
const ie11 = (() => 'ActiveXObject' in window)()
|
const ie11 = (() => 'ActiveXObject' in window)()
|
||||||
return compare('MSIE') || ie11
|
return compare('MSIE') || ie11
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,65 +59,65 @@ export function isIE() {
|
||||||
* @param timeout
|
* @param timeout
|
||||||
*/
|
*/
|
||||||
export function removeLoadingAnimate(id = '', timeout = 1500) {
|
export function removeLoadingAnimate(id = '', timeout = 1500) {
|
||||||
if (id === '') {
|
if (id === '') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document.body.removeChild(document.getElementById(id))
|
document.body.removeChild(document.getElementById(id))
|
||||||
}, timeout)
|
}, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listToTree(list, tree, parentId) {
|
export function listToTree(list, tree, parentId) {
|
||||||
list.map(item => {
|
list.map(item => {
|
||||||
const index = _.findIndex(list, ['id', item.pid])
|
const index = _.findIndex(list, ['id', item.pid])
|
||||||
if(index === -1){
|
if (index === -1) {
|
||||||
item.pid = 0
|
item.pid = 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
list.forEach(item => {
|
list.forEach(item => {
|
||||||
if (item.pid === parentId) {
|
if (item.pid === parentId) {
|
||||||
const child = {
|
const child = {
|
||||||
...item,
|
...item,
|
||||||
scopedSlots: {
|
scopedSlots: {
|
||||||
icon: 'icon'
|
icon: 'icon'
|
||||||
},
|
},
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
listToTree(list, child.children, item.id)
|
listToTree(list, child.children, item.id)
|
||||||
if (child.children.length <= 0) {
|
if (child.children.length <= 0) {
|
||||||
delete child.children
|
delete child.children
|
||||||
}
|
}
|
||||||
tree.push(child)
|
tree.push(child)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return tree
|
return tree
|
||||||
}
|
}
|
||||||
|
|
||||||
// 词典集合转树
|
// 词典集合转树
|
||||||
export function dictToTree(list, tree, parentId) {
|
export function dictToTree(list, tree, parentId) {
|
||||||
list.forEach(item => {
|
list.forEach(item => {
|
||||||
if (item.parentid === parentId) {
|
if (item.parentid === parentId) {
|
||||||
let item_ = {};
|
let item_ = {};
|
||||||
item_.title = item.name;
|
item_.title = item.name;
|
||||||
item_.value = item.value;
|
item_.value = item.value;
|
||||||
item_.key = item.id;
|
item_.key = item.id;
|
||||||
const child = { ...item_, children: [] };
|
const child = {...item_, children: [] };
|
||||||
|
|
||||||
dictToTree(list, child.children, item.value);
|
dictToTree(list, child.children, item.value);
|
||||||
|
|
||||||
if (child.children.length <= 0) {
|
if (child.children.length <= 0) {
|
||||||
delete child.children
|
delete child.children
|
||||||
} else {
|
} else {
|
||||||
child.selectable = false;
|
// child.selectable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree.push(child)
|
tree.push(child)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return tree
|
return tree
|
||||||
}
|
}
|
||||||
|
|
||||||
//拿地址路径中的参数,不能用$route取的就用这个取
|
//拿地址路径中的参数,不能用$route取的就用这个取
|
||||||
export function getUrlKey(name) {
|
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
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
<a-menu-item key="self">自主课程</a-menu-item>
|
<a-menu-item key="self">自主课程</a-menu-item>
|
||||||
<!-- :disabled="tabDis" -->
|
<!-- :disabled="tabDis" -->
|
||||||
</a-menu>
|
</a-menu>
|
||||||
<!-- :defaultExpandedKeys="defaultExpandedKeys" -->
|
<!-- :defaultExpandedKeys="defaultExpandedKeys :replaceFields="replaceFields"" -->
|
||||||
<a-tree :treeData="treeData" @select="onSelect" :defaultExpandAll="true" :replaceFields="replaceFields">
|
<a-tree :treeData="treeData" @select="onSelect" :defaultExpandAll="true" :replaceFields="replaceFields">
|
||||||
<a-icon slot="switcherIcon" type="down" />
|
<a-icon slot="switcherIcon" type="down" />
|
||||||
</a-tree>
|
</a-tree>
|
||||||
|
@ -62,6 +62,7 @@
|
||||||
import { coursewareClassList } from '@/api/course/courseware'
|
import { coursewareClassList } from '@/api/course/courseware'
|
||||||
import { listByClass } from '@/api/course/course'
|
import { listByClass } from '@/api/course/course'
|
||||||
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
|
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
|
||||||
|
import { dictToTree } from '@/utils/util'
|
||||||
import { STable } from '@/components'
|
import { STable } from '@/components'
|
||||||
const rootParentId = 0
|
const rootParentId = 0
|
||||||
|
|
||||||
|
@ -87,7 +88,7 @@ export default {
|
||||||
menuKey: ['sys'], //默认系统课程
|
menuKey: ['sys'], //默认系统课程
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParam: { name: '', classType: 1, type: 1, tags: [] },
|
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: [],
|
expandedKeys: [],
|
||||||
autoExpandParent: true,
|
autoExpandParent: true,
|
||||||
dictCourseTag: [], //课程标签
|
dictCourseTag: [], //课程标签
|
||||||
|
@ -256,21 +257,28 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
//获取课程分类数据,转换成树结构
|
//获取课程分类数据,转换成树结构
|
||||||
getCourseTreeData(type) {
|
// getCourseTreeData(type) {
|
||||||
coursewareClassList({ type: type }).then((res) => {
|
// coursewareClassList({ type: type }).then((res) => {
|
||||||
//list转🌲
|
// //list转🌲
|
||||||
const list2tree1 = (list, parentId) => {
|
// const list2tree1 = (list, parentId) => {
|
||||||
return list.filter((item) => {
|
// return list.filter((item) => {
|
||||||
// 默认选中第一个节点
|
// // 默认选中第一个节点
|
||||||
if (!this.treeDataOne) this.treeDataOne.push(item.value)
|
// if (!this.treeDataOne) this.treeDataOne.push(item.value)
|
||||||
if (item.parentId === parentId) {
|
// if (item.parentId === parentId) {
|
||||||
item.children = list2tree1(list, item.id)
|
// item.children = list2tree1(list, item.id)
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
return false
|
// return false
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
this.treeData = list2tree1(res.data, 0)
|
// this.treeData = list2tree1(res.data, 0)
|
||||||
|
// })
|
||||||
|
// },
|
||||||
|
getCourseTreeData () {
|
||||||
|
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
|
||||||
|
const result = dictToTree(res.data, [], 0)
|
||||||
|
console.log('result',result)
|
||||||
|
this.treeData = result
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-model-item ref="parentid" label="上级编号" prop="parentid">
|
<a-form-model-item ref="parentid" label="所属上级" prop="parentid">
|
||||||
<a-input-number v-if="operable" v-model="form.parentid" :min="0"/>
|
<a-input-number v-if="operable" v-model="form.parentid" :min="0"/>
|
||||||
<span v-else>{{ form.parentid }}</span>
|
<span v-else>{{ form.parentid }}</span>
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
|
|
|
@ -66,11 +66,11 @@ export default {
|
||||||
selectedRowKeys: [], // 选中行的key 出选择框时需要配置
|
selectedRowKeys: [], // 选中行的key 出选择框时需要配置
|
||||||
selectedRows: [], // 选中行的数据
|
selectedRows: [], // 选中行的数据
|
||||||
columns: [
|
columns: [
|
||||||
{ title: '编号', width: 30, dataIndex: 'id', key: 'id' },
|
// { title: '编号', width: 30, dataIndex: 'id', key: 'id' },
|
||||||
{ title: '词典项名称', width: 30, dataIndex: 'name', key: 'name' },
|
{ title: '词典项名称', width: 30, dataIndex: 'name', key: 'name' },
|
||||||
{ title: '词典项值', width: 30, dataIndex: 'value', key: 'value' },
|
{ title: '词典项值', width: 30, dataIndex: 'value', key: 'value' },
|
||||||
{ title: '词典标识', width: 30, dataIndex: 'dictionaryCode', key: 'dictionaryCode' },
|
{ title: '词典标识', width: 30, dataIndex: 'dictionaryCode', key: 'dictionaryCode' },
|
||||||
{ title: '上级编号', width: 30, dataIndex: 'parentid', key: 'parentid' },
|
{ title: '上级', width: 30, dataIndex: 'parentid', key: 'parentid' },
|
||||||
{ title: '排序', width: 30, dataIndex: 'sortid', key: 'sortid' }
|
{ title: '排序', width: 30, dataIndex: 'sortid', key: 'sortid' }
|
||||||
],
|
],
|
||||||
loadData: parameter => {
|
loadData: parameter => {
|
||||||
|
|
Loading…
Reference in New Issue