|
@@ -7,8 +7,8 @@ import Modal from 'antd/lib/modal/Modal'
|
|
|
import { RadioChangeEvent } from 'antd/lib/radio'
|
|
|
import { ColumnsType } from 'antd/lib/table'
|
|
|
import { observer } from 'mobx-react'
|
|
|
-import React, { useEffect, useRef, useState } from 'react'
|
|
|
-import { apiGetIncome, apiResfulContractTree } from '../../api'
|
|
|
+import React, { KeyboardEvent, useEffect, useRef, useState } from 'react'
|
|
|
+import { apiGetIncome, apiResfulContractTree, apiUpdateName, apiUpdateSerial } from '../../api'
|
|
|
import { apiContractIncome, apiSetTemplate } from '../Modal/api'
|
|
|
import Detail from '../Tabs/Detail'
|
|
|
import File from '../Tabs/File'
|
|
@@ -93,7 +93,6 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
useEffect(() => {
|
|
|
initHandler()
|
|
|
}, [])
|
|
|
-
|
|
|
const initHandler = async () => {
|
|
|
const data = await apiContractIncome(tenderStore.bid)
|
|
|
if (data.code === consts.RET_CODE.SUCCESS) {
|
|
@@ -120,13 +119,25 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
|
|
|
const newLabelHandler = async (type: string, payload: iLabelHandlerProps) => {
|
|
|
let RET_CODE: number = -1
|
|
|
- if (type === 'name') {
|
|
|
+ if (type === 'create') {
|
|
|
payload.name = inputEl.current?.state.value
|
|
|
const { code = -1 } = await apiResfulContractTree('add', payload)
|
|
|
RET_CODE = code
|
|
|
}
|
|
|
+ if (type === 'edit') {
|
|
|
+ const name = inputEl.current?.state.value
|
|
|
+ const { code = -1 } = await apiUpdateName(payload.id, payload.bidsectionId, name)
|
|
|
+ RET_CODE = code
|
|
|
+ }
|
|
|
if (RET_CODE === consts.RET_CODE.SUCCESS) {
|
|
|
- contractStore.resetTree(tenderStore.bidsectionId)
|
|
|
+ contractStore.resetTree(tenderStore.tender.bidsectionId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const codeChange = async (row: iIncomeTree, value: string) => {
|
|
|
+ const { code = -1 } = await apiUpdateSerial(row.id, row.bidsectionId, value)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ initHandler()
|
|
|
}
|
|
|
}
|
|
|
const inputEl = useRef<Input>(null)
|
|
@@ -156,7 +167,14 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
render: (text: string, row: iIncomeTree) => {
|
|
|
if (row.isEdit) {
|
|
|
- return <Input value={row.serial} addonBefore={row.attribution} size="small" style={{ width: 30 }}></Input>
|
|
|
+ return (
|
|
|
+ <Input
|
|
|
+ defaultValue={row.serial}
|
|
|
+ addonBefore={row.attribution}
|
|
|
+ size="small"
|
|
|
+ style={{ width: 80 }}
|
|
|
+ onPressEnter={(e: KeyboardEvent<HTMLInputElement>) => codeChange(row, e.currentTarget.value)}
|
|
|
+ />)
|
|
|
} else {
|
|
|
return <span>{row.code}</span>
|
|
|
}
|
|
@@ -167,8 +185,17 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
title: '项目名称',
|
|
|
dataIndex: 'name',
|
|
|
render: (text:any, record: iIncomeTree) => {
|
|
|
- if (record.isEdit) {
|
|
|
- return <Input defaultValue={record.name} size="small" type="text" ref={inputEl} onPressEnter={() => newLabelHandler('name', { id: record.parentId, bidsectionId: record.bidsectionId })} onBlur={() => newLabelHandler('name', { id: record.parentId, bidsectionId: record.bidsectionId })}></Input>
|
|
|
+ if (record.isEdit || record.isNew) {
|
|
|
+ const type = record.isEdit ? 'edit' : 'create'
|
|
|
+ return (
|
|
|
+ <Input
|
|
|
+ defaultValue={record.name}
|
|
|
+ size="small"
|
|
|
+ type="text"
|
|
|
+ ref={inputEl}
|
|
|
+ onPressEnter={() => newLabelHandler(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
|
|
|
+ onBlur={() => newLabelHandler(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
|
|
|
+ />)
|
|
|
} else {
|
|
|
return <span>{text}</span>
|
|
|
}
|
|
@@ -218,7 +245,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
})
|
|
|
return message.error('请选择项目节模板!')
|
|
|
}
|
|
|
- const { code = -1 } = await apiSetTemplate(sectionTemplate.template, tenderStore.bidsectionId)
|
|
|
+ const { code = -1 } = await apiSetTemplate(sectionTemplate.template, tenderStore.tender.bidsectionId)
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
await initHandler()
|
|
|
}
|
|
@@ -241,10 +268,10 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
const onClickRow = (record: iIncomeTree) => {
|
|
|
return {
|
|
|
onClick() {
|
|
|
- setRow(record)
|
|
|
+ rowClickHandler(record.id, record.bidsectionId, record.isEdit)
|
|
|
},
|
|
|
onDoubleClick() {
|
|
|
- rowClickHandler(record.id, record.bidsectionId, record.isEdit)
|
|
|
+ contractStore.rowChange(row.id)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -256,7 +283,6 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
setRow(section)
|
|
|
setContract({ ...contract, ...newContract })
|
|
|
- contractStore.rowChange(id)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -305,7 +331,8 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
</div>
|
|
|
<div className={styles.projectTable}>
|
|
|
{
|
|
|
- tempalte.template2?.children && tempalte.template2?.children.length? <Table
|
|
|
+ tempalte.template2?.children && tempalte.template2?.children.length?
|
|
|
+ <Table
|
|
|
dataSource={tempalte.template2?.children}
|
|
|
columns={modalColumns}
|
|
|
bordered
|
|
@@ -313,8 +340,8 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
scroll={{ y: '300px' }}
|
|
|
rowKey={record => record.id}
|
|
|
defaultExpandAllRows={true}
|
|
|
- >
|
|
|
- </Table> : ''
|
|
|
+ />
|
|
|
+ : ''
|
|
|
}
|
|
|
|
|
|
</div>
|
|
@@ -326,19 +353,19 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
<div className={styles.spreadSheets}>
|
|
|
{
|
|
|
contractStore.showTable ?
|
|
|
- <Table<iIncomeTree>
|
|
|
- dataSource={contractStore.tree}
|
|
|
- columns={TableColumns}
|
|
|
- bordered
|
|
|
- pagination={false}
|
|
|
- rowKey={record => record.id}
|
|
|
- defaultExpandAllRows={true}
|
|
|
- onRow={onClickRow}
|
|
|
- rowClassName={handleRowClass}
|
|
|
- style={{ height: '100%', overflowY: 'scroll' }}
|
|
|
- />
|
|
|
- : ''
|
|
|
- }
|
|
|
+ <Table<iIncomeTree>
|
|
|
+ dataSource={contractStore.tree}
|
|
|
+ columns={TableColumns}
|
|
|
+ bordered
|
|
|
+ pagination={false}
|
|
|
+ rowKey={record => record.id}
|
|
|
+ defaultExpandAllRows={true}
|
|
|
+ onRow={onClickRow}
|
|
|
+ rowClassName={handleRowClass}
|
|
|
+ style={{ height: '100%', overflowY: 'scroll' }}
|
|
|
+ />
|
|
|
+ : ''
|
|
|
+ }
|
|
|
</div>
|
|
|
<div className={styles.extraControl}>
|
|
|
<Tabs
|
|
@@ -347,7 +374,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ modalHandler, row, setRow }) =>
|
|
|
defaultActiveKey="1"
|
|
|
tabBarExtraContent={{ right: <div className="pi-mg-right-5"><Button type="primary" size="small" danger className="pi-mg-right-3" onClick={() => modalHandler('close')}>关闭合同</Button><Button type="primary" size="small" onClick={() => modalHandler('edit')}>编辑合同</Button></div> }}>
|
|
|
<TabPane key="1" tab="合同详情">
|
|
|
- <Detail></Detail>
|
|
|
+ <Detail {...contract}></Detail>
|
|
|
</TabPane>
|
|
|
<TabPane key="2" tab="合同回款">
|
|
|
<Receivable></Receivable>
|