|
|
@@ -6,7 +6,7 @@
|
|
|
import React, { Component } from 'react'
|
|
|
import { isObjEmpty, isObjNull } from '../../utils/common'
|
|
|
import { message } from 'antd'
|
|
|
-import { Toast, List, Button } from 'antd-mobile'
|
|
|
+import { Toast, List, Button, Modal } from 'antd-mobile'
|
|
|
import { fetchGet, fetchPost } from '../../utils/fetchRequest'
|
|
|
import BillModel, {
|
|
|
TYPE_ADD,
|
|
|
@@ -20,6 +20,8 @@ import FormTitle from '../../components/approvalAdd/FormTitle'
|
|
|
import FormAdd from '../../components/approvalAdd/FormAdd'
|
|
|
import FormImage from '../../components/approvalAdd/FormImage'
|
|
|
|
|
|
+const alert = Modal.alert
|
|
|
+
|
|
|
let mBaseUrl = 'http://29226oq576.qicp.vip/uas/'
|
|
|
|
|
|
let mCaller//当前单据的Caller
|
|
|
@@ -62,6 +64,7 @@ export default class ApprovalAdd extends Component {
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
Toast.hide()
|
|
|
+ this.deleteAlert && this.deleteAlert.close()
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
@@ -77,7 +80,8 @@ export default class ApprovalAdd extends Component {
|
|
|
if (!isObjNull(showBillFields) &&
|
|
|
showBillFields.length > 0) {
|
|
|
//添加组标题
|
|
|
- this.addGroupTitle(g, billGroup, gridStartIndex, formItems)
|
|
|
+ gridStartIndex = this.addGroupTitle(g, billGroup, gridStartIndex,
|
|
|
+ formItems)
|
|
|
//添加显示字段
|
|
|
for (let i = 0; i < showBillFields.length; i++) {
|
|
|
let billModel = showBillFields[i]
|
|
|
@@ -96,7 +100,8 @@ export default class ApprovalAdd extends Component {
|
|
|
formItems.push(
|
|
|
<FormInput billModel={billModel} groupIndex={g}
|
|
|
childIndex={i}
|
|
|
- onTextChange={this.onTextChange.bind(this)}/>,
|
|
|
+ onTextChange={this.onTextChange.bind(this)}
|
|
|
+ onInputClick={this.onInputClick.bind(this)}/>,
|
|
|
)
|
|
|
break
|
|
|
case 2:
|
|
|
@@ -118,7 +123,8 @@ export default class ApprovalAdd extends Component {
|
|
|
/*if (billGroup.isForm == false && billGroup.lastInType == true) {
|
|
|
//如果是最后一个从表,则添加【新增】按钮
|
|
|
formItems.push(
|
|
|
- <FormAdd billModel={this.getAddModel(g)} groupIndex={g}/>,
|
|
|
+ <FormAdd billModel={this.getAddModel(g)} groupIndex={g}
|
|
|
+ onAddClick={this.onAddClick.bind(this)}/>,
|
|
|
)
|
|
|
}*/
|
|
|
}
|
|
|
@@ -143,6 +149,58 @@ export default class ApprovalAdd extends Component {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加明细组
|
|
|
+ * @param groupIndex
|
|
|
+ */
|
|
|
+ onAddClick = groupIndex => {
|
|
|
+ const { billGroupModelList } = this.state
|
|
|
+ billGroupModelList[groupIndex].lastInType = false
|
|
|
+
|
|
|
+ let newBillGroup = this.newGridBillGroup(groupIndex,
|
|
|
+ billGroupModelList[groupIndex])
|
|
|
+ billGroupModelList.push(newBillGroup)
|
|
|
+ console.log('newgroup', billGroupModelList)
|
|
|
+ this.setState({
|
|
|
+ billGroupModelList,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ newGridBillGroup = (groupIndex, oldBillGroup) => {
|
|
|
+ let oldGridIndex = oldBillGroup.gridIndex
|
|
|
+ let isForm = oldBillGroup.isForm
|
|
|
+
|
|
|
+ let newBillGroup = new BillGroupModel()
|
|
|
+ newBillGroup.isForm = isForm
|
|
|
+ if (isForm == true) {
|
|
|
+ newBillGroup.group = oldBillGroup.group
|
|
|
+ } else {
|
|
|
+ newBillGroup.group = `明细${oldGridIndex + 1}`
|
|
|
+ }
|
|
|
+ newBillGroup.billCaller = oldBillGroup.billCaller
|
|
|
+ newBillGroup.gridIndex = oldGridIndex + 1
|
|
|
+ newBillGroup.isDeleteAble = true
|
|
|
+ newBillGroup.lastInType = true
|
|
|
+ newBillGroup.groupIndex = groupIndex + 1
|
|
|
+
|
|
|
+ let showBillFields = oldBillGroup.showBillFields
|
|
|
+ let hideBillFields = oldBillGroup.hideBillFields
|
|
|
+
|
|
|
+ if (!isObjEmpty(showBillFields)) {
|
|
|
+ for (let i = 0; i < showBillFields.length; i++) {
|
|
|
+ let billModel = showBillFields[i]
|
|
|
+ newBillGroup.addShow(new BillModel(billModel))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!isObjEmpty(hideBillFields)) {
|
|
|
+ for (let i = 0; i < hideBillFields.length; i++) {
|
|
|
+ let billModel = hideBillFields[i]
|
|
|
+ newBillGroup.addHide(new BillModel(billModel))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return newBillGroup
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加分组头部
|
|
|
* @param g
|
|
|
@@ -169,12 +227,74 @@ export default class ApprovalAdd extends Component {
|
|
|
}
|
|
|
if (!isObjEmpty(titleBillModel.caption)) {
|
|
|
formItems.push(
|
|
|
- <FormTitle billModel={titleBillModel}/>,
|
|
|
+ <FormTitle billModel={titleBillModel} groupIndex={g}
|
|
|
+ onDeleteClick={this.onDeleteClick.bind(this)}/>,
|
|
|
)
|
|
|
}
|
|
|
+ return gridStartIndex
|
|
|
+ }
|
|
|
+
|
|
|
+ onDeleteClick = groupIndex => {
|
|
|
+ this.deleteAlert = alert('提示', '确认删除该明细?', [
|
|
|
+ {
|
|
|
+ text: '取消',
|
|
|
+ onPress: () => {},
|
|
|
+ style: 'default',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '确定', onPress: () => {
|
|
|
+ this.deleteGroup(groupIndex)
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ])
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除分组
|
|
|
+ * @param groupIndex
|
|
|
+ */
|
|
|
+ deleteGroup (groupIndex) {
|
|
|
+ const { billGroupModelList } = this.state
|
|
|
+ let deleteGroup = billGroupModelList[groupIndex]
|
|
|
+ let isLastGroup = deleteGroup.lastInType
|
|
|
+ if (isLastGroup == true && groupIndex - 1 >= 0) {
|
|
|
+ let billGroup = billGroupModelList[groupIndex - 1]
|
|
|
+ if (deleteGroup.isForm == false && (billGroup.isForm == true)) {
|
|
|
+ //明细删除光了,要默认添加一个空明细表
|
|
|
+ deleteGroup.groupIndex = groupIndex - 1
|
|
|
+ deleteGroup.gridIndex = 0
|
|
|
+ let newGridGroup = this.newGridBillGroup(groupIndex - 1, deleteGroup)
|
|
|
+ newGridGroup.isDeleteAble = false
|
|
|
+ billGroupModelList.splice(groupIndex, 1)
|
|
|
+ billGroupModelList.push(newGridGroup)
|
|
|
+ } else {
|
|
|
+ billGroup.lastInType = true
|
|
|
+ billGroupModelList.splice(groupIndex, 1)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ billGroupModelList.splice(groupIndex, 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setState({
|
|
|
+ billGroupModelList,
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
- onTextChange = (groupIndex, childIndex, value) => {
|
|
|
+ onInputClick = (groupIndex, childIndex) => {
|
|
|
+ /*const { billGroupModelList } = this.state
|
|
|
+ if (!isObjNull(billGroupModelList) &&
|
|
|
+ !isObjNull(billGroupModelList[groupIndex])) {
|
|
|
+ let billGroup = billGroupModelList[groupIndex]
|
|
|
+ if (!isObjNull(billGroup.showBillFields) &&
|
|
|
+ !isObjNull(billGroup.showBillFields[childIndex])) {
|
|
|
+ let billModel = billGroup.showBillFields[childIndex]
|
|
|
+ let localDatas = billModel.localDatas
|
|
|
+
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
+ onTextChange = (groupIndex, childIndex, value, display) => {
|
|
|
const { billGroupModelList } = this.state
|
|
|
if (!isObjNull(billGroupModelList) &&
|
|
|
!isObjNull(billGroupModelList[groupIndex])) {
|
|
|
@@ -182,6 +302,9 @@ export default class ApprovalAdd extends Component {
|
|
|
if (!isObjNull(billGroup.showBillFields) &&
|
|
|
!isObjNull(billGroup.showBillFields[childIndex])) {
|
|
|
billGroup.showBillFields[childIndex].value = value
|
|
|
+ if (!isObjNull(display)){
|
|
|
+ billGroup.showBillFields[childIndex].display = display
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
this.setState({
|
|
|
@@ -261,7 +384,12 @@ export default class ApprovalAdd extends Component {
|
|
|
message.success('单据提交成功')
|
|
|
this.props.history.goBack()
|
|
|
setTimeout(() => {
|
|
|
- this.props.history.push('/approval')
|
|
|
+ this.props.history.push('/approval/%7B%22' +
|
|
|
+ 'master%22%3A%22' + mMaster
|
|
|
+ + '%22%2C%22nodeId%22%3A' + mId
|
|
|
+ + '%2C%22type%22%3A' + 1
|
|
|
+ + '%2C%22baseUrl%22%3A%22' + encodeURIComponent(mBaseUrl)
|
|
|
+ + '%22%7D')
|
|
|
}, 100)
|
|
|
}
|
|
|
} else {
|
|
|
@@ -343,8 +471,8 @@ export default class ApprovalAdd extends Component {
|
|
|
*/
|
|
|
loadFormandGridDetail () {
|
|
|
fetchPost(mBaseUrl + (mId <= 0
|
|
|
- ? 'mobile/common/getformandgriddetail.action'
|
|
|
- : 'mobile/getformandgriddetail.action'), {
|
|
|
+ ? 'mobile/uapproval/getformandgriddetail.action'
|
|
|
+ : 'mobile/getformandgriddetail_uapproval.action'), {
|
|
|
condition: '1=1',
|
|
|
caller: mCaller,
|
|
|
id: mId,
|