🌈 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
View File
@@ -178,4 +178,3 @@ export const ReturnGoodsOrderForm = {
},
},
}
+99 -86
View File
@@ -1,5 +1,11 @@
import { Text, View } from '@tarojs/components'
import classnames from 'classnames'
import dayjs from 'dayjs'
import { memo, useCallback, useEffect, useRef, useState } from 'react'
import styles from './index.module.scss'
import { ArrangedForm, OrderForm, PaymentAmountForm, ReturnGoodsOrderForm } from './config'
import { ProductRankApi, PurchaserRankApi, SaleOrderDataFormApi, SalesmanRankApi } from '@/api/statistic/saleStatistic'
import { formatPriceDiv, setPriceUnit, dataUnit } from '@/common/format'
import { dataUnit, formatPriceDiv, setPriceUnit } from '@/common/format'
import { getFilterData } from '@/common/util'
import Cell from '@/components/cell'
import Divider from '@/components/Divider'
@@ -8,19 +14,15 @@ import LayoutBlock from '@/components/layoutBlock'
import SelectMarketingDepartment from '@/components/SelectMarketingDepartment'
import SelectSaleRankingIndicators from '@/components/SelectSaleRankingIndicators'
import SelectSaleType from '@/components/SelectSaleType'
import SelectTimePicker, { ChangedValue } from '@/components/SelectTimePicker'
import Table, { TablePropsType } from '@/components/table'
import type { ChangedValue } from '@/components/SelectTimePicker'
import SelectTimePicker from '@/components/SelectTimePicker'
import type { TablePropsType } from '@/components/table'
import Table from '@/components/table'
import ToolTip from '@/components/toolTips'
import { View, Text } from '@tarojs/components'
import classnames from 'classnames'
import dayjs from 'dayjs'
import { memo, useCallback, useEffect, useRef, useState } from 'react'
import styles from './index.module.scss'
import { OrderForm, ArrangedForm, PaymentAmountForm, ReturnGoodsOrderForm } from './config'
import IconText from '@/components/iconText'
import SelectGroup from '@/components/SelectGroup'
//处理金额(后端单位分,转元)
// 处理金额(后端单位分,转元)
const priceformat = (val: number) => {
return dataUnit(val / 100)
}
@@ -28,7 +30,7 @@ const priceformat = (val: number) => {
const defaultLimit = 10
const FilterTimeOptions = {
'0': {
0: {
name: '今天',
date_min: `${dayjs(new Date())
.add(0, 'day')
@@ -37,7 +39,7 @@ const FilterTimeOptions = {
.add(1, 'day')
.format('YYYY-MM-DD')} 00:00:00`,
},
'1': {
1: {
name: '昨日',
date_min: `${dayjs(new Date())
.add(-1, 'day')
@@ -46,7 +48,7 @@ const FilterTimeOptions = {
.add(0, 'day')
.format('YYYY-MM-DD')} 00:00:00`,
},
'2': {
2: {
name: '近7日',
date_min: `${dayjs(new Date())
.add(-7, 'day')
@@ -55,7 +57,7 @@ const FilterTimeOptions = {
.add(0, 'day')
.format('YYYY-MM-DD')} 00:00:00`,
},
'3': {
3: {
name: '近30日',
date_min: `${dayjs(new Date())
.add(-30, 'day')
@@ -64,7 +66,7 @@ const FilterTimeOptions = {
.add(0, 'day')
.format('YYYY-MM-DD')} 00:00:00`,
},
'4': {
4: {
name: '近90日',
date_min: `${dayjs(new Date())
.add(-90, 'day')
@@ -90,7 +92,7 @@ const saleStatistic = () => {
getData()
}, [saleType, saleDepartmentId, dateRange])
const getData = async () => {
const getData = async() => {
const res = await fetchData(
getFilterData({
sale_type: saleType,
@@ -142,7 +144,8 @@ const saleStatistic = () => {
// 全部
if (saleType === -1) {
setSaleType(null)
} else {
}
else {
setSaleType(saleType)
}
}, [])
@@ -152,7 +155,8 @@ const saleStatistic = () => {
// 全部
if (department === -1) {
setSaleDepartmentId(null)
} else {
}
else {
setSaleDepartmentId(department)
}
}, [])
@@ -165,22 +169,22 @@ const saleStatistic = () => {
<View className={styles.saleStatistic}>
<View className={styles['saleStatistic--filterBar']}>
<SelectGroup>
<SelectSaleType onChange={onChangeSaleType} defaultValue={-1} onCloseOverlay={()=>true} ref={selectSaleTypeRef}></SelectSaleType>
<SelectMarketingDepartment onChange={onChangeDepartment} onCloseOverlay={()=>true} ref={selectMarketingDepartmentRef}></SelectMarketingDepartment>
<SelectTimePicker onChange={onChangeTimePicker} onCloseOverlay={()=>true} defaultValue='0' timeOptions={FilterTimeOptions} ref={selectTimePickerRef}></SelectTimePicker>
<SelectSaleType onChange={onChangeSaleType} defaultValue={-1} onCloseOverlay={() => true} ref={selectSaleTypeRef}></SelectSaleType>
<SelectMarketingDepartment onChange={onChangeDepartment} onCloseOverlay={() => true} ref={selectMarketingDepartmentRef}></SelectMarketingDepartment>
<SelectTimePicker onChange={onChangeTimePicker} onCloseOverlay={() => true} defaultValue="0" timeOptions={FilterTimeOptions} ref={selectTimePickerRef}></SelectTimePicker>
</SelectGroup>
</View>
<View className={styles['saleStatistic--content']}>
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
<View className='flex-row items-center'>
<IconText iconName='icon-guanlidingdan' iconSize={32} svg text='订单' textClassName={styles.title}></IconText>
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
<View className="flex-row items-center">
<IconText iconName="icon-guanlidingdan" iconSize={32} svg text="订单" textClassName={styles.title}></IconText>
</View>
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<View className={styles.totalSummary}>
<ToolTip placement='top' content={OrderForm.summary.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top" content={OrderForm.summary.tips}>
<View className="flex-row items-center">
<Text className={styles['totalSummary--title']}>{OrderForm.summary.summaryTitle}</Text>
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
</View>
</ToolTip>
<View className={classnames(styles['totalSummary--current'], OrderForm.summary.value.cls)}>{OrderForm.summary.value.num}</View>
@@ -194,29 +198,30 @@ const saleStatistic = () => {
<Cell
key={key}
title={
<ToolTip placement='top-start' content={value.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top-start" content={value.tips}>
<View className="flex-row items-center">
<Text className={styles.title}>{value.cellTitle}</Text>
<Iconfont name='icon-tishi' size={36}></Iconfont>
<Iconfont name="icon-tishi" size={36}></Iconfont>
</View>
</ToolTip>
}
desc={value.value.num}
customDescClassName={value.value.cls}
customClassName={styles['cell-desc']}></Cell>
customClassName={styles['cell-desc']}
></Cell>
)
})}
</LayoutBlock>
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
<View className='flex-row items-center'>
<IconText iconName='icon-guanlidingdan' iconSize={32} svg text='配布' textClassName={styles.title}></IconText>
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
<View className="flex-row items-center">
<IconText iconName="icon-guanlidingdan" iconSize={32} svg text="配布" textClassName={styles.title}></IconText>
</View>
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<View className={styles.totalSummary}>
<ToolTip placement='top' content={ArrangedForm.summary.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top" content={ArrangedForm.summary.tips}>
<View className="flex-row items-center">
<Text className={styles['totalSummary--title']}>{ArrangedForm.summary.summaryTitle}</Text>
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
</View>
</ToolTip>
<View className={classnames(styles['totalSummary--current'], ArrangedForm.summary.value.cls)}>{ArrangedForm.summary.value.num}</View>
@@ -230,31 +235,32 @@ const saleStatistic = () => {
<Cell
key={key}
title={
<ToolTip placement='top-start' content={value.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top-start" content={value.tips}>
<View className="flex-row items-center">
<Text className={styles.title}>{value.cellTitle}</Text>
<Iconfont name='icon-tishi' size={36}></Iconfont>
<Iconfont name="icon-tishi" size={36}></Iconfont>
</View>
</ToolTip>
}
desc={value.value.num}
customDescClassName={value.value.cls}
customClassName={styles['cell-desc']}></Cell>
{((index + 1) % 3 === 0 && (index + 1) !== 9) ? <Divider direction='horizontal' customStyles={{ margin: '10rpx 0' }}></Divider> : null}
customClassName={styles['cell-desc']}
></Cell>
{((index + 1) % 3 === 0 && (index + 1) !== 9) ? <Divider direction="horizontal" customStyles={{ margin: '10rpx 0' }}></Divider> : null}
</>
)
})}
</LayoutBlock>
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
<View className='flex-row items-center'>
<IconText iconName='icon-daikuan' iconSize={32} svg text='货款' textClassName={styles.title}></IconText>
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
<View className="flex-row items-center">
<IconText iconName="icon-daikuan" iconSize={32} svg text="货款" textClassName={styles.title}></IconText>
</View>
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<View className={styles.totalSummary}>
<ToolTip placement='top' content={PaymentAmountForm.summary.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top" content={PaymentAmountForm.summary.tips}>
<View className="flex-row items-center">
<Text className={styles['totalSummary--title']}>{PaymentAmountForm.summary.summaryTitle}</Text>
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
</View>
</ToolTip>
<View className={classnames(styles['totalSummary--current'], PaymentAmountForm.summary.value.cls)}>{PaymentAmountForm.summary.value.num}</View>
@@ -264,29 +270,30 @@ const saleStatistic = () => {
<Cell
key={key}
title={
<ToolTip placement='top-start' content={value.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top-start" content={value.tips}>
<View className="flex-row items-center">
<Text className={styles.title}>{value.cellTitle}</Text>
<Iconfont name='icon-tishi' size={36}></Iconfont>
<Iconfont name="icon-tishi" size={36}></Iconfont>
</View>
</ToolTip>
}
desc={value.value.num}
customDescClassName={value.value.cls}
customClassName={styles['cell-desc']}></Cell>
customClassName={styles['cell-desc']}
></Cell>
)
})}
</LayoutBlock>
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
<View className='flex-row items-center'>
<IconText iconName='icon-tuikuan' iconSize={32} svg text='退货' textClassName={styles.title}></IconText>
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
<View className="flex-row items-center">
<IconText iconName="icon-tuikuan" iconSize={32} svg text="退货" textClassName={styles.title}></IconText>
</View>
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
<View className={styles.totalSummary}>
<ToolTip placement='top' content={ReturnGoodsOrderForm.summary.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top" content={ReturnGoodsOrderForm.summary.tips}>
<View className="flex-row items-center">
<Text className={styles['totalSummary--title']}>{ReturnGoodsOrderForm.summary.summaryTitle}</Text>
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
</View>
</ToolTip>
<View className={classnames(styles['totalSummary--current'], ReturnGoodsOrderForm.summary.value.cls)}>
@@ -298,16 +305,17 @@ const saleStatistic = () => {
<Cell
key={key}
title={
<ToolTip placement='top-start' content={value.tips}>
<View className='flex-row items-center'>
<ToolTip placement="top-start" content={value.tips}>
<View className="flex-row items-center">
<Text className={styles.title}>{value.cellTitle}</Text>
<Iconfont name='icon-tishi' size={36}></Iconfont>
<Iconfont name="icon-tishi" size={36}></Iconfont>
</View>
</ToolTip>
}
desc={value.value.num}
customDescClassName={value.value.cls}
customClassName={styles['cell-desc']}></Cell>
customClassName={styles['cell-desc']}
></Cell>
)
})}
</LayoutBlock>
@@ -317,9 +325,9 @@ const saleStatistic = () => {
)
}
//需要传进来的数据示例
// 需要传进来的数据示例
//需要传进来的表头数据示例
// 需要传进来的表头数据示例
const productRankingColumns = [
{
key: 'index',
@@ -352,7 +360,7 @@ const productRankingColumns = [
},
]
//需要传进来的表头数据示例
// 需要传进来的表头数据示例
const purchaserRankingColumns = [
{
key: 'index',
@@ -385,7 +393,7 @@ const purchaserRankingColumns = [
},
]
//需要传进来的表头数据示例
// 需要传进来的表头数据示例
const salesmanRankingColumns = [
{
key: 'index',
@@ -440,14 +448,14 @@ interface RankingBlockPropsType {
date_max?: string
}
// 销售排行
const RankingBlock = memo<RankingBlockPropsType>(props => {
const RankingBlock = memo<RankingBlockPropsType>((props) => {
const { saleType, saleDepartmentId, date_min, date_max } = props
const { fetchData: fetchProductRank } = ProductRankApi()
const { fetchData: fetchPurchaserRank } = PurchaserRankApi()
const { fetchData: fetchSalesmanRank } = SalesmanRankApi()
let [limit, setLimit] = useState(defaultLimit)
const [limit, setLimit] = useState(defaultLimit)
const [indicator, setIndicator] = useState<number | null>(null)
@@ -456,22 +464,23 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
console.log('indicators', indicators)
if (indicators === -1) {
setIndicator(null)
} else {
}
else {
setIndicator(indicators)
}
}, [])
const [currentKey, setCurrentKey] = useState(tabsConfig[0].key)
const handleClickTab = event => {
const handleClickTab = (event) => {
const key = event.target.dataset.key
if (key === currentKey) return
if (key === currentKey) { return }
setCurrentKey(key)
setLimit(defaultLimit)
}
const getData = useCallback(
async (tabKey: number) => {
async(tabKey: number) => {
let res: any
const payload = {
limit,
@@ -483,9 +492,11 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
}
if (tabKey === 0) {
res = await fetchProductRank(getFilterData(payload))
} else if (tabKey === 1) {
}
else if (tabKey === 1) {
res = await fetchPurchaserRank(getFilterData(payload))
} else {
}
else {
res = await fetchSalesmanRank(getFilterData(payload))
}
if (res.data) {
@@ -504,7 +515,8 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
total: res.data.total,
},
}))
} else if (tabKey === 1) {
}
else if (tabKey === 1) {
setCurrentTable(() => ({
columns: purchaserRankingColumns,
dataSource: {
@@ -518,7 +530,8 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
total: res.data.total,
},
}))
} else {
}
else {
setCurrentTable(() => ({
columns: salesmanRankingColumns,
dataSource: {
@@ -555,20 +568,20 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
return (
<>
{/* 销售排行 */}
<LayoutBlock circle flexDirection='col' customStyle={{ padding: 0 }}>
<LayoutBlock circle flexDirection="col" customStyle={{ padding: 0 }}>
<View className={classnames(styles.rankingIndicatorTitle, 'flex-row justify-between')} style={{ position: 'relative' }}>
<View className='flex-row items-center'>
<Iconfont name='icon-paiming' size={32}></Iconfont>
<View className="flex-row items-center">
<Iconfont name="icon-paiming" size={32}></Iconfont>
<Text className={styles.title}>销售排行</Text>
</View>
<View style={{ width: '90px' }}>
<SelectSaleRankingIndicators onChange={onChangeIndicators} dropDownStyle={{padding: '16rpx 0'}}></SelectSaleRankingIndicators>
<SelectSaleRankingIndicators onChange={onChangeIndicators} dropDownStyle={{ padding: '16rpx 0' }}></SelectSaleRankingIndicators>
</View>
</View>
<View style={{ padding: '0 32rpx' }}>
<Divider direction='horizontal' customStyles={{ margin: '10rpx 0 20rpx 0' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '10rpx 0 20rpx 0' }}></Divider>
<View className={styles.rankingTabs} onClick={handleClickTab}>
{tabsConfig.map(item => {
{tabsConfig.map((item) => {
return (
<View data-key={item.key} className={classnames(styles.rankingTab, item.key === currentKey ? styles.active : '')} key={item.key}>
{item.name}