From 2a73febdba063b027e308473d46d15e8c812692b Mon Sep 17 00:00:00 2001 From: xuan Date: Mon, 26 Sep 2022 10:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E6=8F=90=E8=B4=A7=E8=AF=A6?= =?UTF-8?q?=E6=83=85):=20=E5=B7=B2=E5=AE=8C=E6=88=90=E6=8F=90=E8=B4=A7?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ItemList/index.tsx | 19 ++--- .../components/remark/index.module.scss | 48 ++++++++++++ .../takeDelivery/components/remark/index.tsx | 43 +++++++++++ src/pages/takeDeliveryDetail/index.config.ts | 2 +- .../takeDeliveryDetail/index.module.scss | 2 +- src/pages/takeDeliveryDetail/index.tsx | 77 +++++++++++++------ 6 files changed, 158 insertions(+), 33 deletions(-) create mode 100644 src/pages/takeDelivery/components/remark/index.module.scss create mode 100644 src/pages/takeDelivery/components/remark/index.tsx diff --git a/src/pages/takeDelivery/components/ItemList/index.tsx b/src/pages/takeDelivery/components/ItemList/index.tsx index e182641..eca6ef2 100644 --- a/src/pages/takeDelivery/components/ItemList/index.tsx +++ b/src/pages/takeDelivery/components/ItemList/index.tsx @@ -27,21 +27,21 @@ const ItemList:FC = (props) => { }) } - const { fetchData, state } = TakeGoodsOrderAudit() + const { fetchData } = TakeGoodsOrderAudit() // 确认审核 const handleAudit = (id: number) => { Taro.showModal({ - content: '确认要审核吗?', + content: '确认要提货吗?', confirmColor: '#337FFF', success: async (res) => { if (res.confirm) { const res = await fetchData({ id }) if (res.success) { - Taro.showToast({ title: '审核成功', icon: 'success' }) + Taro.showToast({ title: '提货成功', icon: 'success' }) onSuccess?.() }else{ - Taro.showToast({ title: '审核失败', icon: 'error' }) + Taro.showToast({ title: '操作失败', icon: 'error' }) } } }, @@ -53,10 +53,10 @@ const ItemList:FC = (props) => { 单号:{itemData?.take_goods_order_no} - {itemData?.take_goods_status === 0 && 提货中} - {itemData?.take_goods_status === 1 && ( - 已收货 + {itemData?.take_goods_status === 0 && ( + 提货中 )} + {itemData?.take_goods_status === 1 && 已收货} {itemData?.take_goods_order_type_name} @@ -66,17 +66,18 @@ const ItemList:FC = (props) => { 货品信息: + {/* TODO: 面料字段、颜色字段 */} {itemData.delivery_product_nums}种面料,{itemData.delivery_product_color_nums}种颜色,共 {itemData?.sale_mode === EnumSaleMode.Bulk ? `${itemData?.take_roll}条` : `${formatMeterDiv(itemData?.take_meters)}米`} 供应信息: - {itemData?.delivery_address || '空'} + {itemData?.supplier_name || '空'} 创建时间: - {formatDateTime(itemData?.create_time) || '空'} + {formatDateTime(itemData?.take_goods_order_create_time) || '空'} diff --git a/src/pages/takeDelivery/components/remark/index.module.scss b/src/pages/takeDelivery/components/remark/index.module.scss new file mode 100644 index 0000000..036a4ce --- /dev/null +++ b/src/pages/takeDelivery/components/remark/index.module.scss @@ -0,0 +1,48 @@ +.order_popup{ + display: flex; + flex-direction: column; + align-items: center; + padding: 20px 0; + .order_popup_title{ + color: $font_size_big; + font-weight: 700; + color: #000000; + padding-bottom: 20px; + } + .order_popup_input{ + width: 100%; + padding: 0 25px; + box-sizing: border-box; + margin-top: 43px; + position: relative; + .descDataNum{ + position: absolute; + right: 40px; + bottom: 10px; + height: 39px; + font-size: $font_size_medium; + color: $color_font_two; + } + textarea{ + background-color: #f3f3f3; + border-radius: 10px; + width: 100%; + height: 313px; + padding: 20px; + padding-bottom: 50px; + box-sizing: border-box; + font-size: $font_size; + border: 2px solid #e6e6e6; + } + } + .order_save_address{ + height: 82px; + background: #007aff; + border-radius: 40px; + width: 668px; + text-align: center; + line-height: 82px; + color: #fff; + margin-top: 60px; + } +} \ No newline at end of file diff --git a/src/pages/takeDelivery/components/remark/index.tsx b/src/pages/takeDelivery/components/remark/index.tsx new file mode 100644 index 0000000..db4b68f --- /dev/null +++ b/src/pages/takeDelivery/components/remark/index.tsx @@ -0,0 +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' + +type 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 + }) + + 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 setSave = () => { + onSave?.(descData.value) + } + return ( + + 编辑备注 + + + {descData.number}/{descData.count} + + setSave()}>保存 + + ) +} \ No newline at end of file diff --git a/src/pages/takeDeliveryDetail/index.config.ts b/src/pages/takeDeliveryDetail/index.config.ts index 51bc524..381c573 100644 --- a/src/pages/takeDeliveryDetail/index.config.ts +++ b/src/pages/takeDeliveryDetail/index.config.ts @@ -1,3 +1,3 @@ export default { - navigationBarTitleText: '提货', + navigationBarTitleText: '提货详情', } diff --git a/src/pages/takeDeliveryDetail/index.module.scss b/src/pages/takeDeliveryDetail/index.module.scss index ead9e16..b848324 100644 --- a/src/pages/takeDeliveryDetail/index.module.scss +++ b/src/pages/takeDeliveryDetail/index.module.scss @@ -29,7 +29,7 @@ page { margin: 0 24px; display: flex; flex-flow: row nowrap; - justify-content: space-between; + justify-content: center; align-items: center; padding-top: 24px; padding-bottom: calc(20px + constant(safe-area-inset-bottom)); diff --git a/src/pages/takeDeliveryDetail/index.tsx b/src/pages/takeDeliveryDetail/index.tsx index a6e5df8..9374f00 100644 --- a/src/pages/takeDeliveryDetail/index.tsx +++ b/src/pages/takeDeliveryDetail/index.tsx @@ -1,4 +1,4 @@ -import { TakeGoodsOrder, TakeGoodsOrderAudit, DeliveryNoticeOrderUpload, TakeGoodsOrderRefuse } from '@/api' +import { TakeGoodsOrder, TakeGoodsOrderAudit, TakeGoodsOrderRefuse } from '@/api' import { formatDateTime, formatMeterDiv, formatWeightDiv } from '@/common/format' import Cell from '@/components/cell' import Divider from '@/components/divider' @@ -12,6 +12,8 @@ import { useRouter } from '@tarojs/taro' import { alert } from '@/common/common' import { FC, useCallback, useEffect, useMemo, useState } from 'react' import styles from './index.module.scss' +import Popup from '@/components/popup' +import Remark from '../takeDelivery/components/remark' const TakeDeliveryDetail: FC = () => { const router = useRouter() @@ -27,14 +29,16 @@ const TakeDeliveryDetail: FC = () => { }) console.log('res==>', res.data) setDetailInfo(res.data) + // 动态设置标题 + Taro.setNavigationBarTitle({ + title: res.data.take_goods_order_type_name, + }) } useEffect(() => { getData() }, []) - const { fetchData: uploadData } = DeliveryNoticeOrderUpload() - const { fetchData: FetchAudit } = TakeGoodsOrderAudit() const DetailItem = useMemo(() => { @@ -78,39 +82,63 @@ const TakeDeliveryDetail: FC = () => { console.log('imageList===>', imageList) setReadyToUploadList((prev) => [...prev, ...imageList]) } + + const { fetchData: refuseOrder } = TakeGoodsOrderRefuse() + + const [showRemarkModal, setShowRemarkModal] = useState(false) + + const handleRefuseOrder = async (remark: string) => { + const res = await refuseOrder({ + id: Number(router.params.id), + remark: remark, + }) + if (res.success) { + alert.success('拒收成功') + getData() + } else { + alert.error('该操作失败') + } + } + + const onRemarkSave = async (remark: string) => { + handleRefuseOrder(remark) + + } + // 拒收 - const handleRefuse = useCallback(async () => {}, []) + const handleRefuse = useCallback(() => { + setShowRemarkModal(true) + }, []) + + // 审核 const handleAudit = useCallback(() => { Taro.showModal({ confirmColor: '#337FFF', - title: '确定审核?', + title: '确定要提货?', success: async function (res) { if (res.confirm) { const res = await FetchAudit({ id: Number(router.params.id) }) if (res.success) { - alert.success('审核成功') + alert.success('提货成功') getData() } else { - alert.error('审核失败') + alert.error('请求失败') } - } else if (res.cancel) { - console.log('用户点击取消') } }, }) }, [readyToUploadList]) - const { fetchData: refuseOrder } = TakeGoodsOrderRefuse() - const { fetchData: auditOrder } = TakeGoodsOrderAudit() - + // 底部按钮栏 const BottomBar = useMemo(() => { - if (detailInfo?.take_goods_order_type === 0) { + + if (detailInfo?.take_goods_order_type !== 0) { // 采购提货 return ( - + 确认提货 @@ -118,11 +146,11 @@ const TakeDeliveryDetail: FC = () => { } else { // 退货提货 return ( - - + + 拒收 - + 确认提货 @@ -176,13 +204,18 @@ const TakeDeliveryDetail: FC = () => { - - 备注信息 - - {detailInfo?.remark} - + {detailInfo?.take_goods_order_type !== 0 && ( + + 备注信息 + + {detailInfo?.remark} + + )} {detailInfo?.take_goods_status === 0 && BottomBar} + setShowRemarkModal(false)}> + + ) }