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

pref:修改窗口关联业务

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