diff --git a/src/api/order.ts b/src/api/order.ts index a6f47ab..a34436f 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -165,5 +165,11 @@ export const mpenumreturngoodsStatus = () => { method: "get", }) } - +//申请退货 +export const mpreturnApplyOrder = () => { + return useRequest({ + url: `/v1/mp/returnApplyOrder`, + method: "put", + }) +} diff --git a/src/pages/applyGoods/index.tsx b/src/pages/applyGoods/index.tsx index 54be4be..7570256 100644 --- a/src/pages/applyGoods/index.tsx +++ b/src/pages/applyGoods/index.tsx @@ -8,7 +8,8 @@ import { mpsaleOrder, mpenumreturnOrderreturnReason, mpenumreturnExplain, - mpenumreturngoodsStatus + mpenumreturngoodsStatus, + mpreturnApplyOrder } from "@/api/order" import Popup from '@/components/popup' import UploadImage from '@/components/uploadImage' @@ -138,11 +139,7 @@ export default () => { }, []) - //判断是否允许提交 - const isDisabled = useMemo(() => { - return false - }, []) //筛选内容展示 const [showPopup, setshowPopup] = useState(false) @@ -177,6 +174,18 @@ export default () => { // sale_order_id:infoObj.id,//详情id }) + //判断是否允许提交 + const isDisabled = useMemo(() => { + if (Query.GoodStatus !== '' && + Query.return_explain !== '' && + totalNums !== 0 && + Query.GoodStatus !== '' + ) { + return false + } else { + return true + } + }, [Query]) ///获取退货原因 const { fetchData: resonFetch } = mpenumreturnOrderreturnReason() @@ -210,7 +219,7 @@ export default () => { }) setQuery((val) => ({ ...val, return_reason: item.id, return_explain: '' })) queryRef.current.return_reason = item.id - queryRef.current.reasonName = item.name + // queryRef.current.reasonName = item.name setReasonList([...ReasonList]) getReasonTwo() } @@ -226,9 +235,9 @@ export default () => { return it }) setReasonListTwo([...ReasonListTwo]) - queryRef.current.reasonNameTwo = item.name + // queryRef.current.reasonNameTwo = item.name setQuery({ return_explain: item.id }) - queryRef.current.return_explain = item.id + // queryRef.current.return_explain = item.id } //重置 @@ -266,6 +275,16 @@ export default () => { //确认选择退货原因 const handSlect = () => { + const resOne = ReasonList.filter(item => { + return item.default + }) + queryRef.current.return_reason = resOne[0].id + queryRef.current.reasonName = resOne[0].name + const resTwo = ReasonListTwo.filter(item => { + return item.default + }) + queryRef.current.return_explain = resTwo[0].id + queryRef.current.reasonNameTwo = resTwo[0].name setQuery((val) => ({ ...val, reasonName: queryRef.current.reasonName, @@ -297,10 +316,8 @@ export default () => { } return it }) - setQuery((val) => ({ ...val, GoodStatus: item.id, GoodStatusName: item.name })) + setQuery((val) => ({ ...val, GoodStatus: item.id })) setGoodStatusList([...GoodStatusList]) - queryRef.current.GoodStatus = item.id - queryRef.current.GoodStatusName = item.name } //判断状态是否有选 @@ -323,10 +340,82 @@ export default () => { //确认选择货物状况 const handSlectStatus = () => { + const res = GoodStatusList.filter(item => { + return item.default + }) + queryRef.current.GoodStatus = res[0].id + queryRef.current.GoodStatusName = res[0].name setQuery((val) => ({ ...val, GoodStatus: queryRef.current.GoodStatus, GoodStatusName: queryRef.current.GoodStatusName })) setDescPopup(false) } + //取消返回 + const handCancl = () => { + Taro.navigateBack({ + delta: 1 + }) + } + + //确认退货 + const { fetchData: sureFetch } = mpreturnApplyOrder() + const handSure = () => { + const arr: any = []; + ListArr.forEach((item) => { + item.av_product_color.forEach((it) => { + arr.push({ + product_color_id: it.sale_mode == 0 ? it.product_color_id : '', + product_id: it.sale_mode == 0 ? it.product_id : '', + product_roll: it.sale_mode == 0 ? it.nums : 0, + sale_order_detail_id: it.sale_order_detail_id, + }); + }); + }); + const query = { + reason_describe: TextareaValue, + fabric_piece_accessory_url: picUrl.current, + goods_status: Query.GoodStatus, + return_reason: Query.return_reason, + return_explain: Query.return_explain, + roll: 0, + roll_list: arr, + sale_order_id: Number(infoObj.id), + } + 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 [TextareaValue, setTextareaValue] = useState('') + const getDesc = (e) => { + setTextareaValue(e) + } return ( @@ -348,10 +437,10 @@ export default () => { 退货原因 * { - Query.reasonName === '请选择' && 请选择 + queryRef.current.reasonName === '请选择' && 请选择 } { - Query.reasonName !== '请选择' && {Query.reasonName}/{Query.reasonNameTwo} + queryRef.current.reasonName !== '请选择' && {Query.reasonName}/{Query.reasonNameTwo} } @@ -361,10 +450,10 @@ export default () => { 货物情况 * { - Query.GoodStatusName === '请选择' && 请选择 + queryRef.current.GoodStatusName === '请选择' && 请选择 } { - Query.GoodStatusName !== '请选择' && {Query.GoodStatusName} + queryRef.current.GoodStatusName !== '请选择' && {Query.GoodStatusName} } @@ -378,6 +467,8 @@ export default () => { 其他说明