Просмотр исходного кода

完成周四项目进度相关功能

code4eat 4 лет назад
Родитель
Сommit
b918836356
49 измененных файлов с 3840 добавлено и 967 удалено
  1. 2 2
      config/config.js
  2. 8 3
      config/defaultSettings.js
  3. 1 1
      config/proxy.js
  4. 17 2
      config/routes.js
  5. 4 4
      mock/apportionmentLevel.js
  6. 142 0
      mock/costShareParamsSettingConnect.js
  7. 45 77
      src/app.jsx
  8. 8 4
      src/components/CAUpload/index.jsx
  9. 1 1
      src/components/RightContent/AvatarDropdown.jsx
  10. 2 2
      src/global.jsx
  11. 3 3
      src/pages/accountingSubject/index.jsx
  12. 22 3
      src/pages/accountingSubjectConnect/index.jsx
  13. 135 0
      src/pages/apportionmentLevel/components/drawerContent.jsx
  14. 54 26
      src/pages/apportionmentLevel/index.jsx
  15. 21 15
      src/pages/apportionmentLevel/updateForm.jsx
  16. 0 99
      src/pages/baseSetting/reportProjectSetting/component/drawer.jsx
  17. 135 0
      src/pages/baseSetting/reportProjectSetting/component/drawerContent.jsx
  18. 280 205
      src/pages/baseSetting/reportProjectSetting/index.js
  19. 12 1
      src/pages/baseSetting/reportProjectSetting/service.js
  20. 5 3
      src/pages/baseSetting/reportProjectSetting/updateForm.jsx
  21. 3 3
      src/pages/baseSetting/visitsAndBedDayCostSetting/index.jsx
  22. 10 8
      src/pages/costAccounting/afterCollectionSearch/index.jsx
  23. 8 2
      src/pages/costAccounting/beforeCollectionSearch/index.jsx
  24. 238 0
      src/pages/costAccounting/beforeCostShareSearch/index.jsx
  25. 33 0
      src/pages/costAccounting/beforeCostShareSearch/service.js
  26. 150 0
      src/pages/costAccounting/costShareParamsHandle/components/drawerContent.jsx
  27. 823 0
      src/pages/costAccounting/costShareParamsHandle/index.js
  28. 72 0
      src/pages/costAccounting/costShareParamsHandle/service.js
  29. 124 0
      src/pages/costAccounting/costShareParamsHandle/updateForm.jsx
  30. 2 2
      src/pages/costAccounting/incomeCollection/index.jsx
  31. 33 18
      src/pages/costAccounting/incomeCostDataImport/index.jsx
  32. 300 0
      src/pages/costAccounting/wholeHospIncomeAndCost/index.jsx
  33. 51 0
      src/pages/costAccounting/wholeHospIncomeAndCost/service.js
  34. 295 79
      src/pages/costAllocationParamsConnect/index.jsx
  35. 138 0
      src/pages/costAllocationParamsConnect/selectCopyDrawer.jsx
  36. 27 2
      src/pages/costAllocationParamsConnect/service.js
  37. 58 23
      src/pages/costAllocationParamsConnect/updateForm.jsx
  38. 3 4
      src/pages/costAllocationParamsConnect/updateForm_drawer.js
  39. 83 108
      src/pages/costAllocationParamsSetting/index.jsx
  40. 138 0
      src/pages/costAllocationParamsSetting/selectCopyDrawer.jsx
  41. 1 1
      src/pages/costProjectMana/index.jsx
  42. 5 4
      src/pages/platformMana/menuManage/index.js
  43. 2 2
      src/pages/platformMana/menuManage/updateForm.jsx
  44. 23 10
      src/pages/platformMana/roleManage/component/drawer.jsx
  45. 2 1
      src/pages/platformMana/roleManage/index.js
  46. 162 139
      src/pages/responsibilityCenter/index.jsx
  47. 85 71
      src/pages/responsibilityCenter/updateForm.jsx
  48. 18 37
      src/pages/user/Login/index.jsx
  49. 56 2
      src/utils.js

+ 2 - 2
config/config.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-22 15:04:09
- * @LastEditTime: 2021-08-13 09:46:17
+ * @LastEditTime: 2021-08-23 11:37:04
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/config/config.js
@@ -9,7 +9,7 @@
 // https://umijs.org/config/
 import { defineConfig } from 'umi';
 import { join } from 'path';
-import defaultSettings from './defaultSettings';
+import {Settings as defaultSettings} from './defaultSettings';
 import proxy from './proxy';
 import routes from './routes';
 const { REACT_APP_ENV } = process.env;

+ 8 - 3
config/defaultSettings.js

@@ -1,14 +1,15 @@
 /*
  * @Author: your name
  * @Date: 2021-07-22 15:04:09
- * @LastEditTime: 2021-08-02 11:51:42
+ * @LastEditTime: 2021-08-23 11:41:59
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/config/defaultSettings.js
  */
 
+console.log('process.env.NODE_ENV',process.env.NODE_ENV);
 
-const Settings = {
+export const Settings = {
   navTheme: 'light',
   // 拂晓蓝
   primaryColor: '#00528E',
@@ -25,4 +26,8 @@ const Settings = {
   logo:'https://i.postimg.cc/WzYX2nfQ/KC-white.png',
   iconfontUrl: '',
 };
-export default Settings;
+
+export const envConfig = {
+    host:process.env.NODE_ENV == 'development'?'http://112.124.59.133:8082':'http://112.124.59.133:8082'
+}
+

+ 1 - 1
config/proxy.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-22 15:04:09
- * @LastEditTime: 2021-08-12 10:15:56
+ * @LastEditTime: 2021-08-17 09:16:58
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/config/proxy.js

+ 17 - 2
config/routes.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-22 15:04:09
- * @LastEditTime: 2021-08-12 09:59:23
+ * @LastEditTime: 2021-08-23 10:56:02
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/config/routes.js
@@ -95,6 +95,21 @@ export default [
         path: '/costAccounting/afterCollectionSearch',
         name: '归集后查询',
         component: './costAccounting/afterCollectionSearch/index',
+      },
+      {
+        path: '/costAccounting/costShareParamsHandle',
+        name: '月成本分摊参数值处理',
+        component: './costAccounting/costShareParamsHandle/index',
+      },
+      {
+        path: '/costAccounting/wholeHospIncomeAndCost',
+        name: '全院其他收支',
+        component: './costAccounting/wholeHospIncomeAndCost/index',
+      },
+      {
+        path: '/costAccounting/beforeCostShareSearch',
+        name: '成本分摊前查询',
+        component: './costAccounting/beforeCostShareSearch/index',
       }
     ]
   },
@@ -182,7 +197,7 @@ export default [
   },
   {
     path: '/',
-    redirect: '/UserMana',
+    redirect: '/costAccounting',
   },
   {
     component: './404',

+ 4 - 4
mock/apportionmentLevel.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-27 19:23:55
- * @LastEditTime: 2021-07-27 19:26:28
+ * @LastEditTime: 2021-08-17 09:12:31
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/config/apportionmentLevel.js
@@ -192,7 +192,7 @@ function updateList(req, res, u, b) {
 export default {
   // GET 科室列表
 
-  'GET /api/costsharelevel/list':getList,
-  'POST /api/costsharelevel/save': updateList,
-  'DELETE /api/costsharelevel/delete': updateList,
+  'GET /api/costAccount/costsharelevel/list':getList,
+  'POST /api/costAccount/costsharelevel/save': updateList,
+  'DELETE /api/costAccount/costsharelevel/delete': updateList,
 };

+ 142 - 0
mock/costShareParamsSettingConnect.js

@@ -0,0 +1,142 @@
+/*
+ * @Author: your name
+ * @Date: 2021-08-16 15:36:05
+ * @LastEditTime: 2021-08-16 16:26:15
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /CostAccountManaSys/mock/costShareParamsSettingConnect.js
+ */
+
+
+/*
+ * @Author: your name
+ * @Date: 2021-08-04 18:43:08
+ * @LastEditTime: 2021-08-04 18:44:57
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /CostAccountManaSys/mock/costShareParams.js
+ */
+
+
+
+
+
+// eslint-disable-next-line import/no-extraneous-dependencies
+import moment from 'moment';
+import { parse } from 'url'; // mock tableListDataSource
+
+
+//成本分摊参数设置对应
+
+const genList = (current, pageSize) => {
+  
+  const tableListDataSource = [];
+
+  for (let i = 0; i < pageSize; i += 1) {
+    const index = (current - 1) * 10 + i;
+    tableListDataSource.push({
+      key: index,
+      id: index,
+      calcType:1,
+      shareParamCode:index,
+      shareParamName:`分摊参数名${i}`,
+    });
+  }
+  //   console.log({tableListDataSource});
+  tableListDataSource.reverse();
+  return tableListDataSource;
+};
+
+
+const getLevelTwo = (req, res, u)=>{
+       const result = {
+        data:tableListDataSource,
+        status: 200,
+        success: true,
+      };
+      return res.json(result);
+}
+
+const selectAccounting = (req, res, u)=>{
+    const result = {
+        data: {
+          list: tableListDataSource,
+          totalCount: tableListDataSource.length,
+          pageSize: 10,
+        },
+        status: 200,
+        success: true,
+      };
+      return res.json(result);
+
+}
+
+let tableListDataSource = genList(1, 100);
+
+function getList(req, res, u) {
+  let realUrl = u;
+
+  if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
+    realUrl = req.url;
+  }
+
+  const { current = 1, pageSize = 10 } = req.query;
+  let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
+
+  const result = {
+    data: {
+      list: dataSource,
+      totalCount: tableListDataSource.length,
+      pageSize: pageSize,
+    },
+    status: 200,
+    success: true,
+  };
+  return res.json(result);
+}
+
+function postList(req, res, u, b) {
+  let realUrl = u;
+
+  if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
+    realUrl = req.url;
+  }
+
+  const { method, body } = req;
+
+  tableListDataSource.push({ ...body });
+
+  const result = {
+    status: 200,
+    msg: '',
+  };
+  res.json(result);
+}
+
+function delList(req, res, u, b) {
+  const { method, body } = req;
+  tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
+  const result = {
+    status: 200,
+    msg: '',
+  };
+  res.json(result);
+}
+
+function bindList(req, res, u, b) {
+  const { method, body } = req;
+  const { roleId, userIds } = body;
+  const result = {
+    status: 200,
+    msg: '',
+  };
+  res.json(result);
+}
+
+export default {
+  'GET /api/costAccount/costaccountshare/list': getList,
+  'GET /api/costAccount/responsibility/getLevelTwo': getLevelTwo,
+  'GET /api/costAccount/accounting/selectAccounting': selectAccounting,
+//   'POST /api/costAccount/role/delete': delList,
+//   'POST /api/costAccount/role/editUserRole': bindList,
+};

+ 45 - 77
src/app.jsx

@@ -69,21 +69,28 @@ export const initialStateConfig = {
  * */
 
 export async function getInitialState() {
+
   const fetchUserInfo = async () => {
     const userData = localStorage.getItem('userData');
     if (userData) {
       return JSON.parse(userData);
     }
     return undefined;
-  }; // 如果是登录页面,不执行
+  };
+
+
 
   const getMenuDataFromServer = async () => {
-    const resp = await getMenus();
-    const { status, data } = resp;
-    if (status == 200) {
-      return data;
-    } else {
-      return [];
+    if (window.location.pathname !== `/user/login`) {
+      const resp = await getMenus();
+      const { status, data } = resp;
+      if (status == 200) {
+        return data;
+      } else {
+        return [{
+          component: './404',
+        },];
+      }
     }
   };
 
@@ -101,6 +108,7 @@ export async function getInitialState() {
 
   if (history.location.pathname !== loginPath) {
     const currentUser = await fetchUserInfo();
+    const menu = await getMenuDataFromServer();
     return {
       fetchUserInfo,
       currentUser,
@@ -108,7 +116,7 @@ export async function getInitialState() {
       isExpired: false,
       fetchSubHosp,
       sign,
-      getMenuDataFromServer
+      menu: menu
     };
   }
 
@@ -116,8 +124,7 @@ export async function getInitialState() {
     fetchUserInfo,
     settings: {},
     fetchSubHosp,
-    sign,
-    getMenuDataFromServer
+    sign
   };
 }
 
@@ -127,7 +134,6 @@ export async function getInitialState() {
  */
 const loginOut = async () => {
   // await outLogin();
-  // Note: There may be security issues, please not
   localStorage.removeItem('userData');
   localStorage.removeItem('menus');
   if (window.location.pathname !== `/user/login` && !redirect) {
@@ -141,44 +147,7 @@ const loginOut = async () => {
   }
 };
 
-/**
- * 异常处理程序
-    200: '服务器成功返回请求的数据。',
-    201: '新建或修改数据成功。',
-    202: '一个请求已经进入后台排队(异步任务)。',
-    204: '删除数据成功。',
-    400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
-    401: '用户没有权限(令牌、用户名、密码错误)。',
-    403: '用户得到授权,但是访问是被禁止的。',
-    404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
-    405: '请求方法不被允许。',
-    406: '请求的格式不可得。',
-    410: '请求的资源被永久删除,且不会再得到的。',
-    422: '当创建一个对象时,发生一个验证错误。',
-    500: '服务器发生错误,请检查服务器。',
-    502: '网关错误。',
-    503: '服务不可用,服务器暂时过载或维护。',
-    504: '网关超时。',
- //-----English
-    200: The server successfully returned the requested data. ',
-    201: New or modified data is successful. ',
-    202: A request has entered the background queue (asynchronous task). ',
-    204: Data deleted successfully. ',
-    400: 'There was an error in the request sent, and the server did not create or modify data. ',
-    401: The user does not have permission (token, username, password error). ',
-    403: The user is authorized, but access is forbidden. ',
-    404: The request sent was for a record that did not exist. ',
-    405: The request method is not allowed. ',
-    406: The requested format is not available. ',
-    410':
-        'The requested resource is permanently deleted and will no longer be available. ',
-    422: When creating an object, a validation error occurred. ',
-    500: An error occurred on the server, please check the server. ',
-    502: Gateway error. ',
-    503: The service is unavailable. ',
-    504: The gateway timed out. ',
- * @see cd 
- */
+
 
 //请求拦截器
 const authHeaderInterceptor = (url, options) => {
@@ -207,8 +176,7 @@ const authHeaderInterceptor = (url, options) => {
 
 //响应拦截器
 const demoResponseInterceptors = async (response, options) => {
-  // response.headers.append('interceptors', 'yes yo');
-  // console.log({response});
+
   try {
 
     const { status } = response;
@@ -226,7 +194,7 @@ const demoResponseInterceptors = async (response, options) => {
         });
       } else {
         notification.error({
-          message:`错误 ${status}`
+          message: `错误 ${status}`
         });
       }
     }
@@ -252,12 +220,14 @@ const demoResponseInterceptors = async (response, options) => {
           }
         });
       } else {
-        notification.error({
-          message: errorMessage,
-          duration: 5,
-        });
+        if (errorMessage) {
+          notification.error({
+            message: errorMessage,
+            duration: 5,
+          });
+        }
       }
-      
+
     }
 
   } catch (err) {
@@ -275,7 +245,7 @@ export const request = {
   // 新增自动添加AccessToken的请求前拦截器
   requestInterceptors: [authHeaderInterceptor],
   responseInterceptors: [demoResponseInterceptors],
-}; // ProLayout 支持的api https://procomponents.ant.design/components/layout
+}; 
 
 
 
@@ -283,7 +253,7 @@ export const request = {
 const mappingIcon = menuData => {
   const mappingMenu = menuData.map(item => ({
     ...item,
-    icon: iconEnum[item.icon],
+    icon: item.icon&&iconEnum[item.icon],
     children: item.children ? mappingIcon(item.children) : [],
   }));
   return mappingMenu;
@@ -291,18 +261,11 @@ const mappingIcon = menuData => {
 
 
 
+
+
 export const layout = async ({ initialState }) => {
 
-  // const localMenus = localStorage.getItem('menus');
-  // console.log({pathname,localMenus});
 
-  // let menus = [];
-  // if(pathname != '/user/login'){
-  //   const {getMenuDataFromServer} = initialState;
-  //   const menu = await getMenuDataFromServer();
-  //   menus = mappingIcon(menu);
-  //   localStorage.setItem('menus',menus);
-  // }
 
 
   return {
@@ -315,11 +278,6 @@ export const layout = async ({ initialState }) => {
     footerRender: () => <Footer />,
     onPageChange: () => {
       const { location } = history; // 如果没有登录,重定向到 login
-      // console.log('location.pathname',location.pathname);
-      // console.log('layoutActionRef.current',layoutActionRef.current);
-      if (layoutActionRef.current) {
-        layoutActionRef.current.reload();
-      }
       if (!initialState?.currentUser && location.pathname !== '/user/login') {
         history.push(loginPath);
       }
@@ -331,15 +289,25 @@ export const layout = async ({ initialState }) => {
       //   return menuData;
       // },
 
-
       params: {
         userId: initialState?.currentUser?.userid,
       },
       request: async (params, defaultMenuData) => {
         // initialState.currentUser 中包含了所有用户信息
-        const menuData = await getMenus();
-        // console.log({menuData});
-        return menuData.data;
+        const { currentUser} = initialState;
+
+        if (currentUser) {
+          const resp = await getMenus();
+          const { data: menu } = resp;
+  
+          return mappingIcon(menu);
+        } else {
+          return [
+            {
+              component: './404',
+            }
+          ]
+        }
       },
     },
     links: isDev

+ 8 - 4
src/components/CAUpload/index.jsx

@@ -5,9 +5,13 @@ import { ImportOutlined } from '@ant-design/icons';
 import React, { Component } from 'react';
 import PropTypes from 'prop-types';
 import { Button, Upload, message, Modal, Divider, Menu, Dropdown } from 'antd';
+import {envConfig} from '../../../config/defaultSettings';
 // import Cookies from 'js-cookie';
+
 // 服务器地址
-const Host = 'http://112.124.59.133:8082';
+
+const {host} = envConfig;
+const Host = host;
 
 
 
@@ -128,7 +132,7 @@ class CAUpload extends Component {
 
 
     handleMenuClick(e){
-        console.log('菜单点击',e);
+        // console.log('菜单点击',e);
         const {key} = e;
         this.label = ''
         this.templeteUrl = key;
@@ -184,7 +188,7 @@ class CAUpload extends Component {
         const uploadProps = this.uploadProps;
         const { type,templateHrefs } = this.props;
         // console.log({...this.props});
-        if (type == 'normal') {
+        if (type == 'normal'||!type) {
             return [
                 // <Button style={{marginLeft: 10}} key='exportExcel' onClick={this.exportExcel}>导出</Button>,
                 <Upload style={{ marginLeft: 10 }} key='importExcel' {...uploadProps} >
@@ -197,7 +201,7 @@ class CAUpload extends Component {
             return [
                 <Button type="primary" key='a' onClick={() => this.openModal()}>导入</Button>,
                 // <Button style={{marginLeft: 10}} key='templateDowloadTwo' onClick={this.jumpTo}>模板下载</Button>,
-                <Dropdown.Button onClick={this.handleButtonClick.bind(this)} overlay={this.renderMenu()}>
+                <Dropdown.Button  key='b' onClick={this.handleButtonClick.bind(this)} overlay={this.renderMenu()}>
                     模板下载
                 </Dropdown.Button>
 

+ 1 - 1
src/components/RightContent/AvatarDropdown.jsx

@@ -43,7 +43,7 @@ const AvatarDropdown = ({ menu }) => {
       const { key } = event;
 
       if (key === 'logout') {
-        setInitialState((s) => ({ ...s, currentUser: undefined }));
+        setInitialState((s) => ({ ...s, currentUser: undefined,menu:undefined }));
         loginOut();
         return;
       }

+ 2 - 2
src/global.jsx

@@ -1,6 +1,6 @@
 import { Button, message, notification } from 'antd';
-import defaultSettings from '../config/defaultSettings';
-const { pwa } = defaultSettings;
+import {Settings} from '../config/defaultSettings';
+const { pwa } = Settings;
 const isHttps = document.location.protocol === 'https:'; // if pwa is true
 
 if (pwa) {

+ 3 - 3
src/pages/accountingSubject/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 10:30:42
+ * @LastEditTime: 2021-08-13 17:10:45
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -356,7 +356,7 @@ const AccountingSubject = () => {
           width="sm"
           name="accountingName"
         />
-        <ProFormSelect
+        {/* <ProFormSelect
           rules={[
             {
               required: false,
@@ -376,7 +376,7 @@ const AccountingSubject = () => {
           width="sm"
           name="isBaseCode"
           label="是否固定成本"
-        />
+        /> */}
       </ModalForm>
 
       {/* 更新 */}

+ 22 - 3
src/pages/accountingSubjectConnect/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-03 16:58:29
+ * @LastEditTime: 2021-08-13 19:06:24
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -91,6 +91,7 @@ const ResponsibilityCenterConnect = () => {
   const [drawerVisible, setDrawerVisible] = useState(false);
   const [selectedRowKeys,setSelectedRowKeys] = useState([]);
   const [defaultExpandedRowKeys,setDefaultExpandedRowKeys] = useState([]);
+  const [accountType,setAccountType] = useState(1)
 
   /**
    * 
@@ -109,7 +110,7 @@ const ResponsibilityCenterConnect = () => {
 
   //获取责任中心对应列表
   const getList = async (params = {}, sort, filter) => {
-    const res = await getAccountProductConnectList(params);
+    const res = await getAccountProductConnectList({...params,accountType});
     // console.log({res});
 
     const defaultKeys = res.data.list.map(item=>item.id);
@@ -143,7 +144,25 @@ const ResponsibilityCenterConnect = () => {
 
 
   return (
-    <PageContainer>
+    <PageContainer 
+        tabList={[
+          {
+            tab: '收入',
+            key: 1,
+          },
+          {
+            tab: '支出',
+            key: 2,
+          },
+        ]}
+
+        onTabChange={(key)=>{
+          setAccountType(key);
+          if (actionRef.current) {
+            actionRef.current.reload();
+          }
+        }}
+    >
       <ProTable
         columns={columns}
         request={getList}

+ 135 - 0
src/pages/apportionmentLevel/components/drawerContent.jsx

@@ -0,0 +1,135 @@
+
+
+
+
+import React,{useState,useEffect,useRef} from 'react'
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {Table } from 'antd';
+import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
+
+
+
+
+
+
+export default function DrawerContent(props) {
+
+    const { 
+        visible=false,
+        onVisibleChange=()=>{},
+        currentRow={},
+        renderListFunc=()=>{},
+        onFinishFunc=()=>{console.log('init onFinishFunc')},
+        columns=[],
+        defaultSelected=[],
+        config={},
+        title,
+        pageContainerConfig=()=>{},
+        expandable={}
+    } = props;
+    
+    const {rowKeys='id',tableSearch=false,} = config;
+    const drawerRef = useRef();
+    const [selectedKeys,setSelectedKeys] = useState([]);
+    const [defaultSelectedKeys,setDefaultSelectedKeys] = useState([]);
+    const [ifSearch,setIfSearch] = useState(false);
+    const drawerTableRef= useRef();
+    const [selectedRows,setSelectedRows] = useState([]);
+
+    const renderDefault = ()=>{
+        const defaultSelects = defaultSelected;
+        setDefaultSelectedKeys(defaultSelected);
+        setSelectedKeys(defaultSelects);
+    }
+
+
+    useEffect(()=>{
+        renderDefault();
+    },[currentRow,defaultSelected])
+
+
+
+    return visible&&currentRow&&columns.length>0 ? (
+        <>
+            <DrawerForm
+                title={title}
+                visible={visible}
+                onVisibleChange={onVisibleChange}
+                formRef={drawerRef}
+                drawerProps={{
+                    forceRender: true,
+                    destroyOnClose: true,
+                }}
+                onFinish={async (values) => {
+                    //   console.log({onFinishFunc,values});
+                      onFinishFunc(values,defaultSelectedKeys,selectedRows);
+                }}
+            
+            >
+               <PageContainer
+                    {...pageContainerConfig(drawerTableRef)}
+               >
+                <ProTable
+                    columns={columns}
+                    rowKey={rowKeys}
+                    tableClassName="drawerContent"
+                    request={renderListFunc}
+                    search={tableSearch}
+                    actionRef={drawerTableRef}
+                    onSubmit={(u)=>{
+                        //  console.log({u});
+                        setIfSearch(true);
+                    }}
+                    onReset={()=>{setIfSearch(false);}}
+                    expandable={{...expandable}}
+                    rowSelection={{
+                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
+                        // 注释该行则默认不显示下拉选项
+                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
+                        checkStrictly:true,
+                        selectedRowKeys:selectedKeys,
+                        renderCell:(checked, record, index, originNode)=>{
+                               if(!record.children||record.children.length==0)return originNode
+                        },
+                        onChange:(selectedRowKeys, selectedRows)=>{
+                            // console.log({selectedRowKeys,selectedRows});
+                            setSelectedRows(selectedRows);
+                            setSelectedKeys(selectedRowKeys);
+                        },
+                        onSelect:(record, selected, selectedRows, nativeEvent)=>{
+                            // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
+                            let _defaultSelectedKeys = defaultSelectedKeys;
+                            let {children} = record;
+                            let arr=[];
+                            if(children&&children.length>0){
+                                arr = deepGetVal(children,rowKeys,'children');
+                            }
+                            arr.push(record[rowKeys]);
+                            
+                            if(!selected){
+                                arr.forEach(val=>{
+                                    const index =  defaultSelectedKeys.findIndex(item=>item == val);
+                                // console.log(index,record[rowKeys],defaultSelectedKeys)
+                                    if(index != -1){
+                                        _defaultSelectedKeys.splice(index,1);
+                                    }
+                                });
+                                _defaultSelectedKeys = unique(_defaultSelectedKeys);
+                                setDefaultSelectedKeys(_defaultSelectedKeys);
+
+                            }else{
+                                let tempArr = _defaultSelectedKeys.concat(arr);
+                                tempArr = unique(tempArr);
+                                setDefaultSelectedKeys([].concat(tempArr));
+                            }
+
+                        }
+                    }}
+                />
+              </PageContainer>
+            </DrawerForm>
+        </>
+    ) : <></>
+}

+ 54 - 26
src/pages/apportionmentLevel/index.jsx

@@ -1,18 +1,18 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-03 17:05:02
+ * @LastEditTime: 2021-08-19 17:47:41
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
  */
 
 import { PlusOutlined } from '@ant-design/icons';
-import { Button, Popconfirm, Table, Space } from 'antd';
+import { Button, Popconfirm, Table, Space, Select, Form } from 'antd';
 import React, { useState, useRef } from 'react';
 import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
-import { ModalForm, ProFormText, ProFormSelect, ProFormDigit } from '@ant-design/pro-form';
+import { ModalForm, ProFormText, ProFormSelect, ProFormDigit, ProFormDependency } from '@ant-design/pro-form';
 import UpdateForm from './updateForm';
 
 import { getApportionmentLevelList, editApportionmentLevelList, delApportionmentLevel, addApportionmentLevel } from './service';
@@ -43,10 +43,10 @@ const ApportionmentLevel = () => {
       dataIndex: 'calcType',
       key: 'calcType',
       hideInSearch: true,
-      render: (text) =><>{text == 0 ? '合并计算' : '分开计算'}</>,
+      render: (text) => <>{text == 0 ? '合并计算' : '分开计算'}</>,
     },
     {
-      title:'操作',
+      title: '操作',
       dataIndex: 'option',
       valueType: 'option',
       render: (_, record) => [
@@ -76,7 +76,9 @@ const ApportionmentLevel = () => {
   const [createModalVisible, handleModalVisible] = useState(false);
   const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const actionRef = useRef();
+  const addModalRef = useRef();
   const [currentRow, setCurrentRow] = useState({});
+  const [selectableLevelList, setSelectableLevelList] = useState([]);
 
   /**
    *
@@ -91,6 +93,9 @@ const ApportionmentLevel = () => {
   const getList = async (params = {}, sort, filter) => {
 
     const res = await getApportionmentLevelList(params);
+    const { status, data: { list } } = res;
+    const tempArr = list.map(item => ({ label: item.shareName, value: item.leverSort }))
+    setSelectableLevelList(tempArr);
     return {
       data: res.data.list,
       total: res.data.totalCount,
@@ -104,8 +109,8 @@ const ApportionmentLevel = () => {
    */
   const delListHandler = async (value) => {
     const resp = await delApportionmentLevel(value);
-    const {status} = resp;
-    if(status==200){
+    const { status } = resp;
+    if (status == 200) {
       if (actionRef.current) {
         actionRef.current.reload();
       }
@@ -168,10 +173,17 @@ const ApportionmentLevel = () => {
         width="800px"
         labelCol={{ span: 5, offset: 3 }}
         layout={'horizontal'}
+        formRef={addModalRef}
         visible={createModalVisible}
         onVisibleChange={handleModalVisible}
         onFinish={async (value) => {
-          const success = await addApportionmentLevel(value);
+          // console.log({value});
+          let { targetLevel = null } = value;
+          // console.log(addModalRef?.current?.getFieldsValue(true));
+          !targetLevel&&(targetLevel = (addModalRef?.current?.getFieldsValue(true).targetLevel))
+          
+          const tempArr = targetLevel ? targetLevel.map(item => item.value) : [];
+          const success = await addApportionmentLevel({ ...value, targetLevel: tempArr.join(',') });
           //   console.log({ success });
           if (success) {
             handleModalVisible(false);
@@ -187,42 +199,30 @@ const ApportionmentLevel = () => {
           rules={[
             {
               required: true,
-              message:'分摊层级序号是必填项',
+              message: '分摊层级序号是必填项',
             },
           ]}
           width="sm"
           name="leverSort"
           min={1} max={100}
         />
-    
+
         <ProFormText
           label="分摊层级名"
           rules={[
             {
               required: true,
-              message:'分摊层级名是必填项',
+              message: '分摊层级名是必填项',
             },
           ]}
           width="sm"
           name="shareName"
         />
-        <ProFormDigit
-          label="目标层级"
-          rules={[
-            {
-              required: true,
-              message:'目标层级是必填项',
-            },
-          ]}
-          min={1} max={100}
-          width="sm"
-          name="targetLevel"
-        />
         <ProFormSelect
           rules={[
             {
               required: true,
-              message:'请选择计算方式',
+              message: '请选择计算方式',
             },
           ]}
           options={[
@@ -239,14 +239,41 @@ const ApportionmentLevel = () => {
           name="calcType"
           label="计算方式"
         />
-
+        <ProFormDependency name={['leverSort']}>
+          {
+            ({ leverSort }) => {
+              const filteredArr = selectableLevelList.filter(item => item.value >= leverSort);
+              if(filteredArr.length==0){
+                //当大于最大可选分摊层级
+                addModalRef?.current?.setFieldsValue({targetLevel:[{value:`${leverSort}`}]})
+              }
+              return filteredArr.length>0&&(
+                <Form.Item name='targetLevel' label="目标层级" shouldUpdate  >
+                  <Select
+                    mode="multiple"
+                    labelInValue={true}
+                    style={{ width: '80%' }}
+                    placeholder='请选择'
+                  >
+                    {filteredArr.map((item, index) => (
+                      <Select.Option key={index} value={item.value}>
+                        {`${item.label}层级${item.value}`}
+                      </Select.Option>
+                    ))}
+                  </Select>
+                </Form.Item>
+              )
+            }
+          }
+        </ProFormDependency>
       </ModalForm>
 
       {/* 更新 */}
       <UpdateForm
         onSubmit={async (value) => {
           // console.log({ '编辑': value });
-          const success = await editApportionmentLevelList(value);
+          const { targetLevel } = value;
+          const success = await editApportionmentLevelList({ ...value, targetLevel: targetLevel.join(',') });
 
           if (success) {
             handleUpdateModalVisible(false);
@@ -264,6 +291,7 @@ const ApportionmentLevel = () => {
         updateModalVisible={updateModalVisible}
         updateModalVisibleChange={updateModalVisibleChange}
         values={currentRow || {}}
+        selectableLevelList={selectableLevelList}
       />
     </PageContainer>
   );

+ 21 - 15
src/pages/apportionmentLevel/updateForm.jsx

@@ -1,21 +1,25 @@
-import React from 'react';
+import React,{useEffect,useState} from 'react';
 import {
   ProFormSelect,
   ProFormText,
   ModalForm
 } from '@ant-design/pro-form';
+import { Form,Select} from 'antd';
 
 
 const UpdateForm = (props) => {
-  const { updateModalVisible, updateModalVisibleChange, values, onSubmit } = props;
-  // console.log({values});
+  const { updateModalVisible, updateModalVisibleChange, values, onSubmit,selectableLevelList } = props;
+  
+  const {targetLevel} = values;
+
+  
   return (
     <>
       {
         JSON.stringify(values) !== '{}' && <ModalForm
           title="编辑医院"
           width="800px"
-          initialValues={{ ...values }}
+          initialValues={{ ...values,targetLevel:targetLevel?targetLevel.split(',').map(item=>Number(item)):[]}}
           labelCol={{ span: 5, offset: 3 }}
           layout={'horizontal'}
           visible={updateModalVisible}
@@ -45,17 +49,6 @@ const UpdateForm = (props) => {
             width="sm"
             name="shareName"
           />
-          <ProFormText
-            label="目标层级"
-            rules={[
-              {
-                required: true,
-                message:'目标层级是必填项',
-              },
-            ]}
-            width="sm"
-            name="targetLevel"
-          />
           <ProFormSelect
             rules={[
               {
@@ -77,6 +70,19 @@ const UpdateForm = (props) => {
             name="calcType"
             label="计算方式"
           />
+          <Form.Item  name='targetLevel' label="目标层级"  shouldUpdate >
+          <Select
+            mode="multiple"
+            style={{ width:'80%' }}
+            placeholder='请选择'
+          >
+            {selectableLevelList.map((item,index) => (
+              <Select.Option key={index} value={item.value} >
+                {`${item.label}层级${item.value}`}
+              </Select.Option>
+            ))}
+          </Select>
+        </Form.Item>
         </ModalForm>
       }
     </>

+ 0 - 99
src/pages/baseSetting/reportProjectSetting/component/drawer.jsx

@@ -1,99 +0,0 @@
-
-
-import React, { useState, useEffect, useRef } from 'react'
-import { PageContainer } from '@ant-design/pro-layout';
-import ProTable from '@ant-design/pro-table';
-import { Table } from 'antd';
-import { DrawerForm } from '@ant-design/pro-form';
-
-
-
-
-
-
-export default function DrawerContent(props) {
-
-    const {
-        title = 'Drawer',
-        visible = false,
-        onVisibleChange = () => { },
-        currentRow = {},
-        renderListFunc = () => { },
-        onFinishFunc = () => { console.log('init onFinishFunc') },
-        columns = [],
-        defaultSelected = [],
-        config = {},
-        tabList=[],
-        onTabChange
-    } = props;
-
-    const { rowKeys = 'id', tableSearch = false,} = config;
-    const drawerRef = useRef();
-    const drawerTableRef = useRef();
-    const [selectedKeys, setSelectedKeys] = useState([]);
-
-    const renderDefault = () => {
-        const defaultSelects = defaultSelected;
-        setSelectedKeys(defaultSelects);
-    }
-
-    
-    const reloadTable = ()=>{
-        console.log('刷新');
-        if(drawerTableRef.current){
-            drawerTableRef.current.reload();
-        }
-    }
-
-    useEffect(() => {
-        renderDefault();
-    }, [currentRow, defaultSelected])
-
-
-
-    return visible && currentRow && columns.length > 0 ? (
-        <DrawerForm
-            title={title}
-            visible={visible}
-            onVisibleChange={onVisibleChange}
-            formRef={drawerRef}
-            drawerProps={{
-                forceRender: true,
-                destroyOnClose: true,
-            }}
-            onFinish={async (values) => {
-                //   console.log({onFinishFunc,values});
-                onFinishFunc(values, selectedKeys);
-            }}
-
-        >
-            <PageContainer className="DrawerContent"
-                 header={{
-                       title:'',
-                       breadcrumb:''
-                 }}
-                 tabList={tabList}
-                 onTabChange={(key)=>onTabChange(key,reloadTable)}
-            >
-                <ProTable
-                    columns={columns}
-                    rowKey={rowKeys}
-                    tableClassName="drawerContent"
-                    request={renderListFunc}
-                    search={tableSearch}
-                    actionRef={drawerTableRef}
-                    rowSelection={{
-                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
-                        // 注释该行则默认不显示下拉选项
-                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
-                        selectedRowKeys: selectedKeys,
-                        checkStrictly:false,
-                        onChange: (selectedRowKeys, selectedRows) => {
-                            setSelectedKeys(selectedRowKeys);
-                        }
-                    }}
-                />
-            </PageContainer>
-        </DrawerForm>
-    ) : <></>
-}

+ 135 - 0
src/pages/baseSetting/reportProjectSetting/component/drawerContent.jsx

@@ -0,0 +1,135 @@
+
+
+
+
+import React,{useState,useEffect,useRef} from 'react'
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {Table } from 'antd';
+import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
+
+
+
+
+
+
+export default function DrawerContent(props) {
+
+    const { 
+        visible=false,
+        onVisibleChange=()=>{},
+        currentRow={},
+        renderListFunc=()=>{},
+        onFinishFunc=()=>{console.log('init onFinishFunc')},
+        columns=[],
+        defaultSelected=[],
+        config={},
+        title,
+        pageContainerConfig=()=>{},
+        expandable={}
+    } = props;
+    
+    const {rowKeys='id',tableSearch=false,} = config;
+    const drawerRef = useRef();
+    const [selectedKeys,setSelectedKeys] = useState([]);
+    const [defaultSelectedKeys,setDefaultSelectedKeys] = useState([]);
+    const [ifSearch,setIfSearch] = useState(false);
+    const drawerTableRef= useRef();
+    const [selectedRows,setSelectedRows] = useState([]);
+
+    const renderDefault = ()=>{
+        const defaultSelects = defaultSelected;
+        setDefaultSelectedKeys(defaultSelected);
+        setSelectedKeys(defaultSelects);
+    }
+
+
+    useEffect(()=>{
+        renderDefault();
+    },[currentRow,defaultSelected])
+
+
+
+    return visible&&currentRow&&columns.length>0 ? (
+        <>
+            <DrawerForm
+                title={title}
+                visible={visible}
+                onVisibleChange={onVisibleChange}
+                formRef={drawerRef}
+                drawerProps={{
+                    forceRender: true,
+                    destroyOnClose: true,
+                }}
+                onFinish={async (values) => {
+                    //   console.log({onFinishFunc,values});
+                      onFinishFunc(values,defaultSelectedKeys,selectedRows);
+                }}
+            
+            >
+               <PageContainer
+                    {...pageContainerConfig(drawerTableRef)}
+               >
+                <ProTable
+                    columns={columns}
+                    rowKey={rowKeys}
+                    tableClassName="drawerContent"
+                    request={renderListFunc}
+                    search={tableSearch}
+                    actionRef={drawerTableRef}
+                    onSubmit={(u)=>{
+                        //  console.log({u});
+                        setIfSearch(true);
+                    }}
+                    onReset={()=>{setIfSearch(false);}}
+                    expandable={{...expandable}}
+                    rowSelection={{
+                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
+                        // 注释该行则默认不显示下拉选项
+                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
+                        checkStrictly:true,
+                        selectedRowKeys:selectedKeys,
+                        renderCell:(checked, record, index, originNode)=>{
+                               if(!record.children||record.children.length==0)return originNode
+                        },
+                        onChange:(selectedRowKeys, selectedRows)=>{
+                            // console.log({selectedRowKeys,selectedRows});
+                            setSelectedRows(selectedRows);
+                            setSelectedKeys(selectedRowKeys);
+                        },
+                        onSelect:(record, selected, selectedRows, nativeEvent)=>{
+                            // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
+                            let _defaultSelectedKeys = defaultSelectedKeys;
+                            let {children} = record;
+                            let arr=[];
+                            if(children&&children.length>0){
+                                arr = deepGetVal(children,rowKeys,'children');
+                            }
+                            arr.push(record[rowKeys]);
+                            
+                            if(!selected){
+                                arr.forEach(val=>{
+                                    const index =  defaultSelectedKeys.findIndex(item=>item == val);
+                                // console.log(index,record[rowKeys],defaultSelectedKeys)
+                                    if(index != -1){
+                                        _defaultSelectedKeys.splice(index,1);
+                                    }
+                                });
+                                _defaultSelectedKeys = unique(_defaultSelectedKeys);
+                                setDefaultSelectedKeys(_defaultSelectedKeys);
+
+                            }else{
+                                let tempArr = _defaultSelectedKeys.concat(arr);
+                                tempArr = unique(tempArr);
+                                setDefaultSelectedKeys([].concat(tempArr));
+                            }
+
+                        }
+                    }}
+                />
+              </PageContainer>
+            </DrawerForm>
+        </>
+    ) : <></>
+}

+ 280 - 205
src/pages/baseSetting/reportProjectSetting/index.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-06 19:00:19
+ * @LastEditTime: 2021-08-19 17:26:06
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -27,15 +27,15 @@ import {
   delReportProjectSettingList,
   getReportProjectSettingList,
   saveReportRelation,
-  getHasSetReportRelation
+  getHasSetReportRelation,
+  copyDataToSelectedType
 } from './service';
 
-import {getAccountingSubjectList} from '@/pages/accountingSubject/service'
+import { getAccountingSubjectList } from '@/pages/accountingSubject/service';
 
-import {getApportionmentLevelList } from '@/pages/apportionmentLevel/service'
+import { getApportionmentLevelList } from '@/pages/apportionmentLevel/service';
 
-
-import DrawerContent from './component/drawer';
+import DrawerContent from './component/drawerContent';
 
 const IncomeCollectionSetting = () => {
   const columns = [
@@ -75,6 +75,8 @@ const IncomeCollectionSetting = () => {
             return <>小计</>;
           case 4:
             return <>计算公式</>;
+          case 5:
+            return <>按责任中心</>;
         }
       },
     },
@@ -121,50 +123,53 @@ const IncomeCollectionSetting = () => {
       title: '操作',
       dataIndex: 'option',
       valueType: 'option',
-      render: (_, record) =>{
-            const {showAddRelation,parentId} = record;
-            const btnGroup = [
-              <a
-                key="config1"
-                onClick={() => {
-                  setIfAddZeroLevelMenu(false);
-                  handleModalVisible(true);
-                  setCurrentRow(record);
-                }}
-              >
-              {parentId==0&&'添加'}
-              </a>,
+      render: (_, record) => {
+        const { showAddRelation, parentId } = record;
+        const btnGroup = [
+          <a
+            key="config1"
+            onClick={() => {
+              setIfAddZeroLevelMenu(false);
+              handleModalVisible(true);
+              setCurrentRow(record);
+            }}
+          >
+            {parentId == 0 && '添加'}
+          </a>,
+          <a
+            key="config2"
+            onClick={() => {
+              handleUpdateModalVisible(true);
+              setCurrentRow(record);
+            }}
+          >
+            编辑
+          </a>,
+          <Popconfirm
+            key="subscribeAlert"
+            title="是否确定删除?"
+            onConfirm={() => {
+              delUserHandler(record);
+            }}
+          >
+            <a>删除</a>
+          </Popconfirm>,
+        ];
+
+        return showAddRelation
+          ? [
               <a
-                key="config2"
+                key="config3"
                 onClick={() => {
-                  handleUpdateModalVisible(true);
-                  setCurrentRow(record);
+                  setRelationInit(showAddRelation, record);
                 }}
               >
-                编辑
+                {showAddRelation == 1 ? '对应会计科目设置' : showAddRelation == 2 && '对应分摊层级'}
               </a>,
-              <Popconfirm
-                key="subscribeAlert"
-                title="是否确定删除?"
-                onConfirm={() => {
-                  delUserHandler(record);
-                }}
-              >
-                <a>删除</a>
-              </Popconfirm>,
+              ...btnGroup,
             ]
-            
-
-
-            return showAddRelation?[<a
-              key="config3"
-              onClick={() => {
-                setRelationInit(showAddRelation,record);
-              }}
-            >
-               {showAddRelation==1?'对应会计科目设置':showAddRelation==2&&'对应分摊层级'}
-            </a>,...btnGroup]:btnGroup;
-      }
+          : btnGroup;
+      },
     },
   ];
 
@@ -197,6 +202,30 @@ const IncomeCollectionSetting = () => {
     },
   ];
 
+
+  const tabList = [
+    {
+      tab: '损益表',
+      key: 0,
+    },
+    {
+      tab: '完全成本法表',
+      key: 1,
+    },
+    {
+      tab: '变动成本表',
+      key: 2,
+    },
+    {
+      tab: '全院损益表',
+      key: 3,
+    },
+    {
+      tab: '全成本报表',
+      key: 4,
+    },
+  ]
+
   const [createModalVisible, handleModalVisible] = useState(false);
   const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const actionRef = useRef();
@@ -204,14 +233,16 @@ const IncomeCollectionSetting = () => {
   const [ifAddZeroLevelMenu, setIfAddZeroLevelMenu] = useState(true);
   const [reportType, setReportType] = useState(0);
 
-  const [accountType,setAccountType] = useState(1);
+  const [accountType, setAccountType] = useState(1);
 
-  const [settingType, setSettingType] = useState(0);
-  const [drawerVisible, setDrawerVisible] = useState(false);
+  const [modalFormType, setModalFormType] = useState(0); // 1 新增表单  2  复制表单
 
+  //drawer表格类型
+  const [settingType, setSettingType] = useState(0); // 1 会计科目  2 分摊层级
 
-  const [selectedKeys,setSelectedKeys] = useState([]);
+  const [drawerVisible, setDrawerVisible] = useState(false);
 
+  const [selectedKeys, setSelectedKeys] = useState([]);
 
   /**
    *
@@ -232,19 +263,18 @@ const IncomeCollectionSetting = () => {
     };
   };
 
-
   //获取Drawer表格列表
   const getTableList = async (params = {}, sort, filter) => {
-    if(settingType==1){
-      const res = await getAccountingSubjectList({ ...params,accountType});
+    if (settingType == 1) {
+      const res = await getAccountingSubjectList({ ...params, accountType });
       return {
         data: res.data.list,
         total: res.data.totalCount,
         success: res.success,
       };
     }
-    if(settingType==2){
-      const res = await getApportionmentLevelList({ ...params});
+    if (settingType == 2) {
+      const res = await getApportionmentLevelList({ ...params });
       return {
         data: res.data.list,
         total: res.data.totalCount,
@@ -276,58 +306,36 @@ const IncomeCollectionSetting = () => {
   };
 
   /**
-   * 
+   *
    * @param {Number} showAddRelation  1.对应会计科目设置,2.对应分摊参数设置
-   * @param {*} record 
+   * @param {*} record
    */
-  const setRelationInit = async (showAddRelation,record)=>{
-
-    const {id:reportId} = record;
+  const setRelationInit = async (showAddRelation, record) => {
+    const { id: reportId } = record;
     setSettingType(showAddRelation);
     setCurrentRow(record);
-    
-    const resp = await getHasSetReportRelation({reportId,relation:showAddRelation});
-    const {status,data} = resp;
-    console.log({showAddRelation});
-    if(status==200){
-       if(showAddRelation==1){
-        const tempArr = data.map(item=>item.code);
+
+    const resp = await getHasSetReportRelation({ reportId, relation: showAddRelation });
+    const { status, data } = resp;
+    if (status == 200) {
+      if (showAddRelation == 1) {
+        const tempArr = data.map((item) => item.code);
         setSelectedKeys(tempArr);
-       }
-       if(showAddRelation==2){
-        const tempArr = data.map(item=>Number(item.code));
-        console.log({tempArr,showAddRelation});
+      }
+      if (showAddRelation == 2) {
+        const tempArr = data.map((item) => Number(item.code));
+        console.log({ tempArr, showAddRelation });
         setSelectedKeys(tempArr);
-       }
+      }
     }
     setDrawerVisible(true);
-  }
+  };
 
+ 
 
   return (
     <PageContainer
-      tabList={[
-        {
-          tab: '损益表',
-          key: 0,
-        },
-        {
-          tab: '完全成本法表',
-          key: 1,
-        },
-        {
-          tab: '变动成本表',
-          key: 2,
-        },
-        {
-          tab: '全院损益表',
-          key: 3,
-        },
-        {
-          tab: '全成本报表',
-          key: 4,
-        },
-      ]}
+      tabList={tabList}
       onTabChange={onTabChangeHandle}
     >
       <ProTable
@@ -336,11 +344,21 @@ const IncomeCollectionSetting = () => {
         actionRef={actionRef}
         rowKey="id"
         toolBarRender={() => [
+          <Button
+            key="button"
+            onClick={() => {
+              setModalFormType(2);
+              handleModalVisible(true);
+            }}
+          >
+            复制数据
+          </Button>,
           <Button
             key="button"
             icon={<PlusOutlined />}
             type="primary"
             onClick={() => {
+              setModalFormType(1);
               setIfAddZeroLevelMenu(true);
               handleModalVisible(true);
             }}
@@ -365,134 +383,191 @@ const IncomeCollectionSetting = () => {
         visible={createModalVisible}
         onVisibleChange={handleModalVisible}
         onFinish={async (value) => {
-          let id = 0;
-          // console.log({currentRow,id});
-          currentRow&&(id = currentRow.id);
-          const resp = await addReportProjectSettingList({...value,reportType:Number(reportType),parentId:id});
-          const { status } = resp;
-          setCurrentRow(undefined);
-          if (status == 200) {
-            if (actionRef.current) {
-              actionRef.current.reload();
+          if(modalFormType ==1){
+            let id = 0;
+            currentRow && (id = currentRow.id);
+            const resp = await addReportProjectSettingList({
+              ...value,
+              reportType: Number(reportType),
+              parentId: id,
+            });
+            const { status } = resp;
+            setCurrentRow(undefined);
+            if (status == 200) {
+              if (actionRef.current) {
+                actionRef.current.reload();
+              }
+              return true;
             }
-            return true;
           }
+
+          if(modalFormType == 2){
+               const {toReportType} = value;
+               const resp = await copyDataToSelectedType({fromReportType:Number(reportType),toReportType});
+               if (resp) {
+                if (actionRef.current) {
+                  actionRef.current.reload();
+                }
+                return true;
+              }
+          }
+          
         }}
       >
-        <ProFormText
-          label="报表名"
-          rules={[
-            {
-              required: true,
-              message: '报表名是必填项!',
-            },
-          ]}
-          width="sm"
-          name="reportName"
-        />
-        <ProFormDigit
-          label="排序"
-          rules={[
-            {
-              required: true,
-              message: '排序必填项!',
-            },
-          ]}
-          width="sm"
-          name="sort"
-        />
-        <ProFormSelect
-          name="calcType"
-          label="计算类型"
-          width="sm"
-          options={[
-            { label: '不设置', value: 0 },
-            { label: '对应会计科目', value: 1 },
-            { label: '对应分摊层级', value: 2 },
-            { label: '小计', value: 3 },
-            { label: '计算公式', value: 4 },
-          ]}
-          placeholder="请选择状态"
-          rules={[{ required: true, message: '请选择开单科室状态!' }]}
-        />
-      
-        <ProFormDependency name={['calcType']}>
-          {({ calcType }) => {
-            // const resp = await getResponsibilityCenterList({pageSize:100,current:1});
-            return calcType == 4 ? (
-              <ProFormText
-                label="计算公示"
-                rules={[
-                  {
-                    required: true,
-                    message: '计算公式是必填项!',
-                  },
-                ]}
-                width="sm"
-                name="calcFormula"
-              />
-            ) : (
-              <></>
-            );
-          }}
-        </ProFormDependency>
+        {modalFormType == 1 && (
+          <>
+            <ProFormText
+              label="报表名"
+              rules={[
+                {
+                  required: true,
+                  message: '报表名是必填项!',
+                },
+              ]}
+              width="sm"
+              name="reportName"
+            />
+            <ProFormDigit
+              label="排序"
+              rules={[
+                {
+                  required: true,
+                  message: '排序必填项!',
+                },
+              ]}
+              width="sm"
+              name="sort"
+            />
+            <ProFormSelect
+              name="calcType"
+              label="计算类型"
+              width="sm"
+              options={[
+                { label: '不设置', value: 0 },
+                { label: '对应会计科目', value: 1 },
+                { label: '对应分摊层级', value: 2 },
+                { label: '小计', value: 3 },
+                { label: '计算公式', value: 4 },
+                { label: '按责任中心', value: 5 },
+              ]}
+              placeholder="请选择状态"
+              rules={[{ required: true, message: '请选择开单科室状态!' }]}
+            />
+
+            <ProFormDependency name={['calcType']}>
+              {({ calcType }) => {
+                // const resp = await getResponsibilityCenterList({pageSize:100,current:1});
+                return calcType == 4 ? (
+                  <ProFormText
+                    label="计算公示"
+                    rules={[
+                      {
+                        required: true,
+                        message: '计算公式是必填项!',
+                      },
+                    ]}
+                    width="sm"
+                    placeholder="例如:[1] + [2]"
+                    name="calcFormula"
+                  />
+                ) : (
+                  <></>
+                );
+              }}
+            </ProFormDependency>
+          </>
+        )}
+        {modalFormType == 2 && (
+            <ProFormSelect
+              name="toReportType"
+              label="复制到"
+              width="sm"
+              options={(()=>{
+                 const tempArr = tabList.map(item=>({label:item.tab,value:item.key}));
+                 return tempArr.filter(item=>item.value != reportType);
+              })()}
+              placeholder="请选择"
+              rules={[{ required: true, message: '请选择复制到目标!' }]}
+            />
+        )}
       </ModalForm>
 
       {/* 对应设置抽屉 */}
       <DrawerContent
-          title={settingType==1?'对应会计科目设置':'对应分摊层级'}
-          columns={settingType==1?accountingSubjectColumn:shareParamsColumn}  //shareParamsColumn
-          visible={drawerVisible}
-          currentRow={currentRow}
-          // tableRef = {drawerTableRef}
-          defaultSelected={selectedKeys}
-          tabList={settingType==1?[
-            {
-              tab: '收益',
-              key:1,
-            },
-            {
-              tab: '支出',
-              key:2,
+        title={settingType == 1 ? '对应会计科目设置' : '对应分摊层级'}
+        columns={settingType == 1 ? accountingSubjectColumn : shareParamsColumn} //shareParamsColumn
+        visible={drawerVisible}
+        currentRow={currentRow}
+        // tableRef = {drawerTableRef}
+        defaultSelected={selectedKeys}
+        pageContainerConfig={(tableRef) => {
+          return {
+            header: {
+              title: '',
+              breadcrumb: '',
             },
-          ]:[]}
-          onTabChange={(key,reloadTable)=>{
-            // console.log({key,reloadTable});
-            setAccountType(key);
-            reloadTable();
-          }}
-          onVisibleChange={(bool) => setDrawerVisible(bool)}
-          renderListFunc={getTableList}
-          config={{tableSearch:false,rowKeys:settingType==1?'accountingCode':'id'}}
-          onFinishFunc={async (value, selectedRowKeys) => {
-            // console.log({value,selectedRowKeys});
-            let selectedRowKeysToStr = [];
-            if(settingType==2){
-              selectedRowKeys.map(item=>selectedRowKeysToStr.push(`${item}`))
-            }
-            const { id:reportId } = currentRow;
-            const resp = await saveReportRelation({ reportId,relation:settingType,relationCodes: settingType==1?selectedRowKeys:selectedRowKeysToStr });
-            const { status } = resp;
-            if (status == 200) {
-              setDrawerVisible(false);
-              setCurrentRow(undefined);
-              if (actionRef.current) {
-                actionRef.current.reload();
+            tabList:
+              settingType == 1
+                ? [
+                    {
+                      tab: '收益',
+                      key: 1,
+                    },
+                    {
+                      tab: '支出',
+                      key: 2,
+                    },
+                  ]
+                : [],
+            onTabChange: (key) => {
+              // console.log({key,reloadTable});
+              setAccountType(key);
+              if (tableRef.current) {
+                tableRef.current.reload();
               }
+            },
+          };
+        }}
+        onVisibleChange={(bool) => setDrawerVisible(bool)}
+        renderListFunc={getTableList}
+        config={{ tableSearch: false, rowKeys: settingType == 1 ? 'accountingCode' : 'id' }}
+        onFinishFunc={async (value, selectedRowKeys) => {
+          // console.log({value,selectedRowKeys});
+          let selectedRowKeysToStr = [];
+          if (settingType == 2) {
+            selectedRowKeys.map((item) => selectedRowKeysToStr.push(`${item}`));
+          }
+          const { id: reportId } = currentRow;
+          const resp = await saveReportRelation({
+            reportId,
+            relation: settingType,
+            relationCodes: settingType == 1 ? selectedRowKeys : selectedRowKeysToStr,
+          });
+          const { status } = resp;
+          if (status == 200) {
+            setDrawerVisible(false);
+            setCurrentRow(undefined);
+            if (actionRef.current) {
+              actionRef.current.reload();
             }
-          }}
-        />
+          }
+        }}
+      />
 
       {/* 更新 */}
       <UpdateForm
         onSubmit={async (value) => {
-          const { parentId,calcType:calcTypePrev } = currentRow;
-          const {id,reportName,sort,calcType} = value;
+          const { parentId, calcType: calcTypePrev } = currentRow;
+          const { id, reportName, sort, calcType,calcFormula } = value;
           const updateData = {
-            id,parentId,reportName,sort,reportType,calcType
-          }
-
-  
+            id,
+            parentId,
+            reportName,
+            sort,
+            reportType,
+            calcType,
+            calcFormula
+          };
 
           const resp = await editReportProjectSettingList(updateData);
           const { status } = resp;

+ 12 - 1
src/pages/baseSetting/reportProjectSetting/service.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-08-03 14:38:54
- * @LastEditTime: 2021-08-04 18:15:37
+ * @LastEditTime: 2021-08-17 15:10:20
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /CostAccountManaSys/src/pages/platformMana/menuManage/service.js
@@ -58,6 +58,17 @@ export async function saveReportRelation(body, options) {
 }
 
 
+
+//复制数据
+export async function copyDataToSelectedType(body, options) {
+  return request('/api/costAccount/reportForm/copyReport', {
+    method: 'POST',
+    data: {...body},
+    ...(options || {}),
+  });
+}
+
+
 //根据关系类型,获取已绑定的关系数据
 export async function getHasSetReportRelation(params, options) {
   return request('/api/costAccount/reportForm/getRelationList', {

+ 5 - 3
src/pages/baseSetting/reportProjectSetting/updateForm.jsx

@@ -15,7 +15,7 @@ const UpdateForm = (props) => {
     <>
       {
         JSON.stringify(values) !== '{}' && <ModalForm
-          title="编辑收入归集设置"
+          title="编辑报表项目设置"
           width="800px"
           initialValues={{ ...values}}
           labelCol={{ span: 5, offset: 3 }}
@@ -56,16 +56,17 @@ const UpdateForm = (props) => {
             { label: '对应分摊层级', value: 2 },
             { label: '小计', value: 3 },
             { label: '计算公式', value: 4 },
+            { label: '按责任中心', value: 5 },
           ]}
           placeholder="请选择状态"
           rules={[{ required: true, message: '请选择开单科室状态!' }]}
         />
-      
+        
         <ProFormDependency name={['calcType']}>
           {({ calcType }) => {
             return calcType == 4 ? (
               <ProFormText
-                label="计算公"
+                label="计算公"
                 rules={[
                   {
                     required: true,
@@ -73,6 +74,7 @@ const UpdateForm = (props) => {
                   },
                 ]}
                 width="sm"
+                placeholder="例如:[1] + [2]"
                 name="calcFormula"
               />
             ) : (

+ 3 - 3
src/pages/baseSetting/visitsAndBedDayCostSetting/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 10:40:26
+ * @LastEditTime: 2021-08-13 20:18:17
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -341,11 +341,11 @@ const DistrictMana = () => {
             options={[
               {
                 value: 1,
-                label: '门诊收入',
+                label: '住院收入',
               },
               {
                 value: 2,
-                label: '住院收入',
+                label: '门诊收入',
               },
             ]}
             width="sm"

+ 10 - 8
src/pages/costAccounting/afterCollectionSearch/index.jsx

@@ -2,7 +2,7 @@
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
 
- * @LastEditTime: 2021-08-13 16:19:27
+ * @LastEditTime: 2021-08-20 16:26:15
 
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
@@ -28,7 +28,7 @@ import './index.less';
 
 const AfterCollectionSearch = () => {
 
-  const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM'));
+  const [currentTime, setCurrentTime] = useState(moment(new Date()).subtract(1,'months').format('YYYY-MM'));
   const [selectableResponsibilityList, setSelectableResponsibilityList] = useState([]);
   const [selectedResponsibilityCode,setSelectedResponsibilityCode] = useState(null);
   const [selectedAccountingCode,setSelectedAccountingCode] = useState(null)
@@ -58,7 +58,7 @@ const AfterCollectionSearch = () => {
       key: 'responsibilityCode',
       hideInTable: true,
       fieldProps: (form, config) => {
-        console.log({ form, config });
+        // console.log({ form, config });
       },
       dataIndex: 'responsibilityName',
       renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
@@ -199,9 +199,11 @@ const AfterCollectionSearch = () => {
   //获取列表
   const getList = async (params = {}, sort, filter) => {
 
-    const { dateTime } = params;
-    console.log(moment(dateTime).format('yyyyMM'));
-    const res = await getAfterIncomeCollectionList({ ...params, date: moment(dateTime).format('yyyyMM') });
+    const { dateTime,responsibilityCode=[],productCode='',pageSize,current} = params;
+ 
+    const res = await getAfterIncomeCollectionList({
+      productCode,responsibilityCode:responsibilityCode[responsibilityCode.length-1],
+       date: moment(dateTime).format('yyyyMM'),pageSize,current });
 
     if (res && res.status) {
       const { data: { totalAmount } } = res;
@@ -311,11 +313,11 @@ const AfterCollectionSearch = () => {
           summary={() => (
             <Table.Summary fixed >
               <Table.Summary.Row className="rowCell">
-                <Table.Summary.Cell className="firstCell" index={0}>合计</Table.Summary.Cell>
+                {/* <Table.Summary.Cell className="firstCell" index={0}>合计</Table.Summary.Cell> */}
                 {
                   totalData.map((item, index) => {
                     return (
-                      <Table.Summary.Cell key={index}  className={index == totalData.length-1 ? 'ant-table-cell ant-table-cell-fix-right ant-table-cell-fix-right-last' : 'cell'} index={index+1}>{item[1]}</Table.Summary.Cell>
+                      <Table.Summary.Cell key={index}  className={index == totalData.length-1 ? 'ant-table-cell ant-table-cell-fix-right ant-table-cell-fix-right-last' : 'cell'} index={index}>{item[1]}</Table.Summary.Cell>
                     )
                   })
                 }

+ 8 - 2
src/pages/costAccounting/beforeCollectionSearch/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 15:39:41
+ * @LastEditTime: 2021-08-20 16:13:29
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -42,7 +42,7 @@ const IncomeCostDataImport = () => {
         }
         return (
           <Form.Item >
-             <ProFormDatePicker initialValue={currentTime} fieldProps={{picker:'month',format:(value)=>{return value.format('YYYY-MM')},locale:locale}}  name="dateTime" />
+             <ProFormDatePicker initialValue={moment(currentTime).subtract(1,'months')} fieldProps={{picker:'month',format:(value)=>{return value.format('YYYY-MM')},locale:locale}}  name="dateTime" />
           </Form.Item>
         )
       },
@@ -121,6 +121,12 @@ const IncomeCostDataImport = () => {
       key: 'dateMonth',
       hideInSearch: true,
     },
+    {
+      title: '开单科室',
+      dataIndex: 'openDepartmentName',
+      key: 'openDepartmentName',
+      hideInSearch: true,
+    },
     {
       title: '开单责任中心',
       dataIndex: 'openResponsibilityCodeName',

+ 238 - 0
src/pages/costAccounting/beforeCostShareSearch/index.jsx

@@ -0,0 +1,238 @@
+/*
+ * @Author: your name
+ * @Date: 2021-07-26 10:13:13
+ * @LastEditTime: 2021-08-20 13:42:30
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
+ */
+
+// import { PlusOutlined } from '@ant-design/icons';
+import { Cascader,Form } from 'antd';
+import React, { useRef, useState, useEffect } from 'react';
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {
+  ProFormDatePicker,
+  ProFormSelect,
+} from '@ant-design/pro-form';
+import { getBeforeCostShareSearchList } from './service';
+import { getResponsibilityCenterList } from '@/pages/responsibilityCenter/service';
+import {getAccountingSubjectList} from '@/pages/accountingSubject/service';
+import moment from 'moment';
+import 'moment/locale/zh-cn';
+import locale from 'antd/es/date-picker/locale/zh_CN';
+
+const IncomeCostDataImport = () => {
+
+  const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM'));
+  const [selectableResponsibilityList,setSelectableResponsibilityList] = useState([]);
+  const [selectableAccountingSubjectList,setSelectableAccountingSubjectList] = useState([]);
+  // const [selectableCostProjectList, setSelectableCostProjectList] = useState([])
+
+  const columns = [
+    {
+      title: '选择时间',
+      key: 'date',
+      hideInTable: true,
+      dataIndex: 'date',
+      renderFormItem: (item, {type, defaultRender,formItemProps, fieldProps, ...rest }, form) => {
+       
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item >
+             <ProFormDatePicker initialValue={currentTime} fieldProps={{picker:'month',format:(value)=>{return value.format('YYYY-MM')},locale:locale}}  name="date" />
+          </Form.Item>
+        )
+      },
+    },
+    {
+      title: '执行责任中心',
+      key: 'responsibilityCode',
+      hideInTable: true,
+      fieldProps:(form,config)=>{
+          //  console.log({form,config});
+      },
+      dataIndex: 'responsibilityName',
+      renderFormItem: (item, { type, defaultRender,formItemProps, fieldProps, ...rest }, form) => {
+        // console.log({item,type, defaultRender,formItemProps, fieldProps,rest,form })
+        if (type === 'form') {
+          return null;
+        }
+
+        return (
+          <Form.Item name="responsibilityCode">
+          <Cascader options={selectableResponsibilityList} 
+          fieldNames={{
+            label:'responsibilityName',
+            value:'responsibilityCode',
+            children:'child'
+          }}
+          {...fieldProps}
+          />
+          </Form.Item>
+        )
+      },
+    },
+    {
+      title: '会计科目(支出)',
+      key: 'accountCode',
+      hideInTable: true,
+      fieldProps:(form,config)=>{
+  
+      },
+      dataIndex: 'accountCode',
+      renderFormItem: (item, { type, defaultRender,formItemProps, fieldProps, ...rest }, form) => {
+        // console.log({item,type, defaultRender,formItemProps, fieldProps,rest,form })
+        if (type === 'form') {
+          return null;
+        }
+
+        return (
+          <Form.Item name="accountCode">
+          <Cascader options={selectableAccountingSubjectList} 
+          fieldNames={{
+            label:'accountingName',
+            value:'accountingCode',
+            children:'children'
+          }}
+          {...fieldProps}
+          />
+          </Form.Item>
+        )
+      },
+    },
+    {
+      title: '年份',
+      dataIndex: 'year',
+      key: 'year',
+      hideInSearch: true,
+    },
+    {
+      title: '月份',
+      dataIndex: 'month',
+      key: 'month',
+      hideInSearch: true,
+    },
+    {
+      title: '科室编码',
+      dataIndex: 'departCode',
+      key: 'departCode',
+      hideInSearch: true,
+    },
+    {
+      title: '科室名称',
+      dataIndex: 'departName',
+      key: 'departName',
+      hideInSearch: true,
+    },
+    {
+      title: '责任中心编码',
+      dataIndex: 'responsibilityCode',
+      key: 'responsibilityCode',
+      hideInSearch: true,
+    },
+    {
+      title: '责任中心名称',
+      dataIndex: 'responsibilityName',
+      key: 'responsibilityName',
+      hideInSearch: true,
+    },
+    {
+      title: '会计科目编码',
+      dataIndex: 'accountCode',
+      key: 'accountCode',
+      hideInSearch: true,
+    },
+    {
+      title: '会计科目名称',
+      dataIndex: 'accountName',
+      key: 'accountName',
+      hideInSearch: true,
+    },
+    {
+      title: '成本项目编码',
+      dataIndex: 'productCode',
+      key: 'productCode',
+      hideInSearch: true,
+    },
+    {
+      title: '成本项目名称',
+      dataIndex: 'productName',
+      key: 'productName',
+      hideInSearch: true,
+    },
+    {
+      title: '金额',
+      dataIndex: 'amount',
+      key: 'amount',
+      hideInSearch: true,
+    },
+  ];
+
+
+  const actionRef = useRef();
+  const [totalCount, setTotalCount] = useState(0)
+
+
+  //获取列表
+  const getList = async (params = {}, sort, filter) => {
+    const {date,responsibilityCode=[],accountCode=[],pageSize,current}  = params;
+    // console.log({responsibilityCode,accountCode});
+    const res = await getBeforeCostShareSearchList({pageSize,current,responsibilityCode:responsibilityCode[responsibilityCode.length-1],accountCode:accountCode[accountCode.length-1],date:moment(date).format('YYYY-MM')});
+    if(res&&res.status){
+      const { data: { totalAmount=0 } } = res;
+      setTotalCount(totalAmount);
+      return {
+        data: res.data.list,
+        total: res.data.totalCount,
+        success: res.success,
+      };
+    }
+    
+  };
+
+
+  const getAllAccountingSubjectForSearch = async ()=>{
+       const resp = await getAccountingSubjectList({pageSize:200,current:1,accountType:2});
+       const {data:{list=[]}} = resp;
+       setSelectableAccountingSubjectList(list);
+  }
+
+
+
+
+  useEffect(async () => {
+       const responsibilityList = await getResponsibilityCenterList({pageSize:500});
+       const {data:{list}} = responsibilityList;
+       setSelectableResponsibilityList(list);
+       await getAllAccountingSubjectForSearch();
+  }, []);
+
+  return (
+    <PageContainer>
+      <ProTable
+        columns={columns}
+        request={getList}
+        actionRef={actionRef}
+        rowKey="id"
+        toolBarRender={() => [
+        ]}
+
+        pagination={{
+          pageSize: 10,
+        }}
+        search={{
+          defaultCollapsed: false,
+          labelWidth: 'auto',
+        }}
+        footer={() => <a>{`合计:${totalCount}`}</a>}
+
+      />
+    </PageContainer>
+  );
+};
+
+export default IncomeCostDataImport;

+ 33 - 0
src/pages/costAccounting/beforeCostShareSearch/service.js

@@ -0,0 +1,33 @@
+/*
+ * @Author: your name
+ * @Date: 2021-07-26 08:54:08
+ * @LastEditTime: 2021-08-20 08:58:28
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /TracerMethodology_PC/src/pages/DepartmentMana/service.js
+ */
+
+import { request } from 'umi';
+
+
+//获取 成本分摊前查询列表
+export async function getBeforeCostShareSearchList(params, options) {
+    return request('/api/costAccount/costcostinggroup/queryStartAllocation', {
+      method: 'GET',
+      params:{...params},
+      ...(options || {}),
+    });
+}
+
+
+//导入数据
+export async function addIncomeCostDataImport(body, options) {
+  const {fileFormData} = body;
+  return request('/api/costAccount/excel/importDataByFileType', {
+    method: 'POST',
+    data:fileFormData,
+    ...(options || {}),
+  });
+}
+
+

+ 150 - 0
src/pages/costAccounting/costShareParamsHandle/components/drawerContent.jsx

@@ -0,0 +1,150 @@
+
+
+
+
+import React,{useState,useEffect,useRef} from 'react'
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {Table } from 'antd';
+import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
+
+
+
+
+
+
+export default function DrawerContent(props) {
+
+    const { 
+        visible=false,
+        onVisibleChange=()=>{},
+        currentRow={},
+        renderListFunc=()=>{},
+        onFinishFunc=()=>{console.log('init onFinishFunc')},
+        columns=[],
+        defaultSelected=[],
+        config={},
+        title,
+        type,
+        pageContainerConfig=()=>{},
+        expandable={}
+    } = props;
+    
+    const {rowKeys='id',tableSearch=false,} = config;
+    const drawerRef = useRef();
+    const [selectedKeys,setSelectedKeys] = useState([]);
+    const [defaultSelectedKeys,setDefaultSelectedKeys] = useState([]);
+    const [ifSearch,setIfSearch] = useState(false);
+    const drawerTableRef= useRef();
+    const [selectedRows,setSelectedRows] = useState([]);
+
+    const renderDefault = ()=>{
+        const defaultSelects = defaultSelected;
+        setDefaultSelectedKeys(defaultSelected);
+        setSelectedKeys(defaultSelects);
+        // console.log({defaultSelected});
+    }
+
+
+    useEffect(()=>{
+        renderDefault();
+    },[defaultSelected])
+
+
+
+    return visible&&currentRow&&columns.length>0 ? (
+        <>
+            <DrawerForm
+                title={title}
+                visible={visible}
+                onVisibleChange={onVisibleChange}
+                formRef={drawerRef}
+                drawerProps={{
+                    forceRender: true,
+                    destroyOnClose: true,
+                }}
+                onFinish={async (values) => {
+                    //   console.log({onFinishFunc,values});
+                      onFinishFunc(values,defaultSelectedKeys,selectedRows);
+                }}
+            
+            >
+               <PageContainer
+                    {...pageContainerConfig(drawerTableRef)}
+               >
+                <ProTable
+                    columns={columns}
+                    rowKey={rowKeys}
+                    tableClassName="drawerContent"
+                    request={renderListFunc}
+                    search={tableSearch}
+                    actionRef={drawerTableRef}
+                    onSubmit={(u)=>{
+                        //  console.log({u});
+                        setIfSearch(true);
+                    }}
+                    onReset={()=>{setIfSearch(false);}}
+                    expandable={{...expandable}}
+                    rowSelection={{
+                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
+                        // 注释该行则默认不显示下拉选项
+                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
+                        checkStrictly:false,
+                        selectedRowKeys:selectedKeys,
+                        type:type,
+                        renderCell:(checked, record, index, originNode)=>{
+                               if(!record[expandable.childrenColumnName]||record[expandable.childrenColumnName].length==0)return originNode
+                        },
+                        onChange:(selectedRowKeys, selectedRows)=>{
+                            // console.log({selectedRowKeys,selectedRows});
+                            setSelectedRows(selectedRows);
+                            setSelectedKeys(selectedRowKeys);
+                        },
+                        onSelect:(record, selected, selectedRows, nativeEvent)=>{
+                            // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
+
+                            if(type == 'checkbox'){
+                                //多选框
+                                let _defaultSelectedKeys = defaultSelectedKeys.length>0?defaultSelectedKeys:[];
+                                let {children} = record;
+                                let arr=[];
+                                if(children&&children.length>0){
+                                    arr = deepGetVal(children,rowKeys,'children');
+                                }
+                                arr.push(record[rowKeys]);
+    
+                                console.log({arr,_defaultSelectedKeys,defaultSelectedKeys});
+    
+                                if(!selected){
+                                    arr.forEach(val=>{
+                                        const index =  defaultSelectedKeys.findIndex(item=>item == val);
+                                    // console.log(index,record[rowKeys],defaultSelectedKeys)
+                                        if(index != -1){
+                                            _defaultSelectedKeys.splice(index,1);
+                                        }
+                                    });
+                                    _defaultSelectedKeys = unique(_defaultSelectedKeys);
+                                    setDefaultSelectedKeys(_defaultSelectedKeys);
+    
+                                }else{
+                                    let tempArr = arr.length>0?_defaultSelectedKeys.concat(arr):_defaultSelectedKeys;
+                                    console.log({tempArr,_defaultSelectedKeys});
+                                    tempArr = unique(tempArr);
+                                    
+                                    setDefaultSelectedKeys(tempArr);
+                                }
+                            }else {
+                                //单选
+                                setDefaultSelectedKeys(selectedRows.map(item=>item[rowKeys]))
+                            }
+                            
+
+                        }
+                    }}
+                />
+              </PageContainer>
+            </DrawerForm>
+        </>
+    ) : <></>
+}

+ 823 - 0
src/pages/costAccounting/costShareParamsHandle/index.js

@@ -0,0 +1,823 @@
+/*
+ * @Author: your name
+ * @Date: 2021-07-26 10:13:13
+ * @LastEditTime: 2021-08-20 17:12:49
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
+ */
+
+import { PlusOutlined,EditFilled } from '@ant-design/icons';
+import { Button, Popconfirm, Form, Cascader,InputNumber } from 'antd';
+import React, { useState, useRef, useEffect,useContext} from 'react';
+
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {
+  ModalForm,
+  ProFormSelect,
+  ProFormDatePicker,
+  ProFormText,
+  ProFormDigit,
+} from '@ant-design/pro-form';
+
+import {
+  getMonthCostShareDataList,
+  addMonthCostShareData,
+  editMonthCostShareData,
+  delMonthCostShareData,
+  copyMonthCostShareData,
+  calculateMonthCostShareData
+} from './service';
+
+import { getResponsibilityCenterList } from '@/pages/responsibilityCenter/service';
+
+import { getCostshareparamList } from '@/pages/costAllocationParamsSetting/service';
+
+import moment from 'moment';
+import 'moment/locale/zh-cn';
+import locale from 'antd/es/date-picker/locale/zh_CN';
+
+import DrawerContent from './components/drawerContent';
+
+const EditableContext = React.createContext(null);
+
+const EditableRow = ({ index, ...props }) => {
+  const [form] = Form.useForm();
+  return (
+    <Form form={form} component={false}>
+      <EditableContext.Provider value={form}>
+        <tr {...props} />
+      </EditableContext.Provider>
+    </Form>
+  );
+};
+
+const EditableCell = ({
+  title,
+  editable,
+  children,
+  dataIndex,
+  record,
+  handleSave,
+  ...restProps
+}) => {
+  const [editing, setEditing] = useState(false);
+  const inputRef = useRef(null);
+  const form = useContext(EditableContext);
+  useEffect(() => {
+    if (editing) {
+      inputRef.current.focus();
+    }
+  }, [editing]);
+
+  const toggleEdit = () => {
+    setEditing(!editing);
+    form.setFieldsValue({
+      [dataIndex]: record[dataIndex],
+    });
+  };
+
+  const save = async () => {
+    try {
+      const values = await form.validateFields();
+      toggleEdit();
+      handleSave({ ...record, ...values });
+    } catch (errInfo) {
+      console.log('Save failed:', errInfo);
+    }
+  };
+
+  let childNode = children;
+
+  if (editable) {
+    childNode = editing ? (
+      <Form.Item
+        style={{
+          margin: 0,
+        }}
+        name={dataIndex}
+        rules={[
+          {
+            required: true,
+            message: `${title} is required.`,
+          },
+        ]}
+      >
+        <InputNumber ref={inputRef} onPressEnter={save} onBlur={save} style={{width:'90%'}}/>
+      </Form.Item>
+    ) : (
+      <div
+        className="editable-cell-value-wrap"
+        style={{
+          paddingRight: 24,
+        }}
+        onClick={toggleEdit}
+      >
+        {children}   <EditFilled />
+      </div>
+    );
+  }
+
+  return <td {...restProps}>{childNode}</td>;
+};
+
+//月成本分摊参数设置
+const CostShareParamsHandle = () => {
+  const [currentTime, setCurrentTime] = useState(moment(new Date()).subtract(1,'months').format('YYYY-MM'));
+  const columns = [
+    {
+      title: '选择时间',
+      key: 'date',
+      hideInTable: true,
+      dataIndex: 'date',
+      renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item>
+            <ProFormDatePicker
+              initialValue={currentTime}
+              fieldProps={{
+                picker: 'month',
+                format: (value) => {
+                  return value.format('YYYY-MM');
+                },
+                locale: locale,
+                onChange: (moment) => {
+                  setCurrentTime(moment.format('YYYYMM'));
+                },
+              }}
+              name="date"
+            />
+          </Form.Item>
+        );
+      },
+    },
+    {
+      title: '分摊参数',
+      key: 'shareParamCode',
+      hideInTable: true,
+      dataIndex: 'shareParamCode',
+      renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item>
+            <ProFormSelect
+              request={async () => {
+                const resp = await getCostshareparamList({ pageSize: 500 });
+                const {
+                  status,
+                  data: { list },
+                } = resp;
+                if (status == 200) {
+                  return (
+                    list &&
+                    list.map((item) => ({ label: item.shareParamName, value: item.shareParamCode }))
+                  );
+                }
+              }}
+              width="md"
+              name="shareParamCode"
+            />
+          </Form.Item>
+        );
+      },
+    },
+    {
+      title: '责任中心',
+      key: 'responsibilityCode',
+      hideInTable: true,
+      dataIndex: 'responsibilityCode',
+      renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
+        // console.log({item,type, defaultRender,formItemProps, fieldProps,rest,form })
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item name="responsibilityCode">
+            <Cascader
+              options={responsibilityList}
+              fieldNames={{
+                label: 'responsibilityName',
+                value: 'responsibilityCode',
+                children: 'child',
+              }}
+              {...fieldProps}
+            />
+          </Form.Item>
+        );
+      },
+    },
+    {
+      title: 'id',
+      dataIndex: 'id',
+      key: 'id',
+      hideInSearch: true,
+      hideInTable: true,
+    },
+    {
+      title: '年份',
+      dataIndex: 'dateYear',
+      key: 'dateYear',
+      hideInSearch: true,
+    },
+    {
+      title: '月份',
+      dataIndex: 'dateMonth',
+      key: 'dateMonth',
+      hideInSearch: true,
+    },
+    {
+      title: '分摊参数编码',
+      dataIndex: 'shareParamCode',
+      key: 'shareParamCode',
+      hideInSearch: true,
+    },
+    {
+      title: '分摊参数名称',
+      dataIndex: 'shareParamName',
+      key: 'shareParamName',
+      hideInSearch: true,
+    },
+    {
+      title: '责任中心编码',
+      dataIndex: 'responsibilityCode',
+      key: 'responsibilityCode',
+      hideInSearch: true,
+    },
+    {
+      title: '责任中心名称',
+      dataIndex: 'responsibilityName',
+      key: 'responsibilityName',
+      hideInSearch: true,
+    },
+    {
+      title: '数值',
+      dataIndex: 'valueNum',
+      key: 'valueNum',
+      hideInSearch: true,
+      editable: true,
+    },
+    {
+      title: '操作',
+      dataIndex: 'option',
+      valueType: 'option',
+      render: (_, record) => {
+        const btnGroups = [
+          <a
+            key="config"
+            onClick={() => {
+              setCurrentRow(record);
+              setEdit(true);
+              setModalTitle('编辑月成本分摊参数值处理');
+              setModalType(3);
+              handleModalVisible(true);
+            }}
+          >
+            编辑
+          </a>,
+          <Popconfirm
+            key="subscribeAlert"
+            title="是否确定删除?"
+            onConfirm={() => {
+              delList(record);
+            }}
+          >
+            <a>删除</a>
+          </Popconfirm>,
+        ];
+        return btnGroups;
+      },
+    },
+  ];
+
+  const responsibilityColumns = [
+    {
+      title: '责任中心编码',
+      dataIndex: 'responsibilityCode',
+      key: 'responsibilityCode',
+      hideInSearch: false,
+    },
+    {
+      title: '责任中心名',
+      dataIndex: 'responsibilityName',
+      key: 'responsibilityName',
+      hideInSearch: false,
+    },
+  ];
+
+  const [createModalVisible, handleModalVisible] = useState(false);
+  const actionRef = useRef();
+  const [modalTitle, setModalTitle] = useState('');
+  const [currentRow, setCurrentRow] = useState({});
+  const [modalType, setModalType] = useState(0); // 1 复制数据 2 新增数据
+  const formRef = useRef(); //新增/编辑表单ref
+  const [edit, setEdit] = useState(false);
+
+  const [drawerType, setDrawerType] = useState(0);
+  const [drawerVisible, setDrawerVisible] = useState(false);
+  const [defaultSelectedDrawerTableList, setDefaultSelectedDrawerTableList] = useState([]);
+  const [responsibilityList, setResponsibilityList] = useState([]);
+
+  // const [shareParamsSetting,setShareParamsSetting] = useState(false);  //是否分摊参数设置
+
+  //获取列表
+  const getMonthCostShareData = async (params = {}, sort, filter) => {
+    const { date, responsibilityCode } = params;
+    const res = await getMonthCostShareDataList({
+      ...params,
+      date: moment(date).format('yyyyMM'),
+      responsibilityCode: responsibilityCode
+        ? responsibilityCode[responsibilityCode.length - 1]
+        : '',
+    });
+
+    return {
+      data: res.data.list,
+      total: res.data.totalCount,
+      success: res.success,
+    };
+  };
+
+  /**
+   *
+   * @param {Object} value 删除项数据
+   */
+  const delList = async (value) => {
+    const ids = [value.id];
+    const resp = await delMonthCostShareData({ ids });
+    if (resp.status == 200) {
+      if (actionRef.current) {
+        actionRef.current.reload();
+      }
+    }
+  };
+
+  const openDrawer = () => {
+    console.log('openDrawer');
+    setDrawerType(1);
+    setDrawerVisible(false);
+    setDrawerVisible(true);
+    if (edit) {
+      const { responsibilityCode: responsibilityCodes } = formRef?.current?.getFieldsValue(true);
+      setTimeout(() => {
+        setDefaultSelectedDrawerTableList([].concat([responsibilityCodes]));
+      }, 1000);
+    }
+  };
+
+  const getResponsibilityTableList = async (params = {}, sort, filter) => {
+    const resp = await getResponsibilityCenterList(params);
+    const {
+      status,
+      data: { list, totalCount },
+    } = resp;
+
+    if (status == 200) {
+      return {
+        data: list,
+        total: totalCount,
+        success: true,
+      };
+    }
+  };
+
+  const addListhandle = async () => {
+    setEdit(false);
+    setModalTitle('新增月成本分摊参数值处理');
+    setModalType(3);
+    handleModalVisible(true);
+  };
+
+  const copyDataHandle = () => {
+    setModalType(1);
+    setModalTitle('复制数据');
+    handleModalVisible(true);
+  };
+
+  const calculateHandle = async () => {
+    // setModalType(2);
+    // setModalTitle('计算数据');
+    const resp = await calculateMonthCostShareData({date:currentTime});
+    const {status} = resp;
+    if(status==200){
+      actionRef?.current?.reload();
+    }
+    
+  };
+
+  /**
+   *
+   * @param {Object} formData  //表单提交的数据
+   */
+  const modalFormOnFinishHandle = async (formData) => {
+    //  console.log({formData});
+    // console.log({modalType,edit});
+    if (modalType == 3) {
+      const {shareParamCode, valueNum } = formData;
+      const { responsibilityCode } = formRef?.current?.getFieldsValue(true);
+      
+      if (!edit) {
+        await addMonthCostShareData({
+          date:moment(currentTime).format('yyyyMM'),
+          shareParamCode,
+          valueNum,
+          responsibilityCode,
+        });
+      }
+
+      if (edit) {
+        const { id } = currentRow;
+        await editMonthCostShareData({
+          id,
+          date:moment(currentTime).format('yyyyMM'),
+          shareParamCode,
+          valueNum,
+          responsibilityCode,
+        });
+      }
+    }
+
+    if (modalType == 1) {
+      const {dataSourceType,toDate,date:fromDate} = formData
+      await copyMonthCostShareData({dataSourceType,toDate:moment(toDate).format('yyyyMM'),fromDate:moment(fromDate).format('yyyyMM')});
+    }
+
+    // if (modalType == 2) {
+    //   const {date} = formData
+    //   await calculateMonthCostShareData({date:moment(date).format('yyyyMM')});
+    // }
+
+    actionRef?.current?.reload();
+    setEdit(false);
+    setCurrentRow(null);
+    handleModalVisible(false);
+  };
+
+  const getDeafaultSelectedList = () => {
+    return drawerType == 1 && edit ? defaultSelectedDrawerTableList : [];
+  };
+
+  const tableColumns = columns.map((col) => {
+    if (!col.editable) {
+      return col;
+    }
+
+    return {
+      ...col,
+      onCell: (record) => ({
+        record,
+        editable: col.editable,
+        dataIndex: col.dataIndex,
+        title: col.title,
+        handleSave:async (row)=>{
+              // console.log({row,record});
+              const {valueNum:oldValueNum} = record;
+              const {id,dateMonth,dateYear,shareParamCode,responsibilityCode,valueNum} = row;
+              if(oldValueNum != valueNum){
+                setEdit(true);
+                setModalType(3);
+                const resp = await editMonthCostShareData({
+                  id,
+                  date:`${dateYear}${dateMonth>9?dateMonth:'0'+dateMonth}`,
+                  shareParamCode,
+                  valueNum,
+                  responsibilityCode,
+                });
+  
+                const {status} = resp;
+                if(status==200){
+                  actionRef?.current?.reload();
+                }
+              }
+        },
+      }),
+    };
+  });
+
+  const components = {
+    body: {
+      row: EditableRow,
+      cell: EditableCell,
+    },
+  };
+
+  useEffect(async () => {
+    //赋值搜索级联组件
+    const resp = await getResponsibilityTableList({ pageSize: 500 });
+    const { data } = resp;
+    setResponsibilityList(data);
+  }, []);
+
+  return (
+    <PageContainer>
+      <ProTable
+        columns={tableColumns}
+        request={getMonthCostShareData}
+        actionRef={actionRef}
+        components={components}
+        rowKey="id"
+        search={{}}
+        toolBarRender={() => [
+          <Button
+            key="button"
+            onClick={() => {
+              copyDataHandle();
+            }}
+          >
+            复制数据
+          </Button>,
+          <Button
+            key="button"
+            onClick={() => {
+              calculateHandle();
+            }}
+          >
+            计算数据
+          </Button>,
+          <Button
+            key="button"
+            icon={<PlusOutlined />}
+            type="primary"
+            onClick={() => {
+              addListhandle();
+            }}
+          >
+            新增
+          </Button>,
+        ]}
+        pagination={{
+          pageSize: 10,
+        }}
+      />
+
+      <ModalForm
+        title={modalTitle}
+        width="800px"
+        formRef={formRef}
+        labelCol={{ span: 5, offset: 3 }}
+        layout={'horizontal'}
+        modalProps={{
+          destroyOnClose: true,
+        }}
+        initialValues={
+          edit
+            ? { ...currentRow, date:`${currentRow.dateYear}-${currentRow.dateMonth}` }
+            : { date:moment().format('YYYY-MM') }
+        }
+        visible={createModalVisible}
+        onVisibleChange={handleModalVisible}
+        onFinish={async (value) => {
+          modalFormOnFinishHandle(value);
+          // setCurrentRow(undefined);
+        }}
+      >
+        {/* 复制数据 */}
+        {modalType == 1 && (
+          <>
+            <ProFormDatePicker
+              name="date"
+              rules={[
+                {
+                  required: true,
+                  message: '复制时间是必填项!',
+                },
+              ]}
+              width="sm"
+              label="复制数据年月"
+              fieldProps={{ picker: 'month', locale: locale, format: 'yyyy-MM' }}
+            />
+            <ProFormDatePicker
+              name="toDate"
+              label="目标年月"
+              rules={[
+                {
+                  required: true,
+                  message: '目标时间是必填项!',
+                },
+              ]}
+              width="sm"
+              fieldProps={{ picker: 'month', locale: locale, format: 'yyyy-MM' }}
+            />
+            <ProFormSelect
+              options={[
+                {
+                  value: 1,
+                  label: '手动输入',
+                },
+                {
+                  value: 2,
+                  label: '文件导入',
+                },
+                {
+                  value: 3,
+                  label: '全部',
+                },
+              ]}
+              rules={[
+                {
+                  required: true,
+                  message: '数据类型是必填项!',
+                },
+              ]}
+              width="sm"
+              name="dataSourceType"
+              label="数据类型"
+            />
+          </>
+        )}
+        {/* 计算数据 */}
+        {/* {modalType == 2 && (
+          <>
+            <ProFormDatePicker
+              name="date"
+              rules={[
+                {
+                  required: true,
+                  message: '时间是必选项!',
+                },
+              ]}
+              width="sm"
+              label="选择数据年月"
+              fieldProps={{ picker: 'month', locale: locale, format: 'yyyy-MM' }}
+            />
+          </>
+        )} */}
+        {/* 新增/编辑数据 */}
+        {modalType == 3 && (
+          <>
+            {/* <ProFormDatePicker
+              name="date"
+              rules={[
+                {
+                  required: true,
+                  message: '时间是必选项!',
+                },
+              ]}
+              width="sm"
+              label="年月"
+              fieldProps={{ picker: 'month', locale: locale, format: 'yyyy-MM' }}
+            /> */}
+            <ProFormSelect
+              name="shareParamCode"
+              label="选择分摊参数"
+              rules={[
+                {
+                  required: true,
+                  message: '必选项!',
+                },
+              ]}
+              request={async (params = {}, sort, filter) => {
+                const resp = await getCostshareparamList({ ...params, pageSize: 500 });
+                const {
+                  status,
+                  data: { list },
+                } = resp;
+                if (status == 200) {
+                  return (
+                    list &&
+                    list.map((item) => ({ label: item.shareParamName, value: item.shareParamCode }))
+                  );
+                }
+              }}
+              width="sm"
+              placeholder="请选择"
+              rules={[{ required: true, message: '分摊参数是必选项!' }]}
+            />
+            <ProFormText
+              name="responsibilityName"
+              label="选择责任中心"
+              placeholder="请选择"
+              rules={[
+                {
+                  required: true,
+                  message: '必选项!',
+                },
+              ]}
+              stringMode
+              width="sm"
+              min={0}
+              fieldProps={{
+                onClick: () => openDrawer(),
+              }}
+            />
+            <ProFormDigit
+              label="数值"
+              name="valueNum"
+              width="sm"
+              rules={[
+                {
+                  required: true,
+                  message: '必选项!',
+                },
+              ]}
+            />
+          </>
+        )}
+      </ModalForm>
+
+      {drawerType != 0 &&(
+        <DrawerContent
+          columns={drawerType == 1 ? responsibilityColumns : []}
+          visible={drawerVisible}
+          currentRow={currentRow?currentRow:{}}
+          type="radio"
+          title={drawerType == 1 ? '选择责任中心' : ''}
+          defaultSelected={getDeafaultSelectedList()}
+          pageContainerConfig={(tableRef) => {
+            return {
+              header: {
+                title: '',
+                breadcrumb: '',
+              },
+            };
+          }}
+          onVisibleChange={(bool) => setDrawerVisible(bool)}
+          renderListFunc={drawerType == 1 ? getResponsibilityTableList : () => {}}
+          config={{ rowKeys: 'responsibilityCode', tableSearch: false }}
+          tableSearch={false}
+          expandable={{
+            childrenColumnName: 'child',
+          }}
+          onFinishFunc={async (value, selectedRowKeys, selectedRows) => {
+            // console.log({ value, selectedRowKeys, selectedRows, drawerType });
+            //新增
+            if (drawerType == 1) {
+              if (selectedRows.length > 0) {
+                const { responsibilityCode, responsibilityName } = selectedRows[0];
+                if (formRef.current) {
+                  formRef.current.setFieldsValue({
+                    responsibilityName,
+                    responsibilityCode,
+                  });
+                }
+              }
+            }
+
+            if (drawerType == 2) {
+              //selectedRows为空标识没有编辑
+              let selectedItemNames = selectedRows.map((item) => item.accountingName);
+
+              if (edit) {
+                if (selectedRows.length > 0) {
+                  if (updateFormRef.current) {
+                    updateFormRef.current.setFieldsValue({
+                      accountingNames: selectedItemNames.join(','),
+                      accountingIds: selectedRowKeys.join(','),
+                    });
+                  }
+                }
+              }
+              if (!edit) {
+                if (ref.current) {
+                  ref.current.setFieldsValue({
+                    accountingName: selectedItemNames.join(','),
+                    accountingIds: selectedRowKeys.join(','),
+                  });
+                }
+              }
+              setDrawerVisible(false);
+            }
+
+            setDrawerType(0);
+          }}
+        />
+      )}
+
+      {/* 更新 */}
+      {/* <UpdateForm
+        onSubmit={async (value) => {
+          const { id } = currentRow;
+          const { responsibilityCodes } = value;
+          const resp = await editIncomeCollectionList({
+            ...value,
+            id,
+            responsibilityCodes: responsibilityCodes ? responsibilityCodes.join('/') : null,
+          });
+          const { status } = resp;
+          if (status == 200) {
+            handleUpdateModalVisible(false);
+            setCurrentRow(undefined);
+
+            if (actionRef.current) {
+              actionRef.current.reload();
+            }
+          }
+        }}
+        onCancel={() => {
+          handleUpdateModalVisible(false);
+          setCurrentRow(undefined);
+        }}
+        updateModalVisible={updateModalVisible}
+        updateModalVisibleChange={updateModalVisibleChange}
+        values={currentRow || {}}
+      /> */}
+    </PageContainer>
+  );
+};
+
+export default CostShareParamsHandle;

+ 72 - 0
src/pages/costAccounting/costShareParamsHandle/service.js

@@ -0,0 +1,72 @@
+/*
+ * @Author: your name
+ * @Date: 2021-08-03 14:38:54
+ * @LastEditTime: 2021-08-18 19:22:29
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /CostAccountManaSys/src/pages/platformMana/menuManage/service.js
+ */
+
+
+
+import { request } from 'umi';
+
+//获月成本分摊参数值处理列表
+export async function getMonthCostShareDataList(params, options) {
+    return request('/api/costAccount/shareParamValue/list', {
+      method: 'GET',
+      params: {...params},
+      ...(options || {}),
+    });
+}
+
+
+
+
+//新增月成本分摊参数值处理
+export async function addMonthCostShareData(body, options) {
+    return request('/api/costAccount/shareParamValue/addData', {
+      method: 'POST',
+      data: {...body},
+      ...(options || {}),
+    });
+}
+
+//编辑
+export async function editMonthCostShareData(body, options) {
+  return request('/api/costAccount/shareParamValue/edit', {
+    method: 'POST',
+    data: {...body},
+    ...(options || {}),
+  });
+}
+
+//复制数据
+export async function copyMonthCostShareData(body, options) {
+  return request('/api/costAccount/shareParamValue/copyData', {
+    method: 'POST',
+    data: {...body},
+    ...(options || {}),
+  });
+}
+
+//计算数据
+export async function calculateMonthCostShareData(params, options) {
+  return request('/api/costAccount/shareParamValue/calcData', {
+    method: 'POST',
+    params: {...params},
+    ...(options || {}),
+  });
+}
+
+//删除
+export async function delMonthCostShareData(body, options) {
+  const {ids} = body;
+  return request(`/api/costAccount/shareParamValue/delete`, {
+    data:ids,
+    method: 'POST',
+    ...(options || {}),
+  });
+}
+
+

+ 124 - 0
src/pages/costAccounting/costShareParamsHandle/updateForm.jsx

@@ -0,0 +1,124 @@
+import React, { useEffect, useState } from 'react';
+import {
+  ModalForm,
+  ProFormSelect,
+  ProFormDigit,
+  ProFormDatePicker
+} from '@ant-design/pro-form';
+
+// import { Cascader, Form, Input } from 'antd';
+
+import { getResponsibilityCenterList } from '@/pages/responsibilityCenter/service';
+
+import { getCostshareparamList } from '@/pages/costAllocationParamsSetting/service';
+
+
+
+const UpdateForm = (props) => {
+  const { updateModalVisible, updateModalVisibleChange, values, onSubmit } = props;
+  const [options, setOptions] = useState([]);
+  const [responsibilityCodes, setResponsibilityCode] = useState(null);
+  const [selected, setSelected] = useState([]);
+  // console.log({'回显':values});
+
+  useEffect(async () => {
+    if (JSON.stringify(values) !== '{}') {
+      const { responsibilityCodes } = values;
+
+      setSelected(responsibilityCodes ? [].concat(responsibilityCodes.split('/')) : []);
+      const resp = await getResponsibilityCenterList({ pageSize: 50, current: 1 });
+      const { status, data } = resp;
+      if (status == 200) {
+        setOptions(data.list);
+      }
+    }
+  }, [values]);
+
+
+
+  return (
+    <>
+      {
+        JSON.stringify(values) !== '{}' && <ModalForm
+          title="编辑收入归集设置"
+          width="800px"
+          initialValues={{ ...values }}
+          labelCol={{ span: 5, offset: 3 }}
+          layout={'horizontal'}
+          visible={updateModalVisible}
+          onVisibleChange={(visible) => updateModalVisibleChange(visible)}
+          onFinish={(value) => onSubmit({ ...values, ...value, responsibilityCodes })}
+        >
+          <ProFormDatePicker
+            name="date"
+            rules={[
+              {
+                required: true,
+                message: '时间是必选项!',
+              },
+            ]}
+            width="sm"
+            label="年月"
+            fieldProps={{ picker: 'month', locale: locale, format: 'yyyy-MM' }}
+          />
+          <ProFormSelect
+            name="shareParamCode"
+            label="选择分摊参数"
+            rules={[
+              {
+                required: true,
+                message: '必选项!',
+              },
+            ]}
+            request={async (params = {}, sort, filter) => {
+              const resp = await getCostshareparamList({ ...params, pageSize: 500 });
+              const {
+                status,
+                data: { list },
+              } = resp;
+              if (status == 200) {
+                return (
+                  list &&
+                  list.map((item) => ({ label: item.shareParamName, value: item.shareParamCode }))
+                );
+              }
+            }}
+            width="sm"
+            placeholder="请选择"
+            rules={[{ required: true, message: '分摊参数是必选项!' }]}
+          />
+          <ProFormText
+            name="responsibilityName"
+            label="选择责任中心"
+            placeholder="请选择"
+            rules={[
+              {
+                required: true,
+                message: '必选项!',
+              },
+            ]}
+            stringMode
+            width="sm"
+            min={0}
+            fieldProps={{
+              onClick: () => openDrawer(),
+            }}
+          />
+          <ProFormDigit
+            label="数值"
+            name="valueNum"
+            width="sm"
+            rules={[
+              {
+                required: true,
+                message: '必选项!',
+              },
+            ]}
+          />
+        </ModalForm>
+      }
+    </>
+  );
+};
+
+export default UpdateForm;

+ 2 - 2
src/pages/costAccounting/incomeCollection/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-12 19:28:07
+ * @LastEditTime: 2021-08-20 16:14:33
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -39,7 +39,7 @@ const IncomeCollection = () => {
         }
         return (
           <Form.Item >
-             <ProFormDatePicker initialValue={currentTime} fieldProps={{format:'YYYY-MM',picker:'month',locale:locale}} name="date" />
+             <ProFormDatePicker initialValue={moment(currentTime).subtract(1,'months')} fieldProps={{format:'YYYY-MM',picker:'month',locale:locale}} name="date" />
           </Form.Item>
         )
       },

+ 33 - 18
src/pages/costAccounting/incomeCostDataImport/index.jsx

@@ -1,14 +1,14 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 15:09:58
+ * @LastEditTime: 2021-08-19 15:57:26
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
  */
 
 // import { PlusOutlined } from '@ant-design/icons';
-import { Button} from 'antd';
+import { Button,Form} from 'antd';
 import React, { useState, useRef } from 'react';
 import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
@@ -23,7 +23,27 @@ import locale from 'antd/es/date-picker/locale/zh_CN';
 
 
 const IncomeCostDataImport = () => {
+  const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM'));
   const columns = [
+
+    {
+      title: '所属年份',
+      key: 'dateTime',
+      hideInTable: true,
+      dataIndex: 'dateTime',
+      renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
+
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item  name='dateTime'>
+            <ProFormDatePicker  fieldProps={{ picker: 'month', format: (value) => { return value.format('YYYY-MM') }, locale: locale,onChange:(moment)=>{setCurrentTime(moment.format('YYYY-MM'))} }} name="dateTime" />
+          </Form.Item>
+        )
+      },
+    },
+
     {
       title: '文件编号',
       dataIndex: 'id',
@@ -46,6 +66,9 @@ const IncomeCostDataImport = () => {
       dataIndex: 'dateTime',
       key: 'dateTime',
       hideInSearch: true,
+      render:(_,record)=>{
+          return `${record.dateYear}-${record.dateMonth}`
+      }
     },
     {
       title: '导入时间',
@@ -87,10 +110,11 @@ const IncomeCostDataImport = () => {
       dataIndex: 'option',
       valueType: 'option',
       render: (_, record) =>{
-          const {errStatus} = record;
+          const {errStatus,rollbackStatus} = record;
           return [
             <Button
               key="config"
+              disabled={rollbackStatus==1?true:false}
               danger={errStatus==1?true:false}
               onClick={() => {
                 optionBtnGrouphandle(errStatus,record)
@@ -123,7 +147,6 @@ const IncomeCostDataImport = () => {
 
 
   const [createModalVisible, handleModalVisible] = useState(false);
-  const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const actionRef = useRef();
   const ref = useRef();   //新增表单
   const importFormRef = useRef();   //导入表单
@@ -155,18 +178,12 @@ const IncomeCostDataImport = () => {
   }
  
 
-  /**
-   *
-   * @param {Boolean} bool 弹窗展示状态
-   */
-  const updateModalVisibleChange = (bool) => {
-    handleUpdateModalVisible(bool);
-    if (!bool) setCurrentRow(undefined);
-  };
+
 
   //获取列表
   const getList = async (params = {}, sort, filter) => {
-    const res = await getIncomeCostDataImport(params);
+    const {dateTime}  = params
+    const res = await getIncomeCostDataImport({...params,dateTime:dateTime?currentTime:''});
     // console.log({res});
     return {
       data: res.data.list,
@@ -207,10 +224,7 @@ const IncomeCostDataImport = () => {
               const {fileType,dateTime} = values;
               formData.set('fileType',fileType);
               formData.set('dateTime',dateTime);
-              // console.log({formData});
-              // console.log(formData.get('fileType'));
-              // console.log(formData.get('dateTime'));
-              // console.log(formData.get('file'));
+         
               const resp = await addIncomeCostDataImport({formData},{
                 'content-type':'multipart/form-data',
               })
@@ -273,7 +287,7 @@ const IncomeCostDataImport = () => {
   
 
   const getDrawerTableList = async ()=>{
-        console.log({currentRow});
+        // console.log({currentRow});
         const {id} = currentRow;
         const resp = await getIncomeCostDataImportErrList({id});
         const {status,data} = resp;
@@ -300,6 +314,7 @@ const IncomeCostDataImport = () => {
         rowKey="id"
         toolBarRender={() => [
           <CAUpload
+            key='CAUpload'
             templateHrefs={[
                 {
                   label:'成本分摊参数模板',

+ 300 - 0
src/pages/costAccounting/wholeHospIncomeAndCost/index.jsx

@@ -0,0 +1,300 @@
+/*
+ * @Author: your name
+ * @Date: 2021-07-26 10:13:13
+ * @LastEditTime: 2021-08-20 11:42:55
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
+ */
+
+import { PlusOutlined } from '@ant-design/icons';
+import { Button, Popconfirm, Form } from 'antd';
+import React, { useState, useRef } from 'react';
+
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import { ModalForm, ProFormText, ProFormSelect, ProFormDigit, ProFormDatePicker, ProFormDependency } from '@ant-design/pro-form';
+
+import { getWholeHospCostList, editWholeHospCostList, delWholeHospCostList, addWholeHospCostList } from './service';
+import { getWholeHospCostList as getWholeHospCostSetList } from '@/pages/baseSetting/wholeHospCostAndIncomeSet/service';
+import moment from 'moment';
+import 'moment/locale/zh-cn';
+import locale from 'antd/es/date-picker/locale/zh_CN';
+
+const WholeHospIncomeAndCost = () => {
+  const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM'));
+  const columns = [
+    {
+      title: '选择时间',
+      key: 'dateTime',
+      hideInTable: true,
+      dataIndex: 'dateTime',
+      renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
+        if (type === 'form') {
+          return null;
+        }
+        return (
+          <Form.Item>
+            <ProFormDatePicker
+              fieldProps={{
+                picker: 'month',
+                format: (value) => {
+                  return value.format('YYYY-MM');
+                },
+                locale: locale,
+                onChange: (moment) => {
+                  setCurrentTime(moment.format('YYYYMM'));
+                },
+              }}
+              name="dateTime"
+            />
+          </Form.Item>
+        );
+      },
+    },
+    {
+      title: 'id',
+      dataIndex: 'id',
+      key: 'id',
+      hideInSearch: true,
+      hideInTable: true,
+    },
+    {
+      title: '年份',
+      dataIndex: 'dateYear',
+      key: 'dateYear',
+      hideInSearch: true,
+    },
+    {
+      title: '月份',
+      dataIndex: 'dateMonth',
+      key: 'dateMonth',
+      hideInSearch: true,
+    },
+    {
+      title: '收支类型',
+      dataIndex: 'paymentsType',
+      key: 'paymentsType',
+      hideInSearch: true,
+      render: num => <>{num == 1 ? '收入' : '支出'}</>
+    },
+    {
+      title: '收支名称',
+      dataIndex: 'paymentsName',
+      key: 'paymentsName',
+      hideInSearch: true,
+    },
+    {
+      title: '金额',
+      dataIndex: 'totalAmount',
+      key: 'totalAmount',
+      hideInSearch: true,
+    },
+    {
+      title: '操作',
+      dataIndex: 'option',
+      valueType: 'option',
+      render: (_, record) => [
+        <a
+          key="config"
+          onClick={() => {
+            setEdit(true);
+            handleModalVisible(true);
+            setCurrentRow(record);
+          }}
+        >
+          编辑
+        </a>,
+        <Popconfirm
+          key="subscribeAlert"
+          title="是否确定删除?"
+          onConfirm={() => {
+            setCurrentRow(record);
+            delListHandler(record);
+          }}
+        >
+          <a>删除</a>
+        </Popconfirm>,
+      ],
+    },
+  ];
+
+
+  const [createModalVisible, handleModalVisible] = useState(false);
+  const actionRef = useRef();
+  const ref = useRef();   //新增表单
+  const [currentRow, setCurrentRow] = useState(undefined);
+  const [edit, setEdit] = useState(false);
+
+
+
+
+  //获取列表
+  const getList = async (params = {}, sort, filter) => {
+    const res = await getWholeHospCostList({ ...params });
+    // console.log({res});
+    return {
+      data: res.data.list,
+      total: res.data.totalCount,
+      success: res.success,
+    };
+  };
+
+
+
+  /**
+   *
+   * @param {Object} value 删除项数据
+   */
+  const delListHandler = async (value) => {
+    const resp = await delWholeHospCostList(value);
+    // console.log({ resp });
+    if (resp.status) {
+      if (actionRef.current) {
+        actionRef.current.reload();
+      }
+    }
+  };
+
+
+
+
+  // useEffect(()=>{
+  //   CARequest('/api/costAccount/hosptail/list');
+  // },[]);
+
+  return (
+    <PageContainer>
+      <ProTable
+        columns={columns}
+        request={getList}
+        actionRef={actionRef}
+        rowKey="id"
+        toolBarRender={() => [
+          <Button
+            key="button"
+            icon={<PlusOutlined />}
+            type="primary"
+            onClick={() => {
+              setEdit(false)
+              handleModalVisible(true);
+            }}
+          >
+            新增
+          </Button>
+        ]}
+
+        pagination={{
+          pageSize: 10,
+        }}
+
+
+      />
+
+      <ModalForm
+        title={edit ? '编辑全院其他收支数值' : '新增全院其他收支数值'}
+        width="800px"
+        labelCol={{ span: 5, offset: 3 }}
+        layout={'horizontal'}
+        formRef={ref}
+        initialValues={edit && currentRow ? { ...currentRow, 
+          dateTime: `${currentRow.dateYear}-${currentRow.dateMonth > 9 ? currentRow.dateMonth : '0' + currentRow.dateMonth}`,
+          paymentData:JSON.stringify(currentRow?{paymentsType:currentRow.paymentsType,paymentsName:currentRow.paymentsName}:{})
+         } : {}}
+        visible={createModalVisible}
+        onVisibleChange={(bool) => {
+          if (ref.current) {
+            ref.current.resetFields();
+          }
+          handleModalVisible(bool);
+        }}
+        onFinish={async (value) => {
+          // console.log({value});
+          const { dateTime,paymentData:paymentsTypeJson,totalAmount } = value;
+          // console.log(JSON.parse(paymentsTypeJson));
+          const {paymentsType,paymentsName} = paymentsTypeJson?JSON.parse(paymentsTypeJson):{};
+          if(!edit){
+            const resp = await addWholeHospCostList({ ...value,paymentsName,paymentsType,totalAmount,dateTime: moment(dateTime).format('yyyy-MM') });
+            const { status } = resp;
+            if (status == 200) {
+              handleModalVisible(false);
+              actionRef?.current?.reload();
+            }
+          }
+          if(edit){
+            const {id} = currentRow;
+            const resp = await editWholeHospCostList({ ...value,id,paymentsName,paymentsType,totalAmount,dateTime: moment(dateTime).format('yyyy-MM') });
+            const { status} = resp;
+            if (status == 200) {
+              handleModalVisible(false);
+              actionRef?.current?.reload();
+            }
+          }
+          
+        }}
+      >
+
+        <ProFormDatePicker
+          // initialValue={currentTime}
+          rules={[
+            {
+              required: true,
+              message: '年月是必填项!',
+            },
+          ]}
+          fieldProps={{
+            picker: 'month',
+            format: (value) => {
+              return value.format('YYYY-MM');
+            },
+            locale: locale,
+          }}
+          label="选择年月"
+          name="dateTime"
+        />
+        <ProFormSelect
+          rules={[
+            {
+              required: true,
+              message: '请选择收支名称',
+            },
+          ]}
+          fieldProps={{
+              onChange:(val)=>{
+                  // console.log({val});
+                  const {paymentsType:type,paymentsName} = val?JSON.parse(val):{};
+                  paymentsName&&(ref?.current?.setFieldsValue({paymentsName:paymentsName,paymentsType:type}))
+              }
+          }}
+          request={async () => {
+            const resp = await getWholeHospCostSetList({ pageSize: 200, current: 1 });
+            const {data: { list } } = resp;
+      
+            return list.map(item => ({
+              label: item.paymentsName,
+              value: JSON.stringify({paymentsType:item.paymentsType,paymentsName:item.paymentsName})
+            }))
+
+          }}
+          width="sm"
+          name="paymentData"
+          label="选择收支名称"
+        />
+        <ProFormDigit
+          rules={[
+            {
+              required: true,
+              message: '金额手必填项',
+            },
+          ]}
+          width="sm"
+          min={0}
+          name="totalAmount"
+          label="金额"
+        />
+      </ModalForm>
+    </PageContainer>
+  );
+};
+
+export default WholeHospIncomeAndCost;

+ 51 - 0
src/pages/costAccounting/wholeHospIncomeAndCost/service.js

@@ -0,0 +1,51 @@
+/*
+ * @Author: your name
+ * @Date: 2021-07-26 08:54:08
+ * @LastEditTime: 2021-08-20 10:40:28
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: /TracerMethodology_PC/src/pages/DepartmentMana/service.js
+ */
+
+import { request } from 'umi';
+
+
+//获取  全院其他收支列表
+export async function getWholeHospCostList(params, options) {
+    return request('/api/costAccount/costotherpaymentsdata/list', {
+      method: 'GET',
+      params:{...params},
+      ...(options || {}),
+    });
+}
+
+
+//编辑
+export async function editWholeHospCostList(body, options) {
+  return request('/api/costAccount/costotherpaymentsdata/update', {
+    method: 'POST',
+    data:{...body},
+    ...(options || {}),
+  });
+}
+
+//新增
+export async function addWholeHospCostList(body, options) {
+  return request('/api/costAccount/costotherpaymentsdata/save', {
+    method: 'POST',
+    data:{...body},
+    ...(options || {}),
+  });
+}
+
+//删除
+export async function delWholeHospCostList(params, options) {
+  const {id} = params;
+  const ids = [id];
+  return request(`/api/costAccount/costotherpaymentsdata/delete`, {
+    method: 'POST',
+    data:ids,
+    ...(options || {}),
+  });
+}
+

+ 295 - 79
src/pages/costAllocationParamsConnect/index.jsx

@@ -1,27 +1,31 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-03 17:10:11
+ * @LastEditTime: 2021-08-20 11:05:55
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
  */
 
 import { PlusOutlined } from '@ant-design/icons';
-import { Button, Popconfirm, Cascader} from 'antd';
+import { Button, Popconfirm,Tag } from 'antd';
 import React, { useState, useRef, useEffect } from 'react';
-import { PageContainer} from '@ant-design/pro-layout';
+import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
-import ProForm, { ModalForm, DrawerForm, ProFormSelect, ProFormTextArea, ProFormDigit } from '@ant-design/pro-form';
+import ProForm, { ModalForm, DrawerForm, ProFormSelect, ProFormTextArea, ProFormDigit, ProFormText } from '@ant-design/pro-form';
 import UpdateForm from './updateForm';
 import UpdateFormDrawer from './updateForm_drawer';
 // import CAUpload from '@/components/CAUpload';
+import DrawerContent from './selectCopyDrawer';
+import { getAccountingSubjectList } from '../accountingSubject/service';
 import {
   getCostshareparamConnectList, editCostshareparamConnectList, delCostshareparamConnect,
   addCostshareparamConnect, getResponsibilityCenterSelecterList, getAccountingSubjectForSelecter,
-  getHasSetParamsList, getParamsSelectableList, saveParamsList
+  getHasSetParamsList, getParamsSelectableList, saveParamsList, copyParamsList,getCopyableToList
 } from './service';
 
+import {deepGetAllParents} from '@/utils';
+
 
 const DepartmentMana = () => {
   const columns = [
@@ -43,19 +47,29 @@ const DepartmentMana = () => {
       dataIndex: 'responsibilityName',
       key: 'responsibilityName',
       hideInSearch: false,
+      render:(_,record) => {
+             const {isShareCost,responsibilityName} = record;
+             return isShareCost==1?<Tag color="default">{`${responsibilityName}(含)`}</Tag>:`${responsibilityName}`
+      }
     },
     {
-      title: '成本项目名称',
-      dataIndex: 'accountingName',
+      title: '会计科目名称',
+      dataIndex: 'accountingNames',
       key: 'accountingName',
       hideInSearch: true,
     },
     {
-      title: '成本项目编码',
-      dataIndex: 'accountingCode',
+      title: '会计科目编码',
+      dataIndex: 'accountingCodes',
       key: 'accountingCode',
       hideInSearch: true,
     },
+    {
+      title: '别名',
+      dataIndex: 'alias',
+      key: 'alias',
+      hideInSearch: true,
+    },
     {
       title: '备注',
       dataIndex: 'costNode',
@@ -63,7 +77,7 @@ const DepartmentMana = () => {
       hideInSearch: true,
     },
     {
-      title:'操作',
+      title: '操作',
       dataIndex: 'option',
       valueType: 'option',
       render: (_, record) => [
@@ -77,9 +91,20 @@ const DepartmentMana = () => {
         >
           分摊参数设置
         </a>,
+        <a
+          key="config1"
+          onClick={() => {
+            setCurrentRow(record);
+            setDrawerType(1);
+            setCopySelectDrawerVisible(true);
+          }}
+        >
+          复制
+        </a>,
         <a
           key="config2"
           onClick={() => {
+            setEdit(true);
             handleUpdateModalVisible(true);
             setCurrentRow(record);
           }}
@@ -121,7 +146,7 @@ const DepartmentMana = () => {
       hideInSearch: false,
     },
     {
-      title:'操作',
+      title: '操作',
       dataIndex: 'option',
       valueType: 'option',
       render: (_, record) => [
@@ -149,16 +174,55 @@ const DepartmentMana = () => {
 
   ];
 
+
+  const responsibilityColumns = [
+    {
+      title: '责任中心Id',
+      dataIndex: 'id',
+      key: 'id',
+      hideInSearch: false,
+    },
+    {
+      title: '责任中心名',
+      dataIndex: 'responsibilityName',
+      key: 'responsibilityName',
+      hideInSearch: false,
+    }
+  ]
+
+  const accountSubjectColumns = [
+    {
+      title: '会计科目Id',
+      dataIndex: 'id',
+      key: 'id',
+      hideInSearch: false,
+    },
+    {
+      title: '会计科目名名',
+      dataIndex: 'accountingName',
+      key: 'accountingName',
+      hideInSearch: false,
+    }
+  ]
+
   const [createModalVisible, handleModalVisible] = useState(false);
   const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const [cascaderOptions, setCascaderOptions] = useState([]);
   const actionRef = useRef(); //表格
   const ref = useRef();   //新增表单
   const [currentResponsibilityRow, setCurrentResponsibilityRow] = useState({});
-  const [selectedCascader, setSelectedCascader] = useState(null);
-  const [currentRow, setCurrentRow] = useState({});
+
+  const [currentRow, setCurrentRow] = useState(undefined);
   const [ifDisable, setIfDisable] = useState(false);
   const [selectedResponsibilityId, setSelectedResponsibilityId] = useState(null);
+  const [selectedResponsibility, setSelectedResponsibility] = useState(null);
+
+  const [copySelectDrawerVisible, setCopySelectDrawerVisible] = useState(false);
+
+  const [drawerType, setDrawerType] = useState(0);  //1 复制数据  2  新增选择会计科目
+  const [accountType, setAccountType] = useState(2); // 1 收入 2  支出
+
+  const [edit,setEdit] = useState(false);
 
 
   const drawerFormRef = useRef(); //DrawerForm
@@ -170,7 +234,12 @@ const DepartmentMana = () => {
   const [selectedParam, setSelectedParam] = useState(null);
   const [newAddParamList, setNewAddParamList] = useState([]);
 
-  const [drawerUpdateModalVisible,setDrawerUpdateModalVisible] = useState(false);
+  const [drawerUpdateModalVisible, setDrawerUpdateModalVisible] = useState(false);
+
+  const [expandedRowKeys,setexpandedRowKeys] = useState([]);
+
+  const [selectedAccountSubjects,setSelectedAccountSubjects] = useState([]);
+  const updateFormRef = useRef();
 
 
   /**
@@ -182,7 +251,7 @@ const DepartmentMana = () => {
     if (!bool) setCurrentRow(undefined);
   };
 
-  const drawerUpdateModalVisibleChange = (bool)=>{
+  const drawerUpdateModalVisibleChange = (bool) => {
     setDrawerUpdateModalVisible(bool);
     if (!bool) setCurrentRow(undefined);
   }
@@ -214,25 +283,17 @@ const DepartmentMana = () => {
    * 
    * @param {Object} record 表格行数据
    */
-  const delParamsListHandler = (record)=>{
-      const {id} = record;
-      const arr = hasSetParamsList;
-      arr.splice(arr.findIndex(item => item.id === id), 1);
-      setHasSetParamsList([].concat(arr));
-      if (actionDrawertableRef.current) {
-        actionDrawertableRef.current.reload();
-      }
+  const delParamsListHandler = (record) => {
+    const { id } = record;
+    const arr = hasSetParamsList;
+    arr.splice(arr.findIndex(item => item.id === id), 1);
+    setHasSetParamsList([].concat(arr));
+    if (actionDrawertableRef.current) {
+      actionDrawertableRef.current.reload();
+    }
   }
 
-  //级联回调
 
-  /**
-   * 
-   * @param {Object} value 
-   */
-  const cascaderChangeHandle = (value) => {
-    setSelectedCascader(value[value.length - 1]);
-  }
   //分摊参数回调
   /**
    * 
@@ -247,7 +308,7 @@ const DepartmentMana = () => {
       const { data, msg, status } = resp;
       // console.log({data, msg, status});
       if (status == 200) {
-        setHasSetParamsList(data?data:[]);
+        setHasSetParamsList(data ? data : []);
 
         if (actionDrawertableRef.current) {
           actionDrawertableRef.current.reload();
@@ -256,7 +317,7 @@ const DepartmentMana = () => {
     }
     setDrawerVisible(bool);
   }
-  
+
 
   /**
    * 
@@ -267,6 +328,47 @@ const DepartmentMana = () => {
   }
 
 
+  const getCopyableTableList = async () => {
+    const {id:accountShareId} = currentRow;
+    const resp = await getCopyableToList({accountShareId});
+    const { status, data} = resp;
+    if (status == 200) {
+      return {
+        data: data,
+        total:data.length ,
+        success: true
+      }
+    }
+  }
+
+  const getAccountingSubjects = async (params = {}, sort, filter) => {
+    const resp = await getAccountingSubjectList({...params,accountType });
+    const { status, data: { list, totalCount } } = resp;
+
+    let accountingIdList=undefined;
+    
+    currentRow&&(accountingIdList = currentRow.accountingIdList)
+
+    const defaultSelected = accountingIdList?accountingIdList.map(item=>Number(item)):[];
+    // console.log({defaultSelected});
+    setSelectedAccountSubjects(defaultSelected);
+    const allParents = deepGetAllParents(list,'children');
+    const ids = allParents.map(item=>item.id);
+    setexpandedRowKeys(ids);
+    if (status == 200) {
+      return {
+        data: list,
+        total: totalCount,
+        success: true
+      }
+    }
+  }
+
+  const selectAccountSubjecthandle = () => {
+    setDrawerType(2);
+    setCopySelectDrawerVisible(true);
+  }
+
   useEffect(async () => {
     const respForSelecter = await getAccountingSubjectForSelecter();
     if (respForSelecter.status == 200) {
@@ -287,6 +389,7 @@ const DepartmentMana = () => {
             icon={<PlusOutlined />}
             type="primary"
             onClick={() => {
+              setEdit(false);
               handleModalVisible(true);
             }}
           >
@@ -311,22 +414,26 @@ const DepartmentMana = () => {
         formRef={ref}
         onVisibleChange={(bool) => {
           if (ref.current) {
+            setIfDisable(false);
             ref.current.resetFields();
           }
           handleModalVisible(bool);
         }}
         onFinish={async (value) => {
-          const { costNode } = value;
+          // console.log({value});
+          const { costNode,isShareCost=1,alias} = value;
+          const { accountingIds } = ref.current.getFieldsValue(true);
+          const { responsibilityCode, responsibilityId, responsibilityName, shareLevel } = selectedResponsibility;
+
           const success = await addCostshareparamConnect({
             responsibilityId: selectedResponsibilityId,
-            accountingId: selectedCascader > 0 ? selectedCascader : 0,
-            costNode
-
+            accountingIds: accountingIds,isShareCost,alias,
+            costNode, responsibilityName, shareLevel, responsibilityCode
           });
           //   console.log({ success });
           if (success) {
             handleModalVisible(false);
-
+            
             if (actionRef.current) {
               actionRef.current.reload();
             }
@@ -337,7 +444,7 @@ const DepartmentMana = () => {
           rules={[
             {
               required: true,
-              message:'请选择责任中心',
+              message: '请选择责任中心',
             },
           ]}
           fieldProps={{//这里使用了select的onChange方法,必须使用这样的写法来进行调用onChange方法
@@ -347,10 +454,11 @@ const DepartmentMana = () => {
               const { data, msg, status } = resp;
               if (status == 200) {
                 const selected = data.filter(item => item.id == val);
-                if (selected && selected[0].calcType == 0) {
-                  setIfDisable(true);
-                } else {
+                setSelectedResponsibility(selected[0]);
+                if (selected && selected[0].calcType == 1) {
                   setIfDisable(false);
+                } else {
+                  setIfDisable(true);
                 }
               }
             },
@@ -369,11 +477,42 @@ const DepartmentMana = () => {
           name="responsibilityId"
           label="请选择责任中心"
         />
-        <ProForm.Group style={{ marginBottom: 20 }}>
-          <div style={{ marginLeft: 115 }}>请选择成本科目:</div>
-          <Cascader disabled={ifDisable} options={cascaderOptions} onChange={cascaderChangeHandle} placeholder="请选择成本科目" />
-        </ProForm.Group>
-
+        <ProFormText
+          disabled={ifDisable}
+          rules={[
+            {
+              required: ifDisable?false:true,
+              message: '请选择会计科目',
+            },
+          ]}
+          fieldProps={{
+            onClick: () => selectAccountSubjecthandle()
+          }}
+          width="sm"
+          name="accountingName"
+          label="选择会计科目"
+        />
+        <ProFormSelect
+          disabled={ifDisable}
+          rules={[
+            {
+              required: ifDisable?false:true,
+              message: '请选择',
+            },
+          ]}
+          width="sm"
+          request={async () => [
+            { label: '不包含分摊成本', value: 0 },
+            { label: '包含分摊成本', value: 1 }
+          ]}
+          name="isShareCost"
+          label="是否包含分摊成本"
+        />
+        <ProFormText
+          width="sm"
+          name="alias"
+          label="别名"
+        />
         <ProFormTextArea
           name="costNode"
           label="备注"
@@ -390,27 +529,26 @@ const DepartmentMana = () => {
         onVisibleChange={(visible) => drawerVisibleChange(visible)}
         // onFinish={(value) => onSubmit({ ...values, ...value })}
         onFinish={async () => {
-          if(true){
+          if (true) {
             const { id } = currentResponsibilityRow;
-      
+
             const resp = await saveParamsList({
               id,
               shareParamProportionVOList: hasSetParamsList
             });
-            const {status} = resp;
-            if(status == 200){
+            const { status } = resp;
+            if (status == 200) {
               setDrawerVisible(false);
               if (actionRef.current) {
                 actionRef.current.reload();
               }
             }
           }
-          
+
         }}
       >
         <ProTable
           columns={drawerTableColumns}
-          // request={[]}
           rowKey="id"
           actionRef={actionDrawertableRef}
           toolBarRender={() => [
@@ -427,15 +565,13 @@ const DepartmentMana = () => {
             </Button>
           ]}
           request={async (params = {}, sort, filter) => {
-            console.log({ hasSetParamsList });
+            // console.log({ hasSetParamsList });
             return {
               data: hasSetParamsList,
               success: true
             };
           }}
-          pagination={{
-            pageSize: 10,
-          }}
+          pagination={false}
           search={false}
         />
         <ModalForm
@@ -453,7 +589,7 @@ const DepartmentMana = () => {
           }}
 
           onFinish={async (value) => {
-            console.log({ '新增分摊参数': value, selectedParam,hasSetParamsList});
+            // console.log({ '新增分摊参数': value, selectedParam,hasSetParamsList});
             const { shareParamPopout } = value;
             const { id, shareParamCode, shareParamName } = selectedParam;
 
@@ -476,7 +612,7 @@ const DepartmentMana = () => {
             rules={[
               {
                 required: true,
-                message:'请选择责任中心',
+                message: '请选择责任中心',
               },
             ]}
 
@@ -487,7 +623,7 @@ const DepartmentMana = () => {
                 // console.log({currentResponsibilityRow});
                 const resp = await getParamsSelectableList({ id });
                 const { data, status } = resp;
-                console.log({resp});
+                // console.log({resp});
                 if (status == 200) {
                   const selected = data.list.filter(item => item.id == val);
                   console.log({ selected });
@@ -500,7 +636,7 @@ const DepartmentMana = () => {
               const { id } = currentResponsibilityRow;
               const resp = await getParamsSelectableList({ id });
               const { data, status } = resp;
-              console.log({ resp });
+              // console.log({ resp });
               if (status == 200) {
                 const temp = data.list.map(item => ({
                   label: item.shareParamName,
@@ -522,17 +658,23 @@ const DepartmentMana = () => {
         {/* 分摊更新 */}
         <UpdateFormDrawer
           onSubmit={async (value) => {
-               
-               const {id} = value;
-               const index = hasSetParamsList.findIndex(item=>item.id == id);
-               const temp = hasSetParamsList;
-               temp[index] = value;
-               console.log({value,temp});
-               setHasSetParamsList([].concat(temp));
-               setDrawerUpdateModalVisible(false);
-               if (actionDrawertableRef.current) {
-                actionDrawertableRef.current.reload();
-              }
+          
+            const {id,selectedParam} = value;
+            const index = hasSetParamsList.findIndex(item=>item.id == id);
+            let temp = hasSetParamsList;
+            temp[index] = value;
+            if(selectedParam){
+                //修改了分摊参数名
+                const {shareParamCode,shareParamName} = selectedParam;
+                temp[index] = {...temp[index],shareParamCode,shareParamName}
+                // console.log({shareParamCode,shareParamName,'temp[index]':temp[index]});
+            }
+            setHasSetParamsList([].concat(temp));
+            setDrawerUpdateModalVisible(false);
+            if (actionDrawertableRef.current) {
+             actionDrawertableRef.current.reload();
+           }
+              
           }}
           onCancel={() => {
             drawerUpdateModalVisible(false);
@@ -542,22 +684,95 @@ const DepartmentMana = () => {
           drawerUpdateModalVisible={drawerUpdateModalVisible}
           drawerUpdateModalVisibleChange={drawerUpdateModalVisibleChange}
           values={currentRow || {}}
-       
+
 
         />
       </DrawerForm>
 
 
+      {/* 选择复制抽屉 */}
+      {
+        drawerType != 0 && (
+          <DrawerContent
+            columns={drawerType == 1 ? responsibilityColumns : accountSubjectColumns}
+            visible={copySelectDrawerVisible}
+            currentRow={currentRow}
+            title={drawerType == 1 ? '选择复制目标' : '选择会计科目'}
+            defaultSelected={drawerType == 1?[]:selectedAccountSubjects}
+            pageContainerConfig={(tableRef) => {
+
+              return {
+                header: {
+                  title: ''
+                }
+              }
+            }}
+            onVisibleChange={(bool) => setCopySelectDrawerVisible(bool)}
+            renderListFunc={drawerType == 1 ? getCopyableTableList : getAccountingSubjects}
+            config={{ rowKeys: 'id', tableSearch: false }}
+            tableSearch={false}
+            expandable={{
+              expandedRowKeys:expandedRowKeys
+            }}
+            onFinishFunc={async (value, selectedRowKeys, selectedRows) => {
+              // console.log({ value, selectedRowKeys, selectedRows,drawerType });
+              if (drawerType == 1) {
+                const { id } = currentRow;
+                const resp = await copyParamsList({ id, responsibilityIds: selectedRowKeys });
+                const { status } = resp;
+                if (status == 200) {
+                  setCurrentRow(undefined);
+                  setCopySelectDrawerVisible(false);
+                  if (actionRef.current) {
+                    actionRef.current.reload();
+                  }
+                }
+              }
+
+              if (drawerType == 2) {
+                
+                //selectedRows为空标识没有编辑
+                let selectedItemNames = selectedRows.map(item => item.accountingName);
+
+                if(edit){
+                  if(selectedRows.length>0){
+                    if (updateFormRef.current) {
+                      updateFormRef.current.setFieldsValue({ accountingNames: selectedItemNames.join(','), accountingIds: selectedRowKeys.join(',') })
+                    }
+                  }
+                }
+                if(!edit){
+                  
+                    if (ref.current) {
+                      ref.current.setFieldsValue({ accountingName:selectedItemNames.join(','), accountingIds: selectedRowKeys.join(',') })
+                    }
+                
+                }
+                setCopySelectDrawerVisible(false);
+              }
+
+
+              setDrawerType(0);
+            }}
+          />
+        )
+      }
+
+
+
 
       {/* 更新 */}
       <UpdateForm
         onSubmit={async (value) => {
-          console.log({ '编辑': value });
-          const { responsibilityId, ifDisable, accountingId, costNode, id } = value;
+          // console.log({ '编辑': value });
+          // // return;
+          // console.log(updateFormRef.current.getFieldsValue(true));
+          const { accountingIds } = updateFormRef.current.getFieldsValue(true);
+          const { responsibilityId,responsibilityName,responsibilityCode,shareLevel,ifDisable, costNode,alias, id,isShareCost=1 } = value;
 
           const success = await editCostshareparamConnectList(ifDisable ? {
-            responsibilityId, costNode, id
-          } : { responsibilityId, accountingId, costNode, id });
+            responsibilityId, costNode, id,responsibilityName,responsibilityCode,shareLevel,isShareCost,alias
+          } : { responsibilityId,accountingIds, costNode, id,responsibilityName,responsibilityCode,shareLevel,isShareCost });
 
           if (success) {
             handleUpdateModalVisible(false);
@@ -567,6 +782,7 @@ const DepartmentMana = () => {
               actionRef.current.reload();
             }
           }
+          
         }}
         onCancel={() => {
           handleUpdateModalVisible(false);
@@ -575,8 +791,8 @@ const DepartmentMana = () => {
         updateModalVisible={updateModalVisible}
         updateModalVisibleChange={updateModalVisibleChange}
         values={currentRow || {}}
-        cascaderOptions={cascaderOptions}
-        cascaderChangeHandle={cascaderChangeHandle}
+        updateFormRef={updateFormRef}
+        selectAccountSubjecthandle={selectAccountSubjecthandle}
 
       />
     </PageContainer>

+ 138 - 0
src/pages/costAllocationParamsConnect/selectCopyDrawer.jsx

@@ -0,0 +1,138 @@
+
+
+
+
+import React,{useState,useEffect,useRef} from 'react'
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {Table } from 'antd';
+import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
+
+
+
+
+
+
+export default function DrawerContent(props) {
+
+    const { 
+        visible=false,
+        onVisibleChange=()=>{},
+        currentRow={},
+        renderListFunc=()=>{},
+        onFinishFunc=()=>{console.log('init onFinishFunc')},
+        columns=[],
+        defaultSelected=[],
+        config={},
+        title,
+        pageContainerConfig=()=>{},
+        expandable={}
+    } = props;
+    
+    const {rowKeys='id',tableSearch=false,} = config;
+    const drawerRef = useRef();
+    const [selectedKeys,setSelectedKeys] = useState([]);
+    const [defaultSelectedKeys,setDefaultSelectedKeys] = useState([]);
+    const [ifSearch,setIfSearch] = useState(false);
+    const drawerTableRef= useRef();
+    const [selectedRows,setSelectedRows] = useState([]);
+
+    const renderDefault = ()=>{
+        console.log('renderDefault ');
+        const defaultSelects = defaultSelected;
+        setDefaultSelectedKeys(defaultSelected);
+        setSelectedKeys(defaultSelects);
+    }
+
+
+    useEffect(()=>{
+        renderDefault();
+    },[defaultSelected])
+
+
+
+    return visible&&currentRow&&columns.length>0 ? (
+        <>
+            <DrawerForm
+                title={title}
+                visible={visible}
+                onVisibleChange={onVisibleChange}
+                formRef={drawerRef}
+                drawerProps={{
+                    forceRender: true,
+                    destroyOnClose: true,
+                }}
+                onFinish={async (values) => {
+                    //   console.log({onFinishFunc,values});
+                      onFinishFunc(values,defaultSelectedKeys,selectedRows);
+                }}
+            
+            >
+               <PageContainer
+                    {...pageContainerConfig(drawerTableRef)}
+               >
+                <ProTable
+                    columns={columns}
+                    rowKey={rowKeys}
+                    tableClassName="drawerContent"
+                    request={renderListFunc}
+                    search={tableSearch}
+                    actionRef={drawerTableRef}
+                    onSubmit={(u)=>{
+                        //  console.log({u});
+                        setIfSearch(true);
+                    }}
+                    onReset={()=>{setIfSearch(false);}}
+                    expandable={{...expandable}}
+                    rowSelection={{
+                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
+                        // 注释该行则默认不显示下拉选项
+                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
+                        checkStrictly:true,
+                        selectedRowKeys:selectedKeys,
+                        renderCell:(checked, record, index, originNode)=>{
+                               if(!record.children||record.children.length==0)return originNode
+                        },
+                        onChange:(selectedRowKeys, selectedRows)=>{
+                            console.log({selectedRowKeys,selectedRows});
+                            setSelectedRows(selectedRows);
+                            setSelectedKeys([].concat(selectedRowKeys));
+                        },
+                        onSelect:(record, selected, selectedRows, nativeEvent)=>{
+                            // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
+                            let _defaultSelectedKeys = defaultSelectedKeys.length>0?defaultSelectedKeys:[];
+                            let {children} = record;
+                            let arr=[];
+                            if(children&&children.length>0){
+                                arr = deepGetVal(children,rowKeys,'children');
+                            }
+                            arr.push(record[rowKeys]);
+
+                            if(!selected){
+                                arr.forEach(val=>{
+                                    const index =  defaultSelectedKeys.findIndex(item=>item == val);
+                                // console.log(index,record[rowKeys],defaultSelectedKeys)
+                                    if(index != -1){
+                                        _defaultSelectedKeys.splice(index,1);
+                                    }
+                                });
+                                _defaultSelectedKeys = unique(_defaultSelectedKeys);
+                                setDefaultSelectedKeys(_defaultSelectedKeys);
+
+                            }else{
+                                let tempArr = arr.length>0?_defaultSelectedKeys.concat(arr):_defaultSelectedKeys;
+                                // console.log({tempArr,_defaultSelectedKeys});
+                                tempArr = unique(tempArr);
+                                
+                                setDefaultSelectedKeys(tempArr);
+                            }
+
+                        }
+                    }}
+                />
+              </PageContainer>
+            </DrawerForm>
+        </>
+    ) : <></>
+}

+ 27 - 2
src/pages/costAllocationParamsConnect/service.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 08:54:08
- * @LastEditTime: 2021-07-30 18:45:42
+ * @LastEditTime: 2021-08-17 08:55:57
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/DepartmentMana/service.js
@@ -90,7 +90,6 @@ export async function getHasSetParamsList(params, options) {
 //获取添加分摊参数时可选列表
 export async function getParamsSelectableList(params, options) {
   const {id} = params;
-  console.log({params});
   return request(`/api/costAccount/costaccountshare/getAllShareParamStatusById`, {
     method: 'GET',
     params:{
@@ -101,6 +100,19 @@ export async function getParamsSelectableList(params, options) {
 
 }
 
+//获取可选复制目标列表
+export async function getCopyableToList(params, options) {
+  const {accountShareId} = params;
+  return request(`/api/costAccount/costaccountshare/getResponsibilityCalType`, {
+    method: 'GET',
+    params:{
+      accountShareId
+    },
+    ...(options || {}),
+  });
+
+}
+
 
 //保存成本分摊参数
 export async function saveParamsList(params, options) {
@@ -115,3 +127,16 @@ export async function saveParamsList(params, options) {
   });
 
 }
+
+
+//复制数据
+export async function copyParamsList(body, options) {
+  return request(`/api/costAccount/costaccountshare/copyAccountShareData`, {
+    method: 'POST',
+    data:body,
+    ...(options || {}),
+  });
+
+}
+
+

+ 58 - 23
src/pages/costAllocationParamsConnect/updateForm.jsx

@@ -1,9 +1,10 @@
-import React, { useState,useEffect} from 'react';
-import { Cascader,Form } from 'antd';
+import React, { useState, useEffect } from 'react';
+// import { Cascader, Form } from 'antd';
 import {
   ProFormSelect,
   ModalForm,
-  ProFormTextArea
+  ProFormTextArea,
+  ProFormText
 } from '@ant-design/pro-form';
 
 
@@ -13,22 +14,23 @@ import {
 
 
 const UpdateForm = (props) => {
-  const { cascaderOptions, cascaderChangeHandle, values: record ,updateModalVisible, updateModalVisibleChange,onSubmit} = props;
-  const { accountingId,responsibilityId } = record;
+
+  const { values: record, updateModalVisible, updateFormRef, updateModalVisibleChange, onSubmit, selectAccountSubjecthandle } = props;
+  const { accountingId, responsibilityId } = record;
 
   const [ifDisable, setIfDisable] = useState(false);
   const [selectedResponsibilityId, setSelectedResponsibilityId] = useState(null);
 
   // console.log({record});
-   
+
   useEffect(async () => {
     const resp = await getResponsibilityCenterSelecterList();
     const { data, msg, status } = resp;
     if (status == 200) {
-      const selected = data.filter(item =>{
-          return item.responsibilityId == responsibilityId
+      const selected = data.filter(item => {
+        return item.responsibilityId == responsibilityId
       });
-      if (selected&&selected.length>0&&selected[0].calcType == 0) {
+      if (selected && selected.length > 0 && selected[0].calcType == 0) {
         setIfDisable(true);
       } else {
         setIfDisable(false);
@@ -42,39 +44,41 @@ const UpdateForm = (props) => {
         JSON.stringify(record) !== '{}' && <ModalForm
           title="编辑成本分摊参数"
           width="800px"
-          initialValues={{ ...record,cascaderIds:[accountingId] }}
+          initialValues={{ ...record }}
           labelCol={{ span: 5, offset: 3 }}
           layout={'horizontal'}
+          formRef={updateFormRef}
           visible={updateModalVisible}
           onVisibleChange={(visible) => updateModalVisibleChange(visible)}
-          onFinish={(value) => onSubmit({ ...record, ...value,ifDisable })}
+          onFinish={(value) => onSubmit({ ...record, ...value, ifDisable })}
         >
           <ProFormSelect
             rules={[
               {
                 required: true,
-                message:'请选择责任中心',
+                message: '请选择责任中心',
               },
             ]}
             fieldProps={{//这里使用了select的onChange方法,必须使用这样的写法来进行调用onChange方法
               onChange: async (val) => {
                 setSelectedResponsibilityId(val);
                 const resp = await getResponsibilityCenterSelecterList();
-                const { data,status } = resp;
+                const { data, status } = resp;
+
                 if (status == 200) {
                   const selected = data.filter(item => item.id == val);
-       
-                  if (selected && selected[0].calcType == 0) {
-                    setIfDisable(true);
-                  } else {
+
+                  if (selected && selected[0].calcType == 1) {
                     setIfDisable(false);
+                  } else {
+                    setIfDisable(true);
                   }
                 }
               },
             }}
             request={async () => {
               const resp = await getResponsibilityCenterSelecterList();
-              const { data,status } = resp;
+              const { data, status } = resp;
               if (status == 200) {
                 return data.map(item => ({
                   label: item.responsibilityName,
@@ -86,12 +90,43 @@ const UpdateForm = (props) => {
             name="responsibilityId"
             label="请选择责任中心"
           />
-          <Form.Item name="cascaderIds" label="请选择成本科目" wrapperCol={{ offset:0, span:7 }} >
-                <Cascader disabled={ifDisable} options={cascaderOptions}    placeholder="请选择成本科目" onChange={cascaderChangeHandle} />
-
-          </Form.Item>
-  
+          <ProFormText
+            disabled={ifDisable}
+            rules={[
+              {
+                required: ifDisable ? false : true,
+                message: '请选择会计科目',
+              },
+            ]}
+            fieldProps={{
+              onClick: () => selectAccountSubjecthandle()
+            }}
+            width="sm"
+            name="accountingNames"
+            label="选择会计科目"
+          />
+          <ProFormSelect
+            disabled={ifDisable}
+            rules={[
+              {
+                required: ifDisable ? false : true,
+                message: '请选择',
+              },
+            ]}
+            width="sm"
+            request={async () => [
+              { label: '不包含分摊成本', value: 0 },
+              { label: '包含分摊成本', value: 1 }
+            ]}
+            name="isShareCost"
+            label="是否包含分摊成本"
+          />
 
+          <ProFormText
+            width="sm"
+            name="alias"
+            label="别名"
+          />
           <ProFormTextArea
             name="costNode"
             label="备注"

+ 3 - 4
src/pages/costAllocationParamsConnect/updateForm_drawer.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-30 18:09:25
- * @LastEditTime: 2021-08-03 17:12:06
+ * @LastEditTime: 2021-08-19 14:02:29
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/costAllocationParamsConnect/updateForm_drawer.js
@@ -35,14 +35,14 @@ const UpdateFormDrawer = (props) => {
     <>
       {JSON.stringify(record) !== '{}'&&record.shareParamPopout && (
         <ModalForm
-          title="编辑分摊参数"
+          title="编辑分摊参数"
           width="800px"
           initialValues={{ ...record }}
           labelCol={{ span: 5, offset: 3 }}
           layout={'horizontal'}
           visible={drawerUpdateModalVisible}
           onVisibleChange={(visible) => drawerUpdateModalVisibleChange(visible)}
-          onFinish={(value) => onSubmit({ ...record, ...value })}
+          onFinish={(value) =>{onSubmit({ ...record,shareParamPopout:value.shareParamPopout,selectedParam });setSelectedParam(null)}}
         >
           <ProFormSelect
             rules={[
@@ -60,7 +60,6 @@ const UpdateFormDrawer = (props) => {
                 const { data, status } = resp;
                 if (status == 200) {
                   const selected = data.list.filter((item) => item.id == val);
-                  console.log({ selected });
                   setSelectedParam(selected[0]);
                 }
               },

+ 83 - 108
src/pages/costAllocationParamsSetting/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-12 14:28:44
+ * @LastEditTime: 2021-08-20 15:30:20
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -13,10 +13,11 @@ import React, { useState, useRef } from 'react';
 
 import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
-import { ModalForm, ProFormText, ProFormSelect,DrawerForm,ProFormDigit} from '@ant-design/pro-form';
+import { ModalForm, ProFormText, ProFormSelect} from '@ant-design/pro-form';
 import UpdateForm from './updateForm';
+import DrawerContent from './selectCopyDrawer';
 
-
+import {deepGetAllParents} from '@/utils';
 import { getCostshareparamList, editCostshareparamList, delCostshareparam, addCostshareparam,updateCostShareParamByAccountId } from './service';
 import { getAccountingSubjectList} from '../accountingSubject/service';
 
@@ -86,13 +87,13 @@ const DepartmentMana = () => {
 
   const drawerTableColumns = [
     {
-      title: '成本科目编码',
+      title: '会计科目编码',
       dataIndex: 'accountingCode',
       key: 'accountingCode',
       hideInSearch: true,
     },
     {
-      title: '成本科目名称',
+      title: '会计科目名称',
       dataIndex: 'accountingName',
       key: 'accountingName',
       hideInSearch: false,
@@ -105,22 +106,17 @@ const DepartmentMana = () => {
   const ref = useRef();   //新增表单
   const [currentRow, setCurrentRow] = useState({});
   const [currentResponsibilityRow, setCurrentResponsibilityRow] = useState({});
-  
-  const drawerFormRef = useRef(); //DrawerForm
+  const [expandedRowKeys,setExpandedRowKeys] = useState([]);
+
   const actionDrawertableRef = useRef(); //Drawertable
-  const drawerModalRef = useRef(); //DrawerModal
+
   const [drawerVisible, setDrawerVisible] = useState(false);
-  const [drawerMadalVisible, setDrawerMadalVisible] = useState(false);
-  const [hasSetParamsList, setHasSetParamsList] = useState([]);
-  const [selectedParam, setSelectedParam] = useState(null);
-  const [newAddParamList, setNewAddParamList] = useState([]);
+
 
   const [accountType, setAccountType] = useState(1);
   const [selectedRowKeys,setSelectedRowKeys] = useState([]);
   
 
-  const [drawerUpdateModalVisible,setDrawerUpdateModalVisible] = useState(false);
-
   /**
    *
    * @param {Boolean} bool 弹窗展示状态
@@ -130,10 +126,7 @@ const DepartmentMana = () => {
     if (!bool) setCurrentRow(undefined);
   };
 
-  const drawerUpdateModalVisibleChange = (bool)=>{
-    setDrawerUpdateModalVisible(bool);
-    if (!bool) setCurrentRow(undefined);
-  }
+
 
   //获取科室列表
   const getList = async (params = {}, sort, filter) => {
@@ -168,21 +161,40 @@ const DepartmentMana = () => {
           }
       }
       setDrawerVisible(bool);
+
     }
-  
-    const handleDrawerModalVisible = (bool) => {
-      setDrawerMadalVisible(bool);
+
+    const getAccountingSubjects = async (params = {}, sort, filter)=>{
+      const {id} = currentResponsibilityRow;
+      const {accountingIds=[]} = currentRow;
+      const result = await getAccountingSubjectList({accountType,shareParamId:id});
+      const {status,data:{list}} = result;
+      if(status==200){
+        const allparents= deepGetAllParents(list,'children');
+        const allparentsIds = allparents.map(item=>item.id);
+        setExpandedRowKeys(allparentsIds);
+       
+        const temp = accountingIds.map(item=>Number(item));
+        setSelectedRowKeys(temp);
+        return {
+          data: list,
+          success: true
+        };
+      }
     }
+  
+
     
 
     /**
      * 
-     * @param {Number} key 
+     * @param {*} key  tab key
+     * @param {*} tableRef  dtawer table instance
      */
-    const onTabChange = (key)=>{
+    const onTabChange = (key,tableRef)=>{
       setAccountType(Number(key));
-      if (actionDrawertableRef.current) {
-        actionDrawertableRef.current.reload();
+      if (tableRef.current) {
+        tableRef.current.reload();
       }
     }
 
@@ -286,7 +298,51 @@ const DepartmentMana = () => {
 
 
       {/* 设置对应会计科目 */}
-      <DrawerForm
+
+      <DrawerContent
+            columns={drawerTableColumns}
+            visible={drawerVisible}
+            currentRow={currentRow}
+            title={'选择会计科目'}
+            defaultSelected={selectedRowKeys}
+            pageContainerConfig={(tableRef) => {
+              return {
+                header: {
+                  title: ''
+                },
+                tabList:[
+                  {
+                    tab: '收益',
+                    key: 1,
+                  },
+                  {
+                    tab: '支出',
+                    key: 2,
+                  },
+                ],
+                onTabChange:(key)=>onTabChange(key,tableRef)
+              }
+            }}
+            onVisibleChange={(bool) => drawerVisibleChange(bool)}
+            renderListFunc={getAccountingSubjects}
+            config={{ rowKeys: 'id', tableSearch: false }}
+            tableSearch={false}
+            expandable={{
+              expandedRowKeys:expandedRowKeys
+            }}
+            onFinishFunc={async (value, selectedRowKeys, selectedRows) => {
+              const {id} = currentResponsibilityRow;
+              const resp = await updateCostShareParamByAccountId({costShareParamId:id,accountIds:selectedRowKeys});
+              const {status} = resp;
+              setDrawerVisible(false);
+              if(status==200){
+                if (actionRef.current) {
+                  actionRef.current.reload();
+                }
+              }
+            }}
+          />
+      {/* <DrawerForm
         title="设置对应会计科目"
         formRef={drawerFormRef}
         visible={drawerVisible}
@@ -295,7 +351,6 @@ const DepartmentMana = () => {
         onFinish={async () => {
 
           const {id} = currentResponsibilityRow;
-          // console.log({selectedRowKeys,currentResponsibilityRow});
           const resp = await updateCostShareParamByAccountId({costShareParamId:id,accountIds:selectedRowKeys});
           const {status} = resp;
           setDrawerVisible(false);
@@ -369,89 +424,9 @@ const DepartmentMana = () => {
           }}
           search={false}
         />
-        <ModalForm
-          title="新增分摊参数"
-          width="800px"
-          labelCol={{ span: 5, offset: 3 }}
-          layout={'horizontal'}
-          visible={drawerMadalVisible}
-          formRef={drawerModalRef}
-          onVisibleChange={(bool) => {
-            if (ref.current) {
-              ref.current.resetFields();
-            }
-            handleDrawerModalVisible(bool);
-          }}
-
-          onFinish={async (value) => {
-            // console.log({ '新增分摊参数': value, selectedParam,hasSetParamsList});
-            const { shareParamPopout } = value;
-            const { id, shareParamCode, shareParamName } = selectedParam;
-
-            setHasSetParamsList(hasSetParamsList.concat([{
-              id, shareParamCode, shareParamName, shareParamPopout
-            }]));
-
-            setNewAddParamList(newAddParamList.concat([{
-              id, shareParamCode, shareParamName, shareParamPopout
-            }]));
-
-            setDrawerMadalVisible(false);
-
-            if (actionDrawertableRef.current) {
-              actionDrawertableRef.current.reload();
-            }
-          }}
-        >
-          <ProFormSelect
-            rules={[
-              {
-                required: true,
-                message:'请选择责任中心',
-              },
-            ]}
-
-            fieldProps={{//这里使用了select的onChange方法,必须使用这样的写法来进行调用onChange方法
-              onChange: async (val) => {
-                // setSelectedParam(val);
-                const { id } = currentResponsibilityRow;
-                // console.log({currentResponsibilityRow});
-                const resp = await getParamsSelectableList({ id });
-                const { data, status } = resp;
-                if (status == 200) {
-                  const selected = data.list.filter(item => item.id == val);
-                  console.log({ selected });
-                  setSelectedParam(selected[0]);
-                }
-              },
-            }}
-
-            request={async () => {
-              const { id } = currentResponsibilityRow;
-              const resp = await getParamsSelectableList({ id });
-              const { data, status } = resp;
-
-              if (status == 200) {
-                const temp = data.list.map(item => ({
-                  label: item.shareParamName,
-                  value: item.id
-                }));
-                return temp;
-              }
-
-            }}
-            width="sm"
-            name="id"
-            label="请选择分摊参数"
-          />
-
-          <ProFormDigit width={100} label="分摊比例" name="shareParamPopout" min={0} max={100} />
-
-        </ModalForm>
-
         </PageContainer>
         
-      </DrawerForm>
+      </DrawerForm> */}
 
 
       {/* 更新 */}

+ 138 - 0
src/pages/costAllocationParamsSetting/selectCopyDrawer.jsx

@@ -0,0 +1,138 @@
+
+
+
+
+import React,{useState,useEffect,useRef} from 'react'
+import { PageContainer } from '@ant-design/pro-layout';
+import ProTable from '@ant-design/pro-table';
+import {Table } from 'antd';
+import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
+
+
+
+
+
+
+export default function DrawerContent(props) {
+
+    const { 
+        visible=false,
+        onVisibleChange=()=>{},
+        currentRow={},
+        renderListFunc=()=>{},
+        onFinishFunc=()=>{console.log('init onFinishFunc')},
+        columns=[],
+        defaultSelected=[],
+        config={},
+        title,
+        pageContainerConfig=()=>{},
+        expandable={}
+    } = props;
+    
+    const {rowKeys='id',tableSearch=false,} = config;
+    const drawerRef = useRef();
+    const [selectedKeys,setSelectedKeys] = useState([]);
+    const [defaultSelectedKeys,setDefaultSelectedKeys] = useState([]);
+    const [ifSearch,setIfSearch] = useState(false);
+    const drawerTableRef= useRef();
+    const [selectedRows,setSelectedRows] = useState([]);
+
+    const renderDefault = ()=>{
+        // console.log('renderDefault ');
+        const defaultSelects = defaultSelected;
+        setDefaultSelectedKeys(defaultSelected);
+        setSelectedKeys(defaultSelects);
+    }
+
+
+    useEffect(()=>{
+        renderDefault();
+    },[defaultSelected])
+
+
+
+    return visible&&currentRow&&columns.length>0 ? (
+        <>
+            <DrawerForm
+                title={title}
+                visible={visible}
+                onVisibleChange={onVisibleChange}
+                formRef={drawerRef}
+                drawerProps={{
+                    forceRender: true,
+                    destroyOnClose: true,
+                }}
+                onFinish={async (values) => {
+                    //   console.log({onFinishFunc,values});
+                      onFinishFunc(values,defaultSelectedKeys,selectedRows);
+                }}
+            
+            >
+               <PageContainer
+                    {...pageContainerConfig(drawerTableRef)}
+               >
+                <ProTable
+                    columns={columns}
+                    rowKey={rowKeys}
+                    tableClassName="drawerContent"
+                    request={renderListFunc}
+                    search={tableSearch}
+                    actionRef={drawerTableRef}
+                    onSubmit={(u)=>{
+                        //  console.log({u});
+                        setIfSearch(true);
+                    }}
+                    onReset={()=>{setIfSearch(false);}}
+                    expandable={{...expandable}}
+                    rowSelection={{
+                        // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
+                        // 注释该行则默认不显示下拉选项
+                        selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
+                        checkStrictly:true,
+                        selectedRowKeys:selectedKeys,
+                        renderCell:(checked, record, index, originNode)=>{
+                               if(!record.children||record.children.length==0)return originNode
+                        },
+                        onChange:(selectedRowKeys, selectedRows)=>{
+                            console.log({selectedRowKeys,selectedRows});
+                            setSelectedRows(selectedRows);
+                            setSelectedKeys([].concat(selectedRowKeys));
+                        },
+                        onSelect:(record, selected, selectedRows, nativeEvent)=>{
+                            // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
+                            let _defaultSelectedKeys = defaultSelectedKeys.length>0?defaultSelectedKeys:[];
+                            let {children} = record;
+                            let arr=[];
+                            if(children&&children.length>0){
+                                arr = deepGetVal(children,rowKeys,'children');
+                            }
+                            arr.push(record[rowKeys]);
+
+                            if(!selected){
+                                arr.forEach(val=>{
+                                    const index =  defaultSelectedKeys.findIndex(item=>item == val);
+                                // console.log(index,record[rowKeys],defaultSelectedKeys)
+                                    if(index != -1){
+                                        _defaultSelectedKeys.splice(index,1);
+                                    }
+                                });
+                                _defaultSelectedKeys = unique(_defaultSelectedKeys);
+                                setDefaultSelectedKeys(_defaultSelectedKeys);
+
+                            }else{
+                                let tempArr = arr.length>0?_defaultSelectedKeys.concat(arr):_defaultSelectedKeys;
+                                // console.log({tempArr,_defaultSelectedKeys});
+                                tempArr = unique(tempArr);
+                                
+                                setDefaultSelectedKeys(tempArr);
+                            }
+
+                        }
+                    }}
+                />
+              </PageContainer>
+            </DrawerForm>
+        </>
+    ) : <></>
+}

+ 1 - 1
src/pages/costProjectMana/index.jsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-11 16:07:08
+ * @LastEditTime: 2021-08-16 20:33:16
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js

+ 5 - 4
src/pages/platformMana/menuManage/index.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-06 17:37:47
+ * @LastEditTime: 2021-08-23 11:17:44
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -96,7 +96,7 @@ const UserMana = () => {
   const [createModalVisible, handleModalVisible] = useState(false);
   const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const actionRef = useRef();
-  const [currentRow, setCurrentRow] = useState({});
+  const [currentRow, setCurrentRow] = useState(undefined);
   const [ifAddZeroLevelMenu, setIfAddZeroLevelMenu] = useState(true);
 
   // const [shareParamsSetting,setShareParamsSetting] = useState(false);  //是否分摊参数设置
@@ -174,6 +174,7 @@ const UserMana = () => {
         
           let id=0;
           currentRow&&(id=currentRow.menuId);
+          console.log({id});
           const resp = await addList({ ...value, parentId:id });
           const { status } = resp;
           if (status == 200) {
@@ -238,7 +239,7 @@ const UserMana = () => {
           placeholder="请选择类型"
           rules={[{ required: true, message: '请选择类型!' }]}
         />
-        {/* <ProFormText
+        <ProFormText
           label="菜单Icon"
           rules={[
             {
@@ -247,7 +248,7 @@ const UserMana = () => {
           ]}
           width="sm"
           name="icon"
-        /> */}
+        />
         <ProFormDigit
           label="菜单排序"
           rules={[

+ 2 - 2
src/pages/platformMana/menuManage/updateForm.jsx

@@ -73,7 +73,7 @@ const UpdateForm = (props) => {
             placeholder="请选择类型"
             rules={[{ required: true, message: '请选择类型!' }]}
           />
-          {/* <ProFormText
+          <ProFormText
             label="菜单Icon"
             rules={[
               {
@@ -82,7 +82,7 @@ const UpdateForm = (props) => {
             ]}
             width="sm"
             name="icon"
-          /> */}
+          />
           <ProFormDigit
             label="菜单排序"
             rules={[

+ 23 - 10
src/pages/platformMana/roleManage/component/drawer.jsx

@@ -1,10 +1,11 @@
 
 
 import React,{useState,useEffect,useRef} from 'react'
-import { PageContainer } from '@ant-design/pro-layout';
+// import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
 import {Table } from 'antd';
 import { DrawerForm } from '@ant-design/pro-form';
+import {deepGetVal,unique} from '@/utils';
 
 
 
@@ -81,22 +82,34 @@ export default function DrawerContent(props) {
                         checkStrictly:false,
                         selectedRowKeys:selectedKeys,
                         onChange:(selectedRowKeys, selectedRows)=>{
+                            // console.log({selectedRowKeys,selectedRows});
                             setSelectedKeys(selectedRowKeys);
                         },
                         onSelect:(record, selected, selectedRows, nativeEvent)=>{
                             // console.log({record, selected, selectedRows, nativeEvent,ifSearch});
-                            const _defaultSelectedKeys = defaultSelectedKeys;
+                            let _defaultSelectedKeys = defaultSelectedKeys;
+                            let {children} = record;
+                            let arr=[]
+                            if(children&&children.length>0){
+                               arr = deepGetVal(children,rowKeys,'children');
+                            }
+                            arr.push(record[rowKeys]);
+
                             if(!selected){
-                                const index =  defaultSelectedKeys.findIndex(item=>item == record[rowKeys]);
+                                arr.forEach(val=>{
+                                    const index =  defaultSelectedKeys.findIndex(item=>item == val);
                                 // console.log(index,record[rowKeys],defaultSelectedKeys)
-                                if(index != -1){
-                        
-                                     _defaultSelectedKeys.splice(index,1);
-                                     setDefaultSelectedKeys(_defaultSelectedKeys);
-                                }
-                            }else{
-                                _defaultSelectedKeys.push(record[rowKeys]);
+                                    if(index != -1){
+                                        _defaultSelectedKeys.splice(index,1);
+                                    }
+                                });
+                                _defaultSelectedKeys = unique(_defaultSelectedKeys);
                                 setDefaultSelectedKeys(_defaultSelectedKeys);
+
+                            }else{
+                                let tempArr = _defaultSelectedKeys.concat(arr);
+                                tempArr = unique(tempArr);
+                                setDefaultSelectedKeys([].concat(tempArr));
                             }
 
                         }

+ 2 - 1
src/pages/platformMana/roleManage/index.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 10:16:27
+ * @LastEditTime: 2021-08-13 18:30:28
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
@@ -376,6 +376,7 @@ const UserMana = () => {
           tableSearch={false}
           onFinishFunc={async (value, selectedRowKeys) => {
             // console.log({value,selectedRowKeys});
+            // return ;
             const { roleId } = currentRow;
             const resp = await roleBindMenu({ roleId, menuIds: selectedRowKeys });
             const { status } = resp;

+ 162 - 139
src/pages/responsibilityCenter/index.jsx

@@ -1,19 +1,19 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 10:13:13
- * @LastEditTime: 2021-08-13 14:31:32
+ * @LastEditTime: 2021-08-19 16:53:22
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/pages/UserMana/index.js
  */
 
 import { PlusOutlined } from '@ant-design/icons';
-import { Button, Popconfirm} from 'antd';
+import { Button, Popconfirm, Tag } from 'antd';
 import React, { useState, useRef } from 'react';
 
 import { PageContainer } from '@ant-design/pro-layout';
 import ProTable from '@ant-design/pro-table';
-import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form';
+import { ModalForm, ProFormText, ProFormSelect, ProFormDependency } from '@ant-design/pro-form';
 import UpdateForm from './updateForm';
 // import CAUpload from '@/components/CAUpload';
 import { getResponsibilityCenterList, editResponsibilityCenterList, delResponsibilityCenter, addResponsibilityCenter } from './service';
@@ -28,7 +28,11 @@ const responsibilityCenter = () => {
       dataIndex: 'responsibilityName',
       key: 'responsibilityName',
       hideInSearch: false,
-      width: '15%'
+      width: '15%',
+      render: (_, record) => {
+        const { isDefault, responsibilityName } = record;
+        return isDefault == 1 ? <Tag>{`${responsibilityName}(是)`}</Tag> : responsibilityName
+      }
     },
     {
       title: '责任中心编码',
@@ -67,31 +71,45 @@ const responsibilityCenter = () => {
       width: '15%'
     },
     {
-      title:'操作',
+      title: '操作',
       dataIndex: 'option',
       valueType: 'option',
       width: '15%',
-      render: (_, record) => [
-        <a
-          key="config"
+      render: (_, record) => {
+        const { isGatherCenter } = record;
+        const btnGroup = [
+          <a
+            key="config"
+            onClick={() => {
+              handleUpdateModalVisible(true);
+              setCurrentRow(record);
+            }}
+          >
+            编辑
+          </a>,
+          <Popconfirm
+            key="subscribeAlert"
+            title="是否确定删除?"
+            onConfirm={() => {
+              setCurrentRow(record);
+              delListHandler(record);
+            }}
+          >
+            <a>删除</a>
+          </Popconfirm>,
+        ];
+
+        return isGatherCenter == 1 ? [<a
+          key="addChild"
           onClick={() => {
-            handleUpdateModalVisible(true);
+            setIfAddChild(true);
             setCurrentRow(record);
+            handleModalVisible(true);
           }}
         >
-          编辑
-        </a>,
-        <Popconfirm
-          key="subscribeAlert"
-          title="是否确定删除?"
-          onConfirm={() => {
-            setCurrentRow(record);
-            delListHandler(record);
-          }}
-        >
-          <a>删除</a>
-        </Popconfirm>,
-      ],
+          添加
+        </a>, ...btnGroup] : [...btnGroup]
+      }
     },
   ];
 
@@ -99,9 +117,10 @@ const responsibilityCenter = () => {
   const [updateModalVisible, handleUpdateModalVisible] = useState(false);
   const actionRef = useRef();  //表格
   const ref = useRef();   //新增表单
-  const [currentRow, setCurrentRow] = useState({});
-  const [selectedLevelList,setSelectedLevelList] = useState(null); //可选的分摊层级列表
-  const [selectedLevel,setSelectedLevel] = useState(null);
+  const [currentRow, setCurrentRow] = useState(undefined);
+  const [selectedLevelList, setSelectedLevelList] = useState(null); //可选的分摊层级列表
+  const [selectedLevel, setSelectedLevel] = useState(null);
+  const [ifAddChild, setIfAddChild] = useState(false);
 
   /**
    *
@@ -130,30 +149,14 @@ const responsibilityCenter = () => {
    */
   const delListHandler = async (value) => {
     const resp = await delResponsibilityCenter(value);
-    if(resp.status==200){
+    if (resp.status == 200) {
       if (actionRef.current) {
         actionRef.current.reload();
       }
     }
   };
 
-  //展开table
-  const expandedRowRender = (record, index, indent, expanded) => {
-    // console.log({ record, index, indent, expanded });
-    const _columns = columns.filter(item => !(['id'].includes(item.key)));
-    return (
-      <ProTable
-        columns={[..._columns]}
-        headerTitle={false}
-        showHeader={false}
-        search={false}
-        options={false}
-        rowKey="id"
-        dataSource={record.child}
-        pagination={false}
-      />
-    );
-  };
+
 
   return (
     <PageContainer>
@@ -163,7 +166,7 @@ const responsibilityCenter = () => {
         actionRef={actionRef}
         rowKey="id"
         childrenColumnName="child"
-        expandable={{defaultExpandedRowKeys:[]}}
+        expandable={{ defaultExpandedRowKeys: [] }}
         toolBarRender={() => [
           <Button
             key="button"
@@ -190,8 +193,9 @@ const responsibilityCenter = () => {
         width="800px"
         labelCol={{ span: 5, offset: 3 }}
         layout={'horizontal'}
+        initialValues={{ isDefault: 0 }}
         visible={createModalVisible}
-        onVisibleChange={(bool)=>{
+        onVisibleChange={(bool) => {
           if (ref.current) {
             ref.current.resetFields();
           }
@@ -200,8 +204,11 @@ const responsibilityCenter = () => {
         formRef={ref}
         onFinish={async (value) => {
           // console.log({'新增':value,selectedLevel})
-    
-          const body = {...value,shareName:selectedLevel.shareName,shareId:selectedLevel.id};
+          let id = 0;
+          currentRow && (id = currentRow.id);
+          const { isDefault = 0 } = value;
+          const body = { ...value, shareName: selectedLevel?selectedLevel.shareName:'', shareId: selectedLevel?selectedLevel.id:0, isDefault, id };
+          console.log({body});
           const success = await addResponsibilityCenter(body);
           if (success) {
             handleModalVisible(false);
@@ -210,86 +217,90 @@ const responsibilityCenter = () => {
               actionRef.current.reload();
             }
           }
+          setCurrentRow(undefined);
         }}
       >
-
         <ProFormSelect
-          name="id"
-          label="责任管理中心"
-          showSearch
-          request={async ({ keyWords }) => {
-            const res = await getResponsibilityCenterList();
-            if(res.status == 200){
-              // console.log({res});
-                 const filter_arr = res.data.list.filter(item=>{
-                  //  console.log({item});
-                   if(keyWords){
-                    return item.responsibilityName.indexOf(keyWords) != -1
-                   }else {
-                    return item
-                   }
-                   
-                 });
-                 const arr = filter_arr.map(item=>({label:item.responsibilityName, value:item.id}));
-                 return arr;
-            }else {
-                 return [];
-            }
-
-          }}
-          width='md'
-          placeholder="选择需要新增在哪个责任中心下,默认新增最外层"
-          rules={[{ required: false, message: '' }]}
-        />
-
-        <ProFormText
-          label="责任中心名"
           rules={[
             {
               required: true,
-              message:'医院名是必填项',
+              message: '请选择是否为汇总中心',
+            },
+          ]}
+          options={[
+            {
+              value: 1,
+              label: '是',
+            },
+            {
+              value: 2,
+              label: '否',
             },
           ]}
           width="sm"
-          name="responsibilityName"
+          name="isGatherCenter"
+          label="是否汇总中心"
         />
+
         <ProFormText
-          label="责任中心编码"
+          label="责任中心名"
           rules={[
             {
               required: true,
-              message:'责任中心编码是必填项',
+              message: '医院名是必填项',
             },
           ]}
           width="sm"
-          name="responsibilityCode"
+          name="responsibilityName"
         />
-        <ProFormSelect
+        <ProFormText
+          label="责任中心编码"
           rules={[
             {
               required: true,
-              message:'请选择是否为汇总中心',
-            },
-          ]}
-          options={[
-            {
-              value: 1,
-              label: '是',
-            },
-            {
-              value: 2,
-              label: '否',
+              message: '责任中心编码是必填项',
             },
           ]}
           width="sm"
-          name="isGatherCenter"
-          label="是否汇总中心"
+          name="responsibilityCode"
         />
+        <ProFormDependency name={['isGatherCenter']}>
+          {
+            ({ isGatherCenter }) => {
+              return isGatherCenter == 2 ? (
+                <ProFormSelect
+                  rules={[
+                    {
+                      required: true,
+                      message: '请选择是否默认责任中心',
+                    },
+                  ]}
+                  options={[
+                    {
+                      value: 1,
+                      label: '是',
+                    },
+                    {
+                      value: 0,
+                      label: '否',
+                    },
+                  ]}
+                  width="sm"
+                  name="isDefault"
+                  label="是否默认责任中心"
+                />
+              ) : (
+                <></>
+              )
+
+            }
+          }
+        </ProFormDependency>
         <ProFormSelect
           rules={[
             {
               required: true,
-              message:'请选择责任类型',
+              message: '请选择责任类型',
             },
           ]}
           options={[
@@ -306,54 +317,66 @@ const responsibilityCenter = () => {
           name="responsibilityType"
           label="选择责任类型"
         />
-        <ProFormSelect
-          rules={[
-            {
-              required: true,
-              message:'请选择分摊级别',
-            },
-          ]}
-          fieldProps={{
-            onChange: async (val) => {
-              const resp = await getApportionmentLevelListNoPage();
-              const {status,data} = resp;
-              if(status==200){
-                const needItem = data.list.filter(item=>item.leverSort == val);
-                setSelectedLevel(needItem[0]);
-              }
-            },
-          }}
-          request={ async ()=>{
-                const resp = await getApportionmentLevelListNoPage();
-                const {status,data} = resp;
-                if(status==200){
-                    setSelectedLevelList(data.list);
-                    return data.list.map(item=>({label:`级别${item.leverSort}-${item.shareName}`,value:item.leverSort}))
-                }else{
-                   return []
-                }
-          }}
-          width="sm"
-          name='shareLevel'
-          label="选择分摊级别"
-        />
+        <ProFormDependency name={['isGatherCenter']}>
+          {
+            ({ isGatherCenter }) => {
+              return isGatherCenter != 1 && (
+                <ProFormSelect
+                  rules={[
+                    {
+                      required: true,
+                      message: '请选择分摊级别',
+                    },
+                  ]}
+                  fieldProps={{
+                    onChange: async (val) => {
+                      const resp = await getApportionmentLevelListNoPage();
+                      const { status, data } = resp;
+                      if (status == 200) {
+                        const needItem = data.list.filter(item => item.leverSort == val);
+                        setSelectedLevel(needItem[0]);
+                      }
+                    },
+                  }}
+                  request={async () => {
+                    const resp = await getApportionmentLevelListNoPage();
+                    const { status, data } = resp;
+                    if (status == 200) {
+                      setSelectedLevelList(data.list);
+                      return data.list.map(item => ({ label: `级别${item.leverSort}-${item.shareName}`, value: item.leverSort }))
+                    } else {
+                      return []
+                    }
+                  }}
+                  width="sm"
+                  name='shareLevel'
+                  label="选择分摊级别"
+                />
+              )
+            }
+          }
+        </ProFormDependency>
       </ModalForm>
 
       {/* 更新 */}
       <UpdateForm
         onSubmit={async (value) => {
-          console.log({ '编辑': value });
-         
-          const {responsibilityLevel,selectedLevel} = value;
-          const body = selectedLevel.length==0?{
+          // console.log({ '编辑': value });
+
+          const { responsibilityLevel=0, selectedLevel,shareId } = value;
+          // console.log({responsibilityLevel, selectedLevel});
+          let body = {};
+          if(selectedLevel.length==0){
             //没有修改分摊层级
-            ...value,shareLevelId:responsibilityLevel
-          }:{
-                  //修改了分摊层级
-                  ...value,shareLevelId:selectedLevel[0].id
+            body={...value, shareLevelId: shareId}
+          }
+
+          if(Object.prototype.toString.call(selectedLevel)=='[object Object]'){
+             //修改了分摊层级
+            //  console.log('修改了分摊层级');
+             body={...value, shareLevelId: selectedLevel.id,shareName:selectedLevel.shareName}
           }
-          // console.log({'editBody':body});
-          // return;
+      
           const success = await editResponsibilityCenterList(body);
 
           if (success) {

+ 85 - 71
src/pages/responsibilityCenter/updateForm.jsx

@@ -2,7 +2,8 @@ import React, { useState, useEffect } from 'react';
 import {
   ProFormSelect,
   ProFormText,
-  ModalForm
+  ModalForm,
+  ProFormDependency
 } from '@ant-design/pro-form';
 
 
@@ -34,53 +35,12 @@ const UpdateForm = (props) => {
           onVisibleChange={(visible) => updateModalVisibleChange(visible)}
           onFinish={(value) => onSubmit({ ...values, ...value, selectedLevel })}
         >
-          {
-            parentId != 0 &&<ProFormSelect
-              name="parentId"
-              label="责任管理中心"
-              showSearch
-              request={async ({ keyWords }) => {
-                const res = await getResponsibilityCenterList();
-                if (res.status == 200) {
-                  // console.log({res});
-                  const filter_arr = res.data.list.filter(item => {
-                    //  console.log({item});
-                    if (keyWords) {
-                      return item.responsibilityName.indexOf(keyWords) != -1
-                    } else {
-                      return item
-                    }
-
-                  });
-                  const arr = filter_arr.map(item => ({ label: item.responsibilityName, value: item.id }));
-                  return arr;
-                } else {
-                  return [];
-                }
-
-              }}
-              width='md'
-              placeholder="选择需要新增在哪个责任中心下,默认新增最外层"
-              rules={[{ required: false, message: '' }]}
-            />
-          }
 
-          <ProFormText
-            label="责任中心名"
-            rules={[
-              {
-                required: true,
-                message:'医院名是必填项',
-              },
-            ]}
-            width="sm"
-            name="responsibilityName"
-          />
           <ProFormSelect
             rules={[
               {
                 required: true,
-                message:'请选择是否为汇总中心',
+                message: '请选择是否为汇总中心',
               },
             ]}
             options={[
@@ -97,11 +57,22 @@ const UpdateForm = (props) => {
             name="isGatherCenter"
             label="是否汇总中心"
           />
+          <ProFormText
+            label="责任中心名"
+            rules={[
+              {
+                required: true,
+                message: '医院名是必填项',
+              },
+            ]}
+            width="sm"
+            name="responsibilityName"
+          />
           <ProFormSelect
             rules={[
               {
                 required: true,
-                message:'请选择责任类型',
+                message: '请选择责任类型',
               },
             ]}
             options={[
@@ -118,35 +89,78 @@ const UpdateForm = (props) => {
             name="responsibilityType"
             label="选择责任类型"
           />
-          <ProFormSelect
-            rules={[
-              {
-                required: true,
-                message:'请选择分摊级别',
-              },
-            ]}
-            fieldProps={{
-              onChange: async (val) => {
+          <ProFormDependency name={['isGatherCenter']}>
+            {
+              ({ isGatherCenter }) => {
+                return isGatherCenter == 2 ? (
+                  <ProFormSelect
+                    rules={[
+                      {
+                        required: true,
+                        message: '请选择是否默认责任中心',
+                      },
+                    ]}
+                    options={[
+                      {
+                        value: 1,
+                        label: '是',
+                      },
+                      {
+                        value: 0,
+                        label: '否',
+                      },
+                    ]}
+                    width="sm"
+                    name="isDefault"
+                    label="是否默认责任中心"
+                  />
+                ) : (
+                  <></>
+                )
 
-                const needItem = selectedLevelList.filter(item => item.leverSort == val);
-                setSelectedLevel(needItem);
-              },
-            }}
-
-            request={async () => {
-              const resp = await getApportionmentLevelListNoPage();
-              const { status, data } = resp;
-              if (status == 200) {
-                setSelectedLevelList(data.list);
-                return data.list.map(item => ({ label: `级别${item.leverSort}-${item.shareName}`, value: item.leverSort }))
-              } else {
-                return []
               }
-            }}
-            width="sm"
-            name='shareLevel'
-            label="选择分摊级别"
-          />
+            }
+          </ProFormDependency>
+          <ProFormDependency name={['isGatherCenter']}>
+          {
+            ({ isGatherCenter }) => {
+              return isGatherCenter != 1 && (
+                <ProFormSelect
+                  rules={[
+                    {
+                      required: true,
+                      message: '请选择分摊级别',
+                    },
+                  ]}
+                  fieldProps={{
+                    onChange: async (val) => {
+                      const resp = await getApportionmentLevelListNoPage();
+                      const { status, data } = resp;
+                      if (status == 200) {
+                        const needItem = data.list.filter(item => item.leverSort == val);
+                        setSelectedLevel(needItem[0]);
+                      }
+                    },
+                  }}
+                  request={async () => {
+                    const resp = await getApportionmentLevelListNoPage();
+                    const { status, data } = resp;
+                    if (status == 200) {
+                      setSelectedLevelList(data.list);
+                      return data.list.map(item => ({ label: `级别${item.leverSort}-${item.shareName}`, value: item.leverSort }))
+                    } else {
+                      return []
+                    }
+                  }}
+                  width="sm"
+                  name='shareLevel'
+                  label="选择分摊级别"
+                />
+              )
+            }
+          }
+        </ProFormDependency>
+          
         </ModalForm>
       }
     </>

+ 18 - 37
src/pages/user/Login/index.jsx

@@ -28,38 +28,15 @@ const LoginMessage = ({ content }) => (
 
 
 
-//将服务端获取的菜单 icon 字符串映射为对应的 icon Dom
-const mappingIcon = menuData => {
-  // const mappingMenu = menuData.map(item => ({
-  //   ...item,
-  //   icon: iconEnum[item.icon],
-  //   children: item.children ? mappingIcon(item.children) : [],
-  // }));
-  return menuData;
-};
-
-
-const getMenuData = async ()=>{
-    
-      const menu = await getMenus();
-      const {data} = menu;
-      const menus = mappingIcon(data);
-      return menus;
-}
-
 const Login = () => {
   const [submitting, setSubmitting] = useState(false);
   const [userLoginState, setUserLoginState] = useState({});
   const [type, setType] = useState('account');
-  const [subHospList, setSubHospList] = useState([]);
+  // const [subHospList, setSubHospList] = useState([]);
   const { query = {} } = history.location;
   const { redirect,hospSign } = query;
   const { initialState, setInitialState } = useModel('@@initialState');
 
-
-
-  const { fetchSubHosp,sign } = initialState;
-
   const handleSubmit = async (values) => {
     setSubmitting(true);
 
@@ -81,18 +58,22 @@ const Login = () => {
         localStorage.setItem('loginParams',JSON.stringify({hospSign:hospSign}));
         localStorage.setItem('userData',JSON.stringify({...data,avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',}));
 
-        message.success(defaultloginSuccessMessage);
+        
         // await setInitialState((s) => ({ ...s, currentUser:data }));
         /** 此方法会跳转到 redirect 参数所在的位置 */
 
-        // const menus = await getMenuData();
+       
         await setInitialState((s) => ({ ...s, currentUser:data}));
-        // localStorage.setItem('menus',JSON.stringify(menus));
-      
+     
+        message.success(defaultloginSuccessMessage);
 
         if (!history) return;
         const { query } = history.location;
         const { redirect } = query;
+  
+        // const resp = await getMenus();
+        // const {data:menu} = resp;
+        // await setInitialState((s) => ({ ...s,menu:menu}));
         history.push(redirect || '/');
         return;
       }else {
@@ -115,15 +96,15 @@ const Login = () => {
 
   useEffect(() => {
 
-    fetchSubHosp().then(res => {
-      if (res&&res.success) {
-        const temp = res.map(item => ({
-          'value': item.id,
-          'label': item.name
-        }))
-        setSubHospList(temp);
-      }
-    })
+    // fetchSubHosp().then(res => {
+    //   if (res&&res.success) {
+    //     const temp = res.map(item => ({
+    //       'value': item.id,
+    //       'label': item.name
+    //     }))
+    //     setSubHospList(temp);
+    //   }
+    // })
   }, []);
 
 

+ 56 - 2
src/utils.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-07-26 13:50:44
- * @LastEditTime: 2021-08-10 15:24:28
+ * @LastEditTime: 2021-08-19 14:34:13
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: /TracerMethodology_PC/src/utils.js
@@ -45,7 +45,61 @@ const CARequest = (url)=>{
       
 }
 
+//递归获取所有层级某一属性
+const deepGetVal = (dataToDeep,key,subArr)=>{
+    // console.log({dataToDeep,key,subArr});
+    let resultArr = [];
+
+    dataToDeep.forEach(item=>{
+        if(item[subArr]&&item[subArr].length>0){
+            deepGetVal(item[subArr],key,subArr);
+        }else {
+            resultArr.push(item[key]);
+        }
+    });
+
+    return resultArr
+}
+
+//递归获取所有有树子集的节点
+const deepGetAllParents = (dataToDeep,subArr)=>{
+    let resultArr = [];
+
+    function looper(dataToDeep,subArr){
+        dataToDeep.forEach(item=>{
+            if(item[subArr]&&item[subArr].length>0){
+                resultArr.push(item);
+                // console.log({resultArr});
+                looper(item[subArr],subArr);
+            }
+        });
+    };
+
+    looper(dataToDeep,subArr);
+
+    return resultArr
+    
+}
+
+//数组去重
+function unique(arr) {
+    if (!Array.isArray(arr)) {
+        console.log('type error!')
+        return
+    }
+    var array = [];
+    for (var i = 0; i < arr.length; i++) {
+        if (array .indexOf(arr[i]) === -1) {
+            array .push(arr[i])
+        }
+    }
+    return array;
+}
+
 export  {
     getQueryString,
-    CARequest
+    CARequest,
+    deepGetVal,
+    deepGetAllParents,
+    unique
 }