Commit 7693efba by fairyly

fix:修改树形数据

parent 280e4bba
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>好办管理平台</title><link rel=stylesheet type=text/css href=//web-1251519181.file.myqcloud.com/custom-element/custom-element.1.0.24.css><link href=./static/css/app.0ae7ce63c1c1b32e84a7e3831561d173.css rel=stylesheet></head><body style="min-width: 1400px;" class=damolish><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script src=//web-1251519181.file.myqcloud.com/components/footer.2.0.04.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script type=text/javascript src=./static/js/manifest.045eda77180209a1ac9b.js></script><script type=text/javascript src=./static/js/vendor.2cff6c68669f76f7bb26.js></script><script type=text/javascript src=./static/js/app.4ad545414a2bd6f8aef7.js></script></body></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>好办管理平台</title><link rel=stylesheet type=text/css href=//web-1251519181.file.myqcloud.com/custom-element/custom-element.1.0.24.css><link href=./static/css/app.958dcd7513d724c90185d55a61bc3211.css rel=stylesheet></head><body style="min-width: 1400px;" class=damolish><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script src=//web-1251519181.file.myqcloud.com/components/footer.2.0.04.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script type=text/javascript src=./static/js/manifest.603d9dd1066352ad0c6a.js></script><script type=text/javascript src=./static/js/vendor.2cff6c68669f76f7bb26.js></script><script type=text/javascript src=./static/js/app.4ad545414a2bd6f8aef7.js></script></body></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,o,c){for(var f,i,u,d=0,b=[];d<r.length;d++)i=r[d],a[i]&&b.push(a[i][0]),a[i]=0;for(f in o)Object.prototype.hasOwnProperty.call(o,f)&&(e[f]=o[f]);for(n&&n(r,o,c);b.length;)b.shift()();if(c)for(d=0;d<c.length;d++)u=t(t.s=c[d]);return u};var r={},a={21:0};function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}t.e=function(e){var n=a[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,t){n=a[e]=[r,t]});n[2]=r;var o=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,t.nc&&c.setAttribute("nonce",t.nc),c.src=t.p+"static/js/"+e+"."+{0:"1d32d63fa419a4b86bba",1:"9a1776fdc262362d75b8",2:"036a333a663344cf67d9",3:"aff73457228a6df23650",4:"59cbb98ef3301b7d1be0",5:"afc7b726a46486df899a",6:"9e12ea68528f2ad5f9a5",7:"4c95fe66c59573d7da03",8:"c2a3c1c2b9ffb4687826",9:"4b8efecc95608bc88200",10:"ac7009c4a56552235c6f",11:"cdcdaabe8dd05b754b5f",12:"2bf38ff033ad1f7a922b",13:"b13f744cd55ac3168789",14:"840b162a636493a5d4f9",15:"b2964c8a20328a2a5e5f",16:"188fa59e318626239ae8",17:"17423916aa77b50f2ee3",18:"b918fbf8403d96eac90a"}[e]+".js";var f=setTimeout(i,12e4);function i(){c.onerror=c.onload=null,clearTimeout(f);var n=a[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),a[e]=void 0)}return c.onerror=c.onload=i,o.appendChild(c),r},t.m=e,t.c=r,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="./",t.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,o){for(var f,i,u,d=0,b=[];d<r.length;d++)i=r[d],t[i]&&b.push(t[i][0]),t[i]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(e[f]=c[f]);for(n&&n(r,c,o);b.length;)b.shift()();if(o)for(d=0;d<o.length;d++)u=a(a.s=o[d]);return u};var r={},t={21:0};function a(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,a){n=t[e]=[r,a]});n[2]=r;var c=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.charset="utf-8",o.async=!0,o.timeout=12e4,a.nc&&o.setAttribute("nonce",a.nc),o.src=a.p+"static/js/"+e+"."+{0:"e024953879088085b363",1:"9a1776fdc262362d75b8",2:"036a333a663344cf67d9",3:"3f6c375482ebae11669c",4:"59cbb98ef3301b7d1be0",5:"afc7b726a46486df899a",6:"9e12ea68528f2ad5f9a5",7:"4c95fe66c59573d7da03",8:"c2a3c1c2b9ffb4687826",9:"4b8efecc95608bc88200",10:"ac7009c4a56552235c6f",11:"cdcdaabe8dd05b754b5f",12:"2bf38ff033ad1f7a922b",13:"b13f744cd55ac3168789",14:"840b162a636493a5d4f9",15:"b2964c8a20328a2a5e5f",16:"188fa59e318626239ae8",17:"17423916aa77b50f2ee3",18:"b918fbf8403d96eac90a"}[e]+".js";var f=setTimeout(i,12e4);function i(){o.onerror=o.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return o.onerror=o.onload=i,c.appendChild(o),r},a.m=e,a.c=r,a.d=function(e,n,r){a.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},a.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(n,"a",n),n},a.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},a.p="./",a.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
......@@ -3,8 +3,8 @@
* @version: 1.0.0
* @Author: 无尘
* @Date: 2018-10-10 14:44:45
* @LastEditors: 无尘
* @LastEditTime: 2019-10-29 10:05:39
* @LastEditors : 无尘
* @LastEditTime : 2020-02-23 10:40:44
*/
import Vue from 'vue';
// import axios from 'axios';
......@@ -45,10 +45,10 @@ Vue.axios.interceptors.response.use(
if (window.location.href.indexOf('gic-error') != -1) {
return false;
}
window.location.href = local + '/haoban-manage3-web/#/login';
window.location.href = local + '/haoban-3/#/login';
}
if (data.data.errorCode == 10 || data.data.errorCode == 7) {
window.location.href = local + '/haoban-manage3-web/#/index';
window.location.href = local + '/haoban-3/#/index';
}
return data;
}
......
......@@ -22,7 +22,7 @@ export default {
// return false;
// }
if (response.errorCode == 10) {
window.location.href = local + '/haoban-manage3-web/#/index';
window.location.href = local + '/haoban-3/#/index';
return false;
}
Message.error({
......
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2019-08-14 16:51:07
* @LastEditors : 无尘
* @LastEditTime : 2020-02-22 15:49:36
* @LastEditTime : 2020-02-23 11:55:10
-->
<!--
<wx-tree v-model="itemData" ></wx-tree>
......@@ -13,12 +13,12 @@ import wxTree from './wx-tree.vue';
-->
<template>
<ul class="">
<draggable :list="itemData" class="wx-component" :options="rightOption" @input="emitter" @change="changeData">
<li v-for="(item, index) in itemData" :key="index + 'gic'">
<draggable :list="itemData" class="wx-component" :options="rightOption" @input="emitter" @change="changeData" :move="onMove" @start="isDragging = true" @end="itemMoveEnd">
<li v-for="(item, index) in itemData" :key="index + 'wx'">
<div class="li-cell cursor-pointer" @click="toggleExpand(item)">
<div class="flex flex-space-between boder-box p-r-20" :style="{ 'padding-left': item.level * 10 + 'px' }">
<div class="flex flex-space-between boder-box p-r-20" :style="{ 'padding-left': (item.level + 1) * 10 + 'px' }">
<div class="tree-left">
<span v-if="!item.isStore" :class="['font-12 color-606266', item.expand ? 'el-icon-caret-bottom' : 'el-icon-caret-right']"></span><span :class="['font-14 p-l-10 p-r-10 iconfont', item.isStore == 1 ? 'icondianpu-kuai' : 'iconqiye-tianchong', item.bindFlag == 1 ? 'color-2f54eb' : 'color-dedfe6']"></span><span class="font-14 color-606266">{{ item.label }}</span>
<span :class="['font-12 color-606266', item.isStore == 1 ? 'color-fff' : '', item.expand ? 'el-icon-caret-bottom' : 'el-icon-caret-right']"></span><span :class="['font-14 p-l-10 p-r-10 iconfont', item.isStore == 1 ? 'icondianpu-kuai' : 'iconqiye-tianchong', item.bindFlag == 1 ? 'color-2f54eb' : 'color-dedfe6']"></span><span class="font-14 color-606266">{{ item.label }}</span>
</div>
<div class="tree-right">
<el-button v-if="item.isStore == 0" type="text" @click.stop="addChild(item)">添加子部门</el-button>
......@@ -78,6 +78,26 @@ export default {
},
computed: {},
methods: {
onMove(evt) {
// const that = this;
// 判断中间是否存在父级
const draggedElement = evt.draggedContext.element;
// 首级不能移动
if (draggedElement.level == 0) {
return false;
}
console.log(evt, draggedElement, !draggedElement.fixed);
return !draggedElement.fixed;
},
/**
* move end
*/
itemMoveEnd(evt) {
const that = this;
// 判断中间是否已经添加
console.log(evt, that.itemData);
that.$forceUpdate();
},
/**
* 改变数组数据
*/
......@@ -91,9 +111,6 @@ export default {
/**
* 展开或者关闭下级
*/
/**
* 展开或者关闭下级
*/
async toggleExpand(item) {
const that = this;
// console.log(item);
......@@ -144,8 +161,8 @@ export default {
if (name == 'close') {
return false;
}
// 添加子部门的时候判断是否有子级
const arr = !that.additem.addFlag ? await that.getChildData(that.additem) : [];
// 添加子部门的时候判断是否有子级且不是新添加
const arr = !that.additem.addFlag && !that.additem.children.length ? await that.getChildData(that.additem) : [];
if (arr.length && !that.additem.addFlag) {
arr.forEach(ele => {
that.additem.children.push(ele);
......@@ -165,7 +182,7 @@ export default {
},
/**
* 搜索查询列表
* 删除
*/
delPost(item) {
const that = this;
......@@ -304,11 +321,21 @@ export default {
.li-cell {
min-height: 26px;
line-height: 26px;
.tree-left {
.color-fff {
color: #fff;
}
}
.tree-right {
display: none;
}
&:hover {
background: rgba(47, 84, 235, 0.05);
.tree-left {
.color-fff {
color: rgba(47, 84, 235, 0.05);
}
}
.tree-right {
display: block;
}
......
......@@ -119,7 +119,7 @@ export default {
})
.then(() => {
that.axios
.post(that.baseUrl + '/haoban-manage-web/logout', {})
.post('/haoban-manage3-web/logout', {})
.then(res => {
let resData = res.data;
if (resData.errorCode == 1) {
......@@ -128,7 +128,7 @@ export default {
type: 'success'
});
// 跳转登录页
window.location.href = window.location.origin + '/haoban-manage3-web/#/login';
window.location.href = window.location.origin + '/haoban-3/#/login';
return;
}
that.$message.error({
......
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2019-03-20 14:36:37
* @LastEditors : 无尘
* @LastEditTime : 2020-02-21 10:22:54
* @LastEditTime : 2020-02-23 11:53:25
-->
<template>
<div class="my-customer-wrap common-set-wrap">
......@@ -45,7 +45,22 @@
<el-button type="text" @click="toRecycle">回收站()</el-button>
</div>
<div class="content-wx">
<wx-tree :itemData="wxData" v-model="wxData"></wx-tree>
<ul class="">
<li v-for="(item, index) in wxData" :key="index + 'wx'">
<div class="li-cell cursor-pointer" @click="toggleExpand(item)">
<div class="flex flex-space-between boder-box p-r-20" :style="{ 'padding-left': (item.level + 1) * 10 + 'px' }">
<div class="tree-left">
<span v-if="!item.isStore" :class="['font-12 color-606266', item.expand ? 'el-icon-caret-bottom' : 'el-icon-caret-right']"></span><span :class="['font-14 p-l-10 p-r-10 iconfont', item.isStore == 1 ? 'icondianpu-kuai' : 'iconqiye-tianchong', item.bindFlag == 1 ? 'color-2f54eb' : 'color-dedfe6']"></span><span class="font-14 color-606266">{{ item.label }}</span>
</div>
<div class="tree-right">
<el-button v-if="item.isStore == 0" type="text" @click.stop="addChild(item)">添加子部门</el-button>
<el-button type="text" @click.stop="modChild(item)">修改名称</el-button>
</div>
</div>
</div>
<wx-tree v-if="item.expand" :itemData="item.children" v-model="item.children"></wx-tree>
</li>
</ul>
</div>
</div>
</div>
......@@ -57,6 +72,7 @@
</div>
</div>
<add-enterprise v-if="addShow" @refreshData="refreshData"></add-enterprise>
<add-depart v-if="addDepartShow" :departObj="departObj" @refreshData="refreshDepartData"></add-depart>
</div>
<vue-gic-footer></vue-gic-footer>
</div>
......@@ -66,9 +82,11 @@ import navCrumb from '@/components/nav/nav.vue';
import addEnterprise from '@/components/company/add-enterprise.vue';
import orgTree from '@/components/company/org-tree.vue';
import wxTree from '@/components/company/wx-tree.vue';
import addDepart from '@/components/company/add-depart.vue';
import { getRequest, postRequest } from '@/api/api';
import errMsg from '@/common/js/error';
import { _debounce } from '@/common/js/public';
import localforage from 'localforage';
export default {
name: 'reviewed',
data() {
......@@ -110,7 +128,8 @@ export default {
// }]
// }
],
addShow: false
addDepartShow: false,
additem: {}
};
},
computed: {},
......@@ -190,6 +209,7 @@ export default {
});
}
that.wxData = resData.result || [];
that.getLocalData();
return false;
}
errMsg.errorMsg(resData);
......@@ -201,6 +221,148 @@ export default {
});
});
},
/**
* 添加子部门
*/
addChild(item) {
const that = this;
// console.log('添加:', item);
that.addDepartShow = true;
that.additem = item;
},
/**
* 修改名称
*/
modChild(item) {
const that = this;
// console.log('修改:', item);
item.label = 2222;
that.addDepartShow = true;
that.$forceUpdate();
},
async refreshDepartData(name) {
const that = this;
that.addDepartShow = false;
if (name == 'close') {
return false;
}
// 添加子部门的时候判断是否有子级且不是新添加
const arr = !that.additem.addFlag && !that.additem.children.length ? await that.getChildData(that.additem) : [];
if (arr.length && !that.additem.addFlag) {
arr.forEach(ele => {
that.additem.children.push(ele);
});
}
that.additem.children.push({
id: String(new Date().getTime()),
expand: true,
level: that.additem.level + 1,
isStore: 0,
label: name,
departmentName: name,
addFlag: true,
children: []
});
that.$forceUpdate();
},
/**
* 展开或者关闭下级
*/
async toggleExpand(item) {
const that = this;
// console.log(item);
item.expand = item.expand ? false : true;
// 新增加子部门不存本地数据
if (item.addFlag) {
return false;
}
// 点击的时候,如果非门店且子级是空的需要请求获取子级
if (item.isStore == 0 && !item.children.length) {
item.children = await that.getChildData(item);
}
// 只有展开且不是门店的才会保存
if (item.expand && !item.isStore) {
localforage.setItem('org' + item.departmentId, item);
}
if (!item.expand) {
localforage.removeItem('org' + item.departmentId);
}
that.$forceUpdate();
},
/**
* 获取下级数据
*/
getChildData(item) {
const that = this;
let para = {
parentId: item.departmentId, //
isStore: item.isStore, //
keyword: '' //
};
return new Promise((resolve, reject) => {
getRequest('/haoban-manage3-web/department-list-level', para)
.then(res => {
let resData = res.data;
if (resData.errorCode == 1) {
if (resData.result.length) {
resData.result.forEach(ele => {
ele.expand = false;
ele.children = [];
ele.label = ele.departmentName;
});
}
resolve(resData.result || []);
return false;
}
resolve([]);
errMsg.errorMsg(resData);
})
.catch(function(error) {
resolve([]);
that.$message.error({
duration: 1000,
message: error.message
});
});
});
},
async checkLocal(data) {
// const that = this;
return new Promise((resolve, reject) => {
localforage
.getItem('org' + data.departmentId)
.then(value => {
// 当离线仓库中的值被载入时,此处代码运行
// console.log(value);
value ? resolve(true) : resolve(false);
})
.catch(function(err) {
// 当出错时,此处代码运行
resolve(false);
// console.log(err);
});
});
},
/**
* 获取存储的数据
*/
async getLocalData() {
const that = this;
for (let index = 0; index < that.wxData.length; index++) {
const flag = await that.checkLocal(that.wxData[index]);
if (flag) {
that.wxData[index].expand = true;
that.wxData[index].children = await that.getChildData(that.wxData[index]);
}
}
},
/**
* 新增
*/
......@@ -267,7 +429,8 @@ export default {
navCrumb,
addEnterprise,
orgTree,
wxTree
wxTree,
addDepart
}
};
</script>
......@@ -410,6 +573,10 @@ export default {
.content-wx {
padding: 10px 0 20px 0;
box-sizing: border-box;
.li-cell {
min-height: 26px;
line-height: 26px;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment