Prechádzať zdrojové kódy

fix: MoneyInput组件处理以0开始的数字输入

lanjianrong 4 rokov pred
rodič
commit
6f5756ebed

+ 4 - 2
src/components/MoneyInput/index.tsx

@@ -52,9 +52,11 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
   }
   const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
     const val = e.target.value?.match(/^(\d*)\.?(\d{0,2})/)
-    const newInputVal = val && val[0] || ''
+    let newInputVal = val && val[0] || ''
+
 
     if (newInputVal) {
+      newInputVal = parseFloat(newInputVal).toString()
       // if (maxPrice && parseFloat(newInputVal) > maxPrice) {
       //   newInputVal = maxPrice.toString()
       // }
@@ -64,7 +66,7 @@ const MoneyInput: React.FC<MoneyInputProps> = (props) => {
 
       //   newInputVal = minPrice.toString()
       // }
-      const len = val && val[1].length || null
+      const len = val && parseFloat(val[1]) && parseFloat(val[1]).toString().length || null
 
       if (len && len > 12) {
         return

+ 2 - 2
src/pages/Contract/Content/Income/components/Modal/index.tsx

@@ -311,7 +311,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
             <Form.Item name="contractsId" hidden>
               <Input />
             </Form.Item>
-            <Form.Item name="time" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}日期`} rules={[ { required: true, message: '请选择回款日期' } ]}>
+            <Form.Item name="time" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}日期`} rules={[ { required: true, message: `请选择${contractType === ContractType.INCOME ? '回款' : '支付'}日期` } ]}>
               <DatePicker allowClear locale={locale} className="pi-width-100P" />
             </Form.Item>
             <Form.Item name="price" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}金额`} rules={[ { required: true, message: `请输入${contractType === ContractType.INCOME ? '回款' : '支付'}金额` }, () => ({
@@ -325,7 +325,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
               {/* <Input onChange={handleReturnPrice}/> */}
               <MoneyInput  />
             </Form.Item>
-            <Form.Item name="way" label="支付方式" rules={[ { required: true, message: '请选择回款方式' } ]}>
+            <Form.Item name="way" label={`${contractType === ContractType.INCOME ? '回款' : '支付'}方式`} rules={[ { required: true, message: `请选择${contractType === ContractType.INCOME ? '回款' : '支付'}方式` } ]}>
               <Select>{options}</Select>
             </Form.Item>
             <Form.Item name="remarks" label="备注">

+ 7 - 3
src/pages/Contract/Content/Income/components/Tabs/File/index.tsx

@@ -15,26 +15,30 @@ interface iFileState {
   createTime: string
 }
 
-const File: React.FC<{type: 'income' | 'expenditure'}> = ({ type }) => {
+const File: React.FC<{ type: 'income' | 'expenditure' }> = ({ type }) => {
   const [ data, setData ] = useState<Array<iFileState>>([])
   const [ total, setTotal ] = useState<number>(0)
   const [ id, setId ] = useState<string>('')
+  const [ pagination, setPagination ] = useState({
+    pageNo: 1,
+    pageSize: 7
+  })
   useEffect(() => {
     if (contractStore.contract.id) {
       if (contractStore.contract.id !== id) {
         setId(contractStore.contract.id)
         initData()
       } else if (contractStore.shouldUpdate && contractStore.shouldUpdate === '3') {
-        initData()
+        initData(pagination.pageNo, pagination.pageSize)
       }
       contractStore.shouldUpdate && (contractStore.changeUpdate(''))
     }
   }, [ contractStore.contract.id, contractStore.shouldUpdate ])
 
   const initData = async (pageNo: number = 1, pageSize: number = 7) => {
+    setPagination({ ...pagination, pageNo, pageSize })
     const { code = -1, data = [], total = 0 } = await apiGetFileList(type === 'income' ? consts.DATA_TYPE.CONTRACT_RETURN : consts.DATA_TYPE.CONTRACT_PAID, contractStore.contract.id, pageNo, pageSize)
     if (code === consts.RET_CODE.SUCCESS) {
-
       setData(data)
       setTotal(total)
     }