🌈 style(eslint): add eslint rules
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '收款账户',
|
||||
navigationBarTitleText: '收款账户',
|
||||
}
|
||||
|
||||
+128
-132
@@ -1,152 +1,148 @@
|
||||
import { View, ScrollView, Image, 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, Image, Input, ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Search from '@/components/search'
|
||||
import { mpcashManagementOrderaccount } from '@/api/newCollection'
|
||||
import { useDidShow } from '@tarojs/taro';
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const [search, setSearch] = useState({
|
||||
search_name: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = mpcashManagementOrderaccount()
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
bankId: null,
|
||||
bankName: '',
|
||||
})
|
||||
|
||||
const [search, setSearch] = useState({
|
||||
search_name: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch(e => ({ ...e, search_name: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.search_name === '') {
|
||||
setSearch(e => ({ ...e, search_name: null }))
|
||||
}
|
||||
if (search.search_name !== '') { getCuss() }
|
||||
}, [search])
|
||||
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch(e => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
const getCuss = async() => {
|
||||
const res = await clitentFetch({ search_name: search.search_name === null ? '' : search.search_name, page: search.page, size: search.size })
|
||||
if (router?.params.bankId) {
|
||||
res.data.list.map((item) => {
|
||||
if (item.receiving_account_id == router?.params.bankId) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
// 选择业务员
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map((it) => {
|
||||
if (item.receiving_account_id === it.receiving_account_id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = mpcashManagementOrderaccount()
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
bankId: null,
|
||||
bankName: ''
|
||||
const pages = Taro.getCurrentPages() // 获取当前的页面栈
|
||||
const prevPage = pages[pages.length - 2]
|
||||
prevPage.setData({ // 设置上一个页面的值
|
||||
bankId: item.receiving_account_id,
|
||||
bankName: item.company_account,
|
||||
})
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch((e) => ({ ...e, search_name: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.search_name === '') {
|
||||
setSearch((e) => ({ ...e, search_name: null }))
|
||||
}
|
||||
if (search.search_name !== '') getCuss()
|
||||
}, [search])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch((e) => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch((val) => ({ ...val, size: 10 }))
|
||||
setClientlist(e => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
setclientObj(item)
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.bankId !== null) {
|
||||
setclientObj(clientObj)
|
||||
}
|
||||
const getCuss = async () => {
|
||||
let res = await clitentFetch({ search_name: search.search_name === null ? '' : search.search_name, page: search.page, size: search.size })
|
||||
if (router?.params.bankId) {
|
||||
res.data.list.map(item => {
|
||||
if (item.receiving_account_id == router?.params.bankId) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
//选择业务员
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map(it => {
|
||||
if (item.receiving_account_id === it.receiving_account_id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({ //设置上一个页面的值
|
||||
bankId: item.receiving_account_id,
|
||||
bankName: item.company_account
|
||||
});
|
||||
setClientlist((e) => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
setclientObj(item)
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.bankId !== null) {
|
||||
setclientObj(clientObj)
|
||||
}
|
||||
// else {
|
||||
// let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
// let prevPage = pages[pages.length - 2];
|
||||
// prevPage.setData({ //设置上一个页面的值
|
||||
// bankId: '',
|
||||
// bankName: '',
|
||||
// });
|
||||
// }
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
{/* <View className={styles.searchBox}>
|
||||
// else {
|
||||
// let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
// let prevPage = pages[pages.length - 2];
|
||||
// prevPage.setData({ //设置上一个页面的值
|
||||
// bankId: '',
|
||||
// bankName: '',
|
||||
// });
|
||||
// }
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
{/* <View className={styles.searchBox}>
|
||||
<View className={styles.two}>
|
||||
<Search placeholder='请输入收款账户' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
|
||||
</View> */}
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.company_account}</View>
|
||||
{/* <View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.company_account}</View>
|
||||
{/* <View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.woker}>{item.company_account}</View> */}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
|
||||
</View>
|
||||
)
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '新增地址',
|
||||
}
|
||||
navigationBarTitleText: '新增地址',
|
||||
}
|
||||
|
||||
+319
-321
@@ -1,338 +1,336 @@
|
||||
import { alert } from "@/common/common"
|
||||
import Address from "@/components/address"
|
||||
import FromList from "@/components/FromList"
|
||||
import { Button, Input, Text, Textarea, View, Switch } from "@tarojs/components"
|
||||
import Taro, { setNavigationBarTitle, useDidShow, useRouter } from "@tarojs/taro"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import { mppurchaseraddress, mppurchaseraddressget, mppurchaseraddressput, mppurchaseraddressdelect } from '@/api/addressList'
|
||||
import { Button, Input, Switch, Text, Textarea, View } from '@tarojs/components'
|
||||
import Taro, { setNavigationBarTitle, useDidShow, useRouter } from '@tarojs/taro'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import FromList from '@/components/FromList'
|
||||
import Address from '@/components/address'
|
||||
import { alert } from '@/common/common'
|
||||
import { mppurchaseraddress, mppurchaseraddressdelect, mppurchaseraddressget, mppurchaseraddressput } from '@/api/addressList'
|
||||
import { getFilterData } from '@/common/util'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
export default () => {
|
||||
const [itemList, setItemList] = useState<any[]>(
|
||||
[
|
||||
{
|
||||
title: '联系人',
|
||||
require: true,
|
||||
placeholderFont: '请输入收货人姓名',
|
||||
type: 'text',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '加工厂',
|
||||
require: false,
|
||||
placeholderFont: '请输入加工厂(选填)',
|
||||
type: 'text',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '联系方式',
|
||||
require: true,
|
||||
placeholderFont: '请输入联系方式',
|
||||
type: 'number',
|
||||
value: '',
|
||||
maxLength: 11,
|
||||
},
|
||||
{
|
||||
title: '收货地址',
|
||||
require: true,
|
||||
placeholderFont: '请选择/省/市/区',
|
||||
type: 'select',
|
||||
disabled: true,
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '详细地址',
|
||||
require: true,
|
||||
placeholderFont: '请输入详细地址(街道、门牌号等)',
|
||||
type: 'text',
|
||||
value: '',
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
const [itemList, setItemList] = useState<any[]>(
|
||||
[
|
||||
{
|
||||
title: '联系人',
|
||||
require: true,
|
||||
placeholderFont: '请输入收货人姓名',
|
||||
type: 'text',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '加工厂',
|
||||
require: false,
|
||||
placeholderFont: '请输入加工厂(选填)',
|
||||
type: 'text',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '联系方式',
|
||||
require: true,
|
||||
placeholderFont: '请输入联系方式',
|
||||
type: 'number',
|
||||
value: '',
|
||||
maxLength: 11
|
||||
},
|
||||
{
|
||||
title: '收货地址',
|
||||
require: true,
|
||||
placeholderFont: '请选择/省/市/区',
|
||||
type: 'select',
|
||||
disabled: true,
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
title: '详细地址',
|
||||
require: true,
|
||||
placeholderFont: '请输入详细地址(街道、门牌号等)',
|
||||
type: 'text',
|
||||
value: '',
|
||||
}
|
||||
]
|
||||
)
|
||||
const [ischecked, setIsChecked] = useState(false)
|
||||
const onChange = (eq) => {
|
||||
setIsChecked(eq.detail.value)
|
||||
setFormData(e => ({ ...e, is_default: eq.detail.value, address_detail: itemList[4].value }))
|
||||
}
|
||||
|
||||
const [ischecked, setIsChecked] = useState(false)
|
||||
const onChange = (eq) => {
|
||||
setIsChecked(eq.detail.value)
|
||||
setFormData((e) => ({ ...e, is_default: eq.detail.value, address_detail: itemList[4].value }))
|
||||
const router = useRouter()
|
||||
useDidShow(() => {
|
||||
if (router.params.type === 'add') {
|
||||
setNavigationBarTitle({ title: '新增收货地址' })
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
useDidShow(() => {
|
||||
if (router.params.type === 'add') {
|
||||
setNavigationBarTitle({ title: "新增收货地址" })
|
||||
} else {
|
||||
setFormData((e) => ({ ...e, id: router.params.id as any }))
|
||||
getInfo()
|
||||
setNavigationBarTitle({ title: "编辑收货地址" })
|
||||
}
|
||||
else {
|
||||
setFormData(e => ({ ...e, id: router.params.id as any }))
|
||||
getInfo()
|
||||
setNavigationBarTitle({ title: '编辑收货地址' })
|
||||
}
|
||||
})
|
||||
const [formData, setFormData] = useState({
|
||||
name: '',
|
||||
phone: '',
|
||||
site: '',
|
||||
siteArray: [],
|
||||
district_id: '',
|
||||
address_detail: '',
|
||||
is_default: false,
|
||||
id: '',
|
||||
factory: '',
|
||||
})
|
||||
// 获取相应id的信息
|
||||
const { fetchData: infoFetch } = mppurchaseraddressget()
|
||||
const [infoObj, setinfoObj] = useState<any>()
|
||||
const getInfo = async() => {
|
||||
const res = await infoFetch({
|
||||
id: router.params.id,
|
||||
})
|
||||
const [formData, setFormData] = useState({
|
||||
name: "",
|
||||
phone: "",
|
||||
site: "",
|
||||
siteArray: [],
|
||||
district_id: "",
|
||||
address_detail: "",
|
||||
is_default: false,
|
||||
id: '',
|
||||
factory: '',
|
||||
if (res.data) {
|
||||
let arr: any[] = []
|
||||
arr = [
|
||||
{ id: res.data.province_id, name: res.data.province_name },
|
||||
{ id: res.data.city_id, name: res.data.city_name },
|
||||
{ id: res.data.district_id, name: res.data.district_name },
|
||||
]
|
||||
setFormData({
|
||||
name: res.data.name,
|
||||
phone: res.data.phone,
|
||||
site: res.data.province_name + res.data.city_name + res.data.district_name,
|
||||
siteArray: arr as any,
|
||||
address_detail: res.data.address_detail,
|
||||
district_id: res.data.district_id,
|
||||
is_default: res.data.is_default,
|
||||
id: res.data.id,
|
||||
factory: res.data.factory,
|
||||
// purchaser_id: res.data.purchaser_id
|
||||
})
|
||||
setinfoObj(res.data)
|
||||
itemList.map((item) => {
|
||||
if (item.title === '联系人') {
|
||||
item.value = res.data.name
|
||||
}
|
||||
if (item.title === '联系方式') {
|
||||
item.value = res.data.phone
|
||||
}
|
||||
if (item.title === '收货地址') {
|
||||
item.value = res.data.province_name, res.data.city_name, res.data.district_name
|
||||
}
|
||||
if (item.title === '详细地址') {
|
||||
item.value = res.data.address_detail
|
||||
}
|
||||
if (item.title === '加工厂') {
|
||||
item.value = res.data.factory
|
||||
}
|
||||
return item
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setIsChecked(res.data.is_default)
|
||||
}
|
||||
}
|
||||
// `${res.data.province_name} + ${res.data.city_name} + ${res.data.district_name}`
|
||||
|
||||
const btnDisabled = useMemo(() => {
|
||||
let canShow = false
|
||||
const obj = itemList.filter((item) => {
|
||||
if (item.require) {
|
||||
return item.value !== ''
|
||||
}
|
||||
})
|
||||
//获取相应id的信息
|
||||
const { fetchData: infoFetch } = mppurchaseraddressget()
|
||||
const [infoObj, setinfoObj] = useState<any>()
|
||||
const getInfo = async () => {
|
||||
let res = await infoFetch({
|
||||
id: router.params.id,
|
||||
})
|
||||
if (res.data) {
|
||||
let arr: any[] = []
|
||||
arr = [
|
||||
{ id: res.data.province_id, name: res.data.province_name },
|
||||
{ id: res.data.city_id, name: res.data.city_name },
|
||||
{ id: res.data.district_id, name: res.data.district_name }
|
||||
]
|
||||
setFormData({
|
||||
name: res.data.name,
|
||||
phone: res.data.phone,
|
||||
site: res.data.province_name + res.data.city_name + res.data.district_name,
|
||||
siteArray: arr as any,
|
||||
address_detail: res.data.address_detail,
|
||||
district_id: res.data.district_id,
|
||||
is_default: res.data.is_default,
|
||||
id: res.data.id,
|
||||
factory: res.data.factory
|
||||
// purchaser_id: res.data.purchaser_id
|
||||
})
|
||||
setinfoObj(res.data)
|
||||
itemList.map(item => {
|
||||
if (item.title === '联系人') {
|
||||
item.value = res.data.name
|
||||
}
|
||||
if (item.title === '联系方式') {
|
||||
item.value = res.data.phone
|
||||
}
|
||||
if (item.title === '收货地址') {
|
||||
item.value = res.data.province_name, res.data.city_name, res.data.district_name
|
||||
}
|
||||
if (item.title === '详细地址') {
|
||||
item.value = res.data.address_detail
|
||||
}
|
||||
if (item.title === '加工厂') {
|
||||
item.value = res.data.factory
|
||||
}
|
||||
return item
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setIsChecked(res.data.is_default)
|
||||
if (obj.length < 4) {
|
||||
canShow = true
|
||||
}
|
||||
else {
|
||||
canShow = false
|
||||
}
|
||||
return canShow
|
||||
}, [itemList])
|
||||
|
||||
const [showSiteModal, setShowSiteModal] = useState(false)
|
||||
|
||||
const handleSetSite = (ev: any) => {
|
||||
const addressName: any = []
|
||||
ev.forEach((v) => {
|
||||
addressName.push(v.name)
|
||||
})
|
||||
if (ev.length === 3) {
|
||||
itemList.map((it) => {
|
||||
if (it.type === 'select') {
|
||||
it.value = addressName
|
||||
}
|
||||
|
||||
return it
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setShowSiteModal(false)
|
||||
}
|
||||
// `${res.data.province_name} + ${res.data.city_name} + ${res.data.district_name}`
|
||||
setFormData({
|
||||
name: itemList[0]?.value,
|
||||
phone: itemList[2]?.value,
|
||||
site: addressName.join(' '),
|
||||
district_id: ev[ev.length - 1]?.id,
|
||||
is_default: ischecked,
|
||||
address_detail: itemList[4]?.value,
|
||||
id: infoObj?.id ? infoObj?.id : '',
|
||||
siteArray: ev,
|
||||
factory: itemList[1]?.value,
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(formData)
|
||||
}, [formData])
|
||||
|
||||
const btnDisabled = useMemo(() => {
|
||||
let canShow = false
|
||||
const obj = itemList.filter(item => {
|
||||
if (item.require) {
|
||||
return item.value !== ''
|
||||
}
|
||||
})
|
||||
if (obj.length < 4) {
|
||||
canShow = true
|
||||
} else {
|
||||
canShow = false
|
||||
useEffect(() => {
|
||||
setItemList(itemList)
|
||||
}, [itemList])
|
||||
const onClose = () => {
|
||||
setShowSiteModal(false)
|
||||
}
|
||||
|
||||
const changeInput = (e, item) => {
|
||||
itemList.map((it) => {
|
||||
if (it.title === item.title) {
|
||||
it.value = e.detail.value
|
||||
}
|
||||
return it
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setFormData(val => ({
|
||||
...val, name: itemList[0].value, phone: itemList[2].value, address_detail: itemList[4].value, factory: itemList[1].value,
|
||||
}))
|
||||
}
|
||||
|
||||
const showModal = (item) => {
|
||||
if (item.type === 'select') {
|
||||
setShowSiteModal(true)
|
||||
}
|
||||
}
|
||||
|
||||
const navBack = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
// 新增地址
|
||||
const { fetchData: addAddressFetch } = mppurchaseraddress()
|
||||
const handAdd = async() => {
|
||||
// if (!btnDisabled) return false
|
||||
const res = await addAddressFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id) })
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
icon: 'none',
|
||||
})
|
||||
navBack()
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑地址
|
||||
const { fetchData: putFetch } = mppurchaseraddressput()
|
||||
const handEdit = async() => {
|
||||
// if (!btnDisabled) return false
|
||||
const res = await putFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id), id: Number(infoObj?.id) })
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
icon: 'none',
|
||||
})
|
||||
navBack()
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
})
|
||||
}
|
||||
}
|
||||
// 删除地址
|
||||
const { fetchData: deleteFetch } = mppurchaseraddressdelect()
|
||||
const handleDelete = async() => {
|
||||
Taro.showModal(({
|
||||
title: '提示',
|
||||
content: '是否删除地址?',
|
||||
async success(ev) {
|
||||
if (ev.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
})
|
||||
const result = await deleteFetch({ id: Number(formData.id) })
|
||||
if (result.success) {
|
||||
alert.success('删除成功')
|
||||
Taro.hideLoading()
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
else {
|
||||
alert.error(result.msg)
|
||||
}
|
||||
}
|
||||
return canShow
|
||||
}, [itemList])
|
||||
|
||||
const [showSiteModal, setShowSiteModal] = useState(false);
|
||||
|
||||
const handleSetSite = (ev: any) => {
|
||||
var addressName: any = []
|
||||
ev.forEach(v => {
|
||||
addressName.push(v.name)
|
||||
})
|
||||
if (ev.length === 3) {
|
||||
itemList.map(it => {
|
||||
if (it.type === 'select') {
|
||||
it.value = addressName
|
||||
},
|
||||
}))
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
{itemList.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.itemBox} key={index}>
|
||||
<View className={styles.leftBox}>
|
||||
{item.title}
|
||||
{
|
||||
item.require && <Text style={{ color: 'red' }}>*</Text>
|
||||
}
|
||||
return it
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setShowSiteModal(false)
|
||||
|
||||
}
|
||||
setFormData({
|
||||
name: itemList[0]?.value,
|
||||
phone: itemList[2]?.value,
|
||||
site: addressName.join(' '),
|
||||
district_id: ev[ev.length - 1]?.id,
|
||||
is_default: ischecked,
|
||||
address_detail: itemList[4]?.value,
|
||||
id: infoObj?.id ? infoObj?.id : '',
|
||||
siteArray: ev,
|
||||
factory: itemList[1]?.value
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(formData)
|
||||
}, [formData])
|
||||
|
||||
useEffect(() => {
|
||||
setItemList(itemList)
|
||||
}, [itemList])
|
||||
const onClose = () => {
|
||||
setShowSiteModal(false)
|
||||
}
|
||||
|
||||
const changeInput = (e, item) => {
|
||||
itemList.map(it => {
|
||||
if (it.title === item.title) {
|
||||
it.value = e.detail.value
|
||||
}
|
||||
return it
|
||||
})
|
||||
setItemList([...itemList])
|
||||
setFormData((val) => ({
|
||||
...val, name: itemList[0].value, phone: itemList[2].value, address_detail: itemList[4].value, factory: itemList[1].value
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
const showModal = (item) => {
|
||||
if (item.type === 'select') {
|
||||
setShowSiteModal(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const navBack = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
//新增地址
|
||||
const { fetchData: addAddressFetch } = mppurchaseraddress()
|
||||
const handAdd = async () => {
|
||||
// if (!btnDisabled) return false
|
||||
let res = await addAddressFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id) })
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
icon: "none"
|
||||
})
|
||||
navBack()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑地址
|
||||
const { fetchData: putFetch } = mppurchaseraddressput()
|
||||
const handEdit = async () => {
|
||||
// if (!btnDisabled) return false
|
||||
let res = await putFetch({ ...formData, purchaser_id: Number(router.params.purchaser_id), id: Number(infoObj?.id) })
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
icon: "none"
|
||||
})
|
||||
navBack()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg
|
||||
})
|
||||
}
|
||||
}
|
||||
// 删除地址
|
||||
const { fetchData: deleteFetch } = mppurchaseraddressdelect()
|
||||
const handleDelete = async () => {
|
||||
Taro.showModal(({
|
||||
title: "提示",
|
||||
content: "是否删除地址?",
|
||||
async success(ev) {
|
||||
if (ev.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...'
|
||||
})
|
||||
const result = await deleteFetch({ id: Number(formData.id) });
|
||||
if (result.success) {
|
||||
alert.success("删除成功");
|
||||
Taro.hideLoading()
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
} else {
|
||||
alert.error(result.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
{itemList.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.itemBox} key={index}>
|
||||
<View className={styles.leftBox}>
|
||||
{item.title}
|
||||
{
|
||||
item.require && <Text style={{ color: 'red' }}>*</Text>
|
||||
}
|
||||
</View>
|
||||
<Input
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
maxlength={item.maxLength ? 11 : 100}
|
||||
onBlur={(e) => changeInput(e, item)}
|
||||
type={item.type}
|
||||
onClick={() => showModal(item)}
|
||||
style={{ width: '212px' }}
|
||||
disabled={item.disabled}
|
||||
placeholder={item.placeholderFont}
|
||||
value={item.value}
|
||||
className={styles.inputClass}
|
||||
></Input>
|
||||
{
|
||||
item.type === 'select' && <IconFont name={'icon-chakanquanbukehu'} color={'#000000'} size={40}></IconFont>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
|
||||
|
||||
</View>
|
||||
<View className={styles.checkBox}>
|
||||
<View className={styles.leftCheck}>
|
||||
<View className={styles.topFont}>设置默认地址</View>
|
||||
<View className={styles.bottomFont}>提醒:下单会优先使用该地址</View>
|
||||
</View>
|
||||
<Switch checked={ischecked} color={'#337fff'} onChange={(e) => { onChange(e) }} />
|
||||
</View>
|
||||
<Input
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
maxlength={item.maxLength ? 11 : 100}
|
||||
onBlur={e => changeInput(e, item)}
|
||||
type={item.type}
|
||||
onClick={() => showModal(item)}
|
||||
style={{ width: '212px' }}
|
||||
disabled={item.disabled}
|
||||
placeholder={item.placeholderFont}
|
||||
value={item.value}
|
||||
className={styles.inputClass}
|
||||
></Input>
|
||||
{
|
||||
item.type === 'select' && <IconFont name="icon-chakanquanbukehu" color="#000000" size={40}></IconFont>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
|
||||
{
|
||||
router.params.type === 'add' &&
|
||||
<View className={styles.bottomBox}>
|
||||
<Button disabled={btnDisabled} onClick={() => handAdd()} className={classnames(btnDisabled ? styles.btn : styles.adtiveBtns)}>保存</Button>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
router.params.type === 'edit' &&
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.delectBox} onClick={() => handleDelete()}>删除</Button>
|
||||
<Button onClick={() => handEdit()} disabled={btnDisabled} className={classnames(btnDisabled ? styles.nobtn : styles.sureBox)} >确认</Button>
|
||||
</View>
|
||||
}
|
||||
<Address addressOnChange={handleSetSite} defaultValue={formData.siteArray} addressOnClose={() => onClose()} show={showSiteModal} />
|
||||
</View>
|
||||
<View className={styles.checkBox}>
|
||||
<View className={styles.leftCheck}>
|
||||
<View className={styles.topFont}>设置默认地址</View>
|
||||
<View className={styles.bottomFont}>提醒:下单会优先使用该地址</View>
|
||||
</View>
|
||||
<Switch checked={ischecked} color="#337fff" onChange={(e) => { onChange(e) }} />
|
||||
</View>
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
{
|
||||
router.params.type === 'add'
|
||||
&& <View className={styles.bottomBox}>
|
||||
<Button disabled={btnDisabled} onClick={() => handAdd()} className={classnames(btnDisabled ? styles.btn : styles.adtiveBtns)}>保存</Button>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
router.params.type === 'edit'
|
||||
&& <View className={styles.bottomBox}>
|
||||
<Button className={styles.delectBox} onClick={() => handleDelete()}>删除</Button>
|
||||
<Button onClick={() => handEdit()} disabled={btnDisabled} className={classnames(btnDisabled ? styles.nobtn : styles.sureBox)} >确认</Button>
|
||||
</View>
|
||||
}
|
||||
<Address addressOnChange={handleSetSite} defaultValue={formData.siteArray} addressOnClose={() => onClose()} show={showSiteModal} />
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,102 +1,101 @@
|
||||
import { ScrollView, View, Text, Input } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv, formatDateTime } from '@/common/format'
|
||||
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatDateTime, formatPriceDiv } from '@/common/format'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import UploadImage from '@/components/uploadImage'
|
||||
|
||||
interface Params {
|
||||
title?: string, //传入的名称
|
||||
require?: boolean, //是否显示必须选填的内容图标
|
||||
isInput?: boolean, //是否显示输入框
|
||||
inputValue?: string, //输入框的值
|
||||
inputType?: any, //输入框类型
|
||||
getInput?: (any) => void //输入框回调
|
||||
showScan?: boolean, //是否显示扫描图标
|
||||
placeholderFont?: string, //输入框默认文本
|
||||
showMore?: boolean, // 是否显示更多图标
|
||||
disabled?: boolean, // 是否输入框禁止
|
||||
onlyRead?: boolean, //图片是否只读
|
||||
showPic?: boolean, // 是否显示图片组件
|
||||
getImageList?: (any) => void //上传图片回调
|
||||
PicList?: [], //默认图片列表
|
||||
styleNone?: boolean, //根据不同的栏目调整样式
|
||||
getScan?: (any) => void, // 扫描
|
||||
navTo?: () => void, //跳转选择
|
||||
showSizeFont?: boolean, //展示金额的大写
|
||||
bigMoney?: any, //展示的大写金额,
|
||||
isOpen?: boolean //是否展开状态
|
||||
title?: string // 传入的名称
|
||||
require?: boolean // 是否显示必须选填的内容图标
|
||||
isInput?: boolean // 是否显示输入框
|
||||
inputValue?: string // 输入框的值
|
||||
inputType?: any // 输入框类型
|
||||
getInput?: (any) => void // 输入框回调
|
||||
showScan?: boolean // 是否显示扫描图标
|
||||
placeholderFont?: string // 输入框默认文本
|
||||
showMore?: boolean // 是否显示更多图标
|
||||
disabled?: boolean // 是否输入框禁止
|
||||
onlyRead?: boolean // 图片是否只读
|
||||
showPic?: boolean // 是否显示图片组件
|
||||
getImageList?: (any) => void // 上传图片回调
|
||||
PicList?: [] // 默认图片列表
|
||||
styleNone?: boolean // 根据不同的栏目调整样式
|
||||
getScan?: (any) => void // 扫描
|
||||
navTo?: () => void // 跳转选择
|
||||
showSizeFont?: boolean // 展示金额的大写
|
||||
bigMoney?: any // 展示的大写金额,
|
||||
isOpen?: boolean // 是否展开状态
|
||||
}
|
||||
|
||||
export default memo((pros: Params) => {
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
return (
|
||||
<>
|
||||
{
|
||||
pros.isOpen && <View className={styles.itemBox}
|
||||
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}
|
||||
>
|
||||
<View className={styles.itemLeft}>
|
||||
<View className={styles.finkFlex}>
|
||||
<View className={styles.itemTitle}>{pros.title}</View>
|
||||
{
|
||||
pros.require && <Text className={styles.xing}>*</Text>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.isOpen && <View className={styles.itemBox}
|
||||
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}>
|
||||
<View className={styles.itemLeft}
|
||||
>
|
||||
<View className={styles.finkFlex}>
|
||||
<View className={styles.itemTitle}>{pros.title}</View>
|
||||
{
|
||||
pros.require && <Text className={styles.xing}>*</Text>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.showPic &&
|
||||
<View className={styles.bigPic}>
|
||||
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
|
||||
style={{
|
||||
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`, alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
|
||||
display: `${!pros.showSizeFont ? 'flex' : ''}`
|
||||
}}
|
||||
>
|
||||
<View className={styles.rightFlex}>
|
||||
{
|
||||
pros.isInput && <Input
|
||||
disabled={pros.disabled}
|
||||
placeholder={pros.placeholderFont}
|
||||
value={pros.inputValue}
|
||||
className={styles.inputStyle}
|
||||
type={pros.inputType}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={(e) => pros.getInput?.(e.detail.value)}
|
||||
></Input>
|
||||
}
|
||||
</View>
|
||||
|
||||
{/* <View className={styles.iconFlex}></View> */}
|
||||
{
|
||||
pros.showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View className={styles.shu}></View>
|
||||
}
|
||||
{
|
||||
pros.showScan && <View onClick={(e) => pros.getScan?.(e)}><IconFont name={'icon-saomiao'} size={50} color={'#337FFF'}></IconFont></View>
|
||||
}
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
|
||||
}
|
||||
</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
{
|
||||
pros.showPic
|
||||
&& <View className={styles.bigPic}>
|
||||
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
|
||||
style={{
|
||||
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`,
|
||||
alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
|
||||
display: `${!pros.showSizeFont ? 'flex' : ''}`,
|
||||
}}
|
||||
>
|
||||
<View className={styles.rightFlex}>
|
||||
{
|
||||
pros.isInput && <Input
|
||||
disabled={pros.disabled}
|
||||
placeholder={pros.placeholderFont}
|
||||
value={pros.inputValue}
|
||||
className={styles.inputStyle}
|
||||
type={pros.inputType}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={e => pros.getInput?.(e.detail.value)}
|
||||
></Input>
|
||||
}
|
||||
</View>
|
||||
|
||||
{/* <View className={styles.iconFlex}></View> */}
|
||||
{
|
||||
pros.showMore && <IconFont name="icon-chakanquanbukehu" size={50} color="#000000"></IconFont>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View className={styles.shu}></View>
|
||||
}
|
||||
{
|
||||
pros.showScan && <View onClick={e => pros.getScan?.(e)}><IconFont name="icon-saomiao" size={50} color="#337FFF"></IconFont></View>
|
||||
}
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
|
||||
}
|
||||
</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
+259
-261
@@ -1,283 +1,281 @@
|
||||
import { View, Input, Button, Textarea } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import { Button, Input, Textarea, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Form from './components/form'
|
||||
import {
|
||||
mpcashManagementOrderpost, mpshouldCollectOrderpurchaser
|
||||
} from "@/api/newCollection"
|
||||
import { alert } from "@/common/common"
|
||||
mpcashManagementOrderaccount, mpcashManagementOrderpost,
|
||||
mpshouldCollectOrderpurchaser,
|
||||
} from '@/api/newCollection'
|
||||
import { alert } from '@/common/common'
|
||||
import smallToBig from '@/common/money'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { mpcashManagementOrderaccount } from '@/api/newCollection'
|
||||
|
||||
export default () => {
|
||||
//获取选择的客户
|
||||
let pages = Taro.getCurrentPages();
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
useDidShow(() => {
|
||||
// 获取选择的客户
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
useDidShow(() => {
|
||||
setQuery(e => ({
|
||||
...e,
|
||||
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id,
|
||||
clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName,
|
||||
bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId,
|
||||
bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName,
|
||||
}))
|
||||
})
|
||||
|
||||
const [Query, setQuery] = useState<any>({})
|
||||
|
||||
setQuery((e) => ({
|
||||
...e,
|
||||
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : Query.purchaser_id,
|
||||
clientName: currPage.data?.clientName ? currPage.data?.clientName : Query.clientName,
|
||||
bankId: currPage.data?.bankId ? currPage.data?.bankId : Query.bankId,
|
||||
bankName: currPage.data?.bankName ? currPage.data?.bankName : Query.bankName,
|
||||
}))
|
||||
// 获取图片列表
|
||||
const picUrl = useRef([])
|
||||
const getImageList = useCallback((list) => {
|
||||
picUrl.current = list
|
||||
setQuery(val => ({ ...val, picList: list }))
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
getCuss()
|
||||
}, [])
|
||||
|
||||
// 获取首个银行账号
|
||||
const { fetchData: clitentFetch } = mpcashManagementOrderaccount()
|
||||
const getCuss = async() => {
|
||||
const res = await clitentFetch({ page: 1, size: 10 })
|
||||
if (res.data) {
|
||||
setQuery(val => ({ ...val, bankId: res.data.list[0].receiving_account_id, bankName: res.data.list[0].company_account }))
|
||||
}
|
||||
}
|
||||
|
||||
const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser()
|
||||
// 扫描
|
||||
const handScan = (e) => {
|
||||
e.stopPropagation()
|
||||
Taro.scanCode({
|
||||
async success(res) {
|
||||
const restult = await scanFetch({ order_no: res.result })
|
||||
setQuery(val => ({ ...val, purchaser_id: restult.data.purchaser_id, clientName: restult.data.purchaser_name }))
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const [Query, setQuery] = useState<any>({})
|
||||
|
||||
//获取图片列表
|
||||
const picUrl = useRef([])
|
||||
const getImageList = useCallback((list) => {
|
||||
picUrl.current = list
|
||||
setQuery((val) => ({ ...val, picList: list }))
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getCuss()
|
||||
}, [])
|
||||
|
||||
//获取首个银行账号
|
||||
const { fetchData: clitentFetch } = mpcashManagementOrderaccount()
|
||||
const getCuss = async () => {
|
||||
let res = await clitentFetch({ page: 1, size: 10 })
|
||||
if (res.data) {
|
||||
setQuery((val) => ({ ...val, bankId: res.data.list[0].receiving_account_id, bankName: res.data.list[0].company_account }))
|
||||
}
|
||||
// 选择内容跳转
|
||||
const navTo = (val) => {
|
||||
if (val == 1) {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/customerPage/index?clientId=${Query.purchaser_id}`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const { fetchData: scanFetch } = mpshouldCollectOrderpurchaser()
|
||||
//扫描
|
||||
const handScan = (e) => {
|
||||
e.stopPropagation()
|
||||
Taro.scanCode({
|
||||
success: async function (res) {
|
||||
const restult = await scanFetch({ order_no: res.result })
|
||||
setQuery((val) => ({ ...val, purchaser_id: restult.data.purchaser_id, clientName: restult.data.purchaser_name }))
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res);
|
||||
},
|
||||
});
|
||||
else {
|
||||
if (typeof (Query.purchaser_id) == 'undefined') {
|
||||
return alert.error('请先选择客户')
|
||||
}
|
||||
else {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/accountPage/index?bankId?=${Query?.bankId}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//选择内容跳转
|
||||
const navTo = (val) => {
|
||||
if (val == 1) {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/customerPage/index?clientId=' + Query.purchaser_id
|
||||
// 判断是否可以提交
|
||||
const isDisabled = useMemo(() => {
|
||||
if (Query.clientName == ''
|
||||
|| Query.money == ''
|
||||
|| Query.picList?.length == 0
|
||||
) {
|
||||
return true
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
}, [Query])
|
||||
|
||||
// 收款金额回调
|
||||
const getInput = (e) => {
|
||||
setQuery({ ...Query, money: e })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setQuery(Query)
|
||||
}, [Query])
|
||||
|
||||
// useEffect(() => {
|
||||
// if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
|
||||
// setQuery({ ...Query, bankId: '', bankName: '' })
|
||||
// }
|
||||
// }, [Query])
|
||||
|
||||
// 备注信息
|
||||
const [TextareaValue, setTextareaValue] = useState('')
|
||||
const getDesc = (e) => {
|
||||
setQuery({ ...Query, nums: e.length })
|
||||
setTextareaValue(e)
|
||||
}
|
||||
|
||||
// 取消返回
|
||||
const handCancl = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
|
||||
// 确认新建
|
||||
const { fetchData: sureFetch } = mpcashManagementOrderpost()
|
||||
const handSure = () => {
|
||||
const query = {
|
||||
payment_credential_url: picUrl.current,
|
||||
purchaser_id: Query.purchaser_id,
|
||||
receipt_amount: Number(Query.money) * 100,
|
||||
receiving_account_id: Query.bankId,
|
||||
remark: TextareaValue,
|
||||
}
|
||||
Taro.showModal({
|
||||
content: '确认提交吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
const res = await sureFetch(query)
|
||||
if (res?.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
})
|
||||
} else {
|
||||
if (typeof (Query.purchaser_id) == 'undefined') {
|
||||
return alert.error('请先选择客户')
|
||||
} else {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/accountPage/index?bankId?=' + Query?.bankId
|
||||
})
|
||||
}
|
||||
Taro.hideLoading()
|
||||
handCancl()
|
||||
}
|
||||
else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res?.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const [IsOpen, setIsOpen] = useState(false)
|
||||
const handOpen = () => {
|
||||
if (IsOpen) {
|
||||
setIsOpen(false)
|
||||
}
|
||||
|
||||
//判断是否可以提交
|
||||
const isDisabled = useMemo(() => {
|
||||
if (Query.clientName == '' ||
|
||||
Query.money == '' ||
|
||||
Query.picList?.length == 0
|
||||
) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}, [Query])
|
||||
|
||||
//收款金额回调
|
||||
const getInput = (e) => {
|
||||
setQuery({ ...Query, money: e })
|
||||
else {
|
||||
setIsOpen(true)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setQuery(Query)
|
||||
}, [Query])
|
||||
|
||||
// useEffect(() => {
|
||||
// if (currPage.data?.clientId && (currPage.data?.clientId != Query.purchaser_id)) {
|
||||
// setQuery({ ...Query, bankId: '', bankName: '' })
|
||||
// }
|
||||
// }, [Query])
|
||||
|
||||
|
||||
//备注信息
|
||||
const [TextareaValue, setTextareaValue] = useState('')
|
||||
const getDesc = (e) => {
|
||||
setQuery({ ...Query, nums: e.length })
|
||||
setTextareaValue(e)
|
||||
const openFont = useMemo(() => {
|
||||
if (IsOpen) {
|
||||
return '收起'
|
||||
}
|
||||
|
||||
//取消返回
|
||||
const handCancl = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
else {
|
||||
return '展开'
|
||||
}
|
||||
|
||||
//确认新建
|
||||
const { fetchData: sureFetch } = mpcashManagementOrderpost()
|
||||
const handSure = () => {
|
||||
|
||||
const query = {
|
||||
payment_credential_url: picUrl.current,
|
||||
purchaser_id: Query.purchaser_id,
|
||||
receipt_amount: Number(Query.money) * 100,
|
||||
receiving_account_id: Query.bankId,
|
||||
remark: TextareaValue
|
||||
}
|
||||
Taro.showModal({
|
||||
content: "确认提交吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
const res = await sureFetch(query)
|
||||
if (res?.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
handCancl()
|
||||
} else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res?.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const [IsOpen, setIsOpen] = useState(false)
|
||||
const handOpen = () => {
|
||||
if (IsOpen) {
|
||||
setIsOpen(false)
|
||||
} else {
|
||||
setIsOpen(true)
|
||||
}
|
||||
}
|
||||
|
||||
const openFont = useMemo(() => {
|
||||
if (IsOpen) {
|
||||
return '收起'
|
||||
} else {
|
||||
return '展开'
|
||||
}
|
||||
}, [IsOpen])
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(IsOpen === false ? styles.addBox : styles.activeBox)}>
|
||||
<Form
|
||||
isOpen={true}
|
||||
title={'客户名称'}
|
||||
require={true}
|
||||
isInput={true}
|
||||
disabled={true}
|
||||
placeholderFont={'请选择客户信息'}
|
||||
inputValue={Query.clientName}
|
||||
showMore={true}
|
||||
showScan={true}
|
||||
styleNone={true}
|
||||
showPic={false}
|
||||
getScan={(e) => handScan(e)}
|
||||
navTo={() => navTo(1)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen={true}
|
||||
title={'收款金额'}
|
||||
require={true}
|
||||
isInput={true}
|
||||
disabled={false}
|
||||
placeholderFont={'请输入金额'}
|
||||
inputType={'digit'}
|
||||
showMore={false}
|
||||
inputValue={Query.money}
|
||||
showScan={false}
|
||||
styleNone={true}
|
||||
showPic={false}
|
||||
getInput={(e) => getInput(e)}
|
||||
showSizeFont={true}
|
||||
bigMoney={smallToBig(typeof (Query.money) == 'undefined' ? 0 : Query.money)}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen={true}
|
||||
styleNone={false}
|
||||
title={'收款凭证'}
|
||||
require={true}
|
||||
isInput={false}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
showPic={true}
|
||||
getImageList={(list) => getImageList(list)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen={IsOpen}
|
||||
title={'收款账户'}
|
||||
require={false}
|
||||
isInput={true}
|
||||
disabled={true}
|
||||
placeholderFont={'请选择银行账号'}
|
||||
inputValue={Query.bankName}
|
||||
showMore={true}
|
||||
showScan={false}
|
||||
styleNone={true}
|
||||
showPic={false}
|
||||
navTo={() => navTo(2)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
{
|
||||
IsOpen && <View className={styles.textAreaBox}>
|
||||
<View className={styles.textAreaLeft}>备注信息</View>
|
||||
<View className={styles.textAreaRight}>
|
||||
<Textarea
|
||||
style={{ width: '70%' }}
|
||||
onInput={(e) => getDesc(e.detail.value)}
|
||||
value={TextareaValue}
|
||||
placeholderStyle='font-size: 28rpx;font-weight: 400;'
|
||||
maxlength={64}
|
||||
placeholder={'请填写备注信息'}
|
||||
></Textarea>
|
||||
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
<View className={styles.openBox} onClick={() => handOpen()}>
|
||||
<View className={styles.openFont}>{openFont}</View>
|
||||
{
|
||||
!IsOpen && <IconFont name={'icon-zhankai'} size={30} color={'#337FFF'} ></IconFont>
|
||||
}
|
||||
{
|
||||
IsOpen && <IconFont name={'icon-shouqi'} size={30} color={'#337FFF'} ></IconFont>
|
||||
}
|
||||
</View>
|
||||
</View >
|
||||
<View className={styles.safeBox}> </View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handCancl() }}> 取消</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 提交</Button >
|
||||
}, [IsOpen])
|
||||
return (
|
||||
<>
|
||||
<View className={classnames(IsOpen === false ? styles.addBox : styles.activeBox)}>
|
||||
<Form
|
||||
isOpen
|
||||
title="客户名称"
|
||||
require
|
||||
isInput
|
||||
disabled
|
||||
placeholderFont="请选择客户信息"
|
||||
inputValue={Query.clientName}
|
||||
showMore
|
||||
showScan
|
||||
styleNone
|
||||
showPic={false}
|
||||
getScan={e => handScan(e)}
|
||||
navTo={() => navTo(1)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen
|
||||
title="收款金额"
|
||||
require
|
||||
isInput
|
||||
disabled={false}
|
||||
placeholderFont="请输入金额"
|
||||
inputType="digit"
|
||||
showMore={false}
|
||||
inputValue={Query.money}
|
||||
showScan={false}
|
||||
styleNone
|
||||
showPic={false}
|
||||
getInput={e => getInput(e)}
|
||||
showSizeFont
|
||||
bigMoney={smallToBig(typeof (Query.money) == 'undefined' ? 0 : Query.money)}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen
|
||||
styleNone={false}
|
||||
title="收款凭证"
|
||||
require
|
||||
isInput={false}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
showPic
|
||||
getImageList={list => getImageList(list)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
isOpen={IsOpen}
|
||||
title="收款账户"
|
||||
require={false}
|
||||
isInput
|
||||
disabled
|
||||
placeholderFont="请选择银行账号"
|
||||
inputValue={Query.bankName}
|
||||
showMore
|
||||
showScan={false}
|
||||
styleNone
|
||||
showPic={false}
|
||||
navTo={() => navTo(2)}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
{
|
||||
IsOpen && <View className={styles.textAreaBox}>
|
||||
<View className={styles.textAreaLeft}>备注信息</View>
|
||||
<View className={styles.textAreaRight}>
|
||||
<Textarea
|
||||
style={{ width: '70%' }}
|
||||
onInput={e => getDesc(e.detail.value)}
|
||||
value={TextareaValue}
|
||||
placeholderStyle="font-size: 28rpx;font-weight: 400;"
|
||||
maxlength={64}
|
||||
placeholder="请填写备注信息"
|
||||
></Textarea>
|
||||
<View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View>
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</View>
|
||||
}
|
||||
<View className={styles.openBox} onClick={() => handOpen()}>
|
||||
<View className={styles.openFont}>{openFont}</View>
|
||||
{
|
||||
!IsOpen && <IconFont name="icon-zhankai" size={30} color="#337FFF" ></IconFont>
|
||||
}
|
||||
{
|
||||
IsOpen && <IconFont name="icon-shouqi" size={30} color="#337FFF" ></IconFont>
|
||||
}
|
||||
</View>
|
||||
</View >
|
||||
<View className={styles.safeBox}> </View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handCancl() }}> 取消</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 提交</Button >
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
|
||||
import AddressList from "@/components/AddressList"
|
||||
import { Button, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { stopPullDownRefresh, useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro"
|
||||
import { useState } from "react"
|
||||
import "./index.scss"
|
||||
import { Button, ScrollView, Text, View } from '@tarojs/components'
|
||||
import { stopPullDownRefresh, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import AddressList from '@/components/AddressList'
|
||||
import './index.scss'
|
||||
|
||||
export default () => {
|
||||
const router = useRouter()
|
||||
return (
|
||||
<View className="address-manager">
|
||||
<AddressList refresherEnabled={true} purchaser_id={router.params.purchaser_id as any} />
|
||||
<AddressList refresherEnabled purchaser_id={router.params.purchaser_id as any} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+639
-646
File diff suppressed because it is too large
Load Diff
+491
-497
File diff suppressed because it is too large
Load Diff
@@ -1,104 +1,101 @@
|
||||
import { ScrollView, View, Text, Input } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv, formatDateTime } from '@/common/format'
|
||||
import { Input, ScrollView, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatDateTime, formatPriceDiv } from '@/common/format'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import UploadImage from '@/components/uploadImage'
|
||||
|
||||
interface Params {
|
||||
title?: string, //传入的名称
|
||||
require?: boolean, //是否显示必须选填的内容图标
|
||||
isInput?: boolean, //是否显示输入框
|
||||
inputValue?: string, //输入框的值
|
||||
inputType?: any, //输入框类型
|
||||
getInput?: (any) => void //输入框回调
|
||||
showScan?: boolean, //是否显示扫描图标
|
||||
placeholderFont?: string, //输入框默认文本
|
||||
showMore?: boolean, // 是否显示更多图标
|
||||
disabled?: boolean, // 是否输入框禁止
|
||||
onlyRead?: boolean, //图片是否只读
|
||||
showPic?: boolean, // 是否显示图片组件
|
||||
getImageList?: (any) => void //上传图片回调
|
||||
PicList?: any[], //默认图片列表
|
||||
styleNone?: boolean, //根据不同的栏目调整样式
|
||||
getScan?: (any) => void, // 扫描
|
||||
navTo?: () => void, //跳转选择
|
||||
showSizeFont?: boolean, //展示金额的大写
|
||||
bigMoney?: any //展示的大写金额
|
||||
title?: string // 传入的名称
|
||||
require?: boolean // 是否显示必须选填的内容图标
|
||||
isInput?: boolean // 是否显示输入框
|
||||
inputValue?: string // 输入框的值
|
||||
inputType?: any // 输入框类型
|
||||
getInput?: (any) => void // 输入框回调
|
||||
showScan?: boolean // 是否显示扫描图标
|
||||
placeholderFont?: string // 输入框默认文本
|
||||
showMore?: boolean // 是否显示更多图标
|
||||
disabled?: boolean // 是否输入框禁止
|
||||
onlyRead?: boolean // 图片是否只读
|
||||
showPic?: boolean // 是否显示图片组件
|
||||
getImageList?: (any) => void // 上传图片回调
|
||||
PicList?: any[] // 默认图片列表
|
||||
styleNone?: boolean // 根据不同的栏目调整样式
|
||||
getScan?: (any) => void // 扫描
|
||||
navTo?: () => void // 跳转选择
|
||||
showSizeFont?: boolean // 展示金额的大写
|
||||
bigMoney?: any // 展示的大写金额
|
||||
}
|
||||
|
||||
export default memo((pros: Params) => {
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.itemBox}
|
||||
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}>
|
||||
<View className={styles.itemLeft}
|
||||
|
||||
>
|
||||
<View className={styles.finkFlex}>
|
||||
<View className={styles.itemTitle}>{pros.title}</View>
|
||||
{
|
||||
pros.require && <Text className={styles.xing}>*</Text>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.showPic &&
|
||||
<View className={styles.bigPic}>
|
||||
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
|
||||
style={{
|
||||
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`, alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
|
||||
display: `${!pros.showSizeFont ? 'flex' : ''}`
|
||||
}}
|
||||
>
|
||||
<View className={styles.rightFlex}>
|
||||
{
|
||||
pros.isInput && <Input
|
||||
disabled={pros.disabled}
|
||||
placeholder={pros.placeholderFont}
|
||||
value={pros.inputValue}
|
||||
className={styles.inputStyle}
|
||||
type={pros.inputType}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={(e) => pros.getInput?.(e.detail.value)}
|
||||
></Input>
|
||||
}
|
||||
{
|
||||
!pros.isInput && <View className={styles.inputStyle}>{pros.inputValue}</View>
|
||||
}
|
||||
</View>
|
||||
|
||||
<View className={styles.iconFlex}></View>
|
||||
{
|
||||
pros.showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
|
||||
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View className={styles.shu}></View>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View onClick={(e) => pros.getScan?.(e)}><IconFont name={'icon-saomiao'} size={50} color={'#337FFF'}></IconFont></View>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
|
||||
}
|
||||
</View>
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.itemBox}
|
||||
style={{ justifyContent: `${pros.styleNone ? 'space-between' : ''}`, alignItems: `${pros.styleNone ? 'center' : ''}` }}
|
||||
>
|
||||
<View className={styles.itemLeft}>
|
||||
<View className={styles.finkFlex}>
|
||||
<View className={styles.itemTitle}>{pros.title}</View>
|
||||
{
|
||||
pros.require && <Text className={styles.xing}>*</Text>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.finkFont}>展示大小写</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
pros.showPic
|
||||
&& <View className={styles.bigPic}>
|
||||
<UploadImage onChange={pros.getImageList} defaultList={pros.PicList} onlyRead={pros.onlyRead} />
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!pros.showPic && <View className={styles.itemRight} onClick={() => pros.navTo?.()}
|
||||
style={{
|
||||
justifyContent: `${!pros.showSizeFont ? 'space-between' : ''}`,
|
||||
alignItems: `${!pros.showSizeFont ? 'center' : ''}`,
|
||||
display: `${!pros.showSizeFont ? 'flex' : ''}`,
|
||||
}}
|
||||
>
|
||||
<View className={styles.rightFlex}>
|
||||
{
|
||||
pros.isInput && <Input
|
||||
disabled={pros.disabled}
|
||||
placeholder={pros.placeholderFont}
|
||||
value={pros.inputValue}
|
||||
className={styles.inputStyle}
|
||||
type={pros.inputType}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={e => pros.getInput?.(e.detail.value)}
|
||||
></Input>
|
||||
}
|
||||
{
|
||||
!pros.isInput && <View className={styles.inputStyle}>{pros.inputValue}</View>
|
||||
}
|
||||
</View>
|
||||
|
||||
<View className={styles.iconFlex}></View>
|
||||
{
|
||||
pros.showMore && <IconFont name="icon-chakanquanbukehu" size={50} color="#000000"></IconFont>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View className={styles.shu}></View>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showScan && <View onClick={e => pros.getScan?.(e)}><IconFont name="icon-saomiao" size={50} color="#337FFF"></IconFont></View>
|
||||
|
||||
}
|
||||
{
|
||||
pros.showSizeFont && <View className={styles.assginFont}>{pros.bigMoney}</View>
|
||||
}
|
||||
</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,88 +1,84 @@
|
||||
import { View, Input, Button, Textarea } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
|
||||
import { Button, Input, Textarea, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow, useRouter } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import Form from './components/form'
|
||||
import Search from '@/components/search'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Popup from '@/components/popup'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import Taro, { faceVerifyForPay, useDidShow, useRouter } from '@tarojs/taro'
|
||||
import Form from './components/form'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpcashManagementOrder
|
||||
} from "@/api/newCollection"
|
||||
import TimePicker from "@/components/timePicker"
|
||||
import dayjs from 'dayjs'
|
||||
import { alert } from "@/common/common"
|
||||
mpcashManagementOrder,
|
||||
} from '@/api/newCollection'
|
||||
import TimePicker from '@/components/timePicker'
|
||||
import { alert } from '@/common/common'
|
||||
import smallToBig from '@/common/money'
|
||||
import { IMG_CND_Prefix } from "@/common/constant";
|
||||
import { IMG_CND_Prefix } from '@/common/constant'
|
||||
|
||||
export default () => {
|
||||
|
||||
const router = useRouter()
|
||||
const [Query, setQuery] = useState<any>({})
|
||||
const { fetchData: getFetch } = mpcashManagementOrder()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
const getDetail = async () => {
|
||||
Taro.showLoading({
|
||||
title: '请稍等',
|
||||
mask: true
|
||||
})
|
||||
const res = await getFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
// res.data?.payment_credential_url?.map(it => {
|
||||
// it = IMG_CND_Prefix + it
|
||||
// return it
|
||||
// })
|
||||
Taro.hideLoading()
|
||||
setQuery(res.data)
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
const [Query, setQuery] = useState<any>({})
|
||||
const { fetchData: getFetch } = mpcashManagementOrder()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
const getDetail = async() => {
|
||||
Taro.showLoading({
|
||||
title: '请稍等',
|
||||
mask: true,
|
||||
})
|
||||
const res = await getFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
// res.data?.payment_credential_url?.map(it => {
|
||||
// it = IMG_CND_Prefix + it
|
||||
// return it
|
||||
// })
|
||||
Taro.hideLoading()
|
||||
setQuery(res.data)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setQuery(Query)
|
||||
}, [Query])
|
||||
|
||||
useEffect(() => {
|
||||
setQuery(Query)
|
||||
}, [Query])
|
||||
const money = useMemo(() => {
|
||||
let res = 0
|
||||
res = Query.receipt_amount / 100
|
||||
return res
|
||||
}, [Query])
|
||||
|
||||
const money = useMemo(() => {
|
||||
let res = 0
|
||||
res = Query.receipt_amount / 100
|
||||
return res
|
||||
}, [Query])
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.topFont}>收款金额(元)</View>
|
||||
<View className={styles.topMon}>{money}</View>
|
||||
<View className={styles.topBigMon}>{smallToBig(typeof (money) == 'undefined' ? 0 : money)}</View>
|
||||
</View>
|
||||
<View className={styles.addBox}>
|
||||
<View className={styles.msgBox}>
|
||||
<View className={styles.msgLeft}>订单编号</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.order_no}</View>
|
||||
<View className={styles.msgTime} style={{ color: '#E42945' }}>{Query.auditor_status_name}</View>
|
||||
</View>
|
||||
</View>
|
||||
<Form
|
||||
title={'客户名称'}
|
||||
require={false}
|
||||
isInput={true}
|
||||
disabled={true}
|
||||
inputValue={Query.purchaser_name}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
styleNone={true}
|
||||
showPic={false}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
{/* <Form
|
||||
return (
|
||||
<>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.topFont}>收款金额(元)</View>
|
||||
<View className={styles.topMon}>{money}</View>
|
||||
<View className={styles.topBigMon}>{smallToBig(typeof (money) == 'undefined' ? 0 : money)}</View>
|
||||
</View>
|
||||
<View className={styles.addBox}>
|
||||
<View className={styles.msgBox}>
|
||||
<View className={styles.msgLeft}>订单编号</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.order_no}</View>
|
||||
<View className={styles.msgTime} style={{ color: '#E42945' }}>{Query.auditor_status_name}</View>
|
||||
</View>
|
||||
</View>
|
||||
<Form
|
||||
title="客户名称"
|
||||
require={false}
|
||||
isInput
|
||||
disabled
|
||||
inputValue={Query.purchaser_name}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
styleNone
|
||||
showPic={false}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
{/* <Form
|
||||
title={'收款金额'}
|
||||
require={false}
|
||||
isInput={true}
|
||||
@@ -96,63 +92,63 @@ export default () => {
|
||||
showSizeFont={true}
|
||||
bigMoney={smallToBig(typeof (money) == 'undefined' ? 0 : money)}
|
||||
></Form> */}
|
||||
<Form
|
||||
styleNone={false}
|
||||
title={'收款凭证'}
|
||||
require={false}
|
||||
PicList={Query?.payment_credential_url}
|
||||
isInput={false}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
onlyRead={true}
|
||||
showPic={true}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
title={'收款账户'}
|
||||
require={false}
|
||||
isInput={false}
|
||||
disabled={true}
|
||||
inputValue={Query.receiving_account}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
styleNone={true}
|
||||
showPic={false}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<View className={styles.textAreaBox}>
|
||||
<View className={styles.textAreaLeft}>备注信息</View>
|
||||
<View className={styles.textAreaRight}>
|
||||
{
|
||||
Query.remark !== '' && <Textarea
|
||||
disabled={true}
|
||||
style={{ width: '70%' }}
|
||||
value={Query.remark}
|
||||
placeholderStyle='font-size: 28rpx;font-weight: 400;'
|
||||
autoFocus
|
||||
maxlength={64}
|
||||
></Textarea>
|
||||
}
|
||||
<Form
|
||||
styleNone={false}
|
||||
title="收款凭证"
|
||||
require={false}
|
||||
PicList={Query?.payment_credential_url}
|
||||
isInput={false}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
onlyRead
|
||||
showPic
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<Form
|
||||
title="收款账户"
|
||||
require={false}
|
||||
isInput={false}
|
||||
disabled
|
||||
inputValue={Query.receiving_account}
|
||||
showMore={false}
|
||||
showScan={false}
|
||||
styleNone
|
||||
showPic={false}
|
||||
showSizeFont={false}
|
||||
></Form>
|
||||
<View className={styles.textAreaBox}>
|
||||
<View className={styles.textAreaLeft}>备注信息</View>
|
||||
<View className={styles.textAreaRight}>
|
||||
{
|
||||
Query.remark !== '' && <Textarea
|
||||
disabled
|
||||
style={{ width: '70%' }}
|
||||
value={Query.remark}
|
||||
placeholderStyle="font-size: 28rpx;font-weight: 400;"
|
||||
autoFocus
|
||||
maxlength={64}
|
||||
></Textarea>
|
||||
}
|
||||
|
||||
{/* <View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.msgBox}>
|
||||
<View className={styles.msgLeft}>创建信息</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.creator_name}</View>
|
||||
<View className={styles.msgTime}>{formatDateTime(Query.create_time)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.msgBox} style={{ borderBottom: 'none', paddingBottom: '10rpx' }}>
|
||||
<View className={styles.msgLeft}>审核信息</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.auditor_name}</View>
|
||||
<View className={styles.msgTime}>{formatDateTime(Query.audit_time)}</View>
|
||||
</View>
|
||||
</View>
|
||||
</View >
|
||||
<View className={styles.safeBox} style={{ height: '200rpx' }}></View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
{/* <View className={styles.numsTotal}>{`${typeof (Query.nums) == 'undefined' ? 0 : Query.nums}/64`}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.msgBox}>
|
||||
<View className={styles.msgLeft}>创建信息</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.creator_name}</View>
|
||||
<View className={styles.msgTime}>{formatDateTime(Query.create_time)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.msgBox} style={{ borderBottom: 'none', paddingBottom: '10rpx' }}>
|
||||
<View className={styles.msgLeft}>审核信息</View>
|
||||
<View className={styles.msgFlex}>
|
||||
<View className={styles.msgName}>{Query.auditor_name}</View>
|
||||
<View className={styles.msgTime}>{formatDateTime(Query.audit_time)}</View>
|
||||
</View>
|
||||
</View>
|
||||
</View >
|
||||
<View className={styles.safeBox} style={{ height: '200rpx' }}></View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
import Popup from './Popup'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from '../css/linkBlueTooth.module.scss'
|
||||
import Popup from './Popup'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
|
||||
export default memo(() => {
|
||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||
@@ -18,9 +18,11 @@ export default memo(() => {
|
||||
useEffect(() => {
|
||||
if (!state.available) {
|
||||
setLinkStatus(1)
|
||||
} else if (state.available && state.connected?.name) {
|
||||
}
|
||||
else if (state.available && state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
}, [state.available, state.connected])
|
||||
@@ -30,13 +32,13 @@ export default memo(() => {
|
||||
return state.connected?.localName || ''
|
||||
}, [state.connected])
|
||||
|
||||
//链接设备
|
||||
// 链接设备
|
||||
const onLinkListen = (item) => {
|
||||
if (!state.connected && !state.connecting) connect(item)
|
||||
if (!state.connected && !state.connecting) { connect(item) }
|
||||
}
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
//显示设备列表
|
||||
// 显示设备列表
|
||||
const onFindDevice = () => {
|
||||
console.log('linkStatus==>', linkStatus)
|
||||
if (linkStatus == 1) {
|
||||
@@ -44,16 +46,17 @@ export default memo(() => {
|
||||
title: '请打开蓝牙',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) startScan()
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
|
||||
//断开链接
|
||||
// 断开链接
|
||||
const onDisconnect = () => {
|
||||
disconnect()
|
||||
setPopupShow(false)
|
||||
@@ -62,19 +65,19 @@ export default memo(() => {
|
||||
return (
|
||||
<>
|
||||
<View className={styles.main}>
|
||||
<SearchInput title='蓝牙设备' showIcon={true} showBorder={false}>
|
||||
<SearchInput title="蓝牙设备" showIcon showBorder={false}>
|
||||
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
||||
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
|
||||
{(linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>) ||
|
||||
(linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>) ||
|
||||
(linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>)}
|
||||
{(linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>)
|
||||
|| (linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>)
|
||||
|| (linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>)}
|
||||
</View>
|
||||
</SearchInput>
|
||||
<Popup
|
||||
state={state}
|
||||
show={popupShow}
|
||||
onClose={() => setPopupShow(false)}
|
||||
onLink={(item) => onLinkListen(item)}
|
||||
onLink={item => onLinkListen(item)}
|
||||
onOff={onDisconnect}
|
||||
onFind={onFindEven}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import Loading from '@/components/loading'
|
||||
import style from '../css/popup.module.scss'
|
||||
import Loading from '@/components/loading'
|
||||
|
||||
interface params {
|
||||
state: any
|
||||
@@ -30,15 +30,15 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
<View className={style.title}>搜索设备</View>
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{(state.devices &&
|
||||
state.devices.length > 0 &&
|
||||
state?.devices.map((item) => {
|
||||
{(state.devices
|
||||
&& state.devices.length > 0
|
||||
&& state?.devices.map((item) => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{(!state.connecting && !state.connected && <View>链接</View>) ||
|
||||
(state.connecting && item.deviceId == state.connecting.deviceId && <View className={style.link_ing}>正在链接...</View>) ||
|
||||
(state.connected && item.deviceId == state.connected.deviceId && <View className={style.link_success}>链接成功</View>)}
|
||||
{(!state.connecting && !state.connected && <View>链接</View>)
|
||||
|| (state.connecting && item.deviceId == state.connecting.deviceId && <View className={style.link_ing}>正在链接...</View>)
|
||||
|| (state.connected && item.deviceId == state.connected.deviceId && <View className={style.link_success}>链接成功</View>)}
|
||||
</View>
|
||||
)
|
||||
})) || (
|
||||
@@ -59,17 +59,17 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
<View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>
|
||||
断开链接
|
||||
</View>
|
||||
)) ||
|
||||
(!state.connected && state.discovering && (
|
||||
))
|
||||
|| (!state.connected && state.discovering && (
|
||||
<View className={`${style.footer} ${style.finding}`}>
|
||||
搜索中
|
||||
<Loading width={30} color='orange' />
|
||||
<Loading width={30} color="orange" />
|
||||
</View>
|
||||
)) || (
|
||||
<View className={style.footer} onClick={onFind}>
|
||||
<View className={style.footer} onClick={onFind}>
|
||||
重新搜索
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
</View>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import React, { FC, memo, useEffect, useState } from "react"
|
||||
import { View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import React, { memo, useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
showModal: boolean
|
||||
children?: React.ReactNode
|
||||
}
|
||||
@@ -20,11 +21,13 @@ const DrawerCenter: FC<PropsType> = memo((props) => {
|
||||
setShow(false)
|
||||
}
|
||||
|
||||
return show ? (
|
||||
<View className={styles.popups} catchMove>
|
||||
<View className={styles.popcoms}>{children}</View>
|
||||
<View className={styles.cover} onClick={close}></View>
|
||||
</View>
|
||||
) : null
|
||||
return show
|
||||
? (
|
||||
<View className={styles.popups} catchMove>
|
||||
<View className={styles.popcoms}>{children}</View>
|
||||
<View className={styles.cover} onClick={close}></View>
|
||||
</View>
|
||||
)
|
||||
: null
|
||||
})
|
||||
export default DrawerCenter
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import Popup from '@/components/popup'
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { FC, forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import Taro from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import { formatDateTime, formatHashTag } from '@/common/format'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { usePropsValue } from '@/use/useCommon'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
showModal: boolean
|
||||
onVisibleChange?: (visible: boolean) => void
|
||||
onColor?: Function
|
||||
}
|
||||
type HistoryListItem = {
|
||||
interface HistoryListItem {
|
||||
p_time: number
|
||||
lab: number[]
|
||||
code: string
|
||||
@@ -50,28 +51,28 @@ const HistoryColor: FC<PropsType> = forwardRef((props, ref) => {
|
||||
setVisible(false)
|
||||
}
|
||||
|
||||
//获取本地列表(无差别存储版本)
|
||||
// 获取本地列表(无差别存储版本)
|
||||
const getList = () => {
|
||||
let historyColorList = Taro.getStorageSync('historyColor')
|
||||
const historyColorList = Taro.getStorageSync('historyColor')
|
||||
console.log('historyColorList==>', historyColorList)
|
||||
setList(historyColorList || [])
|
||||
}
|
||||
|
||||
const [list, setList] = useState<HistoryListItem[]>([])
|
||||
|
||||
//保留1位小数
|
||||
// 保留1位小数
|
||||
const noScale = (val, num = 1) => {
|
||||
return val?.toFixed(num)
|
||||
}
|
||||
//rgb转换字符串
|
||||
const labRoRgb = val => {
|
||||
// rgb转换字符串
|
||||
const labRoRgb = (val) => {
|
||||
const rgb = toRgb(val)
|
||||
return `rgb(${rgb[0]},${rgb[1]},${rgb[2]})`
|
||||
}
|
||||
|
||||
const getInfo = val => {
|
||||
const getInfo = (val) => {
|
||||
const index = list.findIndex(item => item.p_time == val.p_time)
|
||||
let tempList = JSON.parse(JSON.stringify(list))
|
||||
const tempList = JSON.parse(JSON.stringify(list))
|
||||
tempList.splice(index, 1)
|
||||
tempList.unshift(val)
|
||||
setList(tempList)
|
||||
@@ -82,32 +83,34 @@ const HistoryColor: FC<PropsType> = forwardRef((props, ref) => {
|
||||
|
||||
return (
|
||||
<View className={styles.history_color}>
|
||||
<Popup title='历史取样记录 ( 最近30条 )' show={visible} onClose={closeEven}>
|
||||
<Popup title="历史取样记录 ( 最近30条 )" show={visible} onClose={closeEven}>
|
||||
<ScrollView className={styles['selectList-scroll-color']} scrollY>
|
||||
<View className={styles.selectCon}>
|
||||
{list?.length ? (
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={index} className={styles.selectList} onClick={() => getInfo(item)}>
|
||||
<View className={styles.rgbColor} style={{ background: labRoRgb(item.lab) }}></View>
|
||||
<View className={styles.product_con}>
|
||||
<View className={styles.product_name}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.date}>{formatDateTime(item.p_time)}</View>
|
||||
</View>
|
||||
<View className={styles.labColor}>
|
||||
<View className={styles.labColor_btn}>+</View>
|
||||
<View className={styles.labColor_con}>
|
||||
<View className={styles.L}>L*:{noScale(item.lab[0])}</View>
|
||||
<View className={styles.a}>a*:{noScale(item.lab[1])}</View>
|
||||
<View className={styles.b}>b*:{noScale(item.lab[2])}</View>
|
||||
{list?.length
|
||||
? (
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View key={index} className={styles.selectList} onClick={() => getInfo(item)}>
|
||||
<View className={styles.rgbColor} style={{ background: labRoRgb(item.lab) }}></View>
|
||||
<View className={styles.product_con}>
|
||||
<View className={styles.product_name}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.date}>{formatDateTime(item.p_time)}</View>
|
||||
</View>
|
||||
<View className={styles.labColor}>
|
||||
<View className={styles.labColor_btn}>+</View>
|
||||
<View className={styles.labColor_con}>
|
||||
<View className={styles.L}>L*:{noScale(item.lab[0])}</View>
|
||||
<View className={styles.a}>a*:{noScale(item.lab[1])}</View>
|
||||
<View className={styles.b}>b*:{noScale(item.lab[2])}</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<View className={styles.noData}>暂无数据</View>
|
||||
)}
|
||||
)
|
||||
})
|
||||
)
|
||||
: (
|
||||
<View className={styles.noData}>暂无数据</View>
|
||||
)}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</Popup>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { FC, useMemo } from 'react'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import { formatDateTime } from '@/common/format'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
lab?: Array<any>
|
||||
time?: any
|
||||
onLab?: Function
|
||||
@@ -17,7 +18,7 @@ const LabColor: FC<PropsType> = (props) => {
|
||||
}
|
||||
|
||||
const labObj = useMemo(() => {
|
||||
if (lab.length <= 0) return { lab: [], rgb: '' }
|
||||
if (lab.length <= 0) { return { lab: [], rgb: '' } }
|
||||
const rgb = toRgb(lab)
|
||||
return {
|
||||
lab: [noScale(lab[0]), noScale(lab[1]), noScale(lab[2])],
|
||||
@@ -26,7 +27,7 @@ const LabColor: FC<PropsType> = (props) => {
|
||||
}, [lab])
|
||||
|
||||
const labTime = useMemo(() => {
|
||||
if (time.length <= 0) return ''
|
||||
if (time.length <= 0) { return '' }
|
||||
return formatDateTime(time)
|
||||
}, [time])
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import { FC, useState } from 'react'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import styles from './index.module.scss'
|
||||
import { formatDateTime } from '@/common/format'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import DrawerCenter from '../DrawerCenter'
|
||||
import styles from './index.module.scss'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import { formatDateTime } from '@/common/format'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
list?: Array<any>
|
||||
customStyle?: React.CSSProperties
|
||||
}
|
||||
|
||||
const RecommendColor: FC<PropsType> = (props) => {
|
||||
|
||||
const { list, customStyle = {} } = props
|
||||
|
||||
//rgb转换字符串
|
||||
// rgb转换字符串
|
||||
const labRoRgb = (val) => {
|
||||
const lab = val ? [val.l, val.a, val.b] : []
|
||||
const rgb = toRgb(lab)
|
||||
return `rgb(${rgb[0]},${rgb[1]},${rgb[2]})`
|
||||
}
|
||||
|
||||
//保留1位小数
|
||||
// 保留1位小数
|
||||
const noScale = (val, num = 1) => {
|
||||
return val.toFixed(num)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ const RecommendColor: FC<PropsType> = (props) => {
|
||||
const [selectObj, setSelectObj] = useState({
|
||||
rgb: '',
|
||||
product_color_code: '',
|
||||
product_color_name: ''
|
||||
product_color_name: '',
|
||||
})
|
||||
|
||||
const openShow = (val) => {
|
||||
@@ -40,7 +40,6 @@ const RecommendColor: FC<PropsType> = (props) => {
|
||||
setSelectObj({ ...val, rgb: labRoRgb(val.lab) })
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<View className={classnames(styles.RecommendColor_main, customStyle)}>
|
||||
<View className={styles.RecommendColor_list}>
|
||||
@@ -57,10 +56,10 @@ const RecommendColor: FC<PropsType> = (props) => {
|
||||
</View>
|
||||
<View className={styles.product_con}>
|
||||
<View className={styles.product_title}>
|
||||
<View className={styles.product_name}>{item.product_code + '# ' + item.product_name}</View>
|
||||
<View className={styles.product_name}>{`${item.product_code}# ${item.product_name}`}</View>
|
||||
<View className={styles.product_num}>{noScale(item.match_rate_percent, 1)}%</View>
|
||||
</View>
|
||||
<View className={styles.product_color}>{item.product_color_code + ' ' + item.product_color_name}</View>
|
||||
<View className={styles.product_color}>{`${item.product_color_code} ${item.product_color_name}`}</View>
|
||||
<View className={styles.date}>
|
||||
<text className={styles.g_num}>{item.dyelot_number}</text>
|
||||
<View className={styles.labColor_btn}>+</View>
|
||||
@@ -74,7 +73,7 @@ const RecommendColor: FC<PropsType> = (props) => {
|
||||
<DrawerCenter showModal={show}>
|
||||
<View className={styles.con}>
|
||||
<View className={styles.showRgb} style={{ background: selectObj?.rgb }}></View>
|
||||
<View className={styles.name}>{selectObj.product_color_code + ' ' + selectObj.product_color_name}</View>
|
||||
<View className={styles.name}>{`${selectObj.product_color_code} ${selectObj.product_color_name}`}</View>
|
||||
</View>
|
||||
</DrawerCenter>
|
||||
</View>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { FC, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import LineBluetooth from '../components/bluetooth/LinkBlueTooth'
|
||||
import styles from './index.module.scss'
|
||||
import HistoryColor from './components/HistoryColor'
|
||||
import LabColor from './components/LabColor'
|
||||
import RecommendColor from './components/RecommendColor'
|
||||
import SelectProduct from '@/components/selectProduct'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import RecommendColor from './components/RecommendColor'
|
||||
import { FindColorListApi } from '@/api/index'
|
||||
import Loading from '@/components/loading'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { throttle } from '@/common/util'
|
||||
|
||||
const FindColor: FC = () => {
|
||||
@@ -19,8 +20,8 @@ const FindColor: FC = () => {
|
||||
const [list, setList] = useState([])
|
||||
const [product, setProduct] = useState<Record<string, any>>({})
|
||||
|
||||
//获取数据
|
||||
const getData = async lab => {
|
||||
// 获取数据
|
||||
const getData = async(lab) => {
|
||||
const res = await ApiFindColorList({
|
||||
product_id: product.id,
|
||||
l: lab[0],
|
||||
@@ -34,8 +35,8 @@ const FindColor: FC = () => {
|
||||
|
||||
const [labArray, setlabArray] = useState<Array<any>>([])
|
||||
const [labtime, setLabtime] = useState<any>(+new Date())
|
||||
//点击获取lab按钮
|
||||
const labEven = throttle(async () => {
|
||||
// 点击获取lab按钮
|
||||
const labEven = throttle(async() => {
|
||||
if (!bluetoothState.connected) {
|
||||
Taro.showToast({ title: '请先链接设备', icon: 'none' })
|
||||
return
|
||||
@@ -77,16 +78,19 @@ const FindColor: FC = () => {
|
||||
const ResultContainer = useMemo(() => {
|
||||
if (!colorState.loading && list?.length > 0) {
|
||||
return <RecommendColor customStyle={{ flex: 1 }} list={list} />
|
||||
} else if (!colorState.loading && labArray.length == 0) {
|
||||
}
|
||||
else if (!colorState.loading && labArray.length == 0) {
|
||||
return <View className={styles.noList}>-请取色-</View>
|
||||
} else if (!colorState.loading && labArray.length > 0 && list?.length == 0) {
|
||||
}
|
||||
else if (!colorState.loading && labArray.length > 0 && list?.length == 0) {
|
||||
return <View className={styles.noList}>-暂无数据-</View>
|
||||
} else if (colorState.loading) {
|
||||
}
|
||||
else if (colorState.loading) {
|
||||
return <Loading />
|
||||
}
|
||||
}, [colorState, list])
|
||||
|
||||
//历史取样
|
||||
// 历史取样
|
||||
const historyShowEven = () => {
|
||||
setShowHistory(true)
|
||||
}
|
||||
@@ -105,16 +109,16 @@ const FindColor: FC = () => {
|
||||
}
|
||||
}, [bluetoothState.deviceLab])
|
||||
|
||||
//本地存储取色记录(无差别存储版本)
|
||||
const localSave = lab => {
|
||||
let historyColorList = Taro.getStorageSync('historyColor') || []
|
||||
let obj = {
|
||||
// 本地存储取色记录(无差别存储版本)
|
||||
const localSave = (lab) => {
|
||||
const historyColorList = Taro.getStorageSync('historyColor') || []
|
||||
const obj = {
|
||||
...product,
|
||||
p_time: +new Date(),
|
||||
lab,
|
||||
}
|
||||
historyColorList.unshift(obj)
|
||||
if (historyColorList.length > 30) historyColorList.pop()
|
||||
if (historyColorList.length > 30) { historyColorList.pop() }
|
||||
Taro.setStorageSync('historyColor', historyColorList)
|
||||
}
|
||||
|
||||
@@ -133,7 +137,7 @@ const FindColor: FC = () => {
|
||||
</View>
|
||||
<HistoryColor showModal={showHistory} onColor={getColor} onVisibleChange={handleVisibleChange} />
|
||||
{ResultContainer}
|
||||
<View className='common_safe_area_y'></View>
|
||||
<View className="common_safe_area_y"></View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { Image, Text, Textarea, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import classnames from 'classnames'
|
||||
import LinkBlueTooth from '../components/bluetooth/LinkBlueTooth'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import styles from './index.module.scss'
|
||||
import { productabsorbcontrast } from '@/api/index'
|
||||
import { isObject } from '@tarojs/shared'
|
||||
import LinkBlueTooth from '../components/bluetooth/LinkBlueTooth'
|
||||
import styles from './index.module.scss'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
import { productabsorbcontrast } from '@/api/index'
|
||||
import { alert } from '@/common/common'
|
||||
|
||||
export default () => {
|
||||
//搜索参数
|
||||
// 搜索参数
|
||||
const [searchField, setSearchField] = useState({
|
||||
l1: '',
|
||||
a1: '',
|
||||
@@ -19,7 +20,7 @@ export default () => {
|
||||
a2: '',
|
||||
b2: '',
|
||||
})
|
||||
type ColorList = {
|
||||
interface ColorList {
|
||||
one?: Record<string, any> | null
|
||||
two?: Record<string, any> | null
|
||||
}
|
||||
@@ -29,15 +30,17 @@ export default () => {
|
||||
})
|
||||
const { state: colorState, measureAndGetLab } = useBluetooth()
|
||||
|
||||
const getLab = async val => {
|
||||
const getLab = async(val) => {
|
||||
if (colorState.connected) {
|
||||
let res = await measureAndGetLab()
|
||||
const res = await measureAndGetLab()
|
||||
if (val === 1) {
|
||||
setColorList({ ...colorList, one: res })
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setColorList({ ...colorList, two: res })
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: '请链接设备',
|
||||
icon: 'none',
|
||||
@@ -46,14 +49,14 @@ export default () => {
|
||||
}
|
||||
const getNowTime = () => {
|
||||
const yy = new Date().getFullYear()
|
||||
const MM = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
|
||||
const dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()
|
||||
const HH = new Date().getHours() < 10 ? '0' + new Date().getHours() : new Date().getHours()
|
||||
const mm = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
|
||||
const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
|
||||
return yy + '-' + MM + '-' + dd + ' ' + HH + ':' + mm + ':' + ss
|
||||
const MM = new Date().getMonth() + 1 < 10 ? `0${new Date().getMonth() + 1}` : new Date().getMonth() + 1
|
||||
const dd = new Date().getDate() < 10 ? `0${new Date().getDate()}` : new Date().getDate()
|
||||
const HH = new Date().getHours() < 10 ? `0${new Date().getHours()}` : new Date().getHours()
|
||||
const mm = new Date().getMinutes() < 10 ? `0${new Date().getMinutes()}` : new Date().getMinutes()
|
||||
const ss = new Date().getSeconds() < 10 ? `0${new Date().getSeconds()}` : new Date().getSeconds()
|
||||
return `${yy}-${MM}-${dd} ${HH}:${mm}:${ss}`
|
||||
}
|
||||
//监听lab数据变化
|
||||
// 监听lab数据变化
|
||||
const [blueToothColor, setBlueToothColor] = useState('')
|
||||
const [blueToothColorTwo, setBlueToothColorTwo] = useState('')
|
||||
const [time, setTime] = useState('')
|
||||
@@ -88,7 +91,7 @@ export default () => {
|
||||
const [data, setData] = useState('')
|
||||
const [result, setResult] = useState('')
|
||||
const { fetchData } = productabsorbcontrast()
|
||||
const handTake = async () => {
|
||||
const handTake = async() => {
|
||||
if (searchField.l1 === '') {
|
||||
Taro.showToast({
|
||||
title: '请填充基础样品',
|
||||
@@ -110,7 +113,7 @@ export default () => {
|
||||
const res = await fetchData(query)
|
||||
if (res.success) {
|
||||
setData(res.data)
|
||||
let diffarray = [
|
||||
const diffarray = [
|
||||
res.data.reddish && '偏红',
|
||||
res.data.yellowish && '偏黄',
|
||||
res.data.greenish && '偏绿',
|
||||
@@ -118,7 +121,7 @@ export default () => {
|
||||
res.data.whitish && '偏亮',
|
||||
res.data.darker && '偏暗',
|
||||
]
|
||||
let resCont = diffarray.filter(item => item).join(',')
|
||||
const resCont = diffarray.filter(item => item).join(',')
|
||||
setResult(resCont)
|
||||
}
|
||||
alert.hideLoading()
|
||||
@@ -129,7 +132,7 @@ export default () => {
|
||||
<LinkBlueTooth />
|
||||
</View>
|
||||
<View className={styles.contBox}>
|
||||
<View className={styles.firstBox} style='margin-right:27px'>
|
||||
<View className={styles.firstBox} style="margin-right:27px">
|
||||
<View className={styles.firstLeftName}>基础样品</View>
|
||||
{blueToothColor === '' && (
|
||||
<View className={styles.firstLeftbox} onClick={() => getLab(1)}>
|
||||
@@ -162,12 +165,12 @@ export default () => {
|
||||
{data && (
|
||||
<View className={styles.notBox}>
|
||||
<View className={styles.notLeft}>色差值: {(data as any).ciede_2000}</View>
|
||||
{!(data as any).reddish &&
|
||||
!(data as any).yellowish &&
|
||||
!(data as any).greenish &&
|
||||
!(data as any).bluish &&
|
||||
!(data as any).whitish &&
|
||||
!(data as any).darker && <View className={styles.notright}>无明显色差</View>}
|
||||
{!(data as any).reddish
|
||||
&& !(data as any).yellowish
|
||||
&& !(data as any).greenish
|
||||
&& !(data as any).bluish
|
||||
&& !(data as any).whitish
|
||||
&& !(data as any).darker && <View className={styles.notright}>无明显色差</View>}
|
||||
{result && <View className={styles.notright}>{result}</View>}
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import React, { FC, memo, useEffect, useRef, useState, useTransition } from 'react'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import React, { memo, useEffect, useRef, useState, useTransition } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import { formatHashTag } from '@/common/format'
|
||||
import dayjs from 'dayjs'
|
||||
import { alert } from '@/common/common'
|
||||
import { BluetoothStateType } from '@/use/contextBlueTooth'
|
||||
import type { BluetoothStateType } from '@/use/contextBlueTooth'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
currentTakeColorIndex?: number | null
|
||||
item?: Record<string, any>
|
||||
index?: number
|
||||
@@ -18,20 +19,21 @@ type PropsType = {
|
||||
bluetoothState: BluetoothStateType
|
||||
}
|
||||
|
||||
const ColorCard: FC<PropsType> = params => {
|
||||
const ColorCard: FC<PropsType> = (params) => {
|
||||
const { item = {}, index, onTakeColor, onPreviewRgb, currentTakeColorIndex, measureAndGetLab, bluetoothState } = params
|
||||
console.log('item===>', item)
|
||||
const truncation = ev => {
|
||||
const truncation = (ev) => {
|
||||
if (ev) {
|
||||
ev += ''
|
||||
let index = ev.lastIndexOf('.')
|
||||
const index = ev.lastIndexOf('.')
|
||||
let suffix = ev.substr(index + 1)
|
||||
if (suffix.length > 2) {
|
||||
suffix = suffix.substr(0, 1)
|
||||
ev = ev.substr(0, index) + '.' + suffix
|
||||
ev = `${ev.substr(0, index)}.${suffix}`
|
||||
}
|
||||
return ev
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -48,14 +50,14 @@ const ColorCard: FC<PropsType> = params => {
|
||||
}
|
||||
}, [currentTakeColorIndex, index])
|
||||
|
||||
const handleTakeColor = async () => {
|
||||
const handleTakeColor = async() => {
|
||||
if (bluetoothState.connected) {
|
||||
onTakeColor?.(index)
|
||||
|
||||
setMoveBorder(1)
|
||||
console.log('moveBorder==> start measure', moveBorder)
|
||||
let lab = await measureAndGetLab()
|
||||
//转rgb
|
||||
const lab = await measureAndGetLab()
|
||||
// 转rgb
|
||||
const rgb = toRgb([lab.L, lab.a, lab.b])
|
||||
setColor({
|
||||
currnetRgb: {
|
||||
@@ -71,7 +73,8 @@ const ColorCard: FC<PropsType> = params => {
|
||||
})
|
||||
setMoveBorder(2)
|
||||
console.log('moveBorder==> end measure', moveBorder)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none('请连接蓝牙')
|
||||
}
|
||||
}
|
||||
@@ -81,7 +84,7 @@ const ColorCard: FC<PropsType> = params => {
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={classnames(styles['color-list'], { [styles['flash']]: moveBorder === 1 })}>
|
||||
<View className={classnames(styles['color-list'], { [styles.flash]: moveBorder === 1 })}>
|
||||
<View className={classnames(styles.vertical, { [styles['move-vertical']]: moveBorder === 2 })}>
|
||||
<View></View>
|
||||
</View>
|
||||
@@ -95,7 +98,8 @@ const ColorCard: FC<PropsType> = params => {
|
||||
${color.currnetRgb?.g},
|
||||
${color.currnetRgb?.b}
|
||||
)`,
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
{color.currentLab?.l == 0 && color.currentLab?.a == 0 && color.currentLab?.b == 0 && <Text>末取样</Text>}
|
||||
</View>
|
||||
<View className={styles['c-info']}>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { View, Text, Image } from '@tarojs/components'
|
||||
import styles from './index.module.scss'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import { FC, memo, useMemo, useRef, useState } from 'react'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useMemo, useRef, useState } from 'react'
|
||||
import Upload from '../Upload'
|
||||
import styles from './index.module.scss'
|
||||
import { screenshot } from '@/common/util'
|
||||
import { formatImgUrl, formatUrl } from '@/common/format'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
@@ -16,10 +17,10 @@ interface PropsType extends TextureEvent {
|
||||
uploadConfirmState: boolean
|
||||
}
|
||||
|
||||
const Texture: FC<PropsType> = params => {
|
||||
const Texture: FC<PropsType> = (params) => {
|
||||
const { onUploadConfirm, list, detail, uploadConfirmState } = params
|
||||
console.log('detail==>', detail)
|
||||
|
||||
|
||||
const handleUploadConfirm = (url) => {
|
||||
onUploadConfirm && onUploadConfirm(url)
|
||||
}
|
||||
@@ -31,7 +32,7 @@ const Texture: FC<PropsType> = params => {
|
||||
}
|
||||
|
||||
const calcNoSampling = useMemo(() => {
|
||||
let len = list?.filter(item => {
|
||||
const len = list?.filter((item) => {
|
||||
return item.currentLab?.l == 0 && item.currentLab?.a == 0 && item.currentLab?.b == 0
|
||||
})
|
||||
return len?.length ?? 0
|
||||
@@ -43,17 +44,17 @@ const Texture: FC<PropsType> = params => {
|
||||
<View onClick={handleOpenModal} className={styles['tc-i-upload']}>
|
||||
{detail.texture_url && <Image src={formatUrl(detail.texture_url)} />}
|
||||
<View v-else className={styles['tc-i-u-box']}>
|
||||
<IconFont name='icon-shangchuanwenli' size={66} color='#707070'></IconFont>
|
||||
<IconFont name="icon-shangchuanwenli" size={66} color="#707070"></IconFont>
|
||||
<View>上传纹理</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles['tc-i-num']}>
|
||||
<View>
|
||||
<View className='color-blue'>{(list?.length ?? 0) - calcNoSampling}</View>
|
||||
<View className="color-blue">{(list?.length ?? 0) - calcNoSampling}</View>
|
||||
<Text>已取样</Text>
|
||||
</View>
|
||||
<View>
|
||||
<View className='color-yellow'>{calcNoSampling}</View>
|
||||
<View className="color-yellow">{calcNoSampling}</View>
|
||||
<Text>未取样</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import Popup from '@/components/popup'
|
||||
import { FC, forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import { View, Text, Image, RootPortal } from '@tarojs/components'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import { Image, RootPortal, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { FC, forwardRef, useEffect, useImperativeHandle, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
|
||||
interface UploadColorEvent {
|
||||
onUploadConfirm?: Function
|
||||
@@ -19,7 +19,7 @@ const UploadColor = forwardRef((params: PropsType, ref) => {
|
||||
const [filePath, setFilePath] = useState('')
|
||||
const [file, setFile] = useState({})
|
||||
|
||||
const handleUpload = async () => {
|
||||
const handleUpload = async() => {
|
||||
Taro.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['image'],
|
||||
@@ -58,10 +58,10 @@ const UploadColor = forwardRef((params: PropsType, ref) => {
|
||||
|
||||
return (
|
||||
<View className={styles['upload-container']}>
|
||||
<Popup title='上传纹理' show={showModal} onClose={() => handleTriggerUploadModal(false)}>
|
||||
<Popup title="上传纹理" show={showModal} onClose={() => handleTriggerUploadModal(false)}>
|
||||
<View className={styles['u-content']}>
|
||||
<View onClick={handleUpload} className={styles['u-image']}>
|
||||
{filePath && <Image mode='aspectFill' src={filePath} />}
|
||||
{filePath && <Image mode="aspectFill" src={filePath} />}
|
||||
|
||||
<View className={classnames({ 'update-statu': filePath })}>{filePath ? '点击修改' : '点击上传'}</View>
|
||||
</View>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { View, Input, Text } from '@tarojs/components'
|
||||
import { FC, useCallback, useMemo, useRef, useState } from 'react'
|
||||
import { Input, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { useCallback, useMemo, useRef, useState } from 'react'
|
||||
import LinkBlueTooth from '../components/bluetooth/LinkBlueTooth'
|
||||
import SelectProduct from '@/components/selectProduct/index'
|
||||
import styles from './index.module.scss'
|
||||
import ColorCard from './components/ColorCard'
|
||||
import Texture from './components/Texture'
|
||||
import SelectProduct from '@/components/selectProduct/index'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { ColorListApi, ColorDetailedApi, TextureSaveApi, ColorSamplingSaveApi } from '@/api/index'
|
||||
import { ColorDetailedApi, ColorListApi, ColorSamplingSaveApi, TextureSaveApi } from '@/api/index'
|
||||
import { breakupUrl, formatHashTag, formatImgUrl, formatUrl } from '@/common/format'
|
||||
import { alert } from '@/common/common'
|
||||
import Texture from './components/Texture'
|
||||
import useUploadCDNImg from '@/use/useUploadImage'
|
||||
import { useBluetooth } from '@/use/contextBlueTooth'
|
||||
import { toRgb } from '@/common/bluetooth/color/colorSpace'
|
||||
@@ -23,7 +24,7 @@ const TakeColor: FC = () => {
|
||||
const [searchValue, setSearchValue] = useState('')
|
||||
const [selectedProduct, setSelectedProduct] = useState<Record<string, any>>({})
|
||||
|
||||
const selectInput = async event => {
|
||||
const selectInput = async(event) => {
|
||||
if (event) {
|
||||
alert.showLoading('正在加载颜色')
|
||||
setSelectedProduct(event)
|
||||
@@ -40,7 +41,8 @@ const TakeColor: FC = () => {
|
||||
await detailFetchData({ id: event.id })
|
||||
}
|
||||
alert.hideLoading()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setListData([])
|
||||
alert.hideLoading()
|
||||
}
|
||||
@@ -51,7 +53,7 @@ const TakeColor: FC = () => {
|
||||
setSearchValue('')
|
||||
}
|
||||
|
||||
const handlePrViewRgb = useCallback(event => {
|
||||
const handlePrViewRgb = useCallback((event) => {
|
||||
setLabPreview(event)
|
||||
setShowLabPreview(true)
|
||||
}, [])
|
||||
@@ -59,7 +61,6 @@ const TakeColor: FC = () => {
|
||||
const [currentTakeColorIndex, setCurrentTakeColorIndex] = useState<number | null>(null)
|
||||
|
||||
const handleTakeColor = (index: number) => {
|
||||
|
||||
setCurrentTakeColorIndex(index)
|
||||
}
|
||||
|
||||
@@ -73,24 +74,25 @@ const TakeColor: FC = () => {
|
||||
// })
|
||||
// }, [state.data?.list, state])
|
||||
|
||||
const onSearchInput = event => {
|
||||
const onSearchInput = (event) => {
|
||||
const current = event.detail.value
|
||||
if (current === '') {
|
||||
setListData(state.data.list)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setListData(
|
||||
state.data?.list?.filter(item => {
|
||||
state.data?.list?.filter((item) => {
|
||||
return formatHashTag(item.product_color_name, item.product_color_code)!.includes(current)
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
// 底部提交
|
||||
const handleSubmit = async () => {
|
||||
const handleSubmit = async() => {
|
||||
if (selectedProduct.id) {
|
||||
let params = {
|
||||
const params = {
|
||||
id: selectedProduct.id,
|
||||
product_color_absorb: state.data.list.map(item => {
|
||||
product_color_absorb: state.data.list.map((item) => {
|
||||
return {
|
||||
product_color_id: item.product_color_id,
|
||||
l: item.currentLab.l,
|
||||
@@ -107,10 +109,12 @@ const TakeColor: FC = () => {
|
||||
const res = await saveFetchData(params)
|
||||
if (res.success) {
|
||||
alert.success('保存成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('保存失败')
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
productSelectEl.current.clickEvent()
|
||||
alert.none('请选择面料')
|
||||
}
|
||||
@@ -120,7 +124,7 @@ const TakeColor: FC = () => {
|
||||
console.log('handleReset')
|
||||
if (selectedProduct.id) {
|
||||
setListData(
|
||||
state.data.list.map(item => {
|
||||
state.data.list.map((item) => {
|
||||
item.moveBorder = 0
|
||||
item.currnetRgb = item.rgb
|
||||
item.currentLab = item.lab
|
||||
@@ -128,7 +132,8 @@ const TakeColor: FC = () => {
|
||||
return item
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
productSelectEl.current.clickEvent()
|
||||
alert.none('请选择面料')
|
||||
}
|
||||
@@ -148,14 +153,14 @@ const TakeColor: FC = () => {
|
||||
|
||||
const [uploadConfirmState, setUploadConfirmState] = useState(false)
|
||||
|
||||
const handleUploadConfirm = async file => {
|
||||
const handleUploadConfirm = async(file) => {
|
||||
setUploadConfirmState(false)
|
||||
if (file) {
|
||||
if (selectedProduct.id) {
|
||||
alert.showLoading('上传中')
|
||||
let res = await uploadCDNImg({ path: file.tempFilePath }, 'product', 'product')
|
||||
const res = await uploadCDNImg({ path: file.tempFilePath }, 'product', 'product')
|
||||
if (res && res?.code == 200) {
|
||||
//console.log('图片地址真实',`${IMG_CND_Prefix}${res.url}`);
|
||||
// console.log('图片地址真实',`${IMG_CND_Prefix}${res.url}`);
|
||||
|
||||
// TODO: 回填到存储的地方
|
||||
await textureSaveFetchData({
|
||||
@@ -166,14 +171,17 @@ const TakeColor: FC = () => {
|
||||
await detailFetchData({ id: selectedProduct.id })
|
||||
alert.none('上传成功')
|
||||
setUploadConfirmState(true)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res && alert.none(`${res.message}`)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
productSelectEl.current.clickEvent()
|
||||
alert.none('请选择面料')
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.none('请选择图片')
|
||||
}
|
||||
}
|
||||
@@ -190,34 +198,36 @@ const TakeColor: FC = () => {
|
||||
<Text>颜色列表({listData?.length ?? 0})</Text>
|
||||
<View className={styles['lb-t-serach']}>
|
||||
<View className={styles['lb-t-search-content']}>
|
||||
<Input type='text' className={styles['input-bar']} onInput={onSearchInput} placeholder='筛选颜色或颜色编号' />
|
||||
<Input type="text" className={styles['input-bar']} onInput={onSearchInput} placeholder="筛选颜色或颜色编号" />
|
||||
<View onClick={clearSearchValue} className={styles['lb-t-sc-clear']}>
|
||||
{searchValue.length > 0 && <IconFont name='icon-guanbi' size={36}></IconFont>}
|
||||
{searchValue.length > 0 && <IconFont name="icon-guanbi" size={36}></IconFont>}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{listData.length ? (
|
||||
listData.map((item, index) => {
|
||||
return (
|
||||
<ColorCard
|
||||
currentTakeColorIndex={currentTakeColorIndex}
|
||||
onPreviewRgb={handlePrViewRgb}
|
||||
onTakeColor={handleTakeColor}
|
||||
bluetoothState={bluetoothState}
|
||||
measureAndGetLab={measureAndGetLab}
|
||||
key={index}
|
||||
item={item}
|
||||
index={item.key}
|
||||
/>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<View className={styles['not-list']}>-请取色-</View>
|
||||
)}
|
||||
{listData.length
|
||||
? (
|
||||
listData.map((item, index) => {
|
||||
return (
|
||||
<ColorCard
|
||||
currentTakeColorIndex={currentTakeColorIndex}
|
||||
onPreviewRgb={handlePrViewRgb}
|
||||
onTakeColor={handleTakeColor}
|
||||
bluetoothState={bluetoothState}
|
||||
measureAndGetLab={measureAndGetLab}
|
||||
key={index}
|
||||
item={item}
|
||||
index={item.key}
|
||||
/>
|
||||
)
|
||||
})
|
||||
)
|
||||
: (
|
||||
<View className={styles['not-list']}>-请取色-</View>
|
||||
)}
|
||||
</View>
|
||||
<View className={styles['fixedBottom-container']}>
|
||||
<View onClick={handleReset} hoverClass='filter'>
|
||||
<View onClick={handleReset} hoverClass="filter">
|
||||
重置
|
||||
</View>
|
||||
<View onClick={handleSubmit} className={styles['fb-confirm']}>
|
||||
@@ -233,7 +243,8 @@ const TakeColor: FC = () => {
|
||||
${labPreview?.currnetRgb?.g},
|
||||
${labPreview?.currnetRgb?.b}
|
||||
)`,
|
||||
}}></View>
|
||||
}}
|
||||
></View>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -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,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '客户详情',
|
||||
navigationBarTitleText: '客户详情',
|
||||
}
|
||||
|
||||
+123
-122
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,76 +1,73 @@
|
||||
import { View, ScrollView, Button, Input } 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 { alert } from '@/common/common'
|
||||
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
|
||||
import { Button, Input, ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import type { ReactNode } from 'react'
|
||||
import React, { memo, useCallback, useEffect, 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 Popup from '@/components/popup'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
isQuire?: boolean,
|
||||
placeholderFont?: string,
|
||||
handBlur?: (any) => void,
|
||||
inputValue?: string,
|
||||
isDisabled?: boolean,
|
||||
inputType?: any,
|
||||
maxlength?: number,
|
||||
children?: ReactNode,
|
||||
showInput?: boolean,
|
||||
showMore?: boolean,
|
||||
showBorder?: boolean,
|
||||
handNav?: () => void
|
||||
title: string
|
||||
isQuire?: boolean
|
||||
placeholderFont?: string
|
||||
handBlur?: (any) => void
|
||||
inputValue?: string
|
||||
isDisabled?: boolean
|
||||
inputType?: any
|
||||
maxlength?: number
|
||||
children?: ReactNode
|
||||
showInput?: boolean
|
||||
showMore?: boolean
|
||||
showBorder?: boolean
|
||||
handNav?: () => void
|
||||
}
|
||||
export default memo((props: Props) => {
|
||||
const {
|
||||
title = '标题',
|
||||
isQuire = true,
|
||||
placeholderFont = '请输入',
|
||||
handBlur,
|
||||
handNav,
|
||||
inputValue,
|
||||
isDisabled,
|
||||
inputType = 'text',
|
||||
maxlength = 999,
|
||||
children,
|
||||
showInput = true,
|
||||
showMore = false,
|
||||
showBorder = true,
|
||||
} = props
|
||||
|
||||
let {
|
||||
title = '标题',
|
||||
isQuire = true,
|
||||
placeholderFont = '请输入',
|
||||
handBlur,
|
||||
handNav,
|
||||
inputValue,
|
||||
isDisabled,
|
||||
inputType = "text",
|
||||
maxlength = 999,
|
||||
children,
|
||||
showInput = true,
|
||||
showMore = false,
|
||||
showBorder = true
|
||||
} = props
|
||||
|
||||
return (
|
||||
<View className={classnames(showBorder ? styles.mainItem : styles.mainItemactive)}>
|
||||
<View className={styles.leftItem}>{title}
|
||||
{
|
||||
isQuire && <View className={styles.xing}>*</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
!children && <View className={styles.rightItem} onClick={() => handNav?.()}>
|
||||
{
|
||||
showInput && <Input
|
||||
maxlength={maxlength}
|
||||
type={inputType}
|
||||
disabled={isDisabled}
|
||||
className={styles.inputStyle}
|
||||
placeholder={placeholderFont}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={(e) => handBlur?.(e.detail.value)}
|
||||
value={inputValue}
|
||||
></Input>
|
||||
}
|
||||
{
|
||||
showMore && <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'}></IconFont>
|
||||
}
|
||||
</View>
|
||||
}
|
||||
{children}
|
||||
return (
|
||||
<View className={classnames(showBorder ? styles.mainItem : styles.mainItemactive)}>
|
||||
<View className={styles.leftItem}>{title}
|
||||
{
|
||||
isQuire && <View className={styles.xing}>*</View>
|
||||
}
|
||||
</View>
|
||||
{
|
||||
!children && <View className={styles.rightItem} onClick={() => handNav?.()}>
|
||||
{
|
||||
showInput && <Input
|
||||
maxlength={maxlength}
|
||||
type={inputType}
|
||||
disabled={isDisabled}
|
||||
className={styles.inputStyle}
|
||||
placeholder={placeholderFont}
|
||||
placeholderStyle={styles.placeholderStyle}
|
||||
onBlur={e => handBlur?.(e.detail.value)}
|
||||
value={inputValue}
|
||||
></Input>
|
||||
}
|
||||
{
|
||||
showMore && <IconFont name="icon-chakanquanbukehu" size={50} color="#000000"></IconFont>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
|
||||
})
|
||||
}
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '客户编辑',
|
||||
navigationBarTitleText: '客户编辑',
|
||||
}
|
||||
|
||||
+353
-356
@@ -1,382 +1,379 @@
|
||||
import { View, Button } 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, setNavigationBarTitle } from '@tarojs/taro';
|
||||
import { Button, View } from '@tarojs/components'
|
||||
import Taro, { setNavigationBarTitle, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import type { ReactNode } from 'react'
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import Remark from '../orderDetails/components/remark'
|
||||
import styles from './index.module.scss'
|
||||
import Form from './components/form'
|
||||
import Popup from '@/components/popup'
|
||||
import { debounce } from '@/common/util'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
|
||||
import Form from "./components/form"
|
||||
import Remark from '../orderDetails/components/remark';
|
||||
import Address from "@/components/address"
|
||||
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import Address from '@/components/address'
|
||||
import { mppurchaser, mppurchaserpost, mppurchaserput } from '@/api/customer'
|
||||
type AddressParms = {
|
||||
id: number,
|
||||
name: string
|
||||
|
||||
interface AddressParms {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const router = useRouter()
|
||||
|
||||
const [infoObj, setinfoObj] = useState<any>()
|
||||
|
||||
const router = useRouter()
|
||||
const [formData, setformData] = useState<any>()
|
||||
|
||||
const [infoObj, setinfoObj] = useState<any>()
|
||||
const [addressArr, setaddressArr] = useState<AddressParms[]>([])
|
||||
useEffect(() => {
|
||||
if (router.params.type === 'edit') {
|
||||
getInfo()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const [formData, setformData] = useState<any>()
|
||||
// 默认业务员
|
||||
useDidShow(() => {
|
||||
if (router.params.type === 'add') {
|
||||
setNavigationBarTitle({ title: '新增客户' })
|
||||
}
|
||||
else {
|
||||
setNavigationBarTitle({ title: '客户编辑' })
|
||||
}
|
||||
const userInfo = JSON.parse(Taro.getStorageSync('userInfo'))
|
||||
// 获取选择的客户
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
// 判断是否有跳转选择业务员
|
||||
if (currPage.data?.saleuserId && currPage.data?.saleuserId !== '') {
|
||||
setformData(val => ({
|
||||
...val,
|
||||
sale_user_id: currPage.data?.saleuserId,
|
||||
sale_user_name: currPage.data?.saleuserName,
|
||||
}))
|
||||
}
|
||||
// 默认业务员
|
||||
if (currPage.data?.saleuserId == null) {
|
||||
setformData(e => ({
|
||||
...e,
|
||||
sale_user_id: userInfo?.user_id,
|
||||
sale_user_name: userInfo?.user_name,
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
const [addressArr, setaddressArr] = useState<AddressParms[]>([])
|
||||
useEffect(() => {
|
||||
if (router.params.type === 'edit') {
|
||||
getInfo()
|
||||
}
|
||||
}, [])
|
||||
|
||||
//默认业务员
|
||||
useDidShow(() => {
|
||||
if (router.params.type === 'add') {
|
||||
setNavigationBarTitle({ title: "新增客户" })
|
||||
} else {
|
||||
|
||||
setNavigationBarTitle({ title: "客户编辑" })
|
||||
}
|
||||
let userInfo = JSON.parse(Taro.getStorageSync('userInfo'))
|
||||
//获取选择的客户
|
||||
let pages = Taro.getCurrentPages();
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
//判断是否有跳转选择业务员
|
||||
if (currPage.data?.saleuserId && currPage.data?.saleuserId !== '') {
|
||||
setformData((val) => ({
|
||||
...val,
|
||||
sale_user_id: currPage.data?.saleuserId,
|
||||
sale_user_name: currPage.data?.saleuserName
|
||||
}))
|
||||
}
|
||||
//默认业务员
|
||||
if (currPage.data?.saleuserId == null) {
|
||||
setformData((e) => ({
|
||||
...e,
|
||||
sale_user_id: userInfo?.user_id,
|
||||
sale_user_name: userInfo?.user_name,
|
||||
}))
|
||||
}
|
||||
const { fetchData: getDesc } = mppurchaser()
|
||||
const getInfo = async() => {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
const res = await getDesc({ id: router.params.id })
|
||||
setinfoObj(res.data)
|
||||
list.map((item) => {
|
||||
if (item.id == res.data.purchaser_type) {
|
||||
item.check = true
|
||||
}
|
||||
else {
|
||||
item.check = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
setformData({
|
||||
sale_user_id: res.data?.sale_user_id,
|
||||
sale_user_name: res.data?.sale_user_name,
|
||||
name: res.data?.name,
|
||||
short_name: res.data?.short_name,
|
||||
director: res.data?.director,
|
||||
phone: res.data?.phone,
|
||||
addressName: res.data?.province_name + res.data?.city_name + res.data?.district_name,
|
||||
address_detail: res.data?.address_detail,
|
||||
purchaser_type: res.data?.purchaser_type,
|
||||
district_id: res.data?.district_id,
|
||||
})
|
||||
setremarkDesc(res.data?.remark)
|
||||
let arr: any[] = []
|
||||
arr = [
|
||||
{ id: res.data.province_id, name: res.data.province_name },
|
||||
{ id: res.data.city_id, name: res.data.city_name },
|
||||
{ id: res.data.district_id, name: res.data.district_name },
|
||||
]
|
||||
setaddressArr([...arr])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
|
||||
const { fetchData: getDesc } = mppurchaser()
|
||||
const getInfo = async () => {
|
||||
Taro.showLoading({
|
||||
const handTitle = useCallback((e) => {
|
||||
setformData(val => ({ ...val, name: e }))
|
||||
}, [])
|
||||
|
||||
const handName = useCallback((e) => {
|
||||
setformData(val => ({ ...val, short_name: e }))
|
||||
}, [])
|
||||
|
||||
const handUsername = useCallback((e) => {
|
||||
setformData(val => ({ ...val, director: e }))
|
||||
}, [])
|
||||
|
||||
const handUserPhone = useCallback((e) => {
|
||||
setformData(val => ({ ...val, phone: e }))
|
||||
}, [])
|
||||
|
||||
const handAddress = useCallback((e) => {
|
||||
setformData(val => ({ ...val, address_detail: e }))
|
||||
}, [])
|
||||
|
||||
// 客户类型数组
|
||||
const [list, setlist] = useState<any[]>([
|
||||
{
|
||||
id: 1,
|
||||
name: '布行',
|
||||
check: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '二批',
|
||||
check: false,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '制衣厂',
|
||||
check: false,
|
||||
},
|
||||
])
|
||||
|
||||
// 选择客户类型
|
||||
const handItem = (item) => {
|
||||
list.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.check = true
|
||||
}
|
||||
else {
|
||||
it.check = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setlist([...list])
|
||||
setformData(val => ({ ...val, purchaser_type: item.id }))
|
||||
}
|
||||
|
||||
// 备注操作
|
||||
const [remarkDesc, setremarkDesc] = useState('')
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const getRemark = useCallback(async(e) => {
|
||||
setShowDesc(false)
|
||||
setremarkDesc(e)
|
||||
// setformData((val) => ({ ...val, remark: e }))
|
||||
}, [])
|
||||
|
||||
// 地址选择
|
||||
const [showSiteModal, setShowSiteModal] = useState(false)
|
||||
|
||||
const handleSetSite = (ev) => {
|
||||
const addressName: any = []
|
||||
ev.forEach((v) => {
|
||||
addressName.push(v?.name)
|
||||
})
|
||||
if (ev.length === 3) {
|
||||
setShowSiteModal(false)
|
||||
setformData(val => ({ ...val, addressName: ev[0]?.name + ev[1]?.name + ev[2]?.name || '', district_id: ev[2]?.id }))
|
||||
}
|
||||
}
|
||||
|
||||
const onClose = () => {
|
||||
setShowSiteModal(false)
|
||||
}
|
||||
|
||||
const isDisabled = useMemo(() => {
|
||||
let empty: any = null
|
||||
if (typeof (formData) == 'undefined') { return }
|
||||
for (const key in formData) {
|
||||
if (formData.hasOwnProperty(key)) {
|
||||
if (formData[key] !== '' && typeof (formData[key]) !== 'undefined') {
|
||||
empty = false
|
||||
}
|
||||
else {
|
||||
empty = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return empty
|
||||
}, [formData])
|
||||
|
||||
// 重置
|
||||
const handReset = () => {
|
||||
setformData({
|
||||
sale_user_id: '',
|
||||
sale_user_name: '',
|
||||
name: '',
|
||||
short_name: '',
|
||||
director: '',
|
||||
phone: '',
|
||||
addressName: '',
|
||||
address_detail: '',
|
||||
purchaser_type: '',
|
||||
remark: '',
|
||||
district_id: '',
|
||||
})
|
||||
}
|
||||
|
||||
const { fetchData: postFetch } = mppurchaserpost()
|
||||
const { fetchData: putFetch } = mppurchaserput()
|
||||
// 提交
|
||||
const handSure = async() => {
|
||||
// if (!isDisabled) return false
|
||||
const query = {
|
||||
...formData,
|
||||
remark: remarkDesc,
|
||||
id: infoObj?.id,
|
||||
}
|
||||
if (router.params.type == 'add') {
|
||||
delete query.id
|
||||
}
|
||||
Taro.showModal({
|
||||
content: '确定要提交吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await (router.params.type == 'add' ? postFetch(query) : putFetch(query))
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
const res = await getDesc({ id: router.params.id })
|
||||
setinfoObj(res.data)
|
||||
list.map(item => {
|
||||
if (item.id == res.data.purchaser_type) {
|
||||
item.check = true
|
||||
} else {
|
||||
item.check = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
setformData({
|
||||
sale_user_id: res.data?.sale_user_id,
|
||||
sale_user_name: res.data?.sale_user_name,
|
||||
name: res.data?.name,
|
||||
short_name: res.data?.short_name,
|
||||
director: res.data?.director,
|
||||
phone: res.data?.phone,
|
||||
addressName: res.data?.province_name + res.data?.city_name + res.data?.district_name,
|
||||
address_detail: res.data?.address_detail,
|
||||
purchaser_type: res.data?.purchaser_type,
|
||||
district_id: res.data?.district_id
|
||||
})
|
||||
setremarkDesc(res.data?.remark)
|
||||
let arr: any[] = []
|
||||
arr = [
|
||||
{ id: res.data.province_id, name: res.data.province_name },
|
||||
{ id: res.data.city_id, name: res.data.city_name },
|
||||
{ id: res.data.district_id, name: res.data.district_name }
|
||||
]
|
||||
setaddressArr([...arr])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
|
||||
|
||||
|
||||
const handTitle = useCallback((e) => {
|
||||
setformData((val) => ({ ...val, name: e }))
|
||||
}, [])
|
||||
|
||||
const handName = useCallback((e) => {
|
||||
setformData((val) => ({ ...val, short_name: e }))
|
||||
}, [])
|
||||
|
||||
const handUsername = useCallback((e) => {
|
||||
setformData((val) => ({ ...val, director: e }))
|
||||
}, [])
|
||||
|
||||
const handUserPhone = useCallback((e) => {
|
||||
setformData((val) => ({ ...val, phone: e }))
|
||||
}, [])
|
||||
|
||||
const handAddress = useCallback((e) => {
|
||||
setformData((val) => ({ ...val, address_detail: e }))
|
||||
}, [])
|
||||
|
||||
|
||||
//客户类型数组
|
||||
const [list, setlist] = useState<any[]>([
|
||||
{
|
||||
id: 1,
|
||||
name: '布行',
|
||||
check: false
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '二批',
|
||||
check: false
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '制衣厂',
|
||||
check: false
|
||||
},
|
||||
])
|
||||
|
||||
//选择客户类型
|
||||
const handItem = (item) => {
|
||||
list.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.check = true
|
||||
} else {
|
||||
it.check = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setlist([...list])
|
||||
setformData((val) => ({ ...val, purchaser_type: item.id }))
|
||||
}
|
||||
|
||||
//备注操作
|
||||
const [remarkDesc, setremarkDesc] = useState('')
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const getRemark = useCallback(async (e) => {
|
||||
setShowDesc(false)
|
||||
setremarkDesc(e)
|
||||
// setformData((val) => ({ ...val, remark: e }))
|
||||
}, [])
|
||||
|
||||
//地址选择
|
||||
const [showSiteModal, setShowSiteModal] = useState(false);
|
||||
|
||||
const handleSetSite = (ev) => {
|
||||
var addressName: any = []
|
||||
ev.forEach(v => {
|
||||
addressName.push(v?.name)
|
||||
})
|
||||
if (ev.length === 3) {
|
||||
setShowSiteModal(false)
|
||||
setformData((val) => ({ ...val, addressName: ev[0]?.name + ev[1]?.name + ev[2]?.name || '', district_id: ev[2]?.id }))
|
||||
mask: true,
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const onClose = () => {
|
||||
setShowSiteModal(false)
|
||||
}
|
||||
return (
|
||||
<>
|
||||
|
||||
const isDisabled = useMemo(() => {
|
||||
let empty: any = null;
|
||||
if (typeof (formData) == 'undefined') return
|
||||
for (const key in formData) {
|
||||
if (formData.hasOwnProperty(key)) {
|
||||
if (formData[key] !== '' && typeof (formData[key]) !== 'undefined') {
|
||||
empty = false
|
||||
} else {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
<View className={styles.mainBox}>
|
||||
<Form
|
||||
title="客户全称"
|
||||
handBlur={handTitle}
|
||||
placeholderFont="请输入全称"
|
||||
inputValue={formData?.name}
|
||||
></Form>
|
||||
<Form
|
||||
title="客户简称"
|
||||
handBlur={handName}
|
||||
placeholderFont="请输入简称"
|
||||
inputValue={formData?.short_name}
|
||||
></Form>
|
||||
<Form
|
||||
title="客户类型"
|
||||
showInput={false}
|
||||
>
|
||||
<View className={styles.flexBox}>
|
||||
{
|
||||
list.map((item) => {
|
||||
return (
|
||||
<View className={classnames(item.check ? styles.activeBox : styles.itemBox)} onClick={() => handItem(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
return empty;
|
||||
}, [formData])
|
||||
|
||||
|
||||
//重置
|
||||
const handReset = () => {
|
||||
setformData({
|
||||
sale_user_id: '',
|
||||
sale_user_name: '',
|
||||
name: '',
|
||||
short_name: '',
|
||||
director: '',
|
||||
phone: '',
|
||||
addressName: '',
|
||||
address_detail: '',
|
||||
purchaser_type: '',
|
||||
remark: '',
|
||||
district_id: ''
|
||||
})
|
||||
}
|
||||
|
||||
const { fetchData: postFetch } = mppurchaserpost()
|
||||
const { fetchData: putFetch } = mppurchaserput()
|
||||
//提交
|
||||
const handSure = async () => {
|
||||
// if (!isDisabled) return false
|
||||
let query = {
|
||||
...formData,
|
||||
remark: remarkDesc,
|
||||
id: infoObj?.id
|
||||
}
|
||||
if (router.params.type == 'add') {
|
||||
delete query.id
|
||||
}
|
||||
Taro.showModal({
|
||||
content: "确定要提交吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await (router.params.type == 'add' ? postFetch(query) : putFetch(query))
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<View className={styles.mainBox}>
|
||||
<Form
|
||||
title={'客户全称'}
|
||||
handBlur={handTitle}
|
||||
placeholderFont={'请输入全称'}
|
||||
inputValue={formData?.name}
|
||||
></Form>
|
||||
<Form
|
||||
title={'客户简称'}
|
||||
handBlur={handName}
|
||||
placeholderFont={'请输入简称'}
|
||||
inputValue={formData?.short_name}
|
||||
></Form>
|
||||
<Form
|
||||
title={'客户类型'}
|
||||
showInput={false}
|
||||
>
|
||||
<View className={styles.flexBox}>
|
||||
{
|
||||
list.map(item => {
|
||||
return (
|
||||
<View className={classnames(item.check ? styles.activeBox : styles.itemBox)} onClick={() => handItem(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</Form>
|
||||
<Form
|
||||
title={'联系人'}
|
||||
handBlur={handUsername}
|
||||
placeholderFont={'请输入联系人'}
|
||||
inputValue={formData?.director}
|
||||
></Form>
|
||||
<Form
|
||||
title={'联系电话'}
|
||||
handBlur={handUserPhone}
|
||||
inputType={'number'}
|
||||
placeholderFont={'请输入号码'}
|
||||
maxlength={11}
|
||||
inputValue={formData?.phone}
|
||||
></Form>
|
||||
<Form
|
||||
title={'省市区'}
|
||||
isDisabled={true}
|
||||
showMore={true}
|
||||
inputValue={formData?.addressName}
|
||||
placeholderFont={'请选择省市区'}
|
||||
handNav={() => setShowSiteModal(true)}
|
||||
></Form>
|
||||
<Form
|
||||
title={'详细地址'}
|
||||
handBlur={handAddress}
|
||||
placeholderFont={'请输入地址'}
|
||||
inputValue={formData?.address_detail}
|
||||
></Form>
|
||||
<Form
|
||||
title={'业务员'}
|
||||
isDisabled={true}
|
||||
showMore={true}
|
||||
placeholderFont={'请选择业务员'}
|
||||
handNav={() => goLink('/pages/saleuserPage/index')}
|
||||
showBorder={false}
|
||||
inputValue={formData?.sale_user_name}
|
||||
></Form>
|
||||
</View>
|
||||
<DefaultBox title={'备注信息'} showMode={true} modeName={`${'填写/修改备注'} >`} clickNode={() => setShowDesc(true)}>
|
||||
<View className={classnames(remarkDesc === '' ? styles.remarkFontactive : styles.remarkFont)}>{remarkDesc === '' ? '尚未备注信息' : remarkDesc}</View>
|
||||
</DefaultBox>
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
<Remark onSave={(e) => getRemark(e)} defaultValue={infoObj?.remark} showInput={showDesc ? true : false} />
|
||||
</Popup>
|
||||
<Address addressOnChange={(val) => handleSetSite(val)} defaultValue={addressArr} addressOnClose={() => onClose()} show={showSiteModal} />
|
||||
<View className={styles.safeBox}></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button2 : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 确认</Button >
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
</View>
|
||||
</Form>
|
||||
<Form
|
||||
title="联系人"
|
||||
handBlur={handUsername}
|
||||
placeholderFont="请输入联系人"
|
||||
inputValue={formData?.director}
|
||||
></Form>
|
||||
<Form
|
||||
title="联系电话"
|
||||
handBlur={handUserPhone}
|
||||
inputType="number"
|
||||
placeholderFont="请输入号码"
|
||||
maxlength={11}
|
||||
inputValue={formData?.phone}
|
||||
></Form>
|
||||
<Form
|
||||
title="省市区"
|
||||
isDisabled
|
||||
showMore
|
||||
inputValue={formData?.addressName}
|
||||
placeholderFont="请选择省市区"
|
||||
handNav={() => setShowSiteModal(true)}
|
||||
></Form>
|
||||
<Form
|
||||
title="详细地址"
|
||||
handBlur={handAddress}
|
||||
placeholderFont="请输入地址"
|
||||
inputValue={formData?.address_detail}
|
||||
></Form>
|
||||
<Form
|
||||
title="业务员"
|
||||
isDisabled
|
||||
showMore
|
||||
placeholderFont="请选择业务员"
|
||||
handNav={() => goLink('/pages/saleuserPage/index')}
|
||||
showBorder={false}
|
||||
inputValue={formData?.sale_user_name}
|
||||
></Form>
|
||||
</View>
|
||||
<DefaultBox title="备注信息" showMode modeName={`${'填写/修改备注'} >`} clickNode={() => setShowDesc(true)}>
|
||||
<View className={classnames(remarkDesc === '' ? styles.remarkFontactive : styles.remarkFont)}>{remarkDesc === '' ? '尚未备注信息' : remarkDesc}</View>
|
||||
</DefaultBox>
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
<Remark onSave={e => getRemark(e)} defaultValue={infoObj?.remark} showInput={!!showDesc} />
|
||||
</Popup>
|
||||
<Address addressOnChange={val => handleSetSite(val)} defaultValue={addressArr} addressOnClose={() => onClose()} show={showSiteModal} />
|
||||
<View className={styles.safeBox}></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button2 : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 确认</Button >
|
||||
</View>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//卡片盒子元素
|
||||
// 卡片盒子元素
|
||||
interface Obs {
|
||||
title?: string,
|
||||
modeName?: string,
|
||||
showMode?: boolean,
|
||||
children?: ReactNode,
|
||||
clickNode?: () => void
|
||||
title?: string
|
||||
modeName?: string
|
||||
showMode?: boolean
|
||||
children?: ReactNode
|
||||
clickNode?: () => void
|
||||
}
|
||||
|
||||
const DefaultBox = memo((props: Obs) => {
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode
|
||||
} = props
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,229 +1,228 @@
|
||||
import { View, ScrollView } 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 { 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 Tabs from '../tabs'
|
||||
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 DropDownItem from '@/components/dropDown-item'
|
||||
import { GetAddressListApi } from "@/api/addressList";
|
||||
import Tabs from "../tabs"
|
||||
import IconFont from '@/components/iconfont/iconfont';
|
||||
import { GetAddressListApi } from '@/api/addressList'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
interface Props {
|
||||
handCity?: (province: any, city: any) => void,
|
||||
value?: any,
|
||||
onCloseOverlay?: () => void
|
||||
handCity?: (province: any, city: any) => void
|
||||
value?: any
|
||||
onCloseOverlay?: () => void
|
||||
}
|
||||
|
||||
export default memo(forwardRef((props: Props, ref) => {
|
||||
const DropDownItemRef = useRef<any>()
|
||||
const close = () => {
|
||||
DropDownItemRef.current.closePopup()
|
||||
}
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
|
||||
// 获取地址
|
||||
const { fetchData } = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
|
||||
|
||||
const DropDownItemRef = useRef<any>()
|
||||
const close = () => {
|
||||
DropDownItemRef.current.closePopup()
|
||||
// 获取省
|
||||
const getProvince = async() => {
|
||||
const res = await fetchData({ parent_id: 1 })
|
||||
if (res.data) {
|
||||
setlist([...res.data.list])
|
||||
}
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
}
|
||||
|
||||
//获取地址
|
||||
const { fetchData } = GetAddressListApi()
|
||||
useEffect(() => {
|
||||
getProvince()
|
||||
}, [])
|
||||
// 已选的集合市
|
||||
// const [choseCityArr, setchoseCityArr] = useState<any[]>([])
|
||||
const choseCityArr = useRef<any>({ list: [] })
|
||||
|
||||
// 省数组
|
||||
const [list, setlist] = useState<any[]>([])
|
||||
// 区数组
|
||||
const [cityList, setcityList] = useState<any[]>([])
|
||||
|
||||
//获取省
|
||||
const getProvince = async () => {
|
||||
let res = await fetchData({ parent_id: 1 })
|
||||
if (res.data) {
|
||||
setlist([...res.data.list])
|
||||
}
|
||||
}
|
||||
// 区分在哪一栏
|
||||
const [currentValue, setCurrentValue] = useState<number>(1)
|
||||
|
||||
// 顶部栏
|
||||
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])
|
||||
setCurrentValue(item.id)
|
||||
})
|
||||
}
|
||||
|
||||
//已选的集合市
|
||||
// const [choseCityArr, setchoseCityArr] = useState<any[]>([])
|
||||
const choseCityArr = useRef<any>({ list: [] })
|
||||
// 选择省
|
||||
const handProvince = (item) => {
|
||||
list.map((it) => {
|
||||
if (item.id == it.id) {
|
||||
it.check = true
|
||||
}
|
||||
return it
|
||||
})
|
||||
setlist([...list])
|
||||
getCity(item.id)
|
||||
setCurrentValue(2)
|
||||
TarBarList.map((it) => {
|
||||
if (it.id == currentValue) {
|
||||
it.name = item.name
|
||||
it.showBorder = false
|
||||
}
|
||||
else {
|
||||
it.showBorder = true
|
||||
}
|
||||
|
||||
//省数组
|
||||
const [list, setlist] = useState<any[]>([])
|
||||
//区数组
|
||||
const [cityList, setcityList] = useState<any[]>([])
|
||||
return it
|
||||
})
|
||||
setTarBarList([...TarBarList])
|
||||
}
|
||||
|
||||
//区分在哪一栏
|
||||
const [currentValue, setCurrentValue] = useState<number>(1)
|
||||
|
||||
//顶部栏
|
||||
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])
|
||||
setCurrentValue(item.id)
|
||||
// 获取市
|
||||
const getCity = async(id) => {
|
||||
const res = await fetchData({ parent_id: id })
|
||||
if (res.data) {
|
||||
res.data.list.map((item) => {
|
||||
choseCityArr.current.list.forEach((it) => {
|
||||
if (item.id == it.id) {
|
||||
item.check = true
|
||||
}
|
||||
})
|
||||
return item
|
||||
})
|
||||
setcityList([...res.data.list])
|
||||
}
|
||||
const provinceArr = list.filter((next) => { return next.check })
|
||||
props.handCity?.(provinceArr, choseCityArr.current.list)
|
||||
}
|
||||
|
||||
//选择省
|
||||
const handProvince = (item) => {
|
||||
list.map(it => {
|
||||
if (item.id == it.id) {
|
||||
it.check = true
|
||||
}
|
||||
return it
|
||||
})
|
||||
setlist([...list])
|
||||
getCity(item.id)
|
||||
setCurrentValue(2)
|
||||
TarBarList.map(it => {
|
||||
if (it.id == currentValue) {
|
||||
it.name = item.name
|
||||
it.showBorder = false
|
||||
} else {
|
||||
it.showBorder = true
|
||||
}
|
||||
|
||||
return it
|
||||
})
|
||||
setTarBarList([...TarBarList])
|
||||
// 选择市
|
||||
const handCity = (item) => {
|
||||
cityList.map((it) => {
|
||||
if (item.id == it.id) {
|
||||
it.check = !it.check
|
||||
}
|
||||
return it
|
||||
})
|
||||
setcityList([...cityList])
|
||||
const cityArr = cityList.filter((next) => { return next.check })
|
||||
if (item.check) {
|
||||
choseCityArr.current.list.push(item)
|
||||
}
|
||||
|
||||
//获取市
|
||||
const getCity = async (id) => {
|
||||
let res = await fetchData({ parent_id: id })
|
||||
if (res.data) {
|
||||
res.data.list.map(item => {
|
||||
choseCityArr.current.list.forEach(it => {
|
||||
if (item.id == it.id) {
|
||||
item.check = true
|
||||
}
|
||||
})
|
||||
return item
|
||||
})
|
||||
setcityList([...res.data.list])
|
||||
else {
|
||||
deleteById(item.id, choseCityArr.current.list)
|
||||
}
|
||||
// 将市区的全部不选后,该省的颜色不高亮
|
||||
if (cityArr.length == 0) {
|
||||
list.map((item) => {
|
||||
if (cityList[0]?.parent_id == item.id) {
|
||||
item.check = false
|
||||
}
|
||||
let provinceArr = list.filter(next => { return next.check })
|
||||
props.handCity?.(provinceArr, choseCityArr.current.list)
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
}
|
||||
const provinceArr = list.filter((next) => { return next.check })
|
||||
props.handCity?.(provinceArr, choseCityArr.current.list)
|
||||
}
|
||||
|
||||
|
||||
//选择市
|
||||
const handCity = (item) => {
|
||||
cityList.map(it => {
|
||||
if (item.id == it.id) {
|
||||
it.check = !it.check
|
||||
}
|
||||
return it
|
||||
})
|
||||
setcityList([...cityList])
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 根据id删除数组项
|
||||
* @param {Number} id 需要删除的id
|
||||
* @param {Array} list 目标数组
|
||||
*
|
||||
* @return {Array}
|
||||
*
|
||||
* @return {Array}
|
||||
*/
|
||||
function deleteById(id, list) {
|
||||
for (let index = list.length - 1; index >= 0; index--) {
|
||||
if (list[index] && list[index].id === id) {
|
||||
list.splice(index, 1)
|
||||
}
|
||||
}
|
||||
return list
|
||||
function deleteById(id, list) {
|
||||
for (let index = list.length - 1; index >= 0; index--) {
|
||||
if (list[index] && list[index].id === id) {
|
||||
list.splice(index, 1)
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
//重置
|
||||
const handReset = () => {
|
||||
TarBarList.map((item, index) => {
|
||||
if (index == 0) {
|
||||
item.name = '选择省'
|
||||
item.showBorder = true
|
||||
} else {
|
||||
item.showBorder = false
|
||||
// 重置
|
||||
const handReset = () => {
|
||||
TarBarList.map((item, index) => {
|
||||
if (index == 0) {
|
||||
item.name = '选择省'
|
||||
item.showBorder = true
|
||||
}
|
||||
else {
|
||||
item.showBorder = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTarBarList([...TarBarList])
|
||||
setCurrentValue(1)
|
||||
choseCityArr.current.list = []
|
||||
list.map((item) => {
|
||||
item.check = false
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
cityList.map((item) => {
|
||||
item.check = false
|
||||
return item
|
||||
})
|
||||
setcityList([...cityList])
|
||||
props.handCity?.('', '')
|
||||
}
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title="所有省市" value={-1} activeColor="#337fff" onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
<Tabs list={TarBarList} handChose={item => handChose?.(item)} handReset={() => handReset()}></Tabs>
|
||||
{
|
||||
currentValue == 1 && <ScrollView scrollY className={styles.scrollView}>
|
||||
{
|
||||
list.map((item) => {
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => handProvince(item)}>
|
||||
<View className={classnames(item.check ? styles.activeitemProvince : styles.itemProvince)}>{item.name}</View>
|
||||
<IconFont name="icon-chakanquanbukehu" size={50} color="#d8d8d8"></IconFont>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTarBarList([...TarBarList])
|
||||
setCurrentValue(1)
|
||||
choseCityArr.current.list = []
|
||||
list.map(item => {
|
||||
item.check = false
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
cityList.map(item => {
|
||||
item.check = false
|
||||
return item
|
||||
})
|
||||
setcityList([...cityList])
|
||||
props.handCity?.('', '')
|
||||
}
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title={'所有省市'} value={-1} activeColor='#337fff' onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
<Tabs list={TarBarList} handChose={(item) => handChose?.(item)} handReset={() => handReset()}></Tabs>
|
||||
{
|
||||
currentValue == 1 && <ScrollView scrollY className={styles.scrollView}>
|
||||
{
|
||||
list.map(item => {
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => handProvince(item)}>
|
||||
<View className={classnames(item.check ? styles.activeitemProvince : styles.itemProvince)}>{item.name}</View>
|
||||
<IconFont name={'icon-chakanquanbukehu'} size={50} color={'#d8d8d8'}></IconFont>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
}
|
||||
{
|
||||
currentValue == 2 && <ScrollView scrollY className={styles.scrollView}>
|
||||
{
|
||||
cityList.map(item => {
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => handCity(item)}>
|
||||
<View className={classnames(item.check ? styles.activeitemProvince : styles.itemProvince)}>{item.name}</View>
|
||||
{/* <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#d8d8d8'}></IconFont> */}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
}
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
}))
|
||||
</ScrollView>
|
||||
}
|
||||
{
|
||||
currentValue == 2 && <ScrollView scrollY className={styles.scrollView}>
|
||||
{
|
||||
cityList.map((item) => {
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => handCity(item)}>
|
||||
<View className={classnames(item.check ? styles.activeitemProvince : styles.itemProvince)}>{item.name}</View>
|
||||
{/* <IconFont name={'icon-chakanquanbukehu'} size={50} color={'#d8d8d8'}></IconFont> */}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ScrollView>
|
||||
}
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
}))
|
||||
|
||||
@@ -1,97 +1,97 @@
|
||||
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 {
|
||||
obj: any,
|
||||
sortId: number | string
|
||||
obj: any
|
||||
sortId: number | string
|
||||
}
|
||||
|
||||
export default memo((props: Props) => {
|
||||
const handPhone = (e) => {
|
||||
e.stopPropagation()
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: props.obj?.phone,
|
||||
})
|
||||
}
|
||||
|
||||
const handPhone = (e) => {
|
||||
e.stopPropagation()
|
||||
Taro.makePhoneCall({
|
||||
phoneNumber: props.obj?.phone
|
||||
})
|
||||
const handNav = () => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/customerDetails/index?purchaser_id=${props.obj?.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
const time = useMemo(() => {
|
||||
if (props?.sortId == '' || !props?.sortId) {
|
||||
return props?.obj?.recent_order_time
|
||||
}
|
||||
|
||||
const handNav = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/customerDetails/index?purchaser_id=' + props.obj?.id
|
||||
})
|
||||
if (props?.sortId == 1 || props?.sortId == -1) {
|
||||
return props?.obj?.recent_order_time
|
||||
}
|
||||
if (props?.sortId == 2 || props?.sortId == -2) {
|
||||
return props?.obj?.create_time
|
||||
}
|
||||
if (props?.sortId == 3 || props?.sortId == -3) {
|
||||
return props?.obj?.update_time
|
||||
}
|
||||
}, [props?.sortId])
|
||||
|
||||
const time = useMemo(() => {
|
||||
if (props?.sortId == '' || !props?.sortId) {
|
||||
return props?.obj?.recent_order_time
|
||||
}
|
||||
if (props?.sortId == 1 || props?.sortId == -1) {
|
||||
return props?.obj?.recent_order_time
|
||||
}
|
||||
if (props?.sortId == 2 || props?.sortId == -2) {
|
||||
return props?.obj?.create_time
|
||||
}
|
||||
if (props?.sortId == 3 || props?.sortId == -3) {
|
||||
return props?.obj?.update_time
|
||||
}
|
||||
}, [props?.sortId])
|
||||
const timeFont = useMemo(() => {
|
||||
if (props?.sortId == '' || !props?.sortId) {
|
||||
return '下单时间'
|
||||
}
|
||||
if (props?.sortId == 1 || props?.sortId == -1) {
|
||||
return '下单时间'
|
||||
}
|
||||
if (props?.sortId == 2 || props?.sortId == -2) {
|
||||
return '创建时间'
|
||||
}
|
||||
if (props?.sortId == 3 || props?.sortId == -3) {
|
||||
return '更新时间'
|
||||
}
|
||||
}, [props?.sortId])
|
||||
|
||||
const timeFont = useMemo(() => {
|
||||
if (props?.sortId == '' || !props?.sortId) {
|
||||
return '下单时间'
|
||||
}
|
||||
if (props?.sortId == 1 || props?.sortId == -1) {
|
||||
return '下单时间'
|
||||
}
|
||||
if (props?.sortId == 2 || props?.sortId == -2) {
|
||||
return '创建时间'
|
||||
}
|
||||
if (props?.sortId == 3 || props?.sortId == -3) {
|
||||
return '更新时间'
|
||||
}
|
||||
}, [props?.sortId])
|
||||
|
||||
return (
|
||||
<View className={styles.mainItem} onClick={() => handNav()}>
|
||||
<View className={styles.itemTop}>
|
||||
<View className={styles.itemLeft}>
|
||||
<View className={styles.leftSafe}>
|
||||
<View className={styles.itemCile}>{props.obj.name[0]}</View>
|
||||
</View>
|
||||
<View className={styles.item_top_one}>
|
||||
<View className={styles.item_top_one_flex}>
|
||||
<View className={styles.itemName}>{props.obj.name}</View>
|
||||
<View className={styles.itemPhone}>{props.obj.phone}</View>
|
||||
</View>
|
||||
<View className={styles.item_tag_box}>
|
||||
<View className={styles.item_tagItem}>{props.obj.purchaser_type_name || '暂无'}</View>
|
||||
<View className={styles.item_tagItem}>{props.obj.sale_user_name || '暂无'}</View>
|
||||
{
|
||||
props.obj?.label_list?.map(item => {
|
||||
return (
|
||||
<View className={styles.item_tagItem}>{item.label_name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.itemRight} onClick={(e) => handPhone(e)}>
|
||||
|
||||
<IconFont name={'icon-dianhua'} size={30} color={'#337FFF'}></IconFont>
|
||||
<View className={styles.phoneFont}>联系TA</View>
|
||||
</View>
|
||||
return (
|
||||
<View className={styles.mainItem} onClick={() => handNav()}>
|
||||
<View className={styles.itemTop}>
|
||||
<View className={styles.itemLeft}>
|
||||
<View className={styles.leftSafe}>
|
||||
<View className={styles.itemCile}>{props.obj.name[0]}</View>
|
||||
</View>
|
||||
<View className={styles.item_top_one}>
|
||||
<View className={styles.item_top_one_flex}>
|
||||
<View className={styles.itemName}>{props.obj.name}</View>
|
||||
<View className={styles.itemPhone}>{props.obj.phone}</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.flex_bottom}>
|
||||
<View className={styles.flex_left}>{props.obj.default_address.province_name + props.obj.default_address.city_name + props.obj.default_address.district_name || '暂无'}</View>
|
||||
<View className={styles.flex_right}>{timeFont}:{formatDateTime(time) || '暂无'}</View>
|
||||
<View className={styles.item_tag_box}>
|
||||
<View className={styles.item_tagItem}>{props.obj.purchaser_type_name || '暂无'}</View>
|
||||
<View className={styles.item_tagItem}>{props.obj.sale_user_name || '暂无'}</View>
|
||||
{
|
||||
props.obj?.label_list?.map((item) => {
|
||||
return (
|
||||
<View className={styles.item_tagItem}>{item.label_name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.itemRight} onClick={e => handPhone(e)}>
|
||||
|
||||
<IconFont name="icon-dianhua" size={30} color="#337FFF"></IconFont>
|
||||
<View className={styles.phoneFont}>联系TA</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.flex_bottom}>
|
||||
<View className={styles.flex_left}>{props.obj.default_address.province_name + props.obj.default_address.city_name + props.obj.default_address.district_name || '暂无'}</View>
|
||||
<View className={styles.flex_right}>{timeFont}:{formatDateTime(time) || '暂无'}</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,109 +1,108 @@
|
||||
import { View } 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 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 } from '@/common/common'
|
||||
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
|
||||
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import DropDownItem from '@/components/dropDown-item'
|
||||
|
||||
interface Props {
|
||||
handSort?: (any) => void,
|
||||
value?: any,
|
||||
onCloseOverlay?: () => void
|
||||
handSort?: (any) => void
|
||||
value?: any
|
||||
onCloseOverlay?: () => void
|
||||
}
|
||||
|
||||
type ListType = {
|
||||
name: string,
|
||||
id: string,
|
||||
checked: boolean
|
||||
interface ListType {
|
||||
name: string
|
||||
id: string
|
||||
checked: boolean
|
||||
}
|
||||
|
||||
export default memo(forwardRef((props: Props, ref) => {
|
||||
const DropDownItemRef = useRef<any>()
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
|
||||
const DropDownItemRef = useRef<any>()
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
const [list, setlist] = useState<ListType[]>([
|
||||
{
|
||||
name: '下单时间正序',
|
||||
id: '1',
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '创建时间正序',
|
||||
id: '2',
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '更新时间正序',
|
||||
id: '3',
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '下单时间倒序',
|
||||
id: '-1',
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '创建时间倒序',
|
||||
id: '-2',
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '更新时间倒序',
|
||||
id: '-3',
|
||||
checked: false,
|
||||
},
|
||||
])
|
||||
|
||||
const [currentValue, setCurrentValue] = useState<number>(-1)
|
||||
|
||||
const [list, setlist] = useState<ListType[]>([
|
||||
{
|
||||
name: '下单时间正序',
|
||||
id: '1',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '创建时间正序',
|
||||
id: '2',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '更新时间正序',
|
||||
id: '3',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '下单时间倒序',
|
||||
id: '-1',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '创建时间倒序',
|
||||
id: '-2',
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '更新时间倒序',
|
||||
id: '-3',
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
const handItem = (it) => {
|
||||
list.map((item) => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
props.handSort?.(it.id)
|
||||
}
|
||||
|
||||
const [currentValue, setCurrentValue] = useState<number>(-1)
|
||||
|
||||
const handItem = (it) => {
|
||||
list.map(item => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
props.handSort?.(it.id)
|
||||
const title = useMemo(() => {
|
||||
const arr = list.filter((item) => { return item.checked })
|
||||
if (!arr.length) {
|
||||
return '默认排序'
|
||||
}
|
||||
else {
|
||||
return arr[0]?.name
|
||||
}
|
||||
}, [list])
|
||||
|
||||
|
||||
const title = useMemo(() => {
|
||||
let arr = list.filter(item => { return item.checked })
|
||||
if (!arr.length) {
|
||||
return '默认排序'
|
||||
} else {
|
||||
return arr[0]?.name
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title={title} value={currentValue} activeColor="#337fff" onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handItem?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
}, [list])
|
||||
|
||||
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title={title} value={currentValue} activeColor='#337fff' onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handItem?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
}))
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
}))
|
||||
|
||||
@@ -1,118 +1,119 @@
|
||||
import { View } 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 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 } from '@/common/common'
|
||||
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
|
||||
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import { EnumPurchaserType } from '@/api/order'
|
||||
import DropDownItem from '@/components/dropDown-item'
|
||||
import { mppurchaserlist } from "@/api/customer"
|
||||
import { mppurchaserlist } from '@/api/customer'
|
||||
|
||||
interface Props {
|
||||
handType: (any) => void,
|
||||
handTags: (any) => void,
|
||||
value?: any,
|
||||
onCloseOverlay?: () => void
|
||||
handType: (any) => void
|
||||
handTags: (any) => void
|
||||
value?: any
|
||||
onCloseOverlay?: () => void
|
||||
}
|
||||
|
||||
export default memo(forwardRef((props: Props, ref) => {
|
||||
const DropDownItemRef = useRef<any>()
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
const [currentValue, setCurrentValue] = useState<number>(-1)
|
||||
|
||||
const DropDownItemRef = useRef<any>()
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => {
|
||||
return {
|
||||
show: DropDownItemRef?.current?.show,
|
||||
showPopup: DropDownItemRef?.current.showPopup,
|
||||
closePopup: DropDownItemRef?.current?.closePopup,
|
||||
}
|
||||
},
|
||||
[DropDownItemRef?.current],
|
||||
)
|
||||
const [currentValue, setCurrentValue] = useState<number>(-1)
|
||||
const [list, setlist] = useState<any[]>([
|
||||
{
|
||||
name: '二批',
|
||||
id: 0,
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '制衣厂',
|
||||
id: 1,
|
||||
checked: false,
|
||||
},
|
||||
{
|
||||
name: '布行',
|
||||
id: 2,
|
||||
checked: false,
|
||||
},
|
||||
])
|
||||
|
||||
const [list, setlist] = useState<any[]>([
|
||||
{
|
||||
name: '二批',
|
||||
id: 0,
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '制衣厂',
|
||||
id: 1,
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
name: '布行',
|
||||
id: 2,
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
useEffect(() => {
|
||||
getList()
|
||||
}, [])
|
||||
const { fetchData: fetchPurchaserType } = EnumPurchaserType()
|
||||
const { fetchData } = mppurchaserlist()
|
||||
const getList = async () => {
|
||||
const res = await fetchData()
|
||||
const purchaserType = await fetchPurchaserType()
|
||||
if (res.data) {
|
||||
settaglist([...res.data.list])
|
||||
setlist([...purchaserType.data.list])
|
||||
}
|
||||
useEffect(() => {
|
||||
getList()
|
||||
}, [])
|
||||
const { fetchData: fetchPurchaserType } = EnumPurchaserType()
|
||||
const { fetchData } = mppurchaserlist()
|
||||
const getList = async() => {
|
||||
const res = await fetchData()
|
||||
const purchaserType = await fetchPurchaserType()
|
||||
if (res.data) {
|
||||
settaglist([...res.data.list])
|
||||
setlist([...purchaserType.data.list])
|
||||
}
|
||||
}
|
||||
|
||||
const [taglist, settaglist] = useState<any[]>([])
|
||||
const [taglist, settaglist] = useState<any[]>([])
|
||||
|
||||
const handItem = (it) => {
|
||||
list.map(item => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
props.handType(list)
|
||||
}
|
||||
const handItem = (it) => {
|
||||
list.map((item) => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setlist([...list])
|
||||
props.handType(list)
|
||||
}
|
||||
|
||||
const handTag = (it) => {
|
||||
taglist.map(item => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
return item
|
||||
})
|
||||
settaglist([...taglist])
|
||||
props.handTags(taglist)
|
||||
}
|
||||
const handTag = (it) => {
|
||||
taglist.map((item) => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
return item
|
||||
})
|
||||
settaglist([...taglist])
|
||||
props.handTags(taglist)
|
||||
}
|
||||
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title={'自定标签'} value={currentValue} activeColor='#337fff' onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
<View className={styles.pussTitle}>客户类型</View>
|
||||
<View className={styles.pussBox}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handItem?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
<View className={styles.pussTitle}>自定义标签</View>
|
||||
<View className={styles.pussBox}>
|
||||
{
|
||||
taglist.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handTag?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
return (
|
||||
<DropDownItem ref={DropDownItemRef} title="自定标签" value={currentValue} activeColor="#337fff" onCloseOverlay={props?.onCloseOverlay}>
|
||||
<View className={styles.mainBox}>
|
||||
<View className={styles.pussTitle}>客户类型</View>
|
||||
<View className={styles.pussBox}>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handItem?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
<View className={styles.pussTitle}>自定义标签</View>
|
||||
<View className={styles.pussBox}>
|
||||
{
|
||||
taglist.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.itemactiveFlex : styles.itemFlex)} onClick={() => handTag?.(item)}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</DropDownItem>
|
||||
)
|
||||
}))
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
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,
|
||||
handReset?: () => void
|
||||
list: any[]
|
||||
handChose?: (any) => void
|
||||
handReset?: () => void
|
||||
}
|
||||
export default memo((props: Props) => {
|
||||
const { list = [], handChose } = props
|
||||
const { list = [], handChose } = props
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.flexBox}>
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<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 >
|
||||
{
|
||||
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 >
|
||||
)
|
||||
})
|
||||
item.showBorder && <View className={styles.borderBox} ></View>
|
||||
}
|
||||
</View >
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</View >
|
||||
<View className={styles.resetBox} onClick={() => props?.handReset?.()}>重置</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View >
|
||||
<View className={styles.resetBox} onClick={() => props?.handReset?.()}>重置</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '客户列表',
|
||||
navigationBarTitleText: '客户列表',
|
||||
}
|
||||
|
||||
@@ -1,174 +1,171 @@
|
||||
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 Tag from './components/Tag'
|
||||
import Sort from './components/Sort'
|
||||
import ChoseCity from './components/ChoseCity'
|
||||
import ItemLiist from './components/ItemList'
|
||||
import Popup from '@/components/popup'
|
||||
import { debounce } from '@/common/util'
|
||||
import { alert } from '@/common/common'
|
||||
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import Tag from './components/Tag';
|
||||
import Sort from './components/Sort';
|
||||
import ChoseCity from './components/ChoseCity';
|
||||
import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
|
||||
import { alert, goLink } from '@/common/common'
|
||||
import { formatDateTime, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import Search from '@/components/search'
|
||||
import ItemLiist from "./components/ItemList"
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { ClientListApi } from '@/api/order'
|
||||
import { goLink } from '@/common/common'
|
||||
import SelectGroup from '@/components/SelectGroup'
|
||||
|
||||
export default () => {
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
page: number
|
||||
size: number
|
||||
label_ids: string
|
||||
purchaser_type: number | string
|
||||
name_phone_or_sale_user: string
|
||||
province_id: any[] | string
|
||||
city_id: any[] | string
|
||||
abstract_sort_key: string
|
||||
}
|
||||
>({
|
||||
page: 1,
|
||||
size: 10,
|
||||
label_ids: '',
|
||||
purchaser_type: '',
|
||||
name_phone_or_sale_user: '',
|
||||
province_id: '',
|
||||
city_id: '',
|
||||
abstract_sort_key: '',
|
||||
})
|
||||
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
page: number;
|
||||
size: number;
|
||||
label_ids: string,
|
||||
purchaser_type: number | string,
|
||||
name_phone_or_sale_user: string,
|
||||
province_id: any[] | string,
|
||||
city_id: any[] | string,
|
||||
abstract_sort_key: string,
|
||||
}
|
||||
>({
|
||||
page: 1,
|
||||
size: 10,
|
||||
label_ids: '',
|
||||
purchaser_type: '',
|
||||
name_phone_or_sale_user: '',
|
||||
province_id: '',
|
||||
city_id: '',
|
||||
abstract_sort_key: ''
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
const { fetchData: listFetchData, state: orderState } = ClientListApi()
|
||||
const getOrderList = async() => {
|
||||
const res = await listFetchData({
|
||||
...getFilterData(searchField),
|
||||
})
|
||||
setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
const { fetchData: listFetchData, state: orderState } = ClientListApi()
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData({
|
||||
...getFilterData(searchField)
|
||||
})
|
||||
setOrderData((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
// 监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField])
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField(val => ({ ...val, name_phone_or_sale_user: e, size: 10 }))
|
||||
}, [])
|
||||
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! })
|
||||
}, [orderData, orderState])
|
||||
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField])
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
|
||||
// 选择排序
|
||||
const sortRefRef = useRef<any>()
|
||||
const handSort = useCallback((e: string) => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField(val => ({ ...val, size: 10, abstract_sort_key: e }))
|
||||
sortRefRef.current = e
|
||||
}, [])
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, name_phone_or_sale_user: e, size: 10 }))
|
||||
}, [])
|
||||
const SortRef = useRef<any>()
|
||||
const TagRef = useRef<any>()
|
||||
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! })
|
||||
}, [orderData, orderState])
|
||||
// 筛选城市
|
||||
const ChoseCityRef = useRef<any>()
|
||||
const handCity = useCallback((provinceVal, cityVal) => {
|
||||
const provinceArr: number[] = []
|
||||
const cityArr: number[] = []
|
||||
provinceVal.length && provinceVal.forEach((item) => {
|
||||
provinceArr.push(item.id)
|
||||
})
|
||||
cityVal.length && cityVal.forEach((item) => {
|
||||
cityArr.push(item.id)
|
||||
})
|
||||
pageNum.current.page = 1
|
||||
const provinceRes = provinceArr?.toString()
|
||||
const cityRes = cityArr?.toString()
|
||||
console.log(provinceRes, cityRes)
|
||||
setSearchField(val => ({ ...val, province_id: provinceArr.length > 0 ? provinceRes : '', city_id: cityArr.length > 0 ? cityRes : '', size: 10 }))
|
||||
// ChoseCityRef.current.close()
|
||||
}, [])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
// 选择客户类型
|
||||
const handType = useCallback((val) => {
|
||||
const arr = val.filter((item) => { return item.checked })
|
||||
pageNum.current.page = 1
|
||||
setSearchField(val => ({ ...val, size: 10, purchaser_type: arr[0]?.id }))
|
||||
}, [])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField((val) => ({ ...val, size: 10 }))
|
||||
}
|
||||
// 选择标签
|
||||
const handTags = useCallback((val) => {
|
||||
const arr: any[] = []
|
||||
const arrOne = val.filter((item) => { return item.checked })
|
||||
arrOne.forEach((item) => {
|
||||
arr.push(item.id)
|
||||
})
|
||||
pageNum.current.page = 1
|
||||
const res = arr.toString()
|
||||
setSearchField(val => ({ ...val, size: 10, label_ids: arr.length === 0 ? '' : res }))
|
||||
}, [])
|
||||
|
||||
//选择排序
|
||||
const sortRefRef = useRef<any>()
|
||||
const handSort = useCallback((e: string) => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField((val) => ({ ...val, size: 10, abstract_sort_key: e }))
|
||||
sortRefRef.current = e
|
||||
}, [])
|
||||
|
||||
const SortRef = useRef<any>()
|
||||
const TagRef = useRef<any>()
|
||||
|
||||
//筛选城市
|
||||
const ChoseCityRef = useRef<any>()
|
||||
const handCity = useCallback((provinceVal, cityVal) => {
|
||||
const provinceArr: number[] = []
|
||||
const cityArr: number[] = []
|
||||
provinceVal.length && provinceVal.forEach(item => {
|
||||
provinceArr.push(item.id)
|
||||
})
|
||||
cityVal.length && cityVal.forEach(item => {
|
||||
cityArr.push(item.id)
|
||||
})
|
||||
pageNum.current.page = 1
|
||||
let provinceRes = provinceArr?.toString()
|
||||
let cityRes = cityArr?.toString()
|
||||
console.log(provinceRes, cityRes)
|
||||
setSearchField((val) => ({ ...val, province_id: provinceArr.length > 0 ? provinceRes : '', city_id: cityArr.length > 0 ? cityRes : '', size: 10 }))
|
||||
// ChoseCityRef.current.close()
|
||||
}, [])
|
||||
|
||||
//选择客户类型
|
||||
const handType = useCallback((val) => {
|
||||
const arr = val.filter(item => { return item.checked })
|
||||
pageNum.current.page = 1
|
||||
setSearchField((val) => ({ ...val, size: 10, purchaser_type: arr[0]?.id }))
|
||||
}, [])
|
||||
|
||||
//选择标签
|
||||
const handTags = useCallback((val) => {
|
||||
const arr: any[] = []
|
||||
const arrOne = val.filter(item => { return item.checked })
|
||||
arrOne.forEach(item => {
|
||||
arr.push(item.id)
|
||||
})
|
||||
pageNum.current.page = 1
|
||||
let res = arr.toString()
|
||||
setSearchField((val) => ({ ...val, size: 10, label_ids: arr.length === 0 ? '' : res }))
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.mainBox}>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.search_input}>
|
||||
<Search placeholder='搜索客户名称、电话、业务员' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
<View className={styles.menuBox} >
|
||||
<SelectGroup>
|
||||
<Sort ref={SortRef} handSort={handSort} onCloseOverlay={() => true}></Sort>
|
||||
<ChoseCity ref={ChoseCityRef} handCity={handCity} onCloseOverlay={() => true}></ChoseCity>
|
||||
<Tag ref={TagRef} handTags={handTags} handType={handType} onCloseOverlay={() => true}></Tag>
|
||||
</SelectGroup>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.totalFont}>共 {orderData?.total || 0} 个客户</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<ItemLiist sortId={sortRefRef.current} obj={item}></ItemLiist>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<View className={styles.bottom_box}>
|
||||
<View className={styles.bottom_btn} onClick={() => goLink('/pages/customerEditor/index?type=add')}>新建客户</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
return (
|
||||
<View className={styles.mainBox}>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.search_input}>
|
||||
<Search placeholder="搜索客户名称、电话、业务员" showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
<View className={styles.menuBox} >
|
||||
<SelectGroup>
|
||||
<Sort ref={SortRef} handSort={handSort} onCloseOverlay={() => true}></Sort>
|
||||
<ChoseCity ref={ChoseCityRef} handCity={handCity} onCloseOverlay={() => true}></ChoseCity>
|
||||
<Tag ref={TagRef} handTags={handTags} handType={handType} onCloseOverlay={() => true}></Tag>
|
||||
</SelectGroup>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.totalFont}>共 {orderData?.total || 0} 个客户</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<ItemLiist sortId={sortRefRef.current} obj={item}></ItemLiist>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<View className={styles.bottom_box}>
|
||||
<View className={styles.bottom_btn} onClick={() => goLink('/pages/customerEditor/index?type=add')}>新建客户</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '选择客户',
|
||||
navigationBarTitleText: '选择客户',
|
||||
}
|
||||
|
||||
+135
-141
@@ -1,155 +1,149 @@
|
||||
import { View, ScrollView, Image, 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, Image, Input, ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Search from '@/components/search'
|
||||
import { ClientListApi } from '@/api/order'
|
||||
import { useDidShow } from '@tarojs/taro';
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const [search, setSearch] = useState({
|
||||
name_phone_or_sale_user: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = ClientListApi()
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: null,
|
||||
clientName: '',
|
||||
})
|
||||
|
||||
const [search, setSearch] = useState({
|
||||
name_phone_or_sale_user: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch(e => ({ ...e, name_phone_or_sale_user: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.name_phone_or_sale_user === '') {
|
||||
setSearch(e => ({ ...e, name_phone_or_sale_user: null }))
|
||||
}
|
||||
if (search.name_phone_or_sale_user !== '') { getCuss() }
|
||||
}, [search])
|
||||
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch(e => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
const getCuss = async() => {
|
||||
const res = await clitentFetch({ name_phone_or_sale_user: search.name_phone_or_sale_user === null ? '' : search.name_phone_or_sale_user, page: search.page, size: search.size })
|
||||
if (router?.params.clientId) {
|
||||
res.data.list.map((item) => {
|
||||
if (item.id == router?.params.clientId) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
// 选择客户
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = ClientListApi()
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: null,
|
||||
clientName: ''
|
||||
setclientObj(item)
|
||||
const pages = Taro.getCurrentPages() // 获取当前的页面栈
|
||||
const prevPage = pages[pages.length - 2]
|
||||
prevPage.setData({ // 设置上一个页面的值
|
||||
clientId: item.id,
|
||||
clientName: item.name,
|
||||
})
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch((e) => ({ ...e, name_phone_or_sale_user: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.name_phone_or_sale_user === '') {
|
||||
setSearch((e) => ({ ...e, name_phone_or_sale_user: null }))
|
||||
}
|
||||
if (search.name_phone_or_sale_user !== '') getCuss()
|
||||
}, [search])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch((e) => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch((val) => ({ ...val, size: 10 }))
|
||||
setClientlist(e => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.clientId !== null) {
|
||||
setclientObj(clientObj)
|
||||
}
|
||||
const getCuss = async () => {
|
||||
let res = await clitentFetch({ name_phone_or_sale_user: search.name_phone_or_sale_user === null ? '' : search.name_phone_or_sale_user, page: search.page, size: search.size })
|
||||
if (router?.params.clientId) {
|
||||
res.data.list.map(item => {
|
||||
if (item.id == router?.params.clientId) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//选择客户
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map(it => {
|
||||
if (item.id === it.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setclientObj(item)
|
||||
let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({ //设置上一个页面的值
|
||||
clientId: item.id,
|
||||
clientName: item.name,
|
||||
});
|
||||
setClientlist((e) => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.clientId !== null) {
|
||||
setclientObj(clientObj)
|
||||
}
|
||||
// else {
|
||||
// let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
// let prevPage = pages[pages.length - 2];
|
||||
// prevPage.setData({ //设置上一个页面的值
|
||||
// clientId: '',
|
||||
// clientName: '',
|
||||
// });
|
||||
// }
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
<View className={styles.searchBox}>
|
||||
<View className={styles.two}>
|
||||
<Search placeholder='请输入客户名称或手机号码' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
|
||||
</View>
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.name}</View>
|
||||
<View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.woker}>{item.sale_user_name}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
|
||||
// else {
|
||||
// let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
// let prevPage = pages[pages.length - 2];
|
||||
// prevPage.setData({ //设置上一个页面的值
|
||||
// clientId: '',
|
||||
// clientName: '',
|
||||
// });
|
||||
// }
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
<View className={styles.searchBox}>
|
||||
<View className={styles.two}>
|
||||
<Search placeholder="请输入客户名称或手机号码" showBtn={false} changeOnSearch={getSearchData} debounceTime={300} />
|
||||
</View>
|
||||
)
|
||||
|
||||
</View>
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.name}</View>
|
||||
<View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.woker}>{item.sale_user_name}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import SegmentedControl from '@/components/segmentedControl'
|
||||
import { FC, memo, useCallback, useEffect, useState } from 'react'
|
||||
import SegmentedControl from '@/components/segmentedControl'
|
||||
import { EnumSaleorderStatus } from '@/api/index'
|
||||
|
||||
type PropsType = {
|
||||
onChangeStatus?: (data: {id: number, name: string}) => void
|
||||
interface PropsType {
|
||||
onChangeStatus?: (data: { id: number; name: string }) => void
|
||||
}
|
||||
|
||||
const DeliveryStatusList = memo<PropsType>((props) => {
|
||||
const { onChangeStatus } = props
|
||||
const { onChangeStatus } = props
|
||||
const { fetchData } = EnumSaleorderStatus()
|
||||
const [statusList, setStatusList] = useState([
|
||||
{
|
||||
@@ -16,12 +16,12 @@ const DeliveryStatusList = memo<PropsType>((props) => {
|
||||
},
|
||||
])
|
||||
// 请求
|
||||
const getDeliveryStatusList = async () => {
|
||||
const getDeliveryStatusList = async() => {
|
||||
const res = await fetchData()
|
||||
console.log(res.data.list);
|
||||
console.log(res.data.list)
|
||||
setStatusList(
|
||||
res.data.list.filter((item) => {
|
||||
return item.id === 3 || item.id === 4 // 待发货 已完成
|
||||
return item.id === 3 || item.id === 4 // 待发货 已完成
|
||||
}),
|
||||
)
|
||||
}
|
||||
@@ -32,8 +32,8 @@ const DeliveryStatusList = memo<PropsType>((props) => {
|
||||
|
||||
// //状态改变
|
||||
const changeStatus = useCallback(
|
||||
(data: {id:number, name: string}) => {
|
||||
onChangeStatus && onChangeStatus({ id: data.id, name: data.name })
|
||||
(data: { id: number; name: string }) => {
|
||||
onChangeStatus && onChangeStatus({ id: data.id, name: data.name })
|
||||
},
|
||||
[onChangeStatus],
|
||||
)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import classnames from 'classnames'
|
||||
import type { FC } from 'react'
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import Popup from '@/components/popup'
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import React, { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Search from '@/components/search'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { EnumDeliveryNoticeTypeList } from '@/api/index'
|
||||
import dayjs from 'dayjs'
|
||||
import { getFilterData } from '@/common/util'
|
||||
import Taro from '@tarojs/taro'
|
||||
|
||||
interface SearchFilter {
|
||||
type?: number
|
||||
@@ -80,25 +81,25 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
const handleSelectedType = (type: string | number) => {
|
||||
console.log('type==>', type)
|
||||
if (typeof type === 'string' && type === 'default') {
|
||||
setSearchFilter((e) => ({ ...e, type: undefined }))
|
||||
} else {
|
||||
setSearchFilter((e) => ({ ...e, type: type as number }))
|
||||
setSearchFilter(e => ({ ...e, type: undefined }))
|
||||
}
|
||||
else {
|
||||
setSearchFilter(e => ({ ...e, type: type as number }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const typeList = useMemo<{ id: number; name: string }[]>(() => {
|
||||
return state.data.list
|
||||
}, [state])
|
||||
|
||||
useEffect(() => {
|
||||
if (!!!typeList?.length) {
|
||||
if (!typeList?.length) {
|
||||
getEnumData()
|
||||
console.log('getEnumData')
|
||||
}
|
||||
}, [typeList])
|
||||
|
||||
const getEnumData = async () => {
|
||||
const getEnumData = async() => {
|
||||
await fetchData()
|
||||
}
|
||||
|
||||
@@ -107,18 +108,16 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
date_max: undefined,
|
||||
})
|
||||
|
||||
|
||||
|
||||
const handleSelectedTime = (timeOptionId) => {
|
||||
setSearchFilter((e) => ({ ...e, timeKey: timeOptionId }))
|
||||
setSearchFilter(e => ({ ...e, timeKey: timeOptionId }))
|
||||
// 不是设置了自定义时间
|
||||
if (timeOptionId !== '6') {
|
||||
setCustomTime({
|
||||
date_min: filterTimeOptions[timeOptionId]['date_min'],
|
||||
date_max: filterTimeOptions[timeOptionId]['date_max'],
|
||||
date_min: filterTimeOptions[timeOptionId].date_min,
|
||||
date_max: filterTimeOptions[timeOptionId].date_max,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
onSearchTime?.()
|
||||
}
|
||||
|
||||
@@ -144,8 +143,8 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
<FilterButton isActive={searchFilter.type == undefined} onClick={() => handleSelectedType('default')}>
|
||||
不限
|
||||
</FilterButton>
|
||||
{!!typeList?.length &&
|
||||
typeList?.map(item => {
|
||||
{!!typeList?.length
|
||||
&& typeList?.map((item) => {
|
||||
return (
|
||||
<FilterButton isActive={searchFilter.type === item?.id} onClick={() => handleSelectedType(item?.id)}>
|
||||
{item.name}
|
||||
@@ -166,15 +165,15 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
)
|
||||
})}
|
||||
<FilterButton isActive={searchFilter.timeKey === '6'} customClassName={styles.filterTimeButton} onClick={() => handleSelectedTime('6')}>
|
||||
自定义时间<IconFont name='icon-chakanquanbukehu' size={40} color={searchFilter.timeKey === '6' ? '#4581ff' : '#909090'}></IconFont>
|
||||
自定义时间<IconFont name="icon-chakanquanbukehu" size={40} color={searchFilter.timeKey === '6' ? '#4581ff' : '#909090'}></IconFont>
|
||||
</FilterButton>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.filterController}>
|
||||
<NormalButton plain type='primary' round customClassName={classnames(styles.btn, styles.rest_btn)} onClick={handleReset}>
|
||||
<NormalButton plain type="primary" round customClassName={classnames(styles.btn, styles.rest_btn)} onClick={handleReset}>
|
||||
重置
|
||||
</NormalButton>
|
||||
<NormalButton type='primary' round customClassName={classnames(styles.btn, styles.verify_btn)} onClick={handleConfirm}>
|
||||
<NormalButton type="primary" round customClassName={classnames(styles.btn, styles.verify_btn)} onClick={handleConfirm}>
|
||||
确认
|
||||
</NormalButton>
|
||||
</View>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import LayoutBlock from '@/components/layoutBlock'
|
||||
import Divider from '@/components/divider'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { FC } from 'react'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
import { formatDateTime, formatMeterDiv } from '@/common/format'
|
||||
import { goLink } from '@/common/common'
|
||||
@@ -13,12 +13,12 @@ import { goLink } from '@/common/common'
|
||||
import SaleModeTag from '@/components/saleModeTag'
|
||||
// import { alert } from '@/common/common'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
itemData: Record<string, any>
|
||||
onSuccess?: Function
|
||||
}
|
||||
|
||||
const ItemList:FC<PropsType> = (props) => {
|
||||
const ItemList: FC<PropsType> = (props) => {
|
||||
const { itemData, onSuccess } = props
|
||||
// 查看详情
|
||||
const handleDetail = (itemData: Record<string, any>) => {
|
||||
@@ -41,7 +41,7 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
// confirmColor: '#337FFF',
|
||||
// success: async (res) => {
|
||||
// if (res.confirm) {
|
||||
// const res = await fetchData({ id })
|
||||
// const res = await fetchData({ id })
|
||||
// if (res.success) {
|
||||
// Taro.showToast({ title: '审核成功', icon: 'success' })
|
||||
// onSuccess?.()
|
||||
@@ -63,12 +63,12 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
</View>
|
||||
<Text className={styles.topBar__orderType}>{itemData?.type_name}</Text>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0' }}></Divider>
|
||||
<View className={styles.content}>
|
||||
<View className={classnames(styles.content__row, styles.bord)}>
|
||||
<View className={styles.content__row__left}>货品信息:</View>
|
||||
<View className={styles.content__row__right}>
|
||||
<SaleModeTag saleMode={itemData.sale_mode} size='small' customClassName={styles.tag}></SaleModeTag>
|
||||
<SaleModeTag saleMode={itemData.sale_mode} size="small" customClassName={styles.tag}></SaleModeTag>
|
||||
{itemData.delivery_product_nums}种面料,{itemData.delivery_product_color_nums}种颜色,共
|
||||
{itemData?.sale_mode === EnumSaleMode.Bulk ? `${itemData?.delivery_roll}条` : `${formatMeterDiv(itemData?.delivery_length)}米`}
|
||||
</View>
|
||||
@@ -86,10 +86,11 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
<NormalButton
|
||||
customClassName={styles.bottomBar__button}
|
||||
plain
|
||||
type='info'
|
||||
type="info"
|
||||
customStyles={{ color: '#636363', borderColor: '#c8c8c8' }}
|
||||
round
|
||||
onClick={() => handleDetail(itemData)}>
|
||||
onClick={() => handleDetail(itemData)}
|
||||
>
|
||||
查看详情
|
||||
</NormalButton>
|
||||
{/* {itemData?.status === 0 && (
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, FC, memo } from 'react'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/ItemList'
|
||||
import DeliveryStatusList from './components/DeliveryStatusList'
|
||||
import type { SearchField } from './components/Filter'
|
||||
import DeliveryFilter from './components/Filter'
|
||||
import Search from '@/components/search'
|
||||
import { DeliverNoticeOrderList, EnumSaleorderStatus } from '@/api/index'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import IconText from '@/components/iconText'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import ItemList from './components/ItemList'
|
||||
import DeliveryStatusList from './components/DeliveryStatusList'
|
||||
import Popup from '@/components/popup'
|
||||
import DeliveryFilter, { SearchField } from './components/Filter'
|
||||
import TimePickerPopup from '@/components/timePickerPopup'
|
||||
|
||||
type SearchData = {
|
||||
interface SearchData {
|
||||
delivery_notice_order_no?: string // 发货单号
|
||||
delivery_notice_order_status?: number | string // 发货状态
|
||||
date_min?: string // 开始时间
|
||||
@@ -25,8 +26,6 @@ type SearchData = {
|
||||
size: number
|
||||
}
|
||||
|
||||
|
||||
|
||||
const defaultSearchFields = {
|
||||
delivery_notice_order_status: 0, // 待发货
|
||||
page: 1,
|
||||
@@ -41,51 +40,51 @@ const Delivery: FC = () => {
|
||||
const isFirst = useRef(true)
|
||||
|
||||
const { fetchData: FetchDeliveryOrderList, state: orderState } = DeliverNoticeOrderList()
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: deliveryOrderList.list, total: deliveryOrderList.total, status: orderState.loading! })
|
||||
}, [deliveryOrderList, orderState])
|
||||
|
||||
//输入搜索关键字
|
||||
// 输入搜索关键字
|
||||
const getSearchData = useCallback((searchValue: string) => {
|
||||
setSearch((prevProps) => ({ ...prevProps, delivery_notice_order_no: searchValue }))
|
||||
setSearch(prevProps => ({ ...prevProps, delivery_notice_order_no: searchValue }))
|
||||
console.log('searchValue==>', searchValue)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if(!isFirst.current){
|
||||
if (!isFirst.current) {
|
||||
getData()
|
||||
}
|
||||
}, [search])
|
||||
|
||||
useDidShow(()=>{
|
||||
useDidShow(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
//上拉加载数据
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
|
||||
const getScrollToLower = useCallback(() => {
|
||||
if (deliveryOrderList.list.length < deliveryOrderList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch((e) => ({ ...e, size }))
|
||||
setSearch(e => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [deliveryOrderList])
|
||||
|
||||
//列表下拉刷新
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
|
||||
const getRefresherRefresh = async () => {
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch((val) => ({ ...val, size: 10 }))
|
||||
setSearch(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const res = await FetchDeliveryOrderList(getFilterData(search))
|
||||
|
||||
setDeliveryOrderList((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setDeliveryOrderList(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
@@ -95,11 +94,12 @@ const Delivery: FC = () => {
|
||||
let fuckingBadCodeId: string | number = 0
|
||||
if (statusId === 3) {
|
||||
fuckingBadCodeId = 0
|
||||
} else if (statusId === 4) {
|
||||
}
|
||||
else if (statusId === 4) {
|
||||
fuckingBadCodeId = '1,2'
|
||||
}
|
||||
setCurrentStatus(statusName)
|
||||
setSearch((e) => ({ ...e, delivery_notice_order_status: fuckingBadCodeId }))
|
||||
setSearch(e => ({ ...e, delivery_notice_order_status: fuckingBadCodeId }))
|
||||
}
|
||||
|
||||
const handleAuditSuccess = () => {
|
||||
@@ -142,9 +142,10 @@ const Delivery: FC = () => {
|
||||
console.log('changedFields==>changedFields', changedFields)
|
||||
// 自定义时间
|
||||
if (timeKey === '6') {
|
||||
setSearch((prevProps) => ({ ...prevProps, ...changedFields, date_min: start, date_max: end }))
|
||||
} else {
|
||||
setSearch((prevProps) => ({ ...prevProps, ...changedFields }))
|
||||
setSearch(prevProps => ({ ...prevProps, ...changedFields, date_min: start, date_max: end }))
|
||||
}
|
||||
else {
|
||||
setSearch(prevProps => ({ ...prevProps, ...changedFields }))
|
||||
}
|
||||
handlePopupClose()
|
||||
}
|
||||
@@ -159,7 +160,7 @@ const Delivery: FC = () => {
|
||||
const handleScan = () => {
|
||||
Taro.scanCode({
|
||||
success(res) {
|
||||
setSearch((e) => ({ ...e, delivery_notice_order_no: res.result }))
|
||||
setSearch(e => ({ ...e, delivery_notice_order_no: res.result }))
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res)
|
||||
@@ -168,7 +169,7 @@ const Delivery: FC = () => {
|
||||
}
|
||||
return (
|
||||
<View onClick={handleScan} className={styles.scanHandler}>
|
||||
<IconFont name='icon-saomiao' size={40}></IconFont>
|
||||
<IconFont name="icon-saomiao" size={40}></IconFont>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -176,9 +177,9 @@ const Delivery: FC = () => {
|
||||
return (
|
||||
<View className={styles.delivery}>
|
||||
<View className={styles.searchBox}>
|
||||
<Search placeholder='请输入或扫描条形码' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} customRightSlot={scanIcon()}>
|
||||
<Search placeholder="请输入或扫描条形码" showBtn={false} changeOnSearch={getSearchData} debounceTime={300} customRightSlot={scanIcon()}>
|
||||
<View onClick={onShowFilter} className={styles.icon__filter}>
|
||||
<IconText svg iconName='icon-shaixuan' text='筛选' customClass={styles['icon--filter']} />
|
||||
<IconText svg iconName="icon-shaixuan" text="筛选" customClass={styles['icon--filter']} />
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
@@ -189,9 +190,10 @@ const Delivery: FC = () => {
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrollToLower}
|
||||
refresherEnabled={true}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
<Text className={styles['listBox--total']}>
|
||||
{currentStatus}共 {deliveryOrderList.total} 单
|
||||
</Text>
|
||||
@@ -200,10 +202,10 @@ const Delivery: FC = () => {
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Popup show={showFilter} title='筛选列表' onClose={handlePopupClose}>
|
||||
<Popup show={showFilter} title="筛选列表" onClose={handlePopupClose}>
|
||||
<DeliveryFilter onSearchTime={handleSearchTime} onConfirm={handleConfirm} onReset={handleReset} />
|
||||
</Popup>
|
||||
<TimePickerPopup start={start} end={end} showTime={showTime} closePopup={handClose} onSelectDate={(e) => handTime(e)}></TimePickerPopup>
|
||||
<TimePickerPopup start={start} end={end} showTime={showTime} closePopup={handClose} onSelectDate={e => handTime(e)}></TimePickerPopup>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { DeliverNoticeOrder, DeliveryNoticeOrderAudit, DeliveryNoticeOrderUpload } from '@/api'
|
||||
import { formatDateTime, formatMeterDiv, formatWeightDiv } from '@/common/format'
|
||||
import Cell from '@/components/cell'
|
||||
@@ -6,12 +11,7 @@ import LayoutBlock from '@/components/layoutBlock'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import SaleModeTag from '@/components/saleModeTag'
|
||||
import UploadImage from '@/components/uploadImage'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import { alert } from '@/common/common'
|
||||
import { FC, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
const DeliveryDetail: FC = () => {
|
||||
const router = useRouter()
|
||||
@@ -20,7 +20,7 @@ const DeliveryDetail: FC = () => {
|
||||
|
||||
const [detailInfo, setDetailInfo] = useState<Record<string, any>>({})
|
||||
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const { id, order_no } = router.params
|
||||
const res = await fetchData({
|
||||
id,
|
||||
@@ -39,21 +39,21 @@ const DeliveryDetail: FC = () => {
|
||||
const { fetchData: FetchAudit } = DeliveryNoticeOrderAudit()
|
||||
|
||||
const DetailItem = useMemo(() => {
|
||||
const element =
|
||||
!!detailInfo?.weight_list?.length &&
|
||||
detailInfo?.weight_list.map((weightItem) => {
|
||||
const element
|
||||
= !!detailInfo?.weight_list?.length
|
||||
&& detailInfo?.weight_list.map((weightItem) => {
|
||||
return (
|
||||
<View className={styles.detailInfo}>
|
||||
<Divider direction='horizontal' customClassName={styles.divider}></Divider>
|
||||
<Divider direction="horizontal" customClassName={styles.divider}></Divider>
|
||||
<View className={styles.detailInfoItem}>
|
||||
<View className={styles['detailInfoItem--title']}>
|
||||
<View className=''>
|
||||
<View className="">
|
||||
<Text style={{ marginRight: '20rpx' }}>
|
||||
{weightItem.product_code} {weightItem.product_name}
|
||||
</Text>
|
||||
<SaleModeTag saleMode={weightItem?.sale_mode} />
|
||||
</View>
|
||||
<View className=''>共 {weightItem?.sale_mode === 0 ? `${weightItem.roll} 条` : `${formatMeterDiv(weightItem?.length || 0)} 米`}</View>
|
||||
<View className="">共 {weightItem?.sale_mode === 0 ? `${weightItem.roll} 条` : `${formatMeterDiv(weightItem?.length || 0)} 米`}</View>
|
||||
</View>
|
||||
<View className={styles['detailInfoItem--detail']}>
|
||||
<View className={styles['detailInfoItem--detail--row']}>
|
||||
@@ -77,40 +77,43 @@ const DeliveryDetail: FC = () => {
|
||||
|
||||
const handleUploadChange = (imageList: string[]) => {
|
||||
console.log('imageList===>', imageList)
|
||||
setReadyToUploadList((prev) => [...prev, ...imageList])
|
||||
setReadyToUploadList(prev => [...prev, ...imageList])
|
||||
}
|
||||
// 上传附件
|
||||
const handleUploadPic = useCallback(async () => {
|
||||
const handleUploadPic = useCallback(async() => {
|
||||
const res = await uploadData({
|
||||
id: Number(router.params.id),
|
||||
delivery_appendix: readyToUploadList,
|
||||
})
|
||||
if (res.success) {
|
||||
alert.success('上传成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('上传核失败')
|
||||
}
|
||||
}, [readyToUploadList])
|
||||
|
||||
// 审核
|
||||
const handleAudit = useCallback(() => {
|
||||
if (readyToUploadList.length === 0 ) {
|
||||
if (readyToUploadList.length === 0) {
|
||||
alert.error('请先上传附件')
|
||||
return
|
||||
}
|
||||
Taro.showModal({
|
||||
confirmColor: '#337FFF',
|
||||
title: '确定审核?',
|
||||
success: async function (res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await FetchAudit({ id: Number(router.params.id) })
|
||||
if (res.success) {
|
||||
alert.success('审核成功')
|
||||
getData()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('审核失败')
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
},
|
||||
@@ -120,10 +123,10 @@ const DeliveryDetail: FC = () => {
|
||||
const BottomBar = useMemo(() => {
|
||||
return (
|
||||
<View className={styles.bottomBar}>
|
||||
<NormalButton plain type='primary' round onClick={handleUploadPic}>
|
||||
<NormalButton plain type="primary" round onClick={handleUploadPic}>
|
||||
上传附件
|
||||
</NormalButton>
|
||||
<NormalButton type='primary' round onClick={handleAudit}>
|
||||
<NormalButton type="primary" round onClick={handleAudit}>
|
||||
确认审核
|
||||
</NormalButton>
|
||||
</View>
|
||||
@@ -132,7 +135,7 @@ const DeliveryDetail: FC = () => {
|
||||
return (
|
||||
<View className={styles.deliveryDetail}>
|
||||
<View className={styles.content}>
|
||||
<LayoutBlock circle customStyle={{padding: '24rpx'}}>
|
||||
<LayoutBlock circle customStyle={{ padding: '24rpx' }}>
|
||||
<View className={styles.detailTop}>
|
||||
<View className={styles.orderNo}>发货单号:{detailInfo?.order_no}</View>
|
||||
{detailInfo?.status === 0 ? <View className={styles['status--toBeAudit']}>待审核</View> : <View className={styles['status--audited']}>已完成</View>}
|
||||
@@ -147,19 +150,19 @@ const DeliveryDetail: FC = () => {
|
||||
</Text>
|
||||
</View>
|
||||
</LayoutBlock>
|
||||
<LayoutBlock circle customStyle={{padding: '24rpx'}}>
|
||||
<LayoutBlock circle customStyle={{ padding: '24rpx' }}>
|
||||
<View className={styles.orderInfoTop}>订单信息</View>
|
||||
<Divider direction='horizontal' customClassName={styles.divider}></Divider>
|
||||
<View className='orderInfoDetail'>
|
||||
<Cell title='订单备注:' desc={detailInfo?.sale_order_remark || '暂无备注信息'}></Cell>
|
||||
<Cell title='创建时间:' desc={formatDateTime(detailInfo?.create_time) || '暂无创建时间'}></Cell>
|
||||
<Cell title='发货方式:' desc={detailInfo?.shipment_mode_name || '暂无发货方式'}></Cell>
|
||||
<Cell title='发货地址:' desc={`${detailInfo.province_name}${detailInfo.city_name}${detailInfo.district_name}${detailInfo.address_detail}` || '暂无发货地址'}></Cell>
|
||||
<Divider direction="horizontal" customClassName={styles.divider}></Divider>
|
||||
<View className="orderInfoDetail">
|
||||
<Cell title="订单备注:" desc={detailInfo?.sale_order_remark || '暂无备注信息'}></Cell>
|
||||
<Cell title="创建时间:" desc={formatDateTime(detailInfo?.create_time) || '暂无创建时间'}></Cell>
|
||||
<Cell title="发货方式:" desc={detailInfo?.shipment_mode_name || '暂无发货方式'}></Cell>
|
||||
<Cell title="发货地址:" desc={`${detailInfo.province_name}${detailInfo.city_name}${detailInfo.district_name}${detailInfo.address_detail}` || '暂无发货地址'}></Cell>
|
||||
</View>
|
||||
</LayoutBlock>
|
||||
<LayoutBlock circle customStyle={{padding: '24rpx'}}>
|
||||
<LayoutBlock circle customStyle={{ padding: '24rpx' }}>
|
||||
<View className={styles.orderInfoTop}>附件</View>
|
||||
<Divider direction='horizontal' customClassName={styles.divider}></Divider>
|
||||
<Divider direction="horizontal" customClassName={styles.divider}></Divider>
|
||||
<UploadImage onlyRead={detailInfo?.status !== 0} onChange={handleUploadChange} defaultList={detailInfo?.delivery_appendix_url}></UploadImage>
|
||||
</LayoutBlock>
|
||||
</View>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '首页',
|
||||
navigationBarTitleText: '首页',
|
||||
}
|
||||
|
||||
+343
-344
@@ -1,372 +1,371 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Search from '@/components/search'
|
||||
import SideBar from '@/components/sideBar'
|
||||
import Product from '@/components/product'
|
||||
import ShopCart from '@/components/shoppingCart'
|
||||
import { goLink } from '@/common/common'
|
||||
import styles from './index.module.scss'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { kindListApi, ProductListApi } from '@/api/index'
|
||||
import { ProductListApi, kindListApi } from '@/api/index'
|
||||
// import useLogin from '@/use/useLogin'
|
||||
import { mpproductcolorlist, mpshoppingCartproductColorlist } from "@/api/order"
|
||||
import { dataLoadingStatus } from '@/common/util'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { getFilterData } from '@/common/util'
|
||||
import { mpproductcolorlist, mpshoppingCartproductColorlist } from '@/api/order'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import { ClientListApi } from '@/api/order'
|
||||
|
||||
export default () => {
|
||||
useEffect(() => {
|
||||
categoryList()
|
||||
getClient()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
categoryList()
|
||||
getClient()
|
||||
}, [])
|
||||
|
||||
//获取客户
|
||||
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])
|
||||
}
|
||||
|
||||
//获取面料种类
|
||||
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
|
||||
const { fetchData } = kindListApi()
|
||||
const categoryList = async () => {
|
||||
const res = await fetchData()
|
||||
if (res.data?.list) {
|
||||
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
|
||||
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
|
||||
}
|
||||
}
|
||||
|
||||
//获取面料列表
|
||||
const [productData, setProductData] = useState({ list: [], total: 0 })
|
||||
const [hasMore, setHasMore] = useState(true)
|
||||
const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 })
|
||||
const pageNum = useRef({ size: filtrate.size, page: filtrate.page })
|
||||
const { fetchData: productFetchData, state: productState } = ProductListApi()
|
||||
//获取数据方法
|
||||
const getProductList = async () => {
|
||||
const { data, total } = await productFetchData(filtrate)
|
||||
setProductData({ ...productData, list: data.list, total })
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
//监听查询条件
|
||||
useEffect(() => {
|
||||
if (filtrate.product_kind_id) getProductList()
|
||||
}, [filtrate])
|
||||
|
||||
//点击面料类型
|
||||
const getProductKindId = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setProductData({ list: [], total: 0 })
|
||||
setFiltrate((list) => ({ ...list, size: 5, product_kind_id: e.id }))
|
||||
}, [])
|
||||
|
||||
//上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (productData.list.length >= productData.total) {
|
||||
setHasMore(false)
|
||||
} else {
|
||||
pageNum.current.page++
|
||||
const newSize = pageNum.current.size * pageNum.current.page
|
||||
setFiltrate((e) => ({ ...e, size: newSize }))
|
||||
}
|
||||
}, [productData])
|
||||
|
||||
const [showShopCart, setShowShopCart] = useState(false)
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.page = 1
|
||||
setFiltrate({ ...filtrate, size: 5 })
|
||||
setHasMore(true)
|
||||
setRefresherTriggeredStatus(true)
|
||||
}
|
||||
|
||||
const onj = JSON.parse(Taro.getStorageSync('userInfo') || '{}')
|
||||
const [search, setSearchObj] = useState({
|
||||
modeId: 0,
|
||||
goodsId: null,
|
||||
code_or_name: '',
|
||||
physical_warehouse: onj.physical_warehouse,
|
||||
purchaser_id: -1,
|
||||
// 获取客户
|
||||
const [clienList, setclienList] = useState<any[]>([])
|
||||
const { fetchData: listFetchData } = ClientListApi()
|
||||
const getClient = async() => {
|
||||
const res = await listFetchData({
|
||||
page: 1, size: 10,
|
||||
})
|
||||
|
||||
//选择的类型
|
||||
const [typeList, setTypeList] = useState<any[]>([{ id: 0, name: '大货', checked: true }, { id: 1, name: '剪版', checked: false }, { id: 2, name: '散剪', checked: false }])
|
||||
//选择类型
|
||||
const handCheckMode = (item) => {
|
||||
typeList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
setSearchObj((e) => ({ ...e, modeId: it.id }))
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setGoodlist([])
|
||||
}
|
||||
const [goodList, setGoodlist] = useState<any[]>([])
|
||||
const { fetchData: colorlistFetch } = mpproductcolorlist()
|
||||
const ShopCartRef = useRef<any>(null)
|
||||
|
||||
const [goodObj, setGoodsobj] = useState({})
|
||||
//点击对应商品显示购物车
|
||||
const showCart = async (item) => {
|
||||
setSearchObj((e) => ({ ...e, goodsId: item.id, purchaser_id: clientObj?.clientId }))
|
||||
setShowShopCart(true)
|
||||
setGoodsobj(item)
|
||||
ShopCartRef.current.SearchRef.current.clearInput()
|
||||
}
|
||||
|
||||
const getGoodList = async () => {
|
||||
const res = await colorlistFetch({ product_id: search.goodsId, sale_mode: search.modeId, code_or_name: search.code_or_name, physical_warehouse: search?.physical_warehouse, purchaser_id: clientObj?.clientId })
|
||||
res.data.list.map((item) => {
|
||||
item.showInput = false
|
||||
if (search.modeId == 0) {
|
||||
item.nums = 1
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
item.buyNums = 3
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...res.data.list])
|
||||
}
|
||||
//监听选择的类型
|
||||
useEffect(() => {
|
||||
setSearchObj(search)
|
||||
if (search.goodsId) getGoodList()
|
||||
}, [search])
|
||||
|
||||
//关闭弹窗
|
||||
const closePoup = () => {
|
||||
setShowShopCart(false)
|
||||
}
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: productData.list, total: productData.total, status: productState.loading })
|
||||
}, [productData, productState.loading])
|
||||
|
||||
//点击加展示输入框
|
||||
const handAdd = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.showInput = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
//点击减
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
item.nums--
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) it.showInput = false, it.nums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) it.showInput = false, it.nums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
if (item.nums < 3) it.showInput = false, it.nums = 3
|
||||
}
|
||||
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
//点击输入框的加
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.nums++
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
setSearchObj((e) => ({ ...e, code_or_name: eq }))
|
||||
}, [])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: -1,
|
||||
clientName: ''
|
||||
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])
|
||||
}
|
||||
|
||||
|
||||
//加入购物车
|
||||
const { fetchData: preViewFetch, } = mpshoppingCartproductColorlist()
|
||||
const handSure = async () => {
|
||||
const arr = goodList.filter(item => {
|
||||
return item.showInput
|
||||
})
|
||||
const list: any[] = []
|
||||
arr.forEach(it => {
|
||||
list.push({
|
||||
roll: search.modeId === 0 ? Number(it.nums) : 0,
|
||||
length: search.modeId !== 0 ? Number(it.nums) * 100 : 0,
|
||||
product_color_id: Number(it.id)
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: clientObj.clientId,
|
||||
sale_mode: search.modeId,
|
||||
color_list: list,
|
||||
sale_offect: 0
|
||||
}
|
||||
let res = await preViewFetch(getFilterData(query))
|
||||
Taro.showLoading({
|
||||
mask: true,
|
||||
title: '请稍等...'
|
||||
})
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: "加入成功",
|
||||
duration: 2000,
|
||||
});
|
||||
setShowShopCart(false)
|
||||
goodList.map(item => {
|
||||
item.showInput = false
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
Taro.hideLoading()
|
||||
} else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
icon: 'error',
|
||||
title: res.msg,
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
// 获取面料种类
|
||||
const [kindData, setKindData] = useState<any>({ list: [], defaultId: 0 })
|
||||
const { fetchData } = kindListApi()
|
||||
const categoryList = async() => {
|
||||
const res = await fetchData()
|
||||
if (res.data?.list) {
|
||||
setKindData({ ...kindData, list: res.data.list, defaultId: res.data.list[0].id })
|
||||
setFiltrate({ ...filtrate, product_kind_id: res.data.list[0].id })
|
||||
}
|
||||
//输入框失焦
|
||||
const onBlur = (e, id) => {
|
||||
goodList.map(item => {
|
||||
if (item.id == id) {
|
||||
if (search.modeId == 0 && (e.detail.value == '' || Number(e.detail.value) == 0)) {
|
||||
item.showInput = false
|
||||
item.nums = 1
|
||||
}
|
||||
|
||||
} else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
item.showInput = false
|
||||
} else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
if (search.modeId == 2 && Number(e.detail.value) < 3) {
|
||||
item.nums = 3
|
||||
item.showInput = false
|
||||
// 获取面料列表
|
||||
const [productData, setProductData] = useState({ list: [], total: 0 })
|
||||
const [hasMore, setHasMore] = useState(true)
|
||||
const [filtrate, setFiltrate] = useState({ product_kind_id: 0, size: 5, page: 1 })
|
||||
const pageNum = useRef({ size: filtrate.size, page: filtrate.page })
|
||||
const { fetchData: productFetchData, state: productState } = ProductListApi()
|
||||
// 获取数据方法
|
||||
const getProductList = async() => {
|
||||
const { data, total } = await productFetchData(filtrate)
|
||||
setProductData({ ...productData, list: data.list, total })
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
// 监听查询条件
|
||||
useEffect(() => {
|
||||
if (filtrate.product_kind_id) { getProductList() }
|
||||
}, [filtrate])
|
||||
|
||||
} else if (search.modeId == 2 && Number(e.detail.value) >= 3) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
// 点击面料类型
|
||||
const getProductKindId = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setProductData({ list: [], total: 0 })
|
||||
setFiltrate(list => ({ ...list, size: 5, product_kind_id: e.id }))
|
||||
}, [])
|
||||
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
// 上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (productData.list.length >= productData.total) {
|
||||
setHasMore(false)
|
||||
}
|
||||
else {
|
||||
pageNum.current.page++
|
||||
const newSize = pageNum.current.size * pageNum.current.page
|
||||
setFiltrate(e => ({ ...e, size: newSize }))
|
||||
}
|
||||
}, [productData])
|
||||
|
||||
useEffect(() => {
|
||||
setGoodlist(goodList)
|
||||
}, [goodList])
|
||||
const [showShopCart, setShowShopCart] = useState(false)
|
||||
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.page = 1
|
||||
setFiltrate({ ...filtrate, size: 5 })
|
||||
setHasMore(true)
|
||||
setRefresherTriggeredStatus(true)
|
||||
}
|
||||
|
||||
useDidShow(() => {
|
||||
//获取选择的客户
|
||||
let pages = Taro.getCurrentPages();
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
//判断是否有跳转选择客户
|
||||
if (currPage.data?.clientId && currPage.data?.clientId !== '') {
|
||||
setclientObj({
|
||||
clientId: currPage.data?.clientId,
|
||||
clientName: currPage.data?.clientName,
|
||||
})
|
||||
setSearchObj((val) => ({ ...val, purchaser_id: currPage.data?.clientId }))
|
||||
}
|
||||
//默认客户
|
||||
if (currPage.data?.clientId == null) {
|
||||
setclientObj({
|
||||
clientId: clienList.length > 0 ? clienList[0]?.id : - 1,
|
||||
clientName: clienList.length > 0 ? clienList[0]?.name : '',
|
||||
})
|
||||
}
|
||||
const onj = JSON.parse(Taro.getStorageSync('userInfo') || '{}')
|
||||
const [search, setSearchObj] = useState({
|
||||
modeId: 0,
|
||||
goodsId: null,
|
||||
code_or_name: '',
|
||||
physical_warehouse: onj.physical_warehouse,
|
||||
purchaser_id: -1,
|
||||
})
|
||||
|
||||
// 选择的类型
|
||||
const [typeList, setTypeList] = useState<any[]>([{ id: 0, name: '大货', checked: true }, { id: 1, name: '剪版', checked: false }, { id: 2, name: '散剪', checked: false }])
|
||||
// 选择类型
|
||||
const handCheckMode = (item) => {
|
||||
typeList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
setSearchObj(e => ({ ...e, modeId: it.id }))
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setGoodlist([])
|
||||
}
|
||||
const [goodList, setGoodlist] = useState<any[]>([])
|
||||
const { fetchData: colorlistFetch } = mpproductcolorlist()
|
||||
const ShopCartRef = useRef<any>(null)
|
||||
|
||||
return (
|
||||
// <MoveBtn onClick={() => setShowShopCart(showShopCart)}>
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
{/* <View className={styles.search_collect} onClick={() => goLink('/pages/collection/index')}>
|
||||
const [goodObj, setGoodsobj] = useState({})
|
||||
// 点击对应商品显示购物车
|
||||
const showCart = async(item) => {
|
||||
setSearchObj(e => ({ ...e, goodsId: item.id, purchaser_id: clientObj?.clientId }))
|
||||
setShowShopCart(true)
|
||||
setGoodsobj(item)
|
||||
ShopCartRef.current.SearchRef.current.clearInput()
|
||||
}
|
||||
|
||||
const getGoodList = async() => {
|
||||
const res = await colorlistFetch({ product_id: search.goodsId, sale_mode: search.modeId, code_or_name: search.code_or_name, physical_warehouse: search?.physical_warehouse, purchaser_id: clientObj?.clientId })
|
||||
res.data.list.map((item) => {
|
||||
item.showInput = false
|
||||
if (search.modeId == 0) {
|
||||
item.nums = 1
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
item.buyNums = 3
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...res.data.list])
|
||||
}
|
||||
// 监听选择的类型
|
||||
useEffect(() => {
|
||||
setSearchObj(search)
|
||||
if (search.goodsId) { getGoodList() }
|
||||
}, [search])
|
||||
|
||||
// 关闭弹窗
|
||||
const closePoup = () => {
|
||||
setShowShopCart(false)
|
||||
}
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: productData.list, total: productData.total, status: productState.loading })
|
||||
}, [productData, productState.loading])
|
||||
|
||||
// 点击加展示输入框
|
||||
const handAdd = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.showInput = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
// 点击减
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
item.nums--
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) { it.showInput = false, it.nums = 1 }
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) { it.showInput = false, it.nums = 0.5 }
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
if (item.nums < 3) { it.showInput = false, it.nums = 3 }
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
// 点击输入框的加
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.nums++
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
setSearchObj(e => ({ ...e, code_or_name: eq }))
|
||||
}, [])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: -1,
|
||||
clientName: '',
|
||||
})
|
||||
|
||||
// 加入购物车
|
||||
const { fetchData: preViewFetch } = mpshoppingCartproductColorlist()
|
||||
const handSure = async() => {
|
||||
const arr = goodList.filter((item) => {
|
||||
return item.showInput
|
||||
})
|
||||
const list: any[] = []
|
||||
arr.forEach((it) => {
|
||||
list.push({
|
||||
roll: search.modeId === 0 ? Number(it.nums) : 0,
|
||||
length: search.modeId !== 0 ? Number(it.nums) * 100 : 0,
|
||||
product_color_id: Number(it.id),
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: clientObj.clientId,
|
||||
sale_mode: search.modeId,
|
||||
color_list: list,
|
||||
sale_offect: 0,
|
||||
}
|
||||
const res = await preViewFetch(getFilterData(query))
|
||||
Taro.showLoading({
|
||||
mask: true,
|
||||
title: '请稍等...',
|
||||
})
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: '加入成功',
|
||||
duration: 2000,
|
||||
})
|
||||
setShowShopCart(false)
|
||||
goodList.map((item) => {
|
||||
item.showInput = false
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
icon: 'error',
|
||||
title: res.msg,
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
}
|
||||
// 输入框失焦
|
||||
const onBlur = (e, id) => {
|
||||
goodList.map((item) => {
|
||||
if (item.id == id) {
|
||||
if (search.modeId == 0 && (e.detail.value == '' || Number(e.detail.value) == 0)) {
|
||||
item.showInput = false
|
||||
item.nums = 1
|
||||
}
|
||||
else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
if (search.modeId == 2 && Number(e.detail.value) < 3) {
|
||||
item.nums = 3
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 2 && Number(e.detail.value) >= 3) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setGoodlist(goodList)
|
||||
}, [goodList])
|
||||
|
||||
useDidShow(() => {
|
||||
// 获取选择的客户
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
// 判断是否有跳转选择客户
|
||||
if (currPage.data?.clientId && currPage.data?.clientId !== '') {
|
||||
setclientObj({
|
||||
clientId: currPage.data?.clientId,
|
||||
clientName: currPage.data?.clientName,
|
||||
})
|
||||
setSearchObj(val => ({ ...val, purchaser_id: currPage.data?.clientId }))
|
||||
}
|
||||
// 默认客户
|
||||
if (currPage.data?.clientId == null) {
|
||||
setclientObj({
|
||||
clientId: clienList.length > 0 ? clienList[0]?.id : -1,
|
||||
clientName: clienList.length > 0 ? clienList[0]?.name : '',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
// <MoveBtn onClick={() => setShowShopCart(showShopCart)}>
|
||||
<View className={styles.main}>
|
||||
<View className={styles.search}>
|
||||
{/* <View className={styles.search_collect} onClick={() => goLink('/pages/collection/index')}>
|
||||
我的收藏
|
||||
</View> */}
|
||||
<View className={styles.search_input} onClick={() => goLink('/pages/searchPage/index')}>
|
||||
<Search disabled={true} style={{ width: '263rpx' }} />
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.products}>
|
||||
<SideBar
|
||||
list={kindData.list}
|
||||
height='100%'
|
||||
defaultValue={kindData.defaultId}
|
||||
hasMore={hasMore}
|
||||
statusMore={statusMore}
|
||||
selfOnScrolltolower={getScrolltolower}
|
||||
sideBarOnClick={getProductKindId}
|
||||
heightItem={150}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={() => getRefresherRefresh()}>
|
||||
<Product productList={productData.list} popupShow={(item) => showCart(item)} />
|
||||
</SideBar>
|
||||
</View>
|
||||
{/* <View className='common_safe_area_y'></View> */}
|
||||
<ShopCart handSure={() => handSure()}
|
||||
clientName={clientObj?.clientName}
|
||||
clientId={clientObj?.clientId}
|
||||
modeFont={search.modeId}
|
||||
handPlus={(item) => handPlus(item)}
|
||||
obj={goodObj}
|
||||
ref={ShopCartRef}
|
||||
getSearchData={(e) => { getSearchData(e) }}
|
||||
onBlur={(e, id) => onBlur(e, id)}
|
||||
reduceNums={(item) => { reduceNums(item) }}
|
||||
addNums={(item) => { handAdd(item) }}
|
||||
showPopup={showShopCart}
|
||||
handCheck={(item) => { handCheckMode(item) }}
|
||||
closePopup={() => closePoup()}
|
||||
goodList={goodList}
|
||||
typeList={typeList}
|
||||
></ShopCart>
|
||||
<View className={styles.search_input} onClick={() => goLink('/pages/searchPage/index')}>
|
||||
<Search disabled style={{ width: '263rpx' }} />
|
||||
</View>
|
||||
// </MoveBtn>
|
||||
)
|
||||
</View>
|
||||
<View className={styles.products}>
|
||||
<SideBar
|
||||
list={kindData.list}
|
||||
height="100%"
|
||||
defaultValue={kindData.defaultId}
|
||||
hasMore={hasMore}
|
||||
statusMore={statusMore}
|
||||
selfOnScrolltolower={getScrolltolower}
|
||||
sideBarOnClick={getProductKindId}
|
||||
heightItem={150}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={() => getRefresherRefresh()}
|
||||
>
|
||||
<Product productList={productData.list} popupShow={item => showCart(item)} />
|
||||
</SideBar>
|
||||
</View>
|
||||
{/* <View className='common_safe_area_y'></View> */}
|
||||
<ShopCart handSure={() => handSure()}
|
||||
clientName={clientObj?.clientName}
|
||||
clientId={clientObj?.clientId}
|
||||
modeFont={search.modeId}
|
||||
handPlus={item => handPlus(item)}
|
||||
obj={goodObj}
|
||||
ref={ShopCartRef}
|
||||
getSearchData={(e) => { getSearchData(e) }}
|
||||
onBlur={(e, id) => onBlur(e, id)}
|
||||
reduceNums={(item) => { reduceNums(item) }}
|
||||
addNums={(item) => { handAdd(item) }}
|
||||
showPopup={showShopCart}
|
||||
handCheck={(item) => { handCheckMode(item) }}
|
||||
closePopup={() => closePoup()}
|
||||
goodList={goodList}
|
||||
typeList={typeList}
|
||||
></ShopCart>
|
||||
</View>
|
||||
// </MoveBtn>
|
||||
)
|
||||
}
|
||||
// oninputEvent={(e, item) => { oninputEvent(e, item) }}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '登录',
|
||||
navigationBarTitleText: '登录',
|
||||
}
|
||||
|
||||
+27
-29
@@ -1,14 +1,14 @@
|
||||
import { Image, Input, Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Divider from '@/components/divider'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { View, Image, Text, Input } from '@tarojs/components'
|
||||
import { FC, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import IconCard from '@/components/iconCard'
|
||||
import {memo} from 'react'
|
||||
import { LoginApi } from '@/api'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { alert } from '@/common/common'
|
||||
import useUserInfo from '@/use/useUserInfo'
|
||||
|
||||
@@ -18,7 +18,7 @@ const Login: FC = () => {
|
||||
const [eyesStatus, setEyesStatus] = useState(true)
|
||||
|
||||
const handlePwdVisible = () => {
|
||||
setEyesStatus((value) => !value)
|
||||
setEyesStatus(value => !value)
|
||||
}
|
||||
|
||||
const selectCallBack = () => {
|
||||
@@ -33,7 +33,7 @@ const Login: FC = () => {
|
||||
const [account, setAccount] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
|
||||
const formatInput = (value:string) => {
|
||||
const formatInput = (value: string) => {
|
||||
return value.trim()
|
||||
}
|
||||
|
||||
@@ -48,15 +48,10 @@ const Login: FC = () => {
|
||||
|
||||
const { setToken, setUserInfo } = useUserInfo()
|
||||
|
||||
|
||||
|
||||
const { fetchData } = LoginApi()
|
||||
|
||||
|
||||
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (account === '' || password === '') return alert.error('账号密码不能为空!')
|
||||
const handleLogin = async() => {
|
||||
if (account === '' || password === '') { return alert.error('账号密码不能为空!') }
|
||||
console.log('账户密码:', account, password)
|
||||
const res = await fetchData({
|
||||
account,
|
||||
@@ -70,7 +65,8 @@ const Login: FC = () => {
|
||||
Taro.switchTab({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('登陆失败')
|
||||
}
|
||||
}
|
||||
@@ -81,27 +77,29 @@ const Login: FC = () => {
|
||||
|
||||
return (
|
||||
<View className={styles.login}>
|
||||
<Image className='full-100' mode='widthFix' src='https://cdn.zzfzyc.com/service_center/login_head.png'></Image>
|
||||
<Image className="full-100" mode="widthFix" src="https://cdn.zzfzyc.com/service_center/login_head.png"></Image>
|
||||
<View className={styles['login-panel']}>
|
||||
<View className={styles['login-title']}>
|
||||
<Text>您好,</Text>
|
||||
<Text>欢迎来到蜘蛛管家</Text>
|
||||
</View>
|
||||
<View className={styles['input-bar']}>
|
||||
<IconFont name='icon-yonghuming' size={48} color='#999999'></IconFont>
|
||||
<Divider direction='vertical' customStyles={{height: '20px',marginLeft: '10px'}}></Divider>
|
||||
<Input onInput={handleInputAccount} className={styles['input-bar--account']} placeholder='请输入用户名'></Input>
|
||||
<IconFont name="icon-yonghuming" size={48} color="#999999"></IconFont>
|
||||
<Divider direction="vertical" customStyles={{ height: '20px', marginLeft: '10px' }}></Divider>
|
||||
<Input onInput={handleInputAccount} className={styles['input-bar--account']} placeholder="请输入用户名"></Input>
|
||||
</View>
|
||||
<View className={styles['input-bar']}>
|
||||
<IconFont name='icon-mima' size={48} color='#999999'></IconFont>
|
||||
<Divider direction='vertical' customStyles={{height: '20px',marginLeft: '10px'}}></Divider>
|
||||
<Input onInput={handleInputPassword} password={eyesStatus} className={styles['input-bar--password']} type='text' placeholder='请输入密码'></Input>
|
||||
<IconFont name="icon-mima" size={48} color="#999999"></IconFont>
|
||||
<Divider direction="vertical" customStyles={{ height: '20px', marginLeft: '10px' }}></Divider>
|
||||
<Input onInput={handleInputPassword} password={eyesStatus} className={styles['input-bar--password']} type="text" placeholder="请输入密码"></Input>
|
||||
<View onClick={handlePwdVisible}>
|
||||
{!eyesStatus ? (
|
||||
<IconFont name='icon-yanjing' size={48} color='#999999'></IconFont>
|
||||
) : (
|
||||
<IconFont name='icon-biyan' size={48} color='#999999'></IconFont>
|
||||
)}
|
||||
{!eyesStatus
|
||||
? (
|
||||
<IconFont name="icon-yanjing" size={48} color="#999999"></IconFont>
|
||||
)
|
||||
: (
|
||||
<IconFont name="icon-biyan" size={48} color="#999999"></IconFont>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles['login-options']}>
|
||||
@@ -126,11 +124,11 @@ const Login: FC = () => {
|
||||
const QuickLogin: FC = memo(() => {
|
||||
return (
|
||||
<View className={styles['quick-login']}>
|
||||
<Divider direction='horizontal' customClassName={styles['quick-login--divider']}>
|
||||
<Divider direction="horizontal" customClassName={styles['quick-login--divider']}>
|
||||
或通过以下方式登录
|
||||
</Divider>
|
||||
<View className={styles['quick-login--options']}>
|
||||
<IconCard iconName='icon-weixindenglu' title='微信登录' customClass={styles['quick-login--iconCard']}></IconCard>
|
||||
<IconCard iconName="icon-weixindenglu" title="微信登录" customClass={styles['quick-login--iconCard']}></IconCard>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv, formatDateTime } from '@/common/format'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import { navigateTo } from '@tarojs/router'
|
||||
import styles from './index.module.scss'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatDateTime, formatPriceDiv } from '@/common/format'
|
||||
|
||||
interface Params {
|
||||
obj: any
|
||||
obj: any
|
||||
}
|
||||
|
||||
export default memo((pros: Params) => {
|
||||
const navTo = () => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/collectionDetail/index?id=${pros.obj.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const navTo = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/collectionDetail/index?id=' + pros.obj.id
|
||||
})
|
||||
const styleColor = useMemo(() => {
|
||||
if (pros.obj.auditor_status_name == '待审核') {
|
||||
return '#E42945'
|
||||
}
|
||||
else if (pros.obj.auditor_status_name == '已审核') {
|
||||
return '#337FFF'
|
||||
}
|
||||
else if (pros.obj.auditor_status_name == '已拒绝') {
|
||||
return '#000000'
|
||||
}
|
||||
}, [pros.obj])
|
||||
|
||||
const styleColor = useMemo(() => {
|
||||
if (pros.obj.auditor_status_name == '待审核') {
|
||||
return '#E42945'
|
||||
} else if (pros.obj.auditor_status_name == '已审核') {
|
||||
return '#337FFF'
|
||||
} else if (pros.obj.auditor_status_name == '已拒绝') {
|
||||
return '#000000'
|
||||
}
|
||||
}, [pros.obj])
|
||||
|
||||
return (
|
||||
<View className={styles.itemBox}>
|
||||
<View className={styles.itemTop}>
|
||||
<View className={styles.itemTopLeft}>{pros.obj.purchaser_name}</View>
|
||||
<View className={styles.itemTopRight} style={{ color: styleColor }}>{pros.obj.auditor_status_name}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft1}>转账金额:</View>
|
||||
<View className={styles.flexRight1}>¥{formatPriceDiv(pros.obj.receipt_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft}>待认款金额:</View>
|
||||
<View className={styles.flexRight}>¥{formatPriceDiv(pros.obj.pending_distribute_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft}>收款时间:</View>
|
||||
<View className={styles.flexRight}>{formatDateTime(pros.obj.create_time)}</View>
|
||||
</View>
|
||||
<View className={styles.btnAnd} onClick={() => navTo()}>查看详情</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
return (
|
||||
<View className={styles.itemBox}>
|
||||
<View className={styles.itemTop}>
|
||||
<View className={styles.itemTopLeft}>{pros.obj.purchaser_name}</View>
|
||||
<View className={styles.itemTopRight} style={{ color: styleColor }}>{pros.obj.auditor_status_name}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft1}>转账金额:</View>
|
||||
<View className={styles.flexRight1}>¥{formatPriceDiv(pros.obj.receipt_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft}>待认款金额:</View>
|
||||
<View className={styles.flexRight}>¥{formatPriceDiv(pros.obj.pending_distribute_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.flexLeft}>收款时间:</View>
|
||||
<View className={styles.flexRight}>{formatDateTime(pros.obj.create_time)}</View>
|
||||
</View>
|
||||
<View className={styles.btnAnd} onClick={() => navTo()}>查看详情</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
+278
-279
@@ -1,306 +1,305 @@
|
||||
import { View, Input, Button } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
|
||||
import { Button, Input, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/itemList'
|
||||
import Search from '@/components/search'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Popup from '@/components/popup'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
|
||||
import ItemList from './components/itemList'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpcashManagementOrderlist
|
||||
} from "@/api/newCollection"
|
||||
mpcashManagementOrderlist,
|
||||
} from '@/api/newCollection'
|
||||
import TimePickerPopup from '@/components/timePickerPopup'
|
||||
import dayjs from 'dayjs'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
export default () => {
|
||||
let myDate = new Date();
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
page: number;
|
||||
size: number;
|
||||
search_name: string;
|
||||
start_time: number | string;
|
||||
end_time: number | string;
|
||||
}>({
|
||||
page: 1,
|
||||
size: 10,
|
||||
search_name: '',
|
||||
start_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
})
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const myDate = new Date()
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
page: number
|
||||
size: number
|
||||
search_name: string
|
||||
start_time: number | string
|
||||
end_time: number | string
|
||||
}>({
|
||||
page: 1,
|
||||
size: 10,
|
||||
search_name: '',
|
||||
start_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
})
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
|
||||
useDidShow(() => {
|
||||
getOrderList()
|
||||
useDidShow(() => {
|
||||
getOrderList()
|
||||
})
|
||||
|
||||
// 监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField.size, searchField.search_name])
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField(val => ({ ...val, search_name: e, size: 10 }))
|
||||
}, [])
|
||||
|
||||
// 获取订单列表
|
||||
const { fetchData: listFetchData, state: orderState } = mpcashManagementOrderlist()
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number; summary?: any }>({ list: [], total: 0, summary: {} })
|
||||
const getOrderList = async() => {
|
||||
const res = await listFetchData({
|
||||
...searchField,
|
||||
})
|
||||
setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total, summary: res.data?.summary }))
|
||||
// setshowPopup(false)
|
||||
setRefresherTriggeredStatus(false)
|
||||
}
|
||||
|
||||
//监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField.size, searchField.search_name])
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, search_name: e, size: 10 }))
|
||||
}, [])
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.page = 1
|
||||
// pageNum.current.size = 10
|
||||
setRefresherTriggeredStatus(true)
|
||||
getOrderList()
|
||||
setSearchField(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading as any })
|
||||
}, [orderData, orderState])
|
||||
|
||||
|
||||
//获取订单列表
|
||||
const { fetchData: listFetchData, state: orderState } = mpcashManagementOrderlist()
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number, summary?: any }>({ list: [], total: 0, summary: {} })
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData({
|
||||
...searchField
|
||||
})
|
||||
setOrderData((e) => ({ ...e, list: res.data?.list, total: res.data?.total, summary: res.data?.summary }))
|
||||
// setshowPopup(false)
|
||||
setRefresherTriggeredStatus(false)
|
||||
// 上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
console.log(pageNum.current.page, 'pageNum.current.page')
|
||||
console.log(size, 123123)
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.page = 1
|
||||
// pageNum.current.size = 10
|
||||
setRefresherTriggeredStatus(true)
|
||||
getOrderList()
|
||||
setSearchField((val) => ({ ...val, size: 10 }))
|
||||
// 是否不允许确认筛选
|
||||
const isDisabled = useMemo(() => {
|
||||
// if (searchField.stage !== '不限' ||
|
||||
// searchField.sale_mode !== '不限' ||
|
||||
// searchField.return_type !== '不限' ||
|
||||
// searchField.start_time !== '' ||
|
||||
// searchField.end_time !== ''
|
||||
// ) {
|
||||
// return false
|
||||
// } else {
|
||||
// return true
|
||||
// }
|
||||
return false
|
||||
}, [])
|
||||
|
||||
// 新建收款
|
||||
const handAdd = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/addCollection/index',
|
||||
})
|
||||
}
|
||||
|
||||
// 筛选弹出
|
||||
|
||||
const [SelectPopup, setSelectPopup] = useState(false)
|
||||
|
||||
// 时间数组
|
||||
const [TimeList, setTimeList] = useState<any[]>(
|
||||
[
|
||||
{
|
||||
id: 1,
|
||||
name: '默认14天内',
|
||||
start_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '展示全部日期',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
checked: false,
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
// 选择时间item
|
||||
const handSelect = (it) => {
|
||||
TimeList.map((item) => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTimeList([...TimeList])
|
||||
pageNum.current.size = 10
|
||||
setSearchField({ ...searchField, start_time: it.start_time, end_time: it.end_time, size: 10 })
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
// 重置
|
||||
const handReset = () => {
|
||||
TimeList.map((item) => {
|
||||
if (item.id == 1) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTimeList([...TimeList])
|
||||
pageNum.current.size = 10
|
||||
setSearchField({
|
||||
...searchField,
|
||||
start_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
size: 10,
|
||||
})
|
||||
setStart(myDate.toLocaleDateString())
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
// 弹窗确认选择
|
||||
const handSureSelect = () => {
|
||||
pageNum.current.size = 10
|
||||
setSearchField({ ...searchField, size: 10 })
|
||||
getOrderList()
|
||||
setSelectPopup(false)
|
||||
}
|
||||
|
||||
// 展示时间筛选
|
||||
const [showTime, setShowTime] = useState(false)
|
||||
// 关闭时间筛选
|
||||
const handClose = () => {
|
||||
setShowTime(false)
|
||||
}
|
||||
|
||||
const [start, setStart] = useState<any>(myDate.toLocaleDateString())
|
||||
const [end, setEnd] = useState<any>('')
|
||||
// 选择时间
|
||||
const handTime = (eq) => {
|
||||
// 直接进来点确定的时候做处理
|
||||
if (Object.keys(eq).length === 0) {
|
||||
const obj = {
|
||||
start: '',
|
||||
end: '',
|
||||
}
|
||||
obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00`,
|
||||
obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`
|
||||
eq.value = obj
|
||||
}
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading as any })
|
||||
}, [orderData, orderState])
|
||||
setSearchField(val => ({ ...val, start_time: eq?.value?.start, end_time: eq?.value?.end }))
|
||||
setStart(eq?.value?.start)
|
||||
setEnd(eq?.value?.end)
|
||||
setShowTime(false)
|
||||
pageNum.current.size = 10
|
||||
}
|
||||
|
||||
//上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
console.log(pageNum.current.page, 'pageNum.current.page')
|
||||
console.log(size, 123123)
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
//是否不允许确认筛选
|
||||
const isDisabled = useMemo(() => {
|
||||
// if (searchField.stage !== '不限' ||
|
||||
// searchField.sale_mode !== '不限' ||
|
||||
// searchField.return_type !== '不限' ||
|
||||
// searchField.start_time !== '' ||
|
||||
// searchField.end_time !== ''
|
||||
// ) {
|
||||
// return false
|
||||
// } else {
|
||||
// return true
|
||||
// }
|
||||
return false
|
||||
}, [])
|
||||
|
||||
//新建收款
|
||||
const handAdd = () => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/addCollection/index'
|
||||
})
|
||||
const timeArea = useMemo(() => {
|
||||
// const res = TimeList.filter(item => {
|
||||
// return item.checked
|
||||
// })
|
||||
// && res.length > 0
|
||||
if (end !== '') {
|
||||
return `${start} ` + '-' + ` ${end}`
|
||||
}
|
||||
else {
|
||||
return '自定义起始时间'
|
||||
}
|
||||
}, [end])
|
||||
|
||||
//筛选弹出
|
||||
useEffect(() => {
|
||||
setSearchField(searchField)
|
||||
}, [searchField])
|
||||
|
||||
const [SelectPopup, setSelectPopup] = useState(false)
|
||||
|
||||
//时间数组
|
||||
const [TimeList, setTimeList] = useState<any[]>(
|
||||
[
|
||||
return (
|
||||
<>
|
||||
<View style={{ background: '#FFFFFF', paddingLeft: '20rpx', paddingBottom: '20rpx', position: 'sticky', top: '0', zIndex: '99' }}>
|
||||
<Search placeholder="请输入客户或客户跟进人" showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
|
||||
<View className={styles.flexBox} onClick={() => { setSelectPopup(true) }}>
|
||||
<IconFont name="icon-shaixuan" size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles.activeshaixuan} />
|
||||
{/* <View className={classnames('iconfont', 'icon-shaixuan', !isDisabled ? styles.icon_shaixuan : styles.activeshaixuan)}></View> */}
|
||||
<View className={classnames(isDisabled ? styles.shaixuan : styles.activeshai)}>筛选</View>
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
<View className={styles.pageTop}>
|
||||
<View className={styles.pageTopLeft}>时间默认14天内</View>
|
||||
<View className={styles.pageTopRight}>金额汇总:{formatPriceDiv(orderData?.summary?.receipt_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<View key={item.id} className={styles.order_item_con}>
|
||||
<ItemList
|
||||
obj={item}
|
||||
key={index}
|
||||
></ItemList>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
<View className={styles.kongboxTwo}></View>
|
||||
<View className={styles.fixedBox}>
|
||||
<View className={styles.addBtn} onClick={() => handAdd()}>新建收款</View>
|
||||
</View>
|
||||
</View>
|
||||
<Popup title="选择日期" show={SelectPopup} onClose={() => { setSelectPopup(false) }}>
|
||||
<View className={styles.popupBox}>
|
||||
<View className={styles.timeFlex}>
|
||||
{
|
||||
id: 1,
|
||||
name: '默认14天内',
|
||||
start_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '展示全部日期',
|
||||
start_time: '',
|
||||
end_time: '',
|
||||
checked: false
|
||||
TimeList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => handSelect(item)} className={classnames((item.checked && timeArea == '自定义起始时间') ? styles.activetimeOne : styles.timeOne)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
//选择时间item
|
||||
const handSelect = (it) => {
|
||||
|
||||
TimeList.map(item => {
|
||||
if (item.id == it.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTimeList([...TimeList])
|
||||
pageNum.current.size = 10
|
||||
setSearchField({ ...searchField, start_time: it.start_time, end_time: it.end_time, size: 10 })
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
//重置
|
||||
const handReset = () => {
|
||||
TimeList.map(item => {
|
||||
if (item.id == 1) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
setTimeList([...TimeList])
|
||||
pageNum.current.size = 10
|
||||
setSearchField({
|
||||
...searchField,
|
||||
start_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).subtract(14, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
end_time: `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`,
|
||||
size: 10
|
||||
})
|
||||
setStart(myDate.toLocaleDateString())
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
|
||||
|
||||
//弹窗确认选择
|
||||
const handSureSelect = () => {
|
||||
pageNum.current.size = 10
|
||||
setSearchField({ ...searchField, size: 10 })
|
||||
getOrderList()
|
||||
setSelectPopup(false)
|
||||
}
|
||||
|
||||
//展示时间筛选
|
||||
const [showTime, setShowTime] = useState(false)
|
||||
//关闭时间筛选
|
||||
const handClose = () => {
|
||||
setShowTime(false)
|
||||
}
|
||||
|
||||
const [start, setStart] = useState<any>(myDate.toLocaleDateString())
|
||||
const [end, setEnd] = useState<any>('')
|
||||
//选择时间
|
||||
const handTime = (eq) => {
|
||||
//直接进来点确定的时候做处理
|
||||
if (Object.keys(eq).length === 0) {
|
||||
let obj = {
|
||||
start: '',
|
||||
end: ''
|
||||
}
|
||||
obj.start = `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).format('YYYY-MM-DD')} 00:00:00`,
|
||||
obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`
|
||||
eq.value = obj
|
||||
}
|
||||
setSearchField((val) => ({ ...val, start_time: eq?.value?.start, end_time: eq?.value?.end }))
|
||||
setStart(eq?.value?.start)
|
||||
setEnd(eq?.value?.end)
|
||||
setShowTime(false)
|
||||
pageNum.current.size = 10
|
||||
}
|
||||
|
||||
|
||||
const timeArea = useMemo(() => {
|
||||
// const res = TimeList.filter(item => {
|
||||
// return item.checked
|
||||
// })
|
||||
// && res.length > 0
|
||||
if (end !== '') {
|
||||
return start + ' ' + '-' + ' ' + end
|
||||
} else {
|
||||
return '自定义起始时间'
|
||||
}
|
||||
}, [end])
|
||||
|
||||
useEffect(() => {
|
||||
setSearchField(searchField)
|
||||
}, [searchField])
|
||||
|
||||
return (
|
||||
<>
|
||||
<View style={{ background: '#FFFFFF', paddingLeft: '20rpx', paddingBottom: '20rpx', position: 'sticky', top: '0', zIndex: '99' }}>
|
||||
<Search placeholder='请输入客户或客户跟进人' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} >
|
||||
<View className={styles.flexBox} onClick={() => { setSelectPopup(true) }}>
|
||||
<IconFont name='icon-shaixuan' size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles['activeshaixuan']} />
|
||||
{/* <View className={classnames('iconfont', 'icon-shaixuan', !isDisabled ? styles.icon_shaixuan : styles.activeshaixuan)}></View> */}
|
||||
<View className={classnames(isDisabled ? styles.shaixuan : styles.activeshai)}>筛选</View>
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
<View className={classnames(timeArea == '自定义起始时间' ? styles.timeBox2 : styles.activetimeBox2)} onClick={() => { setShowTime(true) }}>{timeArea}
|
||||
<View className={styles.more}>
|
||||
{
|
||||
timeArea == '自定义起始时间'
|
||||
&& <IconFont name="icon-chakanquanbukehu" color="#000000" size={40} customClassName={styles.more}></IconFont>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.pageTop}>
|
||||
<View className={styles.pageTopLeft}>时间默认14天内</View>
|
||||
<View className={styles.pageTopRight}>金额汇总:{formatPriceDiv(orderData?.summary?.receipt_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<View key={item.id} className={styles.order_item_con}>
|
||||
<ItemList
|
||||
obj={item}
|
||||
key={index}
|
||||
></ItemList>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
<View className={styles.kongboxTwo}></View>
|
||||
<View className={styles.fixedBox}>
|
||||
<View className={styles.addBtn} onClick={() => handAdd()}>新建收款</View>
|
||||
</View>
|
||||
</View>
|
||||
<Popup title={'选择日期'} show={SelectPopup} onClose={() => { setSelectPopup(false) }}>
|
||||
<View className={styles.popupBox}>
|
||||
<View className={styles.timeFlex}>
|
||||
{
|
||||
TimeList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => handSelect(item)} className={classnames((item.checked && timeArea == '自定义起始时间') ? styles.activetimeOne : styles.timeOne)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
<View className={classnames(timeArea == '自定义起始时间' ? styles.timeBox2 : styles.activetimeBox2)} onClick={() => { setShowTime(true) }}>{timeArea}
|
||||
<View className={styles.more}>
|
||||
{
|
||||
timeArea == '自定义起始时间' &&
|
||||
<IconFont name={'icon-chakanquanbukehu'} color={'#000000'} size={40} customClassName={styles['more']}></IconFont>
|
||||
}
|
||||
</View>
|
||||
{/* {
|
||||
{/* {
|
||||
timeArea == '自定义起始时间' && <View className={classnames('iconfont', 'icon-chakanquanbukehu', styles.more)}></View>
|
||||
} */}
|
||||
</View>
|
||||
<View className={styles.safeBox} ></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSureSelect()}> 确认</Button >
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
<TimePickerPopup
|
||||
start={start}
|
||||
end={end}
|
||||
showTime={showTime}
|
||||
closePopup={handClose}
|
||||
onSelectDate={(e) => handTime(e)}
|
||||
></TimePickerPopup>
|
||||
</>
|
||||
)
|
||||
</View>
|
||||
<View className={styles.safeBox} ></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button : styles.activeButton)} disabled={isDisabled} onClick={() => handSureSelect()}> 确认</Button >
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
<TimePickerPopup
|
||||
start={start}
|
||||
end={end}
|
||||
showTime={showTime}
|
||||
closePopup={handClose}
|
||||
onSelectDate={e => handTime(e)}
|
||||
></TimePickerPopup>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,193 +1,193 @@
|
||||
|
||||
import { ScrollView, View, Image } from '@tarojs/components'
|
||||
import { memo, useCallback, useEffect, useMemo, useState, useRef } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv, formatImgUrl } from '@/common/format'
|
||||
import { Image, ScrollView, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatImgUrl, formatPriceDiv } from '@/common/format'
|
||||
import Popup from '@/components/popup'
|
||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||
import { alert } from '@/common/common'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
interface Props {
|
||||
showPopup: true | false,
|
||||
popupClose?: () => void,
|
||||
obj: {
|
||||
wait_pay_amount?: number | string,
|
||||
actual_amount?: number | string,
|
||||
total_sale_price?: number | string,
|
||||
should_collect_order_id?: number | string,
|
||||
pre_collect_order_id?: number | string,
|
||||
status?: number | string,
|
||||
},
|
||||
showSide?: boolean,
|
||||
list?: any[],
|
||||
clickItem?: (any) => void,
|
||||
handsurePay?: (any) => void,
|
||||
title: string,
|
||||
picUrl?: string
|
||||
showPopup: true | false
|
||||
popupClose?: () => void
|
||||
obj: {
|
||||
wait_pay_amount?: number | string
|
||||
actual_amount?: number | string
|
||||
total_sale_price?: number | string
|
||||
should_collect_order_id?: number | string
|
||||
pre_collect_order_id?: number | string
|
||||
status?: number | string
|
||||
}
|
||||
showSide?: boolean
|
||||
list?: any[]
|
||||
clickItem?: (any) => void
|
||||
handsurePay?: (any) => void
|
||||
title: string
|
||||
picUrl?: string
|
||||
}
|
||||
|
||||
export default memo((props: Props) => {
|
||||
const {
|
||||
showSide = true,
|
||||
showPopup = false,
|
||||
popupClose,
|
||||
obj = {
|
||||
wait_pay_amount: '',
|
||||
actual_amount: '',
|
||||
total_sale_price: ''
|
||||
},
|
||||
clickItem,
|
||||
handsurePay,
|
||||
list = [],
|
||||
title = '待支付款项',
|
||||
picUrl = ''
|
||||
} = props
|
||||
const {
|
||||
showSide = true,
|
||||
showPopup = false,
|
||||
popupClose,
|
||||
obj = {
|
||||
wait_pay_amount: '',
|
||||
actual_amount: '',
|
||||
total_sale_price: '',
|
||||
},
|
||||
clickItem,
|
||||
handsurePay,
|
||||
list = [],
|
||||
title = '待支付款项',
|
||||
picUrl = '',
|
||||
} = props
|
||||
|
||||
const fileData = useRef({
|
||||
filePath: '',
|
||||
base64: '',
|
||||
const fileData = useRef({
|
||||
filePath: '',
|
||||
base64: '',
|
||||
})
|
||||
|
||||
// 预览图片
|
||||
const showImage = () => {
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(picUrl) || []
|
||||
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
Taro.previewImage({
|
||||
current: fileData.current.filePath, // 当前显示
|
||||
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
|
||||
})
|
||||
}
|
||||
|
||||
//预览图片
|
||||
const showImage = () => {
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(picUrl) || []
|
||||
let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
Taro.previewImage({
|
||||
current: fileData.current.filePath, // 当前显示
|
||||
urls: [fileData.current.filePath], // 需要预览的图片http链接列表
|
||||
})
|
||||
}
|
||||
// 检查是否开启保存图片权限
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
||||
const saveImageCheck = async() => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
|
||||
// 保存图片
|
||||
const saveImage = () => {
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(picUrl) || []
|
||||
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
alert.loading('正在保存图片')
|
||||
Taro.saveImageToPhotosAlbum({
|
||||
filePath: fileData.current.filePath,
|
||||
success() {
|
||||
alert.success('图片保存成功')
|
||||
},
|
||||
fail(err) {
|
||||
console.log('err::', err)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//检查是否开启保存图片权限
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
||||
const saveImageCheck = async () => {
|
||||
const res = await check()
|
||||
res && saveImage()
|
||||
}
|
||||
|
||||
//保存图片
|
||||
const saveImage = () => {
|
||||
const time = new Date().valueOf()
|
||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(picUrl) || []
|
||||
let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format
|
||||
fileData.current.filePath = filePath
|
||||
fileData.current.base64 = bodyData
|
||||
const save = Taro.getFileSystemManager()
|
||||
save.writeFile({
|
||||
filePath: fileData.current.filePath,
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
alert.loading('正在保存图片')
|
||||
Taro.saveImageToPhotosAlbum({
|
||||
filePath: fileData.current.filePath,
|
||||
success: function () {
|
||||
alert.success('图片保存成功')
|
||||
},
|
||||
fail: function (err) {
|
||||
console.log('err::', err)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.popupBox}>
|
||||
<Popup show={showPopup} title={title} onClose={() => popupClose?.()}>
|
||||
<ScrollView enhanced scrollY className={styles.scrollStyle} >
|
||||
{
|
||||
showSide &&
|
||||
<View className={styles.contBox}>
|
||||
<View className={styles.topMoney}>
|
||||
return (
|
||||
<View className={styles.popupBox}>
|
||||
<Popup show={showPopup} title={title} onClose={() => popupClose?.()}>
|
||||
<ScrollView enhanced scrollY className={styles.scrollStyle} >
|
||||
{
|
||||
showSide
|
||||
&& <View className={styles.contBox}>
|
||||
<View className={styles.topMoney}>
|
||||
¥{formatPriceDiv(obj.wait_pay_amount)}
|
||||
</View>
|
||||
<View className={styles.itemMoney}>
|
||||
<View className={styles.leftFont}>
|
||||
</View>
|
||||
<View className={styles.itemMoney}>
|
||||
<View className={styles.leftFont}>
|
||||
订单金额
|
||||
</View>
|
||||
<View className={styles.rightFont}>
|
||||
</View>
|
||||
<View className={styles.rightFont}>
|
||||
¥{formatPriceDiv(obj.wait_pay_amount)}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.itemMoney}>
|
||||
<View className={styles.leftFont}>
|
||||
</View>
|
||||
<View className={styles.itemMoney}>
|
||||
<View className={styles.leftFont}>
|
||||
已付金额
|
||||
</View>
|
||||
<View className={styles.rightFont}>
|
||||
¥{formatPriceDiv(obj.actual_amount)}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.itemBox} key={index} onClick={() => clickItem?.(item)}>
|
||||
<View className={styles.leftItem}>
|
||||
<View className={styles.leftCrile}
|
||||
style={{ backgroundColor: `${item.name == '线下汇款' ? '#fca846' : '#4a7fff'}` }}
|
||||
>
|
||||
<IconFont name={item.iconfont} size={35} color={item.color}></IconFont>
|
||||
{/* <View className={classnames('iconfont', item.iconfont, styles.lujing)}></View> */}
|
||||
<View className={styles.rightFont}>
|
||||
¥{formatPriceDiv(obj.actual_amount)}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.itemBox} key={index} onClick={() => clickItem?.(item)}>
|
||||
<View className={styles.leftItem}>
|
||||
<View className={styles.leftCrile}
|
||||
style={{ backgroundColor: `${item.name == '线下汇款' ? '#fca846' : '#4a7fff'}` }}
|
||||
>
|
||||
<IconFont name={item.iconfont} size={35} color={item.color}></IconFont>
|
||||
{/* <View className={classnames('iconfont', item.iconfont, styles.lujing)}></View> */}
|
||||
</View>
|
||||
<View className={styles.rightLeft}>
|
||||
<View className={styles.title}>{item.name}</View>
|
||||
{
|
||||
item.fonts && <View className={styles.nums}>{item.fonts}{
|
||||
item.money !== '' ? '¥' : ''
|
||||
}{item.money}</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
item.name !== '扫码支付' && item.name !== '线下汇款'
|
||||
&& <View className={item.checked ? styles.activeChecked : styles.checkYuan}>
|
||||
{/* <View className={classnames('iconfont', 'icon-lujing', styles.gou)}></View> */}
|
||||
<IconFont name="icon-lujing" size={20} color="#ffffff"></IconFont>
|
||||
</View>
|
||||
<View className={styles.rightLeft}>
|
||||
<View className={styles.title}>{item.name}</View>
|
||||
{
|
||||
item.fonts && <View className={styles.nums}>{item.fonts}{
|
||||
item.money !== "" ? "¥" : ""
|
||||
}{item.money}</View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
item.name !== '扫码支付' && item.name !== '线下汇款' &&
|
||||
<View className={item.checked ? styles.activeChecked : styles.checkYuan}>
|
||||
{/* <View className={classnames('iconfont', 'icon-lujing', styles.gou)}></View> */}
|
||||
<IconFont name={'icon-lujing'} size={20} color={'#ffffff'}></IconFont>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(item.name === '扫码支付' || item.name === '线下汇款') &&
|
||||
<IconFont name={'icon-chakanquanbukehu'} size={50} color={'#000000'} customClassName={styles['chakanquanbukehu']}></IconFont>
|
||||
}
|
||||
{
|
||||
(item.name === '扫码支付' || item.name === '线下汇款')
|
||||
&& <IconFont name="icon-chakanquanbukehu" size={50} color="#000000" customClassName={styles.chakanquanbukehu}></IconFont>
|
||||
// <View className={classnames('iconfont', 'icon-chakanquanbukehu', styles.chakanquanbukehu)}></View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</View>
|
||||
|
||||
}
|
||||
{
|
||||
showSide && <View className={styles.sure} onClick={() => handsurePay?.(props?.obj)}>确认交易</View>
|
||||
}
|
||||
{
|
||||
!showSide &&
|
||||
<ScrollView enhanced scrollY className={styles.scroStyle}>
|
||||
<View className={styles.pic}>
|
||||
<Image lazyLoad mode='widthFix' style={{ width: '100%', height: '100%' }} src={picUrl} onClick={() => showImage()}></Image>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
showSide && <View className={styles.sure} onClick={() => handsurePay?.(props?.obj)}>确认交易</View>
|
||||
}
|
||||
{
|
||||
!showSide
|
||||
&& <ScrollView enhanced scrollY className={styles.scroStyle}>
|
||||
<View className={styles.pic}>
|
||||
<Image lazyLoad mode="widthFix" style={{ width: '100%', height: '100%' }} src={picUrl} onClick={() => showImage()}></Image>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
}
|
||||
{
|
||||
!showSide && <View className={styles.sure} onClick={() => saveImageCheck()}>保存图片</View>
|
||||
}
|
||||
<View className={styles.safeBox}></View>
|
||||
</ScrollView>
|
||||
</Popup >
|
||||
</View >
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
!showSide && <View className={styles.sure} onClick={() => saveImageCheck()}>保存图片</View>
|
||||
}
|
||||
<View className={styles.safeBox}></View>
|
||||
</ScrollView>
|
||||
</Popup >
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,107 +1,108 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv } from '@/common/format'
|
||||
import Taro from '@tarojs/taro'
|
||||
import LabAndImg from "@/components/LabAndImg"
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
interface propsObj {
|
||||
obj: any,
|
||||
cancle?: (arg: any, obj: any) => void,
|
||||
nextBuy?: (arg: any, obj: any) => void,
|
||||
toPay?: (arg: any, obj: any) => void
|
||||
obj: any
|
||||
cancle?: (arg: any, obj: any) => void
|
||||
nextBuy?: (arg: any, obj: any) => void
|
||||
toPay?: (arg: any, obj: any) => void
|
||||
}
|
||||
|
||||
|
||||
export default memo((props: propsObj) => {
|
||||
const navTo = (e) => {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/orderDetails/index?id=' + props?.obj?.id
|
||||
})
|
||||
const navTo = (e) => {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/orderDetails/index?id=${props?.obj?.id}`,
|
||||
})
|
||||
}
|
||||
|
||||
const totalMoney = useMemo(() => {
|
||||
if (props?.obj.status == 0 || props?.obj.status == 1 || props?.obj.status == 2) {
|
||||
return props?.obj?.estimate_amount
|
||||
}
|
||||
else {
|
||||
return props?.obj?.bill_total_sale_price
|
||||
}
|
||||
}, [props?.obj])
|
||||
|
||||
const totalMoney = useMemo(() => {
|
||||
if (props?.obj.status == 0 || props?.obj.status == 1 || props?.obj.status == 2) {
|
||||
return props?.obj?.estimate_amount
|
||||
} else {
|
||||
return props?.obj?.bill_total_sale_price
|
||||
}
|
||||
}, [props?.obj])
|
||||
// 待接单、配布中、已配布状态时,叫预估金额,其他状态叫合计金额。
|
||||
const monyFont = useMemo(() => {
|
||||
if (props?.obj?.status === 0 || props?.obj?.status === 1) {
|
||||
return '预估金额'
|
||||
}
|
||||
else {
|
||||
return '合计金额'
|
||||
}
|
||||
}, [props?.obj])
|
||||
|
||||
//待接单、配布中、已配布状态时,叫预估金额,其他状态叫合计金额。
|
||||
const monyFont = useMemo(() => {
|
||||
if (props?.obj?.status === 0 || props?.obj?.status === 1) {
|
||||
return "预估金额"
|
||||
} else {
|
||||
return "合计金额"
|
||||
}
|
||||
}, [props?.obj])
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={e => navTo(e)}>
|
||||
<View className={styles.topItem}>
|
||||
<View className={styles.orderNo}>单号:{props?.obj?.order_no}</View>
|
||||
<View className={styles.status}>{props?.obj?.status_name}</View>
|
||||
</View>
|
||||
<View className={styles.pussName}>{props?.obj?.purchaser_name}</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.contBox}>
|
||||
<View style={{ minWidth: '24%' }}>
|
||||
<View className={styles.leftCont}>
|
||||
<LabAndImg value={labAndImgObj(props?.obj?.product_list?.[0])} />
|
||||
<View className={styles.leftContNums}>颜色 ({props?.obj?.total_colors})</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={(e) => navTo(e)}>
|
||||
<View className={styles.topItem}>
|
||||
<View className={styles.orderNo}>单号:{props?.obj?.order_no}</View>
|
||||
<View className={styles.status}>{props?.obj?.status_name}</View>
|
||||
<View className={styles.rightCont}>
|
||||
<View className={styles.rightTop}>
|
||||
<View className={styles.productBox}>
|
||||
<View className={styles.productName}>{props?.obj?.product_list[0]?.code} {props?.obj?.product_list[0]?.name}</View>
|
||||
<View className={styles.productMode}>{props?.obj?.sale_mode === 0 ? '大货' : props?.obj?.sale_mode === 1 ? '剪版' : '散剪'}</View>
|
||||
</View>
|
||||
<View className={styles.pussName}>{props?.obj?.purchaser_name}</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.contBox}>
|
||||
<View style={{ minWidth: '24%' }}>
|
||||
<View className={styles.leftCont}>
|
||||
<LabAndImg value={labAndImgObj(props?.obj?.product_list?.[0])} />
|
||||
<View className={styles.leftContNums}>颜色 ({props?.obj?.total_colors})</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className={styles.rightCont}>
|
||||
<View className={styles.rightTop}>
|
||||
<View className={styles.productBox}>
|
||||
<View className={styles.productName}>{props?.obj?.product_list[0]?.code} {props?.obj?.product_list[0]?.name}</View>
|
||||
<View className={styles.productMode}>{props?.obj?.sale_mode === 0 ? '大货' : props?.obj?.sale_mode === 1 ? '剪版' : '散剪'}</View>
|
||||
</View>
|
||||
<View className={styles.shipMode}>{props?.obj?.shipment_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[0]?.code} {props?.obj?.product_list[0]?.product_colors[0]?.name}</View>
|
||||
<View className={styles.colorName}>x{props?.obj?.sale_mode === 0 ? props?.obj?.product_list[0]?.product_colors[0]?.roll : props?.obj?.product_list[0]?.product_colors[0]?.length / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[0]?.sale_price / 100}/{props?.obj?.sale_mode == 1 ? 'm' : 'kg'}</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj?.product_list[0]?.product_colors?.length > 1 && <>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[1]?.code} {props?.obj?.product_list[0]?.product_colors[1]?.name}</View>
|
||||
<View className={styles.colorName}>x{props?.obj?.sale_mode === 0 ? props?.obj?.product_list[0]?.product_colors[1]?.roll : props?.obj?.product_list[0]?.product_colors[1]?.length / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[1]?.sale_price / 100}/{props?.obj?.sale_mode == 1 ? 'm' : 'kg'}</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.lineOne}></View>
|
||||
<View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>布料信息:</View>
|
||||
<View className={styles.msgRight}>{props?.obj?.total_fabrics} 种面料,{props?.obj?.total_colors} 种颜色,共 {props?.obj?.sale_mode === 0 ? props?.obj?.total_number : props?.obj?.total_number / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj.status != 5 && <View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>{monyFont}</View>
|
||||
<View className={styles.msgRightOne}>¥{formatPriceDiv(totalMoney)}</View>
|
||||
</View>
|
||||
}
|
||||
<View className={styles.bottomBox}>
|
||||
<BottomBtns
|
||||
obj={props?.obj}
|
||||
cancle={(e) => props?.cancle?.(e, props?.obj)}
|
||||
nextBuy={(e) => props?.nextBuy?.(e, props?.obj)}
|
||||
toPay={(e) => props?.toPay?.(e, props?.obj)}
|
||||
></BottomBtns>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
<View className={styles.shipMode}>{props?.obj?.shipment_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[0]?.code} {props?.obj?.product_list[0]?.product_colors[0]?.name}</View>
|
||||
<View className={styles.colorName}>x{props?.obj?.sale_mode === 0 ? props?.obj?.product_list[0]?.product_colors[0]?.roll : props?.obj?.product_list[0]?.product_colors[0]?.length / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[0]?.sale_price / 100}/{props?.obj?.sale_mode == 1 ? 'm' : 'kg'}</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj?.product_list[0]?.product_colors?.length > 1 && <>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[1]?.code} {props?.obj?.product_list[0]?.product_colors[1]?.name}</View>
|
||||
<View className={styles.colorName}>x{props?.obj?.sale_mode === 0 ? props?.obj?.product_list[0]?.product_colors[1]?.roll : props?.obj?.product_list[0]?.product_colors[1]?.length / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[1]?.sale_price / 100}/{props?.obj?.sale_mode == 1 ? 'm' : 'kg'}</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.lineOne}></View>
|
||||
<View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>布料信息:</View>
|
||||
<View className={styles.msgRight}>{props?.obj?.total_fabrics} 种面料,{props?.obj?.total_colors} 种颜色,共 {props?.obj?.sale_mode === 0 ? props?.obj?.total_number : props?.obj?.total_number / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj.status != 5 && <View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>{monyFont}</View>
|
||||
<View className={styles.msgRightOne}>¥{formatPriceDiv(totalMoney)}</View>
|
||||
</View>
|
||||
}
|
||||
<View className={styles.bottomBox}>
|
||||
<BottomBtns
|
||||
obj={props?.obj}
|
||||
cancle={e => props?.cancle?.(e, props?.obj)}
|
||||
nextBuy={e => props?.nextBuy?.(e, props?.obj)}
|
||||
toPay={e => props?.toPay?.(e, props?.obj)}
|
||||
></BottomBtns>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,100 +1,101 @@
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
import AmountShow from "../amountShow";
|
||||
import classnames from "classnames";
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import AmountShow from '../amountShow'
|
||||
import styles from './index.module.scss'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import Popup from '@/components/popup'
|
||||
import SearchInput from '@/components/searchInput'
|
||||
|
||||
import MCheckbox from "@/components/checkbox";
|
||||
import Popup from "@/components/popup";
|
||||
import SearchInput from "@/components/searchInput";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
type Param = {
|
||||
show?: true | false,
|
||||
onClose?: () => void,
|
||||
offlineInfo?: {
|
||||
account_name: string,
|
||||
bank_of_deposit: string,
|
||||
transfer_remittance_account: string
|
||||
},
|
||||
showKong?: true | false,
|
||||
interface Param {
|
||||
show?: true | false
|
||||
onClose?: () => void
|
||||
offlineInfo?: {
|
||||
account_name: string
|
||||
bank_of_deposit: string
|
||||
transfer_remittance_account: string
|
||||
}
|
||||
showKong?: true | false
|
||||
}
|
||||
export default memo(({ show = true, onClose, offlineInfo, showKong = true }: Param) => {
|
||||
//复制功能
|
||||
const clipboardData = () => {
|
||||
Taro.setClipboardData({
|
||||
data: `开户名称:${offlineInfo?.account_name};\n\r 开户银行:${offlineInfo?.bank_of_deposit};\n\r 转账汇款账号:${offlineInfo?.transfer_remittance_account};`,
|
||||
success: function (res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功'
|
||||
})
|
||||
}
|
||||
// 复制功能
|
||||
const clipboardData = () => {
|
||||
Taro.setClipboardData({
|
||||
data: `开户名称:${offlineInfo?.account_name};\n\r 开户银行:${offlineInfo?.bank_of_deposit};\n\r 转账汇款账号:${offlineInfo?.transfer_remittance_account};`,
|
||||
success(res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
// //复制功能
|
||||
const copy = (index) => {
|
||||
let res: any = ''
|
||||
if (index === 1) {
|
||||
res = offlineInfo?.account_name
|
||||
}
|
||||
// //复制功能
|
||||
const copy = (index) => {
|
||||
let res: any = ''
|
||||
if (index === 1) {
|
||||
res = offlineInfo?.account_name
|
||||
} else if (index === 2) {
|
||||
res = offlineInfo?.bank_of_deposit
|
||||
} else if (index === 3) {
|
||||
res = offlineInfo?.transfer_remittance_account
|
||||
}
|
||||
Taro.setClipboardData({
|
||||
data: res || '',
|
||||
success: function (res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
},
|
||||
else if (index === 2) {
|
||||
res = offlineInfo?.bank_of_deposit
|
||||
}
|
||||
else if (index === 3) {
|
||||
res = offlineInfo?.transfer_remittance_account
|
||||
}
|
||||
Taro.setClipboardData({
|
||||
data: res || '',
|
||||
success(res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
}
|
||||
return (
|
||||
<View className={styles.offlinePay_main}>
|
||||
<Popup show={show} showTitle={false} onClose={onClose} >
|
||||
<View className={styles.offlinePay_con}>
|
||||
<View className={classnames('iconfont icon-a-moreback', styles.miconfont_title)} onClick={onClose}></View>
|
||||
<View className={styles.title}>线下汇款</View>
|
||||
<View className={styles.offlinePay_list}>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>开户名称</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.account_name}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(1) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>开户银行</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.bank_of_deposit}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(2) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>转账汇款账号</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.transfer_remittance_account}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(3) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
{/* <SearchInput showBorder={false} title='开户银行' titleStyle={{ fontSize: '23rpx' }}>
|
||||
},
|
||||
})
|
||||
}
|
||||
return (
|
||||
<View className={styles.offlinePay_main}>
|
||||
<Popup show={show} showTitle={false} onClose={onClose} >
|
||||
<View className={styles.offlinePay_con}>
|
||||
<View className={classnames('iconfont icon-a-moreback', styles.miconfont_title)} onClick={onClose}></View>
|
||||
<View className={styles.title}>线下汇款</View>
|
||||
<View className={styles.offlinePay_list}>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>开户名称</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.account_name}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(1) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>开户银行</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.bank_of_deposit}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(2) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.flexBox}>
|
||||
<View className={styles.title}>转账汇款账号</View>
|
||||
<View className={styles.leftFlex}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.transfer_remittance_account}</Text>
|
||||
<View className={styles.btn} onClick={() => { copy(3) }}>复制</View>
|
||||
</View>
|
||||
</View>
|
||||
{/* <SearchInput showBorder={false} title='开户银行' titleStyle={{ fontSize: '23rpx' }}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.bank_of_deposit}</Text>
|
||||
</SearchInput>
|
||||
<SearchInput showBorder={false} title='转账汇款账号' titleStyle={{ fontSize: '23rpx' }}>
|
||||
<Text className={styles.offlinePay_con_text}>{offlineInfo?.transfer_remittance_account}</Text>
|
||||
</SearchInput> */}
|
||||
</View>
|
||||
<View className={styles.btns} onClick={clipboardData}>复制信息</View>
|
||||
</View>
|
||||
{
|
||||
showKong && <View className={styles.kongBox}></View>
|
||||
}
|
||||
|
||||
</Popup>
|
||||
</View>
|
||||
<View className={styles.btns} onClick={clipboardData}>复制信息</View>
|
||||
</View>
|
||||
{
|
||||
showKong && <View className={styles.kongBox}></View>
|
||||
}
|
||||
|
||||
)
|
||||
})
|
||||
</Popup>
|
||||
</View>
|
||||
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
type Param = {
|
||||
interface Param {
|
||||
list: { id: number; name: string }[]
|
||||
defaultId?: number | null
|
||||
onSelect?: (val: number) => void
|
||||
}
|
||||
export default memo(({ list = [], defaultId = null, onSelect }: Param) => {
|
||||
const [selectInfo, setSelectInfo] = useState({
|
||||
selected: -1, //当前选中的id
|
||||
tabId: '', //需要滚动到的id
|
||||
selected: -1, // 当前选中的id
|
||||
tabId: '', // 需要滚动到的id
|
||||
})
|
||||
useEffect(() => {
|
||||
if (typeof defaultId === 'number' && defaultId >= 0) {
|
||||
@@ -21,20 +21,20 @@ export default memo(({ list = [], defaultId = null, onSelect }: Param) => {
|
||||
})
|
||||
if (index !== -1) {
|
||||
const num = index > 0 ? index - 1 : 0
|
||||
setSelectInfo((e) => ({ ...e, tabId: list[num].id.toString() }))
|
||||
setSelectInfo(e => ({ ...e, tabId: list[num].id.toString() }))
|
||||
}
|
||||
}
|
||||
setSelectInfo((e) => ({ ...e, selected: defaultId || -1 }))
|
||||
setSelectInfo(e => ({ ...e, selected: defaultId || -1 }))
|
||||
}, [defaultId])
|
||||
const clickEvent = ({ item, index }: { item: any; index: number }) => {
|
||||
const num = index > 0 ? index - 1 : 0
|
||||
setSelectInfo((e) => ({ ...e, tabId: list[num].id.toString(), selected: item.id }))
|
||||
setSelectInfo(e => ({ ...e, tabId: list[num].id.toString(), selected: item.id }))
|
||||
onSelect?.(item.id)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.order_status_list}>
|
||||
<ScrollView scrollX scrollIntoView={`tabs_${selectInfo.tabId}`} scrollWithAnimation={true}>
|
||||
<ScrollView scrollX scrollIntoView={`tabs_${selectInfo.tabId}`} scrollWithAnimation>
|
||||
<View className={styles.order_list_scroll}>
|
||||
{list.map((item, index) => {
|
||||
return (
|
||||
@@ -42,7 +42,8 @@ export default memo(({ list = [], defaultId = null, onSelect }: Param) => {
|
||||
key={item.id}
|
||||
id={`tabs_${item.id}`}
|
||||
onClick={() => clickEvent({ item, index })}
|
||||
className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)}>
|
||||
className={classnames(styles.order_status_item, selectInfo.selected == item.id && styles.selected)}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '订单',
|
||||
navigationBarTitleText: '订单',
|
||||
}
|
||||
|
||||
+216
-211
@@ -1,41 +1,42 @@
|
||||
import { View, Input, Button } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
|
||||
import { mpenumsaleorderstatus, OrderListApi } from '@/api/order'
|
||||
import OrderStatusList from './components/orderStatusList'
|
||||
import Search from '@/components/search'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Popup from '@/components/popup'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { Button, Input, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import OrderStatusList from './components/orderStatusList'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/itemList'
|
||||
import OfflinePay from './components/offlinePay'
|
||||
import PayPopup from './components/PayPopup'
|
||||
import {
|
||||
GetPayCode, OrderListApi,
|
||||
mpenumsaleorderstatus,
|
||||
mpsaleOrdercancel,
|
||||
mpshoppingCartproductColorlist,
|
||||
orderPaymentorderPaymentMethodInfo,
|
||||
orderPaymentpreCollectOrderorderPaymentMethodInfo,
|
||||
orderPaymentorderPaymentSubmission,
|
||||
orderPaymentpreCollectOrderorderPaymentMethodInfo,
|
||||
orderPaymentpreCollectOrderorderPaymentSubmission,
|
||||
GetPayCode
|
||||
} from '@/api/order'
|
||||
import PayPopup from './components/PayPopup'
|
||||
import Search from '@/components/search'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import Popup from '@/components/popup'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
interface filterObj {
|
||||
purchaser_id?: string | number,
|
||||
clientName?: string,
|
||||
sale_user_id?: string | number,
|
||||
saleuserName?: string,
|
||||
order_no?: string | undefined,
|
||||
sale_mode?: Number | undefined,
|
||||
shipment_mode?: Number | undefined
|
||||
}
|
||||
import { PAY_H5_CODE_URL } from '@/common/constant'
|
||||
|
||||
interface filterObj {
|
||||
purchaser_id?: string | number
|
||||
clientName?: string
|
||||
sale_user_id?: string | number
|
||||
saleuserName?: string
|
||||
order_no?: string | undefined
|
||||
sale_mode?: Number | undefined
|
||||
shipment_mode?: Number | undefined
|
||||
}
|
||||
|
||||
export default () => {
|
||||
//页码和页数
|
||||
// 页码和页数
|
||||
const [searchField, setSearchField] = useState<{ status: number | unknown; page: number; size: number; order_no: string }>({
|
||||
status: -1,
|
||||
page: 1,
|
||||
@@ -43,36 +44,33 @@ export default () => {
|
||||
order_no: '',
|
||||
})
|
||||
|
||||
//获取订单列表
|
||||
// 获取订单列表
|
||||
const { fetchData: listFetchData, state: orderState } = OrderListApi()
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData({
|
||||
const getOrderList = async() => {
|
||||
const res = await listFetchData({
|
||||
...getFilterData(searchField),
|
||||
...getFilterData(searchObj)
|
||||
...getFilterData(searchObj),
|
||||
})
|
||||
setOrderData((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setshowPopup(false)
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//列表下拉刷新
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField((val) => ({ ...val, size: 10 }))
|
||||
setSearchField(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
console.log({ list: orderData.list, total: orderData.total, status: orderState.loading }, '{ list: orderData.list, total: orderData.total, status: orderState.loading }')
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading })
|
||||
}, [orderData, orderState])
|
||||
|
||||
//上拉加载数据
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
@@ -85,48 +83,46 @@ export default () => {
|
||||
// //获取订单状态
|
||||
const { fetchData: orderStatusListFetchData } = mpenumsaleorderstatus()
|
||||
const [statusList, setStatusList] = useState<any[]>([{ id: -1, name: '全部' }])
|
||||
const getOrderStatusList = async () => {
|
||||
let res = await orderStatusListFetchData()
|
||||
setStatusList((e) => [...e, ...res.data.list])
|
||||
const getOrderStatusList = async() => {
|
||||
const res = await orderStatusListFetchData()
|
||||
setStatusList(e => [...e, ...res.data.list])
|
||||
}
|
||||
|
||||
//监听筛选条件变化
|
||||
// 监听筛选条件变化
|
||||
useEffect(() => {
|
||||
if (searchField.status != null) getOrderList()
|
||||
if (searchField.status != null) { getOrderList() }
|
||||
}, [searchField])
|
||||
|
||||
// //状态改变
|
||||
const changeStatus = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField((value) => ({ ...value, status: e, size: 10 }))
|
||||
setSearchField(value => ({ ...value, status: e, size: 10 }))
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
}, [])
|
||||
|
||||
//输入了搜索关键字
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, order_no: e, size: 10 }))
|
||||
setSearchField(val => ({ ...val, order_no: e, size: 10 }))
|
||||
}, [])
|
||||
//筛选内容展示
|
||||
// 筛选内容展示
|
||||
const [showPopup, setshowPopup] = useState(false)
|
||||
const showSelctPopup = () => {
|
||||
setshowPopup(true)
|
||||
}
|
||||
//关闭筛选内容展示
|
||||
// 关闭筛选内容展示
|
||||
const closePopup = () => {
|
||||
setshowPopup(false)
|
||||
}
|
||||
|
||||
|
||||
useDidShow(() => {
|
||||
|
||||
//获取选择的客户
|
||||
let pages = Taro.getCurrentPages();
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
// 获取选择的客户
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
console.log(currPage.data, '8888')
|
||||
|
||||
setsearchObj((e) => ({
|
||||
setsearchObj(e => ({
|
||||
...e,
|
||||
purchaser_id: currPage.data?.clientId ? currPage.data?.clientId : '',
|
||||
clientName: currPage.data?.clientName ? currPage.data?.clientName : '',
|
||||
@@ -135,76 +131,77 @@ export default () => {
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
|
||||
//筛选参数
|
||||
// 筛选参数
|
||||
const [searchObj, setsearchObj] = useState<filterObj>({
|
||||
purchaser_id: '',
|
||||
clientName: '',
|
||||
sale_user_id: '',
|
||||
saleuserName: '',
|
||||
sale_mode: undefined,
|
||||
shipment_mode: undefined
|
||||
shipment_mode: undefined,
|
||||
})
|
||||
// 跳转选择客户
|
||||
const navTo = (index) => {
|
||||
if (index === 1) {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/customerPage/index?clientId=' + searchObj?.purchaser_id
|
||||
url: `/pages/customerPage/index?clientId=${searchObj?.purchaser_id}`,
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/saleuserPage/index?saleuserId=' + searchObj?.sale_user_id
|
||||
url: `/pages/saleuserPage/index?saleuserId=${searchObj?.sale_user_id}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//订单类型
|
||||
// 订单类型
|
||||
const [modeList, setModeList] = useState<any[]>([{ id: -1, name: '不限' }, { id: 0, name: '大货' }, { id: 1, name: '剪版' }, { id: 2, name: '散剪' }])
|
||||
//选择订单类型
|
||||
// 选择订单类型
|
||||
const handCheckMode = (item) => {
|
||||
modeList.map(it => {
|
||||
modeList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setModeList([...modeList])
|
||||
setsearchObj((e) => ({ ...e, sale_mode: item.id }))
|
||||
setsearchObj(e => ({ ...e, sale_mode: item.id }))
|
||||
}
|
||||
|
||||
///发货方式类型
|
||||
/// 发货方式类型
|
||||
const [deliveryList, setdeliveryList] = useState<any[]>([{ id: -1, name: '不限' }, { id: 1, name: '自提' }, { id: 2, name: '物流' }])
|
||||
//选择发货方式类型
|
||||
// 选择发货方式类型
|
||||
const handCheckDelivery = (item) => {
|
||||
deliveryList.map(it => {
|
||||
deliveryList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setdeliveryList([...deliveryList])
|
||||
setsearchObj((e) => ({ ...e, shipment_mode: item.id }))
|
||||
setsearchObj(e => ({ ...e, shipment_mode: item.id }))
|
||||
}
|
||||
//是否不允许确认筛选
|
||||
// 是否不允许确认筛选
|
||||
const isDisabled = useMemo(() => {
|
||||
if (searchObj.clientName !== '' ||
|
||||
searchObj.saleuserName !== '' ||
|
||||
searchObj.sale_mode !== undefined ||
|
||||
searchObj.shipment_mode !== undefined
|
||||
if (searchObj.clientName !== ''
|
||||
|| searchObj.saleuserName !== ''
|
||||
|| searchObj.sale_mode !== undefined
|
||||
|| searchObj.shipment_mode !== undefined
|
||||
) {
|
||||
return false
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return true
|
||||
}
|
||||
}, [searchObj])
|
||||
|
||||
//重置
|
||||
// 重置
|
||||
const handReset = () => {
|
||||
pageNum.current.page = 1
|
||||
setsearchObj({
|
||||
@@ -222,29 +219,28 @@ export default () => {
|
||||
setdeliveryList([...arrTwo])
|
||||
}
|
||||
|
||||
|
||||
//数组重置
|
||||
// 数组重置
|
||||
const resetArr = (arr) => {
|
||||
arr.map(it => {
|
||||
arr.map((it) => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
return arr
|
||||
}
|
||||
//确认筛选
|
||||
const handSure = async () => {
|
||||
// 确认筛选
|
||||
const handSure = async() => {
|
||||
getOrderList()
|
||||
}
|
||||
//扫描
|
||||
// 扫描
|
||||
const handScan = () => {
|
||||
Taro.scanCode({
|
||||
success(res) {
|
||||
setSearchField((val) => ({ ...val, order_no: res.result }))
|
||||
setSearchField(val => ({ ...val, order_no: res.result }))
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res);
|
||||
console.log(res)
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -252,192 +248,195 @@ export default () => {
|
||||
}, [])
|
||||
|
||||
const { fetchData: cancelFetch } = mpsaleOrdercancel()
|
||||
//取消订单
|
||||
const cancle = async (e, item) => {
|
||||
e.stopPropagation();
|
||||
// 取消订单
|
||||
const cancle = async(e, item) => {
|
||||
e.stopPropagation()
|
||||
Taro.showModal({
|
||||
content: "确定要取消吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
content: '确定要取消吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
mask: true,
|
||||
})
|
||||
const res = await cancelFetch({ id: item.id })
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '取消成功'
|
||||
title: '取消成功',
|
||||
})
|
||||
Taro.hideLoading()
|
||||
getOrderList()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
//再次购买
|
||||
// 再次购买
|
||||
const { fetchData: buyFetch } = mpshoppingCartproductColorlist()
|
||||
const nextBuy = async (e, item) => {
|
||||
e.stopPropagation();
|
||||
const nextBuy = async(e, item) => {
|
||||
e.stopPropagation()
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
mask: true,
|
||||
})
|
||||
let arr: any = []
|
||||
item.product_list.forEach(item => {
|
||||
item.product_colors.forEach(it => {
|
||||
const arr: any = []
|
||||
item.product_list.forEach((item) => {
|
||||
item.product_colors.forEach((it) => {
|
||||
arr.push({
|
||||
length: it.length,
|
||||
roll: it.roll,
|
||||
product_color_id: it.id
|
||||
product_color_id: it.id,
|
||||
})
|
||||
})
|
||||
})
|
||||
let query = {
|
||||
const query = {
|
||||
purchaser_id: item.purchaser_id,
|
||||
sale_mode: item.sale_mode,
|
||||
color_list: arr
|
||||
color_list: arr,
|
||||
}
|
||||
const res = await buyFetch(query)
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '加入购物车成功!'
|
||||
title: '加入购物车成功!',
|
||||
})
|
||||
Taro.hideLoading()
|
||||
getOrderList()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
//去支付逻辑
|
||||
// 去支付逻辑
|
||||
const { fetchData: infoOneFetch } = orderPaymentorderPaymentMethodInfo()
|
||||
const { fetchData: infoTwoFetch } = orderPaymentpreCollectOrderorderPaymentMethodInfo()
|
||||
const [itemObj, setItemObj] = useState<any>({})
|
||||
const [payList, setPayList] = useState<any[]>([
|
||||
{
|
||||
id: 2,
|
||||
iconfont: "icon-yufukuan1",
|
||||
name: "预存款",
|
||||
fonts: "可用额度 ",
|
||||
money: "",
|
||||
iconfont: 'icon-yufukuan1',
|
||||
name: '预存款',
|
||||
fonts: '可用额度 ',
|
||||
money: '',
|
||||
isCheck: false,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
iconfont: "icon-xianxiahuizong",
|
||||
name: "货到付款",
|
||||
fonts: "发货后3天内付款",
|
||||
iconfont: 'icon-xianxiahuizong',
|
||||
name: '货到付款',
|
||||
fonts: '发货后3天内付款',
|
||||
isCheck: false,
|
||||
money: "",
|
||||
color: '#ffffff'
|
||||
money: '',
|
||||
color: '#ffffff',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
iconfont: "icon-xianxiahuizong",
|
||||
name: "x天账期",
|
||||
fonts: "可用额度 ",
|
||||
money: "",
|
||||
iconfont: 'icon-xianxiahuizong',
|
||||
name: 'x天账期',
|
||||
fonts: '可用额度 ',
|
||||
money: '',
|
||||
isCheck: false,
|
||||
color: '#ffffff'
|
||||
color: '#ffffff',
|
||||
},
|
||||
{
|
||||
iconfont: "icon-yue",
|
||||
name: "线下汇款",
|
||||
iconfont: 'icon-yue',
|
||||
name: '线下汇款',
|
||||
},
|
||||
{
|
||||
iconfont: "icon-saomiao",
|
||||
name: "扫码支付",
|
||||
color: '#ffffff'
|
||||
iconfont: 'icon-saomiao',
|
||||
name: '扫码支付',
|
||||
color: '#ffffff',
|
||||
},
|
||||
])
|
||||
const toPay = async (e, item) => {
|
||||
e.stopPropagation();
|
||||
const toPay = async(e, item) => {
|
||||
e.stopPropagation()
|
||||
|
||||
setItemObj(item)
|
||||
if (item.status !== 10) {
|
||||
let res = await infoOneFetch({ id: item.should_collect_order_id })
|
||||
const res = await infoOneFetch({ id: item.should_collect_order_id })
|
||||
payList.map((item) => {
|
||||
if (item.id === 3) {
|
||||
item.name = `${res.data.account_period}天账期`;
|
||||
item.name = `${res.data.account_period}天账期`
|
||||
item.fonts = `可用额度${formatPriceDiv(
|
||||
res.data.account_period_credit_available_line
|
||||
).toLocaleString()}`;
|
||||
res.data.account_period_credit_available_line,
|
||||
).toLocaleString()}`
|
||||
}
|
||||
if (item.id === 2) {
|
||||
item.fonts = `可用额度${formatPriceDiv(
|
||||
res.data.advance_deposit_balance
|
||||
).toLocaleString()}`;
|
||||
res.data.advance_deposit_balance,
|
||||
).toLocaleString()}`
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return item
|
||||
})
|
||||
setPayList([...payList])
|
||||
if (item.is_shipper_picks_up) {
|
||||
const obj = payList.filter((item) => {
|
||||
return item.id === 6;
|
||||
});
|
||||
console.log(obj, "456456");
|
||||
return item.id === 6
|
||||
})
|
||||
console.log(obj, '456456')
|
||||
if (obj.length === 0) {
|
||||
payList.unshift({
|
||||
id: 6,
|
||||
iconfont: "icon-xianxiahuizong",
|
||||
iconfont: 'icon-xianxiahuizong',
|
||||
color: '#ffffff',
|
||||
name: "货主自提",
|
||||
fonts: "",
|
||||
money: "",
|
||||
name: '货主自提',
|
||||
fonts: '',
|
||||
money: '',
|
||||
isCheck: false,
|
||||
});
|
||||
})
|
||||
setPayList([...payList])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let res = await infoTwoFetch({ id: item.pre_collect_order_id })
|
||||
const arr: any = [];
|
||||
}
|
||||
else {
|
||||
const res = await infoTwoFetch({ id: item.pre_collect_order_id })
|
||||
const arr: any = []
|
||||
arr.push(
|
||||
{
|
||||
id: 2,
|
||||
iconfont: "icon-yufukuan1",
|
||||
name: "预存款",
|
||||
iconfont: 'icon-yufukuan1',
|
||||
name: '预存款',
|
||||
fonts: `可用额度${formatPriceDiv(
|
||||
res.data.advance_deposit_balance
|
||||
res.data.advance_deposit_balance,
|
||||
).toLocaleString()}`,
|
||||
money: "",
|
||||
money: '',
|
||||
isCheck: false,
|
||||
},
|
||||
{
|
||||
iconfont: "icon-yue",
|
||||
name: "线下汇款",
|
||||
iconfont: 'icon-yue',
|
||||
name: '线下汇款',
|
||||
},
|
||||
{
|
||||
iconfont: "icon-saomiao",
|
||||
name: "扫码支付",
|
||||
color: '#ffffff'
|
||||
iconfont: 'icon-saomiao',
|
||||
name: '扫码支付',
|
||||
color: '#ffffff',
|
||||
},
|
||||
|
||||
);
|
||||
)
|
||||
if (item.is_shipper_picks_up) {
|
||||
const obj = arr.filter((item) => {
|
||||
return item.id === 6;
|
||||
});
|
||||
return item.id === 6
|
||||
})
|
||||
if (obj.length === 0) {
|
||||
arr.unshift({
|
||||
id: 6,
|
||||
iconfont: "icon-xianxiahuizong",
|
||||
name: "货主自提",
|
||||
iconfont: 'icon-xianxiahuizong',
|
||||
name: '货主自提',
|
||||
color: '#ffffff',
|
||||
fonts: "",
|
||||
money: "",
|
||||
fonts: '',
|
||||
money: '',
|
||||
isCheck: false,
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
setPayList([...arr])
|
||||
@@ -447,14 +446,15 @@ export default () => {
|
||||
setShowPay(true)
|
||||
}
|
||||
|
||||
//选择支付方式
|
||||
// 选择支付方式
|
||||
const clickItem = (item) => {
|
||||
if (item.name === '扫码支付') { handScanpay() }
|
||||
if (item.name === '线下汇款') { setShowOffine(true) }
|
||||
payList.map(it => {
|
||||
payList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
@@ -462,14 +462,13 @@ export default () => {
|
||||
setPayList([...payList])
|
||||
}
|
||||
|
||||
|
||||
//扫码支付
|
||||
// 扫码支付
|
||||
const [showSide, setShowSide] = useState(true)
|
||||
const [title, setTitle] = useState('')
|
||||
const [picUrl, setPicUrl] = useState('')
|
||||
const { fetchData: payFetch } = GetPayCode()
|
||||
const handScanpay = async () => {
|
||||
const list: any = [];
|
||||
const handScanpay = async() => {
|
||||
const list: any = []
|
||||
itemObj.product_list.forEach((item) => {
|
||||
item.product_colors.forEach((it) => {
|
||||
list.push({
|
||||
@@ -486,12 +485,12 @@ export default () => {
|
||||
: (it.estimate_amount / 100).toString(),
|
||||
length: (it.length / 100).toString(),
|
||||
weight_error: formatWeightDiv(it.weight_error).toString(),
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
list: list,
|
||||
title: "面料销售电子确认单",
|
||||
list,
|
||||
title: '面料销售电子确认单',
|
||||
show_qrcode: true,
|
||||
show_barcode: true,
|
||||
show_wait_pay_amount: true,
|
||||
@@ -529,7 +528,7 @@ export default () => {
|
||||
order_total_weight_error: (
|
||||
itemObj.total_weight_error / 1000
|
||||
).toString(),
|
||||
};
|
||||
}
|
||||
const res = await payFetch(query)
|
||||
if (res.data) {
|
||||
console.log(res.data.base64)
|
||||
@@ -539,67 +538,66 @@ export default () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//确认交易
|
||||
// 确认交易
|
||||
const { fetchData: payOneFetch } = orderPaymentorderPaymentSubmission()
|
||||
const { fetchData: payTwoFetch } = orderPaymentpreCollectOrderorderPaymentSubmission()
|
||||
const handsurePay = (obj) => {
|
||||
let arr: any = []
|
||||
// if (obj.status !== 10) {
|
||||
arr = payList.filter(item => {
|
||||
arr = payList.filter((item) => {
|
||||
return item.checked
|
||||
})
|
||||
if (!arr.length) {
|
||||
Taro.showToast({
|
||||
title: '请选择后再提交',
|
||||
icon: 'error'
|
||||
icon: 'error',
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
Taro.showModal({
|
||||
content: "确定交易吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
content: '确定交易吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
mask: true,
|
||||
})
|
||||
const restult = await (obj.status !== 10 ? payOneFetch({ id: Number(obj.should_collect_order_id), payment_method: Number(arr[0]?.id) }) : payTwoFetch({ id: Number(obj.pre_collect_order_id), payment_method: Number(arr[0]?.id) }))
|
||||
if (restult?.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '交易成功'
|
||||
title: '交易成功',
|
||||
})
|
||||
Taro.hideLoading()
|
||||
setShowPay(false)
|
||||
getOrderList()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: restult?.msg,
|
||||
icon: 'error'
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
//显示支付
|
||||
// 显示支付
|
||||
const [showPay, setShowPay] = useState(false)
|
||||
|
||||
//显示线下汇款
|
||||
// 显示线下汇款
|
||||
const [showOffline, setShowOffine] = useState(false)
|
||||
return (
|
||||
<View>
|
||||
<View style={{ background: '#FFFFFF', paddingLeft: '20rpx', paddingBottom: '20rpx', position: 'sticky', top: '0', zIndex: '99' }}>
|
||||
<Search handScan={() => handScan()} defaultValue={searchField.order_no} showScan placeholder='搜索商品/名称/颜色/订单号' showBtn={false} changeOnSearch={getSearchData} debounceTime={300}>
|
||||
<Search handScan={() => handScan()} defaultValue={searchField.order_no} showScan placeholder="搜索商品/名称/颜色/订单号" showBtn={false} changeOnSearch={getSearchData} debounceTime={300}>
|
||||
<View className={styles.flexBox} onClick={() => showSelctPopup()}>
|
||||
<IconFont name='icon-shaixuan' size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles['activeshaixuan']} />
|
||||
<IconFont name="icon-shaixuan" size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles.activeshaixuan} />
|
||||
{/* <View className={classnames('iconfont', 'icon-shaixuan', !isDisabled ? styles.icon_shaixuan : styles.activeshaixuan)}></View> */}
|
||||
<View className={classnames(isDisabled ? styles.shaixuan : styles.activeshai)}>筛选</View>
|
||||
</View>
|
||||
@@ -612,9 +610,10 @@ export default () => {
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<View key={item.id} className={styles.order_item_con}>
|
||||
@@ -623,14 +622,15 @@ export default () => {
|
||||
key={index}
|
||||
cancle={(e, item) => cancle(e, item)}
|
||||
nextBuy={(e, item) => nextBuy(e, item)}
|
||||
toPay={(e, item) => toPay(e, item)}></ItemList>
|
||||
toPay={(e, item) => toPay(e, item)}
|
||||
></ItemList>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
{/* <View className={styles.kongboxTwo}></View> */}
|
||||
</View>
|
||||
<Popup title={'筛选订单'} show={showPopup} onClose={() => closePopup()}>
|
||||
<Popup title="筛选订单" show={showPopup} onClose={() => closePopup()}>
|
||||
<View className={styles.popupBox}>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.leftTop} onClick={() => navTo(1)}>
|
||||
@@ -658,7 +658,8 @@ export default () => {
|
||||
handCheckMode(item)
|
||||
}}
|
||||
className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)}
|
||||
key={index}>
|
||||
key={index}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
)
|
||||
@@ -675,7 +676,8 @@ export default () => {
|
||||
handCheckDelivery(item)
|
||||
}}
|
||||
className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)}
|
||||
key={index}>
|
||||
key={index}
|
||||
>
|
||||
{item.name}
|
||||
</View>
|
||||
)
|
||||
@@ -690,7 +692,8 @@ export default () => {
|
||||
className={styles.resetBox}
|
||||
onClick={() => {
|
||||
handReset()
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
{' '}
|
||||
重置
|
||||
</Button>
|
||||
@@ -699,7 +702,8 @@ export default () => {
|
||||
disabled={isDisabled}
|
||||
onClick={() => {
|
||||
handSure?.()
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
{' '}
|
||||
确认
|
||||
</Button>
|
||||
@@ -712,11 +716,12 @@ export default () => {
|
||||
obj={itemObj}
|
||||
showPopup={showPay}
|
||||
popupClose={() => setShowPay(false)}
|
||||
clickItem={(item) => clickItem(item)}
|
||||
handsurePay={(obj) => handsurePay(obj)}
|
||||
clickItem={item => clickItem(item)}
|
||||
handsurePay={obj => handsurePay(obj)}
|
||||
showSide={showSide}
|
||||
title={title}
|
||||
picUrl={picUrl}></PayPopup>
|
||||
picUrl={picUrl}
|
||||
></PayPopup>
|
||||
<OfflinePay show={showOffline} onClose={() => setShowOffine(false)} offlineInfo={itemObj}></OfflinePay>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
import { View } from "@tarojs/components"
|
||||
import { memo, useEffect, useState, useMemo } from "react"
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import { View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface prosObj {
|
||||
obj?: {
|
||||
sale_mode?: Number,
|
||||
collect_status?: Number | string,
|
||||
status?: Number,
|
||||
payment_method?: Number,
|
||||
settle_mode?: Number | string,
|
||||
}
|
||||
handApplyGoods?: () => void,
|
||||
handApplyMoney?: () => void,
|
||||
goodsObj?: any
|
||||
// handSureGoods?: () => void,
|
||||
obj?: {
|
||||
sale_mode?: Number
|
||||
collect_status?: Number | string
|
||||
status?: Number
|
||||
payment_method?: Number
|
||||
settle_mode?: Number | string
|
||||
}
|
||||
handApplyGoods?: () => void
|
||||
handApplyMoney?: () => void
|
||||
goodsObj?: any
|
||||
// handSureGoods?: () => void,
|
||||
}
|
||||
|
||||
export default memo((props: prosObj) => {
|
||||
const {
|
||||
obj = {
|
||||
sale_mode: 0,
|
||||
collect_status: '',
|
||||
status: '',
|
||||
payment_method: 0,
|
||||
settle_mode: ''
|
||||
},
|
||||
handApplyGoods,
|
||||
handApplyMoney,
|
||||
goodsObj = {}
|
||||
// handSureGoods
|
||||
} = props
|
||||
const {
|
||||
obj = {
|
||||
sale_mode: 0,
|
||||
collect_status: '',
|
||||
status: '',
|
||||
payment_method: 0,
|
||||
settle_mode: '',
|
||||
},
|
||||
handApplyGoods,
|
||||
handApplyMoney,
|
||||
goodsObj = {},
|
||||
// handSureGoods
|
||||
} = props
|
||||
|
||||
//判断显示申请退货
|
||||
const showTuihuo = useMemo(() => {
|
||||
if (
|
||||
(obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 0 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 1 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 2 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 9 && obj.settle_mode == 3 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 2 && obj.status == 9 && goodsObj?.av_return_product?.length)
|
||||
) {
|
||||
return true
|
||||
} else return false
|
||||
}, [obj])
|
||||
//判断显示申请退款
|
||||
const showTuikuan = useMemo(() => {
|
||||
if (
|
||||
(obj.sale_mode === 0 && obj.status == 2 && obj.collect_status == 1 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 2 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 3 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 11 && (obj.collect_status == 1 || obj.collect_status == 2) && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 2 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 1 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 1 && obj.status == 0 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 1 && obj.status == 9 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 1 && goodsObj?.av_return_product?.length) ||
|
||||
(obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|
||||
) {
|
||||
return true
|
||||
} else return false
|
||||
}, [obj])
|
||||
// 判断显示申请退货
|
||||
const showTuihuo = useMemo(() => {
|
||||
if (
|
||||
(obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 0 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 9 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 9 && obj.settle_mode == 3 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 2 && obj.status == 9 && goodsObj?.av_return_product?.length)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
else { return false }
|
||||
}, [obj])
|
||||
// 判断显示申请退款
|
||||
const showTuikuan = useMemo(() => {
|
||||
if (
|
||||
(obj.sale_mode === 0 && obj.status == 2 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 7 && obj.collect_status == 3 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 11 && (obj.collect_status == 1 || obj.collect_status == 2) && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 0 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 0 && obj.status == 3 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 1 && obj.status == 0 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 1 && obj.status == 9 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 1 && goodsObj?.av_return_product?.length)
|
||||
|| (obj.sale_mode === 2 && obj.status == 0 && obj.collect_status == 2 && goodsObj?.av_return_product?.length)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
else { return false }
|
||||
}, [obj])
|
||||
|
||||
return (
|
||||
< >
|
||||
|
||||
{
|
||||
showTuihuo && <View className={styles.title} onClick={() => handApplyGoods?.()}>申请退货</View>
|
||||
}
|
||||
|
||||
return (
|
||||
< >
|
||||
{
|
||||
showTuikuan && <View className={styles.tuikuan} onClick={() => handApplyMoney?.()}>申请退款</View>
|
||||
|
||||
|
||||
{
|
||||
showTuihuo && <View className={styles.title} onClick={() => handApplyGoods?.()}>申请退货</View>
|
||||
}
|
||||
|
||||
{
|
||||
showTuikuan && <View className={styles.tuikuan} onClick={() => handApplyMoney?.()}>申请退款</View>
|
||||
|
||||
}
|
||||
{/*
|
||||
}
|
||||
{/*
|
||||
{
|
||||
showTake && <View className={styles.tuikuan} onClick={() => handSureGoods?.()}>确认收货</View>
|
||||
} */}
|
||||
|
||||
{
|
||||
!showTuihuo && !showTuikuan && <View className={styles.title} >暂无更多</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
{
|
||||
!showTuihuo && !showTuikuan && <View className={styles.title} >暂无更多</View>
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,66 +1,64 @@
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { alert } from '@/common/common'
|
||||
|
||||
interface propsObj {
|
||||
receivingStatus: Number | null,
|
||||
onReceivingStatus?: (any, Number) => void,
|
||||
obj?: any,
|
||||
navSelect?: (any) => void
|
||||
receivingStatus: Number | null
|
||||
onReceivingStatus?: (any, Number) => void
|
||||
obj?: any
|
||||
navSelect?: (any) => void
|
||||
}
|
||||
export default memo((props: propsObj) => {
|
||||
const {
|
||||
receivingStatus = null,
|
||||
onReceivingStatus,
|
||||
obj = {},
|
||||
navSelect,
|
||||
} = props
|
||||
|
||||
const {
|
||||
receivingStatus = null,
|
||||
onReceivingStatus,
|
||||
obj = {},
|
||||
navSelect
|
||||
} = props
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topBox} onClick={() => navSelect?.(obj)}>
|
||||
<View className={styles.cirle}>
|
||||
<IconFont name={'icon-dingwei'} size={26} color={'#ffffff'}></IconFont>
|
||||
</View>
|
||||
{
|
||||
receivingStatus == 1 && <View className={styles.address}>{obj.take_goods_address || '中华人民共和国广东省佛山市禅城区陆盈纺织仓库'}</View>
|
||||
}
|
||||
{
|
||||
(obj?.province_name != '' && receivingStatus == 2) &&
|
||||
<View className={styles.address}>{obj?.province_name}{obj?.city_name}{obj?.district_name}{obj?.address_detail}</View>
|
||||
}
|
||||
{
|
||||
(obj?.province_name == '' && receivingStatus == 2) &&
|
||||
<View className={styles.address}>{''}</View>
|
||||
}
|
||||
{
|
||||
receivingStatus !== 1 &&
|
||||
<IconFont name={'icon-chakanquanbukehu'} size={50} ></IconFont>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.name}>{receivingStatus === 1 ? '谭先生' : obj.target_user_name}</View>
|
||||
<View className={styles.phone}>{receivingStatus === 1 ? 13242128982 : obj.purchaser_phone}</View>
|
||||
<View className={styles.reatBox}>
|
||||
<View className={styles.updateBtn}>
|
||||
<View className={styles.updateBtn_list}>
|
||||
<View className={classnames(styles.updateBtn_item, receivingStatus == 1 && styles.updateBtn_item_select)} onClick={(e) => onReceivingStatus?.(e, 1)}>
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topBox} onClick={() => navSelect?.(obj)}>
|
||||
<View className={styles.cirle}>
|
||||
<IconFont name="icon-dingwei" size={26} color="#ffffff"></IconFont>
|
||||
</View>
|
||||
{
|
||||
receivingStatus == 1 && <View className={styles.address}>{obj.take_goods_address || '中华人民共和国广东省佛山市禅城区陆盈纺织仓库'}</View>
|
||||
}
|
||||
{
|
||||
(obj?.province_name != '' && receivingStatus == 2)
|
||||
&& <View className={styles.address}>{obj?.province_name}{obj?.city_name}{obj?.district_name}{obj?.address_detail}</View>
|
||||
}
|
||||
{
|
||||
(obj?.province_name == '' && receivingStatus == 2)
|
||||
&& <View className={styles.address}></View>
|
||||
}
|
||||
{
|
||||
receivingStatus !== 1
|
||||
&& <IconFont name="icon-chakanquanbukehu" size={50} ></IconFont>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.name}>{receivingStatus === 1 ? '谭先生' : obj.target_user_name}</View>
|
||||
<View className={styles.phone}>{receivingStatus === 1 ? 13242128982 : obj.purchaser_phone}</View>
|
||||
<View className={styles.reatBox}>
|
||||
<View className={styles.updateBtn}>
|
||||
<View className={styles.updateBtn_list}>
|
||||
<View className={classnames(styles.updateBtn_item, receivingStatus == 1 && styles.updateBtn_item_select)} onClick={e => onReceivingStatus?.(e, 1)}>
|
||||
自提
|
||||
</View>
|
||||
<View className={classnames(styles.updateBtn_item, receivingStatus == 2 && styles.updateBtn_item_select)} onClick={(e) => onReceivingStatus?.(e, 2)}>
|
||||
</View>
|
||||
<View className={classnames(styles.updateBtn_item, receivingStatus == 2 && styles.updateBtn_item_select)} onClick={e => onReceivingStatus?.(e, 2)}>
|
||||
物流
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ transform: receivingStatus == 1 ? 'translateX(0)' : 'translateX(100%)' }} className={classnames(styles.updateBtn_select)}></View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
<View style={{ transform: receivingStatus == 1 ? 'translateX(0)' : 'translateX(100%)' }} className={classnames(styles.updateBtn_select)}></View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,74 +1,71 @@
|
||||
import { formatImgUrl } from "@/common/format";
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import dayjs from "dayjs";
|
||||
import { useTimeCountDown } from "@/use/useCommon";
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from "@/common/enum";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import { formatImgUrl } from '@/common/format'
|
||||
import { useTimeCountDown } from '@/use/useCommon'
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from '@/common/enum'
|
||||
|
||||
type List = {
|
||||
status: string,
|
||||
time: string,
|
||||
tag: string,
|
||||
desc: string,
|
||||
expire_time: string
|
||||
interface List {
|
||||
status: string
|
||||
time: string
|
||||
tag: string
|
||||
desc: string
|
||||
expire_time: string
|
||||
}
|
||||
|
||||
type Param = {
|
||||
onRefresh?: () => void,
|
||||
orderInfo?: {
|
||||
logistics_details:List[], //订单状态列表
|
||||
payment_method: number, //支付方式
|
||||
status: number, //订单状态
|
||||
interface Param {
|
||||
onRefresh?: () => void
|
||||
orderInfo?: {
|
||||
logistics_details: List[] // 订单状态列表
|
||||
payment_method: number // 支付方式
|
||||
status: number // 订单状态
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo, onRefresh }: Param) => {
|
||||
const { showTime, onStart, timeStatus } = useTimeCountDown()
|
||||
|
||||
// 订单状态枚举
|
||||
const { SaleorderstatusWaitingPrePayment } = ORDER_STATUS
|
||||
|
||||
// 获取预付款最后时间
|
||||
const endTime = useMemo(() => {
|
||||
if (orderInfo?.status == SaleorderstatusWaitingPrePayment.value && orderInfo.logistics_details.length > 0) {
|
||||
return orderInfo.logistics_details[0].expire_time
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}, [orderInfo])
|
||||
|
||||
useEffect(() => {
|
||||
if (endTime) { onStart(endTime) }
|
||||
}, [endTime])
|
||||
|
||||
export default memo(({orderInfo, onRefresh}:Param) => {
|
||||
useEffect(() => {
|
||||
if (timeStatus == 2) { onRefresh?.() }
|
||||
}, [timeStatus])
|
||||
|
||||
const {showTime, onStart, timeStatus} = useTimeCountDown()
|
||||
|
||||
//订单状态枚举
|
||||
const {SaleorderstatusWaitingPrePayment} = ORDER_STATUS
|
||||
|
||||
//获取预付款最后时间
|
||||
const endTime = useMemo(() => {
|
||||
if(orderInfo?.status == SaleorderstatusWaitingPrePayment.value && orderInfo.logistics_details.length > 0) {
|
||||
return orderInfo.logistics_details[0].expire_time
|
||||
}
|
||||
return ''
|
||||
}, [orderInfo])
|
||||
|
||||
useEffect(() => {
|
||||
if(endTime) onStart(endTime)
|
||||
}, [endTime])
|
||||
|
||||
useEffect(() => {
|
||||
if(timeStatus == 2) onRefresh?.()
|
||||
}, [timeStatus])
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.advance_main}>
|
||||
<View className={styles.time_con}>
|
||||
<View className={styles.times}>
|
||||
<Text className={styles.text}>剩</Text>
|
||||
<Text className={styles.num}>{showTime.HH}</Text>
|
||||
<Text className={styles.separate}>:</Text>
|
||||
<Text className={styles.num}>{showTime.MM}</Text>
|
||||
<Text className={styles.separate}>:</Text>
|
||||
<Text className={styles.num}>{showTime.SS}</Text>
|
||||
</View>
|
||||
<Text>等待买家付款,超时自动取消</Text>
|
||||
</View>
|
||||
<View className={styles.cardIcon}>
|
||||
<Image className={styles.image} src={formatImgUrl("/mall/my_cart.png")}/>
|
||||
</View>
|
||||
<View className={styles.refresh} onClick={() => onRefresh?.()}>
|
||||
<Text className={classnames(styles.mconfont, 'iconfont icon-shuaxin')}></Text>
|
||||
<Text className={classnames(styles.refresh_text)}>刷新</Text>
|
||||
</View>
|
||||
return (
|
||||
<View className={styles.advance_main}>
|
||||
<View className={styles.time_con}>
|
||||
<View className={styles.times}>
|
||||
<Text className={styles.text}>剩</Text>
|
||||
<Text className={styles.num}>{showTime.HH}</Text>
|
||||
<Text className={styles.separate}>:</Text>
|
||||
<Text className={styles.num}>{showTime.MM}</Text>
|
||||
<Text className={styles.separate}>:</Text>
|
||||
<Text className={styles.num}>{showTime.SS}</Text>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
<Text>等待买家付款,超时自动取消</Text>
|
||||
</View>
|
||||
<View className={styles.cardIcon}>
|
||||
<Image className={styles.image} src={formatImgUrl('/mall/my_cart.png')} />
|
||||
</View>
|
||||
<View className={styles.refresh} onClick={() => onRefresh?.()}>
|
||||
<Text className={classnames(styles.mconfont, 'iconfont icon-shuaxin')}></Text>
|
||||
<Text className={classnames(styles.refresh_text)}>刷新</Text>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
import { Image, Text, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { formatDateTime, formatImgUrl } from "@/common/format";
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from "@/common/enum";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import * as dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import { formatDateTime, formatImgUrl } from '@/common/format'
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from '@/common/enum'
|
||||
|
||||
type List = {
|
||||
status: string,
|
||||
time: string,
|
||||
tag: string,
|
||||
desc: string,
|
||||
expire_time: string
|
||||
interface List {
|
||||
status: string
|
||||
time: string
|
||||
tag: string
|
||||
desc: string
|
||||
expire_time: string
|
||||
}
|
||||
|
||||
type Param = {
|
||||
onRefresh?: () => void,
|
||||
orderInfo?: {
|
||||
logistics_details:List[], //订单状态列表
|
||||
payment_method: number, //支付方式
|
||||
status: number, //订单状态
|
||||
account_period?: number, //账期
|
||||
account_period_time?: string //还款日期
|
||||
}
|
||||
interface Param {
|
||||
onRefresh?: () => void
|
||||
orderInfo?: {
|
||||
logistics_details: List[] // 订单状态列表
|
||||
payment_method: number // 支付方式
|
||||
status: number // 订单状态
|
||||
account_period?: number // 账期
|
||||
account_period_time?: string // 还款日期
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({orderInfo = {logistics_details: [],payment_method: 0, status: 0}, onRefresh}:Param) => {
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::',orderInfo)
|
||||
}, [orderInfo])
|
||||
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
return orderInfo.logistics_details?orderInfo?.logistics_details.reverse():[]
|
||||
}, [orderInfo.logistics_details])
|
||||
export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
|
||||
//订单状态枚举
|
||||
const {SaleorderstatusWaitingPrePayment} = ORDER_STATUS
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
return orderInfo.logistics_details ? orderInfo?.logistics_details.reverse() : []
|
||||
}, [orderInfo.logistics_details])
|
||||
|
||||
//支付方式枚举
|
||||
const {
|
||||
PaymentMethodAccountPeriod,
|
||||
PaymentMethodCashOnDelivery,
|
||||
} = PAYMENT_METHOD
|
||||
// 订单状态枚举
|
||||
const { SaleorderstatusWaitingPrePayment } = ORDER_STATUS
|
||||
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0)&&<View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore&&styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1)&&<View className={classnames(styles.order_status_tail, (index == 0)&&styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1))&&<View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0)&&styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0)&&styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0)&&styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore&&'收起详情'||'点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore&&styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
<View className={styles.image_tag}>
|
||||
{(orderInfo.payment_method == PaymentMethodCashOnDelivery.value)&&<Image mode="aspectFit" src={formatImgUrl('/mall/order_pay_status.png')} className={styles.image}/>}
|
||||
{(orderInfo.payment_method == PaymentMethodAccountPeriod.value)&&<Image mode="aspectFit" src={formatImgUrl('/mall/order_pay_status_day.png')} className={styles.image}/>}
|
||||
</View>
|
||||
</View>}
|
||||
{(orderInfo.payment_method == PaymentMethodAccountPeriod.value)&&<View className={styles.pay_title_tag}>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhuyi')}></Text>
|
||||
// 支付方式枚举
|
||||
const {
|
||||
PaymentMethodAccountPeriod,
|
||||
PaymentMethodCashOnDelivery,
|
||||
} = PAYMENT_METHOD
|
||||
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0) && styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0) && styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0) && styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
<View className={styles.image_tag}>
|
||||
{(orderInfo.payment_method == PaymentMethodCashOnDelivery.value) && <Image mode="aspectFit" src={formatImgUrl('/mall/order_pay_status.png')} className={styles.image} />}
|
||||
{(orderInfo.payment_method == PaymentMethodAccountPeriod.value) && <Image mode="aspectFit" src={formatImgUrl('/mall/order_pay_status_day.png')} className={styles.image} />}
|
||||
</View>
|
||||
</View>}
|
||||
{(orderInfo.payment_method == PaymentMethodAccountPeriod.value) && <View className={styles.pay_title_tag}>
|
||||
<Text className={classnames(styles.miconfont, 'iconfont icon-zhuyi')}></Text>
|
||||
您使用了{orderInfo.account_period}天账期支付,还款日期为{formatDateTime(orderInfo.account_period_time)}
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
import Popup from "@/components/popup"
|
||||
import { Textarea, View } from "@tarojs/components"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { Textarea, View } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
|
||||
type Param = {
|
||||
onBlur?: (val: any) => void
|
||||
onSave?: (val: string) => void
|
||||
defaultValue?: string,
|
||||
showInput: boolean
|
||||
interface Param {
|
||||
onBlur?: (val: any) => void
|
||||
onSave?: (val: string) => void
|
||||
defaultValue?: string
|
||||
showInput: boolean
|
||||
}
|
||||
export default ({ onBlur, onSave, defaultValue = '', showInput = false }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
})
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const getDesc = (value) => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
const getDesc = (value) => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
}
|
||||
|
||||
const setSave = () => {
|
||||
onSave?.(descData.value)
|
||||
}
|
||||
return (
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>编辑备注</View>
|
||||
{
|
||||
showInput && <View className={styles.order_popup_input}>
|
||||
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={(e) => getDesc(e.detail.value)} onBlur={(e) => onBlur?.(e)}></Textarea>
|
||||
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
|
||||
</View>
|
||||
}
|
||||
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
const setSave = () => {
|
||||
onSave?.(descData.value)
|
||||
}
|
||||
return (
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>编辑备注</View>
|
||||
{
|
||||
showInput && <View className={styles.order_popup_input}>
|
||||
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={e => getDesc(e.detail.value)} onBlur={e => onBlur?.(e)}></Textarea>
|
||||
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
navigationBarTitleText: '订单详情',
|
||||
enablePullDownRefresh: true,
|
||||
"backgroundTextStyle": "dark"
|
||||
navigationBarTitleText: '订单详情',
|
||||
enablePullDownRefresh: true,
|
||||
backgroundTextStyle: 'dark',
|
||||
}
|
||||
|
||||
+796
-793
File diff suppressed because it is too large
Load Diff
@@ -1,48 +1,49 @@
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
|
||||
interface propsObj {
|
||||
receivingStatus?: Number | null,
|
||||
onReceivingStatus?: (any, Number) => void,
|
||||
obj: any,
|
||||
handUp?: (any) => void
|
||||
receivingStatus?: Number | null
|
||||
onReceivingStatus?: (any, Number) => void
|
||||
obj: any
|
||||
handUp?: (any) => void
|
||||
}
|
||||
export default memo((props: propsObj) => {
|
||||
const {
|
||||
obj = {},
|
||||
handUp,
|
||||
} = props
|
||||
|
||||
const {
|
||||
obj = {},
|
||||
handUp
|
||||
} = props
|
||||
const seeFont = useMemo(() => {
|
||||
if (obj.stage == 1) {
|
||||
return '上传物流回单'
|
||||
}
|
||||
else {
|
||||
return '查看物流回单'
|
||||
}
|
||||
}, [obj])
|
||||
|
||||
const seeFont = useMemo(() => {
|
||||
if (obj.stage == 1) {
|
||||
return '上传物流回单'
|
||||
} else {
|
||||
return '查看物流回单'
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topFont}>请按以下退货地址寄回货物并提供退货物流信息</View>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.cirle}>
|
||||
<IconFont name="icon-dingwei" size={26} color="#ffffff"></IconFont>
|
||||
</View>
|
||||
<View className={styles.address}>广东省佛山市禅城区陆盈纺织仓库</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.leftBottom}>
|
||||
<View className={styles.name}>谭先生</View>
|
||||
<View className={styles.phone}>{13242128982}</View>
|
||||
</View>
|
||||
{
|
||||
obj.stage != 0 && <View className={styles.btn} onClick={() => handUp?.(obj)}>{seeFont}</View>
|
||||
}
|
||||
}, [obj])
|
||||
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topFont}>请按以下退货地址寄回货物并提供退货物流信息</View>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.cirle}>
|
||||
<IconFont name={'icon-dingwei'} size={26} color={'#ffffff'}></IconFont>
|
||||
</View>
|
||||
<View className={styles.address}>{'广东省佛山市禅城区陆盈纺织仓库'}</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.leftBottom}>
|
||||
<View className={styles.name}>{'谭先生'}</View>
|
||||
<View className={styles.phone}>{13242128982}</View>
|
||||
</View>
|
||||
{
|
||||
obj.stage != 0 && <View className={styles.btn} onClick={() => handUp?.(obj)}>{seeFont}</View>
|
||||
}
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,70 +1,68 @@
|
||||
import { Image, Text, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { formatDateTime, formatImgUrl } from "@/common/format";
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from "@/common/enum";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import * as dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import { formatDateTime, formatImgUrl } from '@/common/format'
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from '@/common/enum'
|
||||
|
||||
type List = {
|
||||
status: string,
|
||||
time: string,
|
||||
tag: string,
|
||||
desc: string,
|
||||
expire_time: string
|
||||
interface List {
|
||||
status: string
|
||||
time: string
|
||||
tag: string
|
||||
desc: string
|
||||
expire_time: string
|
||||
}
|
||||
|
||||
type Param = {
|
||||
onRefresh?: () => void,
|
||||
orderInfo?: {
|
||||
logistics_details: List[], //订单状态列表
|
||||
payment_method: number, //支付方式
|
||||
status: number, //订单状态
|
||||
account_period?: number, //账期
|
||||
account_period_time?: string //还款日期
|
||||
}
|
||||
interface Param {
|
||||
onRefresh?: () => void
|
||||
orderInfo?: {
|
||||
logistics_details: List[] // 订单状态列表
|
||||
payment_method: number // 支付方式
|
||||
status: number // 订单状态
|
||||
account_period?: number // 账期
|
||||
account_period_time?: string // 还款日期
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
const arr = orderInfo?.logistics_details
|
||||
if (orderInfo.logistics_details) {
|
||||
return arr.reverse()
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
let arr = orderInfo?.logistics_details
|
||||
if (orderInfo.logistics_details) {
|
||||
return arr.reverse()
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, [orderInfo.logistics_details])
|
||||
else {
|
||||
return []
|
||||
}
|
||||
}, [orderInfo.logistics_details])
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0) && styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0) && styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0) && styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0) && styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0) && styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0) && styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
navigationBarTitleText: '售后详情',
|
||||
enablePullDownRefresh: true,
|
||||
"backgroundTextStyle": "dark"
|
||||
navigationBarTitleText: '售后详情',
|
||||
enablePullDownRefresh: true,
|
||||
backgroundTextStyle: 'dark',
|
||||
}
|
||||
|
||||
+400
-402
@@ -1,439 +1,437 @@
|
||||
import { View, Input, Button, Image } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, ReactNode, memo } from 'react'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Taro, { faceVerifyForPay, useDidShow, useRouter, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { Button, Image, Input, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/itemList'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpreturnApplyOrder,
|
||||
returnApplyOrdercancel,
|
||||
returnApplyOrderuploadAccessory
|
||||
} from "@/api/refound"
|
||||
import OrderState from './components/orderState'
|
||||
import AddressDetailBox from './components/addressDetailBox'
|
||||
import { IMG_CND_Prefix } from "@/common/constant";
|
||||
import Popup from '@/components/popup';
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpreturnApplyOrder,
|
||||
returnApplyOrdercancel,
|
||||
returnApplyOrderuploadAccessory,
|
||||
} from '@/api/refound'
|
||||
import { IMG_CND_Prefix } from '@/common/constant'
|
||||
import Popup from '@/components/popup'
|
||||
import UploadImage from '@/components/uploadImage'
|
||||
import { alert } from '@/common/common';
|
||||
import RefundCodelist from "@/components/RefundCodelist"
|
||||
import LabAndImg from "@/components/LabAndImg"
|
||||
import { alert } from '@/common/common'
|
||||
import RefundCodelist from '@/components/RefundCodelist'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
export default () => {
|
||||
//页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getDetail()
|
||||
// 页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getDetail()
|
||||
})
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
// 获取详情
|
||||
const { fetchData: detailFetch } = mpreturnApplyOrder()
|
||||
const [DeatailObj, setDeatailObj] = useState<any>({})
|
||||
const getDetail = async() => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
//获取详情
|
||||
const { fetchData: detailFetch } = mpreturnApplyOrder()
|
||||
const [DeatailObj, setDeatailObj] = useState<any>({})
|
||||
const getDetail = async () => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
const res = await detailFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
setDeatailObj(res.data)
|
||||
orderMsg.map((it) => {
|
||||
if (it.leftTitle === '售后编号:') {
|
||||
it.rightTitle = res.data.return_order_no
|
||||
}
|
||||
if (it.leftTitle === '订单号:') {
|
||||
it.rightTitle = res.data.order_no
|
||||
}
|
||||
if (it.leftTitle === '退货原因:') {
|
||||
it.rightTitle = res.data.return_reason_name
|
||||
}
|
||||
if (it.leftTitle === '退货说明:') {
|
||||
it.rightTitle = res.data.return_explain_name
|
||||
}
|
||||
if (it.leftTitle === '其他说明:') {
|
||||
it.rightTitle = res.data.reason_describe
|
||||
}
|
||||
if (it.leftTitle === '货物状况:') {
|
||||
it.rightTitle = res.data.goods_status_name
|
||||
}
|
||||
if (it.leftTitle === '申请时间:') {
|
||||
it.rightTitle = formatDateTime(res.data.apply_time)
|
||||
}
|
||||
})
|
||||
setOrderMsg([...orderMsg])
|
||||
setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []])
|
||||
Taro.hideLoading()
|
||||
// 小程序提供的api,通知页面停止下拉刷新效果
|
||||
Taro.stopPullDownRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
// 分辨用质检中还是质检前的数组
|
||||
const productList = useMemo(() => {
|
||||
if (DeatailObj.stage === 0
|
||||
|| (DeatailObj.sale_mode == 1 && DeatailObj.type == 1) || DeatailObj.stage === 1 || DeatailObj.stage === 2) {
|
||||
return DeatailObj.product_list
|
||||
}
|
||||
else {
|
||||
return DeatailObj.quality_check_pass_product
|
||||
}
|
||||
}, [DeatailObj])
|
||||
|
||||
// 订单信息文字数组
|
||||
const [orderMsg, setOrderMsg] = useState<any[]>([
|
||||
{
|
||||
leftTitle: '售后编号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true,
|
||||
},
|
||||
{
|
||||
leftTitle: '订单号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true,
|
||||
},
|
||||
{
|
||||
leftTitle: '退货原因:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '退货说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '其他说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '货物状况:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '申请时间:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
])
|
||||
|
||||
// 复制功能
|
||||
const clipboardData = (val) => {
|
||||
Taro.setClipboardData({
|
||||
data: val || '',
|
||||
success(res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
const res = await detailFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
setDeatailObj(res.data)
|
||||
orderMsg.map(it => {
|
||||
if (it.leftTitle === '售后编号:') {
|
||||
it.rightTitle = res.data.return_order_no
|
||||
}
|
||||
if (it.leftTitle === '订单号:') {
|
||||
it.rightTitle = res.data.order_no
|
||||
}
|
||||
if (it.leftTitle === '退货原因:') {
|
||||
it.rightTitle = res.data.return_reason_name
|
||||
}
|
||||
if (it.leftTitle === '退货说明:') {
|
||||
it.rightTitle = res.data.return_explain_name
|
||||
}
|
||||
if (it.leftTitle === '其他说明:') {
|
||||
it.rightTitle = res.data.reason_describe
|
||||
}
|
||||
if (it.leftTitle === '货物状况:') {
|
||||
it.rightTitle = res.data.goods_status_name
|
||||
}
|
||||
if (it.leftTitle === '申请时间:') {
|
||||
it.rightTitle = formatDateTime(res.data.apply_time)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 取消退货
|
||||
const { fetchData: cancelFetch } = returnApplyOrdercancel()
|
||||
const handCancle = async() => {
|
||||
Taro.showModal({
|
||||
content: '确定要取消吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetch({ id: Number(DeatailObj.id) })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '取消成功',
|
||||
})
|
||||
setOrderMsg([...orderMsg])
|
||||
setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []])
|
||||
Taro.hideLoading()
|
||||
// 小程序提供的api,通知页面停止下拉刷新效果
|
||||
Taro.stopPullDownRefresh();
|
||||
getDetail()
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
// 查看图片
|
||||
const [ShowPic, setShowPic] = useState(false)
|
||||
|
||||
//分辨用质检中还是质检前的数组
|
||||
const productList = useMemo(() => {
|
||||
if (DeatailObj.stage === 0 ||
|
||||
(DeatailObj.sale_mode == 1 && DeatailObj.type == 1) || DeatailObj.stage === 1 || DeatailObj.stage === 2) {
|
||||
return DeatailObj.product_list
|
||||
} else {
|
||||
return DeatailObj.quality_check_pass_product
|
||||
const [PicList, setPicList] = useState<any[]>([])
|
||||
|
||||
const handUp = (value) => {
|
||||
setShowPic(true)
|
||||
}
|
||||
|
||||
const onlyRead = useMemo(() => {
|
||||
if (DeatailObj.stage == 1) {
|
||||
return false
|
||||
}
|
||||
else {
|
||||
return true
|
||||
}
|
||||
}, [DeatailObj])
|
||||
|
||||
// 获取图片列表
|
||||
const picUrl = useRef([])
|
||||
const getImageList = useCallback((list) => {
|
||||
picUrl.current = list
|
||||
}, [])
|
||||
|
||||
// 提交附件
|
||||
const { fetchData: sureFetch } = returnApplyOrderuploadAccessory()
|
||||
const handSure = () => {
|
||||
let arr: any = []
|
||||
arr = [...picUrl.current]
|
||||
if (arr == 0) {
|
||||
return alert.error('请先添加附件')
|
||||
}
|
||||
Taro.showModal({
|
||||
content: '确定要提交吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await sureFetch({ id: Number(DeatailObj.id), accessory_url: arr })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
})
|
||||
setShowPic(false)
|
||||
Taro.hideLoading()
|
||||
getDetail()
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [DeatailObj])
|
||||
},
|
||||
})
|
||||
}
|
||||
const proview = (item) => {
|
||||
Taro.previewImage({
|
||||
current: IMG_CND_Prefix + item, // 当前显示图片的 http 链接
|
||||
urls: DeatailObj.fabric_piece_accessory_url.map((item) => {
|
||||
item = IMG_CND_Prefix + item
|
||||
return item
|
||||
}), // 需要预览的图片 http 链接列表
|
||||
})
|
||||
}
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const handSee = () => {
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
|
||||
//订单信息文字数组
|
||||
const [orderMsg, setOrderMsg] = useState<any[]>([
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<OrderState orderInfo={DeatailObj} />
|
||||
<AddressDetailBox
|
||||
obj={DeatailObj}
|
||||
handUp={() => handUp(DeatailObj)}
|
||||
></AddressDetailBox>
|
||||
<DefaultBox
|
||||
showMode
|
||||
title="客户信息"
|
||||
modeName={DeatailObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{DeatailObj.purchaser_name}</View>
|
||||
<View className={styles.pussPhone}>{DeatailObj.purchaser_phone}</View>
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<DefaultBox title="退款信息">
|
||||
<GoodsItem list={productList} obj={DeatailObj}></GoodsItem>
|
||||
<View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>总计</View>
|
||||
<View className={styles.totalRight}>{DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 {
|
||||
DeatailObj?.sale_mode == 0 ? DeatailObj?.return_roll : DeatailObj?.total_number / 100
|
||||
} {DeatailObj?.sale_mode == 0 ? '条' : '米'}</View>
|
||||
</View>
|
||||
{
|
||||
leftTitle: '售后编号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true
|
||||
},
|
||||
{
|
||||
leftTitle: '订单号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true
|
||||
},
|
||||
{
|
||||
leftTitle: '退货原因:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '退货说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '其他说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '货物状况:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '申请时间:',
|
||||
rightTitle: '------',
|
||||
}
|
||||
])
|
||||
|
||||
//复制功能
|
||||
const clipboardData = (val) => {
|
||||
Taro.setClipboardData({
|
||||
data: val || '',
|
||||
success: function (res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
//取消退货
|
||||
const { fetchData: cancelFetch } = returnApplyOrdercancel()
|
||||
const handCancle = async () => {
|
||||
Taro.showModal({
|
||||
content: "确定要取消吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetch({ id: Number(DeatailObj.id) })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '取消成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
getDetail()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
//查看图片
|
||||
const [ShowPic, setShowPic] = useState(false)
|
||||
|
||||
|
||||
const [PicList, setPicList] = useState<any[]>([])
|
||||
|
||||
const handUp = (value) => {
|
||||
setShowPic(true)
|
||||
}
|
||||
|
||||
const onlyRead = useMemo(() => {
|
||||
if (DeatailObj.stage == 1) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}, [DeatailObj])
|
||||
|
||||
//获取图片列表
|
||||
const picUrl = useRef([])
|
||||
const getImageList = useCallback((list) => {
|
||||
picUrl.current = list
|
||||
}, [])
|
||||
|
||||
//提交附件
|
||||
const { fetchData: sureFetch } = returnApplyOrderuploadAccessory()
|
||||
const handSure = () => {
|
||||
let arr: any = []
|
||||
arr = [...picUrl.current]
|
||||
if (arr == 0) {
|
||||
return alert.error('请先添加附件')
|
||||
}
|
||||
Taro.showModal({
|
||||
content: "确定要提交吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await sureFetch({ id: Number(DeatailObj.id), accessory_url: arr, })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功'
|
||||
})
|
||||
setShowPic(false)
|
||||
Taro.hideLoading()
|
||||
getDetail()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const proview = (item) => {
|
||||
Taro.previewImage({
|
||||
current: IMG_CND_Prefix + item, // 当前显示图片的 http 链接
|
||||
urls: DeatailObj.fabric_piece_accessory_url.map((item) => {
|
||||
item = IMG_CND_Prefix + item;
|
||||
return item;
|
||||
}), // 需要预览的图片 http 链接列表
|
||||
});
|
||||
};
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const handSee = () => {
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<OrderState orderInfo={DeatailObj} />
|
||||
<AddressDetailBox
|
||||
obj={DeatailObj}
|
||||
handUp={() => handUp(DeatailObj)}
|
||||
></AddressDetailBox>
|
||||
<DefaultBox
|
||||
showMode={true}
|
||||
title={'客户信息'}
|
||||
modeName={DeatailObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{DeatailObj.purchaser_name}</View>
|
||||
<View className={styles.pussPhone}>{DeatailObj.purchaser_phone}</View>
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'退款信息'}>
|
||||
<GoodsItem list={productList} obj={DeatailObj}></GoodsItem>
|
||||
<View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>总计</View>
|
||||
<View className={styles.totalRight}>{DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 {
|
||||
DeatailObj?.sale_mode == 0 ? DeatailObj?.return_roll : DeatailObj?.total_number / 100
|
||||
} {DeatailObj?.sale_mode == 0 ? "条" : "米"}</View>
|
||||
</View>
|
||||
{
|
||||
(DeatailObj.stage == 3) &&
|
||||
<View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.refund_amount)
|
||||
}</View>
|
||||
(DeatailObj.stage == 3)
|
||||
&& <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.refund_amount)
|
||||
}</View>
|
||||
</View>
|
||||
|
||||
}
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'订单信息'}>
|
||||
{
|
||||
orderMsg.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.detailBox} key={index}>
|
||||
<View className={styles.detailFont}>
|
||||
{item.leftTitle}
|
||||
</View>
|
||||
<View className={styles.detailRightFlex}>
|
||||
<View className={styles.detailRight}>{item.rightTitle}</View>
|
||||
{item.showBtn && <View className={styles.detailBtn} onClick={() => clipboardData(item.rightTitle)}>复制</View>}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'售后图片'}>
|
||||
<View className={styles.picBox}>
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => {
|
||||
return (
|
||||
<Image className={styles.pic} lazyLoad key={index} onClick={() => proview(item)}
|
||||
mode="aspectFill" src={IMG_CND_Prefix + item}></Image>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length === 0 && <View className={styles.noPic}>暂无图片</View>
|
||||
}
|
||||
}
|
||||
</DefaultBox>
|
||||
<DefaultBox title="订单信息">
|
||||
{
|
||||
orderMsg.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.detailBox} key={index}>
|
||||
<View className={styles.detailFont}>
|
||||
{item.leftTitle}
|
||||
</View>
|
||||
<View className={styles.detailRightFlex}>
|
||||
<View className={styles.detailRight}>{item.rightTitle}</View>
|
||||
{item.showBtn && <View className={styles.detailBtn} onClick={() => clipboardData(item.rightTitle)}>复制</View>}
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<View className={styles.safeBox}></View>
|
||||
|
||||
<View className={styles.bottomMuck}>
|
||||
{
|
||||
(DeatailObj.stage === 0 || DeatailObj.stage === 1) && <View className={styles.cancleBtn} onClick={() => handCancle()}>取消退货</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
(DeatailObj.sale_mode == 0 && DeatailObj.stage == 3 && (DeatailObj.type == 1 || DeatailObj.type == 3)) && <View className={styles.seeButon} onClick={() => { handSee() }}>查看码单</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
<RefundCodelist
|
||||
obj={DeatailObj}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
<Popup title={'查看/修改物流回单'} show={ShowPic} onClose={() => setShowPic(false)}>
|
||||
<>
|
||||
<UploadImage onChange={getImageList} defaultList={PicList} onlyRead={onlyRead} />
|
||||
{
|
||||
|
||||
!onlyRead && <View className={styles.picBtn} onClick={() => handSure()}>确认修改</View>
|
||||
}
|
||||
</>
|
||||
</Popup>
|
||||
</DefaultBox>
|
||||
<DefaultBox title="售后图片">
|
||||
<View className={styles.picBox}>
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => {
|
||||
return (
|
||||
<Image className={styles.pic} lazyLoad key={index} onClick={() => proview(item)}
|
||||
mode="aspectFill" src={IMG_CND_Prefix + item}
|
||||
></Image>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length === 0 && <View className={styles.noPic}>暂无图片</View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
</DefaultBox>
|
||||
<View className={styles.safeBox}></View>
|
||||
|
||||
<View className={styles.bottomMuck}>
|
||||
{
|
||||
(DeatailObj.stage === 0 || DeatailObj.stage === 1) && <View className={styles.cancleBtn} onClick={() => handCancle()}>取消退货</View>
|
||||
|
||||
}
|
||||
{
|
||||
(DeatailObj.sale_mode == 0 && DeatailObj.stage == 3 && (DeatailObj.type == 1 || DeatailObj.type == 3)) && <View className={styles.seeButon} onClick={() => { handSee() }}>查看码单</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
<RefundCodelist
|
||||
obj={DeatailObj}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
<Popup title="查看/修改物流回单" show={ShowPic} onClose={() => setShowPic(false)}>
|
||||
<>
|
||||
<UploadImage onChange={getImageList} defaultList={PicList} onlyRead={onlyRead} />
|
||||
{
|
||||
|
||||
!onlyRead && <View className={styles.picBtn} onClick={() => handSure()}>确认修改</View>
|
||||
}
|
||||
</>
|
||||
</Popup>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface Obs {
|
||||
title?: string,
|
||||
modeName?: string,
|
||||
showMode?: boolean,
|
||||
children?: ReactNode,
|
||||
clickNode?: () => void
|
||||
title?: string
|
||||
modeName?: string
|
||||
showMode?: boolean
|
||||
children?: ReactNode
|
||||
clickNode?: () => void
|
||||
}
|
||||
|
||||
const DefaultBox = memo((props: Obs) => {
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode
|
||||
} = props
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
interface PropGoods {
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[],
|
||||
obj: any
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[]
|
||||
obj: any
|
||||
}
|
||||
const GoodsItem = memo((porps: PropGoods) => {
|
||||
const { list = [], obj = {} } = porps
|
||||
const { list = [], obj = {} } = porps
|
||||
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
{
|
||||
item.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
{
|
||||
it.texture_url === '' &&
|
||||
<Image className={styles.itemPic} mode={'aspectFill'} src={'https://test.cdn.zzfzyc.com/mall/no_img.png'}></Image>
|
||||
}
|
||||
{
|
||||
it.texture_url !== '' &&
|
||||
<View className={styles.itemPic}>
|
||||
<LabAndImg value={labAndImgObj(it)} />
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
{
|
||||
item.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
{
|
||||
it.texture_url === ''
|
||||
&& <Image className={styles.itemPic} mode="aspectFill" src="https://test.cdn.zzfzyc.com/mall/no_img.png"></Image>
|
||||
}
|
||||
{
|
||||
it.texture_url !== ''
|
||||
&& <View className={styles.itemPic}>
|
||||
<LabAndImg value={labAndImgObj(it)} />
|
||||
</View>
|
||||
}
|
||||
<View className={styles.clear}> </View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code}# {it.name}</View>
|
||||
{/* <View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
{
|
||||
obj.sale_mode == 0 && <View className={styles.itemNums}>x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2
|
||||
? it.roll
|
||||
: obj.stage == 5 || obj.stage == 6 || obj.stage == 3
|
||||
? it.return_roll
|
||||
: it.roll}{obj?.sale_mode == 0 ? '条' : 'm'}</View>
|
||||
}
|
||||
{
|
||||
obj.sale_mode != 0 && <View className={styles.itemNums}>x{it.length / 100}m</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'}</View>
|
||||
{/* <View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.total_sale_price)}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
<View className={styles.clear}> </View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code}# {it.name}</View>
|
||||
{/* <View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
{
|
||||
obj.sale_mode == 0 && <View className={styles.itemNums}>x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2
|
||||
? it.roll
|
||||
: obj.stage == 5 || obj.stage == 6 || obj.stage == 3
|
||||
? it.return_roll
|
||||
: it.roll}{obj?.sale_mode == 0 ? '条' : 'm'}</View>
|
||||
}
|
||||
{
|
||||
obj.sale_mode != 0 && <View className={styles.itemNums}>x{it.length / 100}m</View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'}</View>
|
||||
{/* <View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.total_sale_price)}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
|
||||
interface propsObj {
|
||||
receivingStatus?: Number | null,
|
||||
onReceivingStatus?: (any, Number) => void,
|
||||
obj: any,
|
||||
handUp?: (any) => void
|
||||
receivingStatus?: Number | null
|
||||
onReceivingStatus?: (any, Number) => void
|
||||
obj: any
|
||||
handUp?: (any) => void
|
||||
}
|
||||
export default memo((props: propsObj) => {
|
||||
const {
|
||||
obj = {},
|
||||
handUp,
|
||||
} = props
|
||||
|
||||
const {
|
||||
obj = {},
|
||||
handUp
|
||||
} = props
|
||||
const seeFont = useMemo(() => {
|
||||
if (obj.stage == 1) {
|
||||
return '上传物流回单'
|
||||
}
|
||||
else {
|
||||
return '查看物流回单'
|
||||
}
|
||||
}, [obj])
|
||||
|
||||
const seeFont = useMemo(() => {
|
||||
if (obj.stage == 1) {
|
||||
return '上传物流回单'
|
||||
} else {
|
||||
return '查看物流回单'
|
||||
}
|
||||
}, [obj])
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topFont}>请按以下退货地址寄回货物并提供退货物流信息</View>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.cirle}>
|
||||
<View className={classnames('iconfont', 'icon-dingwei', styles.dingwei)}></View>
|
||||
</View>
|
||||
<View className={styles.address}>广东省佛山市禅城区陆盈纺织仓库</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.name}>谭先生</View>
|
||||
<View className={styles.phone}>{13242128982}</View>
|
||||
|
||||
return (
|
||||
<View className={styles.addressBox}>
|
||||
<View className={styles.topFont}>请按以下退货地址寄回货物并提供退货物流信息</View>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.cirle}>
|
||||
<View className={classnames('iconfont', 'icon-dingwei', styles.dingwei)}></View>
|
||||
</View>
|
||||
<View className={styles.address}>{'广东省佛山市禅城区陆盈纺织仓库'}</View>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.bottom}>
|
||||
<View className={styles.name}>{'谭先生'}</View>
|
||||
<View className={styles.phone}>{13242128982}</View>
|
||||
<View className={styles.btn} onClick={() => handUp?.(obj)}>{seeFont}</View>
|
||||
|
||||
<View className={styles.btn} onClick={() => handUp?.(obj)}>{seeFont}</View>
|
||||
|
||||
{/* {
|
||||
{/* {
|
||||
obj.stage !== 1 && <View className={styles.nobtn}></View>
|
||||
} */}
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
</View>
|
||||
</View >
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,70 +1,68 @@
|
||||
import { Image, Text, View } from "@tarojs/components"
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { formatDateTime, formatImgUrl } from "@/common/format";
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from "@/common/enum";
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import * as dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import { formatDateTime, formatImgUrl } from '@/common/format'
|
||||
import { ORDER_STATUS, PAYMENT_METHOD } from '@/common/enum'
|
||||
|
||||
type List = {
|
||||
status: string,
|
||||
time: string,
|
||||
tag: string,
|
||||
desc: string,
|
||||
expire_time: string
|
||||
interface List {
|
||||
status: string
|
||||
time: string
|
||||
tag: string
|
||||
desc: string
|
||||
expire_time: string
|
||||
}
|
||||
|
||||
type Param = {
|
||||
onRefresh?: () => void,
|
||||
orderInfo?: {
|
||||
logistics_details: List[], //订单状态列表
|
||||
payment_method: number, //支付方式
|
||||
status: number, //订单状态
|
||||
account_period?: number, //账期
|
||||
account_period_time?: string //还款日期
|
||||
}
|
||||
interface Param {
|
||||
onRefresh?: () => void
|
||||
orderInfo?: {
|
||||
logistics_details: List[] // 订单状态列表
|
||||
payment_method: number // 支付方式
|
||||
status: number // 订单状态
|
||||
account_period?: number // 账期
|
||||
account_period_time?: string // 还款日期
|
||||
}
|
||||
}
|
||||
|
||||
export default memo(({ orderInfo = { logistics_details: [], payment_method: 0, status: 0 }, onRefresh }: Param) => {
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
useEffect(() => {
|
||||
console.log('orderInfo33::', orderInfo)
|
||||
}, [orderInfo])
|
||||
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
const [showMore, setShowMore] = useState(false)
|
||||
const changeMore = () => {
|
||||
setShowMore(() => !showMore)
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
const arr = orderInfo?.logistics_details
|
||||
if (orderInfo.logistics_details) {
|
||||
return arr.reverse()
|
||||
}
|
||||
const dataList = useMemo(() => {
|
||||
let arr = orderInfo?.logistics_details
|
||||
if (orderInfo.logistics_details) {
|
||||
return arr.reverse()
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}, [orderInfo.logistics_details])
|
||||
else {
|
||||
return []
|
||||
}
|
||||
}, [orderInfo.logistics_details])
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0) && styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0) && styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0) && styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{(dataList?.length > 0) && <View className={styles.order_flow_state}>
|
||||
<View className={classnames(styles.order_status_list, showMore && styles.order_status_list_show)}>
|
||||
{dataList.map((item, index) => <View className={styles.order_status_item}>
|
||||
{(dataList.length > 1) && <View className={classnames(styles.order_status_tail, (index == 0) && styles.order_status_tail_end)}></View>}
|
||||
{(dataList.length != (index + 1)) && <View className={styles.order_status_line}></View>}
|
||||
<View className={styles.order_status_content}>
|
||||
<View className={classnames(styles.order_status_title, (index == 0) && styles.order_status_select)}>{item.status}</View>
|
||||
<View className={classnames(styles.order_status_time, (index == 0) && styles.order_status_select)}>{formatDateTime(item.time)}</View>
|
||||
</View>
|
||||
<Text className={classnames(styles.order_status_des, (index == 0) && styles.order_status_des_select)}>{item.desc}</Text>
|
||||
</View>)}
|
||||
</View>
|
||||
{(dataList.length > 2) && <View className={styles.more} onClick={() => changeMore()}>
|
||||
<Text>{showMore && '收起详情' || '点击查看详情'}</Text>
|
||||
<Text className={classnames('iconfont icon-a-moreback', styles.miconfonts, showMore && styles.open_miconfonts)}></Text>
|
||||
</View>}
|
||||
</View>}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default {
|
||||
navigationBarTitleText: '售后详情',
|
||||
enablePullDownRefresh: true,
|
||||
"backgroundTextStyle": "dark"
|
||||
navigationBarTitleText: '售后详情',
|
||||
enablePullDownRefresh: true,
|
||||
backgroundTextStyle: 'dark',
|
||||
}
|
||||
|
||||
@@ -1,414 +1,408 @@
|
||||
import { View, Input, Button, Image } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, ReactNode, memo } from 'react'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Taro, { faceVerifyForPay, useDidShow, useRouter, usePullDownRefresh } from '@tarojs/taro'
|
||||
import { Button, Image, Input, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow, usePullDownRefresh, useRouter } from '@tarojs/taro'
|
||||
import type { ReactNode } from 'react'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/itemList'
|
||||
import OrderState from './components/orderState'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpreturnApplyOrder,
|
||||
returnApplyOrdercancel,
|
||||
returnApplyOrderuploadAccessory
|
||||
} from "@/api/refound"
|
||||
import OrderState from './components/orderState'
|
||||
mpreturnApplyOrder,
|
||||
returnApplyOrdercancel,
|
||||
returnApplyOrderuploadAccessory,
|
||||
} from '@/api/refound'
|
||||
// import AddressDetailBox from './components/addressDetailBox'
|
||||
import { IMG_CND_Prefix } from "@/common/constant";
|
||||
import RefundCodelist from "@/components/RefundCodelist"
|
||||
import LabAndImg from "@/components/LabAndImg"
|
||||
import { IMG_CND_Prefix } from '@/common/constant'
|
||||
import RefundCodelist from '@/components/RefundCodelist'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
export default () => {
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
//页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getDetail()
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
// 页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getDetail()
|
||||
})
|
||||
|
||||
// 获取详情
|
||||
const { fetchData: detailFetch } = mpreturnApplyOrder()
|
||||
const [DeatailObj, setDeatailObj] = useState<any>({})
|
||||
const getDetail = async() => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
const res = await detailFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
setDeatailObj(res.data)
|
||||
orderMsg.map((it) => {
|
||||
if (it.leftTitle === '售后编号:') {
|
||||
it.rightTitle = res.data.return_order_no
|
||||
}
|
||||
if (it.leftTitle === '订单号:') {
|
||||
it.rightTitle = res.data.order_no
|
||||
}
|
||||
if (it.leftTitle === '退货原因:') {
|
||||
it.rightTitle = res.data.return_reason_name
|
||||
}
|
||||
if (it.leftTitle === '退货说明:') {
|
||||
it.rightTitle = res.data.return_explain_name
|
||||
}
|
||||
if (it.leftTitle === '其他说明:') {
|
||||
it.rightTitle = res.data.reason_describe
|
||||
}
|
||||
// if (it.leftTitle === '货物状况:') {
|
||||
// it.rightTitle = res.data.goods_status_name
|
||||
// }
|
||||
if (it.leftTitle === '申请时间:') {
|
||||
it.rightTitle = formatDateTime(res.data.apply_time)
|
||||
}
|
||||
})
|
||||
setOrderMsg([...orderMsg])
|
||||
Taro.stopPullDownRefresh()
|
||||
// setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
// 分辨用质检中还是质检前的数组
|
||||
const productList = useMemo(() => {
|
||||
if (DeatailObj?.stage == 0 || DeatailObj?.type == 3 || DeatailObj?.type == 2) {
|
||||
return DeatailObj?.product_list
|
||||
}
|
||||
else {
|
||||
return DeatailObj?.quality_check_pass_product
|
||||
}
|
||||
}, [DeatailObj])
|
||||
|
||||
//获取详情
|
||||
const { fetchData: detailFetch } = mpreturnApplyOrder()
|
||||
const [DeatailObj, setDeatailObj] = useState<any>({})
|
||||
const getDetail = async () => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
// 订单信息文字数组
|
||||
const [orderMsg, setOrderMsg] = useState<any[]>([
|
||||
{
|
||||
leftTitle: '售后编号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true,
|
||||
},
|
||||
{
|
||||
leftTitle: '订单号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true,
|
||||
},
|
||||
{
|
||||
leftTitle: '退货原因:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '退货说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '其他说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
// {
|
||||
// leftTitle: '货物状况:',
|
||||
// rightTitle: '------',
|
||||
// },
|
||||
{
|
||||
leftTitle: '申请时间:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
])
|
||||
|
||||
// 复制功能
|
||||
const clipboardData = (val) => {
|
||||
Taro.setClipboardData({
|
||||
data: val || '',
|
||||
success(res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
const res = await detailFetch({ id: Number(router.params.id) })
|
||||
if (res.data) {
|
||||
setDeatailObj(res.data)
|
||||
orderMsg.map(it => {
|
||||
if (it.leftTitle === '售后编号:') {
|
||||
it.rightTitle = res.data.return_order_no
|
||||
}
|
||||
if (it.leftTitle === '订单号:') {
|
||||
it.rightTitle = res.data.order_no
|
||||
}
|
||||
if (it.leftTitle === '退货原因:') {
|
||||
it.rightTitle = res.data.return_reason_name
|
||||
}
|
||||
if (it.leftTitle === '退货说明:') {
|
||||
it.rightTitle = res.data.return_explain_name
|
||||
}
|
||||
if (it.leftTitle === '其他说明:') {
|
||||
it.rightTitle = res.data.reason_describe
|
||||
}
|
||||
// if (it.leftTitle === '货物状况:') {
|
||||
// it.rightTitle = res.data.goods_status_name
|
||||
// }
|
||||
if (it.leftTitle === '申请时间:') {
|
||||
it.rightTitle = formatDateTime(res.data.apply_time)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 取消退货
|
||||
const { fetchData: cancelFetch } = returnApplyOrdercancel()
|
||||
const handCancle = async() => {
|
||||
Taro.showModal({
|
||||
content: '确定要取消吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetch({ id: Number(DeatailObj.id) })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '取消成功',
|
||||
})
|
||||
setOrderMsg([...orderMsg])
|
||||
Taro.stopPullDownRefresh();
|
||||
// setPicList([...res.data?.accessory_url !== null ? res.data?.accessory_url : []])
|
||||
Taro.hideLoading()
|
||||
getDetail()
|
||||
}
|
||||
else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
// //查看图片
|
||||
// const [ShowPic, setShowPic] = useState(false)
|
||||
|
||||
//分辨用质检中还是质检前的数组
|
||||
const productList = useMemo(() => {
|
||||
if (DeatailObj?.stage == 0 || DeatailObj?.type == 3 || DeatailObj?.type == 2) {
|
||||
return DeatailObj?.product_list
|
||||
} else {
|
||||
return DeatailObj?.quality_check_pass_product
|
||||
}
|
||||
}, [DeatailObj])
|
||||
// const [PicList, setPicList] = useState<any[]>([])
|
||||
|
||||
// const handUp = (value) => {
|
||||
// setShowPic(true)
|
||||
// }
|
||||
|
||||
//订单信息文字数组
|
||||
const [orderMsg, setOrderMsg] = useState<any[]>([
|
||||
{
|
||||
leftTitle: '售后编号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true
|
||||
},
|
||||
{
|
||||
leftTitle: '订单号:',
|
||||
rightTitle: '------',
|
||||
showBtn: true
|
||||
},
|
||||
{
|
||||
leftTitle: '退货原因:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '退货说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
{
|
||||
leftTitle: '其他说明:',
|
||||
rightTitle: '------',
|
||||
},
|
||||
// {
|
||||
// leftTitle: '货物状况:',
|
||||
// rightTitle: '------',
|
||||
// },
|
||||
{
|
||||
leftTitle: '申请时间:',
|
||||
rightTitle: '------',
|
||||
}
|
||||
])
|
||||
// const onlyRead = useMemo(() => {
|
||||
// if (DeatailObj.stage == 1) {
|
||||
// return false
|
||||
// } else {
|
||||
// return true
|
||||
// }
|
||||
// }, [DeatailObj])
|
||||
|
||||
//复制功能
|
||||
const clipboardData = (val) => {
|
||||
Taro.setClipboardData({
|
||||
data: val || '',
|
||||
success: function (res) {
|
||||
Taro.showToast({
|
||||
icon: 'none',
|
||||
title: '复制成功',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
// //获取图片列表
|
||||
// const picUrl = useRef([])
|
||||
// const getImageList = useCallback((list) => {
|
||||
// picUrl.current = list
|
||||
// }, [])
|
||||
|
||||
//取消退货
|
||||
const { fetchData: cancelFetch } = returnApplyOrdercancel()
|
||||
const handCancle = async () => {
|
||||
Taro.showModal({
|
||||
content: "确定要取消吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await cancelFetch({ id: Number(DeatailObj.id) })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
if (res.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '取消成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
getDetail()
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const proview = (item) => {
|
||||
Taro.previewImage({
|
||||
current: IMG_CND_Prefix + item, // 当前显示图片的 http 链接
|
||||
urls: DeatailObj.fabric_piece_accessory_url.map((item) => {
|
||||
item = IMG_CND_Prefix + item
|
||||
return item
|
||||
}), // 需要预览的图片 http 链接列表
|
||||
})
|
||||
}
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const handSee = () => {
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// //查看图片
|
||||
// const [ShowPic, setShowPic] = useState(false)
|
||||
|
||||
|
||||
// const [PicList, setPicList] = useState<any[]>([])
|
||||
|
||||
// const handUp = (value) => {
|
||||
// setShowPic(true)
|
||||
// }
|
||||
|
||||
// const onlyRead = useMemo(() => {
|
||||
// if (DeatailObj.stage == 1) {
|
||||
// return false
|
||||
// } else {
|
||||
// return true
|
||||
// }
|
||||
// }, [DeatailObj])
|
||||
|
||||
// //获取图片列表
|
||||
// const picUrl = useRef([])
|
||||
// const getImageList = useCallback((list) => {
|
||||
// picUrl.current = list
|
||||
// }, [])
|
||||
|
||||
|
||||
const proview = (item) => {
|
||||
Taro.previewImage({
|
||||
current: IMG_CND_Prefix + item, // 当前显示图片的 http 链接
|
||||
urls: DeatailObj.fabric_piece_accessory_url.map((item) => {
|
||||
item = IMG_CND_Prefix + item;
|
||||
return item;
|
||||
}), // 需要预览的图片 http 链接列表
|
||||
});
|
||||
};
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const handSee = () => {
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<OrderState orderInfo={DeatailObj} />
|
||||
{/* <AddressDetailBox
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<OrderState orderInfo={DeatailObj} />
|
||||
{/* <AddressDetailBox
|
||||
obj={DeatailObj}
|
||||
handUp={() => handUp(DeatailObj)}
|
||||
></AddressDetailBox> */}
|
||||
<DefaultBox
|
||||
showMode={true}
|
||||
title={'客户信息'}
|
||||
modeName={DeatailObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{DeatailObj.purchaser_name}</View>
|
||||
<View className={styles.pussPhone}>{DeatailObj.purchaser_phone}</View>
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'退款信息'}>
|
||||
<GoodsItem list={productList} obj={DeatailObj}></GoodsItem>
|
||||
<View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>总计</View>
|
||||
<View className={styles.totalRight}>{DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 {
|
||||
DeatailObj?.sale_mode == 0 ? DeatailObj?.return_roll : DeatailObj?.total_number / 100
|
||||
} {DeatailObj?.sale_mode == 0 ? "条" : "米"}</View>
|
||||
</View>
|
||||
{
|
||||
DeatailObj.stage == 0 && <View className={styles.totalBox}>
|
||||
|
||||
<View className={styles.totalLeft}>合计金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.total_refund_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.refund_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>其他扣除金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.other_deduction_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款去向</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>{
|
||||
DeatailObj.refund_flow_name
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'订单信息'}>
|
||||
{
|
||||
orderMsg.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.detailBox} key={index}>
|
||||
<View className={styles.detailFont}>
|
||||
{item.leftTitle}
|
||||
</View>
|
||||
<View className={styles.detailRightFlex}>
|
||||
<View className={styles.detailRight}>{item.rightTitle}</View>
|
||||
{item.showBtn && <View className={styles.detailBtn} onClick={() => clipboardData(item.rightTitle)}>复制</View>}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</DefaultBox>
|
||||
<DefaultBox title={'售后图片'}>
|
||||
<View className={styles.picBox}>
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => {
|
||||
return (
|
||||
<Image className={styles.pic} lazyLoad key={index} onClick={() => proview(item)}
|
||||
mode="aspectFill" src={IMG_CND_Prefix + item}></Image>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length === 0 && <View className={styles.noPic}>暂无图片</View>
|
||||
}
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<View className={styles.safeBox}></View>
|
||||
<View className={styles.bottomMuck}>
|
||||
{
|
||||
(DeatailObj.stage === 0 || DeatailObj.stage === 1) && <View className={styles.cancleBtn} onClick={() => handCancle()}>取消退货</View>
|
||||
|
||||
}
|
||||
{
|
||||
(DeatailObj.sale_mode == 0 && DeatailObj.stage == 3 && (DeatailObj.type == 1 || DeatailObj.type == 3)) && <View className={styles.seeButon} onClick={() => { handSee() }}>查看码单</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
<RefundCodelist
|
||||
obj={DeatailObj}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
<DefaultBox
|
||||
showMode
|
||||
title="客户信息"
|
||||
modeName={DeatailObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{DeatailObj.purchaser_name}</View>
|
||||
<View className={styles.pussPhone}>{DeatailObj.purchaser_phone}</View>
|
||||
</View>
|
||||
)
|
||||
</DefaultBox>
|
||||
<DefaultBox title="退款信息">
|
||||
<GoodsItem list={productList} obj={DeatailObj}></GoodsItem>
|
||||
<View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>总计</View>
|
||||
<View className={styles.totalRight}>{DeatailObj.total_fabrics} 种面料,{DeatailObj?.total_colors} 种颜色,共 {
|
||||
DeatailObj?.sale_mode == 0 ? DeatailObj?.return_roll : DeatailObj?.total_number / 100
|
||||
} {DeatailObj?.sale_mode == 0 ? '条' : '米'}</View>
|
||||
</View>
|
||||
{
|
||||
DeatailObj.stage == 0 && <View className={styles.totalBox}>
|
||||
|
||||
<View className={styles.totalLeft}>合计金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.total_refund_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.refund_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>其他扣除金额</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>¥{
|
||||
formatPriceDiv(DeatailObj.other_deduction_amount)
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(DeatailObj.stage == 3) && <View className={styles.totalBox}>
|
||||
<View className={styles.totalLeft}>退款去向</View>
|
||||
<View className={styles.totalRight} style={{ color: '#F64861' }}>{
|
||||
DeatailObj.refund_flow_name
|
||||
}</View>
|
||||
</View>
|
||||
}
|
||||
</DefaultBox>
|
||||
<DefaultBox title="订单信息">
|
||||
{
|
||||
orderMsg.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.detailBox} key={index}>
|
||||
<View className={styles.detailFont}>
|
||||
{item.leftTitle}
|
||||
</View>
|
||||
<View className={styles.detailRightFlex}>
|
||||
<View className={styles.detailRight}>{item.rightTitle}</View>
|
||||
{item.showBtn && <View className={styles.detailBtn} onClick={() => clipboardData(item.rightTitle)}>复制</View>}
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
</DefaultBox>
|
||||
<DefaultBox title="售后图片">
|
||||
<View className={styles.picBox}>
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length > 0 && DeatailObj?.fabric_piece_accessory_url.map((item, index) => {
|
||||
return (
|
||||
<Image className={styles.pic} lazyLoad key={index} onClick={() => proview(item)}
|
||||
mode="aspectFill" src={IMG_CND_Prefix + item}
|
||||
></Image>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
DeatailObj?.fabric_piece_accessory_url?.length === 0 && <View className={styles.noPic}>暂无图片</View>
|
||||
}
|
||||
</View>
|
||||
</DefaultBox>
|
||||
<View className={styles.safeBox}></View>
|
||||
<View className={styles.bottomMuck}>
|
||||
{
|
||||
(DeatailObj.stage === 0 || DeatailObj.stage === 1) && <View className={styles.cancleBtn} onClick={() => handCancle()}>取消退货</View>
|
||||
|
||||
}
|
||||
{
|
||||
(DeatailObj.sale_mode == 0 && DeatailObj.stage == 3 && (DeatailObj.type == 1 || DeatailObj.type == 3)) && <View className={styles.seeButon} onClick={() => { handSee() }}>查看码单</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
<RefundCodelist
|
||||
obj={DeatailObj}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface Obs {
|
||||
title?: string,
|
||||
modeName?: string,
|
||||
showMode?: boolean,
|
||||
children?: ReactNode,
|
||||
clickNode?: () => void
|
||||
title?: string
|
||||
modeName?: string
|
||||
showMode?: boolean
|
||||
children?: ReactNode
|
||||
clickNode?: () => void
|
||||
}
|
||||
|
||||
const DefaultBox = memo((props: Obs) => {
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode
|
||||
} = props
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
interface PropGoods {
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[],
|
||||
obj: any
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[]
|
||||
obj: any
|
||||
}
|
||||
const GoodsItem = memo((porps: PropGoods) => {
|
||||
const { list = [], obj = {} } = porps
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
{
|
||||
item?.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
{
|
||||
it.texture_url === '' &&
|
||||
<Image className={styles.itemPic} mode={'aspectFill'} src={'https://test.cdn.zzfzyc.com/mall/no_img.png'}></Image>
|
||||
}
|
||||
{
|
||||
it.texture_url !== '' &&
|
||||
<View className={styles.itemPic}>
|
||||
<LabAndImg value={labAndImgObj(it)} />
|
||||
const { list = [], obj = {} } = porps
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
{
|
||||
item?.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
{
|
||||
it.texture_url === ''
|
||||
&& <Image className={styles.itemPic} mode="aspectFill" src="https://test.cdn.zzfzyc.com/mall/no_img.png"></Image>
|
||||
}
|
||||
{
|
||||
it.texture_url !== ''
|
||||
&& <View className={styles.itemPic}>
|
||||
<LabAndImg value={labAndImgObj(it)} />
|
||||
</View>
|
||||
}
|
||||
{/* <View className={styles.itemPic} style={{ backgroundColor: `rgb(${it?.rgb?.r} ${it?.rgb?.g} ${it?.rgb?.b})` }}></View> */}
|
||||
<View className={styles.clear}> </View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code}# {it.name}</View>
|
||||
{/* <View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
{
|
||||
obj.sale_mode == 0 && <View className={styles.itemNums}>x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2
|
||||
? it.roll
|
||||
: obj.stage == 5 || obj.stage == 6 || obj.stage == 3
|
||||
? it.return_roll
|
||||
: it.roll}{obj?.sale_mode == 0 ? '条' : 'm'}</View>
|
||||
}
|
||||
{
|
||||
obj.sale_mode != 0 && <View className={styles.itemNums}>x{it.length / 100}m</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'}</View>
|
||||
{/* <View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.total_sale_price)}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
{/* <View className={styles.itemPic} style={{ backgroundColor: `rgb(${it?.rgb?.r} ${it?.rgb?.g} ${it?.rgb?.b})` }}></View> */}
|
||||
<View className={styles.clear}> </View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code}# {it.name}</View>
|
||||
{/* <View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
{
|
||||
obj.sale_mode == 0 && <View className={styles.itemNums}>x{obj.stage == 0 || obj.stage == 1 || obj.stage == 2
|
||||
? it.roll
|
||||
: obj.stage == 5 || obj.stage == 6 || obj.stage == 3
|
||||
? it.return_roll
|
||||
: it.roll}{obj?.sale_mode == 0 ? '条' : 'm'}</View>
|
||||
}
|
||||
{
|
||||
obj.sale_mode != 0 && <View className={styles.itemNums}>x{it.length / 100}m</View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode == 0 ? 'kg' : 'm'}</View>
|
||||
{/* <View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.total_sale_price)}</View> */}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,128 +1,127 @@
|
||||
import { ScrollView, View, Image } from '@tarojs/components'
|
||||
import { Image, ScrollView, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
// import BottomBtns from '@/components/BottomBtns'
|
||||
import { formatPriceDiv } from '@/common/format'
|
||||
import Taro from '@tarojs/taro'
|
||||
import LabAndImg from "@/components/LabAndImg"
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
interface propsObj {
|
||||
obj: any,
|
||||
cancle?: (arg: any, obj: any) => void,
|
||||
nextBuy?: (arg: any, obj: any) => void,
|
||||
toPay?: (arg: any, obj: any) => void
|
||||
handSee?: (any) => void
|
||||
obj: any
|
||||
cancle?: (arg: any, obj: any) => void
|
||||
nextBuy?: (arg: any, obj: any) => void
|
||||
toPay?: (arg: any, obj: any) => void
|
||||
handSee?: (any) => void
|
||||
}
|
||||
|
||||
|
||||
export default memo((props: propsObj) => {
|
||||
const navTo = (e) => {
|
||||
if (e.type == 1) {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/refundDetail/index?id=' + props?.obj?.id
|
||||
})
|
||||
} else {
|
||||
Taro.navigateTo({
|
||||
url: '/pages/refundMoneyDetail/index?id=' + props?.obj?.id
|
||||
})
|
||||
}
|
||||
|
||||
const navTo = (e) => {
|
||||
if (e.type == 1) {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/refundDetail/index?id=${props?.obj?.id}`,
|
||||
})
|
||||
}
|
||||
else {
|
||||
Taro.navigateTo({
|
||||
url: `/pages/refundMoneyDetail/index?id=${props?.obj?.id}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => navTo(props.obj)}>
|
||||
<View className={styles.topItem}>
|
||||
<View className={styles.orderNo}>单号:{props?.obj?.order_no}</View>
|
||||
<View className={styles.status}>{props?.obj?.stage_name}</View>
|
||||
</View>
|
||||
<View className={styles.pussName}>{props?.obj?.purchaser_name}</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.contBox}>
|
||||
<View style={{ minWidth: '24%' }}>
|
||||
<View className={styles.leftCont} >
|
||||
{
|
||||
props?.obj?.product_list[0]?.texture_url === '' &&
|
||||
<Image className={styles.leftCont} mode={'aspectFill'} src={'https://test.cdn.zzfzyc.com/mall/no_img.png'}></Image>
|
||||
}
|
||||
{
|
||||
props?.obj?.product_list[0]?.texture_url !== '' &&
|
||||
<>
|
||||
<LabAndImg value={labAndImgObj(props?.obj?.product_list?.[0])} /></>
|
||||
|
||||
}
|
||||
<View className={styles.leftContNums}>颜色 ({props?.obj?.total_colors})</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.rightCont}>
|
||||
<View className={styles.rightTop}>
|
||||
<View className={styles.productBox}>
|
||||
<View className={styles.productName}>{props?.obj?.product_list[0]?.code} {props?.obj?.product_list[0]?.name}</View>
|
||||
<View className={styles.productMode}>{props?.obj?.sale_mode === 0 ? '大货' : props?.obj?.sale_mode === 1 ? '剪版' : '散剪'}</View>
|
||||
</View>
|
||||
<View className={styles.shipMode}>{props?.obj?.shipment_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[0]?.code} {props?.obj?.product_list[0]?.product_colors[0]?.name}</View>
|
||||
<View className={styles.colorName}>x{
|
||||
props?.obj?.product_list && props?.obj.sale_mode === 0
|
||||
? (props?.obj?.product_list && props?.obj.stage == 0) ||
|
||||
props?.obj.stage == 1 ||
|
||||
props?.obj.stage == 2
|
||||
? props?.obj?.product_list[0]?.product_colors[0]?.roll
|
||||
: props?.obj.stage == 5 || props?.obj.stage == 6 || props?.obj.stage == 3
|
||||
? props?.obj?.product_list[0]?.product_colors[0]?.return_roll
|
||||
: props?.obj?.product_list[0]?.product_colors[0]?.roll
|
||||
: props?.obj?.product_list &&
|
||||
props?.obj?.product_list[0]?.product_colors[0]?.length / 100
|
||||
} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[0]?.sale_price / 100}/kg</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj?.product_list[0]?.product_colors?.length > 1 && <>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[1]?.code} {props?.obj?.product_list[0]?.product_colors[1]?.name}</View>
|
||||
<View className={styles.colorName}>x{
|
||||
props?.obj?.product_list && props?.obj.sale_mode === 0
|
||||
? (props?.obj?.product_list && props?.obj.stage == 0) ||
|
||||
props?.obj.stage == 1 ||
|
||||
props?.obj.stage == 2
|
||||
? props?.obj?.product_list[0]?.product_colors[1]?.roll
|
||||
: props?.obj.stage == 5 || props?.obj.stage == 6 || props?.obj.stage == 3
|
||||
? props?.obj?.product_list[0]?.product_colors[1]?.return_roll
|
||||
: props?.obj?.product_list[0]?.product_colors[1]?.roll
|
||||
: props?.obj?.product_list &&
|
||||
props?.obj?.product_list[0]?.product_colors[1]?.length / 100
|
||||
} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[1]?.sale_price / 100}/kg</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.lineOne}></View>
|
||||
<View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>布料信息:</View>
|
||||
<View className={styles.msgRight}>{props?.obj?.total_fabrics} 种面料,{
|
||||
props?.obj?.total_colors
|
||||
} 种颜色,共 {props?.obj?.sale_mode === 0 ? props?.obj?.total_number : props?.obj?.total_number / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => navTo(props.obj)}>
|
||||
<View className={styles.topItem}>
|
||||
<View className={styles.orderNo}>单号:{props?.obj?.order_no}</View>
|
||||
<View className={styles.status}>{props?.obj?.stage_name}</View>
|
||||
</View>
|
||||
<View className={styles.pussName}>{props?.obj?.purchaser_name}</View>
|
||||
<View className={styles.line}></View>
|
||||
<View className={styles.contBox}>
|
||||
<View style={{ minWidth: '24%' }}>
|
||||
<View className={styles.leftCont} >
|
||||
{
|
||||
(props?.obj.stage == 3) && <View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>退款金额:</View>
|
||||
|
||||
<View className={styles.msgRightOne}>¥{formatPriceDiv(props?.obj?.refund_amount)}</View>
|
||||
</View>
|
||||
props?.obj?.product_list[0]?.texture_url === ''
|
||||
&& <Image className={styles.leftCont} mode="aspectFill" src="https://test.cdn.zzfzyc.com/mall/no_img.png"></Image>
|
||||
}
|
||||
{
|
||||
(props.obj.sale_mode == 0 && props?.obj.stage == 3 && (props?.obj.type == 1 || props?.obj.type == 3)) && <View className={styles.bottomBox}>
|
||||
<View className={styles.seeButon} onClick={(e) => { props?.handSee?.(e) }}>查看码单</View>
|
||||
</View>
|
||||
props?.obj?.product_list[0]?.texture_url !== ''
|
||||
&& <>
|
||||
<LabAndImg value={labAndImgObj(props?.obj?.product_list?.[0])} /></>
|
||||
|
||||
}
|
||||
<View className={styles.leftContNums}>颜色 ({props?.obj?.total_colors})</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
<View className={styles.rightCont}>
|
||||
<View className={styles.rightTop}>
|
||||
<View className={styles.productBox}>
|
||||
<View className={styles.productName}>{props?.obj?.product_list[0]?.code} {props?.obj?.product_list[0]?.name}</View>
|
||||
<View className={styles.productMode}>{props?.obj?.sale_mode === 0 ? '大货' : props?.obj?.sale_mode === 1 ? '剪版' : '散剪'}</View>
|
||||
</View>
|
||||
<View className={styles.shipMode}>{props?.obj?.shipment_mode_name}</View>
|
||||
</View>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[0]?.code} {props?.obj?.product_list[0]?.product_colors[0]?.name}</View>
|
||||
<View className={styles.colorName}>x{
|
||||
props?.obj?.product_list && props?.obj.sale_mode === 0
|
||||
? (props?.obj?.product_list && props?.obj.stage == 0)
|
||||
|| props?.obj.stage == 1
|
||||
|| props?.obj.stage == 2
|
||||
? props?.obj?.product_list[0]?.product_colors[0]?.roll
|
||||
: props?.obj.stage == 5 || props?.obj.stage == 6 || props?.obj.stage == 3
|
||||
? props?.obj?.product_list[0]?.product_colors[0]?.return_roll
|
||||
: props?.obj?.product_list[0]?.product_colors[0]?.roll
|
||||
: props?.obj?.product_list
|
||||
&& props?.obj?.product_list[0]?.product_colors[0]?.length / 100
|
||||
} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[0]?.sale_price / 100}/kg</View>
|
||||
</View>
|
||||
{
|
||||
props?.obj?.product_list[0]?.product_colors?.length > 1 && <>
|
||||
<View className={styles.colorsBox}>
|
||||
<View className={styles.colorNameOne}>{props?.obj?.product_list[0]?.product_colors[1]?.code} {props?.obj?.product_list[0]?.product_colors[1]?.name}</View>
|
||||
<View className={styles.colorName}>x{
|
||||
props?.obj?.product_list && props?.obj.sale_mode === 0
|
||||
? (props?.obj?.product_list && props?.obj.stage == 0)
|
||||
|| props?.obj.stage == 1
|
||||
|| props?.obj.stage == 2
|
||||
? props?.obj?.product_list[0]?.product_colors[1]?.roll
|
||||
: props?.obj.stage == 5 || props?.obj.stage == 6 || props?.obj.stage == 3
|
||||
? props?.obj?.product_list[0]?.product_colors[1]?.return_roll
|
||||
: props?.obj?.product_list[0]?.product_colors[1]?.roll
|
||||
: props?.obj?.product_list
|
||||
&& props?.obj?.product_list[0]?.product_colors[1]?.length / 100
|
||||
} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
<View className={styles.colorNameTwo}>¥ {props?.obj?.product_list[0]?.product_colors[1]?.sale_price / 100}/kg</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.lineOne}></View>
|
||||
<View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>布料信息:</View>
|
||||
<View className={styles.msgRight}>{props?.obj?.total_fabrics} 种面料,{
|
||||
props?.obj?.total_colors
|
||||
} 种颜色,共 {props?.obj?.sale_mode === 0 ? props?.obj?.total_number : props?.obj?.total_number / 100} {props?.obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
{
|
||||
(props?.obj.stage == 3) && <View className={styles.bottomMsg}>
|
||||
<View className={styles.msgLeft}>退款金额:</View>
|
||||
|
||||
<View className={styles.msgRightOne}>¥{formatPriceDiv(props?.obj?.refund_amount)}</View>
|
||||
</View>
|
||||
}
|
||||
{
|
||||
(props.obj.sale_mode == 0 && props?.obj.stage == 3 && (props?.obj.type == 1 || props?.obj.type == 3)) && <View className={styles.bottomBox}>
|
||||
<View className={styles.seeButon} onClick={(e) => { props?.handSee?.(e) }}>查看码单</View>
|
||||
</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,5 +1,5 @@
|
||||
export default {
|
||||
navigationBarTitleText: '退款/售后',
|
||||
// enablePullDownRefresh: true,
|
||||
// "backgroundTextStyle": "dark"
|
||||
navigationBarTitleText: '退款/售后',
|
||||
// enablePullDownRefresh: true,
|
||||
// "backgroundTextStyle": "dark"
|
||||
}
|
||||
|
||||
+380
-384
@@ -1,422 +1,418 @@
|
||||
import { View, Input, Button, ScrollView } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react'
|
||||
import { Button, Input, ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/itemList'
|
||||
import Tabs from './components/tabs'
|
||||
import Search from '@/components/search'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Popup from '@/components/popup'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import Taro, { faceVerifyForPay, useDidShow } from '@tarojs/taro'
|
||||
import ItemList from './components/itemList'
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from '@/common/format'
|
||||
import {
|
||||
mpreturnApplyOrderlist,
|
||||
mpenumreturnStage,
|
||||
mpenumreturnType
|
||||
} from "@/api/refound"
|
||||
import Tabs from "./components/tabs"
|
||||
mpenumreturnStage,
|
||||
mpenumreturnType,
|
||||
mpreturnApplyOrderlist,
|
||||
} from '@/api/refound'
|
||||
import TimePickerPopup from '@/components/timePickerPopup'
|
||||
import dayjs from 'dayjs'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import RefundCodelist from "@/components/RefundCodelist"
|
||||
import RefundCodelist from '@/components/RefundCodelist'
|
||||
|
||||
export default () => {
|
||||
//页码和页数
|
||||
// 页码和页数
|
||||
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
status: number | unknown;
|
||||
page: number;
|
||||
size: number;
|
||||
name: string;
|
||||
sale_mode: number | string;
|
||||
stage: number | string;
|
||||
return_type: number | string;
|
||||
sale_start_time: number | string;
|
||||
sale_end_time: number | string;
|
||||
}>({
|
||||
status: 1,
|
||||
page: 1,
|
||||
size: 10,
|
||||
name: '',
|
||||
sale_mode: '不限',
|
||||
stage: '不限',
|
||||
return_type: '不限',
|
||||
sale_start_time: '',
|
||||
sale_end_time: ''
|
||||
})
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
const [searchField, setSearchField] = useState<
|
||||
{
|
||||
status: number | unknown
|
||||
page: number
|
||||
size: number
|
||||
name: string
|
||||
sale_mode: number | string
|
||||
stage: number | string
|
||||
return_type: number | string
|
||||
sale_start_time: number | string
|
||||
sale_end_time: number | string
|
||||
}>({
|
||||
status: 1,
|
||||
page: 1,
|
||||
size: 10,
|
||||
name: '',
|
||||
sale_mode: '不限',
|
||||
stage: '不限',
|
||||
return_type: '不限',
|
||||
sale_start_time: '',
|
||||
sale_end_time: '',
|
||||
})
|
||||
const pageNum = useRef({ size: searchField.size, page: searchField.page })
|
||||
|
||||
//监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField.size, searchField.name, searchField.status])
|
||||
// 监听筛选条件变化
|
||||
useEffect(() => {
|
||||
getOrderList()
|
||||
}, [searchField.size, searchField.name, searchField.status])
|
||||
|
||||
//获取订单列表
|
||||
const { fetchData: listFetchData, state: orderState } = mpreturnApplyOrderlist()
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
const getOrderList = async () => {
|
||||
let res = await listFetchData({
|
||||
...searchField
|
||||
// ...getFilterData(searchField),
|
||||
// ...getFilterData(searchObj)
|
||||
})
|
||||
setOrderData((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
// setshowPopup(false)
|
||||
setRefresherTriggeredStatus(false)
|
||||
// 获取订单列表
|
||||
const { fetchData: listFetchData, state: orderState } = mpreturnApplyOrderlist()
|
||||
const [orderData, setOrderData] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
const getOrderList = async() => {
|
||||
const res = await listFetchData({
|
||||
...searchField,
|
||||
// ...getFilterData(searchField),
|
||||
// ...getFilterData(searchObj)
|
||||
})
|
||||
setOrderData(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
// setshowPopup(false)
|
||||
setRefresherTriggeredStatus(false)
|
||||
}
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField(val => ({ ...val, name: e, size: 10 }))
|
||||
}, [])
|
||||
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField(val => ({ ...val, size: 10 }))
|
||||
getOrderList()
|
||||
}
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! })
|
||||
}, [orderData, orderState])
|
||||
|
||||
// 上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
|
||||
// 顶部栏
|
||||
const [TarBarList, setTarBarList] = useState<any[]>([{ id: 1, name: '售后申请', showBorder: true }, { id: 2, name: '申请记录', showBorder: false }])
|
||||
const handChose = (item) => {
|
||||
if (item.id === searchField.status) { return }
|
||||
TarBarList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.showBorder = true
|
||||
}
|
||||
else {
|
||||
it.showBorder = false
|
||||
}
|
||||
setTarBarList([...TarBarList])
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField(val => ({ ...val, size: 10, status: item.id }))
|
||||
// getOrderList()
|
||||
})
|
||||
}
|
||||
|
||||
// 筛选内容展示
|
||||
const [showPopup, setshowPopup] = useState(false)
|
||||
const showSelctPopup = () => {
|
||||
setshowPopup(true)
|
||||
}
|
||||
|
||||
// 关闭筛选内容展示
|
||||
const closePopup = () => {
|
||||
setshowPopup(false)
|
||||
}
|
||||
|
||||
// 订单类型
|
||||
const [modeList, setModeList] = useState<any[]>([{ id: '', name: '不限' }, { id: 0, name: '大货' }, { id: 1, name: '剪版' }, { id: 2, name: '散剪' }])
|
||||
// 选择订单类型
|
||||
const handCheckMode = (item) => {
|
||||
modeList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setModeList([...modeList])
|
||||
setSearchField(e => ({ ...e, sale_mode: item.id }))
|
||||
}
|
||||
useEffect(() => {
|
||||
getStagelist()
|
||||
getTypeList()
|
||||
}, [])
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, name: e, size: 10 }))
|
||||
}, [])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearchField((val) => ({ ...val, size: 10 }))
|
||||
getOrderList()
|
||||
// 售后状态
|
||||
const [stageList, setStageList] = useState<any[]>([])
|
||||
const { fetchData: stageFetch } = mpenumreturnStage()
|
||||
const getStagelist = async() => {
|
||||
const res = await stageFetch()
|
||||
if (res.data) {
|
||||
res.data.list.unshift({ id: '', name: '不限', checked: false })
|
||||
res.data.list.map((it) => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
setStageList([...res.data.list])
|
||||
}
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: orderData.list, total: orderData.total, status: orderState.loading! })
|
||||
}, [orderData, orderState])
|
||||
}
|
||||
|
||||
//上拉加载数据
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (orderData.list.length < orderData.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearchField({ ...searchField, size })
|
||||
}
|
||||
}, [orderData])
|
||||
// 选择售后状态
|
||||
const handCheckStange = (item) => {
|
||||
stageList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setStageList([...stageList])
|
||||
setSearchField(val => ({ ...val, stage: item.id }))
|
||||
}
|
||||
|
||||
|
||||
//顶部栏
|
||||
const [TarBarList, setTarBarList] = useState<any[]>([{ id: 1, name: '售后申请', showBorder: true }, { id: 2, name: '申请记录', showBorder: false }])
|
||||
const handChose = (item) => {
|
||||
if (item.id === searchField.status) return
|
||||
TarBarList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.showBorder = true
|
||||
} else {
|
||||
it.showBorder = false
|
||||
}
|
||||
setTarBarList([...TarBarList])
|
||||
pageNum.current.page = 1
|
||||
setOrderData(() => ({ list: [], total: 0 }))
|
||||
setSearchField((val) => ({ ...val, size: 10, status: item.id }))
|
||||
// getOrderList()
|
||||
})
|
||||
// 退款类型
|
||||
const [typeList, setTypeList] = useState<any[]>([])
|
||||
const { fetchData: typeFetch } = mpenumreturnType()
|
||||
const getTypeList = async() => {
|
||||
const res = await typeFetch()
|
||||
if (res.data) {
|
||||
res.data.list.unshift({ id: '', name: '不限', checked: false })
|
||||
res.data.list.map((it) => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
setTypeList([...res.data.list])
|
||||
}
|
||||
}
|
||||
|
||||
//筛选内容展示
|
||||
const [showPopup, setshowPopup] = useState(false)
|
||||
const showSelctPopup = () => {
|
||||
setshowPopup(true)
|
||||
// 选择售后类型
|
||||
const handType = (item) => {
|
||||
typeList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setSearchField(val => ({ ...val, return_type: item.id }))
|
||||
}
|
||||
|
||||
// 是否不允许确认筛选
|
||||
const isDisabled = useMemo(() => {
|
||||
if (searchField.stage !== '不限'
|
||||
|| searchField.sale_mode !== '不限'
|
||||
|| searchField.return_type !== '不限'
|
||||
|| searchField.sale_start_time !== ''
|
||||
|| searchField.sale_end_time !== ''
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
//关闭筛选内容展示
|
||||
const closePopup = () => {
|
||||
setshowPopup(false)
|
||||
else {
|
||||
return true
|
||||
}
|
||||
}, [searchField])
|
||||
|
||||
//订单类型
|
||||
const [modeList, setModeList] = useState<any[]>([{ id: '', name: '不限' }, { id: 0, name: '大货' }, { id: 1, name: '剪版' }, { id: 2, name: '散剪' }])
|
||||
//选择订单类型
|
||||
const handCheckMode = (item) => {
|
||||
modeList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setModeList([...modeList])
|
||||
setSearchField((e) => ({ ...e, sale_mode: item.id, }))
|
||||
// 重置
|
||||
const handReset = () => {
|
||||
const arrOne = resetArr(modeList)
|
||||
setModeList([...arrOne])
|
||||
const arrTwo = resetArr(typeList)
|
||||
setTypeList([...arrTwo])
|
||||
const arrThree = resetArr(stageList)
|
||||
setStageList([...arrThree])
|
||||
setSearchField(e => ({
|
||||
...e,
|
||||
sale_mode: '不限',
|
||||
stage: '不限',
|
||||
return_type: '不限',
|
||||
sale_start_time: '',
|
||||
sale_end_time: '',
|
||||
}))
|
||||
setStart(myDate.toLocaleDateString())
|
||||
getOrderList()
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
// 数组重置
|
||||
const resetArr = (arr) => {
|
||||
arr.map((it) => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
return arr
|
||||
}
|
||||
|
||||
// 展示时间筛选
|
||||
const [showTime, setShowTime] = useState(false)
|
||||
// 关闭时间筛选
|
||||
const handClose = () => {
|
||||
setShowTime(false)
|
||||
}
|
||||
let myDate = new Date()
|
||||
const [start, setStart] = useState<any>(myDate.toLocaleDateString())
|
||||
const [end, setEnd] = useState<any>('')
|
||||
// 选择时间
|
||||
const handTime = (eq) => {
|
||||
// 直接进来点确定的时候做处理
|
||||
if (Object.keys(eq).length === 0) {
|
||||
const obj = {
|
||||
start: '',
|
||||
end: '',
|
||||
}
|
||||
obj.start = `${dayjs(new Date(`${myDate?.toLocaleDateString()} ` + '00:00:00')).format('YYYY-MM-DD')} 00:00:00`,
|
||||
obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`
|
||||
eq.value = obj
|
||||
}
|
||||
useEffect(() => {
|
||||
getStagelist()
|
||||
getTypeList()
|
||||
}, [])
|
||||
setSearchField(val => ({ ...val, sale_start_time: eq?.value?.start, sale_end_time: eq?.value?.end, size: 10 }))
|
||||
setStart(eq?.value?.start)
|
||||
setEnd(eq?.value?.end)
|
||||
setShowTime(false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//售后状态
|
||||
const [stageList, setStageList] = useState<any[]>([])
|
||||
const { fetchData: stageFetch } = mpenumreturnStage()
|
||||
const getStagelist = async () => {
|
||||
const res = await stageFetch()
|
||||
if (res.data) {
|
||||
res.data.list.unshift({ id: '', name: '不限', checked: false })
|
||||
res.data.list.map(it => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
setStageList([...res.data.list])
|
||||
|
||||
}
|
||||
const timeArea = useMemo(() => {
|
||||
if (end !== '') {
|
||||
return `${start} ` + '-' + ` ${end}`
|
||||
}
|
||||
|
||||
//选择售后状态
|
||||
const handCheckStange = (item) => {
|
||||
stageList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setStageList([...stageList])
|
||||
setSearchField((val) => ({ ...val, stage: item.id }))
|
||||
else {
|
||||
return '自定义起始时间'
|
||||
}
|
||||
}, [end])
|
||||
|
||||
const handSure = () => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField(val => ({ ...val, size: 10 }))
|
||||
setshowPopup?.(false)
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setSearchField(searchField)
|
||||
}, [searchField])
|
||||
|
||||
//退款类型
|
||||
const [typeList, setTypeList] = useState<any[]>([])
|
||||
const { fetchData: typeFetch } = mpenumreturnType()
|
||||
const getTypeList = async () => {
|
||||
const res = await typeFetch()
|
||||
if (res.data) {
|
||||
res.data.list.unshift({ id: '', name: '不限', checked: false })
|
||||
res.data.list.map(it => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
setTypeList([...res.data.list])
|
||||
}
|
||||
}
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const [ItemInfo, setItemInfo] = useState<any>({})
|
||||
const handSee = (e, item) => {
|
||||
e.stopPropagation()
|
||||
setItemInfo(item)
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
//选择售后类型
|
||||
const handType = (item) => {
|
||||
typeList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setSearchField((val) => ({ ...val, return_type: item.id }))
|
||||
}
|
||||
|
||||
//是否不允许确认筛选
|
||||
const isDisabled = useMemo(() => {
|
||||
if (searchField.stage !== '不限' ||
|
||||
searchField.sale_mode !== '不限' ||
|
||||
searchField.return_type !== '不限' ||
|
||||
searchField.sale_start_time !== '' ||
|
||||
searchField.sale_end_time !== ''
|
||||
) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}, [searchField])
|
||||
|
||||
|
||||
//重置
|
||||
const handReset = () => {
|
||||
const arrOne = resetArr(modeList)
|
||||
setModeList([...arrOne])
|
||||
const arrTwo = resetArr(typeList)
|
||||
setTypeList([...arrTwo])
|
||||
const arrThree = resetArr(stageList)
|
||||
setStageList([...arrThree])
|
||||
setSearchField((e) => ({
|
||||
...e,
|
||||
sale_mode: '不限',
|
||||
stage: '不限',
|
||||
return_type: '不限',
|
||||
sale_start_time: '',
|
||||
sale_end_time: '',
|
||||
}))
|
||||
setStart(myDate.toLocaleDateString())
|
||||
getOrderList()
|
||||
setEnd('')
|
||||
}
|
||||
|
||||
//数组重置
|
||||
const resetArr = (arr) => {
|
||||
arr.map(it => {
|
||||
it.checked = false
|
||||
return it
|
||||
})
|
||||
return arr
|
||||
}
|
||||
|
||||
//展示时间筛选
|
||||
const [showTime, setShowTime] = useState(false)
|
||||
//关闭时间筛选
|
||||
const handClose = () => {
|
||||
setShowTime(false)
|
||||
}
|
||||
let myDate = new Date();
|
||||
const [start, setStart] = useState<any>(myDate.toLocaleDateString())
|
||||
const [end, setEnd] = useState<any>('')
|
||||
//选择时间
|
||||
const handTime = (eq) => {
|
||||
//直接进来点确定的时候做处理
|
||||
if (Object.keys(eq).length === 0) {
|
||||
let obj = {
|
||||
start: '',
|
||||
end: ''
|
||||
}
|
||||
obj.start = `${dayjs(new Date(myDate?.toLocaleDateString() + ' ' + '00:00:00',)).format('YYYY-MM-DD')} 00:00:00`,
|
||||
obj.end = `${dayjs(new Date(obj?.start)).add(1, 'day').format('YYYY-MM-DD')} 00:00:00`
|
||||
eq.value = obj
|
||||
}
|
||||
setSearchField((val) => ({ ...val, sale_start_time: eq?.value?.start, sale_end_time: eq?.value?.end, size: 10 }))
|
||||
setStart(eq?.value?.start)
|
||||
setEnd(eq?.value?.end)
|
||||
setShowTime(false)
|
||||
}
|
||||
|
||||
const timeArea = useMemo(() => {
|
||||
if (end !== '') {
|
||||
return start + ' ' + '-' + ' ' + end
|
||||
} else {
|
||||
return '自定义起始时间'
|
||||
}
|
||||
}, [end])
|
||||
|
||||
const handSure = () => {
|
||||
pageNum.current.page = 1
|
||||
setSearchField((val) => ({ ...val, size: 10 }))
|
||||
setshowPopup?.(false)
|
||||
getOrderList()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setSearchField(searchField)
|
||||
}, [searchField])
|
||||
|
||||
|
||||
const [ShowCode, setShowCode] = useState(false)
|
||||
const [ItemInfo, setItemInfo] = useState<any>({})
|
||||
const handSee = (e, item) => {
|
||||
e.stopPropagation()
|
||||
setItemInfo(item)
|
||||
setShowCode(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View style={{ background: '#FFFFFF', paddingLeft: '20rpx', paddingBottom: '20rpx', position: 'sticky', top: '0', zIndex: '99' }}>
|
||||
<Search placeholder='搜索商品/名称/颜色/订单号' showBtn={false} changeOnSearch={getSearchData} >
|
||||
<View className={styles.flexBox} onClick={() => showSelctPopup()}>
|
||||
<IconFont name='icon-shaixuan' size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles['activeshaixuan']} />
|
||||
{/* <View className={classnames('iconfont', 'icon-shaixuan', !isDisabled ? styles.icon_shaixuan : styles.activeshaixuan)}></View> */}
|
||||
<View className={classnames(isDisabled ? styles.shaixuan : styles.activeshai)}>筛选</View>
|
||||
</View>
|
||||
</Search>
|
||||
return (
|
||||
<>
|
||||
<View style={{ background: '#FFFFFF', paddingLeft: '20rpx', paddingBottom: '20rpx', position: 'sticky', top: '0', zIndex: '99' }}>
|
||||
<Search placeholder="搜索商品/名称/颜色/订单号" showBtn={false} changeOnSearch={getSearchData} >
|
||||
<View className={styles.flexBox} onClick={() => showSelctPopup()}>
|
||||
<IconFont name="icon-shaixuan" size={35} color={!isDisabled ? '#0D7CFF' : ''} customClassName={styles.activeshaixuan} />
|
||||
{/* <View className={classnames('iconfont', 'icon-shaixuan', !isDisabled ? styles.icon_shaixuan : styles.activeshaixuan)}></View> */}
|
||||
<View className={classnames(isDisabled ? styles.shaixuan : styles.activeshai)}>筛选</View>
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
<Tabs list={TarBarList} handChose={item => handChose?.(item)}></Tabs>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<View key={item.id} className={styles.order_item_con}>
|
||||
<ItemList
|
||||
obj={item}
|
||||
key={index}
|
||||
handSee={e => handSee(e, item)}
|
||||
></ItemList>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
<View className={styles.kongboxTwo}></View>
|
||||
</View>
|
||||
<Popup title="筛选订单" show={showPopup} onClose={() => closePopup()}>
|
||||
<View className={styles.popupBox}>
|
||||
<ScrollView className={styles.scrllStyle} scrollY>
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>售后状态</View>
|
||||
<View className={styles.flexModebox}>
|
||||
{
|
||||
stageList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => { handCheckStange(item) }} className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<Tabs list={TarBarList} handChose={(item) => handChose?.(item)}></Tabs>
|
||||
<View className={styles.order_list}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{orderData?.list?.map((item, index) => {
|
||||
return (
|
||||
<View key={item.id} className={styles.order_item_con}>
|
||||
<ItemList
|
||||
obj={item}
|
||||
key={index}
|
||||
handSee={(e) => handSee(e, item)}
|
||||
></ItemList>
|
||||
</View>
|
||||
)
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
<View className={styles.kongboxTwo}></View>
|
||||
<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>
|
||||
</View>
|
||||
<Popup title={'筛选订单'} show={showPopup} onClose={() => closePopup()}>
|
||||
<View className={styles.popupBox}>
|
||||
<ScrollView className={styles.scrllStyle} scrollY>
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>售后状态</View>
|
||||
<View className={styles.flexModebox}>
|
||||
{
|
||||
stageList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => { handCheckStange(item) }} className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<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>
|
||||
</View>
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>退款类型</View>
|
||||
<View className={styles.flexModebox}>
|
||||
{
|
||||
typeList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => { handType(item) }} className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>售后时间</View>
|
||||
<View className={styles.timeBox2} onClick={() => { setShowTime(true) }}>{timeArea}
|
||||
<View className={styles.more}>
|
||||
{
|
||||
timeArea == '自定义起始时间' &&
|
||||
<IconFont name={'icon-chakanquanbukehu'} color={'#000000'} size={40} customClassName={styles['more']}></IconFont>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.safeBox}></View>
|
||||
</ScrollView>
|
||||
<View className={styles.bottomBox}>
|
||||
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button2 : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 确认</Button >
|
||||
</View>
|
||||
{/* <View className={styles.areaBox}></View> */}
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>退款类型</View>
|
||||
<View className={styles.flexModebox}>
|
||||
{
|
||||
typeList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => { handType(item) }} className={classnames(item.checked ? styles.activemodeBox : styles.modeBox)} key={index}>{item.name}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.thirdBox}>
|
||||
<View className={styles.thirdTopfont}>售后时间</View>
|
||||
<View className={styles.timeBox2} onClick={() => { setShowTime(true) }}>{timeArea}
|
||||
<View className={styles.more}>
|
||||
{
|
||||
timeArea == '自定义起始时间'
|
||||
&& <IconFont name="icon-chakanquanbukehu" color="#000000" size={40} customClassName={styles.more}></IconFont>
|
||||
}
|
||||
</View>
|
||||
</Popup>
|
||||
<TimePickerPopup
|
||||
start={start}
|
||||
end={end}
|
||||
showTime={showTime}
|
||||
closePopup={handClose}
|
||||
onSelectDate={(e) => handTime(e)}
|
||||
></TimePickerPopup>
|
||||
<RefundCodelist
|
||||
obj={ItemInfo}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
</>
|
||||
)
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.safeBox}></View>
|
||||
</ScrollView>
|
||||
<View className={styles.bottomBox}>
|
||||
|
||||
<Button className={styles.resetBox} onClick={() => { handReset() }}> 重置</Button >
|
||||
<Button className={classnames(isDisabled ? styles.button2 : styles.activeButton)} disabled={isDisabled} onClick={() => handSure()}> 确认</Button >
|
||||
</View>
|
||||
{/* <View className={styles.areaBox}></View> */}
|
||||
</View>
|
||||
</Popup>
|
||||
<TimePickerPopup
|
||||
start={start}
|
||||
end={end}
|
||||
showTime={showTime}
|
||||
closePopup={handClose}
|
||||
onSelectDate={e => handTime(e)}
|
||||
></TimePickerPopup>
|
||||
<RefundCodelist
|
||||
obj={ItemInfo}
|
||||
// picUrl={PicUrl}
|
||||
showPopup={ShowCode}
|
||||
popupClose={() => setShowCode(false)}
|
||||
></RefundCodelist>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -178,4 +178,3 @@ export const ReturnGoodsOrderForm = {
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { ArrangedForm, OrderForm, PaymentAmountForm, ReturnGoodsOrderForm } from './config'
|
||||
import { ProductRankApi, PurchaserRankApi, SaleOrderDataFormApi, SalesmanRankApi } from '@/api/statistic/saleStatistic'
|
||||
import { formatPriceDiv, setPriceUnit, dataUnit } from '@/common/format'
|
||||
import { dataUnit, formatPriceDiv, setPriceUnit } from '@/common/format'
|
||||
import { getFilterData } from '@/common/util'
|
||||
import Cell from '@/components/cell'
|
||||
import Divider from '@/components/Divider'
|
||||
@@ -8,19 +14,15 @@ import LayoutBlock from '@/components/layoutBlock'
|
||||
import SelectMarketingDepartment from '@/components/SelectMarketingDepartment'
|
||||
import SelectSaleRankingIndicators from '@/components/SelectSaleRankingIndicators'
|
||||
import SelectSaleType from '@/components/SelectSaleType'
|
||||
import SelectTimePicker, { ChangedValue } from '@/components/SelectTimePicker'
|
||||
import Table, { TablePropsType } from '@/components/table'
|
||||
import type { ChangedValue } from '@/components/SelectTimePicker'
|
||||
import SelectTimePicker from '@/components/SelectTimePicker'
|
||||
import type { TablePropsType } from '@/components/table'
|
||||
import Table from '@/components/table'
|
||||
import ToolTip from '@/components/toolTips'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import dayjs from 'dayjs'
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { OrderForm, ArrangedForm, PaymentAmountForm, ReturnGoodsOrderForm } from './config'
|
||||
import IconText from '@/components/iconText'
|
||||
import SelectGroup from '@/components/SelectGroup'
|
||||
|
||||
//处理金额(后端单位分,转元)
|
||||
// 处理金额(后端单位分,转元)
|
||||
const priceformat = (val: number) => {
|
||||
return dataUnit(val / 100)
|
||||
}
|
||||
@@ -28,7 +30,7 @@ const priceformat = (val: number) => {
|
||||
const defaultLimit = 10
|
||||
|
||||
const FilterTimeOptions = {
|
||||
'0': {
|
||||
0: {
|
||||
name: '今天',
|
||||
date_min: `${dayjs(new Date())
|
||||
.add(0, 'day')
|
||||
@@ -37,7 +39,7 @@ const FilterTimeOptions = {
|
||||
.add(1, 'day')
|
||||
.format('YYYY-MM-DD')} 00:00:00`,
|
||||
},
|
||||
'1': {
|
||||
1: {
|
||||
name: '昨日',
|
||||
date_min: `${dayjs(new Date())
|
||||
.add(-1, 'day')
|
||||
@@ -46,7 +48,7 @@ const FilterTimeOptions = {
|
||||
.add(0, 'day')
|
||||
.format('YYYY-MM-DD')} 00:00:00`,
|
||||
},
|
||||
'2': {
|
||||
2: {
|
||||
name: '近7日',
|
||||
date_min: `${dayjs(new Date())
|
||||
.add(-7, 'day')
|
||||
@@ -55,7 +57,7 @@ const FilterTimeOptions = {
|
||||
.add(0, 'day')
|
||||
.format('YYYY-MM-DD')} 00:00:00`,
|
||||
},
|
||||
'3': {
|
||||
3: {
|
||||
name: '近30日',
|
||||
date_min: `${dayjs(new Date())
|
||||
.add(-30, 'day')
|
||||
@@ -64,7 +66,7 @@ const FilterTimeOptions = {
|
||||
.add(0, 'day')
|
||||
.format('YYYY-MM-DD')} 00:00:00`,
|
||||
},
|
||||
'4': {
|
||||
4: {
|
||||
name: '近90日',
|
||||
date_min: `${dayjs(new Date())
|
||||
.add(-90, 'day')
|
||||
@@ -90,7 +92,7 @@ const saleStatistic = () => {
|
||||
getData()
|
||||
}, [saleType, saleDepartmentId, dateRange])
|
||||
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const res = await fetchData(
|
||||
getFilterData({
|
||||
sale_type: saleType,
|
||||
@@ -142,7 +144,8 @@ const saleStatistic = () => {
|
||||
// 全部
|
||||
if (saleType === -1) {
|
||||
setSaleType(null)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setSaleType(saleType)
|
||||
}
|
||||
}, [])
|
||||
@@ -152,7 +155,8 @@ const saleStatistic = () => {
|
||||
// 全部
|
||||
if (department === -1) {
|
||||
setSaleDepartmentId(null)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setSaleDepartmentId(department)
|
||||
}
|
||||
}, [])
|
||||
@@ -165,22 +169,22 @@ const saleStatistic = () => {
|
||||
<View className={styles.saleStatistic}>
|
||||
<View className={styles['saleStatistic--filterBar']}>
|
||||
<SelectGroup>
|
||||
<SelectSaleType onChange={onChangeSaleType} defaultValue={-1} onCloseOverlay={()=>true} ref={selectSaleTypeRef}></SelectSaleType>
|
||||
<SelectMarketingDepartment onChange={onChangeDepartment} onCloseOverlay={()=>true} ref={selectMarketingDepartmentRef}></SelectMarketingDepartment>
|
||||
<SelectTimePicker onChange={onChangeTimePicker} onCloseOverlay={()=>true} defaultValue='0' timeOptions={FilterTimeOptions} ref={selectTimePickerRef}></SelectTimePicker>
|
||||
<SelectSaleType onChange={onChangeSaleType} defaultValue={-1} onCloseOverlay={() => true} ref={selectSaleTypeRef}></SelectSaleType>
|
||||
<SelectMarketingDepartment onChange={onChangeDepartment} onCloseOverlay={() => true} ref={selectMarketingDepartmentRef}></SelectMarketingDepartment>
|
||||
<SelectTimePicker onChange={onChangeTimePicker} onCloseOverlay={() => true} defaultValue="0" timeOptions={FilterTimeOptions} ref={selectTimePickerRef}></SelectTimePicker>
|
||||
</SelectGroup>
|
||||
</View>
|
||||
<View className={styles['saleStatistic--content']}>
|
||||
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
|
||||
<View className='flex-row items-center'>
|
||||
<IconText iconName='icon-guanlidingdan' iconSize={32} svg text='订单' textClassName={styles.title}></IconText>
|
||||
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
|
||||
<View className="flex-row items-center">
|
||||
<IconText iconName="icon-guanlidingdan" iconSize={32} svg text="订单" textClassName={styles.title}></IconText>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<View className={styles.totalSummary}>
|
||||
<ToolTip placement='top' content={OrderForm.summary.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top" content={OrderForm.summary.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles['totalSummary--title']}>{OrderForm.summary.summaryTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
<View className={classnames(styles['totalSummary--current'], OrderForm.summary.value.cls)}>{OrderForm.summary.value.num}</View>
|
||||
@@ -194,29 +198,30 @@ const saleStatistic = () => {
|
||||
<Cell
|
||||
key={key}
|
||||
title={
|
||||
<ToolTip placement='top-start' content={value.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top-start" content={value.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles.title}>{value.cellTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36}></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36}></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
}
|
||||
desc={value.value.num}
|
||||
customDescClassName={value.value.cls}
|
||||
customClassName={styles['cell-desc']}></Cell>
|
||||
customClassName={styles['cell-desc']}
|
||||
></Cell>
|
||||
)
|
||||
})}
|
||||
</LayoutBlock>
|
||||
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
|
||||
<View className='flex-row items-center'>
|
||||
<IconText iconName='icon-guanlidingdan' iconSize={32} svg text='配布' textClassName={styles.title}></IconText>
|
||||
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
|
||||
<View className="flex-row items-center">
|
||||
<IconText iconName="icon-guanlidingdan" iconSize={32} svg text="配布" textClassName={styles.title}></IconText>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<View className={styles.totalSummary}>
|
||||
<ToolTip placement='top' content={ArrangedForm.summary.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top" content={ArrangedForm.summary.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles['totalSummary--title']}>{ArrangedForm.summary.summaryTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
<View className={classnames(styles['totalSummary--current'], ArrangedForm.summary.value.cls)}>{ArrangedForm.summary.value.num}</View>
|
||||
@@ -230,31 +235,32 @@ const saleStatistic = () => {
|
||||
<Cell
|
||||
key={key}
|
||||
title={
|
||||
<ToolTip placement='top-start' content={value.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top-start" content={value.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles.title}>{value.cellTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36}></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36}></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
}
|
||||
desc={value.value.num}
|
||||
customDescClassName={value.value.cls}
|
||||
customClassName={styles['cell-desc']}></Cell>
|
||||
{((index + 1) % 3 === 0 && (index + 1) !== 9) ? <Divider direction='horizontal' customStyles={{ margin: '10rpx 0' }}></Divider> : null}
|
||||
customClassName={styles['cell-desc']}
|
||||
></Cell>
|
||||
{((index + 1) % 3 === 0 && (index + 1) !== 9) ? <Divider direction="horizontal" customStyles={{ margin: '10rpx 0' }}></Divider> : null}
|
||||
</>
|
||||
)
|
||||
})}
|
||||
</LayoutBlock>
|
||||
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
|
||||
<View className='flex-row items-center'>
|
||||
<IconText iconName='icon-daikuan' iconSize={32} svg text='货款' textClassName={styles.title}></IconText>
|
||||
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
|
||||
<View className="flex-row items-center">
|
||||
<IconText iconName="icon-daikuan" iconSize={32} svg text="货款" textClassName={styles.title}></IconText>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<View className={styles.totalSummary}>
|
||||
<ToolTip placement='top' content={PaymentAmountForm.summary.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top" content={PaymentAmountForm.summary.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles['totalSummary--title']}>{PaymentAmountForm.summary.summaryTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
<View className={classnames(styles['totalSummary--current'], PaymentAmountForm.summary.value.cls)}>{PaymentAmountForm.summary.value.num}</View>
|
||||
@@ -264,29 +270,30 @@ const saleStatistic = () => {
|
||||
<Cell
|
||||
key={key}
|
||||
title={
|
||||
<ToolTip placement='top-start' content={value.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top-start" content={value.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles.title}>{value.cellTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36}></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36}></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
}
|
||||
desc={value.value.num}
|
||||
customDescClassName={value.value.cls}
|
||||
customClassName={styles['cell-desc']}></Cell>
|
||||
customClassName={styles['cell-desc']}
|
||||
></Cell>
|
||||
)
|
||||
})}
|
||||
</LayoutBlock>
|
||||
<LayoutBlock circle flexDirection='col' customStyle={{padding: '20rpx 32rpx'}}>
|
||||
<View className='flex-row items-center'>
|
||||
<IconText iconName='icon-tuikuan' iconSize={32} svg text='退货' textClassName={styles.title}></IconText>
|
||||
<LayoutBlock circle flexDirection="col" customStyle={{ padding: '20rpx 32rpx' }}>
|
||||
<View className="flex-row items-center">
|
||||
<IconText iconName="icon-tuikuan" iconSize={32} svg text="退货" textClassName={styles.title}></IconText>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0 ' }}></Divider>
|
||||
<View className={styles.totalSummary}>
|
||||
<ToolTip placement='top' content={ReturnGoodsOrderForm.summary.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top" content={ReturnGoodsOrderForm.summary.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles['totalSummary--title']}>{ReturnGoodsOrderForm.summary.summaryTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36} color='#707070'></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36} color="#707070"></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
<View className={classnames(styles['totalSummary--current'], ReturnGoodsOrderForm.summary.value.cls)}>
|
||||
@@ -298,16 +305,17 @@ const saleStatistic = () => {
|
||||
<Cell
|
||||
key={key}
|
||||
title={
|
||||
<ToolTip placement='top-start' content={value.tips}>
|
||||
<View className='flex-row items-center'>
|
||||
<ToolTip placement="top-start" content={value.tips}>
|
||||
<View className="flex-row items-center">
|
||||
<Text className={styles.title}>{value.cellTitle}</Text>
|
||||
<Iconfont name='icon-tishi' size={36}></Iconfont>
|
||||
<Iconfont name="icon-tishi" size={36}></Iconfont>
|
||||
</View>
|
||||
</ToolTip>
|
||||
}
|
||||
desc={value.value.num}
|
||||
customDescClassName={value.value.cls}
|
||||
customClassName={styles['cell-desc']}></Cell>
|
||||
customClassName={styles['cell-desc']}
|
||||
></Cell>
|
||||
)
|
||||
})}
|
||||
</LayoutBlock>
|
||||
@@ -317,9 +325,9 @@ const saleStatistic = () => {
|
||||
)
|
||||
}
|
||||
|
||||
//需要传进来的数据示例
|
||||
// 需要传进来的数据示例
|
||||
|
||||
//需要传进来的表头数据示例
|
||||
// 需要传进来的表头数据示例
|
||||
const productRankingColumns = [
|
||||
{
|
||||
key: 'index',
|
||||
@@ -352,7 +360,7 @@ const productRankingColumns = [
|
||||
},
|
||||
]
|
||||
|
||||
//需要传进来的表头数据示例
|
||||
// 需要传进来的表头数据示例
|
||||
const purchaserRankingColumns = [
|
||||
{
|
||||
key: 'index',
|
||||
@@ -385,7 +393,7 @@ const purchaserRankingColumns = [
|
||||
},
|
||||
]
|
||||
|
||||
//需要传进来的表头数据示例
|
||||
// 需要传进来的表头数据示例
|
||||
const salesmanRankingColumns = [
|
||||
{
|
||||
key: 'index',
|
||||
@@ -440,14 +448,14 @@ interface RankingBlockPropsType {
|
||||
date_max?: string
|
||||
}
|
||||
// 销售排行
|
||||
const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
const RankingBlock = memo<RankingBlockPropsType>((props) => {
|
||||
const { saleType, saleDepartmentId, date_min, date_max } = props
|
||||
|
||||
const { fetchData: fetchProductRank } = ProductRankApi()
|
||||
const { fetchData: fetchPurchaserRank } = PurchaserRankApi()
|
||||
const { fetchData: fetchSalesmanRank } = SalesmanRankApi()
|
||||
|
||||
let [limit, setLimit] = useState(defaultLimit)
|
||||
const [limit, setLimit] = useState(defaultLimit)
|
||||
|
||||
const [indicator, setIndicator] = useState<number | null>(null)
|
||||
|
||||
@@ -456,22 +464,23 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
console.log('indicators', indicators)
|
||||
if (indicators === -1) {
|
||||
setIndicator(null)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setIndicator(indicators)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const [currentKey, setCurrentKey] = useState(tabsConfig[0].key)
|
||||
|
||||
const handleClickTab = event => {
|
||||
const handleClickTab = (event) => {
|
||||
const key = event.target.dataset.key
|
||||
if (key === currentKey) return
|
||||
if (key === currentKey) { return }
|
||||
setCurrentKey(key)
|
||||
setLimit(defaultLimit)
|
||||
}
|
||||
|
||||
const getData = useCallback(
|
||||
async (tabKey: number) => {
|
||||
async(tabKey: number) => {
|
||||
let res: any
|
||||
const payload = {
|
||||
limit,
|
||||
@@ -483,9 +492,11 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
}
|
||||
if (tabKey === 0) {
|
||||
res = await fetchProductRank(getFilterData(payload))
|
||||
} else if (tabKey === 1) {
|
||||
}
|
||||
else if (tabKey === 1) {
|
||||
res = await fetchPurchaserRank(getFilterData(payload))
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res = await fetchSalesmanRank(getFilterData(payload))
|
||||
}
|
||||
if (res.data) {
|
||||
@@ -504,7 +515,8 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
total: res.data.total,
|
||||
},
|
||||
}))
|
||||
} else if (tabKey === 1) {
|
||||
}
|
||||
else if (tabKey === 1) {
|
||||
setCurrentTable(() => ({
|
||||
columns: purchaserRankingColumns,
|
||||
dataSource: {
|
||||
@@ -518,7 +530,8 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
total: res.data.total,
|
||||
},
|
||||
}))
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setCurrentTable(() => ({
|
||||
columns: salesmanRankingColumns,
|
||||
dataSource: {
|
||||
@@ -555,20 +568,20 @@ const RankingBlock = memo<RankingBlockPropsType>(props => {
|
||||
return (
|
||||
<>
|
||||
{/* 销售排行 */}
|
||||
<LayoutBlock circle flexDirection='col' customStyle={{ padding: 0 }}>
|
||||
<LayoutBlock circle flexDirection="col" customStyle={{ padding: 0 }}>
|
||||
<View className={classnames(styles.rankingIndicatorTitle, 'flex-row justify-between')} style={{ position: 'relative' }}>
|
||||
<View className='flex-row items-center'>
|
||||
<Iconfont name='icon-paiming' size={32}></Iconfont>
|
||||
<View className="flex-row items-center">
|
||||
<Iconfont name="icon-paiming" size={32}></Iconfont>
|
||||
<Text className={styles.title}>销售排行</Text>
|
||||
</View>
|
||||
<View style={{ width: '90px' }}>
|
||||
<SelectSaleRankingIndicators onChange={onChangeIndicators} dropDownStyle={{padding: '16rpx 0'}}></SelectSaleRankingIndicators>
|
||||
<SelectSaleRankingIndicators onChange={onChangeIndicators} dropDownStyle={{ padding: '16rpx 0' }}></SelectSaleRankingIndicators>
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ padding: '0 32rpx' }}>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '10rpx 0 20rpx 0' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '10rpx 0 20rpx 0' }}></Divider>
|
||||
<View className={styles.rankingTabs} onClick={handleClickTab}>
|
||||
{tabsConfig.map(item => {
|
||||
{tabsConfig.map((item) => {
|
||||
return (
|
||||
<View data-key={item.key} className={classnames(styles.rankingTab, item.key === currentKey ? styles.active : '')} key={item.key}>
|
||||
{item.name}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '选择业务员',
|
||||
navigationBarTitleText: '选择业务员',
|
||||
}
|
||||
|
||||
+133
-136
@@ -1,151 +1,148 @@
|
||||
import { View, ScrollView, Image, 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, Image, Input, ScrollView, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Search from '@/components/search'
|
||||
import { mpenumsaleUserlist } from '@/api/order'
|
||||
import { useDidShow } from '@tarojs/taro';
|
||||
import Taro from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
|
||||
export default () => {
|
||||
const [search, setSearch] = useState({
|
||||
name: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = mpenumsaleUserlist()
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
saleuserId: null,
|
||||
saleuserName: '',
|
||||
})
|
||||
|
||||
const [search, setSearch] = useState({
|
||||
name: null,
|
||||
page: 1,
|
||||
size: 10,
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch(e => ({ ...e, name: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.name === '') {
|
||||
setSearch(e => ({ ...e, name: null }))
|
||||
}
|
||||
if (search.name !== '') { getCuss() }
|
||||
}, [search])
|
||||
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch(e => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
const getCuss = async() => {
|
||||
const res = await clitentFetch({ name: search.name === null ? '' : search.name, page: search.page, size: search.size })
|
||||
if (router?.params.clientId) {
|
||||
res.data.list.map((item) => {
|
||||
if (item.id == router?.params.clientId) {
|
||||
item.checked = true
|
||||
}
|
||||
else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
// 选择业务员
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.checked = true
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
const [clentList, setClientlist] = useState<{ list: any[]; total: number }>({ list: [], total: 0 })
|
||||
|
||||
const { fetchData: clitentFetch, state: orderState } = mpenumsaleUserlist()
|
||||
//数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: clentList.list, total: clentList.total, status: orderState.loading! })
|
||||
}, [clentList, orderState])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
saleuserId: null,
|
||||
saleuserName: ''
|
||||
const pages = Taro.getCurrentPages() // 获取当前的页面栈
|
||||
const prevPage = pages[pages.length - 2]
|
||||
prevPage.setData({ // 设置上一个页面的值
|
||||
saleuserId: item.id,
|
||||
saleuserName: item.name,
|
||||
})
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((eq) => {
|
||||
pageNum.current.page = 1
|
||||
setClientlist(() => ({ list: [], total: 0 }))
|
||||
setSearch((e) => ({ ...e, name: eq, size: 10 }))
|
||||
}, [])
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (search.name === '') {
|
||||
setSearch((e) => ({ ...e, name: null }))
|
||||
}
|
||||
if (search.name !== '') getCuss()
|
||||
}, [search])
|
||||
|
||||
//上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
const getScrolltolower = useCallback(() => {
|
||||
if (clentList.list.length < clentList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch((e) => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [clentList])
|
||||
|
||||
//列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
const getRefresherRefresh = async () => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch((val) => ({ ...val, size: 10 }))
|
||||
setClientlist(e => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
setclientObj(item)
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.saleuserId !== null) {
|
||||
setclientObj(clientObj)
|
||||
}
|
||||
const getCuss = async () => {
|
||||
let res = await clitentFetch({ name: search.name === null ? '' : search.name, page: search.page, size: search.size })
|
||||
if (router?.params.clientId) {
|
||||
res.data.list.map(item => {
|
||||
if (item.id == router?.params.clientId) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
setClientlist((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
else {
|
||||
const pages = Taro.getCurrentPages() // 获取当前的页面栈
|
||||
const prevPage = pages[pages.length - 2]
|
||||
prevPage.setData({ // 设置上一个页面的值
|
||||
saleuserId: '',
|
||||
saleuserName: '',
|
||||
})
|
||||
}
|
||||
//选择业务员
|
||||
const selectClient = (item) => {
|
||||
clentList.list.map(it => {
|
||||
if (item.id === it.id) {
|
||||
it.checked = true
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({ //设置上一个页面的值
|
||||
saleuserId: item.id,
|
||||
saleuserName: item.name
|
||||
});
|
||||
setClientlist((e) => ({ ...e, list: clentList?.list, total: clentList?.total }))
|
||||
setclientObj(item)
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
if (clientObj?.saleuserId !== null) {
|
||||
setclientObj(clientObj)
|
||||
} else {
|
||||
let pages = Taro.getCurrentPages(); // 获取当前的页面栈
|
||||
let prevPage = pages[pages.length - 2];
|
||||
prevPage.setData({ //设置上一个页面的值
|
||||
saleuserId: '',
|
||||
saleuserName: '',
|
||||
});
|
||||
}
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
<View className={styles.searchBox}>
|
||||
<View className={styles.two}>
|
||||
<Search placeholder='请输入业务员名称' showBtn={false} changeOnSearch={getSearchData} />
|
||||
</View>
|
||||
|
||||
</View>
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled={true}
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.name}</View>
|
||||
<View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.woker}>{item.sale_user_name}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
|
||||
}, [clientObj])
|
||||
return (
|
||||
<View className={styles.cussBox}>
|
||||
<View className={styles.searchBox}>
|
||||
<View className={styles.two}>
|
||||
<Search placeholder="请输入业务员名称" showBtn={false} changeOnSearch={getSearchData} />
|
||||
</View>
|
||||
)
|
||||
|
||||
</View>
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrolltolower}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
{
|
||||
clentList.list.map((item, index) => {
|
||||
return (
|
||||
<View className={classnames(item.checked ? styles.acticveitemBox : styles.itemBox)} key={index} onClick={() => { selectClient(item) }}>
|
||||
<View className={styles.cussName}>{item.name}</View>
|
||||
<View className={styles.phone}>{item.phone}</View>
|
||||
<View className={styles.woker}>{item.sale_user_name}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,44 +1,42 @@
|
||||
import { View, Image } from '@tarojs/components'
|
||||
import React, { useCallback, memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from "../goods/index.module.scss"
|
||||
import LabAndImg from "@/components/LabAndImg"
|
||||
import { Image, View } from '@tarojs/components'
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from '../goods/index.module.scss'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
|
||||
const Goods = (props: any) => {
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => props?.clickItem?.()}>
|
||||
{
|
||||
props.data?.texture_url === '' && <>
|
||||
|
||||
export default memo((props: any) => {
|
||||
|
||||
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.texture_url }
|
||||
}, [])
|
||||
return (
|
||||
<View className={styles.itemBox} onClick={() => props?.clickItem?.()}>
|
||||
{
|
||||
props.data?.texture_url === '' && <>
|
||||
|
||||
<View className={styles.picBox}>
|
||||
<Image className={styles.pic} mode={'aspectFill'} src={'https://test.cdn.zzfzyc.com/mall/no_img.png'}></Image>
|
||||
<View className={styles.posBox}>{props.data?.product_color_count}色</View>
|
||||
</View>
|
||||
<View className={styles.picBox}>
|
||||
<Image className={styles.pic} mode="aspectFill" src="https://test.cdn.zzfzyc.com/mall/no_img.png"></Image>
|
||||
<View className={styles.posBox}>{props.data?.product_color_count}色</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
{
|
||||
props.data?.texture_url !== ''
|
||||
&& <>
|
||||
<View className={styles.leftBox}>
|
||||
<LabAndImg value={labAndImgObj(props.data)} />
|
||||
{/* <Image className={styles.pic} mode={'aspectFill'} src={props.data?.picUrl}></Image> */}
|
||||
<View className={styles.posBox}>{props.data?.product_color_count}色</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
{
|
||||
props.data?.texture_url !== '' &&
|
||||
<>
|
||||
<View className={styles.leftBox}>
|
||||
<LabAndImg value={labAndImgObj(props.data)} />
|
||||
{/* <Image className={styles.pic} mode={'aspectFill'} src={props.data?.picUrl}></Image> */}
|
||||
<View className={styles.posBox}>{props.data?.product_color_count}色</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
<View className={styles.rightBox}>
|
||||
<View className={styles.productName}>{props.data?.code}#{props.data?.name}</View>
|
||||
<View className={styles.tips}>{props.data?.component}</View>
|
||||
<View className={styles.flexTag}>
|
||||
<View className={styles.tagOne}>{props.data?.width}</View>
|
||||
<View className={styles.tagTwo}>{props.data?.weight_density}</View>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
<View className={styles.rightBox}>
|
||||
<View className={styles.productName}>{props.data?.code}#{props.data?.name}</View>
|
||||
<View className={styles.tips}>{props.data?.component}</View>
|
||||
<View className={styles.flexTag}>
|
||||
<View className={styles.tagOne}>{props.data?.width}</View>
|
||||
<View className={styles.tagTwo}>{props.data?.weight_density}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
export default memo(Goods)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default {
|
||||
navigationBarTitleText: '搜索',
|
||||
navigationBarTitleText: '搜索',
|
||||
}
|
||||
|
||||
+399
-399
@@ -1,427 +1,427 @@
|
||||
import { View } from '@tarojs/components'
|
||||
import React, { useCallback, memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import Search from '@/components/search'
|
||||
import styles from "./index.module.scss"
|
||||
import classnames from "classnames";
|
||||
import Empty from '@/components/empty'
|
||||
import Taro, { useDidShow } from '@tarojs/taro';
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import Goods from './components/goods'
|
||||
import { mpproductlist } from "@/api/search"
|
||||
import { debounce } from "@/common/util";
|
||||
import Search from '@/components/search'
|
||||
import Empty from '@/components/empty'
|
||||
import { mpproductlist } from '@/api/search'
|
||||
import { debounce, getFilterData } from '@/common/util'
|
||||
import ShopCart from '@/components/shoppingCart'
|
||||
import {
|
||||
mpproductcolorlist,
|
||||
mpshoppingCartproductColorlist,
|
||||
mpsearchHistorylist,
|
||||
mpsearchHistory
|
||||
} from "@/api/order"
|
||||
import { getFilterData } from '@/common/util'
|
||||
import { ClientListApi } from '@/api/order'
|
||||
ClientListApi,
|
||||
mpproductcolorlist,
|
||||
mpsearchHistory,
|
||||
mpsearchHistorylist
|
||||
, mpshoppingCartproductColorlist,
|
||||
} from '@/api/order'
|
||||
|
||||
export default memo(() => {
|
||||
const SearchPage = () => {
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: -1,
|
||||
clientName: '',
|
||||
})
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getClient()
|
||||
}, [])
|
||||
|
||||
const [clientObj, setclientObj] = useState({
|
||||
clientId: -1,
|
||||
clientName: ''
|
||||
// 获取客户
|
||||
const [clienList, setclienList] = useState<any[]>([])
|
||||
const { fetchData: listFetchData } = ClientListApi()
|
||||
const getClient = async() => {
|
||||
const res = await listFetchData({
|
||||
page: 1, size: 10,
|
||||
})
|
||||
|
||||
//获取客户
|
||||
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]; // 获取当前页面
|
||||
//判断是否有跳转选择客户
|
||||
if (currPage.data?.clientId && currPage.data?.clientId !== '') {
|
||||
setclientObj({
|
||||
clientId: currPage.data?.clientId,
|
||||
clientName: currPage.data?.clientName,
|
||||
})
|
||||
setSearchObj((val) => ({ ...val, purchaser_id: currPage.data?.clientId }))
|
||||
}
|
||||
//默认客户
|
||||
if (currPage.data?.clientId == null) {
|
||||
setclientObj({
|
||||
clientId: clienList.length > 0 ? clienList[0]?.id : - 1,
|
||||
clientName: clienList.length > 0 ? clienList[0]?.name : '',
|
||||
})
|
||||
}
|
||||
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])
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getClient()
|
||||
}, [])
|
||||
|
||||
//选择的类型
|
||||
const [typeList, setTypeList] = useState<any[]>([{ id: 0, name: '大货', checked: true }, { id: 1, name: '剪版', checked: false }, { id: 2, name: '散剪', checked: false }])
|
||||
const [goodList, setGoodlist] = useState<any[]>([])
|
||||
const onj = JSON.parse(Taro.getStorageSync('userInfo'))
|
||||
const [search, setSearchObj] = useState({
|
||||
modeId: 0,
|
||||
goodsId: null,
|
||||
code_or_name: '',
|
||||
physical_warehouse: onj.physical_warehouse,
|
||||
purchaser_id: -1
|
||||
const onj = JSON.parse(Taro.getStorageSync('userInfo'))
|
||||
const [search, setSearchObj] = useState({
|
||||
modeId: 0,
|
||||
goodsId: null,
|
||||
code_or_name: '',
|
||||
physical_warehouse: onj.physical_warehouse,
|
||||
purchaser_id: -1,
|
||||
})
|
||||
|
||||
useDidShow(() => {
|
||||
// 获取选择的客户
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
// 判断是否有跳转选择客户
|
||||
if (currPage.data?.clientId && currPage.data?.clientId !== '') {
|
||||
setclientObj({
|
||||
clientId: currPage.data?.clientId,
|
||||
clientName: currPage.data?.clientName,
|
||||
})
|
||||
setSearchObj(val => ({ ...val, purchaser_id: currPage.data?.clientId }))
|
||||
}
|
||||
// 默认客户
|
||||
if (currPage.data?.clientId == null) {
|
||||
setclientObj({
|
||||
clientId: clienList.length > 0 ? clienList[0]?.id : -1,
|
||||
clientName: clienList.length > 0 ? clienList[0]?.name : '',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 选择的类型
|
||||
const [typeList, setTypeList] = useState<any[]>([{ id: 0, name: '大货', checked: true }, { id: 1, name: '剪版', checked: false }, { id: 2, name: '散剪', checked: false }])
|
||||
const [goodList, setGoodlist] = useState<any[]>([])
|
||||
|
||||
const [showShopCart, setShowShopCart] = useState(false)
|
||||
|
||||
// 获取商品
|
||||
const { fetchData: colorlistFetch } = mpproductcolorlist()
|
||||
const getGoodList = async() => {
|
||||
const res = await colorlistFetch({ product_id: search.goodsId, sale_mode: search.modeId, code_or_name: search.code_or_name, physical_warehouse: search?.physical_warehouse, purchaser_id: clientObj?.clientId })
|
||||
res.data.list.map((item) => {
|
||||
item.showInput = false
|
||||
if (search.modeId == 0) {
|
||||
item.nums = 1
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
item.buyNums = 3
|
||||
}
|
||||
return item
|
||||
})
|
||||
const [showShopCart, setShowShopCart] = useState(false)
|
||||
setGoodlist([...res.data.list])
|
||||
}
|
||||
|
||||
// 监听选择的类型
|
||||
useEffect(() => {
|
||||
setSearchObj(search)
|
||||
if (search.goodsId) { getGoodList() }
|
||||
}, [search])
|
||||
|
||||
//监听选择的类型
|
||||
useEffect(() => {
|
||||
setSearchObj(search)
|
||||
if (search.goodsId) getGoodList()
|
||||
}, [search])
|
||||
|
||||
|
||||
//获取商品
|
||||
const { fetchData: colorlistFetch } = mpproductcolorlist()
|
||||
const getGoodList = async () => {
|
||||
const res = await colorlistFetch({ product_id: search.goodsId, sale_mode: search.modeId, code_or_name: search.code_or_name, physical_warehouse: search?.physical_warehouse, purchaser_id: clientObj?.clientId })
|
||||
res.data.list.map((item) => {
|
||||
item.showInput = false
|
||||
if (search.modeId == 0) {
|
||||
item.nums = 1
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
item.buyNums = 3
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...res.data.list])
|
||||
// 加入购物车
|
||||
const { fetchData: preViewFetch } = mpshoppingCartproductColorlist()
|
||||
const handSure = async() => {
|
||||
const arr = goodList.filter((item) => {
|
||||
return item.showInput
|
||||
})
|
||||
const list: any[] = []
|
||||
arr.forEach((it) => {
|
||||
list.push({
|
||||
roll: search.modeId === 0 ? it.nums : 0,
|
||||
length: search.modeId !== 0 ? it.nums * 100 : 0,
|
||||
product_color_id: Number(it.id),
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: clientObj.clientId,
|
||||
sale_mode: search.modeId,
|
||||
color_list: list,
|
||||
sale_offect: 0,
|
||||
}
|
||||
const res = await preViewFetch(getFilterData(query))
|
||||
Taro.showLoading({
|
||||
mask: true,
|
||||
title: '请稍等...',
|
||||
})
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: '加入成功',
|
||||
duration: 2000,
|
||||
})
|
||||
setShowShopCart(false)
|
||||
goodList.map((item) => {
|
||||
item.showInput = false
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
console.log(search, '000000.0.0.')
|
||||
Taro.hideLoading()
|
||||
}
|
||||
else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//加入购物车
|
||||
const { fetchData: preViewFetch, } = mpshoppingCartproductColorlist()
|
||||
const handSure = async () => {
|
||||
const arr = goodList.filter(item => {
|
||||
return item.showInput
|
||||
})
|
||||
const list: any[] = []
|
||||
arr.forEach(it => {
|
||||
list.push({
|
||||
roll: search.modeId === 0 ? it.nums : 0,
|
||||
length: search.modeId !== 0 ? it.nums * 100 : 0,
|
||||
product_color_id: Number(it.id)
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: clientObj.clientId,
|
||||
sale_mode: search.modeId,
|
||||
color_list: list,
|
||||
sale_offect: 0
|
||||
// 点击输入框的加
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
// if (it.nums > item.buyNums) {
|
||||
it.nums++
|
||||
// }
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchDataInput = useCallback((eq) => {
|
||||
setSearchObj(e => ({ ...e, code_or_name: eq }))
|
||||
}, [])
|
||||
|
||||
const [goodObj, setGoodsobj] = useState({})
|
||||
const ShopCartRef = useRef<any>()
|
||||
// 点击对应商品显示购物车
|
||||
const showCart = async(item) => {
|
||||
setSearchObj(e => ({ ...e, goodsId: item.id, purchaser_id: clientObj?.clientId }))
|
||||
setShowShopCart(true)
|
||||
setGoodsobj(item)
|
||||
ShopCartRef.current.SearchRef.current.clearInput()
|
||||
}
|
||||
|
||||
// 点击加展示输入框
|
||||
const handAdd = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.showInput = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
// 点击减
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
item.nums--
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) { it.showInput = false, it.nums = 1 }
|
||||
}
|
||||
let res = await preViewFetch(getFilterData(query))
|
||||
Taro.showLoading({
|
||||
mask: true,
|
||||
title: '请稍等...'
|
||||
})
|
||||
if (res.data) {
|
||||
Taro.showToast({
|
||||
title: "加入成功",
|
||||
duration: 2000,
|
||||
});
|
||||
setShowShopCart(false)
|
||||
goodList.map(item => {
|
||||
item.showInput = false
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
console.log(search, '000000.0.0.')
|
||||
Taro.hideLoading()
|
||||
} else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
duration: 2000,
|
||||
});
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) { it.showInput = false, it.nums = 0.5 }
|
||||
}
|
||||
}
|
||||
|
||||
//点击输入框的加
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
// if (it.nums > item.buyNums) {
|
||||
it.nums++
|
||||
// }
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
|
||||
//输入了搜索关键字
|
||||
const getSearchDataInput = useCallback((eq) => {
|
||||
setSearchObj((e) => ({ ...e, code_or_name: eq }))
|
||||
}, [])
|
||||
|
||||
const [goodObj, setGoodsobj] = useState({})
|
||||
const ShopCartRef = useRef<any>()
|
||||
//点击对应商品显示购物车
|
||||
const showCart = async (item) => {
|
||||
setSearchObj((e) => ({ ...e, goodsId: item.id, purchaser_id: clientObj?.clientId }))
|
||||
setShowShopCart(true)
|
||||
setGoodsobj(item)
|
||||
ShopCartRef.current.SearchRef.current.clearInput()
|
||||
}
|
||||
|
||||
//点击加展示输入框
|
||||
const handAdd = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.showInput = true
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
|
||||
//点击减
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
item.nums--
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) it.showInput = false, it.nums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) it.showInput = false, it.nums = 0.5
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
if (item.nums < 3) it.showInput = false, it.nums = 3
|
||||
}
|
||||
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
//选择类型
|
||||
const handCheckMode = (item) => {
|
||||
typeList.map(it => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
setSearchObj((e) => ({ ...e, modeId: it.id }))
|
||||
} else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setGoodlist([])
|
||||
}
|
||||
|
||||
//关闭弹窗
|
||||
const closePoup = () => {
|
||||
setShowShopCart(false)
|
||||
}
|
||||
|
||||
//获取关键字数据
|
||||
const [histroyList, setHistroyList] = useState<any[]>([])
|
||||
const { fetchData: historyFetch } = mpsearchHistorylist()
|
||||
const getHistory = async () => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
const res = await historyFetch()
|
||||
if (res.data) {
|
||||
setHistroyList([...res?.data?.list])
|
||||
Taro.hideLoading()
|
||||
if (search.modeId == 2) {
|
||||
if (item.nums < 3) { it.showInput = false, it.nums = 3 }
|
||||
}
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}, [goodList])
|
||||
|
||||
//搜索商品的数组
|
||||
const [searchList, setSearchList] = useState<any[]>([])
|
||||
//是否有值输入框
|
||||
const [hasFonts, setHasFonts] = useState(false)
|
||||
useEffect(() => {
|
||||
// 选择类型
|
||||
const handCheckMode = (item) => {
|
||||
typeList.map((it) => {
|
||||
if (it.id === item.id) {
|
||||
it.checked = true
|
||||
setSearchObj(e => ({ ...e, modeId: it.id }))
|
||||
}
|
||||
else {
|
||||
it.checked = false
|
||||
}
|
||||
return it
|
||||
})
|
||||
setTypeList([...typeList])
|
||||
setGoodlist([])
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
const closePoup = () => {
|
||||
setShowShopCart(false)
|
||||
}
|
||||
|
||||
// 获取关键字数据
|
||||
const [histroyList, setHistroyList] = useState<any[]>([])
|
||||
const { fetchData: historyFetch } = mpsearchHistorylist()
|
||||
const getHistory = async() => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
const res = await historyFetch()
|
||||
if (res.data) {
|
||||
setHistroyList([...res?.data?.list])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索商品的数组
|
||||
const [searchList, setSearchList] = useState<any[]>([])
|
||||
// 是否有值输入框
|
||||
const [hasFonts, setHasFonts] = useState(false)
|
||||
useEffect(() => {
|
||||
getHistory()
|
||||
}, [])
|
||||
|
||||
// 搜索获取商品数据
|
||||
const { fetchData: productFetch } = mpproductlist()
|
||||
const { fetchData: historyputFetch } = mpsearchHistory()
|
||||
const getProduct = debounce(async(e) => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
await historyputFetch({ key: e, scene: 0 }).then((res) => {
|
||||
if (res.data) {
|
||||
getHistory()
|
||||
}, [])
|
||||
//输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
if (e) {
|
||||
setHasFonts(true)
|
||||
getProduct(e)
|
||||
} else {
|
||||
setHasFonts(false)
|
||||
setSearchList([])
|
||||
}
|
||||
})
|
||||
productFetch({ code_or_name: e }).then((res) => {
|
||||
if (res.data) {
|
||||
Taro.hideLoading()
|
||||
setSearchList([...res?.data?.list])
|
||||
}
|
||||
})
|
||||
}, 300)
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback((e) => {
|
||||
if (e) {
|
||||
setHasFonts(true)
|
||||
getProduct(e)
|
||||
}
|
||||
else {
|
||||
setHasFonts(false)
|
||||
setSearchList([])
|
||||
}
|
||||
}, [])
|
||||
|
||||
// 返回
|
||||
const back = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
|
||||
// 输入框失焦
|
||||
const onBlur = (e, id) => {
|
||||
goodList.map((item) => {
|
||||
if (item.id == id) {
|
||||
if (search.modeId == 0 && (e.detail.value == '' || Number(e.detail.value) == 0)) {
|
||||
item.showInput = false
|
||||
item.nums = 1
|
||||
}
|
||||
}, [])
|
||||
//搜索获取商品数据
|
||||
const { fetchData: productFetch } = mpproductlist()
|
||||
const { fetchData: historyputFetch } = mpsearchHistory()
|
||||
const getProduct = debounce(async (e) => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
await historyputFetch({ key: e, scene: 0 }).then((res) => {
|
||||
if (res.data) {
|
||||
getHistory()
|
||||
}
|
||||
})
|
||||
productFetch({ code_or_name: e }).then((res) => {
|
||||
if (res.data) {
|
||||
Taro.hideLoading()
|
||||
setSearchList([...res?.data?.list])
|
||||
}
|
||||
})
|
||||
}, 300)
|
||||
//返回
|
||||
const back = () => {
|
||||
Taro.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}
|
||||
else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
if (search.modeId == 2 && Number(e.detail.value) < 3) {
|
||||
item.nums = 3
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 2 && Number(e.detail.value) >= 3) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}
|
||||
|
||||
//输入框失焦
|
||||
const onBlur = (e, id) => {
|
||||
goodList.map(item => {
|
||||
if (item.id == id) {
|
||||
if (search.modeId == 0 && (e.detail.value == '' || Number(e.detail.value) == 0)) {
|
||||
item.showInput = false
|
||||
item.nums = 1
|
||||
// 选择中后的值到输入框
|
||||
const [defaultvalue, setdefaultvalue] = useState('')
|
||||
|
||||
} else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
item.showInput = false
|
||||
} else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
if (search.modeId == 2 && Number(e.detail.value) < 3) {
|
||||
item.nums = 3
|
||||
item.showInput = false
|
||||
|
||||
} else if (search.modeId == 2 && Number(e.detail.value) >= 3) {
|
||||
item.nums = Number(e.detail.value).toFixed(2)
|
||||
}
|
||||
|
||||
}
|
||||
return item
|
||||
})
|
||||
setGoodlist([...goodList])
|
||||
}
|
||||
|
||||
//选择中后的值到输入框
|
||||
const [defaultvalue, setdefaultvalue] = useState('')
|
||||
|
||||
//点击关键字搜索内容
|
||||
const handItem = (item) => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
productFetch({ code_or_name: item.search_key }).then((res) => {
|
||||
if (res.data) {
|
||||
setHasFonts(true)
|
||||
setSearchList([...res.data.list])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
})
|
||||
setdefaultvalue(item.search_key)
|
||||
}
|
||||
//点击返回文字
|
||||
const handBack = () => {
|
||||
setHasFonts(false)
|
||||
setSearchList([])
|
||||
}
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.topBox}>
|
||||
<Search placeholder='请输入搜索布料' defaultValue={defaultvalue} showBtn={false} changeOnSearch={getSearchData} >
|
||||
<View className={styles.cancelFont} onClick={() => back()}>取消</View>
|
||||
</Search>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
{
|
||||
!hasFonts && <>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.histroyFonts}>历史搜索</View>
|
||||
<View className={classnames('iconfont', 'icon-shaixuan', styles.icon_delect)}></View>
|
||||
</View>
|
||||
{!!histroyList.length &&
|
||||
<View className={styles.bigBox}>
|
||||
{histroyList.map((item, index) => {
|
||||
return (
|
||||
<View onClick={() => handItem(item)} key={index} className={styles.itemBox}>{item.search_key}</View>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!histroyList.length && <Empty picUrl='https://cdn.zzfzyc.com/empty.png' text={'无搜索历史'}></Empty>
|
||||
}
|
||||
</>
|
||||
}
|
||||
{
|
||||
hasFonts && <>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.histroyLeft}>
|
||||
<View className={styles.histroyFonts}>搜索结果</View>
|
||||
<View className={styles.back} onClick={() => handBack()}>返回</View>
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
!!searchList.length && searchList.map((item, index) => {
|
||||
// 点击关键字搜索内容
|
||||
const handItem = (item) => {
|
||||
Taro.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
productFetch({ code_or_name: item.search_key }).then((res) => {
|
||||
if (res.data) {
|
||||
setHasFonts(true)
|
||||
setSearchList([...res.data.list])
|
||||
Taro.hideLoading()
|
||||
}
|
||||
})
|
||||
setdefaultvalue(item.search_key)
|
||||
}
|
||||
// 点击返回文字
|
||||
const handBack = () => {
|
||||
setHasFonts(false)
|
||||
setSearchList([])
|
||||
}
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<View className={styles.topBox}>
|
||||
<Search placeholder="请输入搜索布料" defaultValue={defaultvalue} showBtn={false} changeOnSearch={getSearchData} >
|
||||
<View className={styles.cancelFont} onClick={() => back()}>取消</View>
|
||||
</Search>
|
||||
</View>
|
||||
<View className={styles.line}></View>
|
||||
{
|
||||
!hasFonts && <>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.histroyFonts}>历史搜索</View>
|
||||
<View className={classnames('iconfont', 'icon-shaixuan', styles.icon_delect)}></View>
|
||||
</View>
|
||||
{!!histroyList.length
|
||||
&& <View className={styles.bigBox}>
|
||||
{histroyList.map((item, index) => {
|
||||
return (
|
||||
<Goods clickItem={() => showCart(item)} key={index} data={item}></Goods>
|
||||
<View onClick={() => handItem(item)} key={index} className={styles.itemBox}>{item.search_key}</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
!searchList.length && <Empty picUrl='https://cdn.zzfzyc.com/empty.png' text={'暂无数据'}></Empty>
|
||||
}
|
||||
</>
|
||||
}
|
||||
<ShopCart
|
||||
ref={ShopCartRef}
|
||||
handSure={() => handSure()}
|
||||
clientName={clientObj?.clientName}
|
||||
clientId={clientObj?.clientId}
|
||||
modeFont={search.modeId}
|
||||
handPlus={(item) => handPlus(item)}
|
||||
obj={goodObj}
|
||||
getSearchData={(e) => { getSearchDataInput(e) }}
|
||||
hasBottom={false}
|
||||
reduceNums={(item) => { reduceNums(item) }}
|
||||
addNums={(item) => { handAdd(item) }}
|
||||
showPopup={showShopCart}
|
||||
handCheck={(item) => { handCheckMode(item) }}
|
||||
closePopup={() => closePoup()}
|
||||
goodList={goodList}
|
||||
typeList={typeList}
|
||||
onBlur={(e, id) => onBlur(e, id)}
|
||||
></ShopCart>
|
||||
})}
|
||||
</View>
|
||||
}
|
||||
{
|
||||
!histroyList.length && <Empty picUrl="https://cdn.zzfzyc.com/empty.png" text="无搜索历史"></Empty>
|
||||
}
|
||||
</>
|
||||
}
|
||||
{
|
||||
hasFonts && <>
|
||||
<View className={styles.topBox}>
|
||||
<View className={styles.histroyLeft}>
|
||||
<View className={styles.histroyFonts}>搜索结果</View>
|
||||
<View className={styles.back} onClick={() => handBack()}>返回</View>
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
!!searchList.length && searchList.map((item, index) => {
|
||||
return (
|
||||
<Goods clickItem={() => showCart(item)} key={index} data={item}></Goods>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
!searchList.length && <Empty picUrl="https://cdn.zzfzyc.com/empty.png" text="暂无数据"></Empty>
|
||||
}
|
||||
</>
|
||||
}
|
||||
<ShopCart
|
||||
ref={ShopCartRef}
|
||||
handSure={() => handSure()}
|
||||
clientName={clientObj?.clientName}
|
||||
clientId={clientObj?.clientId}
|
||||
modeFont={search.modeId}
|
||||
handPlus={item => handPlus(item)}
|
||||
obj={goodObj}
|
||||
getSearchData={(e) => { getSearchDataInput(e) }}
|
||||
hasBottom={false}
|
||||
reduceNums={(item) => { reduceNums(item) }}
|
||||
addNums={(item) => { handAdd(item) }}
|
||||
showPopup={showShopCart}
|
||||
handCheck={(item) => { handCheckMode(item) }}
|
||||
closePopup={() => closePoup()}
|
||||
goodList={goodList}
|
||||
typeList={typeList}
|
||||
onBlur={(e, id) => onBlur(e, id)}
|
||||
></ShopCart>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
export default memo(SearchPage)
|
||||
// oninputEvent={(e, item) => { onInputEven?.(e, item) }}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { ShoppingDispatchType, useShoppingDispatch } from '../../context'
|
||||
import styles from './index.module.scss'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import { usePropsValue } from '@/use/useCommon'
|
||||
import { ShoppingDispatchType, useShoppingDispatch } from '../../context'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
onDelete?: Function
|
||||
onSelectCheckbox?: (bool: boolean) => void
|
||||
disabled?: boolean
|
||||
@@ -41,15 +41,16 @@ export default (props: PropsType) => {
|
||||
status={isSelectAll}
|
||||
disabled={disabled}
|
||||
round
|
||||
size='small'
|
||||
size="small"
|
||||
onSelect={selectCallBack}
|
||||
onClose={closeCallBack}
|
||||
customStyles={{ color: '$color: #000000, $alpha: 0.6' }}>
|
||||
customStyles={{ color: '$color: #000000, $alpha: 0.6' }}
|
||||
>
|
||||
全选
|
||||
</MCheckbox>
|
||||
</View>
|
||||
<View className={styles.bottomRight}>
|
||||
<NormalButton round type='danger' size='normal' onClick={handleDelete} customStyles={{ backgroundColor: '#F44761', padding: '0 80rpx' }}>
|
||||
<NormalButton round type="danger" size="normal" onClick={handleDelete} customStyles={{ backgroundColor: '#F44761', padding: '0 80rpx' }}>
|
||||
<Text style={{ fontSize: '32rpx' }}>删除</Text>
|
||||
</NormalButton>
|
||||
</View>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { formatMillionYuan, toDecimal2 } from '@/common/format'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { memo } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import { formatMillionYuan, toDecimal2 } from '@/common/format'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
amount?: number
|
||||
onSettleAccount?: Function
|
||||
}
|
||||
@@ -25,11 +25,11 @@ export default (props: PropsType) => {
|
||||
<Text className={styles.money}>{Number(Number(amount)
|
||||
.toFixed(2))
|
||||
.toLocaleString()}</Text>
|
||||
|
||||
|
||||
</Text>
|
||||
</View>
|
||||
<View className={styles.bottomRight}>
|
||||
<NormalButton type='primary' round size='normal' onClick={handleSettle} customStyles={{ padding: '0 80rpx' }}>
|
||||
<NormalButton type="primary" round size="normal" onClick={handleSettle} customStyles={{ padding: '0 80rpx' }}>
|
||||
<Text style={{ fontSize: '32rpx' }}>结算</Text>
|
||||
</NormalButton>
|
||||
</View>
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
import { View, Text, Image } from '@tarojs/components'
|
||||
import { Image, Text, View } from '@tarojs/components'
|
||||
import type { FC } from 'react'
|
||||
import { forwardRef, memo, useCallback, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import { selectList } from '../../config'
|
||||
import type { ShoppingStateContextValue } from '../../context'
|
||||
import { Goods, ShoppingDispatchType, useShoppingDispatch, useShoppingState } from '../../context'
|
||||
import type { ShoppingStore } from '../../context/shoppingStore'
|
||||
import { events } from '../../context/shoppingStore'
|
||||
import styles from './index.module.scss'
|
||||
import MCheckbox from '@/components/checkbox'
|
||||
import Counter from '@/components/counter'
|
||||
import { FC, forwardRef, memo, useCallback, useEffect, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import { debounce } from '@/common/util'
|
||||
import { formatImgUrl, formatMeterDiv, formatMeterMul, formatPriceDiv } from '@/common/format'
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
import { selectList } from '../../config'
|
||||
import { AdjestShoppingCartApi } from '@/api/shopping/index'
|
||||
import { Goods, ShoppingDispatchType, ShoppingStateContextValue, useShoppingDispatch, useShoppingState } from '../../context'
|
||||
import { events, ShoppingStore } from '../../context/shoppingStore'
|
||||
import LabAndImg from '@/components/LabAndImg'
|
||||
import { usePropsValue } from '@/use/useCommon'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
state?: {
|
||||
Observer: ShoppingStore
|
||||
}
|
||||
@@ -24,31 +27,30 @@ type PropsType = {
|
||||
onChange?: (isChecked: boolean, goodsId: number) => void
|
||||
}
|
||||
|
||||
const ColorKindItem: FC<PropsType> = props => {
|
||||
console.log('rerender component ColorKindItem', props);
|
||||
const ColorKindItem: FC<PropsType> = (props) => {
|
||||
console.log('rerender component ColorKindItem', props)
|
||||
const { state, purchaserId, itemData, checked = false } = props
|
||||
const [isChecked, setCheck] = usePropsValue({
|
||||
value: checked,
|
||||
defaultValue: checked,
|
||||
onChange: (value) => {
|
||||
props.onChange?.(value, itemData.id)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
//格式化数量
|
||||
const formatCount = itemData => {
|
||||
// 格式化数量
|
||||
const formatCount = (itemData) => {
|
||||
return itemData.sale_mode == EnumSaleMode.Bulk ? itemData.roll : formatMeterDiv(itemData.length)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log('itemData==>',itemData);
|
||||
console.log('itemData==>', itemData)
|
||||
setCount(formatCount(itemData))
|
||||
}, [itemData.roll, itemData.length])
|
||||
|
||||
|
||||
const [count, setCount] = useState(formatCount(itemData))
|
||||
|
||||
//格式化金额
|
||||
// 格式化金额
|
||||
const formatPrice = (price: number) => {
|
||||
return Number(formatPriceDiv(price))
|
||||
}
|
||||
@@ -56,10 +58,9 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
const handleCountChange = (nextValue: number) => {
|
||||
setCount(nextValue)
|
||||
}
|
||||
|
||||
|
||||
//格式化单位
|
||||
const formatUnit = itemData => {
|
||||
// 格式化单位
|
||||
const formatUnit = (itemData) => {
|
||||
return itemData.sale_mode == EnumSaleMode.Bulk ? '条' : '米'
|
||||
}
|
||||
// 选中
|
||||
@@ -83,7 +84,7 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
const { fetchData } = AdjestShoppingCartApi()
|
||||
|
||||
// 调整条数/米数的接口 并在调整完成后重新请求整个购物车页面
|
||||
const getInputValue = useCallback(debounce(async (num) => {
|
||||
const getInputValue = useCallback(debounce(async(num) => {
|
||||
console.log('num===>', num)
|
||||
const targetColor: Record<string, any> = {
|
||||
roll: 0,
|
||||
@@ -92,7 +93,8 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
if (itemData.sale_mode === EnumSaleMode.Bulk) {
|
||||
itemData.roll = num
|
||||
targetColor.roll = num
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
itemData.length = formatMeterMul(num)
|
||||
targetColor.length = formatMeterMul(num)
|
||||
}
|
||||
@@ -106,7 +108,7 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
}
|
||||
}, 460), [itemData])
|
||||
|
||||
const labAndImgObj = useCallback(item => {
|
||||
const labAndImgObj = useCallback((item) => {
|
||||
return { lab: item.lab, rgb: item.rgb, texture_url: item.product_color_texture_url }
|
||||
}, [])
|
||||
|
||||
@@ -116,11 +118,12 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
onSelect={handleSelect}
|
||||
onClose={handleClose}
|
||||
customClassName={classnames(styles.checkbox, isChecked ? styles.selected : '')}
|
||||
customTextClass={styles.colorKindItem}>
|
||||
<View className={styles['colorKindItem__left']}>
|
||||
customTextClass={styles.colorKindItem}
|
||||
>
|
||||
<View className={styles.colorKindItem__left}>
|
||||
<LabAndImg value={labAndImgObj(itemData)} />
|
||||
</View>
|
||||
<View className={styles['colorKindItem__center']}>
|
||||
<View className={styles.colorKindItem__center}>
|
||||
<Text className={styles['colorKindItem__center--title']}>
|
||||
{itemData.product_code}# {itemData.product_name}
|
||||
</Text>
|
||||
@@ -129,7 +132,7 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
<Text className={styles['colorKindItem__center--description']}>{itemData.product_color_name}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles['colorKindItem__right']}>
|
||||
<View className={styles.colorKindItem__right}>
|
||||
<View className={styles['colorKindItem__right--price']}>¥ {formatPrice(itemData.sale_price)}/{itemData.sale_mode == EnumSaleMode.Plate ? '米' : 'kg'}</View>
|
||||
<View className={styles['colorKindItem__right--counter']}>
|
||||
<Counter
|
||||
@@ -152,21 +155,21 @@ const ColorKindItem: FC<PropsType> = props => {
|
||||
// 那么当 context 内的 value 被更新的时候,react 只会强制渲染 Wrapper
|
||||
const withStateSlice = (comp, slice) => {
|
||||
const MemoComp = memo(comp, (prevProps, nextProps) => {
|
||||
let needMemo = true
|
||||
let needMemo = true
|
||||
if (prevProps.itemData !== nextProps.itemData) {
|
||||
console.log('itemData 有变化');
|
||||
console.log('itemData 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
if (prevProps.state.Observer !== nextProps.state.Observer) {
|
||||
console.log('Observer 有变化');
|
||||
console.log('Observer 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
if (prevProps.checked !== nextProps.checked) {
|
||||
console.log('checked 有变化', prevProps.checked, nextProps.checked);
|
||||
console.log('checked 有变化', prevProps.checked, nextProps.checked)
|
||||
needMemo = false
|
||||
}
|
||||
if (prevProps.purchaserId !== nextProps.purchaserId) {
|
||||
console.log('purchaserId 有变化');
|
||||
console.log('purchaserId 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
return needMemo
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
import produce from 'immer'
|
||||
import { FC, ReactNode, useEffect, useMemo, useReducer, useRef } from 'react'
|
||||
import {
|
||||
import type { FC, ReactNode } from 'react'
|
||||
import { useEffect, useMemo, useReducer, useRef } from 'react'
|
||||
import type {
|
||||
ColorStore,
|
||||
GoodsMeta,
|
||||
ShoppingAction,
|
||||
ShoppingDispatchContext,
|
||||
|
||||
ShoppingDispatchContextValue,
|
||||
ShoppingStateContextValue,
|
||||
} from '../../context'
|
||||
import {
|
||||
ShoppingDispatchContext,
|
||||
ShoppingDispatchType,
|
||||
shoppingReducer,
|
||||
ShoppingStateContext,
|
||||
throwError,
|
||||
shoppingReducer, throwError,
|
||||
} from '../../context'
|
||||
import { ColorStore, ShoppingStateContextValue } from '../../context'
|
||||
import { ShoppingStore } from '../../context/shoppingStore'
|
||||
|
||||
export type TriggerCheckboxOptions = {
|
||||
export interface TriggerCheckboxOptions {
|
||||
multipleSelection: GoodsMeta['multipleSelection']
|
||||
setSelectedAmount: ShoppingDispatchContextValue['UPDATE_SELECTED_AMOUNT']
|
||||
}
|
||||
@@ -24,7 +28,7 @@ export interface ShoppingCartPropsType {
|
||||
children?: ReactNode
|
||||
}
|
||||
// 购物车上下文组件
|
||||
export const ShoppingProvider: FC<ShoppingCartPropsType> = props => {
|
||||
export const ShoppingProvider: FC<ShoppingCartPropsType> = (props) => {
|
||||
const { children, onTriggerCheckbox, initialValues } = props
|
||||
|
||||
const onTriggerCheckboxRef = useRef(onTriggerCheckbox)
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import { FC, forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import { nextTick } from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import classNames from 'classnames'
|
||||
import produce, { setAutoFreeze } from 'immer'
|
||||
import ColorKindItem from '../colorKindItem'
|
||||
import { selectList } from '../../config'
|
||||
import type { Goods, GoodsMeta, ShoppingStateContextValue } from '../../context'
|
||||
import { ShoppingDispatchType, useShoppingDispatch, useShoppingState } from '../../context'
|
||||
import type { ShoppingStore } from '../../context/shoppingStore'
|
||||
import { events } from '../../context/shoppingStore'
|
||||
import styles from './index.module.scss'
|
||||
import { formatMeterDiv } from '@/common/format'
|
||||
import LayoutBlock from '@/components/layoutBlock'
|
||||
import Tag from '@/components/tag'
|
||||
import Divider from '@/components/divider'
|
||||
import ColorKindItem from '../colorKindItem'
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
import { selectList } from '../../config'
|
||||
import { Goods, GoodsMeta, ShoppingDispatchType, ShoppingStateContextValue, useShoppingDispatch, useShoppingState } from '../../context'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { alert, isEmptyObject } from '@/common/common'
|
||||
import classNames from 'classnames'
|
||||
import LoadingCard from '@/components/loadingCard'
|
||||
import { ShoppingCartListApi } from '@/api'
|
||||
import { events, ShoppingStore } from '../../context/shoppingStore'
|
||||
import { usePropsValue } from '@/use/useCommon'
|
||||
import produce, { setAutoFreeze } from 'immer'
|
||||
import { nextTick } from '@tarojs/taro'
|
||||
|
||||
interface ButtonPropsType {
|
||||
isActive: boolean
|
||||
@@ -28,7 +31,7 @@ interface ButtonPropsType {
|
||||
}
|
||||
type OperationType = 'add' | 'delete'
|
||||
// 订单类型
|
||||
const SaleModeButton: FC<ButtonPropsType> = props => {
|
||||
const SaleModeButton: FC<ButtonPropsType> = (props) => {
|
||||
const { onClick, children, isActive = false, customStyle } = props
|
||||
const handleClick = () => {
|
||||
onClick?.()
|
||||
@@ -43,7 +46,7 @@ const SaleModeButton: FC<ButtonPropsType> = props => {
|
||||
const DrawerButton = memo<{ isOpen: boolean }>(({ isOpen }) => {
|
||||
return (
|
||||
<View className={styles.drawerButton}>
|
||||
{isOpen ? <IconFont name='icon-shouqi' size={52}></IconFont> : <IconFont name='icon-zhankai' size={52}></IconFont>}
|
||||
{isOpen ? <IconFont name="icon-shouqi" size={52}></IconFont> : <IconFont name="icon-zhankai" size={52}></IconFont>}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
@@ -54,7 +57,7 @@ enum BackEndSaleModeListFieldMap {
|
||||
weight_cut_color_list = 2,
|
||||
}
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
itemData?: ShoppingCartData
|
||||
state?: {
|
||||
multipleSelection?: GoodsMeta['multipleSelection']
|
||||
@@ -63,7 +66,7 @@ type PropsType = {
|
||||
}
|
||||
}
|
||||
|
||||
const ShoppingCartItem: FC<PropsType> = props => {
|
||||
const ShoppingCartItem: FC<PropsType> = (props) => {
|
||||
const { state } = props
|
||||
console.log('rerender component ShoppingCartItem', props)
|
||||
|
||||
@@ -84,7 +87,7 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
const [selected, setSelect] = useState<EnumSaleMode>(0)
|
||||
|
||||
const onSelectOrderType = (type: EnumSaleMode) => {
|
||||
if (isPending) return
|
||||
if (isPending) { return }
|
||||
setSelect(type)
|
||||
dispatch({ type: ShoppingDispatchType.UPDATE_CURRENT_CHECKED_SALEMODE, data: type })
|
||||
// 重置预估金额
|
||||
@@ -92,7 +95,6 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false })
|
||||
}
|
||||
|
||||
|
||||
const handleClickLayout = () => {
|
||||
if (currentCheckedPurchaserId === itemData?.purchaser_id) {
|
||||
return
|
||||
@@ -108,7 +110,7 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
|
||||
// 统计已选面料
|
||||
const materialChecked = useMemo(() => {
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) return 0
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) { return 0 }
|
||||
return new Set(
|
||||
Object.values(multipleSelection)?.reduce((prev, item: Goods) => {
|
||||
if (item.sale_mode === selected) {
|
||||
@@ -121,8 +123,8 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
|
||||
// 统计已选颜色
|
||||
const colorChecked = useMemo(() => {
|
||||
console.log('colorChecked item',multipleSelection);
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) return 0
|
||||
console.log('colorChecked item', multipleSelection)
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) { return 0 }
|
||||
return new Set(
|
||||
Object.values(multipleSelection).reduce((prev, item: Goods) => {
|
||||
if (item.sale_mode === selected) {
|
||||
@@ -135,8 +137,8 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
|
||||
// 统计已选条数 / 米数
|
||||
const lengthOrRollChecked = useMemo(() => {
|
||||
console.log('lengthOrRollChecked item',multipleSelection);
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) return 0
|
||||
console.log('lengthOrRollChecked item', multipleSelection)
|
||||
if (!multipleSelection || isEmptyObject(multipleSelection)) { return 0 }
|
||||
return (
|
||||
Object.values(multipleSelection).reduce((prev, item: Goods) => {
|
||||
return prev + item.count
|
||||
@@ -148,37 +150,38 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
const { fetchData } = ShoppingCartListApi()
|
||||
// 更新当前客户的多选项
|
||||
const updatePurchaserMultipleSelection = (purchaserId, payload, operationType: OperationType, goodsId: number) => {
|
||||
if(operationType === 'add'){
|
||||
if (operationType === 'add') {
|
||||
dispatch({
|
||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||
data: {
|
||||
purchaserId: purchaserId,
|
||||
multipleSelection: produce(multipleSelection, (multipleSelectionDraft) =>{
|
||||
if(!multipleSelectionDraft){
|
||||
purchaserId,
|
||||
multipleSelection: produce(multipleSelection, (multipleSelectionDraft) => {
|
||||
if (!multipleSelectionDraft) {
|
||||
return {
|
||||
[goodsId]: payload
|
||||
[goodsId]: payload,
|
||||
}
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
multipleSelectionDraft[goodsId] = payload
|
||||
}
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
}else if(operationType === 'delete'){
|
||||
const temp = {...multipleSelection}
|
||||
}
|
||||
else if (operationType === 'delete') {
|
||||
const temp = { ...multipleSelection }
|
||||
delete temp?.[goodsId]
|
||||
dispatch({
|
||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||
data: {
|
||||
purchaserId: purchaserId,
|
||||
purchaserId,
|
||||
multipleSelection: temp,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
// 发布订阅
|
||||
useEffect(()=>{
|
||||
useEffect(() => {
|
||||
events.on('updatePurchaserMultipleSelection', updatePurchaserMultipleSelection)
|
||||
return () => {
|
||||
events.off('updatePurchaserMultipleSelection', updatePurchaserMultipleSelection)
|
||||
@@ -186,9 +189,9 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
}, [updatePurchaserMultipleSelection])
|
||||
// 发布订阅
|
||||
useEffect(() => {
|
||||
console.log('update multipleSelection',multipleSelection);
|
||||
const unsubscribe = state?.Observer?.subscribe(async id => {
|
||||
if (itemData?.purchaser_id !== id) return
|
||||
console.log('update multipleSelection', multipleSelection)
|
||||
const unsubscribe = state?.Observer?.subscribe(async(id) => {
|
||||
if (itemData?.purchaser_id !== id) { return }
|
||||
console.log('request new data start run')
|
||||
const res = await fetchData({
|
||||
purchaser_id: id,
|
||||
@@ -235,7 +238,8 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
},
|
||||
})
|
||||
setItemData(() => res.data[0])
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
alert.error('请求失败')
|
||||
}
|
||||
})
|
||||
@@ -247,12 +251,13 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
<LayoutBlock
|
||||
circle
|
||||
customClassName={classnames(styles.layout, itemData?.purchaser_id === currentCheckedPurchaserId ? styles.selected : '')}
|
||||
onClick={handleClickLayout}>
|
||||
onClick={handleClickLayout}
|
||||
>
|
||||
<View className={classNames(styles.checkbox, 'flex-row', 'justify-between')} onClick={handleOpenDetail}>
|
||||
<View className={styles.topItem}>
|
||||
<View className='flex-row items-center'>
|
||||
<View className="flex-row items-center">
|
||||
<View className={styles.topTitle}>{itemData?.purchaser_name}</View>
|
||||
<Tag type='info' size='normal' circle customStyle={{ backgroundColor: '#f0f0f0', borderColor: 'transparent' }} plain>
|
||||
<Tag type="info" size="normal" circle customStyle={{ backgroundColor: '#f0f0f0', borderColor: 'transparent' }} plain>
|
||||
{itemData?.sale_user_name}
|
||||
</Tag>
|
||||
</View>
|
||||
@@ -278,19 +283,22 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
<SaleModeButton
|
||||
customStyle={{ padding: '0 50rpx' }}
|
||||
isActive={selected === EnumSaleMode.Bulk}
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.Bulk)}>
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.Bulk)}
|
||||
>
|
||||
大货
|
||||
</SaleModeButton>
|
||||
<SaleModeButton
|
||||
customStyle={{ padding: '0 50rpx' }}
|
||||
isActive={selected === EnumSaleMode.Plate}
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.Plate)}>
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.Plate)}
|
||||
>
|
||||
剪板
|
||||
</SaleModeButton>
|
||||
<SaleModeButton
|
||||
customStyle={{ padding: '0 50rpx' }}
|
||||
isActive={selected === EnumSaleMode.BulkCut}
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.BulkCut)}>
|
||||
onClick={() => onSelectOrderType(EnumSaleMode.BulkCut)}
|
||||
>
|
||||
散剪
|
||||
</SaleModeButton>
|
||||
</View>
|
||||
@@ -299,7 +307,7 @@ const ShoppingCartItem: FC<PropsType> = props => {
|
||||
<Divider customClassName={styles.line}></Divider>
|
||||
<View className={classnames(styles.orderTitle, 'justify-between')}>
|
||||
<Text>布料颜色</Text>
|
||||
<Tag type='danger' size='normal' circle plain>
|
||||
<Tag type="danger" size="normal" circle plain>
|
||||
{selectList[selected].title}单位:{selectList[selected].unit}
|
||||
</Tag>
|
||||
</View>
|
||||
@@ -327,7 +335,7 @@ interface GoodsListPropType {
|
||||
isPending: boolean
|
||||
startTransition: React.TransitionStartFunction
|
||||
}
|
||||
const GoodsList = memo<GoodsListPropType>(props => {
|
||||
const GoodsList = memo<GoodsListPropType>((props) => {
|
||||
const { itemData, selected, isPending, startTransition, multipleSelection } = props
|
||||
const prevMultipleSelection = useRef(multipleSelection)
|
||||
const currentSelected = useRef<EnumSaleMode | null>(null)
|
||||
@@ -338,49 +346,51 @@ const GoodsList = memo<GoodsListPropType>(props => {
|
||||
// 使用 produce 更新特定的 ColorKindItem
|
||||
const updateSpecifiedComponent = () => {
|
||||
let newId
|
||||
if(multipleSelection && prevMultipleSelection.current !== multipleSelection){
|
||||
for(let key in multipleSelection){
|
||||
if(!prevMultipleSelection.current?.hasOwnProperty(key)){
|
||||
if (multipleSelection && prevMultipleSelection.current !== multipleSelection) {
|
||||
for (const key in multipleSelection) {
|
||||
if (!prevMultipleSelection.current?.hasOwnProperty(key)) {
|
||||
newId = key
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('multipleSelection==+>',multipleSelection);
|
||||
console.log('currentSelected', currentSelected.current, selected);
|
||||
console.log('component',component);
|
||||
if(component){
|
||||
if(itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0){
|
||||
console.log('multipleSelection==+>', multipleSelection)
|
||||
console.log('currentSelected', currentSelected.current, selected)
|
||||
console.log('component', component)
|
||||
if (component) {
|
||||
if (itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) {
|
||||
setComponent(produce(component, (draft) => {
|
||||
console.log('prev',component);
|
||||
const index = (draft as unknown as any[]).findIndex((item)=> item.key === newId)
|
||||
console.log('index',index)
|
||||
if(index !== -1) {
|
||||
const item = itemData?.[BackEndSaleModeListFieldMap[selected]].find(item => {
|
||||
console.log('prev', component)
|
||||
const index = (draft as unknown as any[]).findIndex(item => item.key === newId)
|
||||
console.log('index', index)
|
||||
if (index !== -1) {
|
||||
const item = itemData?.[BackEndSaleModeListFieldMap[selected]].find((item) => {
|
||||
return item.id === Number(newId)
|
||||
})
|
||||
console.log('item', item, newId);
|
||||
console.log('item', item, newId)
|
||||
draft![index] = <ColorKindItem checked={multipleSelection?.hasOwnProperty(newId)} purchaserId={itemData?.purchaser_id} key={newId} itemData={item}></ColorKindItem>
|
||||
}
|
||||
}))
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
setComponent(<View className={styles.noList}>暂无数据</View>)
|
||||
}
|
||||
}
|
||||
prevMultipleSelection.current = multipleSelection
|
||||
|
||||
}
|
||||
// 更新 GoodsList 组件
|
||||
const updateComponent = () => {
|
||||
setComponent(
|
||||
() => itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0 ? (
|
||||
itemData?.[BackEndSaleModeListFieldMap[selected]].map(item => {
|
||||
console.log('item===>', item, multipleSelection?.hasOwnProperty(item.id))
|
||||
return <ColorKindItem checked={multipleSelection?.hasOwnProperty(item.id)} purchaserId={itemData.purchaser_id} key={item.id} itemData={item}></ColorKindItem>
|
||||
})
|
||||
) : (
|
||||
<View className={styles.noList}>暂无数据</View>
|
||||
)
|
||||
() => itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0
|
||||
? (
|
||||
itemData?.[BackEndSaleModeListFieldMap[selected]].map((item) => {
|
||||
console.log('item===>', item, multipleSelection?.hasOwnProperty(item.id))
|
||||
return <ColorKindItem checked={multipleSelection?.hasOwnProperty(item.id)} purchaserId={itemData.purchaser_id} key={item.id} itemData={item}></ColorKindItem>
|
||||
})
|
||||
)
|
||||
: (
|
||||
<View className={styles.noList}>暂无数据</View>
|
||||
),
|
||||
)
|
||||
prevMultipleSelection.current = multipleSelection
|
||||
}
|
||||
@@ -406,11 +416,12 @@ const GoodsList = memo<GoodsListPropType>(props => {
|
||||
data: {
|
||||
purchaserId: itemData?.purchaser_id!,
|
||||
goodsKind: newGoodsKind,
|
||||
multipleSelection: multipleSelection,
|
||||
multipleSelection,
|
||||
},
|
||||
})
|
||||
updateComponent()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
currentSelected.current = selected
|
||||
// 重新把当前的选中状态赋值给ref 作为下一次比较的旧状态
|
||||
dispatch({
|
||||
@@ -427,13 +438,15 @@ const GoodsList = memo<GoodsListPropType>(props => {
|
||||
|
||||
return (
|
||||
<>
|
||||
{isPending ? (
|
||||
<View className={styles.noList} style={{margin: '60rpx 0'}}>
|
||||
<LoadingCard />
|
||||
</View>
|
||||
) : (
|
||||
component
|
||||
)}
|
||||
{isPending
|
||||
? (
|
||||
<View className={styles.noList} style={{ margin: '60rpx 0' }}>
|
||||
<LoadingCard />
|
||||
</View>
|
||||
)
|
||||
: (
|
||||
component
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})
|
||||
@@ -445,27 +458,27 @@ const withStateSlice = (comp, slice) => {
|
||||
if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) {
|
||||
needMemo = false
|
||||
}
|
||||
if(prevProps.itemData.purchaser_name === 'JENNIE'){
|
||||
console.log('------withStateSlice props-------');
|
||||
console.log('withStateSlice props prevProps', prevProps);
|
||||
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData);
|
||||
console.log('withStateSlice props nextProps', nextProps);
|
||||
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection);
|
||||
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId);
|
||||
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer);
|
||||
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state);
|
||||
console.log('------withStateSlice props-------');
|
||||
if (prevProps.itemData.purchaser_name === 'JENNIE') {
|
||||
console.log('------withStateSlice props-------')
|
||||
console.log('withStateSlice props prevProps', prevProps)
|
||||
console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
|
||||
console.log('withStateSlice props nextProps', nextProps)
|
||||
console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection)
|
||||
console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId)
|
||||
console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer)
|
||||
console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
|
||||
console.log('------withStateSlice props-------')
|
||||
}
|
||||
if (prevProps.state.Observer !== nextProps.state.Observer) {
|
||||
console.log('Observer 有变化');
|
||||
console.log('Observer 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
if (prevProps.state.multipleSelection !== nextProps.state.multipleSelection) {
|
||||
console.log('multipleSelection 有变化');
|
||||
console.log('multipleSelection 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
if (prevProps.state.currentCheckedPurchaserId !== nextProps.state.currentCheckedPurchaserId) {
|
||||
console.log('currentCheckedPurchaserId 有变化');
|
||||
console.log('currentCheckedPurchaserId 有变化')
|
||||
needMemo = false
|
||||
}
|
||||
return needMemo
|
||||
@@ -478,7 +491,7 @@ const withStateSlice = (comp, slice) => {
|
||||
}
|
||||
|
||||
const ShoppingCartItemWithStateSlice = withStateSlice(ShoppingCartItem, (state: ShoppingStateContextValue, props) => ({
|
||||
multipleSelection: state.colorStore?.[props.itemData?.purchaser_id]?.['multipleSelection'],
|
||||
multipleSelection: state.colorStore?.[props.itemData?.purchaser_id]?.multipleSelection,
|
||||
currentCheckedPurchaserId: state.currentCheckedPurchaserId,
|
||||
Observer: state.Observer,
|
||||
}))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
import produce from 'immer'
|
||||
import React, { Dispatch } from 'react'
|
||||
import { useContext } from 'react'
|
||||
import { ShoppingStore } from './shoppingStore'
|
||||
import type { Dispatch } from 'react'
|
||||
import React, { useContext } from 'react'
|
||||
import type { ShoppingStore } from './shoppingStore'
|
||||
import type { EnumSaleMode } from '@/common/Enumerate'
|
||||
|
||||
/**
|
||||
* 456: {
|
||||
@@ -30,11 +30,9 @@ import { ShoppingStore } from './shoppingStore'
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
export type ColorStore = {
|
||||
[purchaserId: GoodsMeta['purchaserId']]: GoodsMeta
|
||||
}
|
||||
export type ColorStore = Record<GoodsMeta['purchaserId'], GoodsMeta>
|
||||
|
||||
export type Goods = {
|
||||
export interface Goods {
|
||||
id: number
|
||||
product_code: number // 面料编号
|
||||
product_color_code: number // 颜色编号
|
||||
@@ -47,9 +45,7 @@ export type Goods = {
|
||||
// 分组
|
||||
export interface GoodsMeta {
|
||||
purchaserId: number
|
||||
goodsKind?: {
|
||||
[id: Goods['id']]: Goods
|
||||
}
|
||||
goodsKind?: Record<Goods['id'], Goods>
|
||||
multipleSelection?: GoodsMeta['goodsKind']
|
||||
}
|
||||
|
||||
@@ -83,13 +79,12 @@ export interface ShoppingDispatchContextValue {
|
||||
[ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX]: (amount: React.SetStateAction<ShoppingStateContextValue['selectedAmount']>) => void
|
||||
}
|
||||
|
||||
|
||||
export type ShoppingAction = {
|
||||
export interface ShoppingAction {
|
||||
type: ShoppingDispatchType
|
||||
data?: any
|
||||
}
|
||||
|
||||
export const shoppingReducer = produce((draft: ShoppingStateContextValue, action: ShoppingAction)=>{
|
||||
export const shoppingReducer = produce((draft: ShoppingStateContextValue, action: ShoppingAction) => {
|
||||
const { type, data } = action
|
||||
switch (type) {
|
||||
case ShoppingDispatchType.UPDATE_MANAGE_STATUS: {
|
||||
@@ -117,14 +112,15 @@ export const shoppingReducer = produce((draft: ShoppingStateContextValue, action
|
||||
break
|
||||
}
|
||||
case ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX: {
|
||||
if(!draft.colorStore[data.purchaserId]){
|
||||
if (!draft.colorStore[data.purchaserId]) {
|
||||
draft.colorStore[data.purchaserId] = {
|
||||
purchaserId: data.purchaserId,
|
||||
goodsKind: data.goodsKind,
|
||||
multipleSelection: data.multipleSelection
|
||||
multipleSelection: data.multipleSelection,
|
||||
}
|
||||
}else{
|
||||
draft.colorStore[data.purchaserId] = produce(draft.colorStore[data.purchaserId], purchaserDraft => {
|
||||
}
|
||||
else {
|
||||
draft.colorStore[data.purchaserId] = produce(draft.colorStore[data.purchaserId], (purchaserDraft) => {
|
||||
purchaserDraft.purchaserId = data.purchaserId
|
||||
purchaserDraft.goodsKind = { ...purchaserDraft.goodsKind, ...data.goodsKind }
|
||||
purchaserDraft.multipleSelection = data.multipleSelection ? data.multipleSelection : purchaserDraft?.multipleSelection
|
||||
@@ -136,7 +132,6 @@ export const shoppingReducer = produce((draft: ShoppingStateContextValue, action
|
||||
throwError()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
export const ShoppingStateContext = React.createContext<ShoppingStateContextValue | null>(null)
|
||||
|
||||
@@ -160,7 +155,7 @@ export function useShoppingDispatch() {
|
||||
|
||||
export function useWatch(purchaserId: GoodsMeta['purchaserId'], id: number) {
|
||||
const { colorStore } = useShoppingState()
|
||||
return id ? colorStore[purchaserId]['goodsKind']![id] : colorStore[purchaserId]['goodsKind']
|
||||
return id ? colorStore[purchaserId].goodsKind![id] : colorStore[purchaserId].goodsKind
|
||||
}
|
||||
|
||||
export interface ShoppingCartAction {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
// 用于优化数据流 结合发布订阅 更新组件内部状态可以组件自己处理
|
||||
|
||||
import { Events } from "@tarojs/taro"
|
||||
import { ColorStore } from "."
|
||||
import { Events } from '@tarojs/taro'
|
||||
import type { ColorStore } from '.'
|
||||
|
||||
export const events = new Events()
|
||||
|
||||
export type SubscribeCallback = (changedGoods: any) => void
|
||||
@@ -16,10 +17,12 @@ export class ShoppingStore {
|
||||
constructor(initialValue?: any) {
|
||||
initialValue && this.updateStore(initialValue)
|
||||
}
|
||||
|
||||
// 更新全局缓存
|
||||
private updateStore(nextStore: ColorStore) {
|
||||
this.store = nextStore
|
||||
}
|
||||
|
||||
// 订阅
|
||||
subscribe(callback: SubscribeCallback) {
|
||||
this.observers.push(callback)
|
||||
@@ -30,10 +33,11 @@ export class ShoppingStore {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 通知
|
||||
notify(changedGoods: any) {
|
||||
// 循环调用
|
||||
this.observers.forEach(callback => {
|
||||
this.observers.forEach((callback) => {
|
||||
callback(changedGoods)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
navigationBarTitleText: '购物页面',
|
||||
|
||||
navigationBarTitleText: '购物页面',
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import Search from '@/components/search'
|
||||
import { View } from '@tarojs/components'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { FC, memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import IconText from '@/components/iconText'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/shoppingCartItem/index'
|
||||
import { formatPriceDiv } from '@/common/format'
|
||||
import BottomSettleBar from './components/bottomSettleBar'
|
||||
import BottomEditBar from './components/bottomEditBar'
|
||||
import { ShoppingCartDeleteApi, ShoppingCartListApi } from '@/api/index'
|
||||
import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
|
||||
import { ShoppingProvider } from './components/shoppingCart/index'
|
||||
import { Goods, ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './context'
|
||||
import type { Goods } from './context'
|
||||
import { ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './context'
|
||||
import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
|
||||
import { ShoppingCartDeleteApi, ShoppingCartListApi } from '@/api/index'
|
||||
import { formatPriceDiv } from '@/common/format'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import IconText from '@/components/iconText'
|
||||
import Search from '@/components/search'
|
||||
import { alert, goLink, isEmptyObject } from '@/common/common'
|
||||
|
||||
export const Shopping: FC = memo(() => {
|
||||
@@ -22,12 +24,13 @@ export const Shopping: FC = memo(() => {
|
||||
console.log('handleTriggerCheckbox==>', multipleSelection)
|
||||
|
||||
if (multipleSelection) {
|
||||
const result = Object.values(multipleSelection).reduce((prev: number , value: Goods) => {
|
||||
const result = Object.values(multipleSelection).reduce((prev: number, value: Goods) => {
|
||||
return prev + Number(formatPriceDiv(value.estimate_amount))
|
||||
}, 0) as number
|
||||
// 同步修改上下文的 预估金额
|
||||
setSelectedAmount(result)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setSelectedAmount(0)
|
||||
}
|
||||
}
|
||||
@@ -43,7 +46,7 @@ interface SearchOptions {
|
||||
}
|
||||
|
||||
const ShoppingCartContainer: FC = () => {
|
||||
let isFirst = useRef(true)
|
||||
const isFirst = useRef(true)
|
||||
|
||||
const { isMultipleSelection, isManageStatus, selectedAmount, currentCheckedPurchaserId, currentCheckedSaleMode, colorStore } = useShoppingState()
|
||||
|
||||
@@ -82,8 +85,8 @@ const ShoppingCartContainer: FC = () => {
|
||||
}, [searchOptions])
|
||||
|
||||
// 输入了搜索关键字
|
||||
const getSearchData = useCallback(e => {
|
||||
console.log('getSearchData===>',e);
|
||||
const getSearchData = useCallback((e) => {
|
||||
console.log('getSearchData===>', e)
|
||||
setSearchOptions({ short_name_or_phone: e })
|
||||
}, [])
|
||||
|
||||
@@ -92,8 +95,7 @@ const ShoppingCartContainer: FC = () => {
|
||||
total: number
|
||||
}>({ list: [], total: 0 })
|
||||
|
||||
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
console.log('shoppingCartData==>', shoppingCartData, state)
|
||||
const status = dataLoadingStatus({
|
||||
@@ -107,22 +109,22 @@ const ShoppingCartContainer: FC = () => {
|
||||
|
||||
// useLayoutEffect 执行在DOM更新之后,浏览器绘制之前 如果放在 useEffect 里面会产生多一次不必要的回流和重绘,可能会引起视图闪现
|
||||
useLayoutEffect(() => {
|
||||
;(async () => {
|
||||
(async() => {
|
||||
console.log('useLayoutEffect')
|
||||
await fetchData(getFilterData(searchOptions))
|
||||
isFirst.current = false
|
||||
let query = Taro.createSelectorQuery()
|
||||
const query = Taro.createSelectorQuery()
|
||||
console.log('query', query)
|
||||
query.select('#shoppingContainer').boundingClientRect()
|
||||
query.select('#topBar').boundingClientRect()
|
||||
query.select('#bottomBar').boundingClientRect()
|
||||
query.exec(res => {
|
||||
query.exec((res) => {
|
||||
console.log('res==>', res)
|
||||
const containerHeight = res[0].height
|
||||
const topBarHeight = res[1].height
|
||||
const bottomBarHeight = res[2].height
|
||||
const listHeight = containerHeight - topBarHeight - bottomBarHeight
|
||||
listHeightRef.current = listHeight + 'px'
|
||||
listHeightRef.current = `${listHeight}px`
|
||||
// 强制刷新
|
||||
setForceUpdate({})
|
||||
})
|
||||
@@ -131,19 +133,19 @@ const ShoppingCartContainer: FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (state.success) {
|
||||
console.log('fetch success', state);
|
||||
console.log('fetch success', state)
|
||||
setShoppingCartData({ list: state.data.list, total: state.data.total })
|
||||
}
|
||||
}, [state])
|
||||
|
||||
// 结算
|
||||
const handleSettleAccount = debounce(() => {
|
||||
const multipleSelection = colorStore?.[currentCheckedPurchaserId]?.['multipleSelection']
|
||||
if (!multipleSelection) return alert.error('请先选择客户')
|
||||
const multipleSelection = colorStore?.[currentCheckedPurchaserId]?.multipleSelection
|
||||
if (!multipleSelection) { return alert.error('请先选择客户') }
|
||||
const checkedGoodsKind = Object.values(multipleSelection).reduce((prev, item: Goods) => {
|
||||
return [...prev, item.id]
|
||||
}, [])
|
||||
if (checkedGoodsKind.length === 0) return alert.error('请先选择商品')
|
||||
if (checkedGoodsKind.length === 0) { return alert.error('请先选择商品') }
|
||||
goLink('/pages/submitOrder/index', {
|
||||
purchaser_id: currentCheckedPurchaserId,
|
||||
sale_mode: currentCheckedSaleMode,
|
||||
@@ -155,16 +157,16 @@ const ShoppingCartContainer: FC = () => {
|
||||
const { fetchData: deleteApi } = ShoppingCartDeleteApi()
|
||||
|
||||
// 批量某个客户的删除商品
|
||||
const handleDelete = async () => {
|
||||
const handleDelete = async() => {
|
||||
const multipleSelection = colorStore?.[currentCheckedPurchaserId].multipleSelection
|
||||
let checked: Goods[] = Object.values(multipleSelection!)
|
||||
const checked: Goods[] = Object.values(multipleSelection!)
|
||||
if (checked.length === 0) {
|
||||
return alert.error('请选择商品')
|
||||
}
|
||||
console.log('checked==>', checked)
|
||||
Taro.showModal({
|
||||
title: '要删除这些商品吗?',
|
||||
success: async function(res) {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('删除中')
|
||||
const res = await deleteApi({
|
||||
@@ -184,7 +186,8 @@ const ShoppingCartContainer: FC = () => {
|
||||
})
|
||||
fetchData(searchOptions)
|
||||
// Observer.notify(currentCheckedPurchaserId)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.hideLoading()
|
||||
alert.none(res.msg)
|
||||
}
|
||||
@@ -195,7 +198,7 @@ const ShoppingCartContainer: FC = () => {
|
||||
// 全选
|
||||
const handleSelectAllCheckbox = (isSelectAll: boolean) => {
|
||||
const targetGoodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
|
||||
if (!targetGoodsKind) return alert.error('请先选择客户')
|
||||
if (!targetGoodsKind) { return alert.error('请先选择客户') }
|
||||
|
||||
const tempObject = { ...targetGoodsKind }
|
||||
dispatch({
|
||||
@@ -211,13 +214,14 @@ const ShoppingCartContainer: FC = () => {
|
||||
const [refreshStatus, setRefreshStatus] = useState(false)
|
||||
|
||||
// 下拉刷新
|
||||
const handleRefresh = async () => {
|
||||
const handleRefresh = async() => {
|
||||
setRefreshStatus(true)
|
||||
const res = await fetchData(getFilterData(searchOptions))
|
||||
if (res.success) {
|
||||
setRefreshStatus(false)
|
||||
alert.success('刷新成功')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
alert.error('刷新失败')
|
||||
setRefreshStatus(false)
|
||||
}
|
||||
@@ -225,40 +229,45 @@ const ShoppingCartContainer: FC = () => {
|
||||
// const [isPending, startTransition] = useTransition()
|
||||
|
||||
return (
|
||||
<View className={classnames('flex-col', styles.shopping)} id='shoppingContainer'>
|
||||
<View className={styles['shopping--topBar']} id='topBar'>
|
||||
<Search placeholder='请输入客户名称' showBtn={false} changeOnSearch={getSearchData}>
|
||||
<View className={classnames('flex-col', styles.shopping)} id="shoppingContainer">
|
||||
<View className={styles['shopping--topBar']} id="topBar">
|
||||
<Search placeholder="请输入客户名称" showBtn={false} changeOnSearch={getSearchData}>
|
||||
<View className={styles.flexBox} onClick={onStartToManage}>
|
||||
{isManageStatus ? (
|
||||
<IconText svg iconName='icon-guanlidingdan' text='取消' color='#4581ff' customClass={styles['icon--manage--cancel']} />
|
||||
) : (
|
||||
<IconText svg iconName='icon-guanlidingdan' text='管理' />
|
||||
)}
|
||||
{isManageStatus
|
||||
? (
|
||||
<IconText svg iconName="icon-guanlidingdan" text="取消" color="#4581ff" customClass={styles['icon--manage--cancel']} />
|
||||
)
|
||||
: (
|
||||
<IconText svg iconName="icon-guanlidingdan" text="管理" />
|
||||
)}
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
<View className={classnames('flex-item', 'flex-col', styles['shopping--context'])}>
|
||||
<View id='shoppingListContainer' className={classnames(styles.shopping__list__container, 'flex-item')} style={{ height: listHeightRef.current }}>
|
||||
<InfiniteScroll statusMore={statusMore} refresherEnabled={true} selfOnRefresherRefresh={handleRefresh} refresherTriggered={refreshStatus}>
|
||||
<View id="shoppingListContainer" className={classnames(styles.shopping__list__container, 'flex-item')} style={{ height: listHeightRef.current }}>
|
||||
<InfiniteScroll statusMore={statusMore} refresherEnabled selfOnRefresherRefresh={handleRefresh} refresherTriggered={refreshStatus}>
|
||||
{
|
||||
!!shoppingCartData?.list?.length &&
|
||||
shoppingCartData?.list?.map((item, index) => {
|
||||
!!shoppingCartData?.list?.length
|
||||
&& shoppingCartData?.list?.map((item, index) => {
|
||||
return <ItemList itemData={item} key={index}></ItemList>
|
||||
})
|
||||
}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
</View>
|
||||
<View id='bottomBar'>
|
||||
{isManageStatus ? (
|
||||
<BottomEditBar
|
||||
disabled={currentCheckedPurchaserId < 0}
|
||||
isSelectAll={isMultipleSelection}
|
||||
onDelete={handleDelete}
|
||||
onSelectCheckbox={isAll => handleSelectAllCheckbox(isAll)}></BottomEditBar>
|
||||
) : (
|
||||
<BottomSettleBar onSettleAccount={handleSettleAccount} amount={selectedAmount}></BottomSettleBar>
|
||||
)}
|
||||
<View id="bottomBar">
|
||||
{isManageStatus
|
||||
? (
|
||||
<BottomEditBar
|
||||
disabled={currentCheckedPurchaserId < 0}
|
||||
isSelectAll={isMultipleSelection}
|
||||
onDelete={handleDelete}
|
||||
onSelectCheckbox={isAll => handleSelectAllCheckbox(isAll)}
|
||||
></BottomEditBar>
|
||||
)
|
||||
: (
|
||||
<BottomSettleBar onSettleAccount={handleSettleAccount} amount={selectedAmount}></BottomSettleBar>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ interface ShoppingCartData {
|
||||
sale_user_id: number
|
||||
sale_user_name: string
|
||||
bulk_color_list: ColorList
|
||||
length_cut_color_list: ColorList // 剪板
|
||||
weight_cut_color_list: ColorList // 散剪
|
||||
length_cut_color_list: ColorList // 剪板
|
||||
weight_cut_color_list: ColorList // 散剪
|
||||
[Property: string]: any
|
||||
}
|
||||
interface ColorList {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
navigationBarTitleText: '确认订单',
|
||||
|
||||
}
|
||||
navigationBarTitleText: '确认订单',
|
||||
|
||||
}
|
||||
|
||||
+271
-276
@@ -1,311 +1,306 @@
|
||||
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 type { ReactNode } from 'react'
|
||||
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import AddressDetailBox from '../orderDetails/components/addressDetailBox'
|
||||
import Remark from '../orderDetails/components//remark'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import { debounce } from '@/common/util'
|
||||
import {
|
||||
mpsaleOrderpreView,
|
||||
mpsaleOrderpost,
|
||||
mpsaleOrderpost,
|
||||
mpsaleOrderpreView,
|
||||
} from '@/api/order'
|
||||
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'
|
||||
|
||||
export default () => {
|
||||
const router: any = useRouter()
|
||||
const [infoObj, setInfoObj] = useState<any>({})
|
||||
let selectId: number = -1
|
||||
useDidShow(() => {
|
||||
//获取选择的地址
|
||||
let pages = Taro.getCurrentPages();
|
||||
let currPage = pages[pages.length - 1]; // 获取当前页面
|
||||
setInfoObj((val) => ({
|
||||
...val,
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
province_name: currPage.data?.addressObj?.province_name ? currPage.data?.addressObj?.province_name : '',
|
||||
address_id: currPage.data?.addressObj?.id ? currPage.data?.addressObj?.id : '',
|
||||
city_name: currPage.data?.addressObj?.city_name ? currPage.data?.addressObj?.city_name : '',
|
||||
address_detail: currPage.data?.addressObj?.address_detail ? currPage.data?.addressObj?.address_detail : '',
|
||||
district_name: currPage.data?.addressObj?.district_name ? currPage.data?.addressObj?.district_name : '',
|
||||
target_user_name: currPage.data?.addressObj?.name ? currPage.data?.addressObj?.name : '',
|
||||
purchaser_phone: currPage.data?.addressObj?.phone ? currPage.data?.addressObj?.phone : '',
|
||||
}))
|
||||
selectId = currPage.data?.addressObj?.id
|
||||
let obj = currPage?.data?.ids?.filter(item => { return item == selectId })
|
||||
if (currPage?.data?.ids && obj.length === 0) {
|
||||
setInfoObj((val) => ({
|
||||
...val,
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
province_name: '',
|
||||
address_id: '',
|
||||
city_name: '',
|
||||
address_detail: '',
|
||||
district_name: '',
|
||||
target_user_name: '',
|
||||
purchaser_phone: '',
|
||||
}))
|
||||
}
|
||||
if (!currPage.data?.addressObj) {
|
||||
setReceivingStatus(1)
|
||||
} else {
|
||||
setReceivingStatus(2)
|
||||
}
|
||||
const router: any = useRouter()
|
||||
const [infoObj, setInfoObj] = useState<any>({})
|
||||
let selectId = -1
|
||||
useDidShow(() => {
|
||||
// 获取选择的地址
|
||||
const pages = Taro.getCurrentPages()
|
||||
const currPage = pages[pages.length - 1] // 获取当前页面
|
||||
setInfoObj(val => ({
|
||||
...val,
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
province_name: currPage.data?.addressObj?.province_name ? currPage.data?.addressObj?.province_name : '',
|
||||
address_id: currPage.data?.addressObj?.id ? currPage.data?.addressObj?.id : '',
|
||||
city_name: currPage.data?.addressObj?.city_name ? currPage.data?.addressObj?.city_name : '',
|
||||
address_detail: currPage.data?.addressObj?.address_detail ? currPage.data?.addressObj?.address_detail : '',
|
||||
district_name: currPage.data?.addressObj?.district_name ? currPage.data?.addressObj?.district_name : '',
|
||||
target_user_name: currPage.data?.addressObj?.name ? currPage.data?.addressObj?.name : '',
|
||||
purchaser_phone: currPage.data?.addressObj?.phone ? currPage.data?.addressObj?.phone : '',
|
||||
}))
|
||||
selectId = currPage.data?.addressObj?.id
|
||||
const obj = currPage?.data?.ids?.filter((item) => { return item == selectId })
|
||||
if (currPage?.data?.ids && obj.length === 0) {
|
||||
setInfoObj(val => ({
|
||||
...val,
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
province_name: '',
|
||||
address_id: '',
|
||||
city_name: '',
|
||||
address_detail: '',
|
||||
district_name: '',
|
||||
target_user_name: '',
|
||||
purchaser_phone: '',
|
||||
}))
|
||||
}
|
||||
if (!currPage.data?.addressObj) {
|
||||
setReceivingStatus(1)
|
||||
}
|
||||
else {
|
||||
setReceivingStatus(2)
|
||||
}
|
||||
})
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
|
||||
// 收货方法,1:自提,2物流
|
||||
const [receivingStatus, setReceivingStatus] = useState<any>(null)
|
||||
// 切换自提或者物流
|
||||
const onReceivingStatus = debounce(async(e, value) => {
|
||||
e.stopPropagation()
|
||||
if (receivingStatus == value) {
|
||||
alert.error('不能选择相同的方式')
|
||||
return false
|
||||
}
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
})
|
||||
useEffect(() => {
|
||||
getDetail()
|
||||
}, [])
|
||||
setReceivingStatus(value)
|
||||
Taro.hideLoading()
|
||||
}, 300)
|
||||
|
||||
const { fetchData: infoFetch } = mpsaleOrderpreView()
|
||||
const [pussName, setPusername] = useState<String>('')
|
||||
// 获取订单详情
|
||||
const getDetail = async() => {
|
||||
let arr: any[] = []
|
||||
setPusername(decodeURIComponent(router.params.purchaser_name))
|
||||
arr = JSON.parse(decodeURIComponent(router.params.shopping_cart_product_color_list))
|
||||
const list: any[] = []
|
||||
arr?.forEach((item) => {
|
||||
list.push({
|
||||
shopping_cart_product_color_id: item,
|
||||
sale_price: 0,
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: Number(router.params.purchaser_id),
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
shopping_cart_product_color_list: list,
|
||||
}
|
||||
const res = await infoFetch(query)
|
||||
setInfoObj(res.data)
|
||||
}
|
||||
|
||||
//收货方法,1:自提,2物流
|
||||
const [receivingStatus, setReceivingStatus] = useState<any>(null)
|
||||
//切换自提或者物流
|
||||
const onReceivingStatus = debounce(async (e, value) => {
|
||||
e.stopPropagation()
|
||||
if (receivingStatus == value) {
|
||||
alert.error('不能选择相同的方式')
|
||||
return false
|
||||
}
|
||||
Taro.showLoading({
|
||||
// 备注操作
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const getRemark = useCallback(async(e) => {
|
||||
setShowDesc(false)
|
||||
setInfoObj(val => ({ ...val, remark: e }))
|
||||
}, [])
|
||||
|
||||
const handSelect = (obj) => {
|
||||
if (receivingStatus == 1) { return false }
|
||||
Taro.navigateTo({
|
||||
url: '/pages/addressManager/index?orderId=' + '-100' + `&purchaser_id=${router.params.purchaser_id}`,
|
||||
})
|
||||
}
|
||||
|
||||
// 提交订单
|
||||
const { fetchData: postFetch } = mpsaleOrderpost()
|
||||
const handSure = () => {
|
||||
if (receivingStatus == 2 && !infoObj.address_id) {
|
||||
return alert.error('请选择地址')
|
||||
}
|
||||
const list: any[] = []
|
||||
infoObj.product_list.forEach((item) => {
|
||||
item.product_colors.forEach((it) => {
|
||||
list.push({
|
||||
sale_price: it.sale_price,
|
||||
shopping_cart_product_color_id: Number(it.id),
|
||||
})
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
address_id: Number(infoObj.address_id) ? Number(infoObj.address_id) : 0,
|
||||
list,
|
||||
physical_warehouse: infoObj.physical_warehouse,
|
||||
purchaser_id: Number(router.params.purchaser_id),
|
||||
remark: infoObj.remark,
|
||||
sale_mode: infoObj.sale_mode,
|
||||
shipment_mode: receivingStatus,
|
||||
}
|
||||
Taro.showModal({
|
||||
content: '确认提交吗?',
|
||||
confirmText: '确认',
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
setReceivingStatus(value)
|
||||
Taro.hideLoading()
|
||||
}, 300)
|
||||
|
||||
const { fetchData: infoFetch } = mpsaleOrderpreView()
|
||||
const [pussName, setPusername] = useState<String>('')
|
||||
//获取订单详情
|
||||
const getDetail = async () => {
|
||||
let arr: any[] = []
|
||||
setPusername(decodeURIComponent(router.params.purchaser_name))
|
||||
arr = JSON.parse(decodeURIComponent(router.params.shopping_cart_product_color_list))
|
||||
let list: any[] = []
|
||||
arr?.forEach(item => {
|
||||
list.push({
|
||||
shopping_cart_product_color_id: item,
|
||||
sale_price: 0
|
||||
mask: true,
|
||||
})
|
||||
const res = await postFetch(query)
|
||||
if (res?.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功',
|
||||
})
|
||||
})
|
||||
const query = {
|
||||
purchaser_id: Number(router.params.purchaser_id),
|
||||
sale_mode: Number(router.params.sale_mode),
|
||||
shopping_cart_product_color_list: list
|
||||
}
|
||||
const res = await infoFetch(query)
|
||||
setInfoObj(res.data)
|
||||
}
|
||||
|
||||
//备注操作
|
||||
const [showDesc, setShowDesc] = useState(false)
|
||||
const getRemark = useCallback(async (e) => {
|
||||
setShowDesc(false)
|
||||
setInfoObj((val) => ({ ...val, remark: e }))
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
|
||||
const handSelect = (obj) => {
|
||||
if (receivingStatus == 1) return false
|
||||
Taro.navigateTo({
|
||||
url: '/pages/addressManager/index?orderId=' + '-100' + '&purchaser_id=' + router.params.purchaser_id
|
||||
})
|
||||
}
|
||||
|
||||
//提交订单
|
||||
const { fetchData: postFetch } = mpsaleOrderpost()
|
||||
const handSure = () => {
|
||||
if (receivingStatus == 2 && !infoObj.address_id) {
|
||||
return alert.error('请选择地址')
|
||||
}
|
||||
let list: any[] = []
|
||||
infoObj.product_list.forEach(item => {
|
||||
item.product_colors.forEach(it => {
|
||||
list.push({
|
||||
sale_price: it.sale_price,
|
||||
shopping_cart_product_color_id: Number(it.id)
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.redirectTo({
|
||||
url: `/pages/orderDetails/index?id=${res.data.id}`,
|
||||
})
|
||||
})
|
||||
let query = {
|
||||
address_id: Number(infoObj.address_id) ? Number(infoObj.address_id) : 0,
|
||||
list: list,
|
||||
physical_warehouse: infoObj.physical_warehouse,
|
||||
purchaser_id: Number(router.params.purchaser_id),
|
||||
remark: infoObj.remark,
|
||||
sale_mode: infoObj.sale_mode,
|
||||
shipment_mode: receivingStatus
|
||||
}
|
||||
else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res?.msg,
|
||||
icon: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
Taro.showModal({
|
||||
content: "确认提交吗?",
|
||||
confirmText: "确认",
|
||||
cancelText: "取消",
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true
|
||||
})
|
||||
const res = await postFetch(query)
|
||||
if (res?.msg === 'success') {
|
||||
Taro.showToast({
|
||||
title: '成功'
|
||||
})
|
||||
Taro.hideLoading()
|
||||
Taro.redirectTo({
|
||||
url: '/pages/orderDetails/index?id=' + res.data.id
|
||||
})
|
||||
} else {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: res?.msg,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setInfoObj(infoObj)
|
||||
}, [infoObj])
|
||||
return (
|
||||
<View className={styles.mainBox}>
|
||||
<AddressDetailBox
|
||||
navSelect={(obj) => handSelect(obj)}
|
||||
obj={infoObj}
|
||||
receivingStatus={receivingStatus}
|
||||
onReceivingStatus={(e, value) => onReceivingStatus(e, value)}
|
||||
></AddressDetailBox>
|
||||
<DefaultBox
|
||||
showMode={true}
|
||||
title={'客户信息'}
|
||||
modeName={infoObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{pussName}</View>
|
||||
{/* <View className={styles.pussPhone}>{infoObj.purchaser_phone}</View> */}
|
||||
</View>
|
||||
</DefaultBox>
|
||||
{/* <View className={styles.total}> {infoObj.product_list?.length} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
<View className={styles.productBox}>
|
||||
<GoodsItem list={infoObj?.product_list} obj={infoObj}></GoodsItem>
|
||||
<View className={styles.flexMoney}>
|
||||
<View className={styles.flexTotalBox}>
|
||||
<View className={styles.totalFont}>合计金额</View>
|
||||
<IconFont name={'icon-tishi'} size={28} ></IconFont>
|
||||
{/* <View className={classnames('iconfont', 'icon-tishi', styles.tishi)}></View> */}
|
||||
</View>
|
||||
<View className={styles.shoudPay}>¥{formatPriceDiv(infoObj.estimate_amount)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<DefaultBox title={'备注信息'} showMode={true} modeName={`${'填写/修改备注'} >`} clickNode={() => setShowDesc(true)}>
|
||||
<View className={styles.remarkFont}>{infoObj.remark === '' ? '暂无' : infoObj.remark}</View>
|
||||
</DefaultBox>
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
<Remark onSave={(e) => getRemark(e)} defaultValue={infoObj.remark} showInput={showDesc ? true : false} />
|
||||
</Popup>
|
||||
<View className={styles.safeBottom}></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<View className={styles.leftBottom}>
|
||||
<View className={styles.topFlex}>
|
||||
<View className={styles.topFont}>预估金额:</View>
|
||||
<View className={styles.topTotal}>¥{formatPriceDiv(infoObj.estimate_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.bottomFlex}>{infoObj.product_list?.length} 种面料,{infoObj.total_colors} 种颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
<View className={styles.rightBottom} onClick={() => handSure()}>提交订单</View>
|
||||
</View>
|
||||
useEffect(() => {
|
||||
setInfoObj(infoObj)
|
||||
}, [infoObj])
|
||||
return (
|
||||
<View className={styles.mainBox}>
|
||||
<AddressDetailBox
|
||||
navSelect={obj => handSelect(obj)}
|
||||
obj={infoObj}
|
||||
receivingStatus={receivingStatus}
|
||||
onReceivingStatus={(e, value) => onReceivingStatus(e, value)}
|
||||
></AddressDetailBox>
|
||||
<DefaultBox
|
||||
showMode
|
||||
title="客户信息"
|
||||
modeName={infoObj.sale_mode_name}
|
||||
>
|
||||
<View className={styles.pussBox}>
|
||||
<View className={styles.pussName}>{pussName}</View>
|
||||
{/* <View className={styles.pussPhone}>{infoObj.purchaser_phone}</View> */}
|
||||
</View>
|
||||
)
|
||||
</DefaultBox>
|
||||
{/* <View className={styles.total}> {infoObj.product_list?.length} 种面料,{infoObj.total_colors} 个颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View> */}
|
||||
<View className={styles.productBox}>
|
||||
<GoodsItem list={infoObj?.product_list} obj={infoObj}></GoodsItem>
|
||||
<View className={styles.flexMoney}>
|
||||
<View className={styles.flexTotalBox}>
|
||||
<View className={styles.totalFont}>合计金额</View>
|
||||
<IconFont name="icon-tishi" size={28} ></IconFont>
|
||||
{/* <View className={classnames('iconfont', 'icon-tishi', styles.tishi)}></View> */}
|
||||
</View>
|
||||
<View className={styles.shoudPay}>¥{formatPriceDiv(infoObj.estimate_amount)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<DefaultBox title="备注信息" showMode modeName={`${'填写/修改备注'} >`} clickNode={() => setShowDesc(true)}>
|
||||
<View className={styles.remarkFont}>{infoObj.remark === '' ? '暂无' : infoObj.remark}</View>
|
||||
</DefaultBox>
|
||||
<Popup show={showDesc} showTitle={false} onClose={() => setShowDesc(false)}>
|
||||
<Remark onSave={e => getRemark(e)} defaultValue={infoObj.remark} showInput={!!showDesc} />
|
||||
</Popup>
|
||||
<View className={styles.safeBottom}></View>
|
||||
<View className={styles.bottomBox}>
|
||||
<View className={styles.leftBottom}>
|
||||
<View className={styles.topFlex}>
|
||||
<View className={styles.topFont}>预估金额:</View>
|
||||
<View className={styles.topTotal}>¥{formatPriceDiv(infoObj.estimate_amount)}</View>
|
||||
</View>
|
||||
<View className={styles.bottomFlex}>{infoObj.product_list?.length} 种面料,{infoObj.total_colors} 种颜色,共 {infoObj.sale_mode === 0 ? infoObj.total_number : infoObj.total_number / 100} {infoObj.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
<View className={styles.rightBottom} onClick={() => handSure()}>提交订单</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
//卡片盒子元素
|
||||
// 卡片盒子元素
|
||||
interface Obs {
|
||||
title?: string,
|
||||
modeName?: string,
|
||||
showMode?: boolean,
|
||||
children?: ReactNode,
|
||||
clickNode?: () => void
|
||||
title?: string
|
||||
modeName?: string
|
||||
showMode?: boolean
|
||||
children?: ReactNode
|
||||
clickNode?: () => void
|
||||
}
|
||||
|
||||
const DefaultBox = memo((props: Obs) => {
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode
|
||||
} = props
|
||||
const {
|
||||
title = '标题',
|
||||
modeName = '大货',
|
||||
showMode = false,
|
||||
children,
|
||||
clickNode,
|
||||
} = props
|
||||
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
return (
|
||||
<View className={styles.defaltBox}>
|
||||
<View className={styles.titleBox}>
|
||||
<View className={styles.title}>{title}</View>
|
||||
{
|
||||
showMode && <View className={styles.modeName} onClick={() => clickNode?.()}>{modeName}</View>
|
||||
}
|
||||
</View>
|
||||
<View className={styles.modeLine}></View>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
//产品商品元素
|
||||
// 产品商品元素
|
||||
interface PropGoods {
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[],
|
||||
obj: {
|
||||
sale_mode?: number | string
|
||||
},
|
||||
// item?: {
|
||||
// code?: string | number
|
||||
// }
|
||||
list: any[]
|
||||
obj: {
|
||||
sale_mode?: number | string
|
||||
}
|
||||
}
|
||||
const GoodsItem = memo((porps: PropGoods) => {
|
||||
const { list = [], obj = {} } = porps
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
<View className={styles.goodsLine}></View>
|
||||
{
|
||||
item.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
<View className={styles.itemPic} style={{ backgroundColor: `rgb(${it?.rgb?.r} ${it?.rgb?.g} ${it?.rgb?.b})` }}></View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code} {it.name}</View>
|
||||
<View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'}</View>
|
||||
<View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.estimate_amount)}</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
const { list = [], obj = {} } = porps
|
||||
return (
|
||||
<>
|
||||
{
|
||||
list.map((item, index) => {
|
||||
return (
|
||||
<View className={styles.goodsBox} key={index}>
|
||||
<View className={styles.goodsProduct}>{item.code}# {item.name}</View>
|
||||
<View className={styles.goodsLine}></View>
|
||||
{
|
||||
item.product_colors.map((it, inx) => {
|
||||
return (
|
||||
<View className={styles.itemGoods}>
|
||||
<View className={styles.itemPic} style={{ backgroundColor: `rgb(${it?.rgb?.r} ${it?.rgb?.g} ${it?.rgb?.b})` }}></View>
|
||||
<View className={styles.itemRight}>
|
||||
<View className={styles.item_right_top}>
|
||||
<View className={styles.itemName}>{it.code} {it.name}</View>
|
||||
<View className={styles.itemNums}>x{obj?.sale_mode === 0 ? it.roll : it.length / 100}{obj?.sale_mode === 0 ? '条' : 'm'}</View>
|
||||
</View>
|
||||
)
|
||||
<View className={styles.item_right_Bottom}>
|
||||
<View className={styles.itemMoney}>¥{it.sale_price / 100}/{obj?.sale_mode === 1 ? 'm' : 'kg'}</View>
|
||||
<View className={styles.itemMoneyOne}>¥{formatPriceDiv(it.estimate_amount)}</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</>
|
||||
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import SegmentedControl from '@/components/segmentedControl'
|
||||
import { FC, memo, useCallback, useEffect, useState } from 'react'
|
||||
import SegmentedControl from '@/components/segmentedControl'
|
||||
import { EnumTakeGoodsOrderStatus } from '@/api/index'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
onChangeStatus?: (data: { id: number; name: string }) => void
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const DeliveryStatusList = memo<PropsType>((props) => {
|
||||
},
|
||||
])
|
||||
// 请求
|
||||
const getDeliveryStatusList = async () => {
|
||||
const getDeliveryStatusList = async() => {
|
||||
const res = await fetchData()
|
||||
console.log(res.data.list)
|
||||
setStatusList(
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import { View } from '@tarojs/components'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import React, { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import dayjs from 'dayjs'
|
||||
import styles from './index.module.scss'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import Search from '@/components/search'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import { EnumTakeGoodsOrderTypeList } from '@/api/index'
|
||||
import dayjs from 'dayjs'
|
||||
import { getFilterData } from '@/common/util'
|
||||
import FilterButton from '@/components/filterButton'
|
||||
|
||||
@@ -72,26 +72,25 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
const handleSelectedType = (type: string | number) => {
|
||||
console.log('type==>', type)
|
||||
if (typeof type === 'string' && type === 'default') {
|
||||
setSearchFilter((e) => ({ ...e, take_goods_order_type: undefined }))
|
||||
} else {
|
||||
setSearchFilter((e) => ({ ...e, take_goods_order_type: type as number }))
|
||||
setSearchFilter(e => ({ ...e, take_goods_order_type: undefined }))
|
||||
}
|
||||
else {
|
||||
setSearchFilter(e => ({ ...e, take_goods_order_type: type as number }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const typeList = useMemo<{ id: number; name: string }[]>(() => {
|
||||
return state.data.list
|
||||
}, [state])
|
||||
|
||||
useEffect(() => {
|
||||
if (!!!typeList?.length) {
|
||||
if (!typeList?.length) {
|
||||
getEnumData()
|
||||
console.log('getEnumData')
|
||||
}
|
||||
}, [typeList])
|
||||
|
||||
const getEnumData = async () => {
|
||||
const getEnumData = async() => {
|
||||
await fetchData()
|
||||
}
|
||||
|
||||
@@ -100,23 +99,21 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
date_max: undefined,
|
||||
})
|
||||
|
||||
|
||||
|
||||
const handleSelectedTime = (timeOptionId) => {
|
||||
setSearchFilter((e) => ({ ...e, timeKey: timeOptionId }))
|
||||
setSearchFilter(e => ({ ...e, timeKey: timeOptionId }))
|
||||
// 不是设置了自定义时间
|
||||
if (timeOptionId !== '6') {
|
||||
setCustomTime({
|
||||
date_min: filterTimeOptions[timeOptionId]['date_min'],
|
||||
date_max: filterTimeOptions[timeOptionId]['date_max'],
|
||||
date_min: filterTimeOptions[timeOptionId].date_min,
|
||||
date_max: filterTimeOptions[timeOptionId].date_max,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
onSearchTime?.()
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
setSearchFilter({ take_goods_order_type: undefined, timeKey: '0'})
|
||||
setSearchFilter({ take_goods_order_type: undefined, timeKey: '0' })
|
||||
onReset?.()
|
||||
}
|
||||
const handleConfirm = () => {
|
||||
@@ -129,7 +126,6 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
onConfirm?.(changedField, searchFilter.timeKey)
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.filterItem}>
|
||||
@@ -138,8 +134,8 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
<FilterButton isActive={searchFilter.take_goods_order_type == undefined} onClick={() => handleSelectedType('default')}>
|
||||
不限
|
||||
</FilterButton>
|
||||
{!!typeList?.length &&
|
||||
typeList?.map(item => {
|
||||
{!!typeList?.length
|
||||
&& typeList?.map((item) => {
|
||||
return (
|
||||
<FilterButton isActive={searchFilter.take_goods_order_type === item?.id} onClick={() => handleSelectedType(item?.id)}>
|
||||
{item.name}
|
||||
@@ -163,15 +159,15 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
)
|
||||
})}
|
||||
<FilterButton isActive={searchFilter.timeKey === '6'} customClassName={styles.filterTimeButton} onClick={() => handleSelectedTime('6')}>
|
||||
自定义时间<IconFont name='icon-chakanquanbukehu' size={40} color={searchFilter.timeKey === '6' ? '#4581ff' : '#909090'}></IconFont>
|
||||
自定义时间<IconFont name="icon-chakanquanbukehu" size={40} color={searchFilter.timeKey === '6' ? '#4581ff' : '#909090'}></IconFont>
|
||||
</FilterButton>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.filterController}>
|
||||
<NormalButton type='primary' plain round customClassName={classnames(styles.btn, styles.rest_btn)} onClick={handleReset}>
|
||||
<NormalButton type="primary" plain round customClassName={classnames(styles.btn, styles.rest_btn)} onClick={handleReset}>
|
||||
重置
|
||||
</NormalButton>
|
||||
<NormalButton type='primary' round customClassName={classnames(styles.btn, styles.verify_btn)} onClick={handleConfirm}>
|
||||
<NormalButton type="primary" round customClassName={classnames(styles.btn, styles.verify_btn)} onClick={handleConfirm}>
|
||||
确认
|
||||
</NormalButton>
|
||||
</View>
|
||||
@@ -179,5 +175,4 @@ const DeliveryFilter = memo<DeliveryPropsType>((props) => {
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
export default DeliveryFilter
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.module.scss'
|
||||
import LayoutBlock from '@/components/layoutBlock'
|
||||
import Divider from '@/components/divider'
|
||||
import Tag from '@/components/tag'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { FC } from 'react'
|
||||
import NormalButton from '@/components/normalButton'
|
||||
import styles from './index.module.scss'
|
||||
import classnames from 'classnames'
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
import { formatDateTime, formatMeterDiv } from '@/common/format'
|
||||
import { goLink } from '@/common/common'
|
||||
import { TakeGoodsOrderAudit } from '@/api/index'
|
||||
import Taro from '@tarojs/taro'
|
||||
import SaleModeTag from '@/components/saleModeTag'
|
||||
|
||||
type PropsType = {
|
||||
interface PropsType {
|
||||
itemData: Record<string, any>
|
||||
onSuccess?: Function
|
||||
}
|
||||
|
||||
const ItemList:FC<PropsType> = (props) => {
|
||||
const ItemList: FC<PropsType> = (props) => {
|
||||
const { itemData, onSuccess } = props
|
||||
// 查看详情
|
||||
const handleDetail = (itemData: Record<string, any>) => {
|
||||
@@ -34,13 +34,14 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
Taro.showModal({
|
||||
content: '确认要提货吗?',
|
||||
confirmColor: '#337FFF',
|
||||
success: async (res) => {
|
||||
success: async(res) => {
|
||||
if (res.confirm) {
|
||||
const res = await fetchData({ take_goods_order_id: [id] })
|
||||
if (res.success) {
|
||||
Taro.showToast({ title: '提货成功', icon: 'success' })
|
||||
onSuccess?.()
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
Taro.showToast({ title: '操作失败', icon: 'error' })
|
||||
}
|
||||
}
|
||||
@@ -60,12 +61,12 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
</View>
|
||||
<Text className={styles.topBar__orderType}>{itemData?.take_goods_order_type_name}</Text>
|
||||
</View>
|
||||
<Divider direction='horizontal' customStyles={{ margin: '20rpx 0 10rpx 0' }}></Divider>
|
||||
<Divider direction="horizontal" customStyles={{ margin: '20rpx 0 10rpx 0' }}></Divider>
|
||||
<View className={styles.content}>
|
||||
<View className={classnames(styles.content__row, styles.bord)}>
|
||||
<View className={styles.content__row__left}>货品信息:</View>
|
||||
<View className={styles.content__row__right}>
|
||||
<SaleModeTag saleMode={itemData.sale_mode} size='small' customClassName={styles.tag}></SaleModeTag>
|
||||
<SaleModeTag saleMode={itemData.sale_mode} size="small" customClassName={styles.tag}></SaleModeTag>
|
||||
{itemData.product_count}种面料,{itemData.product_color_count}种颜色,共
|
||||
{itemData?.sale_mode === EnumSaleMode.Bulk ? `${itemData?.take_roll}条` : `${formatMeterDiv(itemData?.take_meters)}米`}
|
||||
</View>
|
||||
@@ -82,15 +83,16 @@ const ItemList:FC<PropsType> = (props) => {
|
||||
<View className={styles.bottomBar}>
|
||||
<NormalButton
|
||||
customClassName={styles.bottomBar__button}
|
||||
type='info'
|
||||
type="info"
|
||||
plain
|
||||
customStyles={{ color: '#636363', borderColor: '#c8c8c8' }}
|
||||
round
|
||||
onClick={() => handleDetail(itemData)}>
|
||||
onClick={() => handleDetail(itemData)}
|
||||
>
|
||||
查看详情
|
||||
</NormalButton>
|
||||
{itemData?.status === 0 && (
|
||||
<NormalButton plain customClassName={styles.bottomBar__button} type='primary' round onClick={() => handleAudit(itemData?.id)}>
|
||||
<NormalButton plain customClassName={styles.bottomBar__button} type="primary" round onClick={() => handleAudit(itemData?.id)}>
|
||||
确认审核
|
||||
</NormalButton>
|
||||
)}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import Popup from "@/components/popup"
|
||||
import { Textarea, View } from "@tarojs/components"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import { Textarea, View } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
|
||||
type Param = {
|
||||
onBlur?: (val:any) => void
|
||||
onSave?: (val: string) => void
|
||||
defaultValue?: string
|
||||
interface Param {
|
||||
onBlur?: (val: any) => void
|
||||
onSave?: (val: string) => void
|
||||
defaultValue?: string
|
||||
}
|
||||
export default ({onBlur, onSave, defaultValue = ''}:Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200
|
||||
})
|
||||
export default ({ onBlur, onSave, defaultValue = '' }: Param) => {
|
||||
const [descData, setDescData] = useState({
|
||||
number: 0,
|
||||
value: '',
|
||||
count: 200,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
useEffect(() => {
|
||||
getDesc(defaultValue)
|
||||
}, [defaultValue])
|
||||
|
||||
const getDesc = (value) => {
|
||||
let res = value
|
||||
if(value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({...descData, number:res.length, value: res})
|
||||
const getDesc = (value) => {
|
||||
let res = value
|
||||
if (value.length > descData.count) {
|
||||
res = value.slice(0, descData.count)
|
||||
}
|
||||
setDescData({ ...descData, number: res.length, value: res })
|
||||
}
|
||||
|
||||
const setSave = () => {
|
||||
onSave?.(descData.value)
|
||||
}
|
||||
return (
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>编辑备注</View>
|
||||
<View className={styles.order_popup_input}>
|
||||
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={(e) => getDesc(e.detail.value)} onBlur={(e) => onBlur?.(e)}></Textarea>
|
||||
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
|
||||
</View>
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
const setSave = () => {
|
||||
onSave?.(descData.value)
|
||||
}
|
||||
return (
|
||||
<View className={styles.order_popup}>
|
||||
<View className={styles.order_popup_title}>编辑备注</View>
|
||||
<View className={styles.order_popup_input}>
|
||||
<Textarea placeholder="请添加备注" value={descData?.value} maxlength={descData.count} cursorSpacing={100} onInput={e => getDesc(e.detail.value)} onBlur={e => onBlur?.(e)}></Textarea>
|
||||
<View className={styles.descDataNum}>{descData.number}/{descData.count}</View>
|
||||
</View>
|
||||
<View className={styles.order_save_address} onClick={() => setSave()}>保存</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, FC, memo } from 'react'
|
||||
import { Text, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, useRouter } from '@tarojs/taro'
|
||||
import type { FC } from 'react'
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import styles from './index.module.scss'
|
||||
import ItemList from './components/ItemList'
|
||||
import DeliveryStatusList from './components/DeliveryStatusList'
|
||||
import type { SearchField } from './components/Filter'
|
||||
import DeliveryFilter from './components/Filter'
|
||||
import Search from '@/components/search'
|
||||
import { TakeGoodsOrderList } from '@/api/index'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import { dataLoadingStatus, getFilterData } from '@/common/util'
|
||||
import IconText from '@/components/iconText'
|
||||
import IconFont from '@/components/iconfont/iconfont'
|
||||
import ItemList from './components/ItemList'
|
||||
import DeliveryStatusList from './components/DeliveryStatusList'
|
||||
import Popup from '@/components/popup'
|
||||
import DeliveryFilter, { SearchField } from './components/Filter'
|
||||
import TimePickerPopup from '@/components/timePickerPopup'
|
||||
import Empty from '@/components/empty'
|
||||
import { LIST_EMPTY_IMAGE } from '@/common/constant'
|
||||
|
||||
type SearchData = {
|
||||
interface SearchData {
|
||||
take_goods_order_no?: string // 提货单号
|
||||
take_goods_status?: number | string // 提货状态
|
||||
date_min?: string // 开始时间
|
||||
@@ -27,8 +28,6 @@ type SearchData = {
|
||||
size: number
|
||||
}
|
||||
|
||||
|
||||
|
||||
const defaultSearchFields = {
|
||||
take_goods_status: 0, // 待提货
|
||||
page: 1,
|
||||
@@ -43,55 +42,55 @@ const Delivery: FC = () => {
|
||||
const isFirst = useRef(true)
|
||||
|
||||
const { fetchData: FetchDeliveryOrderList, state: orderState } = TakeGoodsOrderList()
|
||||
//数据加载状态
|
||||
// 数据加载状态
|
||||
const statusMore = useMemo(() => {
|
||||
return dataLoadingStatus({ list: takeDeliveryOrderList.list, total: takeDeliveryOrderList.total, status: orderState.loading! })
|
||||
}, [takeDeliveryOrderList, orderState])
|
||||
|
||||
//输入搜索关键字
|
||||
// 输入搜索关键字
|
||||
const getSearchData = useCallback((searchValue: string) => {
|
||||
setSearch((prevProps) => ({ ...prevProps, take_goods_order_no: searchValue }))
|
||||
setSearch(prevProps => ({ ...prevProps, take_goods_order_no: searchValue }))
|
||||
console.log('searchValue==>', searchValue)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('useEffect ===> search', search)
|
||||
// 已经不是第一次加载该页面了
|
||||
if(!isFirst.current){
|
||||
if (!isFirst.current) {
|
||||
getData()
|
||||
}
|
||||
}, [search])
|
||||
|
||||
useDidShow(()=>{
|
||||
useDidShow(() => {
|
||||
getData()
|
||||
isFirst.current = false
|
||||
})
|
||||
|
||||
//上拉加载数据
|
||||
// 上拉加载数据
|
||||
const pageNum = useRef({ size: search.size, page: search.page })
|
||||
|
||||
const getScrollToLower = useCallback(() => {
|
||||
if (takeDeliveryOrderList.list.length < takeDeliveryOrderList.total) {
|
||||
pageNum.current.page++
|
||||
const size = pageNum.current.size * pageNum.current.page
|
||||
setSearch((e) => ({ ...e, size }))
|
||||
setSearch(e => ({ ...e, size }))
|
||||
console.log(search, 11111)
|
||||
}
|
||||
}, [takeDeliveryOrderList])
|
||||
|
||||
//列表下拉刷新
|
||||
// 列表下拉刷新
|
||||
const [refresherTriggeredStatus, setRefresherTriggeredStatus] = useState(false)
|
||||
|
||||
const getRefresherRefresh = async () => {
|
||||
const getRefresherRefresh = async() => {
|
||||
pageNum.current.size = 1
|
||||
setRefresherTriggeredStatus(true)
|
||||
setSearch((val) => ({ ...val, size: 10 }))
|
||||
setSearch(val => ({ ...val, size: 10 }))
|
||||
}
|
||||
// 请求数据
|
||||
const getData = async () => {
|
||||
const getData = async() => {
|
||||
const res = await FetchDeliveryOrderList(getFilterData(search))
|
||||
|
||||
setDeliveryOrderList((e) => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setDeliveryOrderList(e => ({ ...e, list: res.data?.list, total: res.data?.total }))
|
||||
setRefresherTriggeredStatus(() => false)
|
||||
}
|
||||
|
||||
@@ -99,7 +98,7 @@ const Delivery: FC = () => {
|
||||
|
||||
const handleChangeStatus = ({ id: statusId, name: statusName }) => {
|
||||
setCurrentStatus(statusName)
|
||||
setSearch((e) => ({ ...e, take_goods_status: statusId }))
|
||||
setSearch(e => ({ ...e, take_goods_status: statusId }))
|
||||
}
|
||||
|
||||
const handleAuditSuccess = () => {
|
||||
@@ -142,9 +141,10 @@ const Delivery: FC = () => {
|
||||
console.log('changedFields==>changedFields', changedFields)
|
||||
// 自定义时间
|
||||
if (timeKey === '6') {
|
||||
setSearch((prevProps) => ({ ...prevProps, ...changedFields, date_min: start, date_max: end }))
|
||||
} else {
|
||||
setSearch((prevProps) => ({ ...prevProps, ...changedFields }))
|
||||
setSearch(prevProps => ({ ...prevProps, ...changedFields, date_min: start, date_max: end }))
|
||||
}
|
||||
else {
|
||||
setSearch(prevProps => ({ ...prevProps, ...changedFields }))
|
||||
}
|
||||
handlePopupClose()
|
||||
}
|
||||
@@ -159,7 +159,7 @@ const Delivery: FC = () => {
|
||||
const handleScan = () => {
|
||||
Taro.scanCode({
|
||||
success(res) {
|
||||
setSearch((e) => ({ ...e, take_goods_order_no: res.result }))
|
||||
setSearch(e => ({ ...e, take_goods_order_no: res.result }))
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res)
|
||||
@@ -168,7 +168,7 @@ const Delivery: FC = () => {
|
||||
}
|
||||
return (
|
||||
<View onClick={handleScan} className={styles.scanHandler}>
|
||||
<IconFont name='icon-saomiao' size={40}></IconFont>
|
||||
<IconFont name="icon-saomiao" size={40}></IconFont>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -176,9 +176,9 @@ const Delivery: FC = () => {
|
||||
return (
|
||||
<View className={styles.delivery}>
|
||||
<View className={styles.searchBox}>
|
||||
<Search placeholder='请输入或扫描条形码' showBtn={false} changeOnSearch={getSearchData} debounceTime={300} customRightSlot={scanIcon()}>
|
||||
<Search placeholder="请输入或扫描条形码" showBtn={false} changeOnSearch={getSearchData} debounceTime={300} customRightSlot={scanIcon()}>
|
||||
<View onClick={onShowFilter} className={styles.icon__filter}>
|
||||
<IconText svg iconName='icon-shaixuan' text='筛选' customClass={styles['icon--filter']} />
|
||||
<IconText svg iconName="icon-shaixuan" text="筛选" customClass={styles['icon--filter']} />
|
||||
</View>
|
||||
</Search>
|
||||
</View>
|
||||
@@ -187,12 +187,13 @@ const Delivery: FC = () => {
|
||||
|
||||
<View className={styles.listBox}>
|
||||
<InfiniteScroll
|
||||
emptySlot={<Empty picUrl={LIST_EMPTY_IMAGE} text='暂无数据'/>}
|
||||
emptySlot={<Empty picUrl={LIST_EMPTY_IMAGE} text="暂无数据" />}
|
||||
statusMore={statusMore}
|
||||
selfonScrollToLower={getScrollToLower}
|
||||
refresherEnabled={true}
|
||||
refresherEnabled
|
||||
refresherTriggered={refresherTriggeredStatus}
|
||||
selfOnRefresherRefresh={getRefresherRefresh}>
|
||||
selfOnRefresherRefresh={getRefresherRefresh}
|
||||
>
|
||||
<Text className={styles['listBox--total']}>
|
||||
{currentStatus}共 {takeDeliveryOrderList.total} 单
|
||||
</Text>
|
||||
@@ -201,10 +202,10 @@ const Delivery: FC = () => {
|
||||
})}
|
||||
</InfiniteScroll>
|
||||
</View>
|
||||
<Popup show={showFilter} title='筛选列表' onClose={handlePopupClose}>
|
||||
<Popup show={showFilter} title="筛选列表" onClose={handlePopupClose}>
|
||||
<DeliveryFilter onSearchTime={handleSearchTime} onConfirm={handleConfirm} onReset={handleReset} />
|
||||
</Popup>
|
||||
<TimePickerPopup start={start} end={end} showTime={showTime} closePopup={handClose} onSelectDate={(e) => handTime(e)}></TimePickerPopup>
|
||||
<TimePickerPopup start={start} end={end} showTime={showTime} closePopup={handClose} onSelectDate={e => handTime(e)}></TimePickerPopup>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user