期刊引用+分类管理(集团分类+期刊)

This commit is contained in:
2024-09-26 13:52:24 +08:00
parent f679d3e7cb
commit b306198109
14 changed files with 3009 additions and 43 deletions

View File

@@ -2,12 +2,12 @@
<div class="wrapper">
<v-head></v-head>
<v-sidebar></v-sidebar>
<div class="content-box" :class="{'content-collapse':collapse}">
<div class="content-box" :class="{ 'content-collapse': collapse }">
<v-tags></v-tags>
<div class="content">
<transition name="move" mode="out-in">
<keep-alive :include="tagsList">
<router-view></router-view>
<router-view ></router-view>
</keep-alive>
</transition>
<el-backtop target=".content"></el-backtop>
@@ -34,12 +34,13 @@ export default {
vTags
},
created() {
bus.$on('collapse-content', msg => {
bus.$on('collapse-content', (msg) => {
this.collapse = msg;
localStorage.setItem('collapse', this.collapse);
});
// 只有在标签页列表里的页面才使用keep-alive即关闭标签之后就不保存到内存中了。
bus.$on('tags', msg => {
bus.$on('tags', (msg) => {
let arr = [];
for (let i = 0, len = msg.length; i < len; i++) {
msg[i].name && arr.push(msg[i].name);

View File

@@ -462,6 +462,11 @@ export default {
index: '5',
title: this.$t('sidebar.journalManagement'),
subs: [
{
index: 'JournalManagement',
title: this.$t('sidebar.journalManagement')
},
{
index: 'Journal_Agreement',
title: this.$t('sidebar.userManSys11')
@@ -626,6 +631,7 @@ export default {
}
},
created() {
localStorage.setItem('collapse', this.collapse);
if (this.userrole == 2) {
//其余的身份(显示作者)
// if (this.user_cap.includes('chief')) { //主编
@@ -652,12 +658,27 @@ export default {
this.items.splice(
3,
0,
{
icon: 'el-icon-s-platform',
index: '13',
title: this.$t('sidebar.chiefInspector'),
subs: [
{
index: 'Classificationmanagement',
title: this.$t('menu.Classificationmanagement'),
subs: [
{
index: 'JournalManagementAll',
title: this.$t('sidebar.journalManagement')
},
{
index: 'GroupClassification',
title: this.$t('sidebar.GroupClassification')
}
]
},
{
index: 'Academicresourcesupervise',
title: this.$t('menu.Academicresourcesupervise'),
@@ -700,8 +721,9 @@ export default {
}
);
this.items=[...this.items,{
this.items = [
...this.items,
{
icon: 'el-icon-s-operation',
index: '12',
title: this.$t('sidebar.managingDirector'),
@@ -711,12 +733,14 @@ export default {
title: this.$t('sidebar.chief1')
}
]
},]
}
];
}
// 通过 Event Bus 进行组件间通信,来折叠侧边栏
bus.$on('collapse', (msg) => {
this.collapse = msg;
localStorage.setItem('collapse', this.collapse);
bus.$emit('collapse-content', msg);
});
},

View File

@@ -43,12 +43,38 @@ const en = {
userManSys6: 'Promotion Record',
JournalCitationAnalysis: 'Journal Citation Analysis',
Academicresourcesupervise: 'Academic Resource Supervise',
Classificationmanagement: 'Classification Management',
publicationsupervise: 'Publication Supervise',
papersubmit: 'Paper Submit',
ArticlePublication: 'Article Publication',
JournalCitationAnalysis: 'Journal Citation Analysis',
},
GroupClassification: {
add: 'Add',
cancel: 'Cancel',
submit: 'Submit',
edit: 'Edit',
delete: 'Delete',
major_title: 'Major Title',
major_current: 'Current Major',
nickname: 'Nick Name',
enter: 'Please Enter...',
sort: 'Sort',
deleteInfo: 'Are you sure you want to delete this category',
Unbind: 'Unbind',
bind: 'Bind',
ExpandAll: 'Expand All',
Journal: 'Journal',
JournalBindInfo: 'The Journal',
BindInfo: 'will be bound to this category, Do you want to continue?',
UnBindInfo: 'will unbind this category, Do you want to continue?',
Tips: 'Tips',
AssociatedJournal: 'Associated Journal',
},
JournalCitationAnalysis: {
journal: 'Journal',
editor: 'Editor',
@@ -61,7 +87,8 @@ const en = {
all: 'All references',
factor: 'Factor',
Sameperiod: 'Same period',
ArticleInfo: 'Article Information',
},
partyRole: {
@@ -202,7 +229,8 @@ const en = {
editorialBoard3: 'Journal Management',
chiefInspector: 'Chief Inspector',
journalArticleCount: 'Journal Article Count',
managingDirector: 'Managing Director'
managingDirector: 'Managing Director',
GroupClassification: 'Group Classification',
},
home: {
authortop: 'Author guide',

View File

@@ -44,21 +44,48 @@ const zh = {
userManSys6: '推广记录',
JournalCitationAnalysis: '期刊引文分析',
Academicresourcesupervise: '学术资源监督',
Classificationmanagement: '分类管理',
publicationsupervise: '出版监督',
papersubmit: '论文提交',
ArticlePublication: '文章发表',
JournalCitationAnalysis: '期刊引文分析',
}, JournalCitationAnalysis: {
},
GroupClassification: {
add: '新增',
cancel: '取消',
submit: '确定',
edit: '编辑',
delete: '删除',
major_title: '分类名称',
major_current: '当前分类',
nickname: '分类昵称',
enter: '请输入...',
sort: '排序',
deleteInfo: '确定要删除该分类吗',
Unbind: '解绑',
bind: '绑定',
ExpandAll: '全部展开',
Journal: '期刊',
JournalBindInfo: '期刊',
BindInfo: '将<span style="color:#006699;font-weight:700;">【绑定】</span>该分类, 是否继续?',
UnBindInfo: '将<span style="color:red;font-weight:700;">【解绑】</span>该分类, 是否继续?',
Tips: '提示',
AssociatedJournal:'关联期刊',
},
JournalCitationAnalysis: {
journal: '期刊',
editor: '编辑',
cite: '引用数量',
article: '文章数量',
citeNum: '引用数量',
articleNum: '文章数量',
ArticleInfo: '文章信息',
info: '以下数据为', wos: 'Wos',
all: '全部引用',
factor: '影响因子',
@@ -76,8 +103,8 @@ const zh = {
}, partyListCorr: {
Realname: '姓名',
Email: '邮箱',
unregistered:'unregistered',
OtherInformation:'其他信息',
unregistered: 'unregistered',
OtherInformation: '其他信息',
articlelist: '文章列表',
journal: '期刊',
Authors: '作者',
@@ -87,7 +114,7 @@ const zh = {
InvestorProducer: '投稿者',
author: '作者',
status: '状态',
Published: '已发表',journal:'Journal',
Published: '已发表', journal: 'Journal',
},
sidebar: {
main: '个人中心',
@@ -198,7 +225,8 @@ const zh = {
editorialBoard3: '期刊列表',
chiefInspector: '总监',
journalArticleCount: '期刊文章计数总结',
managingDirector: '总经理'
managingDirector: '总经理',
GroupClassification: '集团分类',
},
home: {
authortop: '用户指南',

View File

@@ -0,0 +1,19 @@
import OrgTree from './org-tree'
const install = Vue => {
if (install.installed) {
return
}
install.installed = true
Vue.component(OrgTree.name, OrgTree)
}
OrgTree.install = install
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(OrgTree)
}
export default OrgTree

View File

@@ -0,0 +1,177 @@
// 判断是否叶子节点
const isLeaf = (data, prop) => {
return !(Array.isArray(data[prop]) && data[prop].length > 0)
}
// console.info('Thank you for using vue-tree-color \nIf you have any questions about this plug-in, please contact me in the following ways \nWeChat: yanjiahui12345 \nWeChat official number: Web_Miao')
// 创建 node 节点
export const renderNode = (h, data, context) => {
const { props } = context
const cls = ['org-tree-node']
const childNodes = []
const children = data[props.props.children]
if (isLeaf(data, props.props.children)) {
cls.push('is-leaf')
} else if (props.collapsable && !data[props.props.expand]) {
cls.push('collapsed')
}
childNodes.push(renderLabel(h, data, context))
if (!props.collapsable || data[props.props.expand]) {
childNodes.push(renderChildren(h, children, context))
}
return h('div', {
domProps: {
className: cls.join(' ')
}
}, childNodes)
}
// 创建展开折叠按钮
export const renderBtn = (h, data, { props, listeners }) => {
const expandHandler = listeners['on-expand']
const expandMouseover = listeners['on-expand-mouseover']
const expandMouseout = listeners['on-expand-mouseout']
let cls = ['org-tree-node-btn']
if (data[props.props.expand]) {
cls.push('expanded')
}
return h('span', {
domProps: {
className: cls.join(' ')
},
on: {
'click': e => expandHandler && expandHandler(e, data),
'mouseover': e => expandMouseover && expandMouseover(e, data),
'mouseout': e => expandMouseout && expandMouseout(e, data)
}
})
}
// 创建 label 节点
export const renderLabel = (h, data, context) => {
const { props, listeners } = context
const label = data[props.props.label]
const renderContent = props.renderContent
// event handlers
const clickHandler = listeners['on-node-click']
const mouseOverHandler = listeners['on-node-mouseover']
const mouseOutHandler = listeners['on-node-mouseout']
const childNodes = []
if (typeof renderContent === 'function') {
let vnode = renderContent(h, data)
vnode && childNodes.push(vnode)
} else {
childNodes.push(label)
}
if (props.collapsable && !isLeaf(data, props.props.children)) {
childNodes.push(renderBtn(h, data, context))
}
const cls = ['org-tree-node-label-inner']
let { labelWidth, labelClassName, selectedClassName, selectedKey, judge, NodeClass } = props
if (typeof labelWidth === 'number') {
labelWidth += 'px'
}
if (typeof labelClassName === 'function') {
labelClassName = labelClassName(data)
}
labelClassName && cls.push(labelClassName)
// add selected class and key from props
if (typeof selectedClassName === 'function') {
selectedClassName = selectedClassName(data)
}
selectedClassName && selectedKey && data[selectedKey] && cls.push(selectedClassName)
return h('div',
{
domProps: {
className: 'org-tree-node-label'
}
},
[
h('div',
{
domProps: {
className: ChangeTheColor(data, judge, NodeClass, props) + " org-tree-node-label-inner"
},
style: {
width: labelWidth
},
on: {
click: e => clickHandler && clickHandler(e, data),
mouseover: e => mouseOverHandler && mouseOverHandler(e, data),
mouseout: e => mouseOutHandler && mouseOutHandler(e, data)
}
}, childNodes)
]
)
}
function ChangeTheColor(e, judge, NodeClass, props) {
if (e.selected==0 && props.isSelect) {
return 'noselect-org'
} else {
if (judge !== "" && judge !== undefined && judge !== null && judge.swtich !== false) {
for (var k in judge) {
var a = (eval("e." + k))
if (NodeClass) {
for (let c = 0; c < NodeClass.length; c++) {
if (a === NodeClass[c])
return NodeClass[c]
else if (NodeClass.length - 1 == c)
return ""
}
} else {
return ""
}
}
} else {
return ""
}
}
}
// 创建 node 子节点
export const renderChildren = (h, list, context) => {
if (Array.isArray(list) && list.length) {
const children = list.map(item => {
return renderNode(h, item, context)
})
return h('div', {
domProps: {
className: 'org-tree-node-children'
}
}, children)
}
return ''
}
export const render = (h, context) => {
const { props } = context
return renderNode(h, props.data, context)
}
export default render

View File

@@ -0,0 +1,550 @@
<template>
<div class="org-tree-container outBox">
<!-- @mousewheel.prevent="hMouseWheel" -->
<div class="org-tree" :class="{ horizontal, collapsable,isSelect }" v-drag id="ddd">
<org-tree-node
:data="data"
:props="props"
:horizontal="horizontal"
:label-width="labelWidth"
:collapsable="collapsable"
:isSelect="isSelect"
:render-content="renderContent"
:selectedKey="2"
selectedClassName="select-org"
:label-class-name="labelClassName"
@on-expand="(e, data) => $emit('on-expand', e, data)"
@on-expand-mouseover="(e, data) => $emit('on-expand-mouseover', e, data)"
@on-expand-mouseout="(e, data) => $emit('on-expand-mouseout', e, data)"
@on-node-click="
(e, data) => {
$emit('on-node-click', e, data);
}
"
@on-node-mouseover="(e, data) => $emit('on-node-mouseover', e, data)"
@on-node-mouseout="(e, data) => $emit('on-node-mouseout', e, data)"
>
</org-tree-node>
</div>
</div>
</template>
<script>
import render from './node';
export default {
name: 'OrgTree',
components: {
OrgTreeNode: {
render,
functional: true
}
},
props: {
data: {
type: Object,
required: true
},
props: {
type: Object,
default: () => ({
label: 'label',
expand: 'expand',
children: 'children'
})
},
horizontal: Boolean,
collapsable: Boolean,
isSelect: Boolean,
renderContent: Function,
labelWidth: [String, Number],
labelClassName: [Function, String]
},
directives: {
drag: {
// 以下代码大家可以自己提出去封装一下
inserted: function (el) {
// el.style.cursor = 'move'
var firstTime = '';
var lastTime = '';
el.onmousedown = function (e) {
let disx = e.pageX - el.offsetLeft;
let disy = e.pageY - el.offsetTop;
document.getElementById('ddd').setAttribute('data-flag', false);
firstTime = new Date().getTime();
document.onmousemove = function (e) {
let x = e.pageX - disx;
let y = e.pageY - disy;
let maxX = document.body.clientWidth - parseInt(window.getComputedStyle(el).width);
let maxY = document.body.clientHeight - parseInt(window.getComputedStyle(el).height);
// el.style.left = x + 'px'
// el.style.top = y + 'px'
if (x < 0) {
x = 0;
} else if (x > maxX) {
x = maxX;
}
if (y < 0) {
y = 0;
} else if (y > maxY) {
y = maxY;
}
let et = e || window.event;
et.preventDefault();
};
document.onmouseup = function () {
lastTime = new Date().getTime();
if (lastTime - firstTime < 150) {
document.getElementById('ddd').setAttribute('data-flag', true);
}
document.onmousemove = document.onmouseup = null;
};
};
}
}
},
methods: {
hMouseWheel(ev) {
// 缩放功能
var ev = ev || window.event;
var down = true; // 定义一个标志,当滚轮向下滚时,执行一些操作
down = ev.wheelDelta ? ev.wheelDelta < 0 : ev.detail > 0;
var scal = 1;
var oDiv = document.getElementById('ddd');
if (down) {
// 鼠标滚轮向下放大
// scal = (parseFloat(scal) + 0.01).toFixed(2);
scal = scal;
oDiv.style.transform = 'scale(' + scal + ')'; //scale()在这里要使用拼接的方式才能生效
oDiv.style.transformOrigin = '0 0';
} else {
// 鼠标滚轮向上缩小
if (scal == 0.01) {
scal = 0.01;
return;
} else {
// scal = (parseFloat(scal) - 0.01).toFixed(2);
scal = scal - 0.3;
}
oDiv.style.transform = 'scale(' + scal + ')'; //scale()在这里要使用拼接的方式才能生效。
oDiv.style.transformOrigin = '0 0';
}
if (ev.preventDefault) {
/*FF 和 Chrome*/
ev.preventDefault(); // 阻止默认事件
}
return false;
}
}
};
</script>
<style lang="less" scoped>
.outBox {
height: 100%;
width: 100%;
position: relative;
overflow: hidden;
}
#ddd {
height: 100%;
// width:100%;
position: absolute;
overflow: hidden;
// left: 20%; // 打开tree在中间位置弊端是添加节点整个tree不会自动向左移动造成左边留白
}
.org-tree-container {
display: inline-block;
padding: 15px;
background-color: #fff;
}
.org-tree {
display: table;
text-align: center;
}
.org-tree:before,
.org-tree:after {
content: '';
display: table;
}
.org-tree:after {
clear: both;
}
.org-tree-node,
.org-tree-node-children {
position: relative;
margin: 0;
padding: 0;
list-style-type: none;
}
.org-tree-node:before,
.org-tree-node-children:before,
.org-tree-node:after,
.org-tree-node-children:after {
transition: all 0.35s;
}
.org-tree-node-label {
position: relative;
display: inline-block;
}
.org-tree-node-label .org-tree-node-label-inner {
cursor: pointer;
text-align: center;
border-radius: 3px;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
// tree节点不换行
// padding: 6px 20px;
// white-space: nowrap;
// tree节点换行
padding: 2px 10px;
width: auto;
word-wrap: break-word;
}
.org-tree-node-btn {
position: absolute;
top: 100%;
font-size: 12px;
left: 50%;
width: 20px;
height: 20px;
z-index: 10;
margin-left: -11px;
margin-top: 9px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 50%;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
cursor: pointer;
transition: all 0.35s ease;
}
.org-tree-node-btn:hover {
background-color: #e7e8e9;
transform: scale(1.15);
}
.org-tree-node-btn:before,
.org-tree-node-btn:after {
content: '';
position: absolute;
}
.org-tree-node-btn:before {
top: 50%;
left: 4px;
right: 4px;
height: 0;
border-top: 1px solid #ccc;
}
.org-tree-node-btn:after {
top: 4px;
left: 50%;
bottom: 4px;
width: 0;
border-left: 1px solid #ccc;
}
.org-tree-node-btn.expanded:after {
border: none;
}
.org-tree-node {
padding-top: 20px;
display: table-cell;
vertical-align: top;
}
.org-tree-node.is-leaf,
.org-tree-node.collapsed {
padding-left: 10px;
padding-right: 10px;
}
.org-tree-node:before,
.org-tree-node:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 19px;
}
.org-tree-node:after {
left: 50%;
border-left: 1px solid #ddd;
}
.org-tree-node:not(:first-child):before,
.org-tree-node:not(:last-child):after {
border-top: 1px solid #ddd;
}
.collapsable .org-tree-node.collapsed {
padding-bottom: 30px;
}
.collapsable .org-tree-node.collapsed .org-tree-node-label:after {
content: '';
position: absolute;
top: 100%;
left: 0;
width: 50%;
height: 20px;
border-right: 1px solid #ddd;
}
.org-tree > .org-tree-node {
padding-top: 0;
}
.org-tree > .org-tree-node:after {
border-left: 0;
}
.org-tree-node-children {
padding-top: 20px;
display: table;
}
.org-tree-node-children:before {
content: '';
position: absolute;
top: 0;
left: 50%;
width: 0;
height: 20px;
border-left: 1px solid #ddd;
}
.org-tree-node-children:after {
content: '';
display: table;
clear: both;
}
.horizontal .org-tree-node {
display: table-cell;
float: none;
padding-top: 0;
padding-left: 20px;
}
.horizontal .org-tree-node.is-leaf,
.horizontal .org-tree-node.collapsed {
padding-top: 4px;
padding-bottom: 4px;
}
.horizontal .org-tree-node:before,
.horizontal .org-tree-node:after {
width: 19px;
height: 50%;
}
.horizontal .org-tree-node:after {
top: 50%;
left: 0;
border-left: 0;
}
.horizontal .org-tree-node:only-child:before {
top: 1px;
border-bottom: 1px solid #ddd;
}
.horizontal .org-tree-node:not(:first-child):before,
.horizontal .org-tree-node:not(:last-child):after {
border-top: 0;
border-left: 1px solid #ddd;
}
.horizontal .org-tree-node:not(:only-child):after {
border-top: 1px solid #ddd;
}
.horizontal .org-tree-node .org-tree-node-inner {
display: table;
}
.horizontal .org-tree-node-label {
display: table-cell;
vertical-align: middle;
}
.horizontal.collapsable .org-tree-node.collapsed {
padding-right: 30px;
}
.horizontal.collapsable .org-tree-node.collapsed .org-tree-node-label:after {
top: 0;
left: 100%;
width: 20px;
height: 50%;
border-right: 0;
border-bottom: 1px solid #ddd;
}
.horizontal .org-tree-node-btn {
top: 50%;
left: 100%;
margin-top: -11px;
margin-left: 9px;
}
.horizontal > .org-tree-node:only-child:before {
border-bottom: 0;
}
.horizontal .org-tree-node-children {
display: table-cell;
padding-top: 0;
padding-left: 20px;
}
.horizontal .org-tree-node-children:before {
top: 50%;
left: 0;
width: 20px;
height: 0;
border-left: 0;
border-top: 1px solid #ddd;
}
.horizontal .org-tree-node-children:after {
display: none;
}
.horizontal .org-tree-node-children > .org-tree-node {
display: block;
}
/* 1 */
.org-tree-node > .org-tree-node-label > .org-tree-node-label-inner {
background-color: #4c97de;
color: #fff;
}
/* 2 */
.org-tree-node-children > .org-tree-node > .org-tree-node-label > .org-tree-node-label-inner {
background-color: #36a4fd;
color: #fff;
font-size: 14px;
}
/* 3 */
.org-tree-node-children > .org-tree-node > .org-tree-node-children > .org-tree-node > .org-tree-node-label > .org-tree-node-label-inner {
background-color: #c2d4ff;
color: #4665b0;
font-size: 12px;
}
/* 4 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #9dd4e9;
color: #4794b1;
font-size: 12px;
}
/* 第5层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #9ac4f7;
color: #1a75dd;
font-size: 12px;
}
/* 第6层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #eccefe;
color: #653ab5;
font-size: 12px;
}
/* 第7层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #ffe4b4;
color: #dea540;
font-size: 12px;
}
/* 第8层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #c8efef;
color: #76bebe;
font-size: 12px;
}
/* 第9层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #e6d7f3;
color: #bd99dd;
font-size: 12px;
}
/* 第10层 */
.org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-children
> .org-tree-node
> .org-tree-node-label
> .org-tree-node-label-inner {
background-color: #f4f7fe;
font-size: 12px;
color: #9eb1dd;
}
.noselect-org{
background-color: #f0f0f0 !important;
color: #aaa !important;
}
/* 每层多.org-tree-node-children>.org-tree-node */
/* 节点.org-tree-node-label>.org-tree-node-label-inner*/
</style>

View File

@@ -1,20 +1,20 @@
<template>
<div class="container" style="padding-bottom: 50px; width: 100%; height: 100%" v-loading="loading">
<div style="width: 100%; height: auto;">
<div style="width: 100%; height: auto">
<div
style="
width: 100%;
box-sizing: border-box;
margin-bottom: 20px;
background-color: #f4f4f5;
padding: 10px;
font-size: 12px;
color: #909399;
"
>
{{ $t('JournalCitationAnalysis.info') }} : {{ $t('JournalCitationAnalysis.wos') }} /
{{ $t('JournalCitationAnalysis.all') }}
</div>
style="
width: 100%;
box-sizing: border-box;
margin-bottom: 20px;
background-color: #f4f4f5;
padding: 10px;
font-size: 12px;
color: #909399;
"
>
{{ $t('JournalCitationAnalysis.info') }} : {{ $t('JournalCitationAnalysis.wos') }} /
{{ $t('JournalCitationAnalysis.all') }}
</div>
<el-table :data="dataList" border class="msg-table" empty-text="New Data (0)">
<el-table-column type="index" label="No." width="55" align="center"></el-table-column>
<!-- <el-table-column type="index" label="Issn" width="100" align="center">
@@ -35,7 +35,15 @@
align="center"
>
<template slot-scope="scope">
{{ scope.row.cite.month_num }}
<el-button type="primary" size="mini" @click="openDrawer(scope.row)" style="font-weight: bold">
{{ scope.row.cite.month_num }}</el-button
>
<!-- <p
style="padding: 0px 6px;display: inline-block;cursor: pointer; color: #409eff; background: #ecf5ff; border: 1px solid #b3d8ff"
>
{{ scope.row.cite.month_num }}
</p> -->
</template>
</el-table-column>
<el-table-column
@@ -46,7 +54,6 @@
align="center"
>
<template slot-scope="scope">
{{ scope.row.cite.year_num }}
</template>
</el-table-column>
@@ -89,19 +96,103 @@
{{ scope.row.cite.pre_year_article_num }}
</template>
</el-table-column>
<el-table-column
:label="`${$t('JournalCitationAnalysis.factor')}`
"
width="80"
align="center"
>
<el-table-column :label="`${$t('JournalCitationAnalysis.factor')}`" width="80" align="center">
<template slot-scope="scope">
{{ scope.row.cite.yc_if&& scope.row.cite.yc_if>0? scope.row.cite.yc_if.toFixed(2):0 }}
{{ scope.row.cite.yc_if && scope.row.cite.yc_if > 0 ? scope.row.cite.yc_if.toFixed(2) : 0 }}
</template>
</el-table-column>
</el-table>
</div>
<el-drawer :title="drawerTitle" :visible.sync="drawer" direction="rtl" :before-close="handleClose" size="78%">
<div style="padding: 0 20px; box-sizing: border-box">
<el-table
v-loading="JournalListLoad"
height="88vh"
:data="JournalList"
class="table"
ref="multipleTable"
header-cell-class-name="table-header"
empty-text="New messages (0)"
>
<el-table-column label="No." align="center" width="50">
<template slot-scope="scop">
{{ scop.$index + 1 }}
</template>
</el-table-column>
<el-table-column prop="title" :label="$t('JournalCitationAnalysis.ArticleInfo')">
<template slot-scope="scope">
<p style="color: #333; margin-bottom: 4px">
<span style="font-size: 14px; font-weight: 600">Article Tiltle : </span>
<span style="font-size: 14px"> {{ scope.row.article_name }}</span>
</p>
<p>
<span style="font-size: 14px; font-weight: 600">Author : </span>
<span style="font-size: 14px">{{ scope.row.author }}</span>
</p>
<p>
<span style="font-size: 13px; font-weight: 500; color: #888"
>{{ $t('paperArticleCount.Periodroll') }} :
</span>
<span style="font-size: 13px; color: #aaa">( {{ scope.row.vol }} )</span>
</p>
<p>
<span style="font-size: 14px; color: #006699; font-weight: 500">Doi : </span>
<span style="font-size: 14px; color: #006699 !important; font-weight: 500">{{ scope.row.doi }}</span>
</p>
</template>
</el-table-column>
<el-table-column :label="$t('citeList.is_wos')" width="80" align="center">
<template slot-scope="scope">
<span v-if="scope.row.is_wos == 0">{{ $t('citeList.is_china0') }}</span>
<p v-if="scope.row.is_wos == 1">{{ $t('citeList.yes') }}</p>
<p v-if="scope.row.is_wos == 2">{{ $t('citeList.no') }}</p>
</template>
</el-table-column>
<el-table-column :label="$t('citeList.is_china')" width="80" align="center">
<template slot-scope="scope">
<span v-if="scope.row.is_wos == 0">{{ $t('citeList.is_china0') }}</span>
<p v-if="scope.row.is_wos == 1">{{ $t('citeList.yes') }}</p>
<p v-if="scope.row.is_wos == 2">{{ $t('citeList.no') }}</p>
</template>
</el-table-column>
<el-table-column :label="$t('partyRole.status')" width="100" align="center">
<template slot-scope="scope">
<span
style="
padding: 2px 4px;
border-radius: 2px;
margin-left: 10px;
font-size: 12px;
color: #909399;
background: #f4f4f5;
border-color: #d3d4d6;
float: right;
"
v-if="
scope.row.state == 0 ||
scope.row.state == 1 ||
scope.row.state == 2 ||
scope.row.state == 3 ||
scope.row.state == 4 ||
scope.row.state == 5 ||
scope.row.state == 6
"
>
<!-- {{ scope.row.link ?$t('partyRole.Published') : '' }} -->
{{ $t(`artstate.state${scope.row.state}`) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('citeList.factor')" width="80" align="center">
<template slot-scope="scope">
<span style="color: #006699; font-weight: bold">{{ scope.row.factor ? scope.row.factor : '-' }}</span>
</template>
</el-table-column>
</el-table>
</div>
</el-drawer>
</div>
</template>
@@ -111,9 +202,14 @@ const jAtableY = () => import('@/components/common/journalArticleTable');
export default {
data() {
return {
drawerTitle: '',
drawer: false,
lang: !localStorage.getItem('langs') || localStorage.getItem('langs') == 'en' ? 'en' : 'zh',
loading: false,
dataList: [],
JournalList: [],
JournalListLoad: false,
currentData: {},
p_year: new Date().getFullYear() - 1,
year: new Date().getFullYear(),
month: new Date().getMonth() + 1
@@ -129,6 +225,43 @@ export default {
this.$forceUpdate();
},
methods: {
getJournalList() {
this.JournalListLoad = true;
this.JournalList = [];
this.$api
.post('api/Monitor/getCiteListForEditorMonth', {
issn: this.currentData.issn
})
.then(async (res) => {
this.JournalListLoad = false;
if (res.code == 0) {
this.JournalList = res.data.list;
console.log('this.AssociatedJournalList at line 234:', this.AssociatedJournalList);
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.JournalListLoad = false;
this.$message.error(err);
});
},
openDrawer(data) {
this.currentData = data;
if (this.currentData) {
this.drawerTitle = `${this.currentData.title} ${
this.lang == 'en'
? this.$t('JournalCitationAnalysis.cite') + this.getMonthName(this.month)
: this.month + '月' + this.$t('JournalCitationAnalysis.cite')
} ( ${this.currentData.cite.month_num} )`;
}
this.drawer = true;
this.getJournalList();
},
handleClose() {
this.drawer = false;
},
getMonthName(month) {
const months = [
'January',

View File

@@ -0,0 +1,688 @@
<template>
<div id="app">
<!-- <el-button type="primary" @click="horizontal = !horizontal">切换tree方向</el-button> -->
<div style="overflow: hidden">
<span style="font-size: 14px;font-weight: 700; color: #333; margin: 0 10px 0 0">{{ this.$t('sidebar.GroupClassification') }} </span>
<!-- <span style="font-size: 14px; color: #606266; margin: 0 10px 0 0">{{ this.$t('sidebar.GroupClassification')}}: </span>
<el-select
v-model="dataForm.journal_id"
placeholder="Please select a journal"
@change="handleSelectJournal"
style="width: 220px; margin-right: 35px"
>
<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
</el-select> -->
<div
@click="toggleExpand(data, true)"
style="float: right; line-height: 32px; color: #006699; font-size: 12px; font-weight: 700; margin-right: 20px"
>
{{ $t('GroupClassification.ExpandAll') }}
</div>
</div>
<org-tree
id="orgTreeNode"
:data="data"
:horizontal="horizontal"
collapsable
:render-content="renderContent"
@on-expand="onExpand"
@on-node-mouseover="onMouseover"
@on-node-mouseout="onMouseout"
@on-expand-mouseover="Mouseover"
@on-expand-mouseout="Mouseout"
@on-node-click="cccc"
>
</org-tree>
<div
class="floating"
v-show="isShowF && bd && this.currentTreeData.id != 'abc0'"
@mouseover="
() => {
isShowF = true;
}
"
@mouseout="
() => {
isShowF = false;
}
"
@mousewheel.prevent="mouseWheelDia"
>
<p @click="addOrEdit(0)">{{ $t('GroupClassification.add') }}</p>
<p @click="addOrEdit(1)">{{ $t('GroupClassification.edit') }}</p>
<p @click="del">{{ $t('GroupClassification.delete') }}</p>
<p @click="openJournal">{{ $t('GroupClassification.AssociatedJournal') }}</p>
</div>
<!-- 增加/编辑弹层 -->
<el-dialog
:title="isEdit == 0 ? $t('GroupClassification.add') : $t('GroupClassification.edit')"
v-if="dialogVisible"
:visible="dialogVisible"
@close="clearDialog"
show-close
:close-on-click-modal="false"
custom-class="addOrEditDia"
width="35%"
>
<div class="tips">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm" @submit.native.prevent label-width="120px">
<el-form-item :label="$t('GroupClassification.major_current')" v-if="isEdit == 0">
{{ this.currentTreeData.label }}
</el-form-item>
<el-form-item prop="major_title" :label="$t('GroupClassification.major_title')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_title"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="nickname" :label="$t('GroupClassification.nickname')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.nickname"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="major_sort" :label="$t('GroupClassification.sort')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_sort"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="small" type="info" @click="dialogVisible = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="small" type="primary" @click="confirm">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
<!-- 删除 -->
<el-dialog
:title="$t('GroupClassification.delete')"
v-if="dialogVisible2"
:visible="dialogVisible2"
@close="clearDialog"
custom-class="delDia"
width="35%"
>
<div class="tips">
<p style="text-align: left">{{ $t('GroupClassification.deleteInfo') }} {{ this.currentTreeData.label }} ?</p>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="mini" type="info" @click="dialogVisible2 = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="mini" type="primary" @click="confimdelete">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
<el-drawer
:title="this.currentTreeData.label + ' ' + $t('GroupClassification.AssociatedJournal')"
:visible.sync="drawer"
direction="rtl"
:before-close="handleClose"
size="50%"
>
<div style="padding: 0 20px; box-sizing: border-box">
<el-table
:data="AssociatedJournalList"
class="table"
ref="multipleTable"
header-cell-class-name="table-header"
empty-text="New messages (0)"
>
<el-table-column label="No." align="center" width="50">
<template slot-scope="scop">
{{ scop.$index + 1 }}
</template>
</el-table-column>
<el-table-column prop="title" label="title"></el-table-column>
<el-table-column prop="issn" width="160" label="issn"></el-table-column>
<el-table-column label=" " width="80" align="center">
<template slot-scope="scope">
<!-- <el-button plain type="primary" icon="el-icon-edit" @click="handleEdit(scope.row)">Edit Message</el-button> -->
<!-- <p @click="addOrEdit(0)" v-if="scope.row.selected==0">{{ $t('GroupClassification.bind') }}</p> -->
<p
@click="
changeBind({
...scope.row,
selected: 1
})
"
style="color: red; cursor: pointer"
>
{{ $t('GroupClassification.Unbind') }}
</p>
</template>
</el-table-column>
</el-table>
</div>
</el-drawer>
</div>
</template>
<script>
import OrgTree from '@/components/org-tree';
import bus from '@/components/common/bus';
export default {
name: 'app',
components: {
OrgTree
},
directives: {
focus: {
inserted: function (el) {
el.querySelector('input').focus();
}
}
},
data() {
return {
AssociatedJournalList: [],
drawer: false,
bd: true,
ruleForm: {
major_title: '',
nickname: ''
},
rules: {
major_title: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
// nickname: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
},
dialogVisible: false,
dialogVisible2: false,
isShowF: false,
data: {
id: 'abc0',
label: this.$t('sidebar.GroupClassification'),
leave: 1, // tree层级
children: []
},
horizontal: true,
collapsable: true,
isEdit: 0,
currentTreeData: {},
lastId: 11,
labelClassName: 'bg-white',
urlList: {
list: 'api/Major/getMajorList',
add: 'api/Major/addMajor',
edit: 'api/Major/editMajor',
delete: 'api/Major/delMajor',
AssociatedJournalList: 'api/Major/getJournalsForMajor',
bind: 'api/Major/addJournalMajor',
unbind: 'api/Major/delJournalMajor'
}
};
},
watch: {
dialogVisible: {
handler(newV, oldV) {
if (newV == false) {
this.ruleForm = {};
}
}
}
},
async created() {
const a = this.numFormatter(9999999999);
console.log(a);
await this.getDate();
},
async activated() {
await this.getDate();
},
methods: {
changeBind(b) {
var BindInfo = b.selected == 0 ? this.$t('GroupClassification.BindInfo') : this.$t('GroupClassification.UnBindInfo');
this.$confirm(`${this.$t('GroupClassification.JournalBindInfo')} ${b.title}${BindInfo}`, '提示', {
confirmButtonText: this.$t('GroupClassification.submit'),
dangerouslyUseHTMLString: true,
cancelButtonText: this.$t('GroupClassification.cancel'),
type: 'warning'
})
.then(() => {
var url = '';
if (b.selected == 1) {
url = this.urlList.unbind;
} else if (b.selected == 0) {
url = this.urlList.bind;
}
url;
console.log('url at line 278:', url);
this.$api
.post(url, {
journal_issn: b.issn,
major_id: this.currentTreeData.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
this.$nextTick(async () => {
setTimeout(async () => {
await this.getAssociatedJournalList();
}, 200);
});
})
.catch(() => {
// this.$message({
// type: 'info',
// message: this.$t('GroupClassification.cancel')
// });
});
},
handleClose() {
this.drawer = false;
},
getAssociatedJournalList() {
this.$api
.post(this.urlList.AssociatedJournalList, {
major_id: this.currentTreeData.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.AssociatedJournalList = res.data.list;
console.log('this.AssociatedJournalList at line 234:', this.AssociatedJournalList);
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
openJournal() {
this.drawer = true;
// AssociatedJournalList
this.getAssociatedJournalList();
},
renameKeys(obj, oldKey, newKey) {
if (obj[oldKey]) {
obj[newKey] = obj[oldKey];
delete obj[oldKey];
}
for (let k in obj) {
if (typeof obj[k] === 'object') {
this.renameKeys(obj[k], oldKey, newKey);
}
}
},
// 获取数据
async getDate() {
this.$api
.post(this.urlList.list, {})
.then(async (res) => {
if (res.code == 0) {
this.data.children = res.data.majors;
await this.renameKeys(this.data.children, 'major_title', 'label');
await this.toggleExpand(this.data, true); // 调用全部展开
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
// 增加千分位
numFormatter(num) {
let res = num;
if (num && num !== null) {
res = num.toString().replace(/\d+/, (n) => {
return n.replace(/(\d)(?=(\d{3})+$)/g, ($1) => {
return $1 + ',';
});
});
}
return res;
},
cccc(a, b) {
// console.log(a);
// console.log(b);
},
mouseWheelDia() {
// bugfix 鼠标移入弹层滚动鼠标不能缩放bug
this.isShowF = false;
},
Mouseover() {
// 鼠标移入缩放icon
this.bd = false;
},
Mouseout() {
// 鼠标移出缩放icon
this.bd = true;
},
clearDialog() {
// 关闭添加/编辑/删除弹层
this.dialogVisible = false;
this.dialogVisible2 = false;
this.ruleForm.major_title = '';
},
addOrEdit(val) {
// 点击添加/编辑
// 新增val0编辑val1
this.dialogVisible = true;
this.isEdit = val;
// eslint-disable-next-line eqeqeq
if (val == 1) {
// 编辑回显
this.ruleForm = {
major_title: this.currentTreeData.label,
major_sort: this.currentTreeData.major_sort,
major_id: this.currentTreeData.major_id,
nickname: this.currentTreeData.nickname
};
} else {
this.ruleForm.pid = this.currentTreeData.major_id;
}
},
async confirm() {
// 添加/编辑的确定
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.isEdit == 1) {
// 编辑
// this.ruleForm.major_title =
// data.id = this.treeData.id;
// this.currentTreeData.label = data.label;
this.$api
.post(this.urlList.edit, {
major_title: this.ruleForm.major_title,
major_id: this.ruleForm.major_id,
major_sort: this.ruleForm.major_sort,
nickname: this.ruleForm.nickname
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 前端编辑数据
// loading.close();
} else {
this.$api
.post(this.urlList.add, {
major_title: this.ruleForm.major_title,
pid: this.ruleForm.pid,
major_sort: this.ruleForm.major_sort,
nickname: this.ruleForm.nickname
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 添加
// 前端添加数据,需要自己生成子级id,可以传数据的时候把最后一级id传过来,进行累加
// data.id = this.lastId++;
// // data.level = this.currentTreeData.level + 1;
// data.label = this.ruleForm.major_title;
// data.expand = true;
// const render = (formData) => {
// formData.some((item) => {
// if (item.id === this.currentTreeData.id) {
// if (item.children) {
// item.children.push(data);
// } else {
// this.$set(item, 'children', [data]);
// }
// } else if (item.children) {
// render(item.children);
// }
// });
// };
// const arr = [this.data];
// render(arr);
// this.data = arr[0];
// loading.close();
}
this.$nextTick(async () => {
setTimeout(async () => {
await this.getDate();
}, 200);
});
} else {
// loading.close();
}
});
},
del() {
this.dialogVisible2 = true;
},
async confimdelete() {
// 是否确定删除当前节点
// 前端删除 遍历原数据,删除匹配id数据
this.$api
.post(this.urlList.delete, {
major_id: this.currentTreeData.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
this.$nextTick(async () => {
setTimeout(async () => {
await this.getDate();
}, 200);
});
});
// const deleteData = (data) => {
// data.some((item, i) => {
// if (item.id === this.currentTreeData.id) {
// data.splice(i, 1);
// } else if (item.children) {
// deleteData(item.children);
// }
// });
// };
// const arr = [this.data];
// deleteData(arr);
// this.data = arr[0] ? arr[0] : {};
// this.dialogVisible2 = false;
// this.$message({
// type: 'success',
// message: '节点删除成功!'
// });
},
onMouseover(e, data) {
var collapse = localStorage.getItem('collapse');
var width = Number(e.clientX - (!collapse || collapse == 'false' ? 260 : 40));
// 鼠标移入树节点
this.currentTreeData = data; // 鼠标移入,该节点的所有数据
this.isShowF = true;
var floating = document.getElementsByClassName('floating')[0];
if (floating) {
floating.style.left = width + 'px';
floating.style.top = e.clientY - 80 + 'px';
}
},
onMouseout(e, data) {
// 鼠标移出树节点
this.isShowF = false;
},
renderContent(h, data) {
return data.label;
},
onExpand(e, data) {
// 节点展开收缩
// eslint-disable-next-line eqeqeq
if (data.leave == 1 && data.expand == true) {
// bugfix
var dom = document.getElementById('ddd');
(dom.style.top = '50%'), (dom.style.left = '8%');
}
if ('expand' in data) {
data.expand = !data.expand;
if (!data.expand && data.children) {
this.collapse(data.children);
}
} else {
this.$set(data, 'expand', true);
}
},
collapse(list) {
list.forEach((child) => {
if (child.expand) {
child.expand = false;
}
child.children && this.collapse(child.children);
});
},
toggleExpand(data, val) {
// 节点默认全部展开
var _this = this;
// console.log(data);
if (Array.isArray(data)) {
data.forEach(function (item) {
_this.$set(item, 'expand', val);
if (item.children) {
_this.toggleExpand(item.children, val);
}
});
} else {
this.$set(data, 'expand', val);
if (data.children) {
_this.toggleExpand(data.children, val);
}
}
}
}
};
</script>
<style lang="less" scoped>
.floating {
background: rgba(0, 0, 0, 0.7);
box-shadow: rgba(0, 0, 0, 0.2);
width: auto;
// height: 45px;
line-height: 24px;
// display: flex;
// justify-content: space-around;
position: absolute;
color: #fff;
border-radius: 5px;
box-sizing: border-box;
left: 0;
top: 0;
transition: all 0.3s;
z-index: 999;
font-size: 12px;
padding: 6px;
span {
cursor: pointer;
}
}
</style>
<style lang="less">
.addOrEditDia,
.delDia {
padding: 14px 18px 10px 18px;
border-radius: 4px !important;
.el-dialog__header {
display: flex;
justify-content: space-between;
padding: 20px 0 !important;
}
.el-dialog__body {
padding: 0;
padding-top: 20px;
// margin-top: 37px;
}
.el-dialog__footer {
padding: 27px 0 9px 0 !important;
}
.el-dialog__headerbtn {
position: static !important;
}
}
.bg-white {
background-color: white;
}
.bg-orange {
background-color: orange;
}
.bg-gold {
background-color: gold;
}
.bg-gray {
background-color: gray;
}
.bg-lightpink {
background-color: lightpink;
}
.bg-chocolate {
background-color: chocolate;
}
.bg-tomato {
background-color: tomato;
}
.outBox {
height: calc(100% - 100px) !important;
margin-top: 10px;
width: calc(100% - 40px) !important;
overflow: auto !important;
}
</style>

View File

@@ -0,0 +1,648 @@
<template>
<div id="app">
<!-- <el-button type="primary" @click="horizontal = !horizontal">切换tree方向</el-button> -->
<div style="overflow: hidden">
<span style="font-size: 14px;font-weight: 700; color: #606266; margin: 0 10px 0 0">{{ $t('GroupClassification.Journal') }}: </span>
<el-select
v-model="dataForm.journal_id"
placeholder="Please select a journal"
@change="handleSelectJournal"
style="width: 220px; margin-right: 35px"
>
<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
</el-select>
<div
@click="toggleExpand(data, true)"
style="float: right; line-height: 32px; color: #006699; font-size: 12px; font-weight: 700; margin-right: 20px"
>
{{ $t('GroupClassification.ExpandAll') }}
</div>
</div>
<org-tree
id="orgTreeNode"
:data="data"
:horizontal="horizontal"
isSelect
collapsable
:render-content="renderContent"
@on-expand="onExpand"
@on-node-mouseover="onMouseover"
@on-node-mouseout="onMouseout"
@on-expand-mouseover="Mouseover"
@on-expand-mouseout="Mouseout"
@on-node-click="cccc"
>
</org-tree>
<!-- <div
class="floating"
v-show="isShowF && bd&&this.currentTreeData.id!='abc0'"
@mouseover="
() => {
isShowF = true;
}
"
@mouseout="
() => {
isShowF = false;
}
"
@mousewheel.prevent="mouseWheelDia"
>
<p @click="addOrEdit(0)">{{ $t('GroupClassification.bind') }}</p>
<p @click="addOrEdit(1)">{{ $t('GroupClassification.Unbind') }}</p>
</div> -->
<!-- 增加/编辑弹层 -->
<el-dialog
:title="isEdit == 0 ? $t('GroupClassification.add') : $t('GroupClassification.edit')"
v-if="dialogVisible"
:visible="dialogVisible"
@close="clearDialog"
show-close
:close-on-click-modal="false"
custom-class="addOrEditDia"
width="35%"
>
<div class="tips">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm" @submit.native.prevent label-width="120px">
<el-form-item :label="$t('GroupClassification.major_current')" v-if="isEdit == 0">
{{ this.currentTreeData.label }}
</el-form-item>
<el-form-item prop="major_title" :label="$t('GroupClassification.major_title')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_title"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="nickname" :label="$t('GroupClassification.nickname')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.nickname"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="major_sort" :label="$t('GroupClassification.sort')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_sort"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="small" type="info" @click="dialogVisible = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="small" type="primary" @click="confirm">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
<!-- 删除 -->
<el-dialog
:title="$t('GroupClassification.delete')"
v-if="dialogVisible2"
:visible="dialogVisible2"
@close="clearDialog"
custom-class="delDia"
width="35%"
>
<div class="tips">
<p style="text-align: left">{{ $t('GroupClassification.deleteInfo') }} {{ this.currentTreeData.label }} ?</p>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="mini" type="info" @click="dialogVisible2 = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="mini" type="primary" @click="confimdelete">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
</div>
</template>
<script>
import OrgTree from '@/components/org-tree';
import bus from '@/components/common/bus';
export default {
name: 'app',
components: {
OrgTree
},
directives: {
focus: {
inserted: function (el) {
el.querySelector('input').focus();
}
}
},
data() {
return {
dataForm: {},
edit_id: localStorage.getItem('U_id'),
currentJournal: {},
df_jour: [],
bd: true,
ruleForm: {
major_title: '',
nickname: ''
},
rules: {
major_title: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
// nickname: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
},
dialogVisible: false,
dialogVisible2: false,
isShowF: false,
data: {
id: 'abc0',
label: this.$t('sidebar.GroupClassification'),
leave: 1, // tree层级
children: []
},
horizontal: true,
collapsable: true,
isSelect: true,
isEdit: 0,
currentTreeData: {},
lastId: 11,
labelClassName: 'bg-white',
urlList: {
list: 'api/Major/getJournalMajorInAll',
bind: 'api/Major/addJournalMajor',
unbind: 'api/Major/delJournalMajor'
}
};
},
watch: {
dialogVisible: {
handler(newV, oldV) {
if (newV == false) {
this.ruleForm = {};
}
}
},
},
async created() {
const a = this.numFormatter(9999999999);
console.log(a);
await this.getSelect();
},
async activated() {
const a = this.numFormatter(9999999999);
console.log(a);
await this.getSelect();
},
methods: {
// 获取下拉值
async getSelect() {
var that = this;
this.$api
.post('/api/Journal/getAllJournal', {})
.then(async (res) => {
if (res.code == 0) {
this.df_jour = res.data.journals;
this.dataForm.journal_id = this.df_jour[0].journal_id;
this.currentJournal = this.df_jour[0];
this.$nextTick(async () => {
await that.getDate();
});
// this.getDate();
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
async handleSelectJournal(e) {
var data = this.df_jour.find((v) => v.journal_id == e);
this.currentJournal = data;
console.log('this.currentJournal at line 221:', this.currentJournal);
await this.getDate();
this.$forceUpdate();
},
renameKeys(obj, oldKey, newKey) {
if (obj[oldKey]) {
obj[newKey] = obj[oldKey];
delete obj[oldKey];
}
for (let k in obj) {
if (typeof obj[k] === 'object') {
this.renameKeys(obj[k], oldKey, newKey);
}
}
},
// 获取数据
async getDate() {
console.log('getDate at line 251:', 'getDate');
this.$api
.post(this.urlList.list, { journal_issn: this.currentJournal.issn })
.then(async (res) => {
if (res.code == 0) {
this.data.children = res.data.majors;
await this.renameKeys(this.data.children, 'major_title', 'label');
await this.toggleExpand(this.data, true); // 调用全部展开
this.$forceUpdate();
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
// 增加千分位
numFormatter(num) {
let res = num;
if (num && num !== null) {
res = num.toString().replace(/\d+/, (n) => {
return n.replace(/(\d)(?=(\d{3})+$)/g, ($1) => {
return $1 + ',';
});
});
}
return res;
},
async cccc(a, b) {
// console.log('a at line 274:', a);
console.log('b at line 270:', b);
// isShowF && bd
console.log('bd at line 272:', this.isShowF, this.bd);
if (this.isShowF && this.bd&&this.currentTreeData.id!='abc0') {
var BindInfo = b.selected == 0 ? this.$t('GroupClassification.BindInfo') : this.$t('GroupClassification.UnBindInfo');
this.$confirm(`${this.$t('GroupClassification.JournalBindInfo')} ${this.currentJournal.title}${BindInfo}`, '提示', {
confirmButtonText: this.$t('GroupClassification.submit'),
dangerouslyUseHTMLString: true,
cancelButtonText: this.$t('GroupClassification.cancel'),
type: 'warning'
})
.then(() => {
var url = '';
if (b.selected == 1) {
url = this.urlList.unbind;
} else if (b.selected == 0) {
url = this.urlList.bind;
}
url;
console.log('url at line 278:', url);
this.$api
.post(url, {
journal_issn: this.currentJournal.issn,
major_id: b.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
this.$nextTick(async () => {
setTimeout(async () => {
await this.getDate();
}, 200);
});
})
.catch(() => {
// this.$message({
// type: 'info',
// message: this.$t('GroupClassification.cancel')
// });
});
}
},
mouseWheelDia() {
// bugfix 鼠标移入弹层滚动鼠标不能缩放bug
this.isShowF = false;
},
Mouseover() {
// 鼠标移入缩放icon
this.bd = false;
},
Mouseout() {
// 鼠标移出缩放icon
this.bd = true;
},
clearDialog() {
// 关闭添加/编辑/删除弹层
this.dialogVisible = false;
this.dialogVisible2 = false;
this.ruleForm.major_title = '';
},
addOrEdit(val) {
// 点击添加/编辑
// 新增val0编辑val1
this.dialogVisible = true;
this.isEdit = val;
// eslint-disable-next-line eqeqeq
if (val == 1) {
// 编辑回显
this.ruleForm.major_title = this.currentTreeData.label;
this.ruleForm.major_sort = this.currentTreeData.major_sort;
this.ruleForm.major_id = this.currentTreeData.major_id;
this.ruleForm.nickname = this.currentTreeData.nickname;
} else {
this.ruleForm.pid = this.currentTreeData.major_id;
}
},
async confirm() {
// 添加/编辑的确定
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.isEdit == 1) {
// 编辑
// this.ruleForm.major_title =
// data.id = this.treeData.id;
// this.currentTreeData.label = data.label;
this.$api
.post(this.urlList.edit, {
major_title: this.ruleForm.major_title,
major_id: this.ruleForm.major_id,
major_sort: this.ruleForm.major_sort
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 前端编辑数据
// loading.close();
} else {
this.$api
.post(this.urlList.add, {
major_title: this.ruleForm.major_title,
pid: this.ruleForm.pid,
major_sort: this.ruleForm.major_sort
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 添加
// 前端添加数据,需要自己生成子级id,可以传数据的时候把最后一级id传过来,进行累加
// data.id = this.lastId++;
// // data.level = this.currentTreeData.level + 1;
// data.label = this.ruleForm.major_title;
// data.expand = true;
// const render = (formData) => {
// formData.some((item) => {
// if (item.id === this.currentTreeData.id) {
// if (item.children) {
// item.children.push(data);
// } else {
// this.$set(item, 'children', [data]);
// }
// } else if (item.children) {
// render(item.children);
// }
// });
// };
// const arr = [this.data];
// render(arr);
// this.data = arr[0];
// loading.close();
}
this.$nextTick(async () => {
await this.getDate();
});
} else {
// loading.close();
}
});
},
del() {
this.dialogVisible2 = true;
},
async confimdelete() {
// 是否确定删除当前节点
// 前端删除 遍历原数据,删除匹配id数据
this.$api
.post(this.urlList.delete, {
major_id: this.currentTreeData.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
this.$nextTick(async () => {
await this.getDate();
});
});
// const deleteData = (data) => {
// data.some((item, i) => {
// if (item.id === this.currentTreeData.id) {
// data.splice(i, 1);
// } else if (item.children) {
// deleteData(item.children);
// }
// });
// };
// const arr = [this.data];
// deleteData(arr);
// this.data = arr[0] ? arr[0] : {};
// this.dialogVisible2 = false;
// this.$message({
// type: 'success',
// message: '节点删除成功!'
// });
},
onMouseover(e, data) {
var collapse = localStorage.getItem('collapse');
var width = Number(e.clientX - (!collapse || collapse == 'false' ? 260 : 40));
// 鼠标移入树节点
this.currentTreeData = data; // 鼠标移入,该节点的所有数据
this.isShowF = true;
var floating = document.getElementsByClassName('floating')[0];
if (floating) {
floating.style.left = width + 'px';
floating.style.top = e.clientY - 80 + 'px';
}
},
onMouseout(e, data) {
// 鼠标移出树节点
this.isShowF = false;
},
renderContent(h, data) {
return data.label;
},
onExpand(e, data) {
// 节点展开收缩
// eslint-disable-next-line eqeqeq
if (data.leave == 1 && data.expand == true) {
// bugfix
var dom = document.getElementById('ddd');
(dom.style.top = '50%'), (dom.style.left = '8%');
}
if ('expand' in data) {
data.expand = !data.expand;
if (!data.expand && data.children) {
this.collapse(data.children);
}
} else {
this.$set(data, 'expand', true);
}
},
collapse(list) {
list.forEach((child) => {
if (child.expand) {
child.expand = false;
}
child.children && this.collapse(child.children);
});
},
toggleExpand(data, val) {
// 节点默认全部展开
var _this = this;
// console.log(data);
if (Array.isArray(data)) {
data.forEach(function (item) {
_this.$set(item, 'expand', val);
if (item.children) {
_this.toggleExpand(item.children, val);
}
});
} else {
this.$set(data, 'expand', val);
if (data.children) {
_this.toggleExpand(data.children, val);
}
}
}
}
};
</script>
<style lang="less" scoped>
.floating {
background: rgba(0, 0, 0, 0.7);
box-shadow: rgba(0, 0, 0, 0.2);
width: auto;
// height: 45px;
line-height: 24px;
// display: flex;
// justify-content: space-around;
position: absolute;
color: #fff;
border-radius: 5px;
box-sizing: border-box;
left: 0;
top: 0;
transition: all 0.3s;
z-index: 999;
font-size: 12px;
padding: 6px;
span {
cursor: pointer;
}
}
</style>
<style lang="less">
.addOrEditDia,
.delDia {
padding: 14px 18px 10px 18px;
border-radius: 4px !important;
.el-dialog__header {
display: flex;
justify-content: space-between;
padding: 20px 0 !important;
}
.el-dialog__body {
padding: 0;
padding-top: 20px;
// margin-top: 37px;
}
.el-dialog__footer {
padding: 27px 0 9px 0 !important;
}
.el-dialog__headerbtn {
position: static !important;
}
}
.bg-white {
background-color: white;
}
.bg-orange {
background-color: orange;
}
.bg-gold {
background-color: gold;
}
.bg-gray {
background-color: gray;
}
.bg-lightpink {
background-color: lightpink;
}
.bg-chocolate {
background-color: chocolate;
}
.bg-tomato {
background-color: tomato;
}
.outBox {
height: calc(100% - 100px) !important;
margin-top: 10px;
width: calc(100% - 40px) !important;
overflow: auto !important;
}
</style>

View File

@@ -0,0 +1,646 @@
<template>
<div id="app">
<!-- <el-button type="primary" @click="horizontal = !horizontal">切换tree方向</el-button> -->
<div style="overflow: hidden">
<span style="font-size: 14px;font-weight: 700; color: #606266; margin: 0 10px 0 0">{{ $t('GroupClassification.Journal') }}: </span>
<el-select
v-model="dataForm.journal_id"
placeholder="Please select a journal"
@change="handleSelectJournal"
style="width: 220px; margin-right: 35px"
>
<el-option v-for="item in df_jour" :label="item.title" :key="item.journal_id" :value="item.journal_id"></el-option>
</el-select>
<div
@click="toggleExpand(data, true)"
style="float: right; line-height: 32px; color: #006699; font-size: 12px; font-weight: 700; margin-right: 20px"
>
{{ $t('GroupClassification.ExpandAll') }}
</div>
</div>
<org-tree
id="orgTreeNode"
:data="data"
:horizontal="horizontal"
isSelect
collapsable
:render-content="renderContent"
@on-expand="onExpand"
@on-node-mouseover="onMouseover"
@on-node-mouseout="onMouseout"
@on-expand-mouseover="Mouseover"
@on-expand-mouseout="Mouseout"
@on-node-click="cccc"
>
</org-tree>
<!-- <div
class="floating"
v-show="isShowF && bd&&this.currentTreeData.id!='abc0'"
@mouseover="
() => {
isShowF = true;
}
"
@mouseout="
() => {
isShowF = false;
}
"
@mousewheel.prevent="mouseWheelDia"
>
<p @click="addOrEdit(0)">{{ $t('GroupClassification.bind') }}</p>
<p @click="addOrEdit(1)">{{ $t('GroupClassification.Unbind') }}</p>
</div> -->
<!-- 增加/编辑弹层 -->
<el-dialog
:title="isEdit == 0 ? $t('GroupClassification.add') : $t('GroupClassification.edit')"
v-if="dialogVisible"
:visible="dialogVisible"
@close="clearDialog"
show-close
:close-on-click-modal="false"
custom-class="addOrEditDia"
width="35%"
>
<div class="tips">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm" @submit.native.prevent label-width="120px">
<el-form-item :label="$t('GroupClassification.major_current')" v-if="isEdit == 0">
{{ this.currentTreeData.label }}
</el-form-item>
<el-form-item prop="major_title" :label="$t('GroupClassification.major_title')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_title"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="nickname" :label="$t('GroupClassification.nickname')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.nickname"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
<el-form-item prop="major_sort" :label="$t('GroupClassification.sort')">
<el-input
v-focus
:placeholder="$t('GroupClassification.enter')"
clearable
v-model="ruleForm.major_sort"
@keyup.enter.native="confirm"
></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="small" type="info" @click="dialogVisible = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="small" type="primary" @click="confirm">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
<!-- 删除 -->
<el-dialog
:title="$t('GroupClassification.delete')"
v-if="dialogVisible2"
:visible="dialogVisible2"
@close="clearDialog"
custom-class="delDia"
width="35%"
>
<div class="tips">
<p style="text-align: left">{{ $t('GroupClassification.deleteInfo') }} {{ this.currentTreeData.label }} ?</p>
</div>
<span slot="footer" class="dialog-footer">
<div class="tip-left">
<el-button size="mini" type="info" @click="dialogVisible2 = false">{{ $t('GroupClassification.cancel') }}</el-button>
<el-button size="mini" type="primary" @click="confimdelete">{{ $t('GroupClassification.submit') }}</el-button>
</div>
</span>
</el-dialog>
</div>
</template>
<script>
import OrgTree from '@/components/org-tree';
import bus from '@/components/common/bus';
export default {
name: 'app',
components: {
OrgTree
},
directives: {
focus: {
inserted: function (el) {
el.querySelector('input').focus();
}
}
},
data() {
return {
dataForm: {},
edit_id: localStorage.getItem('U_id'),
currentJournal: {},
df_jour: [],
bd: true,
ruleForm: {
major_title: '',
nickname: ''
},
rules: {
major_title: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
// nickname: [{ required: true, message: this.$t('GroupClassification.enter'), trigger: 'change' }]
},
dialogVisible: false,
dialogVisible2: false,
isShowF: false,
data: {
id: 'abc0',
label: this.$t('sidebar.GroupClassification'),
leave: 1, // tree层级
children: []
},
horizontal: true,
collapsable: true,
isSelect: true,
isEdit: 0,
currentTreeData: {},
lastId: 11,
labelClassName: 'bg-white',
urlList: {
list: 'api/Major/getJournalMajorInAll',
bind: 'api/Major/addJournalMajor',
unbind: 'api/Major/delJournalMajor'
}
};
},
watch: {
dialogVisible: {
handler(newV, oldV) {
if (newV == false) {
this.ruleForm = {};
}
}
}
},
async created() {
const a = this.numFormatter(9999999999);
console.log(a);
await this.getSelect();
},
async activated() {
const a = this.numFormatter(9999999999);
console.log(a);
await this.getSelect();
},
methods: {
// 获取下拉值
async getSelect() {
this.$api
.post('/api/Journal/getJournalByeditor', {
user_id: this.edit_id
})
.then(async (res) => {
if (res.code == 0) {
this.df_jour = res.data.journals;
this.dataForm.journal_id = this.df_jour[0].journal_id;
this.currentJournal = this.df_jour[0];
await this.getDate();
// this.getDate();
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
async handleSelectJournal(e) {
var data = this.df_jour.find((v) => v.journal_id == e);
this.currentJournal = data;
console.log('this.currentJournal at line 221:', this.currentJournal);
await this.getDate();
this.$forceUpdate();
},
renameKeys(obj, oldKey, newKey) {
if (obj[oldKey]) {
obj[newKey] = obj[oldKey];
delete obj[oldKey];
}
for (let k in obj) {
if (typeof obj[k] === 'object') {
this.renameKeys(obj[k], oldKey, newKey);
}
}
},
// 获取数据
async getDate() {
this.$api
.post(this.urlList.list, { journal_issn: this.currentJournal.issn })
.then(async (res) => {
if (res.code == 0) {
this.data.children = res.data.majors;
await this.renameKeys(this.data.children, 'major_title', 'label');
await this.toggleExpand(this.data, true); // 调用全部展开
this.$forceUpdate();
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
});
},
// 增加千分位
numFormatter(num) {
let res = num;
if (num && num !== null) {
res = num.toString().replace(/\d+/, (n) => {
return n.replace(/(\d)(?=(\d{3})+$)/g, ($1) => {
return $1 + ',';
});
});
}
return res;
},
async cccc(a, b) {
// console.log('a at line 274:', a);
console.log('b at line 270:', b);
// isShowF && bd
console.log('bd at line 272:', this.isShowF, this.bd);
if (this.isShowF && this.bd&&this.currentTreeData.id!='abc0') {
var BindInfo = b.selected == 0 ? this.$t('GroupClassification.BindInfo') : this.$t('GroupClassification.UnBindInfo');
this.$confirm(`${this.$t('GroupClassification.JournalBindInfo')} ${this.currentJournal.title}${BindInfo}`, '提示', {
confirmButtonText: this.$t('GroupClassification.submit'),
dangerouslyUseHTMLString: true,
cancelButtonText: this.$t('GroupClassification.cancel'),
type: 'warning'
})
.then(() => {
var url = '';
if (b.selected == 1) {
url = this.urlList.unbind;
} else if (b.selected == 0) {
url = this.urlList.bind;
}
url;
console.log('url at line 278:', url);
this.$api
.post(url, {
journal_issn: this.currentJournal.issn,
major_id: b.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
this.$nextTick(async () => {
setTimeout(async () => {
await this.getDate();
}, 200);
});
})
.catch(() => {
// this.$message({
// type: 'info',
// message: this.$t('GroupClassification.cancel')
// });
});
}
},
mouseWheelDia() {
// bugfix 鼠标移入弹层滚动鼠标不能缩放bug
this.isShowF = false;
},
Mouseover() {
// 鼠标移入缩放icon
this.bd = false;
},
Mouseout() {
// 鼠标移出缩放icon
this.bd = true;
},
clearDialog() {
// 关闭添加/编辑/删除弹层
this.dialogVisible = false;
this.dialogVisible2 = false;
this.ruleForm.major_title = '';
},
addOrEdit(val) {
// 点击添加/编辑
// 新增val0编辑val1
this.dialogVisible = true;
this.isEdit = val;
// eslint-disable-next-line eqeqeq
if (val == 1) {
// 编辑回显
this.ruleForm.major_title = this.currentTreeData.label;
this.ruleForm.major_sort = this.currentTreeData.major_sort;
this.ruleForm.major_id = this.currentTreeData.major_id;
this.ruleForm.nickname = this.currentTreeData.nickname;
} else {
this.ruleForm.pid = this.currentTreeData.major_id;
}
},
async confirm() {
// 添加/编辑的确定
this.$refs.ruleForm.validate(async (valid) => {
if (valid) {
if (this.isEdit == 1) {
// 编辑
// this.ruleForm.major_title =
// data.id = this.treeData.id;
// this.currentTreeData.label = data.label;
this.$api
.post(this.urlList.edit, {
major_title: this.ruleForm.major_title,
major_id: this.ruleForm.major_id,
major_sort: this.ruleForm.major_sort
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 前端编辑数据
// loading.close();
} else {
this.$api
.post(this.urlList.add, {
major_title: this.ruleForm.major_title,
pid: this.ruleForm.pid,
major_sort: this.ruleForm.major_sort
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
});
// 添加
// 前端添加数据,需要自己生成子级id,可以传数据的时候把最后一级id传过来,进行累加
// data.id = this.lastId++;
// // data.level = this.currentTreeData.level + 1;
// data.label = this.ruleForm.major_title;
// data.expand = true;
// const render = (formData) => {
// formData.some((item) => {
// if (item.id === this.currentTreeData.id) {
// if (item.children) {
// item.children.push(data);
// } else {
// this.$set(item, 'children', [data]);
// }
// } else if (item.children) {
// render(item.children);
// }
// });
// };
// const arr = [this.data];
// render(arr);
// this.data = arr[0];
// loading.close();
}
this.$nextTick(async () => {
await this.getDate();
});
} else {
// loading.close();
}
});
},
del() {
this.dialogVisible2 = true;
},
async confimdelete() {
// 是否确定删除当前节点
// 前端删除 遍历原数据,删除匹配id数据
this.$api
.post(this.urlList.delete, {
major_id: this.currentTreeData.major_id
})
.then(async (res) => {
if (res.code == 0) {
this.$message({
type: 'success',
message: res.msg
});
this.clearDialog();
} else {
this.$message({
type: 'error',
message: res.msg
});
}
this.$nextTick(async () => {
await this.getDate();
});
});
// const deleteData = (data) => {
// data.some((item, i) => {
// if (item.id === this.currentTreeData.id) {
// data.splice(i, 1);
// } else if (item.children) {
// deleteData(item.children);
// }
// });
// };
// const arr = [this.data];
// deleteData(arr);
// this.data = arr[0] ? arr[0] : {};
// this.dialogVisible2 = false;
// this.$message({
// type: 'success',
// message: '节点删除成功!'
// });
},
onMouseover(e, data) {
var collapse = localStorage.getItem('collapse');
var width = Number(e.clientX - (!collapse || collapse == 'false' ? 260 : 40));
// 鼠标移入树节点
this.currentTreeData = data; // 鼠标移入,该节点的所有数据
this.isShowF = true;
var floating = document.getElementsByClassName('floating')[0];
if(floating){
floating.style.left = width + 'px';
floating.style.top = e.clientY - 80 + 'px';
}
},
onMouseout(e, data) {
// 鼠标移出树节点
this.isShowF = false;
},
renderContent(h, data) {
return data.label;
},
onExpand(e, data) {
// 节点展开收缩
// eslint-disable-next-line eqeqeq
if (data.leave == 1 && data.expand == true) {
// bugfix
var dom = document.getElementById('ddd');
(dom.style.top = '50%'), (dom.style.left = '8%');
}
if ('expand' in data) {
data.expand = !data.expand;
if (!data.expand && data.children) {
this.collapse(data.children);
}
} else {
this.$set(data, 'expand', true);
}
},
collapse(list) {
list.forEach((child) => {
if (child.expand) {
child.expand = false;
}
child.children && this.collapse(child.children);
});
},
toggleExpand(data, val) {
// 节点默认全部展开
var _this = this;
// console.log(data);
if (Array.isArray(data)) {
data.forEach(function (item) {
_this.$set(item, 'expand', val);
if (item.children) {
_this.toggleExpand(item.children, val);
}
});
} else {
this.$set(data, 'expand', val);
if (data.children) {
_this.toggleExpand(data.children, val);
}
}
}
}
};
</script>
<style lang="less" scoped>
.floating {
background: rgba(0, 0, 0, 0.7);
box-shadow: rgba(0, 0, 0, 0.2);
width: auto;
// height: 45px;
line-height: 24px;
// display: flex;
// justify-content: space-around;
position: absolute;
color: #fff;
border-radius: 5px;
box-sizing: border-box;
left: 0;
top: 0;
transition: all 0.3s;
z-index: 999;
font-size: 12px;
padding: 6px;
span {
cursor: pointer;
}
}
</style>
<style lang="less">
.addOrEditDia,
.delDia {
padding: 14px 18px 10px 18px;
border-radius: 4px !important;
.el-dialog__header {
display: flex;
justify-content: space-between;
padding: 20px 0 !important;
}
.el-dialog__body {
padding: 0;
padding-top: 20px;
// margin-top: 37px;
}
.el-dialog__footer {
padding: 27px 0 9px 0 !important;
}
.el-dialog__headerbtn {
position: static !important;
}
}
.bg-white {
background-color: white;
}
.bg-orange {
background-color: orange;
}
.bg-gold {
background-color: gold;
}
.bg-gray {
background-color: gray;
}
.bg-lightpink {
background-color: lightpink;
}
.bg-chocolate {
background-color: chocolate;
}
.bg-tomato {
background-color: tomato;
}
.outBox {
height: calc(100% - 100px) !important;
margin-top: 10px;
width: calc(100% - 40px) !important;
overflow: auto !important;
}
</style>