🌈 style(eslint): add eslint rules

This commit is contained in:
xuan
2022-11-26 14:35:05 +08:00
parent f3aa20f049
commit 99a920975f
245 changed files with 14909 additions and 14349 deletions
@@ -1,102 +1,101 @@
import { ScrollView, View, Text, Input } from '@tarojs/components'
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import styles from './index.module.scss'
import classnames from 'classnames'
// import BottomBtns from '@/components/BottomBtns'
import { formatPriceDiv, formatDateTime } from '@/common/format'
import { Input, ScrollView, Text, View } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
// import BottomBtns from '@/components/BottomBtns'
import { formatDateTime, formatPriceDiv } from '@/common/format'
import IconFont from '@/components/iconfont/iconfont'
import UploadImage from '@/components/uploadImage'
interface Params {
title?: string, //传入的名称
require?: boolean, //是否显示必须选填的内容图标
isInput?: boolean, //是否显示输入框
inputValue?: string, //输入框的值
inputType?: any, //输入框类型
getInput?: (any) => void //输入框回调
showScan?: boolean, //是否显示扫描图标
placeholderFont?: string, //输入框默认文本
showMore?: boolean, // 是否显示更多图标
disabled?: boolean, // 是否输入框禁止
onlyRead?: boolean, //图片是否只读
showPic?: boolean, // 是否显示图片组件
getImageList?: (any) => void //上传图片回调
PicList?: [], //默认图片列表
styleNone?: boolean, //根据不同的栏目调整样式
getScan?: (any) => void, // 扫描
navTo?: () => void, //跳转选择
showSizeFont?: boolean, //展示金额的大写
bigMoney?: any, //展示的大写金额,
isOpen?: boolean //是否展开状态
title?: string // 传入的名称
require?: boolean // 是否显示必须选填的内容图标
isInput?: boolean // 是否显示输入框
inputValue?: string // 输入框的值
inputType?: any // 输入框类型
getInput?: (any) => void // 输入框回调
showScan?: boolean // 是否显示扫描图标
placeholderFont?: string // 输入框默认文本
showMore?: boolean // 是否显示更多图标
disabled?: boolean // 是否输入框禁止
onlyRead?: boolean // 图片是否只读
showPic?: boolean // 是否显示图片组件
getImageList?: (any) => void // 上传图片回调
PicList?: [] // 默认图片列表
styleNone?: boolean // 根据不同的栏目调整样式
getScan?: (any) => void // 扫描
navTo?: () => void // 跳转选择
showSizeFont?: boolean // 展示金额的大写
bigMoney?: any // 展示的大写金额,
isOpen?: boolean // 是否展开状态
}
export default memo((pros: Params) => {
return (
<>
return (
<>
{
pros.isOpen && <View className={styles.itemBox}
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}
>
<View className={styles.itemLeft}>
<View className={styles.finkFlex}>
<View className={styles.itemTitle}>{pros.title}</View>
{
pros.require && <Text className={styles.xing}>*</Text>
}
</View>
{
pros.isOpen && <View className={styles.itemBox}
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}>
<View className={styles.itemLeft}
>
<View className={styles.finkFlex}>
<View className={styles.itemTitle}>{pros.title}</View>
{
pros.require && <Text className={styles.xing}>*</Text>
}
</View>
{
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
}
</View>
{
pros.showPic &&
<View className={styles.bigPic}>
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
</View>
}
{
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
style={{
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`, alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
display: `${!pros.showSizeFont ? 'flex' : ''}`
}}
>
<View className={styles.rightFlex}>
{
pros.isInput && <Input
disabled={pros.disabled}
placeholder={pros.placeholderFont}
value={pros.inputValue}
className={styles.inputStyle}
type={pros.inputType}
placeholderStyle={styles.placeholderStyle}
onBlur={(e) => pros.getInput?.(e.detail.value)}
></Input>
}
</View>
{/* <View className={styles.iconFlex}></View> */}
{
pros.showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
}
{
pros.showScan && <View className={styles.shu}></View>
}
{
pros.showScan && <View onClick={(e) => pros.getScan?.(e)}><IconFont name={'icon-saomiao'} size={50} color={'#337FFF'}></IconFont></View>
}
{
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
}
</View>
}
</View>
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
}
</>
)
})
</View>
{
pros.showPic
&& <View className={styles.bigPic}>
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
</View>
}
{
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
style={{
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`,
alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
display: `${!pros.showSizeFont ? 'flex' : ''}`,
}}
>
<View className={styles.rightFlex}>
{
pros.isInput && <Input
disabled={pros.disabled}
placeholder={pros.placeholderFont}
value={pros.inputValue}
className={styles.inputStyle}
type={pros.inputType}
placeholderStyle={styles.placeholderStyle}
onBlur={e => pros.getInput?.(e.detail.value)}
></Input>
}
</View>
{/* <View className={styles.iconFlex}></View> */}
{
pros.showMore && <IconFont name="icon-chakanquanbukehu" size={50} color="#000000"></IconFont>
}
{
pros.showScan && <View className={styles.shu}></View>
}
{
pros.showScan && <View onClick={e => pros.getScan?.(e)}><IconFont name="icon-saomiao" size={50} color="#337FFF"></IconFont></View>
}
{
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
}
</View>
}
</View>
}
</>
)
})
+259 -261
View File
@@ -1,283 +1,281 @@
import { View, Input, Button, Textarea } from '@tarojs/components'
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
import { Button, Input, Textarea, View } from '@tarojs/components'
import Taro, { useDidShow } from '@tarojs/taro'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import Form from './components/form'
import {
mpcashManagementOrderpost, mpshouldCollectOrderpurchaser
} from "@/api/newCollection"
import { alert } from "@/common/common"
mpcashManagementOrderaccount, mpcashManagementOrderpost,
mpshouldCollectOrderpurchaser,
} from '@/api/newCollection'
import { alert } from '@/common/common'
import smallToBig from '@/common/money'
import IconFont from '@/components/iconfont/iconfont'
import { mpcashManagementOrderaccount } from '@/api/newCollection'
export default () => {
//获取选择的客户
let pages = Taro.getCurrentPages();
let currPage = pages[pages.length - 1]; // 获取当前页面
useDidShow(() => {
// 获取选择的客户
const pages = Taro.getCurrentPages()
const currPage = pages[pages.length - 1] // 获取当前页面
useDidShow(() => {
setQuery(e => ({
...e,
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id,
clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName,
bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId,
bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName,
}))
})
const [Query, setQuery] = useState<any>({})
setQuery((e) => ({
...e,
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id,
clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName,
bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId,
bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName,
}))
// 获取图片列表
const picUrl = useRef([])
const getImageList = useCallback((list) => {
picUrl.current = list
setQuery(val => ({ ...val, picList: list }))
}, [])
useEffect(() => {
getCuss()
}, [])
// 获取首个银行账号
const { fetchData: clitentFetch } = mpcashManagementOrderaccount()
const getCuss = async() => {
const res = await clitentFetch({ page: 1, size: 10 })
if (res.data) {
setQuery(val => ({ ...val, bankId: res.data.list[0].receiving_account_id, bankName: res.data.list[0].company_account }))
}
}
const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser()
// 扫描
const handScan = (e) => {
e.stopPropagation()
Taro.scanCode({
async success(res) {
const restult = await scanFetch({ order_no: res.result })
setQuery(val => ({ ...val, purchaser_id: restult.data.purchaser_id, clientName: restult.data.purchaser_name }))
},
fail(res) {
console.log(res)
},
})
}
const [Query, setQuery] = useState<any>({})
//获取图片列表
const picUrl = useRef([])
const getImageList = useCallback((list) => {
picUrl.current = list
setQuery((val) => ({ ...val, picList: list }))
}, [])
useEffect(() => {
getCuss()
}, [])
//获取首个银行账号
const { fetchData: clitentFetch } = mpcashManagementOrderaccount()
const getCuss = async () => {
let res = await clitentFetch({ page: 1, size: 10 })
if (res.data) {
setQuery((val) => ({ ...val, bankId: res.data.list[0].receiving_account_id, bankName: res.data.list[0].company_account }))
}
// 选择内容跳转
const navTo = (val) => {
if (val == 1) {
Taro.navigateTo({
url: `/pages/customerPage/index?clientId=${Query.purchaser_id}`,
})
}
const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser()
//扫描
const handScan = (e) => {
e.stopPropagation()
Taro.scanCode({
success: async function (res) {
const restult = await scanFetch({ order_no: res.result })
setQuery((val) => ({ ...val, purchaser_id: restult.data.purchaser_id, clientName: restult.data.purchaser_name }))
},
fail(res) {
console.log(res);
},
});
else {
if (typeof (Query.purchaser_id) == 'undefined') {
return alert.error('请先选择客户')
}
else {
Taro.navigateTo({
url: `/pages/accountPage/index?bankId?=${Query?.bankId}`,
})
}
}
}
//选择内容跳转
const navTo = (val) => {
if (val == 1) {
Taro.navigateTo({
url: '/pages/customerPage/index?clientId=' + Query.purchaser_id
// 判断是否可以提交
const isDisabled = useMemo(() => {
if (Query.clientName == ''
|| Query.money == ''
|| Query.picList?.length == 0
) {
return true
}
else {
return false
}
}, [Query])
// 收款金额回调
const getInput = (e) => {
setQuery({ ...Query, money: e })
}
useEffect(() => {
setQuery(Query)
}, [Query])
// useEffect(() => {
// if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
// setQuery({ ...Query, bankId: '', bankName: '' })
// }
// }, [Query])
// 备注信息
const [TextareaValue, setTextareaValue] = useState('')
const getDesc = (e) => {
setQuery({ ...Query, nums: e.length })
setTextareaValue(e)
}
// 取消返回
const handCancl = () => {
Taro.navigateBack({
delta: 1,
})
}
// 确认新建
const { fetchData: sureFetch } = mpcashManagementOrderpost()
const handSure = () => {
const query = {
payment_credential_url: picUrl.current,
purchaser_id: Query.purchaser_id,
receipt_amount: Number(Query.money) * 100,
receiving_account_id: Query.bankId,
remark: TextareaValue,
}
Taro.showModal({
content: '确认提交吗?',
confirmText: '确认',
cancelText: '取消',
async success(res) {
if (res.confirm) {
Taro.showLoading({
title: '请稍等...',
mask: true,
})
const res = await sureFetch(query)
if (res?.msg === 'success') {
Taro.showToast({
title: '成功',
})
} else {
if (typeof (Query.purchaser_id) == 'undefined') {
return alert.error('请先选择客户')
} else {
Taro.navigateTo({
url: '/pages/accountPage/index?bankId?=' + Query?.bankId
})
}
Taro.hideLoading()
handCancl()
}
else {
Taro.hideLoading()
Taro.showToast({
title: res?.msg,
icon: 'error',
})
}
}
},
})
}
const [IsOpen, setIsOpen] = useState(false)
const handOpen = () => {
if (IsOpen) {
setIsOpen(false)
}
//判断是否可以提交
const isDisabled = useMemo(() => {
if (Query.clientName == '' ||
Query.money == '' ||
Query.picList?.length == 0
) {
return true
} else {
return false
}
}, [Query])
//收款金额回调
const getInput = (e) => {
setQuery({ ...Query, money: e })
else {
setIsOpen(true)
}
}
useEffect(() => {
setQuery(Query)
}, [Query])
// useEffect(() => {
// if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
// setQuery({ ...Query, bankId: '', bankName: '' })
// }
// }, [Query])
//备注信息
const [TextareaValue, setTextareaValue] = useState('')
const getDesc = (e) => {
setQuery({ ...Query, nums: e.length })
setTextareaValue(e)
const openFont = useMemo(() => {
if (IsOpen) {
return '收起'
}
//取消返回
const handCancl = () => {
Taro.navigateBack({
delta: 1
})
else {
return '展开'
}
//确认新建
const { fetchData: sureFetch } = mpcashManagementOrderpost()
const handSure = () => {
const query = {
payment_credential_url: picUrl.current,
purchaser_id: Query.purchaser_id,
receipt_amount: Number(Query.money) * 100,
receiving_account_id: Query.bankId,
remark: TextareaValue
}
Taro.showModal({
content: "确认提交吗?",
confirmText: "确认",
cancelText: "取消",
success: async function (res) {
if (res.confirm) {
Taro.showLoading({
title: '请稍等...',
mask: true
})
const res = await sureFetch(query)
if (res?.msg === 'success') {
Taro.showToast({
title: '成功'
})
Taro.hideLoading()
handCancl()
} else {
Taro.hideLoading()
Taro.showToast({
title: res?.msg,
icon: 'error'
})
}
}
}
})
}
const [IsOpen, setIsOpen] = useState(false)
const handOpen = () => {
if (IsOpen) {
setIsOpen(false)
} else {
setIsOpen(true)
}
}
const openFont = useMemo(() => {
if (IsOpen) {
return '收起'
} else {
return '展开'
}
}, [IsOpen])
return (
<>
<View className={classnames(IsOpen === false ? styles.addBox : styles.activeBox)}>
<Form
isOpen={true}
title={'客户名称'}
require={true}
isInput={true}
disabled={true}
placeholderFont={'请选择客户信息'}
inputValue={Query.clientName}
showMore={true}
showScan={true}
styleNone={true}
showPic={false}
getScan={(e) => handScan(e)}
navTo={() => navTo(1)}
showSizeFont={false}
></Form>
<Form
isOpen={true}
title={'收款金额'}
require={true}
isInput={true}
disabled={false}
placeholderFont={'请输入金额'}
inputType={'digit'}
showMore={false}
inputValue={Query.money}
showScan={false}
styleNone={true}
showPic={false}
getInput={(e) => getInput(e)}
showSizeFont={true}
bigMoney={smallToBig(typeof (Query.money) == 'undefined' ? 0 : Query.money)}
></Form>
<Form
isOpen={true}
styleNone={false}
title={'收款凭证'}
require={true}
isInput={false}
showMore={false}
showScan={false}
showPic={true}
getImageList={(list) => getImageList(list)}
showSizeFont={false}
></Form>
<Form
isOpen={IsOpen}
title={'收款账户'}
require={false}
isInput={true}
disabled={true}
placeholderFont={'请选择银行账号'}
inputValue={Query.bankName}
showMore={true}
showScan={false}
styleNone={true}
showPic={false}
navTo={() => navTo(2)}
showSizeFont={false}
></Form>
{
IsOpen && <View className={styles.textAreaBox}>
<View className={styles.textAreaLeft}>备注信息</View>
<View className={styles.textAreaRight}>
<Textarea
style={{ width: '70%' }}
onInput={(e) => getDesc(e.detail.value)}
value={TextareaValue}
placeholderStyle='font-size: 28rpx;font-weight: 400;'
maxlength={64}
placeholder={'请填写备注信息'}
></Textarea>
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
</View>
</View>
}
<View className={styles.openBox} onClick={() => handOpen()}>
<View className={styles.openFont}>{openFont}</View>
{
!IsOpen && <IconFont name={'icon-zhankai'} size={30} color={'#337FFF'} ></IconFont>
}
{
IsOpen && <IconFont name={'icon-shouqi'} size={30} color={'#337FFF'} ></IconFont>
}
</View>
</View >
<View className={styles.safeBox}> </View>
<View className={styles.bottomBox}>
<Button className={styles.resetBox} onClick={() => { handCancl() }}> 取消</Button >
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 提交</Button >
}, [IsOpen])
return (
<>
<View className={classnames(IsOpen === false ? styles.addBox : styles.activeBox)}>
<Form
isOpen
title="客户名称"
require
isInput
disabled
placeholderFont="请选择客户信息"
inputValue={Query.clientName}
showMore
showScan
styleNone
showPic={false}
getScan={e => handScan(e)}
navTo={() => navTo(1)}
showSizeFont={false}
></Form>
<Form
isOpen
title="收款金额"
require
isInput
disabled={false}
placeholderFont="请输入金额"
inputType="digit"
showMore={false}
inputValue={Query.money}
showScan={false}
styleNone
showPic={false}
getInput={e => getInput(e)}
showSizeFont
bigMoney={smallToBig(typeof (Query.money) == 'undefined' ? 0 : Query.money)}
></Form>
<Form
isOpen
styleNone={false}
title="收款凭证"
require
isInput={false}
showMore={false}
showScan={false}
showPic
getImageList={list => getImageList(list)}
showSizeFont={false}
></Form>
<Form
isOpen={IsOpen}
title="收款账户"
require={false}
isInput
disabled
placeholderFont="请选择银行账号"
inputValue={Query.bankName}
showMore
showScan={false}
styleNone
showPic={false}
navTo={() => navTo(2)}
showSizeFont={false}
></Form>
{
IsOpen && <View className={styles.textAreaBox}>
<View className={styles.textAreaLeft}>备注信息</View>
<View className={styles.textAreaRight}>
<Textarea
style={{ width: '70%' }}
onInput={e => getDesc(e.detail.value)}
value={TextareaValue}
placeholderStyle="font-size: 28rpx;font-weight: 400;"
maxlength={64}
placeholder="请填写备注信息"
></Textarea>
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
</View>
</>
)
}
</View>
}
<View className={styles.openBox} onClick={() => handOpen()}>
<View className={styles.openFont}>{openFont}</View>
{
!IsOpen && <IconFont name="icon-zhankai" size={30} color="#337FFF" ></IconFont>
}
{
IsOpen && <IconFont name="icon-shouqi" size={30} color="#337FFF" ></IconFont>
}
</View>
</View >
<View className={styles.safeBox}> </View>
<View className={styles.bottomBox}>
<Button className={styles.resetBox} onClick={() => { handCancl() }}> 取消</Button >
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 提交</Button >
</View>
</>
)
}