From 6ada0ac0c284fb092f18ddaa8bfa831a1eaf1e76 Mon Sep 17 00:00:00 2001 From: Yjhon Date: Tue, 29 Mar 2022 16:56:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=B1=BB=E5=88=AB=E8=B0=83=E6=95=B4=E5=8F=98?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/form/ProjectCourseSelect.vue | 44 +++++++++++-------- .../sys/dictionaryItem/DictionaryItemForm.vue | 2 +- .../sys/dictionaryItem/DictionaryItemList.vue | 4 +- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/views/project/form/ProjectCourseSelect.vue b/src/views/project/form/ProjectCourseSelect.vue index 655de97..57c0bda 100644 --- a/src/views/project/form/ProjectCourseSelect.vue +++ b/src/views/project/form/ProjectCourseSelect.vue @@ -8,8 +8,8 @@ 自主课程 - - + + @@ -62,6 +62,7 @@ import { coursewareClassList } from '@/api/course/courseware' import { listByClass } from '@/api/course/course' import { dictionaryDropDown } from '@/api/sys/dictionaryItem' +import { dictToTree } from '@/utils/util' import { STable } from '@/components' const rootParentId = 0 @@ -87,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: 'name', key: 'value', value: 'id' }, expandedKeys: [], autoExpandParent: true, dictCourseTag: [], //课程标签 @@ -256,21 +257,28 @@ export default { }, //获取课程分类数据,转换成树结构 - getCourseTreeData(type) { - coursewareClassList({ type: type }).then((res) => { - //list转🌲 - const list2tree1 = (list, parentId) => { - return list.filter((item) => { - // 默认选中第一个节点 - if (!this.treeDataOne) this.treeDataOne.push(item.value) - if (item.parentId === parentId) { - item.children = list2tree1(list, item.id) - return true - } - return false - }) - } - this.treeData = list2tree1(res.data, 0) + // getCourseTreeData(type) { + // coursewareClassList({ type: type }).then((res) => { + // //list转🌲 + // const list2tree1 = (list, parentId) => { + // return list.filter((item) => { + // // 默认选中第一个节点 + // if (!this.treeDataOne) this.treeDataOne.push(item.value) + // if (item.parentId === parentId) { + // item.children = list2tree1(list, item.id) + // return true + // } + // return false + // }) + // } + // 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 }) }, }, diff --git a/src/views/sys/dictionaryItem/DictionaryItemForm.vue b/src/views/sys/dictionaryItem/DictionaryItemForm.vue index d9ea871..55c747c 100644 --- a/src/views/sys/dictionaryItem/DictionaryItemForm.vue +++ b/src/views/sys/dictionaryItem/DictionaryItemForm.vue @@ -17,7 +17,7 @@ - + {{ form.parentid }} diff --git a/src/views/sys/dictionaryItem/DictionaryItemList.vue b/src/views/sys/dictionaryItem/DictionaryItemList.vue index e1e1c8b..0d14faa 100644 --- a/src/views/sys/dictionaryItem/DictionaryItemList.vue +++ b/src/views/sys/dictionaryItem/DictionaryItemList.vue @@ -66,11 +66,11 @@ export default { selectedRowKeys: [], // 选中行的key 出选择框时需要配置 selectedRows: [], // 选中行的数据 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: 'value', key: 'value' }, { 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' } ], loadData: parameter => { From 942a5572875218b2a23ed4d4a041d3b0e8f2382d Mon Sep 17 00:00:00 2001 From: Yjhon Date: Tue, 29 Mar 2022 17:29:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=BE=E4=BB=B6=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/util.js | 166 +++++++++--------- .../project/form/ProjectCourseSelect.vue | 4 +- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/utils/util.js b/src/utils/util.js index ae0f8a1..4aabb17 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -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 +} \ No newline at end of file diff --git a/src/views/project/form/ProjectCourseSelect.vue b/src/views/project/form/ProjectCourseSelect.vue index 57c0bda..58bc569 100644 --- a/src/views/project/form/ProjectCourseSelect.vue +++ b/src/views/project/form/ProjectCourseSelect.vue @@ -9,7 +9,7 @@ - + @@ -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: [], //课程标签