|
@@ -1,14 +1,14 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-07-26 10:13:13
|
|
|
- * @LastEditTime: 2021-08-12 15:12:35
|
|
|
+ * @LastEditTime: 2021-08-12 21:09:11
|
|
|
* @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, Button, Drawer,Table} from 'antd';
|
|
|
+import { Cascader, Form, Button, Drawer, Table } from 'antd';
|
|
|
import React, { useRef, useState, useEffect } from 'react';
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
import ProTable from '@ant-design/pro-table';
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
ProFormDatePicker,
|
|
|
ProFormSelect,
|
|
|
} from '@ant-design/pro-form';
|
|
|
-import { getAfterIncomeCollectionList } from './service';
|
|
|
+import { getAfterIncomeCollectionList, getAfterIncomeCollectionTableData } from './service';
|
|
|
import { getResponsibilityCenterList } from '@/pages/responsibilityCenter/service';
|
|
|
import { getCostProjecttList } from '@/pages/costProjectMana/service';
|
|
|
import moment from 'moment';
|
|
@@ -28,14 +28,17 @@ const AfterCollectionSearch = () => {
|
|
|
|
|
|
const [currentTime, setCurrentTime] = useState(moment().format('YYYY-MM'));
|
|
|
const [selectableResponsibilityList, setSelectableResponsibilityList] = useState([]);
|
|
|
+ const [selectedResponsibilityCode,setSelectedResponsibilityCode] = useState(null);
|
|
|
+ const [selectedAccountingCode,setSelectedAccountingCode] = useState(null)
|
|
|
+
|
|
|
// const [selectableCostProjectList, setSelectableCostProjectList] = useState([])
|
|
|
|
|
|
const columns = [
|
|
|
{
|
|
|
title: '选择时间',
|
|
|
- key: 'dateTime',
|
|
|
+ key: 'date',
|
|
|
hideInTable: true,
|
|
|
- dataIndex: 'dateTime',
|
|
|
+ dataIndex: 'date',
|
|
|
renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
|
|
|
|
|
|
if (type === 'form') {
|
|
@@ -43,7 +46,7 @@ const AfterCollectionSearch = () => {
|
|
|
}
|
|
|
return (
|
|
|
<Form.Item >
|
|
|
- <ProFormDatePicker initialValue={currentTime} fieldProps={{ picker: 'month', format: (value) => { return value.format('YYYYMM') }, locale: locale }} name="dateTime" />
|
|
|
+ <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>
|
|
|
)
|
|
|
},
|
|
@@ -68,8 +71,9 @@ const AfterCollectionSearch = () => {
|
|
|
fieldNames={{
|
|
|
label: 'responsibilityName',
|
|
|
value: 'responsibilityCode',
|
|
|
- children: 'child'
|
|
|
+ children: 'child',
|
|
|
}}
|
|
|
+ onChange={(val)=>{setSelectedResponsibilityCode(val[0])}}
|
|
|
{...fieldProps}
|
|
|
/>
|
|
|
</Form.Item>
|
|
@@ -78,9 +82,9 @@ const AfterCollectionSearch = () => {
|
|
|
},
|
|
|
{
|
|
|
title: '成本项目',
|
|
|
- key: 'accountCode',
|
|
|
+ key: 'accountingCode',
|
|
|
hideInTable: true,
|
|
|
- dataIndex: 'accountCode',
|
|
|
+ dataIndex: 'accountingCode',
|
|
|
renderFormItem: (item, { type, defaultRender, formItemProps, fieldProps, ...rest }, form) => {
|
|
|
// console.log({item,type, defaultRender,formItemProps, fieldProps,rest,form })
|
|
|
if (type === 'form') {
|
|
@@ -88,7 +92,7 @@ const AfterCollectionSearch = () => {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <Form.Item name="accountCode">
|
|
|
+ <Form.Item name="accountingCode">
|
|
|
<ProFormSelect
|
|
|
request={async () => {
|
|
|
const resp = await getCostProjecttList({ pageSize: 100 });
|
|
@@ -103,8 +107,11 @@ const AfterCollectionSearch = () => {
|
|
|
return arr;
|
|
|
}
|
|
|
}}
|
|
|
+ fieldProps={{
|
|
|
+ onChange:(value)=>{setSelectedAccountingCode(value)}
|
|
|
+ }}
|
|
|
width="md"
|
|
|
- name="accountCode"
|
|
|
+ name="accountingCode"
|
|
|
/>
|
|
|
</Form.Item>
|
|
|
)
|
|
@@ -179,99 +186,19 @@ const AfterCollectionSearch = () => {
|
|
|
];
|
|
|
|
|
|
|
|
|
- const drawerTableColumns = [
|
|
|
- {
|
|
|
- title: '年份',
|
|
|
- dataIndex: 'year',
|
|
|
- key: 'year',
|
|
|
- hideInSearch: true,
|
|
|
- width:500,
|
|
|
- fixed: 'left',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '月份',
|
|
|
- dataIndex: 'month',
|
|
|
- key: 'month',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '科室编码',
|
|
|
- dataIndex: 'departmentCode',
|
|
|
- key: 'departmentCode',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '科室名称',
|
|
|
- dataIndex: 'departmentName',
|
|
|
- key: 'departmentName',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '责任中心编码',
|
|
|
- dataIndex: 'responsibilityCode',
|
|
|
- key: 'responsibilityCode',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '责任中心名',
|
|
|
- dataIndex: 'responsibilityName',
|
|
|
- key: 'responsibilityName',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '会计科目编码',
|
|
|
- dataIndex: 'accountingCode',
|
|
|
- key: 'accountingCode',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '会计科目名',
|
|
|
- dataIndex: 'accountingName',
|
|
|
- key: 'accountingName',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '成本项目编码',
|
|
|
- dataIndex: 'projectCode',
|
|
|
- key: 'projectCode',
|
|
|
- hideInSearch: true,
|
|
|
- width:500,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '成本项目名',
|
|
|
- dataIndex: 'projectName',
|
|
|
- key: 'projectName',
|
|
|
- hideInSearch: true,
|
|
|
- width:500,
|
|
|
- },
|
|
|
- {
|
|
|
- title: '金额',
|
|
|
- dataIndex: 'amount',
|
|
|
- key: 'amount',
|
|
|
- fixed: 'right',
|
|
|
- width:500,
|
|
|
- hideInSearch: true,
|
|
|
- },
|
|
|
- ]
|
|
|
|
|
|
|
|
|
const actionRef = useRef();
|
|
|
const [totalCount, setTotalCount] = useState(0);
|
|
|
const [drawerVisible, setDrawerVisible] = useState(false);
|
|
|
-
|
|
|
+ const [reportTableColumns, setReportTableColumns] = useState([]);
|
|
|
+ const [totalData,setTotalData] = useState([]);
|
|
|
|
|
|
//获取列表
|
|
|
const getList = async (params = {}, sort, filter) => {
|
|
|
const { dateTime } = params;
|
|
|
// console.log(moment(dateTime).format('YYYY-MM'));
|
|
|
- const res = await getAfterIncomeCollectionList({ ...params, dateTime: moment(dateTime).format('YYYYMM') });
|
|
|
+ const res = await getAfterIncomeCollectionList({ ...params, date: moment(date).format('YYYYMM') });
|
|
|
if (res && res.status) {
|
|
|
const { data: { totalAmount } } = res;
|
|
|
setTotalCount(totalAmount);
|
|
@@ -284,14 +211,48 @@ const AfterCollectionSearch = () => {
|
|
|
|
|
|
};
|
|
|
|
|
|
- const getDrawerTableList = async () => {
|
|
|
- const resp = await getAfterIncomeCollectionList();
|
|
|
- const { status, data } = resp;
|
|
|
+
|
|
|
+ const renderDrawerHandle = () => {
|
|
|
+
|
|
|
+ setDrawerVisible(true);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const getReportData = async (params = {}, sort, filter)=>{
|
|
|
+
|
|
|
+ const resp = await getAfterIncomeCollectionTableData({...params,date:currentTime,responsibilityCode:selectedResponsibilityCode,accountingCode:selectedAccountingCode});
|
|
|
+ const { status, data: { titleMap, realData, totalMap } } = resp;
|
|
|
if (status == 200) {
|
|
|
- return {
|
|
|
- data: data.list,
|
|
|
+ const titleMapToArr = Object.entries(titleMap);
|
|
|
+ const totalMapToArr = Object.entries(totalMap);
|
|
|
+ const columns = [...titleMapToArr].map((item, index) => {
|
|
|
+ if (index == 0 || index == [...titleMapToArr].length - 1) {
|
|
|
+ return {
|
|
|
+ title: item[1],
|
|
|
+ dataIndex: item[0],
|
|
|
+ key: item[0],
|
|
|
+ fixed:index == 0?'left':'right',
|
|
|
+ hideInSearch: true,
|
|
|
+ width: 100,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ title: item[1],
|
|
|
+ dataIndex: item[0],
|
|
|
+ key: item[0],
|
|
|
+ hideInSearch: true,
|
|
|
+ width: 500,
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ setReportTableColumns(columns);
|
|
|
+ setTotalData(totalMapToArr);
|
|
|
+
|
|
|
+ return Promise.resolve({
|
|
|
+ data: realData,
|
|
|
success: true,
|
|
|
- };
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -312,7 +273,7 @@ const AfterCollectionSearch = () => {
|
|
|
actionRef={actionRef}
|
|
|
rowKey="id"
|
|
|
toolBarRender={() => [
|
|
|
- <Button type='primary' onClick={() => setDrawerVisible(true)}>报表数据</Button>
|
|
|
+ <Button type='primary' onClick={() => renderDrawerHandle()}>报表数据</Button>
|
|
|
]}
|
|
|
pagination={{
|
|
|
pageSize: 10,
|
|
@@ -329,34 +290,35 @@ const AfterCollectionSearch = () => {
|
|
|
title="报表数据"
|
|
|
placement="right"
|
|
|
width={'90%'}
|
|
|
+ destroyOnClose={true}
|
|
|
closable={true}
|
|
|
- onClose={()=>setDrawerVisible(false)}
|
|
|
+ onClose={() => setDrawerVisible(false)}
|
|
|
visible={drawerVisible}
|
|
|
>
|
|
|
<ProTable
|
|
|
- columns={drawerTableColumns}
|
|
|
- request={getList}
|
|
|
+ columns={reportTableColumns}
|
|
|
+ request={getReportData}
|
|
|
actionRef={actionRef}
|
|
|
rowKey="id"
|
|
|
-
|
|
|
+ bordered
|
|
|
pagination={false}
|
|
|
search={false}
|
|
|
scroll={{ x: 1500, y: 300 }}
|
|
|
summary={() => (
|
|
|
- <Table.Summary fixed>
|
|
|
+ <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>
|
|
|
{
|
|
|
- [1,2,3,4,5,6,7,8,9,10].map((item,index)=>{
|
|
|
- return (
|
|
|
- <Table.Summary.Cell className={index==9?'ant-table-cell ant-table-cell-fix-right ant-table-cell-fix-right-last':'cell'} index={index}>10000</Table.Summary.Cell>
|
|
|
- )
|
|
|
+ totalData.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <Table.Summary.Cell key={index} className={index == 9 ? '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.Row>
|
|
|
</Table.Summary>
|
|
|
)}
|
|
|
- // footer={() => <a>{`合计:${totalCount}`}</a>}
|
|
|
+ // footer={() => <a>{`合计:${totalCount}`}</a>}
|
|
|
|
|
|
/>
|
|
|
</Drawer>
|