| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- import {
- // SceneListType,
- // GetListWorkshop,
- // WorkspaceAddDatas,
- // LabelModuleListType,WorkShopTempleteType
-
- } from '@/types/scene/type.ts';
- import { useGlobSetting } from '@/hooks/setting';
- const { appPCUrl } = useGlobSetting()
- export const colomns = [
- { label: '名称', prop: 'name', minWidth: 300 },
- { label: '设置', prop: 'labelName', minWidth: 300,
- render: ({ row }) => {
- if(!row.parent && row.labelList?.[0]?.id) {
- return (
- <a
- href={`/#/page-config/config?companyId=${row.id}`}
- >
- 布局设置
- </a>
- );
- } else if (row.parent && !row.parent.parent) {
- return (
- <a href={`/#/map-config/layout?id=${row.id}`}>
- 相机导航设置
- </a>
- );
- }
- },
- },
- // { label: '场景标签', prop: 'labelName', minWidth: 300 },
- // { label: '代码', prop: 'code' },
- {
- label: '预览',
- prop: 'preview',
- minWidth: 300,
- render: ({ row, column }) => {
- if (!row.parent && row.labelList?.[0]?.id) {
- return (
- <a
- href={`${appPCUrl}#/company?companyId=${row.id}&labelId=${row.labelList[0]?.id}`}
- target="_blank"
- >
- 公司预览
- </a>
- );
- } else if (row.parent && !row.parent.parent) {
- return (
- <a href={`${appPCUrl}#/shop?id=${row.id}`} target="_blank">
- 车间预览
- </a>
- );
- }
- },
- },
- ];
- // interface DataSourceUser
- // extends UseComType<UseWorkshopType<UseWorkspaceType>> {
- // parent?: UseComType<UseWorkshopType<UseWorkspaceType>> | null;
- // }
- // 修改: 现在排序车间或工位时按上一级id找 找到公司id为止
- // export const dataSourceWithParent = (d: DataSourceUser[], parent: DataSourceUser | null) => {
- // d.forEach((item, _index) => {
- // item.parent = parent;
- // if (item.children && item.children?.length > 0) {
- // dataSourceWithParent(item.children as DataSourceUser[], item);
- // }
- // });
- // return d;
- // };
- // export function removeParent(data) {
- // return data.map((item) => {
- // // 删除 tag 属性
- // delete item.parent;
- // // 递归处理子项
- // if (item.children && item.children.length > 0) {
- // item.children = removeParent(item.children);
- // }
- // return item;
- // });
- // }
- //找到各个层级
- // export function findIndexByItem(data, targetItem, path = []) {
- // for (let i = 0; i < data.length; i++) {
- // const currentPath = path.concat(i);
- // if (data[i].id === targetItem.id && data[i].name === targetItem.name) {
- // return currentPath;
- // }
- // if (data[i].children && data[i].children.length > 0) {
- // const childResult = findIndexByItem(data[i].children, targetItem, currentPath);
- // if (childResult.length > 0) {
- // return childResult;
- // }
- // }
- // }
- // return [];
- // }
- //用于重新修改serial
- // export const updateSerials = (data) => {
- // for (let i = 0; i < data.length; i++) {
- // data[i].serial = i;
- // // 如果有子项,递归查找
- // if (data[i].children && data[i].children.length > 0) {
- // updateSerials(data[i].children);
- // }
- // }
- // return data;
- // // return false; // 表示未找到目标项
- // };
- //用于新增数据
- // export const updateData = (data, targetId, newAdd) => {
- // for (let i = 0; i < data.length; i++) {
- // const currentItem = data[i];
- // if (currentItem.id === targetId) {
- // if (!currentItem.children) {
- // currentItem.children = [];
- // }
- // currentItem.children.push(newAdd);
- // return true; // 表示已经找到并修改
- // }
- // // 如果有子项,递归查找
- // if (currentItem.children && currentItem.children.length > 0) {
- // const found = updateData(currentItem.children, targetId, newAdd);
- // if (found) {
- // return true; // 如果在子项中找到目标项,停止继续查找
- // }
- // }
- // }
- // return false; // 表示未找到目标项
- // };
- //判断该条数据的层级
- // export const findItemLevel = (data, targetId, targetName, currentLevel = 0) => {
- // for (let i = 0; i < data.length; i++) {
- // const item = data[i];
- // if (item.id === targetId && item.name === targetName) {
- // return currentLevel;
- // }
- // if (item.children && item.children.length > 0) {
- // const childLevel = findItemLevel(item.children, targetId, targetName, currentLevel + 1);
- // if (childLevel !== -1) {
- // return childLevel;
- // }
- // }
- // }
- // return -1;
- // };
- //得到parent
- // export const getParent = (data: DataSourceUser[], targetCode: string) => {
- // //let parentNode = {} as DataSourceUser
- // for (let i = 0; i < data.length; i++) {
- // const item = data[i];
- // if (item.code === targetCode) {
- // // parentNode = item
- // return item
- // }
- // if (item.children && item.children.length > 0) {
- // const foundItem = getParent(item.children as DataSourceUser[], targetCode);
- // if (foundItem) {
- // return foundItem
- // }
- // }
- // }
- // return null;
- // };
- //删除行
- // export const deleteTableRow = (dataSource, targetId) => {
- // const deleteRecursive = (data) => {
- // for (let i = 0; i < data.length; i++) {
- // const currentItem = data[i];
- // if (currentItem.id === targetId) {
- // // 删除当前项
- // data.splice(i, 1);
- // return true;
- // }
- // // 如果有子项,递归查找
- // if (currentItem.children && currentItem.children.length > 0) {
- // const found = deleteRecursive(currentItem.children);
- // if (found) {
- // return true; // 如果在子项中找到目标项,停止继续查找
- // }
- // }
- // }
- // return false; // 表示未找到目标项
- // };
- // // 从顶层开始递归删除
- // deleteRecursive(dataSource);
- // };
- //找出数据中的全部code
- // export const flattenCodes = (data) => {
- // const codes: string[] = [];
- // const traverse = (node: { code: string; children: any[] }) => {
- // codes.push(node.code);
- // if (node.children && node.children.length > 0) {
- // node.children.forEach(traverse);
- // }
- // };
- // data.forEach(traverse);
- // return codes;
- // };
- // export enum ENABLED {
- // FALSE = 1,
- // TRUE = 0,
- // }
|