✨ feat:客户管理70%

This commit is contained in:
Haiyi
2022-10-25 17:39:37 +08:00
parent 9764f9f1bc
commit bc9e43f8ea
11 changed files with 270 additions and 122 deletions
+38 -7
View File
@@ -16,25 +16,52 @@ import {
mpsearchHistory
} from "@/api/order"
import { getFilterData } from '@/common/util'
import { ClientListApi } from '@/api/order'
export default memo(() => {
useEffect(() => {
getClient()
}, [])
const [clientObj, setclientObj] = useState({
clientId: -1,
clientName: ''
})
useDidShow(() => {
//获取客户
const [clienList, setclienList] = useState<any[]>([])
const { fetchData: listFetchData } = ClientListApi()
const getClient = async () => {
const res = await listFetchData({
page: 1, size: 10
})
setclientObj({
clientId: res.data.list.length > 0 ? res.data.list[0]?.id : -1,
clientName: res.data.list.length > 0 ? res.data.list[0]?.name : '',
})
setclienList([...res.data.list])
}
useDidShow(() => {
//获取选择的客户
let pages = Taro.getCurrentPages();
let currPage = pages[pages.length - 1]; // 获取当前页面
setclientObj({
clientId: currPage.data?.clientId,
clientName: currPage.data?.clientName,
})
//判断是否有跳转选择客户
if (currPage.data?.clientId && currPage.data?.clientId !== '') {
setclientObj({
clientId: currPage.data?.clientId,
clientName: currPage.data?.clientName,
})
}
//默认客户
if (currPage.data?.clientId == null) {
setclientObj({
clientId: clienList.length > 0 ? clienList[0]?.id : - 1,
clientName: clienList.length > 0 ? clienList[0]?.name : '',
})
}
})
@@ -298,6 +325,9 @@ export default memo(() => {
setGoodlist([...goodList])
}
//选择中后的值到输入框
const [defaultvalue, setdefaultvalue] = useState('')
//点击关键字搜索内容
const handItem = (item) => {
Taro.showLoading({
@@ -311,6 +341,7 @@ export default memo(() => {
Taro.hideLoading()
}
})
setdefaultvalue(item.search_key)
}
//点击返回文字
const handBack = () => {
@@ -319,7 +350,7 @@ export default memo(() => {
}
return (
<View className={styles.main}>
<Search placeholder='请输入搜索布料' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
<Search placeholder='请输入搜索布料' defaultValue={defaultvalue} showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
<View className={styles.cancelFont} onClick={() => back()}>取消</View>
</Search>
<View className={styles.line}></View>