| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- export default (params) => { // 导出混入对象
- const { //树分类过滤参数
- treeTypeNum=2
- } = params;
- return {
- data() {
- return {
- /**Split 开始 */
- ztreeNodes: [],
- leftSplitWidth: 20,
- rightSplitWidth: 80,
- ztreeObj: null,
- ztreeSetting: {
- check: {
- enable: false,
- },
- data: {
- simpleData: {
- enable: true,
- pIdKey: "parentId",
- },
- },
- view: {
- showIcon: false,
- },
- },
- currentTreeNode: null,
- //----ztreeLeft end---------
- }
- },
- created() {
- this.findLeftTreeData(); // 获取机构树的数据
- },
- mounted() {
- //用像素初始化左边的split的宽度
- this.changeTreeWidth(240); // 初始化树的宽度
- },
- methods: {
- changeTreeWidth(widthVal) {
- // 初始化树的宽度
- this.leftSplitWidth = Math.ceil(
- (widthVal / this.$refs.elMain.$el.clientWidth) * 100
- );
- this.rightSplitWidth = 100 - this.leftSplitWidth;
- },
- findLeftTreeData: function () {
- this.$api.dept.findTree().then((res) => {
- // console.log(treeTypeNum);
- this.treeDataRecursion(res.data, treeTypeNum);
- this.ztreeNodes = res.data;
- });
- },
- //树过滤五级机构递归
- treeDataRecursion(data, num, one) {
- data = data || this.ztreeNodes;
- one = one || 0;
- one++;
- for (let i = 0; i < data.length; i++) {
- if (data[i].comlevel == 5 && (data[i].managementSource != num)) {
- data.splice(i, 1);
- i = i - 1;
- } else {
- this.treeDataRecursion(data[i].children, num, one);
- }
- }
- },
- }
- }
- }
|