From 708b5027bba40d361cd5d266fb5e570e3ddaf005 Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Fri, 28 Oct 2022 18:03:10 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=E5=AE=A2=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=8695%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/customer.ts | 14 +++++ src/common/constant.ts | 4 +- .../components/tagPopup/index.tsx | 59 ++++++++++++++++--- src/pages/customerDetails/index.module.scss | 31 ++++++---- src/pages/customerDetails/index.tsx | 29 ++++++++- .../components/ChoseCity/index.tsx | 13 +++- .../components/Sort/index.tsx | 26 +++----- .../components/Tag/index.tsx | 28 ++++----- src/pages/customerManagement/index.tsx | 21 +++++-- 9 files changed, 157 insertions(+), 68 deletions(-) diff --git a/src/api/customer.ts b/src/api/customer.ts index a0aeed3..e594604 100644 --- a/src/api/customer.ts +++ b/src/api/customer.ts @@ -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", + }) } \ No newline at end of file diff --git a/src/common/constant.ts b/src/common/constant.ts index d19a317..988f7c3 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -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 // 生成密钥 diff --git a/src/pages/customerDetails/components/tagPopup/index.tsx b/src/pages/customerDetails/components/tagPopup/index.tsx index 19b9c57..17b19fa 100644 --- a/src/pages/customerDetails/components/tagPopup/index.tsx +++ b/src/pages/customerDetails/components/tagPopup/index.tsx @@ -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([{ id: -1, name: '不限' }, { id: 0, name: '大货' }, { id: 1, name: '剪版' }, { id: 2, name: '散剪' }, { id: 3, name: '新开发客户' }]) + const [modeList, setModeList] = useState([]) //选择标签 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 ( { props.handClose() }}> @@ -97,4 +138,4 @@ export default memo((props: Props) => { ) -}) \ No newline at end of file +})) \ No newline at end of file diff --git a/src/pages/customerDetails/index.module.scss b/src/pages/customerDetails/index.module.scss index 8730f64..95776f4 100644 --- a/src/pages/customerDetails/index.module.scss +++ b/src/pages/customerDetails/index.module.scss @@ -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; diff --git a/src/pages/customerDetails/index.tsx b/src/pages/customerDetails/index.tsx index 43d3f2f..49f4bd3 100644 --- a/src/pages/customerDetails/index.tsx +++ b/src/pages/customerDetails/index.tsx @@ -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() + 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 ( - {infoObj?.name?.[0]} + + {infoObj?.name?.[0]} + {infoObj?.name} @@ -70,7 +86,14 @@ export default () => { {infoObj?.purchaser_type_name || '暂无'} {infoObj?.sale_user_name || '暂无'} - setshowPopup(true)}> + { + infoObj?.label_list?.map(item => { + return ( + {item.label_name} + ) + }) + } + handShow()}> + 标签 @@ -105,7 +128,7 @@ export default () => { } - setshowPopup(false)}> + setshowPopup(false)} diseShow={() => getInfo()}> ) } \ No newline at end of file diff --git a/src/pages/customerManagement/components/ChoseCity/index.tsx b/src/pages/customerManagement/components/ChoseCity/index.tsx index bda88df..e506ab4 100644 --- a/src/pages/customerManagement/components/ChoseCity/index.tsx +++ b/src/pages/customerManagement/components/ChoseCity/index.tsx @@ -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) } diff --git a/src/pages/customerManagement/components/Sort/index.tsx b/src/pages/customerManagement/components/Sort/index.tsx index e01c98b..21c4b5a 100644 --- a/src/pages/customerManagement/components/Sort/index.tsx +++ b/src/pages/customerManagement/components/Sort/index.tsx @@ -19,30 +19,20 @@ export default memo((props: Props) => { const [list, setlist] = useState([ { - 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(-1) @@ -57,7 +47,7 @@ export default memo((props: Props) => { return item }) setlist([...list]) - props.handSort?.(it) + props.handSort?.(it.id) } diff --git a/src/pages/customerManagement/components/Tag/index.tsx b/src/pages/customerManagement/components/Tag/index.tsx index 0dd1a77..991c656 100644 --- a/src/pages/customerManagement/components/Tag/index.tsx +++ b/src/pages/customerManagement/components/Tag/index.tsx @@ -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([ - { - 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([]) const handItem = (it) => { list.map(item => { diff --git a/src/pages/customerManagement/index.tsx b/src/pages/customerManagement/index.tsx index dbe7d45..794d8cf 100644 --- a/src/pages/customerManagement/index.tsx +++ b/src/pages/customerManagement/index.tsx @@ -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 (