|
|
@ -1,10 +1,10 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="app-container"> |
|
|
|
<div class="app-container"> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
|
|
|
<el-form ref="form1" :model="form" :rules="rules" label-width="100px"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-form-item label="产品线" prop="productLineCode"> |
|
|
|
<el-form-item label="产品线" prop="productLineCode"> |
|
|
|
<el-select v-model="form.productLineCode" placeholder="产品线" |
|
|
|
<el-select v-model="productLineCode" placeholder="产品线" |
|
|
|
@change="setAreaType" clearable> |
|
|
|
@change="setAreaType" clearable> |
|
|
|
<el-option |
|
|
|
<el-option |
|
|
|
v-for="line in dict.type.product_line" |
|
|
|
v-for="line in dict.type.product_line" |
|
|
@ -17,7 +17,7 @@ |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-form-item label="区域类型" prop="areaType"> |
|
|
|
<el-form-item label="区域类型" prop="areaType"> |
|
|
|
<el-select v-model="form.areaType" |
|
|
|
<el-select v-model="areaType" |
|
|
|
@change="setAreaLevel" placeholder="区域类型" clearable> |
|
|
|
@change="setAreaLevel" placeholder="区域类型" clearable> |
|
|
|
<el-option |
|
|
|
<el-option |
|
|
|
v-for="type in areaTypeList" |
|
|
|
v-for="type in areaTypeList" |
|
|
@ -29,42 +29,65 @@ |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-row> |
|
|
|
<el-row> |
|
|
|
|
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
|
|
|
|
<el-form-item> |
|
|
|
|
|
|
|
<el-button type="primary" @click="addArea">新 增</el-button> |
|
|
|
|
|
|
|
<el-button type="primary" @click="delArea">删 除</el-button> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
</el-col> |
|
|
|
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<!--区域树--> |
|
|
|
<!--区域树--> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<div class="head-container"> |
|
|
|
<div class="head-container"> |
|
|
|
<el-tree |
|
|
|
<!-- <el-tree |
|
|
|
:data="areaOptions" |
|
|
|
:data="areaOptions" |
|
|
|
|
|
|
|
node-key="id" |
|
|
|
|
|
|
|
:filter-node-method="filterNode" |
|
|
|
:props="defaultProps" |
|
|
|
:props="defaultProps" |
|
|
|
:expand-on-click-node="false" |
|
|
|
:expand-on-click-node="false" |
|
|
|
:filter-node-method="filterNode" |
|
|
|
|
|
|
|
ref="tree" |
|
|
|
ref="tree" |
|
|
|
node-key="id" |
|
|
|
|
|
|
|
default-expand-all |
|
|
|
default-expand-all |
|
|
|
highlight-current |
|
|
|
highlight-current |
|
|
|
@node-click="handleNodeClick" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
/> |
|
|
|
/>--> |
|
|
|
|
|
|
|
<el-input placeholder="输入区域名称" v-model="filterText" class="search"/> |
|
|
|
|
|
|
|
<el-tree |
|
|
|
|
|
|
|
:data="treeData" |
|
|
|
|
|
|
|
node-key="id" |
|
|
|
|
|
|
|
default-expand-all |
|
|
|
|
|
|
|
@node-click="handleLeftclick" |
|
|
|
|
|
|
|
@node-drag-start="handleDragStart" |
|
|
|
|
|
|
|
@node-drag-enter="handleDragEnter" |
|
|
|
|
|
|
|
@node-drag-leave="handleDragLeave" |
|
|
|
|
|
|
|
@node-drag-over="handleDragOver" |
|
|
|
|
|
|
|
@node-drag-end="handleDragEnd" |
|
|
|
|
|
|
|
@node-drop="handleDrop" |
|
|
|
|
|
|
|
@node-contextmenu="rightClick" |
|
|
|
|
|
|
|
:filter-node-method="filterNode" |
|
|
|
|
|
|
|
draggable :allow-drop="allowDrop" |
|
|
|
|
|
|
|
:allow-drag="allowDrag" ref="tree"> |
|
|
|
|
|
|
|
<span class="slot-t-node" slot-scope="{ node, data }"> |
|
|
|
|
|
|
|
<span :class="[data.id>= 99 ? 'slot-t-node--label' : '']">{{node.label}}</span> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</el-tree> |
|
|
|
|
|
|
|
<el-card class="box-card" ref="card" v-show="menuVisible"> |
|
|
|
|
|
|
|
<div @click="addSameLevelNode()" v-show="firstLevel"> |
|
|
|
|
|
|
|
<i class="el-icon-circle-plus-outline"></i> 同级增加 |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="add" @click="addChildNode()"> |
|
|
|
|
|
|
|
<i class="el-icon-circle-plus-outline"></i> 子级增加 |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="delete" @click="deleteNode()"> |
|
|
|
|
|
|
|
<i class="el-icon-remove-outline"></i> 删除节点 |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</el-card> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-col :span="8" :xs="24"> |
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px"> |
|
|
|
<el-form ref="form" :model="params" :rules="rules" label-width="100px"> |
|
|
|
<el-form-item label="区域编码" prop="areaCode"> |
|
|
|
<el-form-item label="区域编码" prop="areaCode"> |
|
|
|
<el-input v-model="form.areaCode" placeholder="请输入区域编码" /> |
|
|
|
<el-input v-model="params.areaCode" placeholder="请输入区域编码" maxlength="32"/> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="区域名称" prop="areaName"> |
|
|
|
<el-form-item label="区域名称" prop="areaName"> |
|
|
|
<el-input v-model="form.areaName" placeholder="请输入区域名称" /> |
|
|
|
<el-input v-model="params.areaName" placeholder="请输入区域名称" maxlength="64"/> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="区域层级" prop="areaLevel"> |
|
|
|
<el-form-item label="区域层级" prop="areaLevel"> |
|
|
|
<el-select v-model="form.areaLevel" placeholder="区域层级" clearable> |
|
|
|
<el-select v-model="params.areaLevel" placeholder="区域层级" clearable> |
|
|
|
<el-option |
|
|
|
<el-option |
|
|
|
v-for="level in areaLevelList" |
|
|
|
v-for="level in areaLevelList" |
|
|
|
:key="level.value" |
|
|
|
:key="level.value" |
|
|
@ -74,23 +97,23 @@ |
|
|
|
</el-select> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="上级区域" prop="parentName"> |
|
|
|
<el-form-item label="上级区域" prop="parentName"> |
|
|
|
<el-input v-model="form.parentName" placeholder="上级区域" disabled/> |
|
|
|
<el-input v-model="params.parentName" placeholder="上级区域" disabled/> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="区域状态" prop="status"> |
|
|
|
<el-form-item label="区域状态" prop="status"> |
|
|
|
<el-switch |
|
|
|
<el-switch |
|
|
|
v-model="form.status" |
|
|
|
v-model="params.status" |
|
|
|
active-value="1" |
|
|
|
active-value="1" |
|
|
|
inactive-value="0" |
|
|
|
inactive-value="0" |
|
|
|
></el-switch> |
|
|
|
></el-switch> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="显示顺序" prop="orderNum"> |
|
|
|
<el-form-item label="显示顺序" prop="orderNum"> |
|
|
|
<el-input v-model="form.orderNum" placeholder="请输入显示顺序" /> |
|
|
|
<el-input-number v-model="params.orderNum" :min="1" :max="100" label="显示顺序"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="区域说明" prop="areaDesc"> |
|
|
|
<el-form-item label="区域说明" prop="areaDesc"> |
|
|
|
<el-input v-model="form.areaDesc" type="textarea" placeholder="请输入内容" /> |
|
|
|
<el-input v-model="params.areaDesc" type="textarea" placeholder="请输入内容" maxlength="512"/> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-form-item v-show="btnFlag"> |
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button> |
|
|
|
<el-button key="submitBtn" type="primary" @click="submitForm">确 定</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
</el-form> |
|
|
|
</el-col> |
|
|
|
</el-col> |
|
|
@ -99,7 +122,7 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import {areaTreeSelect, getArea, addArea, updateArea} from "@/api/dhc/area"; |
|
|
|
import {areaTreeSelect, getArea, addArea, updateArea, delArea} from "@/api/dhc/area"; |
|
|
|
import {queryList} from "@/api/dhc/productLineArea"; |
|
|
|
import {queryList} from "@/api/dhc/productLineArea"; |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: "Area", |
|
|
|
name: "Area", |
|
|
@ -108,6 +131,8 @@ export default { |
|
|
|
return { |
|
|
|
return { |
|
|
|
// 遮罩层 |
|
|
|
// 遮罩层 |
|
|
|
loading: true, |
|
|
|
loading: true, |
|
|
|
|
|
|
|
// 按钮控制 |
|
|
|
|
|
|
|
btnFlag: false, |
|
|
|
// 选中数组 |
|
|
|
// 选中数组 |
|
|
|
ids: [], |
|
|
|
ids: [], |
|
|
|
// 非单个禁用 |
|
|
|
// 非单个禁用 |
|
|
@ -128,40 +153,69 @@ export default { |
|
|
|
title: "", |
|
|
|
title: "", |
|
|
|
// 是否显示弹出层 |
|
|
|
// 是否显示弹出层 |
|
|
|
open: false, |
|
|
|
open: false, |
|
|
|
// 表单参数 |
|
|
|
currentData: '', |
|
|
|
form: { |
|
|
|
currentNode: '', |
|
|
|
|
|
|
|
menuVisible: false, |
|
|
|
|
|
|
|
firstLevel: false, |
|
|
|
|
|
|
|
filterText: '', |
|
|
|
|
|
|
|
maxexpandId: 4, |
|
|
|
|
|
|
|
productLineCode: '', |
|
|
|
|
|
|
|
areaType: '', |
|
|
|
areaId: 0, |
|
|
|
areaId: 0, |
|
|
|
parentId: null, |
|
|
|
// 表单参数 |
|
|
|
areaCode: null, |
|
|
|
params: { |
|
|
|
areaName: null, |
|
|
|
parentId: 0, |
|
|
|
areaType: null, |
|
|
|
areaCode: '', |
|
|
|
areaLevel: null, |
|
|
|
areaName: '', |
|
|
|
orderNum: null, |
|
|
|
areaLevel: '', |
|
|
|
areaDesc: null, |
|
|
|
orderNum: 1, |
|
|
|
parentName: null, |
|
|
|
areaDesc: '', |
|
|
|
productLineCode: null, |
|
|
|
parentName: '', |
|
|
|
status: '1', |
|
|
|
status: '1', |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
form: {}, |
|
|
|
// 区域树选项 |
|
|
|
// 区域树选项 |
|
|
|
areaOptions: undefined, |
|
|
|
treeData: undefined, |
|
|
|
defaultProps: { |
|
|
|
defaultProps: { |
|
|
|
children: "children", |
|
|
|
children: "children", |
|
|
|
label: "label" |
|
|
|
label: "label" |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 表单校验 |
|
|
|
// 表单校验 |
|
|
|
rules: { |
|
|
|
rules: { |
|
|
|
|
|
|
|
areaCode: [ |
|
|
|
|
|
|
|
{ required: true, message: "区域编码不能为空", trigger: "blur" } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
areaName: [ |
|
|
|
|
|
|
|
{ required: true, message: "区域名称不能为空", trigger: "blur" } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
areaLevel: [ |
|
|
|
|
|
|
|
{ required: true, message: "区域层级不能为空", trigger: "blur" } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
orderNum: [ |
|
|
|
|
|
|
|
{ required: true, message: "显示顺序不能为空", trigger: "blur" } |
|
|
|
|
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
created() { |
|
|
|
this.getAreaTree(); |
|
|
|
this.reset(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
watch: { |
|
|
|
|
|
|
|
filterText(val) { |
|
|
|
|
|
|
|
this.$refs.tree.filter(val) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
/** 查询区域下拉树结构 */ |
|
|
|
/** 查询区域下拉树结构 */ |
|
|
|
getAreaTree() { |
|
|
|
getAreaTree() { |
|
|
|
this.loading = true; |
|
|
|
let queryParams = {productLineCode:this.productLineCode, areaType:this.areaType} |
|
|
|
areaTreeSelect(this.form).then(response => { |
|
|
|
areaTreeSelect(queryParams).then(response => { |
|
|
|
this.areaOptions = response.data; |
|
|
|
this.treeData = response.data; |
|
|
|
|
|
|
|
if (this.treeData.length == 0) { |
|
|
|
|
|
|
|
this.btnFlag = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.btnFlag = false; |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 筛选节点 |
|
|
|
// 筛选节点 |
|
|
@ -169,84 +223,378 @@ export default { |
|
|
|
if (!value) return true; |
|
|
|
if (!value) return true; |
|
|
|
return data.label.indexOf(value) !== -1; |
|
|
|
return data.label.indexOf(value) !== -1; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 节点单击事件 |
|
|
|
|
|
|
|
handleNodeClick(data) { |
|
|
|
|
|
|
|
this.form.areaId = data.id; |
|
|
|
|
|
|
|
this.getArea(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** 修改按钮操作 */ |
|
|
|
|
|
|
|
getArea(row) { |
|
|
|
|
|
|
|
this.reset(); |
|
|
|
|
|
|
|
const areaId = this.form.areaId; |
|
|
|
|
|
|
|
getArea(areaId).then(response => { |
|
|
|
|
|
|
|
this.form = response.data; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 表单重置 |
|
|
|
// 表单重置 |
|
|
|
reset() { |
|
|
|
reset() { |
|
|
|
this.form = { |
|
|
|
this.params = { |
|
|
|
areaId: 0, |
|
|
|
parentId: 0, |
|
|
|
parentId: null, |
|
|
|
areaCode: '', |
|
|
|
areaCode: null, |
|
|
|
areaName: '', |
|
|
|
areaName: null, |
|
|
|
areaLevel: '', |
|
|
|
areaType: null, |
|
|
|
orderNum: 1, |
|
|
|
areaLevel: null, |
|
|
|
areaDesc: '', |
|
|
|
orderNum: null, |
|
|
|
parentName: '', |
|
|
|
areaDesc: null, |
|
|
|
|
|
|
|
parentName: null, |
|
|
|
|
|
|
|
productLineCode: null, |
|
|
|
|
|
|
|
status: '1', |
|
|
|
status: '1', |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 联动区域类型 |
|
|
|
// 联动区域类型 |
|
|
|
setAreaType() { |
|
|
|
setAreaType() { |
|
|
|
let params = {productLineCode:this.form.productLineCode, areaType:'', type:'areaType'} |
|
|
|
let queryParams = {productLineCode:this.productLineCode, areaType:'', type:'areaType'} |
|
|
|
this.form.areaType = null; |
|
|
|
this.areaType = null; |
|
|
|
this.form.areaLevel = null; |
|
|
|
this.params.areaLevel = null; |
|
|
|
|
|
|
|
this.params.productLineCode = this.productLineCode; |
|
|
|
|
|
|
|
this.treeData = []; |
|
|
|
this.areaTypeList = []; |
|
|
|
this.areaTypeList = []; |
|
|
|
this.areaLevelList = []; |
|
|
|
this.areaLevelList = []; |
|
|
|
queryList(params).then(response => { |
|
|
|
queryList(queryParams).then(response => { |
|
|
|
this.areaTypeList = response; |
|
|
|
this.areaTypeList = response; |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.getAreaTree(); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 联动区域等级 |
|
|
|
// 联动区域等级 |
|
|
|
setAreaLevel() { |
|
|
|
setAreaLevel() { |
|
|
|
let params = {productLineCode:this.form.productLineCode, areaType:this.form.areaType, type:'areaLevel'} |
|
|
|
let queryParams = {productLineCode:this.productLineCode, areaType:this.areaType, type:'areaLevel'} |
|
|
|
this.form.areaLevel = null; |
|
|
|
this.params.areaLevel = null; |
|
|
|
|
|
|
|
this.params.areaType = this.areaType; |
|
|
|
|
|
|
|
this.treeData = []; |
|
|
|
this.areaLevelList = []; |
|
|
|
this.areaLevelList = []; |
|
|
|
queryList(params).then(response => { |
|
|
|
queryList(queryParams).then(response => { |
|
|
|
this.areaLevelList = response; |
|
|
|
this.areaLevelList = response; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
this.getAreaTree(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** 提交按钮 */ |
|
|
|
/** 提交按钮 */ |
|
|
|
submitForm() { |
|
|
|
submitForm() { |
|
|
|
this.$refs["form"].validate(valid => { |
|
|
|
this.$refs["form"].validate(valid => { |
|
|
|
if (valid) { |
|
|
|
if (valid) { |
|
|
|
if (this.form.areaId != null && this.form.areaId != 0) { |
|
|
|
this.params.areaId = this.areaId; |
|
|
|
updateArea(this.form).then(response => { |
|
|
|
this.params.areaType = this.areaType; |
|
|
|
|
|
|
|
this.params.productLineCode = this.productLineCode; |
|
|
|
|
|
|
|
if (this.areaId != null && this.areaId != 0) { |
|
|
|
|
|
|
|
updateArea(this.params).then(response => { |
|
|
|
this.$modal.msgSuccess("修改成功"); |
|
|
|
this.$modal.msgSuccess("修改成功"); |
|
|
|
this.open = false; |
|
|
|
this.btnFlag = false; |
|
|
|
this.getAreaTree(); |
|
|
|
this.getAreaTree(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
addArea(this.form).then(response => { |
|
|
|
addArea(this.params).then(response => { |
|
|
|
this.$modal.msgSuccess("新增成功"); |
|
|
|
this.$modal.msgSuccess("新增成功"); |
|
|
|
this.open = false; |
|
|
|
this.btnFlag = false; |
|
|
|
this.getAreaTree(); |
|
|
|
this.getAreaTree(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** 新增按钮操作 */ |
|
|
|
NodeBlur(Node, data) { |
|
|
|
addArea() { |
|
|
|
console.log(Node, data) |
|
|
|
|
|
|
|
if (data.label.length === 0) { |
|
|
|
|
|
|
|
this.$message.error('菜单名不可为空!') |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (data.isEdit) { |
|
|
|
|
|
|
|
this.$set(data, 'isEdit', false) |
|
|
|
|
|
|
|
console.log(data.isEdit) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
this.$refs['slotTreeInput' + data.id].$refs.input.focus() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** 删除按钮操作 */ |
|
|
|
allowDrop(draggingNode, dropNode, type) { |
|
|
|
delArea() { |
|
|
|
if (dropNode.data.label === '二级 3-1') { |
|
|
|
|
|
|
|
return type !== 'inner' |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
allowDrag(draggingNode) { |
|
|
|
|
|
|
|
return draggingNode.data.label.indexOf('三级 3-2-2') === -1 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 鼠标右击事件 |
|
|
|
|
|
|
|
rightClick(event, object, Node, element) { |
|
|
|
|
|
|
|
this.currentData = object |
|
|
|
|
|
|
|
this.currentNode = Node |
|
|
|
|
|
|
|
if (Node.level === 1) { |
|
|
|
|
|
|
|
this.firstLevel = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.firstLevel = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.menuVisible = true |
|
|
|
|
|
|
|
// let menu = document.querySelector('#card') |
|
|
|
|
|
|
|
// /* 菜单定位基于鼠标点击位置 */ |
|
|
|
|
|
|
|
// menu.style.left = event.clientX + 'px' |
|
|
|
|
|
|
|
// menu.style.top = event.clientY + 'px' |
|
|
|
|
|
|
|
document.addEventListener('click', this.foo) |
|
|
|
|
|
|
|
this.$refs.card.$el.style.left = event.clientX - 140 + 'px' |
|
|
|
|
|
|
|
this.$refs.card.$el.style.top = event.clientY - 140 + 'px' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 鼠标左击事件 |
|
|
|
|
|
|
|
handleLeftclick(data, node) { |
|
|
|
|
|
|
|
if (data.id != 0) { |
|
|
|
|
|
|
|
getArea(data.id).then(response => { |
|
|
|
|
|
|
|
this.areaId = response.data.areaId; |
|
|
|
|
|
|
|
this.params = response.data; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.reset(); |
|
|
|
|
|
|
|
this.areaId = 0; |
|
|
|
|
|
|
|
this.params.areaName = '新增区域'; |
|
|
|
|
|
|
|
if (node.level > 1) { |
|
|
|
|
|
|
|
this.params.parentId = node.parent.data.id; |
|
|
|
|
|
|
|
this.params.parentName = node.parent.data.label; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.btnFlag = true; |
|
|
|
|
|
|
|
this.foo() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 取消鼠标监听事件 菜单栏 |
|
|
|
|
|
|
|
foo() { |
|
|
|
|
|
|
|
this.menuVisible = false |
|
|
|
|
|
|
|
// 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了 |
|
|
|
|
|
|
|
document.removeEventListener('click', this.foo) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 增加同级节点事件 |
|
|
|
|
|
|
|
addSameLevelNode() { |
|
|
|
|
|
|
|
this.reset(); |
|
|
|
|
|
|
|
/*let id = Math.ceil(Math.random() * 100)*/ |
|
|
|
|
|
|
|
this.btnFlag = false; |
|
|
|
|
|
|
|
let data = { id: 0, label: '新增区域' } |
|
|
|
|
|
|
|
this.$refs.tree.append(data, this.currentNode.parent) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 增加子级节点事件 |
|
|
|
|
|
|
|
addChildNode() { |
|
|
|
|
|
|
|
if (this.currentNode.level >= 3) { |
|
|
|
|
|
|
|
this.$message.error('最多只支持三级!') |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.reset(); |
|
|
|
|
|
|
|
this.btnFlag = false; |
|
|
|
|
|
|
|
// let id = Math.ceil(Math.random() * 100) |
|
|
|
|
|
|
|
let data = { id: 0, label: '新增区域' } |
|
|
|
|
|
|
|
this.$refs.tree.append(data, this.currentNode) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 删除节点 |
|
|
|
|
|
|
|
deleteNode() { |
|
|
|
|
|
|
|
let that = this; |
|
|
|
|
|
|
|
if (this.areaId == 0) { |
|
|
|
|
|
|
|
that.$modal.msgSuccess("请选择要删除的区域"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (that.currentNode.label == '新增区域') { |
|
|
|
|
|
|
|
that.$refs.tree.remove(this.currentNode) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const areaId = this.areaId; |
|
|
|
|
|
|
|
that.$modal.confirm('是否确认删除区域编号为"' + that.params.areaName + '"的数据项?').then(function() { |
|
|
|
|
|
|
|
delArea(areaId).then(response => { |
|
|
|
|
|
|
|
that.$modal.msgSuccess("删除成功"); |
|
|
|
|
|
|
|
that.btnFlag = false; |
|
|
|
|
|
|
|
that.getAreaTree(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 编辑节点 |
|
|
|
|
|
|
|
editNode(data) { |
|
|
|
|
|
|
|
this.currentData = data ? data : this.currentData |
|
|
|
|
|
|
|
if (!this.currentData.isEdit) { |
|
|
|
|
|
|
|
this.$set(this.currentData, 'isEdit', true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 获取焦点 |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
this.$refs['slotTreeInput' + this.currentData.id].focus() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDragStart(node, ev) { |
|
|
|
|
|
|
|
console.log('drag start', node) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDragEnter(draggingNode, dropNode, ev) { |
|
|
|
|
|
|
|
console.log('tree drag enter: ', dropNode.label) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDragLeave(draggingNode, dropNode, ev) { |
|
|
|
|
|
|
|
console.log('tree drag leave: ', dropNode.label) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDragOver(draggingNode, dropNode, ev) { |
|
|
|
|
|
|
|
console.log('tree drag over: ', dropNode.label) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDragEnd(draggingNode, dropNode, dropType, ev) { |
|
|
|
|
|
|
|
console.log('tree drag end: ', dropNode && dropNode.label, dropType) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleDrop(draggingNode, dropNode, dropType, ev) { |
|
|
|
|
|
|
|
console.log('tree drop: ', dropNode.label, dropType) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped lang="less"> |
|
|
|
|
|
|
|
/* 点击节点时的选中颜色 */ |
|
|
|
|
|
|
|
.tree-container /deep/.el-tree-node.is-current > .el-tree-node__content { |
|
|
|
|
|
|
|
color: blue !important; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node__expand-icon.expanded { |
|
|
|
|
|
|
|
-webkit-transform: rotate(90deg); |
|
|
|
|
|
|
|
transform: rotate(90deg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-icon-caret-right:before { |
|
|
|
|
|
|
|
content: "\e791"; |
|
|
|
|
|
|
|
font-size: 18px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node__expand-icon { |
|
|
|
|
|
|
|
margin-left: 15px; |
|
|
|
|
|
|
|
padding: 0px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node__expand-icon.is-leaf { |
|
|
|
|
|
|
|
margin-left: 0px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node { |
|
|
|
|
|
|
|
position: relative; |
|
|
|
|
|
|
|
padding-left: 16px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node__children { |
|
|
|
|
|
|
|
padding-left: 16px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree > .el-tree-node:before { |
|
|
|
|
|
|
|
border-left: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree > .el-tree-node:after { |
|
|
|
|
|
|
|
border-top: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree > .el-tree-node:before { |
|
|
|
|
|
|
|
border-left: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree > .el-tree-node:after { |
|
|
|
|
|
|
|
border-top: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node:before { |
|
|
|
|
|
|
|
content: ""; |
|
|
|
|
|
|
|
left: 10px; |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
right: auto; |
|
|
|
|
|
|
|
border-width: 1px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node:after { |
|
|
|
|
|
|
|
content: ""; |
|
|
|
|
|
|
|
left: 10px; |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
right: auto; |
|
|
|
|
|
|
|
border-width: 1px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node:before { |
|
|
|
|
|
|
|
border-left: 1px dashed #ccc; |
|
|
|
|
|
|
|
bottom: 0px; |
|
|
|
|
|
|
|
height: 100%; |
|
|
|
|
|
|
|
top: -19px; |
|
|
|
|
|
|
|
width: 1px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node:after { |
|
|
|
|
|
|
|
border-top: 1px dashed #ccc; |
|
|
|
|
|
|
|
height: 25px; |
|
|
|
|
|
|
|
top: 20px; |
|
|
|
|
|
|
|
width: 20px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.el-tree-node :last-child:before { |
|
|
|
|
|
|
|
height: 40px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container { |
|
|
|
|
|
|
|
margin: 10px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree .el-tree-node { |
|
|
|
|
|
|
|
position: relative; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node .el-tree-node__content { |
|
|
|
|
|
|
|
height: 34px; |
|
|
|
|
|
|
|
padding-left: 0px !important; |
|
|
|
|
|
|
|
border: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node .el-tree-node__content::before { |
|
|
|
|
|
|
|
border-left: 1px dashed #ccc; |
|
|
|
|
|
|
|
height: 100%; |
|
|
|
|
|
|
|
top: 0; |
|
|
|
|
|
|
|
width: 1px; |
|
|
|
|
|
|
|
margin-left: 1px; |
|
|
|
|
|
|
|
margin-top: 0px; |
|
|
|
|
|
|
|
z-index: 8; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.tree-container |
|
|
|
|
|
|
|
/deep/ |
|
|
|
|
|
|
|
.el-tree-node |
|
|
|
|
|
|
|
.el-tree-node__children |
|
|
|
|
|
|
|
.el-tree-node__content::before { |
|
|
|
|
|
|
|
border-left: 0px dashed #ccc; |
|
|
|
|
|
|
|
height: 100%; |
|
|
|
|
|
|
|
top: 0; |
|
|
|
|
|
|
|
width: 1px; |
|
|
|
|
|
|
|
margin-left: 1px; |
|
|
|
|
|
|
|
margin-top: 0px; |
|
|
|
|
|
|
|
z-index: 8; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.tree-container /deep/ .el-tree-node .el-tree-node__content::after { |
|
|
|
|
|
|
|
border-top: 1px dashed #ccc; |
|
|
|
|
|
|
|
height: 1px; |
|
|
|
|
|
|
|
top: 18px; |
|
|
|
|
|
|
|
width: 13px; |
|
|
|
|
|
|
|
margin-left: 1px; |
|
|
|
|
|
|
|
z-index: 8; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.tree-container |
|
|
|
|
|
|
|
/deep/ |
|
|
|
|
|
|
|
.el-tree-node |
|
|
|
|
|
|
|
.el-tree-node__children |
|
|
|
|
|
|
|
.el-tree-node__content::after { |
|
|
|
|
|
|
|
border-top: 0px dashed #ccc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.tree-container .el-tree-node .el-tree-node__content::before, |
|
|
|
|
|
|
|
.tree-container .el-tree-node .el-tree-node__content::after { |
|
|
|
|
|
|
|
content: ""; |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
right: auto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/deep/.el-table__placeholder { |
|
|
|
|
|
|
|
padding-left: 8px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/deep/.el-card__body { |
|
|
|
|
|
|
|
padding: 10px !important; |
|
|
|
|
|
|
|
> div { |
|
|
|
|
|
|
|
padding-bottom: 10px; |
|
|
|
|
|
|
|
border-bottom: 1px solid #ccc; |
|
|
|
|
|
|
|
&:hover { |
|
|
|
|
|
|
|
color: blue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.text { |
|
|
|
|
|
|
|
font-size: 14px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.el-tree { |
|
|
|
|
|
|
|
width: 80%; |
|
|
|
|
|
|
|
margin-top: 10px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.search { |
|
|
|
|
|
|
|
width: 60%; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.item { |
|
|
|
|
|
|
|
padding: 18px 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.add { |
|
|
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
margin-top: 10px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.delete { |
|
|
|
|
|
|
|
margin: 10px 0; |
|
|
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.edit { |
|
|
|
|
|
|
|
margin-bottom: 10px; |
|
|
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.search { |
|
|
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.box-card { |
|
|
|
|
|
|
|
width: 150px; |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
z-index: 1000; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|