Commit 77596421 authored by “yiyousong”'s avatar “yiyousong”

pref:修改窗口关联业务

parent a6cbcc4e
......@@ -7,6 +7,7 @@
@cancel="handleClose"
width="600px"
:maskClosable="false"
destroyOnClose
>
<template slot="footer">
<a-button @click="handleReset">重置</a-button>
......@@ -22,6 +23,11 @@
>
</div>
<div class="business-search">
<div>
已关联
<span style="color: #0595fd"> ({{ rowKeys.length }}) </span>
条业务
</div>
<a-input-search
style="width: 300px"
placeholder="请输入业务名称搜索"
......@@ -73,6 +79,7 @@
<script>
import { getSiteBusinessList } from "@/services/business";
import { addBusinessToWindow } from "@/services/dept";
import { extractTree } from "@/utils/util";
import local from "@/utils/local";
const columns = [
{
......@@ -123,17 +130,24 @@ export default {
},
},
},
created() {},
created() {
this.getSiteBusinessList();
},
methods: {
// 获取窗口信息
getWindowInfo(info) {
this.formData = info;
if (info.businessIds.length) {
this.rowKeys = info.businessIds;
let arr = extractTree(this.siteBusinessList, "children").map((v) =>
Number(v.id)
);
console.log(arr);
this.rowKeys = arr.filter((v) => {
return info.businessIds.some((val) => v == val);
});
} else {
this.rowKeys = [];
}
this.getSiteBusinessList();
},
// 去掉空children
delChildren(arr) {
......@@ -211,6 +225,8 @@ export default {
<style lang="less" scoped>
.business-search {
margin-bottom: 20px;
text-align: right;
display: flex;
align-items: center;
justify-content: space-between;
}
</style>
\ No newline at end of file
import enquireJs from 'enquire.js'
import enquireJs from "enquire.js";
export function isDef (v){
return v !== undefined && v !== null
export function isDef(v) {
return v !== undefined && v !== null;
}
/**
* Remove an item from an array.
*/
export function remove (arr, item) {
export function remove(arr, item) {
if (arr.length) {
const index = arr.indexOf(item)
const index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1)
return arr.splice(index, 1);
}
}
}
export function isRegExp (v) {
return _toString.call(v) === '[object RegExp]'
export function isRegExp(v) {
return _toString.call(v) === "[object RegExp]";
}
export function enquireScreen(call) {
const handler = {
match: function () {
call && call(true)
match: function() {
call && call(true);
},
unmatch: function () {
call && call(false)
}
}
enquireJs.register('only screen and (max-width: 767.99px)', handler)
unmatch: function() {
call && call(false);
},
};
enquireJs.register("only screen and (max-width: 767.99px)", handler);
}
const _toString = Object.prototype.toString
const _toString = Object.prototype.toString;
// 扁平化树形结构
export const extractTree = (arrs, childs, attrArr) => {
let attrList = [];
if (!Array.isArray(arrs) && !arrs.length) return [];
if (typeof childs !== "string") return [];
if (!Array.isArray(attrArr) || (Array.isArray(attrArr) && !attrArr.length)) {
attrList = Object.keys(arrs[0]);
attrList.splice(attrList.indexOf(childs), 1);
attrList.splice(attrList.indexOf("isLeaf"), 1);
} else {
attrList = attrArr;
}
let list = [];
const getObj = (arr) => {
arr.forEach(function(row) {
let obj = {};
attrList.forEach((item) => {
obj[item] = row[item];
});
list.push(obj);
if (row[childs]) {
getObj(row[childs]);
}
});
return list;
};
return getObj(arrs);
};
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