view.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. import React, { useState, useEffect, useCallback, useRef } from "react";
  2. import { useHistory } from "react-router-dom";
  3. import PropTypes from "prop-types";
  4. import styles from "./style.less";
  5. import Navigator from "./component/navigator/view.jsx";
  6. import Top from "./component/top/view.jsx";
  7. import ModelMsg from "./component/modelMsg/view.jsx";
  8. import BreadcrumbView from "./component/breadcrumb/view";
  9. import TipMsg from "./component/tipMsg/view.jsx";
  10. import $store from "@store/";
  11. import {
  12. Dropdown,
  13. Menu,
  14. message,
  15. Button,
  16. Form,
  17. Modal,
  18. Tabs,
  19. Input,
  20. } from "antd";
  21. import DefaultImg from "@components/defaultImg/view.jsx";
  22. import {
  23. MenuUnfoldOutlined,
  24. MenuFoldOutlined,
  25. AreaChartOutlined,
  26. PieChartOutlined,
  27. BarChartOutlined,
  28. DotChartOutlined,
  29. LineChartOutlined,
  30. RadarChartOutlined,
  31. HeatMapOutlined,
  32. FallOutlined,
  33. RiseOutlined,
  34. StockOutlined,
  35. BoxPlotOutlined,
  36. FundOutlined,
  37. SlidersOutlined,
  38. DatabaseOutlined,
  39. DollarOutlined,
  40. ControlOutlined,
  41. CodeOutlined,
  42. BarsOutlined,
  43. AppstoreAddOutlined,
  44. ApartmentOutlined,
  45. InfoCircleOutlined,
  46. StarOutlined,
  47. StarFilled,
  48. } from "@ant-design/icons";
  49. import {
  50. getDmpAccessUrl,
  51. getFineBiToken,
  52. getValueByDictCode,
  53. getPreFineBiUrl,
  54. getSunwayAccessUrl,
  55. } from "./component/top/api";
  56. import { dealDiffSheetType, crossMenuClick } from "@utils/util";
  57. import utils from "@utils/index";
  58. import "@themes/themes.less";
  59. import { saveMenu } from "@apis/enter.js";
  60. import { careOrCancelResource, getUserResourceTree } from "./api";
  61. import { observer, observable } from "mobx-react";
  62. import { toJS } from "mobx";
  63. const { SubMenu } = Menu;
  64. const { TabPane } = Tabs;
  65. // Frame.propTypes = {
  66. // child: PropTypes.object,
  67. // };
  68. let keys = [];
  69. let attrs = {
  70. style: { color: "#c7c7c7", fontSize: 13 },
  71. };
  72. const iconObj = {
  73. AreaChartOutlined: <AreaChartOutlined {...attrs} />,
  74. PieChartOutlined: <PieChartOutlined {...attrs} />,
  75. BarChartOutlined: <BarChartOutlined {...attrs} />,
  76. DotChartOutlined: <DotChartOutlined {...attrs} />,
  77. LineChartOutlined: <DotChartOutlined {...attrs} />,
  78. RadarChartOutlined: <RadarChartOutlined {...attrs} />,
  79. HeatMapOutlined: <HeatMapOutlined {...attrs} />,
  80. FallOutlined: <FallOutlined {...attrs} />,
  81. RiseOutlined: <RiseOutlined {...attrs} />,
  82. StockOutlined: <StockOutlined {...attrs} />,
  83. BoxPlotOutlined: <BoxPlotOutlined {...attrs} />,
  84. FundOutlined: <FundOutlined {...attrs} />,
  85. SlidersOutlined: <SlidersOutlined {...attrs} />,
  86. DatabaseOutlined: <DatabaseOutlined {...attrs} />,
  87. DollarOutlined: <DollarOutlined {...attrs} />,
  88. ControlOutlined: <ControlOutlined {...attrs} />,
  89. CodeOutlined: <CodeOutlined {...attrs} />,
  90. BarsOutlined: <BarsOutlined {...attrs} />,
  91. AppstoreAddOutlined: <AppstoreAddOutlined {...attrs} />,
  92. ApartmentOutlined: <ApartmentOutlined {...attrs} />,
  93. };
  94. const layout = {
  95. labelCol: { span: 4 },
  96. wrapperCol: { span: 16 },
  97. };
  98. const formItemLayout = {
  99. labelCol: {
  100. span: 5,
  101. },
  102. wrapperCol: {
  103. span: 18,
  104. },
  105. };
  106. let leafNode = {
  107. // nodeId: {num, parentIds}
  108. };
  109. const findLeaves = (tree = []) => {
  110. function loop(list, parentIds = []) {
  111. list.map((item) => {
  112. // 新建当前ID的键值对
  113. if ((item.resourceList || []).length > 0) {
  114. loop(item.resourceList, parentIds.concat([item.resourceId]));
  115. } else {
  116. leafNode[item.resourceId] = {
  117. name: item.resourceName,
  118. id: item.resourceId,
  119. parentIds,
  120. };
  121. }
  122. });
  123. }
  124. loop(tree, []);
  125. };
  126. let sVal = "";
  127. export default observer(function Frame(props) {
  128. const [searchVal, setSearchVal] = useState(""); /**搜索关键词内容 */
  129. const [collapsed, setCollapsed] = useState(false);
  130. const [leftMenuHeight, setleftMenuHeight] = useState("100%");
  131. const [leftMenuWidth, setleftMenuWidth] = useState(220);
  132. const [modelMsgs, setModelMsgs] = useState({});
  133. const [tipMsgs, setTipMsgs] = useState({});
  134. const history = useHistory();
  135. const [curKey, setKey] = useState("1");
  136. const moveBar = useRef();
  137. const [isMove,setisMove] = useState(false);
  138. const name_arr = {
  139. "#/home/gvc": "产供销价值链",
  140. "#/home/operation": "运营数据中心",
  141. "#/home/tlk": "TLK运营数据中心 / TLK Plant Dashboard",
  142. }
  143. const [titleName, setTitleName] = useState(name_arr[window.location.hash]);
  144. const { Search } = Input;
  145. let showIds = $store.app.showIds;
  146. function calcValue(str) {
  147. if (str === "sysToken") {
  148. return `${sessionStorage.getItem("token")}$`;
  149. }
  150. }
  151. document.onmousemove = function (e) {
  152. //是否为可移动状态
  153. if (isMove) {
  154. let e = e || window.event;
  155. let moveX = e.clientX; //得到距离左边移动距离
  156. if (moveX < 44) {
  157. moveX = 44;
  158. } else if (moveX > 800) {
  159. moveX = 800;
  160. }
  161. setleftMenuWidth(moveX);
  162. } else {
  163. return;
  164. }
  165. };
  166. document.onmouseup = () => {
  167. setisMove(false);
  168. };
  169. const stopLeftMenu = () => {
  170. setisMove(false);
  171. };
  172. const moveLeftMenu = () => {
  173. setisMove(true);
  174. };
  175. /**打开 报表目录 */
  176. const openReportDire = (key) => {
  177. let activePath = `/home/directory/${key}`;
  178. let navObj = {
  179. name: sessionStorage.getItem("resourceName"),
  180. path: activePath,
  181. type: "sys",
  182. openType: "self",
  183. id: key,
  184. };
  185. // $store.app.setNavList(navObj);
  186. // $store.app.setCurNav(activePath);
  187. // history.push(activePath);
  188. };
  189. function callback(key) {
  190. return setKey(key);
  191. }
  192. const onResize = useCallback(() => {
  193. setleftMenuHeight(document.documentElement.clientHeight - 82 + "px");
  194. }, []);
  195. const onResize_pop = useCallback(() => {
  196. }, []);
  197. useEffect(() => {
  198. setSearchVal("");
  199. leafNode = {};
  200. $store.app.setShowIds([]);
  201. // showIds = [];
  202. setleftMenuHeight(document.documentElement.clientHeight - 82 + "px");
  203. window.addEventListener("resize", onResize);
  204. findLeaves($store.sysMenu.submenuList);
  205. return () => {
  206. window.removeEventListener("resize", onResize);
  207. window.removeEventListener("popstate", onResize_pop);
  208. };
  209. }, [$store.app.refresh]);
  210. const onRef = (ref) => {
  211. setModelMsgs(ref);
  212. };
  213. const getTips = () => {
  214. tipMsgs.getTip()
  215. };
  216. const cleatTips = () => {
  217. tipMsgs.cleatTips()
  218. };
  219. const onRef2 = (ref) => {
  220. setTipMsgs(ref);
  221. console.log(tipMsgs, "tipMsgs")
  222. };
  223. return (
  224. <div className={styles.frame}>
  225. <Top names={titleName}/>
  226. <ModelMsg onRef={onRef} getTips={getTips} cleatTips={cleatTips} changeName={(name) => {
  227. setTitleName(name);
  228. }} />
  229. {/* 断网或超时显示提示 */}
  230. {/* <div className="nowifi-tip">当前网络状态不佳</div> */}
  231. {/* 正文 */}
  232. <div style={{ display: "flex", height: '100%' }}>
  233. {$store.sysMenu.submenuList.length > 0 && !collapsed && (
  234. <div
  235. className="movebar"
  236. style={{ left: leftMenuWidth }}
  237. ref={moveBar}
  238. onMouseDown={moveLeftMenu}
  239. onMouseUp={stopLeftMenu}
  240. ></div>
  241. )}
  242. {isMove && <div className="markmore"></div>}
  243. <div
  244. className={"body_box homePage"}
  245. >
  246. <Navigator
  247. style={{
  248. display: "none",
  249. }}
  250. />
  251. <TipMsg onRef={onRef2}></TipMsg>
  252. {$store.app.navList.length === 0 && false &&
  253. !history.location.pathname.match(/index|work|center|clush/) ? (
  254. <DefaultImg />
  255. ) : (
  256. props.child && props.child
  257. )}
  258. </div>
  259. </div>
  260. {/* 元数据展示 */}
  261. <Modal
  262. title="报表元数据"
  263. visible={$store.app.metaData.visible}
  264. width="665px"
  265. onCancel={() => {
  266. $store.app.setMetaData({
  267. visible: false,
  268. });
  269. }}
  270. footer={null}
  271. >
  272. <Form {...layout}>
  273. <Tabs defaultActiveKey="0" onChange={callback}>
  274. <TabPane tab="基础信息" key="0">
  275. <Form.Item name="remark" label="报表描述" {...formItemLayout}>
  276. <span>{$store.app.metaData.data.remark}</span>
  277. </Form.Item>
  278. <Form.Item name="department" label="责任部门" {...formItemLayout}>
  279. <span>{$store.app.metaData.data.departmentInfo}</span>
  280. </Form.Item>
  281. <Form.Item name="charger" label="资产责任人" {...formItemLayout}>
  282. <span>{$store.app.metaData.data.charger}</span>
  283. </Form.Item>
  284. <Form.Item name="itManager" label="IT经理" {...formItemLayout}>
  285. <span>{$store.app.metaData.data.itManager}</span>
  286. </Form.Item>
  287. <Form.Item name="itDeveloper" label="IT研发" {...formItemLayout}>
  288. <span>{$store.app.metaData.data.itDeveloper}</span>
  289. </Form.Item>
  290. </TabPane>
  291. <TabPane tab="资产信息" key="1">
  292. <Form.Item name="dataFrom" label="数据来源" {...formItemLayout}>
  293. <span>{$store.app.metaData.data.dataFrom}</span>
  294. </Form.Item>
  295. <Form.Item
  296. name="updateFrequency"
  297. label="数据更新频率"
  298. {...formItemLayout}
  299. >
  300. <span>{$store.app.metaData.data.updateFrequency}</span>
  301. </Form.Item>
  302. <Form.Item name="businessFormat" label="业态" {...formItemLayout}>
  303. <span>{$store.app.metaData.data.businessFormat}</span>
  304. </Form.Item>
  305. <Form.Item name="module" label="业务模块" {...formItemLayout}>
  306. <span>{$store.app.metaData.data.module}</span>
  307. </Form.Item>
  308. <Form.Item
  309. name="sonModule"
  310. label="业务子模块"
  311. {...formItemLayout}
  312. >
  313. <span>{$store.app.metaData.data.sonModule}</span>
  314. </Form.Item>
  315. <Form.Item name="assetType" label="资产类型" {...formItemLayout}>
  316. <span>{$store.app.metaData.data.assetType}</span>
  317. </Form.Item>
  318. <Form.Item name="assetLevel" label="资产密级" {...formItemLayout}>
  319. <span>{$store.app.metaData.data.assetLevel}</span>
  320. </Form.Item>
  321. </TabPane>
  322. </Tabs>
  323. </Form>
  324. </Modal>
  325. </div>
  326. );
  327. });