index.jsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-07-26 10:13:13
  4. * @LastEditTime: 2021-09-10 09:20:09
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
  8. */
  9. import { PlusOutlined } from '@ant-design/icons';
  10. import { Button, Popconfirm,Tag } from 'antd';
  11. import React, { useState, useRef, useEffect } from 'react';
  12. import { PageContainer } from '@ant-design/pro-layout';
  13. import ProTable from '@ant-design/pro-table';
  14. import ProForm, { ModalForm, DrawerForm, ProFormSelect, ProFormTextArea, ProFormDigit, ProFormText } from '@ant-design/pro-form';
  15. import UpdateForm from './updateForm';
  16. import UpdateFormDrawer from './updateForm_drawer';
  17. // import CAUpload from '@/components/CAUpload';
  18. import DrawerContent from './selectCopyDrawer';
  19. import { getAccountingSubjectList } from '../accountingSubject/service';
  20. import {
  21. getCostshareparamConnectList, editCostshareparamConnectList, delCostshareparamConnect,
  22. addCostshareparamConnect, getResponsibilityCenterSelecterList, getAccountingSubjectForSelecter,
  23. getHasSetParamsList, getParamsSelectableList, saveParamsList, copyParamsList,getCopyableToList
  24. } from './service';
  25. import {deepGetAllParents} from '@/utils';
  26. const CostAllocationParamsConnect = () => {
  27. const columns = [
  28. {
  29. title: '分摊级别',
  30. dataIndex: 'shareLevel',
  31. key: 'shareLevel',
  32. hideInSearch: true,
  33. ellipsis: true,
  34. },
  35. {
  36. title: '责任中心编码',
  37. dataIndex: 'responsibilityCode',
  38. key: 'responsibilityCode',
  39. hideInSearch: true,
  40. ellipsis: true,
  41. },
  42. {
  43. title: '责任中心名',
  44. dataIndex: 'responsibilityName',
  45. key: 'responsibilityName',
  46. ellipsis: true,
  47. hideInSearch: false,
  48. render:(_,record) => {
  49. const {isShareCost,responsibilityName} = record;
  50. return isShareCost==1?<Tag color="default">{`${responsibilityName}(含)`}</Tag>:`${responsibilityName}`
  51. }
  52. },
  53. {
  54. title: '会计科目名称',
  55. dataIndex: 'accountingNames',
  56. key: 'accountingName',
  57. hideInSearch: true,
  58. ellipsis: true,
  59. },
  60. {
  61. title: '会计科目编码',
  62. dataIndex: 'accountingCodes',
  63. key: 'accountingCode',
  64. hideInSearch: true,
  65. ellipsis: true,
  66. },
  67. {
  68. title: '别名',
  69. dataIndex: 'alias',
  70. key: 'alias',
  71. ellipsis: true,
  72. hideInSearch: true,
  73. },
  74. {
  75. title: '备注',
  76. dataIndex: 'costNode',
  77. key: 'costNode',
  78. ellipsis: true,
  79. hideInSearch: true,
  80. },
  81. {
  82. title: '操作',
  83. dataIndex: 'option',
  84. valueType: 'option',
  85. width:'18%',
  86. render: (_, record) => [
  87. <a
  88. key="config1"
  89. onClick={() => {
  90. setDrawerVisible(true);
  91. setCurrentRow(record);
  92. setCurrentResponsibilityRow(record);
  93. }}
  94. >
  95. 分摊参数设置
  96. </a>,
  97. <a
  98. key="config1"
  99. onClick={() => {
  100. setCurrentRow(record);
  101. setDrawerType(1);
  102. setCopySelectDrawerVisible(true);
  103. }}
  104. >
  105. 复制
  106. </a>,
  107. <a
  108. key="config2"
  109. onClick={() => {
  110. setEdit(true);
  111. handleUpdateModalVisible(true);
  112. setCurrentRow(record);
  113. }}
  114. >
  115. 编辑
  116. </a>,
  117. <Popconfirm
  118. key="subscribeAlert"
  119. title="是否确定删除?"
  120. onConfirm={() => {
  121. setCurrentRow(record);
  122. delListHandler(record);
  123. }}
  124. >
  125. <a>删除</a>
  126. </Popconfirm>,
  127. ],
  128. },
  129. ];
  130. const drawerTableColumns = [
  131. {
  132. title: '分摊参数编码',
  133. dataIndex: 'shareParamCode',
  134. key: 'shareParamCode',
  135. hideInSearch: true,
  136. ellipsis: true,
  137. },
  138. {
  139. title: '分摊参数名称',
  140. dataIndex: 'shareParamName',
  141. key: 'shareParamName',
  142. hideInSearch: false,
  143. ellipsis: true,
  144. },
  145. {
  146. title: '分摊比例',
  147. dataIndex: 'shareParamPopout',
  148. key: 'shareParamPopout',
  149. hideInSearch: false,
  150. ellipsis: true,
  151. },
  152. {
  153. title: '操作',
  154. dataIndex: 'option',
  155. valueType: 'option',
  156. render: (_, record) => [
  157. <a
  158. key="config2"
  159. onClick={() => {
  160. setDrawerUpdateModalVisible(true);
  161. setCurrentRow(record);
  162. }}
  163. >
  164. 编辑
  165. </a>,
  166. <Popconfirm
  167. key="subscribeAlert"
  168. title="是否确定删除?"
  169. onConfirm={() => {
  170. setCurrentRow(record);
  171. delParamsListHandler(record);
  172. }}
  173. >
  174. <a>删除</a>
  175. </Popconfirm>,
  176. ],
  177. },
  178. ];
  179. const responsibilityColumns = [
  180. {
  181. title: '责任中心Id',
  182. dataIndex: 'id',
  183. key: 'id',
  184. hideInSearch: false,
  185. ellipsis: true,
  186. },
  187. {
  188. title: '责任中心名',
  189. dataIndex: 'responsibilityName',
  190. key: 'responsibilityName',
  191. hideInSearch: false,
  192. ellipsis: true,
  193. }
  194. ]
  195. const accountSubjectColumns = [
  196. {
  197. title: '会计科目Id',
  198. dataIndex: 'id',
  199. key: 'id',
  200. hideInSearch: false,
  201. ellipsis: true,
  202. },
  203. {
  204. title: '会计科目名名',
  205. dataIndex: 'accountingName',
  206. key: 'accountingName',
  207. hideInSearch: false,
  208. ellipsis: true,
  209. }
  210. ]
  211. const [createModalVisible, handleModalVisible] = useState(false);
  212. const [updateModalVisible, handleUpdateModalVisible] = useState(false);
  213. const [cascaderOptions, setCascaderOptions] = useState([]);
  214. const actionRef = useRef(); //表格
  215. const ref = useRef(); //新增表单
  216. const [currentResponsibilityRow, setCurrentResponsibilityRow] = useState({});
  217. const [currentRow, setCurrentRow] = useState(undefined);
  218. const [ifDisable, setIfDisable] = useState(false);
  219. const [selectedResponsibilityId, setSelectedResponsibilityId] = useState(null);
  220. const [selectedResponsibility, setSelectedResponsibility] = useState(null);
  221. const [copySelectDrawerVisible, setCopySelectDrawerVisible] = useState(false);
  222. const [drawerType, setDrawerType] = useState(0); //1 复制数据 2 新增选择会计科目
  223. const [accountType, setAccountType] = useState(2); // 1 收入 2 支出
  224. const [edit,setEdit] = useState(false);
  225. const drawerFormRef = useRef(); //DrawerForm
  226. const actionDrawertableRef = useRef(); //Drawertable
  227. const drawerModalRef = useRef(); //DrawerModal
  228. const [drawerVisible, setDrawerVisible] = useState(false);
  229. const [drawerMadalVisible, setDrawerMadalVisible] = useState(false);
  230. const [hasSetParamsList, setHasSetParamsList] = useState([]);
  231. const [selectedParam, setSelectedParam] = useState(null);
  232. const [newAddParamList, setNewAddParamList] = useState([]);
  233. const [drawerUpdateModalVisible, setDrawerUpdateModalVisible] = useState(false);
  234. const [expandedRowKeys,setexpandedRowKeys] = useState([]);
  235. const [selectedAccountSubjects,setSelectedAccountSubjects] = useState([]);
  236. const updateFormRef = useRef();
  237. /**
  238. *
  239. * @param {Boolean} bool 弹窗展示状态
  240. */
  241. const updateModalVisibleChange = (bool) => {
  242. handleUpdateModalVisible(bool);
  243. if (!bool) setCurrentRow(undefined);
  244. };
  245. const drawerUpdateModalVisibleChange = (bool) => {
  246. setDrawerUpdateModalVisible(bool);
  247. if (!bool) setCurrentRow(undefined);
  248. }
  249. //获取科室列表
  250. const getList = async (params = {}, sort, filter) => {
  251. const res = await getCostshareparamConnectList(params);
  252. return {
  253. data: res.data.list,
  254. total: res.data.totalCount,
  255. success: res.success,
  256. };
  257. };
  258. /**
  259. *
  260. * @param {Object} value 删除项数据
  261. */
  262. const delListHandler = async (value) => {
  263. const resp = await delCostshareparamConnect(value);
  264. if (resp.status == 200) {
  265. if (actionRef.current) {
  266. actionRef.current.reload();
  267. }
  268. }
  269. };
  270. /**
  271. *
  272. * @param {Object} record 表格行数据
  273. */
  274. const delParamsListHandler = (record) => {
  275. const { id } = record;
  276. const arr = hasSetParamsList;
  277. arr.splice(arr.findIndex(item => item.id === id), 1);
  278. setHasSetParamsList([].concat(arr));
  279. if (actionDrawertableRef.current) {
  280. actionDrawertableRef.current.reload();
  281. }
  282. }
  283. //分摊参数回调
  284. /**
  285. *
  286. * @param {Boolean} bool
  287. */
  288. const drawerVisibleChange = async (bool) => {
  289. // console.log({currentRow});
  290. if (bool) {
  291. //展示
  292. const { id } = currentRow;
  293. const resp = await getHasSetParamsList({ id });
  294. const { data, msg, status } = resp;
  295. // console.log({data, msg, status});
  296. if (status == 200) {
  297. setHasSetParamsList(data ? data : []);
  298. if (actionDrawertableRef.current) {
  299. actionDrawertableRef.current.reload();
  300. }
  301. }
  302. }
  303. setDrawerVisible(bool);
  304. }
  305. /**
  306. *
  307. * @param {Boolean} bool
  308. */
  309. const handleDrawerModalVisible = (bool) => {
  310. setDrawerMadalVisible(bool);
  311. }
  312. const getCopyableTableList = async () => {
  313. const {id:accountShareId} = currentRow;
  314. const resp = await getCopyableToList({accountShareId});
  315. const { status, data} = resp;
  316. if (status == 200) {
  317. return {
  318. data: data,
  319. total:data.length ,
  320. success: true
  321. }
  322. }
  323. }
  324. const getAccountingSubjects = async (params = {}, sort, filter) => {
  325. const resp = await getAccountingSubjectList({...params,accountType });
  326. const { status, data: { list, totalCount } } = resp;
  327. let accountingIdList=undefined;
  328. currentRow&&(accountingIdList = currentRow.accountingIdList)
  329. const defaultSelected = accountingIdList?accountingIdList.map(item=>Number(item)):[];
  330. // console.log({defaultSelected});
  331. setSelectedAccountSubjects(defaultSelected);
  332. const allParents = deepGetAllParents(list,'children');
  333. const ids = allParents?allParents.map(item=>item.id):[];
  334. setexpandedRowKeys(ids);
  335. if (status == 200) {
  336. return {
  337. data: list,
  338. total: totalCount,
  339. success: true
  340. }
  341. }
  342. }
  343. const selectAccountSubjecthandle = () => {
  344. setDrawerType(2);
  345. setCopySelectDrawerVisible(true);
  346. }
  347. useEffect(async () => {
  348. const respForSelecter = await getAccountingSubjectForSelecter();
  349. if (respForSelecter.status == 200) {
  350. setCascaderOptions(respForSelecter.data);
  351. }
  352. }, [])
  353. return (
  354. <PageContainer>
  355. <ProTable
  356. columns={columns}
  357. request={getList}
  358. actionRef={actionRef}
  359. rowKey="id"
  360. toolBarRender={() => [
  361. <Button
  362. key="button"
  363. icon={<PlusOutlined />}
  364. type="primary"
  365. onClick={() => {
  366. setEdit(false);
  367. handleModalVisible(true);
  368. }}
  369. >
  370. 新增
  371. </Button>
  372. ]}
  373. pagination={{
  374. pageSize: 10,
  375. }}
  376. search={{
  377. defaultCollapsed: false,
  378. labelWidth: 'auto',
  379. }}
  380. />
  381. <ModalForm
  382. title="新增成本分摊参数对应"
  383. width="800px"
  384. labelCol={{ span: 5, offset: 3 }}
  385. layout={'horizontal'}
  386. visible={createModalVisible}
  387. formRef={ref}
  388. onVisibleChange={(bool) => {
  389. if (ref.current) {
  390. setIfDisable(false);
  391. ref.current.resetFields();
  392. }
  393. handleModalVisible(bool);
  394. }}
  395. onFinish={async (value) => {
  396. // console.log({value});
  397. // console.log(ref.current.getFieldsValue(true));
  398. const { costNode,isShareCost=1,alias} = value;
  399. const { accountingIds } = ref.current.getFieldsValue(true);
  400. const { responsibilityCode, responsibilityId, responsibilityName, shareLevel } = selectedResponsibility;
  401. const success = await addCostshareparamConnect({
  402. responsibilityId: selectedResponsibilityId,
  403. accountingIds: accountingIds,isShareCost,alias,
  404. costNode, responsibilityName, shareLevel, responsibilityCode
  405. });
  406. // console.log({ success });
  407. if (success) {
  408. handleModalVisible(false);
  409. if (actionRef.current) {
  410. actionRef.current.reload();
  411. }
  412. }
  413. }}
  414. >
  415. <ProFormSelect
  416. rules={[
  417. {
  418. required: true,
  419. message: '请选择责任中心',
  420. },
  421. ]}
  422. fieldProps={{//这里使用了select的onChange方法,必须使用这样的写法来进行调用onChange方法
  423. onChange: async (val) => {
  424. setSelectedResponsibilityId(val);
  425. const resp = await getResponsibilityCenterSelecterList();
  426. const { data, msg, status } = resp;
  427. if (status == 200) {
  428. const selected = data.filter(item => item.id == val);
  429. setSelectedResponsibility(selected[0]);
  430. if (selected && selected[0].calcType == 1) {
  431. setIfDisable(false);
  432. } else {
  433. setIfDisable(true);
  434. }
  435. }
  436. },
  437. }}
  438. request={async () => {
  439. const resp = await getResponsibilityCenterSelecterList();
  440. const { data=[], msg, status } = resp;
  441. if (status == 200) {
  442. return data.map(item => ({
  443. label: item.responsibilityName,
  444. value: item.id
  445. }))
  446. }
  447. }}
  448. width="sm"
  449. name="responsibilityId"
  450. label="请选择责任中心"
  451. />
  452. <ProFormText
  453. disabled={ifDisable}
  454. rules={[
  455. {
  456. required: ifDisable?false:true,
  457. message: '请选择会计科目',
  458. },
  459. ]}
  460. fieldProps={{
  461. onClick: () => selectAccountSubjecthandle()
  462. }}
  463. width="sm"
  464. name="accountingName"
  465. label="选择会计科目"
  466. />
  467. <ProFormSelect
  468. disabled={ifDisable}
  469. rules={[
  470. {
  471. required: ifDisable?false:true,
  472. message: '请选择',
  473. },
  474. ]}
  475. width="sm"
  476. request={async () => [
  477. { label: '不包含分摊成本', value: 0 },
  478. { label: '包含分摊成本', value: 1 }
  479. ]}
  480. name="isShareCost"
  481. label="是否包含分摊成本"
  482. />
  483. <ProFormText
  484. width="sm"
  485. name="alias"
  486. label="别名"
  487. />
  488. <ProFormTextArea
  489. name="costNode"
  490. label="备注"
  491. width={300}
  492. placeholder="请输入备注"
  493. />
  494. </ModalForm>
  495. {/* 成本分摊参数设置 */}
  496. <DrawerForm
  497. title="分摊参数设置"
  498. formRef={drawerFormRef}
  499. visible={drawerVisible}
  500. onVisibleChange={(visible) => drawerVisibleChange(visible)}
  501. // onFinish={(value) => onSubmit({ ...values, ...value })}
  502. onFinish={async () => {
  503. if (true) {
  504. const { id } = currentResponsibilityRow;
  505. const resp = await saveParamsList({
  506. id,
  507. shareParamProportionVOList: hasSetParamsList
  508. });
  509. const { status } = resp;
  510. if (status == 200) {
  511. setDrawerVisible(false);
  512. if (actionRef.current) {
  513. actionRef.current.reload();
  514. }
  515. }
  516. }
  517. }}
  518. >
  519. <ProTable
  520. columns={drawerTableColumns}
  521. rowKey="id"
  522. actionRef={actionDrawertableRef}
  523. toolBarRender={() => [
  524. <Button
  525. key="button"
  526. icon={<PlusOutlined />}
  527. type="primary"
  528. onClick={() => {
  529. setDrawerMadalVisible(true);
  530. setCurrentRow(undefined);
  531. }}
  532. >
  533. 新增
  534. </Button>
  535. ]}
  536. request={async (params = {}, sort, filter) => {
  537. // console.log({ hasSetParamsList });
  538. return {
  539. data: hasSetParamsList,
  540. success: true
  541. };
  542. }}
  543. pagination={false}
  544. search={false}
  545. />
  546. <ModalForm
  547. title="新增分摊参数"
  548. width="800px"
  549. labelCol={{ span: 5, offset: 3 }}
  550. layout={'horizontal'}
  551. visible={drawerMadalVisible}
  552. formRef={drawerModalRef}
  553. onVisibleChange={(bool) => {
  554. if (drawerModalRef.current) {
  555. drawerModalRef.current.resetFields();
  556. }
  557. handleDrawerModalVisible(bool);
  558. }}
  559. onFinish={async (value) => {
  560. // console.log({ '新增分摊参数': value, selectedParam,hasSetParamsList});
  561. const { shareParamPopout } = value;
  562. const { id, shareParamCode, shareParamName } = selectedParam;
  563. setHasSetParamsList(hasSetParamsList.concat([{
  564. id, shareParamCode, shareParamName, shareParamPopout
  565. }]));
  566. setNewAddParamList(newAddParamList.concat([{
  567. id, shareParamCode, shareParamName, shareParamPopout
  568. }]));
  569. setDrawerMadalVisible(false);
  570. if (actionDrawertableRef.current) {
  571. actionDrawertableRef.current.reload();
  572. }
  573. }}
  574. >
  575. <ProFormSelect
  576. rules={[
  577. {
  578. required: true,
  579. message: '请选择责任中心',
  580. },
  581. ]}
  582. fieldProps={{//这里使用了select的onChange方法,必须使用这样的写法来进行调用onChange方法
  583. onChange: async (val) => {
  584. // setSelectedParam(val);
  585. const { id } = currentResponsibilityRow;
  586. // console.log({currentResponsibilityRow});
  587. const resp = await getParamsSelectableList({ id });
  588. const { data:{list=[]}, status } = resp;
  589. // console.log({resp});
  590. if (status == 200) {
  591. const selected = list.filter(item => item.id == val);
  592. console.log({ selected });
  593. setSelectedParam(selected[0]);
  594. }
  595. },
  596. }}
  597. request={async () => {
  598. const { id } = currentResponsibilityRow;
  599. const resp = await getParamsSelectableList({ id });
  600. const { data:{list=[]}, status } = resp;
  601. // console.log({ resp });
  602. if (status == 200) {
  603. const temp = list.map(item => ({
  604. label: item.shareParamName,
  605. value: item.id
  606. }));
  607. return temp;
  608. }
  609. }}
  610. width="sm"
  611. name="id"
  612. label="请选择分摊参数"
  613. />
  614. <ProFormDigit width={100} label="分摊比例" name="shareParamPopout" min={0} max={100} />
  615. </ModalForm>
  616. {/* 分摊更新 */}
  617. <UpdateFormDrawer
  618. onSubmit={async (value) => {
  619. const {id,selectedParam} = value;
  620. const index = hasSetParamsList.findIndex(item=>item.id == id);
  621. let temp = hasSetParamsList;
  622. temp[index] = value;
  623. if(selectedParam){
  624. //修改了分摊参数名
  625. const {shareParamCode,shareParamName} = selectedParam;
  626. temp[index] = {...temp[index],shareParamCode,shareParamName}
  627. // console.log({shareParamCode,shareParamName,'temp[index]':temp[index]});
  628. }
  629. setHasSetParamsList([].concat(temp));
  630. setDrawerUpdateModalVisible(false);
  631. if (actionDrawertableRef.current) {
  632. actionDrawertableRef.current.reload();
  633. }
  634. }}
  635. onCancel={() => {
  636. drawerUpdateModalVisible(false);
  637. setCurrentRow(undefined);
  638. }}
  639. currentResponsibilityRow={currentResponsibilityRow}
  640. drawerUpdateModalVisible={drawerUpdateModalVisible}
  641. drawerUpdateModalVisibleChange={drawerUpdateModalVisibleChange}
  642. values={currentRow || {}}
  643. />
  644. </DrawerForm>
  645. {/* 选择复制抽屉 */}
  646. {
  647. drawerType != 0 && (
  648. <DrawerContent
  649. columns={drawerType == 1 ? responsibilityColumns : accountSubjectColumns}
  650. visible={copySelectDrawerVisible}
  651. currentRow={currentRow}
  652. title={drawerType == 1 ? '选择复制目标' : '选择会计科目'}
  653. defaultSelected={drawerType == 1?[]:selectedAccountSubjects}
  654. pageContainerConfig={(tableRef) => {
  655. return {
  656. header: {
  657. title: ''
  658. }
  659. }
  660. }}
  661. onVisibleChange={(bool) => setCopySelectDrawerVisible(bool)}
  662. renderListFunc={drawerType == 1 ? getCopyableTableList : getAccountingSubjects}
  663. config={{ rowKeys: 'id', tableSearch: false }}
  664. tableSearch={false}
  665. expandable={{
  666. expandedRowKeys:expandedRowKeys
  667. }}
  668. onFinishFunc={async (value, selectedRowKeys, selectedRows) => {
  669. // console.log({ value, selectedRowKeys, selectedRows,drawerType });
  670. if (drawerType == 1) {
  671. const { id } = currentRow;
  672. const resp = await copyParamsList({ id, responsibilityIds: selectedRowKeys });
  673. const { status } = resp;
  674. if (status == 200) {
  675. setCurrentRow(undefined);
  676. setCopySelectDrawerVisible(false);
  677. if (actionRef.current) {
  678. actionRef.current.reload();
  679. }
  680. }
  681. }
  682. if (drawerType == 2) {
  683. //selectedRows为空标识没有编辑
  684. let selectedItemNames = selectedRows.map(item => item.accountingName);
  685. if(edit){
  686. if(selectedRows.length>0){
  687. if (updateFormRef.current) {
  688. updateFormRef.current.setFieldsValue({ accountingNames: selectedItemNames.join(','), accountingIds: selectedRowKeys.join(',') })
  689. }
  690. }
  691. }
  692. if(!edit){
  693. if (ref.current) {
  694. ref.current.setFieldsValue({ accountingName:selectedItemNames.join(','), accountingIds: selectedRowKeys.join(',') })
  695. }
  696. }
  697. setCopySelectDrawerVisible(false);
  698. }
  699. setDrawerType(0);
  700. }}
  701. />
  702. )
  703. }
  704. {/* 更新 */}
  705. <UpdateForm
  706. onSubmit={async (value) => {
  707. // console.log({ '编辑': value });
  708. // // return;
  709. // console.log(updateFormRef.current.getFieldsValue(true));
  710. const { accountingIds } = updateFormRef.current.getFieldsValue(true);
  711. const { responsibilityId,responsibilityName,responsibilityCode,shareLevel,ifDisable, costNode,alias, id,isShareCost=1 } = value;
  712. console.log({alias});
  713. const success = await editCostshareparamConnectList(ifDisable ? {
  714. responsibilityId, costNode, id,responsibilityName,responsibilityCode,shareLevel,isShareCost,alias
  715. } : { responsibilityId,accountingIds, costNode,alias,id,responsibilityName,responsibilityCode,shareLevel,isShareCost });
  716. if (success) {
  717. handleUpdateModalVisible(false);
  718. setCurrentRow(undefined);
  719. if (actionRef.current) {
  720. actionRef.current.reload();
  721. }
  722. }
  723. }}
  724. onCancel={() => {
  725. handleUpdateModalVisible(false);
  726. setCurrentRow(undefined);
  727. }}
  728. updateModalVisible={updateModalVisible}
  729. updateModalVisibleChange={updateModalVisibleChange}
  730. values={currentRow || {}}
  731. updateFormRef={updateFormRef}
  732. selectAccountSubjecthandle={selectAccountSubjecthandle}
  733. />
  734. </PageContainer>
  735. );
  736. };
  737. export default CostAllocationParamsConnect;