|
@@ -1,19 +1,19 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-07-26 10:13:13
|
|
|
- * @LastEditTime: 2021-08-13 17:10:45
|
|
|
+ * @LastEditTime: 2021-08-28 10:28:33
|
|
|
* @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 } 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 { ModalForm, ProFormText, ProFormSelect} from '@ant-design/pro-form';
|
|
|
+import { ModalForm, ProFormText, ProFormDependency,ProFormSelect } from '@ant-design/pro-form';
|
|
|
import UpdateForm from './updateForm';
|
|
|
import { getAccountingSubjectList, editAccountingSubjectList, delAccountingSubject, addAccountingSubject, getAccountingSubjectForSelecter } from './service';
|
|
|
|
|
@@ -46,7 +46,7 @@ const AccountingSubject = () => {
|
|
|
// width: '20%'
|
|
|
// },
|
|
|
{
|
|
|
- title:'操作',
|
|
|
+ title: '操作',
|
|
|
dataIndex: 'option',
|
|
|
valueType: 'option',
|
|
|
key: 'option',
|
|
@@ -95,7 +95,7 @@ const AccountingSubject = () => {
|
|
|
const [options, setOptions] = useState([]);
|
|
|
|
|
|
const [ifChild, setIfChild] = useState(false);
|
|
|
- const [expanedRowIds,setExpanedRowIds] = useState([]);
|
|
|
+ const [expanedRowIds, setExpanedRowIds] = useState([]);
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -134,33 +134,33 @@ const AccountingSubject = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const expandHandle = id=>{
|
|
|
-
|
|
|
- if(expanedRowIds.includes(id)){
|
|
|
+ const expandHandle = id => {
|
|
|
+
|
|
|
+ if (expanedRowIds.includes(id)) {
|
|
|
const temp = expanedRowIds;
|
|
|
temp.splice(temp.findIndex(item => item == id), 1);
|
|
|
setExpanedRowIds([...temp])
|
|
|
- }else{
|
|
|
- setExpanedRowIds([...expanedRowIds,id])
|
|
|
+ } else {
|
|
|
+ setExpanedRowIds([...expanedRowIds, id])
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param {Object} record record对象
|
|
|
* @param {String} type 可选值[del,edit,‘add’]
|
|
|
*/
|
|
|
- const customRowUpdata = (record,type)=>{
|
|
|
- // console.log({record});
|
|
|
- const {accountingCode,accountingName,id} = record;
|
|
|
- const needRowData = {accountingCode,accountingName,id};
|
|
|
- setIfChild(true);
|
|
|
- setCurrentRow(needRowData);
|
|
|
-
|
|
|
- if(type == 'add')handleModalVisible(true);
|
|
|
- if(type == 'edit')handleUpdateModalVisible(true);
|
|
|
- if(type == 'del')delListHandler(needRowData);
|
|
|
+ const customRowUpdata = (record, type) => {
|
|
|
+ // console.log({record});
|
|
|
+ const { accountingCode, accountingName, id } = record;
|
|
|
+ const needRowData = { accountingCode, accountingName, id };
|
|
|
+ setIfChild(true);
|
|
|
+ setCurrentRow(needRowData);
|
|
|
+
|
|
|
+ if (type == 'add') handleModalVisible(true);
|
|
|
+ if (type == 'edit') handleUpdateModalVisible(true);
|
|
|
+ if (type == 'del') delListHandler(needRowData);
|
|
|
}
|
|
|
|
|
|
//展开table
|
|
@@ -172,67 +172,67 @@ const AccountingSubject = () => {
|
|
|
return (<table>
|
|
|
<tbody>
|
|
|
{
|
|
|
- child&&child.map((item, index) => {
|
|
|
+ child && child.map((item, index) => {
|
|
|
const { accountingCode, accountingName, id, child } = item;
|
|
|
console.log({ accountingCode, accountingName, id, child });
|
|
|
return (
|
|
|
- <React.Fragment key={index}>
|
|
|
+ <React.Fragment key={index}>
|
|
|
<tr key={id} style={{ position: 'relative' }}>
|
|
|
<td>
|
|
|
<table>
|
|
|
<tbody>
|
|
|
- <tr>
|
|
|
- <td style={{ position: 'absolute', width: 0 }}>
|
|
|
- {
|
|
|
- child&&child.length > 0 &&(
|
|
|
- <button onClick={()=>expandHandle(id)} style={{top:12}} className={
|
|
|
- expanedRowIds.includes(id)?'ant-table-row-expand-icon ant-table-row-expand-icon-expanded':'ant-table-row-expand-icon ant-table-row-expand-icon-collapsed'
|
|
|
- }></button>
|
|
|
- )
|
|
|
- }
|
|
|
- {/* <button className="ant-table-row-expand-icon ant-table-row-expand-icon-expanded customExpandIcon"></button> */}
|
|
|
- </td>
|
|
|
- <td width="30%" style={{ paddingLeft: '0.8%',paddingTop:10,paddingBottom:10 }}><span style={{transform:'rotateY(180deg)'}}>↵</span>会计科目名称:{accountingName}</td>
|
|
|
- <td width="30%" style={{ paddingLeft: '0.3%' }}>会计科目编码:{accountingCode}</td>
|
|
|
- <td width="20%" style={{ paddingLeft: '0.7%' }}>否</td>
|
|
|
- <td width="15%" style={{ paddingLeft: '0.9%' }}>
|
|
|
- <a onClick={()=>customRowUpdata(item,'add')}>添加</a>
|
|
|
- <a onClick={()=>customRowUpdata(item,'edit')}>编辑</a>
|
|
|
- <a onClick={()=>customRowUpdata(item,'del')}>删除</a>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ <tr>
|
|
|
+ <td style={{ position: 'absolute', width: 0 }}>
|
|
|
+ {
|
|
|
+ child && child.length > 0 && (
|
|
|
+ <button onClick={() => expandHandle(id)} style={{ top: 12 }} className={
|
|
|
+ expanedRowIds.includes(id) ? 'ant-table-row-expand-icon ant-table-row-expand-icon-expanded' : 'ant-table-row-expand-icon ant-table-row-expand-icon-collapsed'
|
|
|
+ }></button>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ {/* <button className="ant-table-row-expand-icon ant-table-row-expand-icon-expanded customExpandIcon"></button> */}
|
|
|
+ </td>
|
|
|
+ <td width="30%" style={{ paddingLeft: '0.8%', paddingTop: 10, paddingBottom: 10 }}><span style={{ transform: 'rotateY(180deg)' }}>↵</span>会计科目名称:{accountingName}</td>
|
|
|
+ <td width="30%" style={{ paddingLeft: '0.3%' }}>会计科目编码:{accountingCode}</td>
|
|
|
+ <td width="20%" style={{ paddingLeft: '0.7%' }}>否</td>
|
|
|
+ <td width="15%" style={{ paddingLeft: '0.9%' }}>
|
|
|
+ <a onClick={() => customRowUpdata(item, 'add')}>添加</a>
|
|
|
+ <a onClick={() => customRowUpdata(item, 'edit')}>编辑</a>
|
|
|
+ <a onClick={() => customRowUpdata(item, 'del')}>删除</a>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</td>
|
|
|
</tr>
|
|
|
{
|
|
|
- expanedRowIds.includes(id)&&<tr key={`expand${id}`}>
|
|
|
- <td width="100%">
|
|
|
- <table>
|
|
|
- <tbody>
|
|
|
- {
|
|
|
- child.map((data, index) => {
|
|
|
-
|
|
|
- const { accountingCode, accountingName, id, child } = data;
|
|
|
- return (
|
|
|
- <tr key={id} style={{ position: 'relative' }}>
|
|
|
- <td style={{ position: 'absolute', width: 0 }}>
|
|
|
- {
|
|
|
- child&&child.length > 0 && <button class="ant-table-row-expand-icon ant-table-row-expand-icon-collapsed"></button>
|
|
|
- }
|
|
|
- </td>
|
|
|
- <td width="30%" style={{ paddingLeft: '2.5%',paddingTop:10,paddingBottom:10 }}>↵会计科目名称:{accountingName}</td>
|
|
|
- <td width="30%" style={{ paddingLeft: '0.3%' }}>会计科目编码:{accountingCode}</td>
|
|
|
- <td width="20%" style={{ paddingLeft: '0.7%' }}>否</td>
|
|
|
- <td width="15%" style={{ paddingLeft: '0.9%' }}><a >编辑</a></td>
|
|
|
- </tr>
|
|
|
- )
|
|
|
- })
|
|
|
- }
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ expanedRowIds.includes(id) && <tr key={`expand${id}`}>
|
|
|
+ <td width="100%">
|
|
|
+ <table>
|
|
|
+ <tbody>
|
|
|
+ {
|
|
|
+ child&&child.map((data, index) => {
|
|
|
+
|
|
|
+ const { accountingCode, accountingName, id, child } = data;
|
|
|
+ return (
|
|
|
+ <tr key={id} style={{ position: 'relative' }}>
|
|
|
+ <td style={{ position: 'absolute', width: 0 }}>
|
|
|
+ {
|
|
|
+ child && child.length > 0 && <button class="ant-table-row-expand-icon ant-table-row-expand-icon-collapsed"></button>
|
|
|
+ }
|
|
|
+ </td>
|
|
|
+ <td width="30%" style={{ paddingLeft: '2.5%', paddingTop: 10, paddingBottom: 10 }}>↵会计科目名称:{accountingName}</td>
|
|
|
+ <td width="30%" style={{ paddingLeft: '0.3%' }}>会计科目编码:{accountingCode}</td>
|
|
|
+ <td width="20%" style={{ paddingLeft: '0.7%' }}>否</td>
|
|
|
+ <td width="15%" style={{ paddingLeft: '0.9%' }}><a >编辑</a></td>
|
|
|
+ </tr>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
}
|
|
|
</React.Fragment>
|
|
|
)
|
|
@@ -241,10 +241,10 @@ const AccountingSubject = () => {
|
|
|
</tbody>
|
|
|
</table>
|
|
|
)
|
|
|
-
|
|
|
+
|
|
|
};
|
|
|
-
|
|
|
- const onTabChange = (key)=>{
|
|
|
+
|
|
|
+ const onTabChange = (key) => {
|
|
|
|
|
|
setAccountType(Number(key));
|
|
|
if (actionRef.current) {
|
|
@@ -261,17 +261,17 @@ const AccountingSubject = () => {
|
|
|
|
|
|
return (
|
|
|
<PageContainer
|
|
|
- tabList={[
|
|
|
- {
|
|
|
- tab: '收益',
|
|
|
- key: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- tab: '支出',
|
|
|
- key: 2,
|
|
|
- },
|
|
|
- ]}
|
|
|
- onTabChange={onTabChange}
|
|
|
+ tabList={[
|
|
|
+ {
|
|
|
+ tab: '收入',
|
|
|
+ key: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ tab: '支出',
|
|
|
+ key: 2,
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ onTabChange={onTabChange}
|
|
|
>
|
|
|
|
|
|
<ProTable
|
|
@@ -279,11 +279,11 @@ const AccountingSubject = () => {
|
|
|
request={getList}
|
|
|
actionRef={actionRef}
|
|
|
rowKey="id"
|
|
|
- expandable={{defaultExpandedRowKeys:[]}}
|
|
|
+ expandable={{ defaultExpandedRowKeys: [] }}
|
|
|
// expandable={{ expandedRowRender }}
|
|
|
toolbar={{
|
|
|
actions: [
|
|
|
-
|
|
|
+
|
|
|
<Button
|
|
|
key="button"
|
|
|
icon={<PlusOutlined />}
|
|
@@ -309,7 +309,7 @@ const AccountingSubject = () => {
|
|
|
layout={'horizontal'}
|
|
|
visible={createModalVisible}
|
|
|
onVisibleChange={(bool) => {
|
|
|
-
|
|
|
+
|
|
|
if (ref.current) {
|
|
|
ref.current.resetFields();
|
|
|
}
|
|
@@ -318,9 +318,9 @@ const AccountingSubject = () => {
|
|
|
}}
|
|
|
formRef={ref}
|
|
|
onFinish={async (value) => {
|
|
|
- let id=0;
|
|
|
- currentRow&&(id=currentRow.id)
|
|
|
- const success = await addAccountingSubject({ ...value, id:id,accountingType:accountType });
|
|
|
+ let id = 0;
|
|
|
+ currentRow && (id = currentRow.id)
|
|
|
+ const success = await addAccountingSubject({ ...value, id: id, accountingType: accountType });
|
|
|
// console.log({ success });
|
|
|
if (success) {
|
|
|
handleModalVisible(false);
|
|
@@ -332,14 +332,14 @@ const AccountingSubject = () => {
|
|
|
setCurrentRow(undefined);
|
|
|
}}
|
|
|
>
|
|
|
-
|
|
|
+
|
|
|
|
|
|
<ProFormText
|
|
|
label="会计科目编码"
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
- message:'会计科目编码是必填项',
|
|
|
+ message: '会计科目编码是必填项',
|
|
|
},
|
|
|
]}
|
|
|
width="sm"
|
|
@@ -350,41 +350,49 @@ const AccountingSubject = () => {
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
- message:'会计科目名是必填项',
|
|
|
+ message: '会计科目名是必填项',
|
|
|
},
|
|
|
]}
|
|
|
width="sm"
|
|
|
name="accountingName"
|
|
|
/>
|
|
|
- {/* <ProFormSelect
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: false,
|
|
|
- message:'',
|
|
|
- },
|
|
|
- ]}
|
|
|
- options={[
|
|
|
- {
|
|
|
- value: 0,
|
|
|
- label: '不是',
|
|
|
- },
|
|
|
- {
|
|
|
- value: 1,
|
|
|
- label: '是',
|
|
|
- },
|
|
|
- ]}
|
|
|
- width="sm"
|
|
|
- name="isBaseCode"
|
|
|
- label="是否固定成本"
|
|
|
- /> */}
|
|
|
+ <ProFormDependency name={['accountingCode']}>
|
|
|
+ {
|
|
|
+ ({accountingCode}) => {
|
|
|
+ return accountType == 2 ?(
|
|
|
+ <ProFormSelect
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ options={[
|
|
|
+ {
|
|
|
+ value: 0,
|
|
|
+ label: '不是',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 1,
|
|
|
+ label: '是',
|
|
|
+ },
|
|
|
+ ]}
|
|
|
+ width="sm"
|
|
|
+ name="isBaseCode"
|
|
|
+ label="是否固定成本"
|
|
|
+ />
|
|
|
+ ):<></>
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </ProFormDependency>
|
|
|
</ModalForm>
|
|
|
|
|
|
{/* 更新 */}
|
|
|
<UpdateForm
|
|
|
onSubmit={async (value) => {
|
|
|
// console.log({ '编辑': value });
|
|
|
- console.log({currentRow});
|
|
|
- const success = await editAccountingSubjectList({...value,accountType});
|
|
|
+ // console.log({ currentRow });
|
|
|
+ const success = await editAccountingSubjectList({ ...value, accountType });
|
|
|
|
|
|
if (success) {
|
|
|
handleUpdateModalVisible(false);
|
|
@@ -399,6 +407,7 @@ const AccountingSubject = () => {
|
|
|
handleUpdateModalVisible(false);
|
|
|
setCurrentRow(undefined);
|
|
|
}}
|
|
|
+ accountType={accountType}
|
|
|
updateModalVisible={updateModalVisible}
|
|
|
updateModalVisibleChange={updateModalVisibleChange}
|
|
|
values={currentRow || {}}
|