Commit da7ccfcf authored by GuanHua's avatar GuanHua

fix;修改订单结算新增个人类型发票填写项问题

parent 3fb09f60
......@@ -4,6 +4,8 @@ import {
SchemaForm,
SchemaMarkupField as Field,
createAsyncFormActions,
FormEffectHooks,
createFormActions
} from '@formily/antd'
import { Input, Switch, Select, FormMegaLayout, Radio } from '@formily/antd-components'
import styles from './index.less'
......@@ -33,6 +35,9 @@ const AddInvoice: React.FC<AddAddressPropsType> = (props) => {
const { visible = false, title, onOk, onCancel, editItem, type } = props
const [state, setState] = useState({ editable: true })
const [confirmLoading, setConfirmLoading] = useState<boolean>(false)
const [invoiceTitle, setInvoiceTitle] = useState<string>("发票抬头")
const [invoiceTitleTip, setInvoiceTitleTip] = useState<string>("请输入发票抬头")
const [taxNoRequired, setTaxNoRequired] = useState<boolean>(true)
/**
* @description: Form保存
......@@ -65,6 +70,22 @@ const AddInvoice: React.FC<AddAddressPropsType> = (props) => {
actions.submit()
}
const { onFieldValueChange$ } = FormEffectHooks
const useTypeEffects = () => {
onFieldValueChange$('type').subscribe(({ value }) => {
if(value === 1) {
setInvoiceTitle("发票抬头")
setInvoiceTitleTip("请输入发票抬头")
setTaxNoRequired(true)
} else {
setInvoiceTitle("名称")
setInvoiceTitleTip("请输入名称")
setTaxNoRequired(false)
}
})
}
return visible && (
<Modal
title={title}
......@@ -79,6 +100,9 @@ const AddInvoice: React.FC<AddAddressPropsType> = (props) => {
>
<SchemaForm editable={state.editable}
actions={actions} // 要传递
effects={() => {
useTypeEffects()
}}
initialValues={type === 'edit' ? editItem : {
type: 1,
kind: 1
......@@ -114,9 +138,9 @@ const AddInvoice: React.FC<AddAddressPropsType> = (props) => {
<Field
x-rules={{
required: true,
message: '请输入发票抬头',
message: invoiceTitleTip,
}}
title="发票抬头"
title={invoiceTitle}
name="invoiceTitle"
maxLength={40}
x-component="Input"
......@@ -126,7 +150,7 @@ const AddInvoice: React.FC<AddAddressPropsType> = (props) => {
/>
<Field
x-rules={{
required: true,
required: taxNoRequired,
message: '请输入纳税号',
}}
title="纳税号"
......
......@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react'
import { Checkbox, Radio, Modal } from 'antd'
import AddInvoice from '../components/addInvoice'
import { PublicApi } from '@/services/api'
import { getAuth } from '@/utils/auth';
import { GetSettleAccountsInvoiceMessageListResponse } from '@/services/SettleApi'
import cx from 'classnames'
import styles from './index.less'
......@@ -26,8 +25,6 @@ const Invoice: React.FC<InvoicePropsType> = (props) => {
}, [])
const fetchInvoiceList = (init = false) => {
const { memberId } = getAuth() || {}
//@ts-ignore
PublicApi.getSettleAccountsInvoiceMessageList().then(res => {
if (res.code === 1000) {
setInvoiceList(res.data)
......@@ -40,7 +37,7 @@ const Invoice: React.FC<InvoicePropsType> = (props) => {
const initDefaultInvoice = (data: GetSettleAccountsInvoiceMessageListResponse) => {
let selectItem
for (let item of data) {
for (const item of data) {
if (item.isDefault === 1) {
selectItem = item
}
......@@ -54,7 +51,7 @@ const Invoice: React.FC<InvoicePropsType> = (props) => {
const handleSelect = (e: any) => {
setSelectKey(e.target.value)
let selectItem
for (let item of invoiceList) {
for (const item of invoiceList) {
if (item.id === e.target.value) {
selectItem = item
}
......@@ -98,9 +95,8 @@ const Invoice: React.FC<InvoicePropsType> = (props) => {
* @param item
*/
const handleSetDefault = (item) => {
let param = item
const param = item
param.isDefault = 1
//@ts-ignore
PublicApi.postSettleAccountsInvoiceMessageUpdate(param).then(res => {
if (res.code === 1000) {
fetchInvoiceList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment