detail.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. import PageContent from '@/components/PageContent';
  2. import { Button, Tabs, Space, Drawer, Timeline, message } from 'antd';
  3. import styles from './index.less';
  4. import { useEffect, useMemo, useRef, useState } from 'react';
  5. import axios from 'axios';
  6. import {
  7. useLocation,
  8. useParams,
  9. useRequest,
  10. useSearchParams,
  11. useNavigate,
  12. useModel,
  13. } from '@umijs/max';
  14. import {
  15. queryPsrExcel,
  16. queryPsrExcelList,
  17. queryPsrMonthDetail,
  18. queryPsrMonthLast,
  19. queryPsrMonthList,
  20. queryPsrWorkLoad,
  21. querySavePsrMonth,
  22. } from '../../services/psr';
  23. import SaveModal from './components/saveOtherModal';
  24. import CompareModal from './components/compareModal';
  25. import CompareCom from './components/compareCom';
  26. import dayjs from 'dayjs';
  27. import { getToken } from '@/utils/utils';
  28. import { exportExcel, getUUID } from '../../utils/exportExcl';
  29. import { stringify } from 'qs';
  30. import LuckyExcel from 'luckyexcel';
  31. const ZeroNineType = {
  32. Equipment: '09-010', //设备费
  33. Production: '09-020', //金科制造中心设备制造费
  34. UF: '09-030', //金科制造中心-UF膜(
  35. AI: '09-040', //数字双胞胎
  36. Install: '09-050', //安装分包费用(包括增值税)
  37. Construction: '09-060', //土建分包费用(包括增值税)
  38. };
  39. const preActConfig = [
  40. {
  41. type: ZeroNineType.Equipment,
  42. originC: 6,
  43. originR: { begin: 6, end: 297 }, //总的减上面所有的
  44. fill: { c: 5, r: 36 },
  45. num: 293,
  46. },
  47. {
  48. type: ZeroNineType.Production,
  49. originC: 6,
  50. originR: { begin: 17, end: 27 },
  51. //填充到psr表中的位置
  52. fill: { c: 5, r: 37 },
  53. num: 301,
  54. },
  55. {
  56. type: ZeroNineType.UF,
  57. originC: 6,
  58. originR: { begin: 6, end: 16 },
  59. fill: { c: 5, r: 38 },
  60. num: 309,
  61. },
  62. {
  63. type: ZeroNineType.AI,
  64. originC: 6,
  65. originR: { begin: 172, end: 192 },
  66. fill: { c: 5, r: 39 },
  67. num: 317,
  68. },
  69. {
  70. type: ZeroNineType.Install,
  71. originC: 6,
  72. originR: { begin: 214, end: 224 },
  73. fill: { c: 5, r: 40 },
  74. num: 325,
  75. },
  76. {
  77. type: ZeroNineType.Construction,
  78. originC: 6,
  79. originR: { begin: 214, end: 224 },
  80. fill: { c: 5, r: 41 },
  81. num: 333,
  82. },
  83. {
  84. type: ZeroNineType.Equipment,
  85. originC: 8,
  86. originR: { begin: 6, end: 297 }, //总的减上面所有的
  87. fill: { c: 3, r: 36 },
  88. num: 291,
  89. },
  90. {
  91. type: ZeroNineType.Production,
  92. originC: 8,
  93. originR: { begin: 17, end: 27 },
  94. //填充到psr表中的位置
  95. fill: { c: 3, r: 37 },
  96. num: 299,
  97. },
  98. {
  99. type: ZeroNineType.UF,
  100. originC: 8,
  101. originR: { begin: 6, end: 16 },
  102. fill: { c: 3, r: 38 },
  103. num: 307,
  104. },
  105. {
  106. type: ZeroNineType.AI,
  107. originC: 8,
  108. originR: { begin: 172, end: 192 },
  109. fill: { c: 3, r: 39 },
  110. num: 315,
  111. },
  112. {
  113. type: ZeroNineType.Install,
  114. originC: 8,
  115. originR: { begin: 214, end: 224 },
  116. fill: { c: 3, r: 40 },
  117. num: 323,
  118. },
  119. {
  120. type: ZeroNineType.Construction,
  121. originC: 8,
  122. originR: { begin: 214, end: 224 },
  123. fill: { c: 3, r: 41 },
  124. num: 331,
  125. },
  126. ];
  127. const curMonthConfig = [
  128. {
  129. type: ZeroNineType.Equipment,
  130. originC: null,
  131. originR: { begin: 6, end: 297 }, //总的减上面所有的
  132. fill: { c: 7, r: 36 },
  133. num: 295,
  134. },
  135. {
  136. type: ZeroNineType.Production,
  137. originC: null, //需要计算的出,当前表单是第几月,取当月的那列
  138. originR: { begin: 17, end: 27 },
  139. fill: { c: 7, r: 37 },
  140. num: 303,
  141. },
  142. {
  143. type: ZeroNineType.UF,
  144. originC: null,
  145. originR: { begin: 6, end: 16 },
  146. fill: { c: 7, r: 38 },
  147. num: 311,
  148. },
  149. {
  150. type: ZeroNineType.AI,
  151. originC: null,
  152. originR: { begin: 172, end: 192 },
  153. fill: { c: 7, r: 39 },
  154. num: 319,
  155. },
  156. {
  157. type: ZeroNineType.Install,
  158. originC: null,
  159. originR: { begin: 214, end: 224 },
  160. fill: { c: 7, r: 40 },
  161. num: 327,
  162. },
  163. {
  164. type: ZeroNineType.Construction,
  165. originC: null,
  166. originR: { begin: 214, end: 224 },
  167. fill: { c: 7, r: 41 },
  168. num: 335,
  169. },
  170. ];
  171. const workConfig = [
  172. {
  173. code: '02-010',
  174. fill: { r: 7, actC: 3, curC: 7 }, // actC实际支出 curC当月发生额
  175. },
  176. {
  177. code: '04-010',
  178. fill: { r: 11, actC: 3, curC: 7 },
  179. },
  180. {
  181. code: '05-010',
  182. fill: { r: 16, actC: 3, curC: 7 },
  183. },
  184. {
  185. code: '06-010',
  186. fill: { r: 24, actC: 3, curC: 7 },
  187. },
  188. {
  189. code: '07-010',
  190. fill: { r: 28, actC: 3, curC: 7 },
  191. },
  192. {
  193. code: '08-010',
  194. fill: { r: 32, actC: 3, curC: 7 },
  195. },
  196. {
  197. code: '10-010',
  198. fill: { r: 44, actC: 3, curC: 7 },
  199. },
  200. {
  201. code: '11-010',
  202. fill: { r: 59, actC: 3, curC: 7 },
  203. },
  204. {
  205. code: '11-030',
  206. fill: { r: 61, actC: 3, curC: 7 },
  207. },
  208. {
  209. code: '11-050',
  210. fill: { r: 63, actC: 3, curC: 7 },
  211. },
  212. ];
  213. const PSRDetail = () => {
  214. const { initialState } = useModel('@@initialState');
  215. const user = initialState?.user || {};
  216. const navigate = useNavigate();
  217. const params = useParams();
  218. const location = useLocation();
  219. const token = getToken();
  220. const { id: projectId } = params;
  221. const {
  222. state: { project_name, flow_id, node_id, init_flow_id },
  223. } = location;
  224. const [historyList, setHistoryList] = useState([]);
  225. const [excelData, setExcelData] = useState();
  226. const [historyOpen, setHistoryOpen] = useState();
  227. const [open, setOpen] = useState(false);
  228. const [key, setKey] = useState();
  229. const [compareOpen, setCompareOpen] = useState(false);
  230. const [compareValues, setCompareValues] = useState([]);
  231. const [isOriginVer, setIsOriginVer] = useState(false); //是否原始版本 是的话只能另存不能编辑
  232. const luckysheetRef = useRef();
  233. const iframeRef = useRef();
  234. const unableEdit = (option) => {
  235. option.showtoolbar = false;
  236. option.enableAddRow = false;
  237. option.sheetFormulaBar = false;
  238. option.enableAddBackTop = false;
  239. option.showsheetbarConfig = {
  240. add: false,
  241. sheet: false,
  242. };
  243. option.cellRightClickConfig = {
  244. copy: false, // 复制
  245. copyAs: false, // 复制为
  246. paste: false, // 粘贴
  247. insertRow: false, // 插入行
  248. insertColumn: false, // 插入列
  249. deleteRow: false, // 删除选中行
  250. deleteColumn: false, // 删除选中列
  251. deleteCell: false, // 删除单元格
  252. hideRow: false, // 隐藏选中行和显示选中行
  253. hideColumn: false, // 隐藏选中列和显示选中列
  254. rowHeight: false, // 行高
  255. columnWidth: false, // 列宽
  256. clear: false, // 清除内容
  257. matrix: false, // 矩阵操作选区
  258. sort: false, // 排序选区
  259. filter: false, // 筛选选区
  260. chart: false, // 图表生成
  261. image: false, // 插入图片
  262. link: false, // 插入链接
  263. data: false, // 数据验证
  264. cellFormat: false, // 设置单元格格式
  265. };
  266. };
  267. //请求投标版、签字版psr excel
  268. // const { run: runExcel } = useRequest(queryPsrExcel, {
  269. // manual: true,
  270. // formatResult: (res) => {
  271. // if (res) {
  272. // const jsonData = JSON.parse(res);
  273. // renderSheet(jsonData);
  274. // }
  275. // },
  276. // });
  277. //请求月度psr和现金流列表 data_type 1 psr 2 现金流
  278. const {
  279. // data: historyList,
  280. run: runList,
  281. loading: listLoading,
  282. } = useRequest(
  283. (data) =>
  284. queryPsrMonthList({
  285. project_id: projectId,
  286. data_type: data_type,
  287. ...data,
  288. }),
  289. {
  290. manual: true,
  291. formatResult: (res) => {
  292. if (res.code == 200) {
  293. const list = res?.data?.list?.map((item) => {
  294. let name = dayjs(item.day).format('YYYY-MM');
  295. if (item.ver_type == 1) name = '原始版本';
  296. if (item.ver_type == 2) name = '基础版本';
  297. return { ...item, name };
  298. });
  299. setHistoryList(list);
  300. }
  301. },
  302. },
  303. );
  304. //保存/另存为月度psr和现金流接口
  305. const { run: runSave, loading: saveLoading } = useRequest(
  306. (data) => querySavePsrMonth(data),
  307. {
  308. manual: true,
  309. onSuccess: () => {
  310. message.success('保存成功');
  311. if (open) setOpen(false);
  312. },
  313. onError: () => {
  314. message.success('添加失败');
  315. },
  316. },
  317. );
  318. //请求月度psr和现金流详情接口
  319. const { run: runDetail } = useRequest((data) => queryPsrMonthDetail(data), {
  320. manual: true,
  321. formatResult: (res) => {
  322. if (res?.data) {
  323. let data = res.data;
  324. let name = dayjs(data.day).format('YYYY-MM');
  325. if (data.ver_type == 1) name = '原始版本';
  326. if (data.ver_type == 2) name = '基础版本';
  327. setExcelData({ ...data, name });
  328. setHistoryOpen(false);
  329. const jsonData = JSON.parse(data.json_data);
  330. if (jsonData[0].celldata && typeof jsonData[0].celldata == 'string')
  331. jsonData[0].celldata = JSON.parse(jsonData[0].celldata);
  332. if (jsonData[0].config && typeof jsonData[0].config == 'string')
  333. jsonData[0].config = JSON.parse(jsonData[0].config);
  334. renderSheet(jsonData, data.is_edit);
  335. }
  336. },
  337. });
  338. //请求签字版PSR历史版本列表
  339. const { run: run, loading: loading } = useRequest(
  340. (id) =>
  341. queryPsrExcelList({
  342. project_id: projectId,
  343. template_node_id: id,
  344. }),
  345. {
  346. manual: true,
  347. formatResult: (res) => {
  348. if (res.code == 200) {
  349. const list = res?.data?.list?.map((item) => {
  350. return { ...item, name: item.version_name };
  351. });
  352. setHistoryList(list);
  353. }
  354. },
  355. },
  356. );
  357. // useEffect(() => {
  358. // let url = '/psrData.json';
  359. // axios.get(url).then((res) => {
  360. // if (res.status == 200) {
  361. // renderSheet(res.data);
  362. // }
  363. // });
  364. // }, [key]);
  365. const data_type = useMemo(() => {
  366. if (key == '3') return 1;
  367. if (key == '4') return 2;
  368. return null;
  369. }, [key]);
  370. useEffect(() => {
  371. setCompareValues([]);
  372. if (key) {
  373. onChange(key);
  374. } else {
  375. queryPsrExcel({ gridKey: node_id });
  376. }
  377. }, [key]);
  378. //请求投标版、签字版psr excel
  379. const queryPsrExcel = (data) => {
  380. axios({
  381. url: `/api/v1/purchase/record/sheet?${stringify(data)}`,
  382. method: 'POST',
  383. data,
  384. headers: {
  385. 'JWT-TOKEN': token,
  386. },
  387. }).then((req) => {
  388. if (req.status == 200) {
  389. const jsonData = JSON.parse(req.data);
  390. renderSheet(jsonData);
  391. }
  392. });
  393. };
  394. const onChange = (key) => {
  395. if (key == '1') {
  396. queryPsrExcel({ gridKey: node_id });
  397. } else if (key == '2') {
  398. queryPsrExcel({ gridKey: flow_id });
  399. } else {
  400. initPsrActrual(key);
  401. }
  402. };
  403. //请求前两个tab的数据
  404. const initPsrActrual = async (key) => {
  405. const data_type = key == '3' ? 1 : 2;
  406. const res = await queryPsrMonthLast({ project_id: projectId, data_type });
  407. if (res.data?.length > 0 && res.data[0].json_data) {
  408. let name = dayjs(res.data[0].day).format('YYYY-MM');
  409. if (res.data[0].ver_type == 1) name = '原始版本';
  410. if (res.data[0].ver_type == 2) name = '基础版本';
  411. const isOrigin = res.data[0].ver_type == 1 ? 1 : 0;
  412. setIsOriginVer(isOrigin);
  413. setExcelData({ ...res.data[0], name });
  414. const data = JSON.parse(res.data[0].json_data);
  415. if (data.celldata) data.celldata = JSON.parse(data.celldata);
  416. if (data.config) data.config = JSON.parse(data.config);
  417. renderSheet(
  418. Array.isArray(data) ? data : [data],
  419. isOrigin ? 0 : res.data[0].is_edit,
  420. );
  421. }
  422. };
  423. //另存为月版本
  424. const handlerSaveOther = (data) => {
  425. const luckyData = luckysheetRef.current?.toJson();
  426. //设置表单日期
  427. const day =
  428. data.ver_type == 2 //基础版本是创建当天的日期 月版本是创建月份的最后一天
  429. ? dayjs().format('YYYY-MM-DD')
  430. : dayjs(data.day).endOf('month').format('YYYY-MM-DD');
  431. const celldata = luckyData?.data[0]?.celldata;
  432. const rc = key == '3' ? { r: 1, c: 1 } : { r: 1, c: 3 }; //psr日期位置是1 1 现金流日期位置是 1 3
  433. const dateItem = celldata?.find((item) => item.r == rc.r && item.c == rc.c);
  434. if (dateItem) {
  435. dateItem.v.v = day;
  436. dateItem.v.m = day;
  437. }
  438. if (luckyData?.data) {
  439. const params = {
  440. ...data,
  441. project_id: Number(projectId),
  442. json_data: JSON.stringify(luckyData.data),
  443. data_type: data_type,
  444. };
  445. runSave(params);
  446. }
  447. };
  448. //保存
  449. const handlerSave = () => {
  450. const luckyData = luckysheetRef.current?.toJson();
  451. let allData;
  452. //如果是现金流的保存。需要计算一些数值填充到psr中;
  453. if (key == '4') {
  454. //当月发生额数据 计算当月发生额的月份 originC
  455. let newMonthConfig = [...curMonthConfig];
  456. const celldata = luckyData.data[0].celldata;
  457. const originC = getMonthCol(celldata);
  458. if (originC || originC == 0) {
  459. newMonthConfig = curMonthConfig.map((item) => {
  460. return { ...item, originC };
  461. });
  462. }
  463. allData = getPsrDataByAct([...preActConfig, ...newMonthConfig]);
  464. console.log(allData);
  465. }
  466. const params = {
  467. id: excelData?.id,
  468. data_type: excelData?.data_type,
  469. project_id: excelData?.project_id,
  470. day: dayjs(excelData?.day).format('YYYY-MM-DD'),
  471. json_data: JSON.stringify(luckyData.data),
  472. psr_json_data: JSON.stringify(allData),
  473. };
  474. console.log(params);
  475. runSave(params);
  476. };
  477. //获取当月发生额的月份
  478. const getMonthCol = (celldata) => {
  479. //计算出当月发生额的月份 originC
  480. const date = changeDate(excelData?.day); //转换成55078这种格式
  481. const originC = celldata.find(
  482. (item) => item.r == 5 && Math.abs(item.v?.v - date) < 5,
  483. )?.c;
  484. return originC;
  485. };
  486. const getPsrDataByAct = (configList) => {
  487. const luckyData = luckysheetRef.current?.toJson();
  488. let otherValueTotal = 0; //获取除设备费之外的所有费用的和
  489. const preValues = configList.map((item) => {
  490. const celldata = luckyData.data[0].celldata;
  491. const {
  492. type,
  493. originC,
  494. num,
  495. originR: { begin, end },
  496. } = item;
  497. let value = 0;
  498. for (let i = begin; i <= end; i++) {
  499. const item = celldata.find((item) => item.c == originC && item.r == i);
  500. if (item?.v?.v) value += item.v.v;
  501. }
  502. if (type !== ZeroNineType.Equipment) otherValueTotal += value;
  503. return { num, value };
  504. });
  505. const EquPreItem = preValues.find(
  506. (item) => item.type == ZeroNineType.Equipment,
  507. );
  508. if (EquPreItem?.value)
  509. EquPreItem.value = EquPreItem?.value - otherValueTotal; //全部的费用 减去 除设备费之外的所有费用的和 得到设备费
  510. console.log('------预算列的值---------', preValues);
  511. return preValues;
  512. };
  513. const exportExcl = (title) => {
  514. const luckyData = luckysheetRef.current?.toJson();
  515. exportExcel(luckyData.data, title);
  516. };
  517. const handlerLoad = () => {
  518. const contentWindow = iframeRef.current.contentWindow;
  519. luckysheetRef.current = contentWindow.luckysheet;
  520. };
  521. const renderSheet = (currentData, is_edit = false) => {
  522. if (!luckysheetRef.current) {
  523. setTimeout(() => {
  524. renderSheet(currentData, is_edit);
  525. }, 500);
  526. return;
  527. }
  528. const data = currentData;
  529. //设置单元格不可编辑
  530. data?.forEach((item) => {
  531. item.config.authority = is_edit
  532. ? null
  533. : {
  534. sheet: true,
  535. hintText: '当前excel不可编辑!',
  536. };
  537. // 公式计算
  538. let calcChain = [];
  539. let index = item.index;
  540. item.celldata?.forEach((cell) => {
  541. if (typeof cell.v.f !== 'undefined') {
  542. calcChain.push({
  543. r: cell.r,
  544. c: cell.c,
  545. index,
  546. });
  547. }
  548. });
  549. item.calcChain = calcChain;
  550. });
  551. let option = {
  552. lang: 'zh',
  553. showinfobar: false,
  554. showstatisticBar: false,
  555. permissions: user?.Permission,
  556. data: JSON.parse(JSON.stringify(data)),
  557. hook: {
  558. cellMousedown: (cell, position, sheet) => {
  559. console.log(cell, sheet);
  560. },
  561. cellUpdated: () => {
  562. luckysheetRef.current.refreshFormula();
  563. },
  564. workbookCreateAfter: async () => {
  565. //当前为为终版psr标签并且可编辑状态时填充人日数据
  566. if (key == '3' && is_edit) {
  567. fillWorkLoadData();
  568. // const res = await queryPsrWorkLoad({ project_id: projectId });
  569. // if (res?.data) {
  570. // console.log('--------------------', res.data);
  571. // luckysheetRef.current.setCellValue(8, 4, res.data.Total);
  572. // luckysheetRef.current.setCellValue(8, 8, res.data.Month);
  573. // }
  574. }
  575. },
  576. },
  577. };
  578. option.data.forEach((item) => {
  579. delete item.data;
  580. if (item.celldata) {
  581. item.celldata.forEach((cell) => {
  582. // 生成uuid
  583. if (!cell.v.cid) cell.v.cid = getUUID();
  584. });
  585. }
  586. // 默认禁止编辑
  587. // item.config.authority = { sheet: true, hintText };
  588. });
  589. console.log(option.data);
  590. //设置不可编辑
  591. if (!is_edit) unableEdit(option);
  592. luckysheetRef.current.destroy();
  593. luckysheetRef.current.create(option);
  594. };
  595. const fillWorkLoadData = async () => {
  596. const param = { project_id: projectId };
  597. param.code = workConfig.map((item) => item.code).join(',');
  598. param.s_time = dayjs('2023-01').startOf('month').format('YYYY-MM-DD');
  599. param.e_time = dayjs('2023-07').endOf('month').format('YYYY-MM-DD');
  600. const res = await queryPsrWorkLoad(param);
  601. if (res?.data) {
  602. const data = { '02-010': [800, 100] };
  603. Object.keys(data).forEach((code) => {
  604. const list = data[code]; //第一个是当月的,第二个是累计的
  605. const fill = workConfig.find((item) => item.code == code)?.fill;
  606. if (list?.length > 0 && fill)
  607. luckysheetRef.current.setCellValue(fill.r, fill.curC, list[0]);
  608. luckysheetRef.current.setCellValue(fill.r, fill.actC, list[1]);
  609. });
  610. console.log('--------------------', res.data);
  611. // luckysheetRef.current.setCellValue(8, 4, res.data.Total);
  612. // luckysheetRef.current.setCellValue(8, 8, res.data.Month);
  613. }
  614. };
  615. const renderTitle = (data_type, title) => {
  616. if (compareValues?.length == 2) {
  617. return (
  618. <div className={styles.exportDiv}>
  619. <Button
  620. type="primary"
  621. onClick={() => {
  622. setCompareValues([]);
  623. setTimeout(() => {
  624. initPsrActrual(key);
  625. }, 500);
  626. }}
  627. >
  628. 退出比对
  629. </Button>
  630. </div>
  631. );
  632. }
  633. if (data_type == 0)
  634. //投标版psr
  635. return (
  636. <div className={styles.exportDiv}>
  637. <Button type="primary" onClick={() => exportExcl(title)}>
  638. 导出
  639. </Button>
  640. </div>
  641. );
  642. if (data_type == 3)
  643. //签字版psr
  644. return (
  645. <div className={styles.excelTitle}>
  646. <div>
  647. 当前PSR表单:
  648. <span style={{ color: 'blue' }}>{excelData?.name}</span>
  649. </div>
  650. <Space>
  651. <Button
  652. type="primary"
  653. onClick={() => {
  654. run(init_flow_id);
  655. setHistoryOpen(true);
  656. }}
  657. >
  658. {`${title}历史版本`}
  659. </Button>
  660. <Button type="primary" onClick={() => exportExcl(title)}>
  661. 导出
  662. </Button>
  663. </Space>
  664. </div>
  665. );
  666. //过程/终版psr 现金流
  667. return (
  668. <div className={styles.excelTitle}>
  669. <div>
  670. 当前PSR表单:
  671. <span style={{ color: 'blue' }}>{excelData?.name}</span>
  672. </div>
  673. <Space>
  674. <Button
  675. type="primary"
  676. onClick={() => {
  677. runList();
  678. setHistoryOpen(true);
  679. }}
  680. >
  681. {`${title}历史版本`}
  682. </Button>
  683. <Button
  684. type="primary"
  685. onClick={() => setOpen(true)}
  686. disabled={!excelData?.is_edit}
  687. >
  688. 另存为
  689. </Button>
  690. <Button
  691. type="primary"
  692. onClick={handlerSave}
  693. disabled={!excelData?.is_edit || isOriginVer}
  694. >
  695. 保存
  696. </Button>
  697. <Button type="primary" onClick={() => setCompareOpen(true)}>
  698. 比对
  699. </Button>
  700. <Button type="primary" onClick={() => exportExcl(title)}>
  701. 导出
  702. </Button>
  703. </Space>
  704. </div>
  705. );
  706. };
  707. const changeDate = (date) => {
  708. date = dayjs(date);
  709. const startDate = dayjs('1900-01-01');
  710. const daysDifference = date.diff(startDate, 'day');
  711. return daysDifference;
  712. };
  713. const items = [
  714. {
  715. key: '1',
  716. label: '投标版PSR',
  717. children: renderTitle(0, '投标版PSR'),
  718. },
  719. {
  720. key: '2',
  721. label: '签字版PSR',
  722. children: renderTitle(3, '签字版PSR'),
  723. },
  724. {
  725. key: '3',
  726. label: '过程/终版PSR',
  727. children: renderTitle(1, '过程/终版PSR'),
  728. },
  729. {
  730. key: '4',
  731. label: '现金流',
  732. children: renderTitle(2, '现金流'),
  733. },
  734. ];
  735. // const handlerOnChange = (event) => {
  736. // console.log(event);
  737. // console.log('----------------', luckysheetRef.current);
  738. // var file = event.target.files[0];
  739. // var fileName = file.name;
  740. // fileName = fileName + '';
  741. // //將文件加載到頁面上
  742. // LuckyExcel.transformExcelToLucky(
  743. // file,
  744. // function (exportJson, luckysheetfile) {
  745. // if (exportJson.sheets == null || exportJson.sheets.length == 0) {
  746. // alert(
  747. // 'Failed to read the content of the excel file, currently does not support xls files!',
  748. // );
  749. // return;
  750. // }
  751. // console.log(exportJson, luckysheetfile);
  752. // renderSheet(exportJson?.sheets);
  753. // // window.luckysheet.destroy();
  754. // // window.luckysheet.create({
  755. // // container: 'luckysheet', //luckysheet is the container id
  756. // // showinfobar:false,
  757. // // lang: 'zh', // 设定表格语言
  758. // // allowEdit: true,//作用:是否允许前台编辑
  759. // // // allowUpdate: true,
  760. // // allowCopy: true, //是否允许拷贝
  761. // // showtoolbar: true, //是否第二列显示工具栏
  762. // // showinfobar: true, //是否显示顶部名称栏
  763. // // showsheetbar: true, //是否显示底部表格名称区域
  764. // // showstatisticBar: true, //是否显示底部计数栏
  765. // // pointEdit: false, //是否是编辑器插入表格模式
  766. // // pointEditUpdate: null, //编辑器表格更新函数
  767. // // data:exportJson.sheets,
  768. // // title:exportJson.info.name,
  769. // // userInfo:exportJson.info.name.creator,
  770. // // functionButton: '<button id="" class="btn btn-primary" style=" padding:3px 6px; font-size: 16px;width: 100px;height: 27px; margin-right: 85px;" οnclick="downExcelData()">導出</button>',
  771. // // });
  772. // },
  773. // );
  774. // };
  775. const handlerDetailClick = (id) => {
  776. if (key == '2') {
  777. queryPsrExcel({ gridKey: id });
  778. setHistoryOpen(false);
  779. return;
  780. }
  781. runDetail({ id });
  782. };
  783. return (
  784. <PageContent>
  785. <div className={styles.titleDev}>
  786. <Button type="primary" onClick={() => navigate(-1)}>
  787. 返回
  788. </Button>
  789. {/* <input type="file" onChange={handlerOnChange} /> */}
  790. <span className={styles.title}>{project_name}</span>
  791. </div>
  792. <Tabs defaultActiveKey="1" type="card" items={items} onChange={setKey} />
  793. {compareValues?.length == 2 ? (
  794. <CompareCom values={compareValues} />
  795. ) : (
  796. <iframe
  797. style={{
  798. width: '100%',
  799. height: '80vh',
  800. }}
  801. ref={iframeRef}
  802. onLoad={handlerLoad}
  803. src="/luckysheet.html"
  804. />
  805. )}
  806. <Drawer
  807. title="历史版本"
  808. placement="right"
  809. loading={listLoading}
  810. onClose={() => setHistoryOpen(false)}
  811. open={historyOpen}
  812. >
  813. <Timeline
  814. items={historyList?.map((item) => {
  815. return {
  816. children: (
  817. <a onClick={() => handlerDetailClick(item.id)}>{item.name}</a>
  818. ),
  819. };
  820. })}
  821. />
  822. </Drawer>
  823. <SaveModal
  824. loading={saveLoading}
  825. open={open}
  826. onCancel={() => setOpen(false)}
  827. onOk={handlerSaveOther}
  828. />
  829. <CompareModal
  830. list={historyList}
  831. open={compareOpen}
  832. onOk={(values) => {
  833. setCompareValues(values);
  834. setCompareOpen(false);
  835. }}
  836. onCancel={() => setCompareOpen(false)}
  837. />
  838. </PageContent>
  839. );
  840. };
  841. export default PSRDetail;