1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /*
- * @Author: your name
- * @Date: 2022-01-13 17:09:05
- * @LastEditTime: 2022-03-03 15:02:41
- * @LastEditors: Please set LastEditors
- * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- * @FilePath: /KC-MiddlePlatform/src/utils.js
- */
- export const randomString = (length: number) => {
- const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_=-';
- let result = '';
- for (let i = length; i > 0; --i) {
- result += chars[Math.floor(Math.random() * chars.length)];
- }
- return result;
- };
- export interface TreeItemType {
- children?: TreeItemType[];
- [key: string]: any;
- }
- //获取树结构指定的值集合
- export const getValsFromTree = (data: TreeItemType[], key: string) => {
- let result: any[] = [];
- function looper(data: TreeItemType[], key: string) {
- data.forEach((t) => {
- if (t[key]) {
- result.push(t[key]);
- }
- if (t.children && t.children.length > 0) {
- looper(t.children, key);
- }
- });
- }
- looper(data, key);
- return result;
- };
- export const searchTree = (treeData: TreeItemType[]) => {};
|