🌈 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,38 +1,38 @@
import { View } from '@tarojs/components'
import React, { useCallback, memo, useEffect, useMemo, useRef, useState, ReactNode } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
import Taro, { usePullDownRefresh, useRouter, useDidShow } from '@tarojs/taro';
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import React, { ReactNode, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import { alert } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
import IconFont from '@/components/iconfont/iconfont'
interface Props {
title: string,
des: string | number,
isPhone?: boolean
isBorder?: boolean
title: string
des: string | number
isPhone?: boolean
isBorder?: boolean
}
export default memo((props: Props) => {
const {
isPhone = false,
isBorder = true,
} = props
const {
isPhone = false,
isBorder = true,
} = props
const handPhone = () => {
Taro.makePhoneCall({
phoneNumber: props.des as string
})
}
const handPhone = () => {
Taro.makePhoneCall({
phoneNumber: props.des as string,
})
}
return (
<View className={classnames(isBorder ? styles.mainItem : styles.mainItem_active)}>
<View className={styles.mainItem_left}>{props.title}</View>
<View className={classnames(isPhone ? styles.mainItem_active_right : styles.mainItem_right)}>{props.des}</View>
{
isPhone && <View className={styles.call} onClick={() => handPhone()}>拨打</View>
}
</View>
)
})
return (
<View className={classnames(isBorder ? styles.mainItem : styles.mainItem_active)}>
<View className={styles.mainItem_left}>{props.title}</View>
<View className={classnames(isPhone ? styles.mainItem_active_right : styles.mainItem_right)}>{props.des}</View>
{
isPhone && <View className={styles.call} onClick={() => handPhone()}>拨打</View>
}
</View>
)
})
@@ -1,32 +1,32 @@
import { View, Input, Button } from '@tarojs/components'
import { useCallback, useEffect, useMemo, useRef, useState, memo } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
import { Button, Input, View } from '@tarojs/components'
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
interface Props {
list: any[],
handChose?: (any) => void
list: any[]
handChose?: (any) => void
}
export default memo((props: Props) => {
const { list = [], handChose } = props
const { list = [], handChose } = props
return (
<View className={styles.flexBox}>
{
list.map((item, index) => {
return (
<View className={styles.itemBox} key={index} onClick={() => handChose?.(item)}>
<View
className={classnames(item.showBorder ? styles.activeItems : styles.itemFont)}
return (
<View className={styles.flexBox}>
{
list.map((item, index) => {
return (
<View className={styles.itemBox} key={index} onClick={() => handChose?.(item)}>
<View
className={classnames(item.showBorder ? styles.activeItems : styles.itemFont)}
>{item?.name}</View >
{
item.showBorder && <View className={styles.borderBox} ></View>
}
</View >
)
})
}
</View >
)
})
>{item?.name}</View >
{
item.showBorder && <View className={styles.borderBox} ></View>
}
</View >
)
})
}
</View >
)
})
@@ -1,141 +1,145 @@
import { View, ScrollView, Button } from '@tarojs/components'
import React, { useCallback, memo, useEffect, useMemo, useRef, useState, ReactNode, forwardRef, useImperativeHandle } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
import Taro, { usePullDownRefresh, useRouter, useDidShow } from '@tarojs/taro';
import { alert } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
import { Button, ScrollView, View } from '@tarojs/components'
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import React, { ReactNode, forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import { alert, goLink } from '@/common/common'
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
import IconFont from '@/components/iconfont/iconfont'
import Popup from '@/components/popup';
import { goLink } from '@/common/common'
import { mppurchaserlist, mppurchaserlabeladd } from "@/api/customer"
import Popup from '@/components/popup'
import { mppurchaserlabeladd, mppurchaserlist } from '@/api/customer'
interface Props {
showPopup: boolean,
handClose: () => void,
purchaser_id?: string | number
diseShow?: () => void
showPopup: boolean
handClose: () => void
purchaser_id?: string | number
diseShow?: () => void
}
export default memo(forwardRef((props: Props, ref) => {
const router = useRouter()
useEffect(() => {
getList()
}, [])
const { fetchData } = mppurchaserlist()
const getList = async () => {
const res = await fetchData()
if (res.data) {
setModeList([...res.data.list])
}
const router = useRouter()
useEffect(() => {
getList()
}, [])
const { fetchData } = mppurchaserlist()
const getList = async() => {
const res = await fetchData()
if (res.data) {
setModeList([...res.data.list])
}
}
//标签
const [modeList, setModeList] = useState<any[]>([])
//选择标签
const handCheckMode = (item) => {
modeList.map(it => {
if (it.id === item.id) {
it.checked = !it.checked
}
return it
})
setModeList([...modeList])
// 标签
const [modeList, setModeList] = useState<any[]>([])
// 选择标签
const handCheckMode = (item) => {
modeList.map((it) => {
if (it.id === item.id) {
it.checked = !it.checked
}
return it
})
setModeList([...modeList])
}
const handReset = () => {
modeList.map((it) => {
it.checked = false
return it
})
setModeList([...modeList])
}
const { fetchData: addFetch } = mppurchaserlabeladd()
const handSure = async() => {
const arr: any[] = []
const fltArr = modeList.filter((item) => { return item.checked })
fltArr.forEach((item) => {
arr.push({
label_id: item.id,
})
})
Taro.showLoading({
title: '请稍等...',
mask: true,
})
const res = await addFetch({ binding_label: arr, purchaser_id: Number(router.params.purchaser_id) })
if (res.msg == 'success') {
Taro.showToast({
icon: 'success',
title: '成功',
})
Taro.hideLoading()
}
const handReset = () => {
modeList.map(it => {
it.checked = false
return it
})
setModeList([...modeList])
else {
Taro.showToast({
icon: 'error',
title: res.msg,
})
Taro.hideLoading()
}
const { fetchData: addFetch } = mppurchaserlabeladd()
const handSure = async () => {
const arr: any[] = []
const fltArr = modeList.filter(item => { return item.checked })
fltArr.forEach(item => {
arr.push({
label_id: item.id
})
})
Taro.showLoading({
title: '请稍等...',
mask: true
})
const res = await addFetch({ binding_label: arr, purchaser_id: Number(router.params.purchaser_id) })
if (res.msg == 'success') {
Taro.showToast({
icon: 'success',
title: '成功'
})
Taro.hideLoading()
} else {
Taro.showToast({
icon: 'error',
title: res.msg
})
Taro.hideLoading()
}
props?.diseShow?.()
props?.diseShow?.()
}
const isDisabled = useMemo(() => {
const arr = modeList.filter((item) => { return item.checked })
if (arr.length) {
return false
}
else {
return true
}
}, [modeList])
const isDisabled = useMemo(() => {
let arr = modeList.filter(item => { return item.checked })
if (arr.length) {
return false
} else {
return true
}
}, [modeList])
const choseNums = useMemo(() => {
const arr = modeList.filter((item) => { return item.checked })
return arr.length
}, [modeList])
const choseNums = useMemo(() => {
let arr = modeList.filter(item => { return item.checked })
return arr.length
}, [modeList])
useImperativeHandle(ref, () => ({
modeList,
setModeList
}))
return (
<Popup title={'选择标签'} show={props.showPopup} onClose={() => { props.handClose() }}>
<ScrollView scrollY className={styles.scrollView}>
<View className={styles.thirdBox}>
<View className={styles.thirdTopfont}>自定义标签分组</View>
<View className={styles.flexModebox}>
{modeList.map((item, index) => {
return (
<View
onClick={() => {
handCheckMode(item)
}}
className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)}
key={index}>
{item.name}
</View>
)
})}
</View>
useImperativeHandle(ref, () => ({
modeList,
setModeList,
}))
return (
<Popup title="选择标签" show={props.showPopup} onClose={() => { props.handClose() }}>
<ScrollView scrollY className={styles.scrollView}>
<View className={styles.thirdBox}>
<View className={styles.thirdTopfont}>自定义标签分组</View>
<View className={styles.flexModebox}>
{modeList.map((item, index) => {
return (
<View
onClick={() => {
handCheckMode(item)
}}
className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)}
key={index}
>
{item.name}
</View>
</ScrollView>
<View className={styles.bottomBox}>
<Button
className={styles.resetBox}
onClick={() => {
handReset()
}}>
)
})}
</View>
</View>
</ScrollView>
<View className={styles.bottomBox}>
<Button
className={styles.resetBox}
onClick={() => {
handReset()
}}
>
重置
</Button>
<Button
className={classnames(isDisabled ? styles.button : styles.activeButton)}
disabled={isDisabled}
onClick={() => {
handSure?.()
}}>
</Button>
<Button
className={classnames(isDisabled ? styles.button : styles.activeButton)}
disabled={isDisabled}
onClick={() => {
handSure?.()
}}
>
保存({choseNums})
</Button>
</View>
</Popup>
)
}))
</Button>
</View>
</Popup>
)
}))
+1 -1
View File
@@ -1,3 +1,3 @@
export default {
navigationBarTitleText: '客户详情',
navigationBarTitleText: '客户详情',
}
+123 -122
View File
@@ -1,134 +1,135 @@
import { View } from '@tarojs/components'
import React, { useCallback, memo, useEffect, useMemo, useRef, useState, ReactNode } from 'react'
import styles from "./index.module.scss"
import classnames from "classnames";
import Taro, { usePullDownRefresh, useRouter, useDidShow } from '@tarojs/taro';
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
import React, { ReactNode, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
import Tabs from './components/tabs'
import Form from './components/form'
import TagPopup from './components/tagPopup'
import Popup from '@/components/popup'
import { debounce } from '@/common/util'
import { alert } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
import Tabs from "./components/tabs"
import Form from "./components/form"
import AddressList from "@/components/AddressList"
import TagPopup from './components/tagPopup';
import { goLink } from '@/common/common'
import { alert, goLink } from '@/common/common'
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
import AddressList from '@/components/AddressList'
import { mppurchaser } from '@/api/customer'
export default () => {
const router = useRouter()
const router = useRouter()
const [status, setstatus] = useState<number>(1)
const [status, setstatus] = useState<number>(1)
useDidShow(() => {
getInfo()
useDidShow(() => {
getInfo()
})
const [infoObj, setinfoObj] = useState<any>()
const { fetchData: getDesc } = mppurchaser()
const getInfo = async() => {
Taro.showLoading({
title: '请稍等...',
mask: true,
})
const [infoObj, setinfoObj] = useState<any>()
const { fetchData: getDesc } = mppurchaser()
const getInfo = async () => {
Taro.showLoading({
title: '请稍等...',
mask: true
})
const res = await getDesc({ id: router.params.purchaser_id })
setinfoObj(res.data)
Taro.hideLoading()
setshowPopup(false)
}
const res = await getDesc({ id: router.params.purchaser_id })
setinfoObj(res.data)
Taro.hideLoading()
setshowPopup(false)
}
//顶部栏
const AddressListRef = useRef<any>()
const [TarBarList, setTarBarList] = useState<any[]>([{ id: 1, name: '基础信息', showBorder: true }, { id: 2, name: '收货地址', showBorder: false }])
const handChose = (item) => {
TarBarList.map(it => {
if (it.id === item.id) {
it.showBorder = true
} else {
it.showBorder = false
}
setTarBarList([...TarBarList])
setstatus(item.id)
// pageNum.current.page = 1
// setOrderData(() => ({ list: [], total: 0 }))
// setSearchField((val) => ({ ...val, size: 10, status: item.id }))
})
if (item.id == 2) {
Taro.nextTick(() => {
AddressListRef.current?.getData()
})
// 顶部栏
const AddressListRef = useRef<any>()
const [TarBarList, setTarBarList] = useState<any[]>([{ id: 1, name: '基础信息', showBorder: true }, { id: 2, name: '收货地址', showBorder: false }])
const handChose = (item) => {
TarBarList.map((it) => {
if (it.id === item.id) {
it.showBorder = true
}
else {
it.showBorder = false
}
setTarBarList([...TarBarList])
setstatus(item.id)
// pageNum.current.page = 1
// setOrderData(() => ({ list: [], total: 0 }))
// setSearchField((val) => ({ ...val, size: 10, status: item.id }))
})
if (item.id == 2) {
Taro.nextTick(() => {
AddressListRef.current?.getData()
})
}
}
const [showPopup, setshowPopup] = useState(false)
const TagPopupRef = useRef<any>()
const handShow = () => {
TagPopupRef?.current?.modeList.map((it) => {
infoObj?.label_list?.forEach((item) => {
if (it.id == item.label_id) {
it.checked = true
}
}
const [showPopup, setshowPopup] = useState(false)
const TagPopupRef = useRef<any>()
const handShow = () => {
TagPopupRef?.current?.modeList.map(it => {
infoObj?.label_list?.forEach(item => {
if (it.id == item.label_id) {
it.checked = true
}
})
return it
})
TagPopupRef.current.setModeList([...TagPopupRef.current.modeList])
setshowPopup(true)
}
return (
<View className={styles.mainBox}>
<View className={styles.mainTop}>
<View className={styles.mainUser}>
<View className={styles.leftSafe}>
<View className={styles.itemCile}>{infoObj?.name?.[0]}</View>
</View>
<View className={styles.item_top_one}>
<View className={styles.item_top_one_flex}>
<View className={styles.itemName}>{infoObj?.name}</View>
<View className={styles.itemPhone}>{infoObj?.phone}</View>
</View>
<View className={styles.item_tag_box}>
<View className={styles.item_tagItem}>{infoObj?.purchaser_type_name || '暂无'}</View>
<View className={styles.item_tagItem}>{infoObj?.sale_user_name || '暂无'}</View>
{
infoObj?.label_list?.map(item => {
return (
<View className={styles.item_tagItem}>{item.label_name}</View>
)
})
}
<View className={styles.item_tagAdd} onClick={() => handShow()}>
<View className={styles.item_add}>+</View>
<View className={styles.item_add_font}>标签</View>
</View>
</View>
</View>
<View className={styles.pos} onClick={() => goLink('/pages/customerEditor/index?id=' + router.params.purchaser_id + '&type=edit')}>{'编辑 >'}</View>
</View>
<Tabs list={TarBarList} handChose={(item) => handChose?.(item)}></Tabs>
})
return it
})
TagPopupRef.current.setModeList([...TagPopupRef.current.modeList])
setshowPopup(true)
}
return (
<View className={styles.mainBox}>
<View className={styles.mainTop}>
<View className={styles.mainUser}>
<View className={styles.leftSafe}>
<View className={styles.itemCile}>{infoObj?.name?.[0]}</View>
</View>
<View className={styles.item_top_one}>
<View className={styles.item_top_one_flex}>
<View className={styles.itemName}>{infoObj?.name}</View>
<View className={styles.itemPhone}>{infoObj?.phone}</View>
</View>
{
status === 1 && <View className={styles.formBox}>
<Form title={'客户全称'} des={infoObj?.name || '暂无'} ></Form>
<Form title={'客户简称'} des={infoObj?.short_name || '暂无'} ></Form>
<Form title={'客户类型'} des={infoObj?.purchaser_type_name || '暂无'} ></Form>
<Form title={'联系人'} des={infoObj?.director || '暂无'} ></Form>
<Form title={'联系电话'} des={infoObj?.phone || '暂无'} isPhone></Form>
<Form title={'省市区'} des={infoObj?.province_name + infoObj?.city_name + infoObj?.district_name || '暂无'} ></Form>
<Form title={'详细地址'} des={infoObj?.address_detail || '暂无'} ></Form>
<Form title={'业务人员'} des={infoObj?.sale_user_name || '暂无'} ></Form>
<Form title={'客户来源'} des={infoObj?.purchaser_source_name || '暂无'} ></Form>
<Form title={'备注信息'} des={infoObj?.remark || '暂无'} ></Form>
<Form title={'下单时间'} des={formatDateTime(infoObj?.recent_order_time) || '暂无'} ></Form>
<Form title={'创建时间'} des={formatDateTime(infoObj?.create_time) || '暂无'} ></Form>
<Form title={'创建人'} des={infoObj?.creator || '暂无'} ></Form>
<Form title={'更新人'} des={infoObj?.update_user_name || '暂无'} ></Form>
<Form title={'更新时间'} des={formatDateTime(infoObj?.update_time) || '暂无'} isBorder={false}></Form>
</View>
}
{
status === 2 &&
<View className={styles.order_list}>
<AddressList ref={AddressListRef} refresherEnabled={true} purchaser_id={router.params.purchaser_id as any} />
</View>
}
<TagPopup ref={TagPopupRef} showPopup={showPopup} handClose={() => setshowPopup(false)} diseShow={() => getInfo()}></TagPopup>
<View className={styles.item_tag_box}>
<View className={styles.item_tagItem}>{infoObj?.purchaser_type_name || '暂无'}</View>
<View className={styles.item_tagItem}>{infoObj?.sale_user_name || '暂无'}</View>
{
infoObj?.label_list?.map((item) => {
return (
<View className={styles.item_tagItem}>{item.label_name}</View>
)
})
}
<View className={styles.item_tagAdd} onClick={() => handShow()}>
<View className={styles.item_add}>+</View>
<View className={styles.item_add_font}>标签</View>
</View>
</View>
</View>
<View className={styles.pos} onClick={() => goLink(`/pages/customerEditor/index?id=${router.params.purchaser_id}&type=edit`)}>{'编辑 >'}</View>
</View>
)
}
<Tabs list={TarBarList} handChose={item => handChose?.(item)}></Tabs>
</View>
{
status === 1 && <View className={styles.formBox}>
<Form title="客户全称" des={infoObj?.name || '暂无'} ></Form>
<Form title="客户简称" des={infoObj?.short_name || '暂无'} ></Form>
<Form title="客户类型" des={infoObj?.purchaser_type_name || '暂无'} ></Form>
<Form title="联系人" des={infoObj?.director || '暂无'} ></Form>
<Form title="联系电话" des={infoObj?.phone || '暂无'} isPhone></Form>
<Form title="省市区" des={infoObj?.province_name + infoObj?.city_name + infoObj?.district_name || '暂无'} ></Form>
<Form title="详细地址" des={infoObj?.address_detail || '暂无'} ></Form>
<Form title="业务人员" des={infoObj?.sale_user_name || '暂无'} ></Form>
<Form title="客户来源" des={infoObj?.purchaser_source_name || '暂无'} ></Form>
<Form title="备注信息" des={infoObj?.remark || '暂无'} ></Form>
<Form title="下单时间" des={formatDateTime(infoObj?.recent_order_time) || '暂无'} ></Form>
<Form title="创建时间" des={formatDateTime(infoObj?.create_time) || '暂无'} ></Form>
<Form title="创建人" des={infoObj?.creator || '暂无'} ></Form>
<Form title="更新人" des={infoObj?.update_user_name || '暂无'} ></Form>
<Form title="更新时间" des={formatDateTime(infoObj?.update_time) || '暂无'} isBorder={false}></Form>
</View>
}
{
status === 2
&& <View className={styles.order_list}>
<AddressList ref={AddressListRef} refresherEnabled purchaser_id={router.params.purchaser_id as any} />
</View>
}
<TagPopup ref={TagPopupRef} showPopup={showPopup} handClose={() => setshowPopup(false)} diseShow={() => getInfo()}></TagPopup>
</View>
)
}