feat:客户管理95%

This commit is contained in:
Haiyi 2022-10-28 18:03:10 +08:00
parent 41dd477f2e
commit 708b5027bb
9 changed files with 157 additions and 68 deletions

View File

@ -20,4 +20,18 @@ export const mppurchaserput = () => {
url: `/v1/mp/purchaser`,
method: "put",
})
}
//获取标签列表
export const mppurchaserlist = () => {
return useRequest({
url: `/v1/mp/purchaser/label/list`,
method: "get",
})
}
//保存标签
export const mppurchaserlabeladd = () => {
return useRequest({
url: `/v1/mp/purchaser/label/add`,
method: "post",
})
}

View File

@ -1,4 +1,4 @@
export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `http://192.168.0.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
@ -15,7 +15,7 @@ export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
// export const BASE_URL = `http://192.168.1.42:50002/lymarket` // 杰
// export const BASE_URL = `http://192.168.1.95:40001/lymarket` // 华
// export const BASE_URL = 'http://192.168.1.22:50002/lymarket' // 婷
export const BASE_URL = 'http://192.168.1.22:50002/lymarket' // 婷
// CDN
// 生成密钥

View File

@ -1,5 +1,5 @@
import { View, ScrollView, Button } from '@tarojs/components'
import React, { useCallback, memo, useEffect, useMemo, useRef, useState, ReactNode } from 'react'
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';
@ -8,17 +8,28 @@ import { formatPriceDiv, formatDateTime, 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"
interface Props {
showPopup: boolean,
handClose: () => void,
purchaser_id?: string | number
diseShow?: () => void
}
export default memo((props: Props) => {
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 [modeList, setModeList] = useState<any[]>([{ id: -1, name: '不限' }, { id: 0, name: '大货' }, { id: 1, name: '剪版' }, { id: 2, name: '散剪' }, { id: 3, name: '新开发客户' }])
const [modeList, setModeList] = useState<any[]>([])
//选择标签
const handCheckMode = (item) => {
modeList.map(it => {
@ -37,9 +48,34 @@ export default memo((props: Props) => {
})
setModeList([...modeList])
}
const handSure = () => {
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?.()
}
const isDisabled = useMemo(() => {
@ -56,6 +92,11 @@ export default memo((props: Props) => {
return arr.length
}, [modeList])
useImperativeHandle(ref, () => ({
modeList,
setModeList
}))
return (
<Popup title={'选择标签'} show={props.showPopup} onClose={() => { props.handClose() }}>
<ScrollView scrollY className={styles.scrollView}>
@ -97,4 +138,4 @@ export default memo((props: Props) => {
</View>
</Popup>
)
})
}))

View File

@ -12,22 +12,27 @@
background: #F6F7FB;
border-radius: 16px;
padding-bottom: 20px;
// margin-bottom: 16px;
.itemCile {
width: 78px;
height: 78px;
background: linear-gradient(337deg, #7BB7FF 0%, #4581FF 100%);
font-size: 32px;
font-weight: 500;
color: #FFFFFF;
text-align: center;
line-height: 78px;
border-radius: 50%;
margin-right: 32px;
margin-left: 32px;
// margin-bottom: 16px;
.leftSafe {
width: 142px;
.itemCile {
width: 78px;
height: 78px;
background: linear-gradient(337deg, #7BB7FF 0%, #4581FF 100%);
font-size: 32px;
font-weight: 500;
color: #FFFFFF;
text-align: center;
line-height: 78px;
border-radius: 50%;
margin-right: 32px;
margin-left: 32px;
}
}
.item_top_one {
.item_top_one_flex {
display: flex;

View File

@ -31,6 +31,7 @@ export default () => {
const res = await getDesc({ id: router.params.purchaser_id })
setinfoObj(res.data)
Taro.hideLoading()
setshowPopup(false)
}
//顶部栏
@ -57,11 +58,26 @@ export default () => {
}
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.itemCile}>{infoObj?.name?.[0]}</View>
<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>
@ -70,7 +86,14 @@ export default () => {
<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>
<View className={styles.item_tagAdd} onClick={() => setshowPopup(true)}>
{
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>
@ -105,7 +128,7 @@ export default () => {
<AddressList ref={AddressListRef} refresherEnabled={true} purchaser_id={router.params.purchaser_id as any} />
</View>
}
<TagPopup showPopup={showPopup} handClose={() => setshowPopup(false)}></TagPopup>
<TagPopup ref={TagPopupRef} showPopup={showPopup} handClose={() => setshowPopup(false)} diseShow={() => getInfo()}></TagPopup>
</View>
)
}

View File

@ -116,12 +116,23 @@ export default memo(forwardRef((props: Props, ref) => {
return it
})
setcityList([...cityList])
let provinceArr = list.filter(next => { return next.check })
let cityArr = cityList.filter(next => { return next.check })
if (item.check) {
choseCityArr.current.list.push(item)
} else {
deleteById(item.id, choseCityArr.current.list)
}
//将市区的全部不选后,该省的颜色不高亮
if (cityArr.length == 0) {
list.map(item => {
if (cityList[0]?.parent_id == item.id) {
item.check = false
}
return item
})
setlist([...list])
}
let provinceArr = list.filter(next => { return next.check })
props.handCity?.(provinceArr, choseCityArr.current.list)
}

View File

@ -19,30 +19,20 @@ export default memo((props: Props) => {
const [list, setlist] = useState<any[]>([
{
name: '下单时间升序',
id: 0,
name: '下单时间',
id: '1',
checked: false
},
{
name: '下单时间升序',
id: 1,
name: '创建时间',
id: '2',
checked: false
},
{
name: '下单时间升序',
id: 2,
name: '更新时间',
id: '3',
checked: false
},
{
name: '下单时间升序',
id: 3,
checked: false
},
{
name: '下单时间升序',
id: 4,
checked: false
},
}
])
const [currentValue, setCurrentValue] = useState<number>(-1)
@ -57,7 +47,7 @@ export default memo((props: Props) => {
return item
})
setlist([...list])
props.handSort?.(it)
props.handSort?.(it.id)
}

View File

@ -6,6 +6,7 @@ import Taro, { usePullDownRefresh, useRouter, useDidShow } from '@tarojs/taro';
import { alert } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
import DropDownItem from '@/components/dropDown-item'
import { mppurchaserlist } from "@/api/customer"
interface Props {
handType: (any) => void,
handTags: (any) => void
@ -35,23 +36,18 @@ export default memo((props: Props) => {
}
])
const [taglist, settaglist] = useState<any[]>([
{
name: '二批321312',
id: 0,
checked: false
},
{
name: '制衣厂312412',
id: 1,
checked: false
},
{
name: '布行54354',
id: 2,
checked: false
useEffect(() => {
getList()
}, [])
const { fetchData } = mppurchaserlist()
const getList = async () => {
const res = await fetchData()
if (res.data) {
settaglist([...res.data.list])
}
])
}
const [taglist, settaglist] = useState<any[]>([])
const handItem = (it) => {
list.map(item => {

View File

@ -27,6 +27,7 @@ export default () => {
name_phone_or_sale_user: string,
province_id: any[] | string,
city_id: any[] | string,
abstract_sort_key: string,
}
>({
page: 1,
@ -35,7 +36,8 @@ export default () => {
purchaser_type: '',
name_phone_or_sale_user: '',
province_id: '',
city_id: ''
city_id: '',
abstract_sort_key: ''
})
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
@ -85,8 +87,9 @@ export default () => {
}
//选择排序
const handSort = useCallback((val) => {
console.log(val, 456456)
const handSort = useCallback((e: string) => {
pageNum.current.page = 1
setSearchField((val) => ({ ...val, size: 10, abstract_sort_key: e }))
}, [])
//筛选城市
@ -108,14 +111,20 @@ export default () => {
//选择客户类型
const handType = useCallback((val) => {
val.filter(item => { return item.checked })
const arr = val.filter(item => { return item.checked })
pageNum.current.page = 1
setSearchField((val) => ({ ...val, size: 10, purchaser_type: val[0]?.id }))
setSearchField((val) => ({ ...val, size: 10, purchaser_type: arr[0]?.id }))
}, [])
//选择标签
const handTags = useCallback((val) => {
console.log(val, 899999)
const arr: number[] = []
const arrOne = val.filter(item => { return item.checked })
arrOne.forEach(item => {
arr.push(item.id)
})
pageNum.current.page = 1
setSearchField((val) => ({ ...val, size: 10, label_ids: arr.length === 0 ? '' : arr }))
}, [])
return (