🌈 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
+58 -60
View File
@@ -1,37 +1,37 @@
import { View, ScrollView } from '@tarojs/components'
import { useCallback, forwardRef, useEffect, useMemo, useRef, useState, memo, useImperativeHandle, } from 'react'
import Search from '@/components/search'
import styles from "./index.module.scss"
import classnames from "classnames";
import Popup from '@/components/popup'
import Goods from "@/components/goodsItem"
import BottomCustomer from "@/components/BottomCustomer"
import { ScrollView, View } from '@tarojs/components'
import { useDidShow } from '@tarojs/taro'
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import VirtualList from '@tarojs/components/virtual-list'
import DotLoading from "@/components/dotLoading"
import Divider from '../divider';
import { useDidShow } from '@tarojs/taro';
import Divider from '../divider'
import styles from './index.module.scss'
import Search from '@/components/search'
import Popup from '@/components/popup'
import Goods from '@/components/goodsItem'
import BottomCustomer from '@/components/BottomCustomer'
import DotLoading from '@/components/dotLoading'
interface prosObj {
showPopup?: false | true,
closePopup?: () => void,
goodList?: any[],
typeList?: any[],
handCheck?: (any) => void,
showPopup?: false | true
closePopup?: () => void
goodList?: any[]
typeList?: any[]
handCheck?: (any) => void
addNums?: (any) => void
reduceNums?: (any) => void
// oninputEvent?: (e: string, res: object) => void,
getSearchData: (any) => void,
handPlus: (any) => void,
handSure: () => void,
getSearchData: (any) => void
handPlus: (any) => void
handSure: () => void
obj?: {
code?: string,
name?: string,
code?: string
name?: string
},
modeFont: Number | string,
clientName: string,
clientId: Number,
hasBottom?: true | false, //默认不占位底部
}
modeFont: Number | string
clientName: string
clientId: Number
hasBottom?: true | false // 默认不占位底部
onBlur?: (e: string, res: object) => void
}
export default memo(forwardRef((props: prosObj, ref) => {
@@ -52,71 +52,69 @@ export default memo(forwardRef((props: prosObj, ref) => {
clientId = -1,
handSure,
hasBottom = true,
onBlur
onBlur,
} = props
const SearchRef = useRef<any>()
useImperativeHandle(ref, () => ({
Object: props,
typeList: typeList,
SearchRef
typeList,
SearchRef,
}))
//判断选择的类型
// 判断选择的类型
const showModefont = useMemo(() => {
const modeObj = typeList.filter(item => {
const modeObj = typeList.filter((item) => {
return item.checked
})
if (modeObj[0].id === 0) {
return '条'
} else {
}
else {
return '米'
}
}, [typeList])
//已选的颜色
// 已选的颜色
const selectTotal = useMemo(() => {
const totalArr = goodList.filter(item => {
const totalArr = goodList.filter((item) => {
return item.showInput
})
return totalArr.length
}, [goodList])
//选择的条数或者米数
// 选择的条数或者米数
const selectNums = useMemo(() => {
let arr: any = []
goodList.forEach(item => {
const arr: any = []
goodList.forEach((item) => {
if (item.showInput) {
arr.push(Number(item.nums))
}
})
let hate = sum(arr)
const hate = sum(arr)
return hate
}, [goodList])
// onInputEven={(e, item) => oninputEvent?.(e, item)}
function sum(arr) {
var s = 0;
for (var i = arr.length - 1; i >= 0; i--) {
s += arr[i];
let s = 0
for (let i = arr.length - 1; i >= 0; i--) {
s += arr[i]
}
return s;
return s
}
const rows = memo(({ id, index, style, data }: any) => {
let item = data[index]
const item = data[index]
return (
<>
<Goods
onBlur={(e, id) => onBlur?.(e, id)}
modeFont={(modeFont as number)}
handPlus={(item) => handPlus?.(item)}
handPlus={item => handPlus?.(item)}
value={item || {}}
clickAdd={(item) => addNums?.(item)}
clickAdd={item => addNums?.(item)}
clickReduce={(item) => { reduceNums?.(item) }}
goodList={goodList}
></Goods>
@@ -134,7 +132,7 @@ export default memo(forwardRef((props: prosObj, ref) => {
<View className={styles.selectFont}>
已选 1 种面料,{selectTotal} 个颜色,共 {selectNums} {showModefont}
</View>
<Divider direction='horizontal' customStyles={{ margin: '12px 0' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '12px 0' }}></Divider>
<View className={styles.typeFont}>布料类型</View>
<View className={styles.flexType}>
{typeList.map((item, index) => {
@@ -144,14 +142,15 @@ export default memo(forwardRef((props: prosObj, ref) => {
handCheck?.(item)
}}
key={index}
className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}>
className={classnames(item.checked ? styles.activemodeFont : styles.modeFont)}
>
{item.name}
</View>
)
})}
</View>
<View style={{ position: 'sticky', top: 0, background: 'white', zIndex: '9999' }}>
<Divider direction='horizontal' customStyles={{ margin: '12px 0' }}></Divider>
<Divider direction="horizontal" customStyles={{ margin: '12px 0' }}></Divider>
<View className={styles.flexFonts}>
<View className={styles.kingFont}>颜色分类({goodList?.length})</View>
<View className={styles.danwei}>
@@ -162,11 +161,11 @@ export default memo(forwardRef((props: prosObj, ref) => {
<Search
ref={SearchRef}
cursorSpacing={100}
placeholder='请输入搜索布料'
placeholder="请输入搜索布料"
showBtn={false}
changeOnSearch={getSearchData}
debounceTime={300}
adjustPosition={true}
adjustPosition
/>
</View>
</View>
@@ -176,11 +175,12 @@ export default memo(forwardRef((props: prosObj, ref) => {
<VirtualList
className={styles.scrollview}
height={300} /* 列表的高度 */
width='100%' /* 列表的宽度 */
width="100%" /* 列表的宽度 */
itemData={goodList} /* 渲染列表的数据 */
itemCount={goodList.length + 0} /* 渲染列表的长度 */
itemSize={100} /* 列表单项的高度 */
overscanCount={1}>
overscanCount={1}
>
{rows}
</VirtualList>
</View>
@@ -202,16 +202,14 @@ export default memo(forwardRef((props: prosObj, ref) => {
<BottomCustomer
clientName={clientName}
clientId={clientId}
isDisabled={selectTotal > 0 && clientName !== '' ? false : true}
isDisabled={!(selectTotal > 0 && clientName !== '')}
handSure={() => {
handSure()
}}></BottomCustomer>
}}
></BottomCustomer>
</View>
</View>
</ScrollView>
</Popup>
)
}))