|
|
@@ -20,7 +20,11 @@ import {
|
|
|
ListView,
|
|
|
SearchBar,
|
|
|
} from 'antd-mobile'
|
|
|
-import { fetchGet, fetchPostForm } from '../../../utils/common/fetchRequest'
|
|
|
+import {
|
|
|
+ fetchGet,
|
|
|
+ fetchPostForm,
|
|
|
+ fetchPostObj,
|
|
|
+} from '../../../utils/common/fetchRequest'
|
|
|
import BillModel, {
|
|
|
TYPE_ADD,
|
|
|
TYPE_TAB,
|
|
|
@@ -28,11 +32,13 @@ import BillModel, {
|
|
|
} from '../../../model/common/BillModel'
|
|
|
import LocalData from '../../../model/common/LocalData'
|
|
|
import BillGroupModel from '../../../model/common/BillGroupModel'
|
|
|
-import FormInput from '../../../components/common/formNew/FormInput'
|
|
|
-import FormTitle from '../../../components/common/formNew/FormTitle'
|
|
|
-import FormAdd from '../../../components/common/formNew/FormAdd'
|
|
|
-import EmployeeItem from '../../../components/private/employeeItem/EmployeeItem'
|
|
|
-import { _baseURL } from '../../../configs/api.config'
|
|
|
+import FormInput from '../formNew/FormInput'
|
|
|
+import FormTitle from '../formNew/FormTitle'
|
|
|
+import FormAdd from '../formNew/FormAdd'
|
|
|
+import EmployeeItem from '../../private/employeeItem/EmployeeItem'
|
|
|
+import { _baseURL, API } from '../../../configs/api.config'
|
|
|
+import { analysisFormData } from '../../../utils/common/form.request'
|
|
|
+import { connect } from 'react-redux'
|
|
|
|
|
|
const alert = Modal.alert
|
|
|
const CheckboxItem = Checkbox.CheckboxItem
|
|
|
@@ -53,7 +59,7 @@ let mModalList = []
|
|
|
|
|
|
let mShowBillModels, mFormBillModels, mUpdateBillModels, mAllBillModels
|
|
|
|
|
|
-export default class BillAdd extends Component {
|
|
|
+class BillAdd extends Component {
|
|
|
|
|
|
constructor () {
|
|
|
super()
|
|
|
@@ -71,9 +77,11 @@ export default class BillAdd extends Component {
|
|
|
|
|
|
componentDidMount () {
|
|
|
document.title = '新增单据'
|
|
|
- mCaller = this.props.match.params.caller
|
|
|
- mMaster = this.props.match.params.master
|
|
|
- mId = this.props.match.params.id
|
|
|
+ const { userState, match, master, caller, id } = this.props
|
|
|
+ mMaster = match ? match.params.master :
|
|
|
+ master ? master : userState.accountCode
|
|
|
+ mCaller = match ? match.params.caller : caller
|
|
|
+ mId = match ? match.params.id : id
|
|
|
if (isObjEmpty(mId)) {
|
|
|
mId = 0
|
|
|
}
|
|
|
@@ -95,6 +103,33 @@ export default class BillAdd extends Component {
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
+ let formItems = this.getFormItems()
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className='approval-add-root'>
|
|
|
+ <Prompt message={this.handlePrompt}
|
|
|
+ when={this.state.promptAble}/>
|
|
|
+ <div className='approval-add-root' style={{ flex: 1 }}>
|
|
|
+ <List>
|
|
|
+ {formItems}
|
|
|
+ </List>
|
|
|
+ </div>
|
|
|
+ {/*{formItems.length > 0 &&*/}
|
|
|
+ {/*<Button type={'primary'}*/}
|
|
|
+ {/* style={{*/}
|
|
|
+ {/* margin: '18px 26px',*/}
|
|
|
+ {/* height: '36px',*/}
|
|
|
+ {/* lineHeight: '36px',*/}
|
|
|
+ {/* fontSize: '16px',*/}
|
|
|
+ {/* }}*/}
|
|
|
+ {/* onClick={this.onSubmitClick}>提交</Button>}*/}
|
|
|
+
|
|
|
+ {this.getDbfindModal()}
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ getFormItems = () => {
|
|
|
const { billGroupModelList } = this.state
|
|
|
let formItems = []
|
|
|
if (!isObjEmpty(billGroupModelList)) {
|
|
|
@@ -143,7 +178,7 @@ export default class BillAdd extends Component {
|
|
|
if (billGroup.isForm == false && billGroup.lastInType == true) {
|
|
|
//如果是最后一个从表,则添加【新增】按钮
|
|
|
formItems.push(
|
|
|
- <BillAdd billModel={this.getAddModel(g)} groupIndex={g}
|
|
|
+ <FormAdd billModel={this.getAddModel(g)} groupIndex={g}
|
|
|
onAddClick={this.onAddClick.bind(this)}/>,
|
|
|
)
|
|
|
}
|
|
|
@@ -151,28 +186,8 @@ export default class BillAdd extends Component {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return (
|
|
|
- <div className='approval-add-root'>
|
|
|
- <Prompt message={this.handlePrompt}
|
|
|
- when={this.state.promptAble}/>
|
|
|
- <div className='approval-add-root' style={{ flex: 1 }}>
|
|
|
- <List>
|
|
|
- {formItems}
|
|
|
- </List>
|
|
|
- </div>
|
|
|
- {formItems.length > 0 &&
|
|
|
- <Button type={'primary'}
|
|
|
- style={{
|
|
|
- margin: '18px 26px',
|
|
|
- height: '36px',
|
|
|
- lineHeight: '36px',
|
|
|
- fontSize: '16px',
|
|
|
- }}
|
|
|
- onClick={this.onSubmitClick}>提交</Button>}
|
|
|
|
|
|
- {this.getDbfindModal()}
|
|
|
- </div>
|
|
|
- )
|
|
|
+ return formItems
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -343,8 +358,8 @@ export default class BillAdd extends Component {
|
|
|
if (!isObjEmpty(billGroupModelList) &&
|
|
|
!isObjNull(billGroupModelList[groupIndex])) {
|
|
|
let billGroup = billGroupModelList[groupIndex]
|
|
|
- billGroup[childIndex].value = selectData.value
|
|
|
- billGroup[childIndex].display = selectData.display
|
|
|
+ billGroup.showBillFields[childIndex].value = selectData.value
|
|
|
+ billGroup.showBillFields[childIndex].display = selectData.display
|
|
|
}
|
|
|
this.setState({
|
|
|
billGroupModelList,
|
|
|
@@ -933,7 +948,8 @@ export default class BillAdd extends Component {
|
|
|
if (isObjNull(billModel)) {
|
|
|
continue
|
|
|
}
|
|
|
- if (isObjEmpty(billModel.getValue()) && billModel.isdefault === -1 &&
|
|
|
+ if (isObjEmpty(this.getValue(billModel)) && billModel.isdefault ===
|
|
|
+ -1 &&
|
|
|
(billModel.allowBlank === 'necessaryField'
|
|
|
|| billModel.allowBlank === 'F')) {
|
|
|
message.error(`${billModel.caption}为必填项`)
|
|
|
@@ -941,7 +957,7 @@ export default class BillAdd extends Component {
|
|
|
}
|
|
|
//Todo 附件上传
|
|
|
|
|
|
- formStore[billModel.field] = billModel.getDisplay()
|
|
|
+ formStore[billModel.field] = this.getDisplay(billModel)
|
|
|
}
|
|
|
return formStore
|
|
|
} else {
|
|
|
@@ -958,7 +974,7 @@ export default class BillAdd extends Component {
|
|
|
let gridStore = {}
|
|
|
for (let j = 0; j < gridFields.length; j++) {
|
|
|
let billModel = gridFields[j]
|
|
|
- if (isObjEmpty(billModel.getValue())
|
|
|
+ if (isObjEmpty(this.getValue(billModel))
|
|
|
&& billModel.isdefault === -1
|
|
|
&& (billModel.allowBlank === 'necessaryField'
|
|
|
|| billModel.allowBlank === 'F')) {
|
|
|
@@ -967,7 +983,7 @@ export default class BillAdd extends Component {
|
|
|
}
|
|
|
//Todo 附件上传
|
|
|
|
|
|
- gridStore[billModel.field] = billModel.getDisplay()
|
|
|
+ gridStore[billModel.field] = this.getDisplay(billModel)
|
|
|
}
|
|
|
gridStoreList.push(gridStore)
|
|
|
}
|
|
|
@@ -980,19 +996,19 @@ export default class BillAdd extends Component {
|
|
|
* 获取主从表数据
|
|
|
*/
|
|
|
loadFormandGridDetail () {
|
|
|
- fetchPostForm(_baseURL + (mId <= 0
|
|
|
- ? '/mobile/uapproval/getformandgriddetail.action'
|
|
|
- : '/mobile/getformandgriddetail_uapproval.action'), {
|
|
|
- condition: '1=1',
|
|
|
+ const { isDetail } = this.props
|
|
|
+ fetchPostObj(API.SETVICES_GETORDER, {
|
|
|
caller: mCaller,
|
|
|
id: mId,
|
|
|
}).then(response => {
|
|
|
Toast.hide()
|
|
|
- let billGroupModels = this.handlerBill(response)
|
|
|
- // this.changeBillModel(billGroupModels)
|
|
|
- // console.log('raomeng', billGroupModels)
|
|
|
+ // let billGroupModels = this.handlerBill(response)
|
|
|
+ // this.setState({
|
|
|
+ // billGroupModelList: billGroupModels,
|
|
|
+ // })
|
|
|
+ const billGroupList = analysisFormData(response.data, isDetail)
|
|
|
this.setState({
|
|
|
- billGroupModelList: billGroupModels,
|
|
|
+ billGroupModelList: billGroupList,
|
|
|
})
|
|
|
}).catch(error => {
|
|
|
Toast.hide()
|
|
|
@@ -1412,4 +1428,18 @@ export default class BillAdd extends Component {
|
|
|
return 1
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ getValue = (billModel) => (
|
|
|
+ billModel.value || billModel.defValue || ''
|
|
|
+ )
|
|
|
+
|
|
|
+ getDisplay = (billModel) => {
|
|
|
+ return billModel.display || this.getValue(billModel)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+let mapStateToProps = (state) => ({
|
|
|
+ userState: state.userState,
|
|
|
+})
|
|
|
+
|
|
|
+export default connect(mapStateToProps)(BillAdd)
|