🐞 fix(ID1000933):销售码单没有显示小计金额
This commit is contained in:
parent
9190aa783d
commit
7cec485c9d
@ -1,99 +1,103 @@
|
|||||||
import { ScrollView, View, Image } from '@tarojs/components'
|
import { Image, ScrollView, View } from '@tarojs/components'
|
||||||
import { memo, useCallback, useEffect, useMemo, useState, useRef } from 'react'
|
import Taro from '@tarojs/taro'
|
||||||
import styles from './index.module.scss'
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
import styles from './index.module.scss'
|
||||||
// import BottomBtns from '@/components/BottomBtns'
|
// import BottomBtns from '@/components/BottomBtns'
|
||||||
import { formatPriceDiv } from '@/common/format'
|
import { formatPriceDiv } from '@/common/format'
|
||||||
import Taro from '@tarojs/taro'
|
|
||||||
import Popup from '@/components/popup'
|
import Popup from '@/components/popup'
|
||||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||||
import { alert } from '@/common/common'
|
import { alert } from '@/common/common'
|
||||||
import { GetPayCode } from "@/api/order"
|
import { GetPayCode } from '@/api/order'
|
||||||
import { formatWeightDiv, formatDateTime } from '@/common/format'
|
import { formatDateTime, formatWeightDiv } from '@/common/format'
|
||||||
import { PAY_H5_CODE_URL } from '@/common/constant'
|
import { PAY_H5_CODE_URL } from '@/common/constant'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
obj: any,
|
obj: any
|
||||||
// picUrl?: string,
|
// picUrl?: string,
|
||||||
showPopup: boolean,
|
showPopup: boolean
|
||||||
popupClose: () => void
|
popupClose: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo((props: Props) => {
|
const codeList = (props: Props) => {
|
||||||
|
|
||||||
const { fetchData: payFetch } = GetPayCode()
|
const { fetchData: payFetch } = GetPayCode()
|
||||||
const [PicUrl, setPicUrl] = useState<string>('')
|
const [PicUrl, setPicUrl] = useState<string>('')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//判断进来的是否是空对象,减少性能问题
|
// 判断进来的是否是空对象,减少性能问题
|
||||||
var length = Object.keys(props.obj);
|
const length = Object.keys(props.obj)
|
||||||
if (length.length > 0) getPic()
|
if (length.length > 0) { getPic() }
|
||||||
}, [props.obj])
|
}, [props.obj])
|
||||||
|
|
||||||
const getPic = async () => {
|
const getPic = async() => {
|
||||||
Taro.showLoading({
|
Taro.showLoading({
|
||||||
title: '请稍等...',
|
title: '请稍等...',
|
||||||
mask: true
|
mask: true,
|
||||||
})
|
})
|
||||||
const list: any = [];
|
const list: any = []
|
||||||
props.obj.product_list?.forEach((item) => {
|
props.obj.product_list?.forEach((item) => {
|
||||||
item.product_colors.forEach((it) => {
|
item.product_colors.forEach((it) => {
|
||||||
list.push({
|
list.push({
|
||||||
product_code: item.code,
|
product_code: item.code,
|
||||||
product_name: item.name,
|
product_name: item.name,
|
||||||
product_color_code: it.code,
|
product_color_code: it.product_color_code,
|
||||||
product_color_name: it.name,
|
product_color_name: it.product_color_name,
|
||||||
num: it.roll.toString(),
|
num: it.roll.toString(),
|
||||||
weight: formatWeightDiv(it.label_weight).toString(),
|
weight: formatWeightDiv(it.actual_weight).toString(),
|
||||||
deduction_weight: formatWeightDiv(it.deductions_weight).toString(),
|
|
||||||
settle_weight: formatWeightDiv(it.settle_weight).toString(),
|
|
||||||
deduction_amount: (it.deductions_amount / 100).toString(),
|
|
||||||
sale_price: (it.sale_price / 100).toString(),
|
sale_price: (it.sale_price / 100).toString(),
|
||||||
total_price: (it.estimate_amount / 100).toString(),
|
total_price:
|
||||||
|
it.total_sale_price !== 0
|
||||||
|
? (it.total_sale_price / 100).toString()
|
||||||
|
: (it.estimate_amount / 100).toString(),
|
||||||
length: (it.length / 100).toString(),
|
length: (it.length / 100).toString(),
|
||||||
weight_error: formatWeightDiv(it.settle_weight_error).toString(),
|
weight_error: formatWeightDiv(it.weight_error).toString(),
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
const query = {
|
const query = {
|
||||||
list: list,
|
list,
|
||||||
title: "面料销售电子确认单",
|
title: '面料销售电子确认单',
|
||||||
show_qrcode: true,
|
show_qrcode: true,
|
||||||
show_barcode: true,
|
show_barcode: true,
|
||||||
show_wait_pay_amount: true,
|
order_type: props?.obj.sale_mode_name,
|
||||||
order_type: props.obj.sale_mode_name,
|
shipment_mode: props?.obj.shipment_mode_name,
|
||||||
shipment_mode: props.obj.shipment_mode_name,
|
company: props?.obj.title_purchaser_name,
|
||||||
company: props.obj.title_purchaser_name,
|
sale_user: props?.obj.sale_user_name,
|
||||||
sale_user: props.obj.sale_user_name,
|
order_created_time: formatDateTime(props?.obj.create_time),
|
||||||
order_created_time: formatDateTime(props.obj.create_time),
|
order_no: props?.obj.order_no,
|
||||||
order_no: props.obj.order_no,
|
target_user_name: props?.obj.target_user_name,
|
||||||
target_user_name: props.obj.target_user_name,
|
target_address: props?.obj.address_detail,
|
||||||
target_address: props.obj.address_detail,
|
target_description: props?.obj.remark,
|
||||||
target_description: props.obj.remark,
|
pay_account: props?.obj.transfer_remittance_account,
|
||||||
pay_account: props.obj.transfer_remittance_account,
|
bank_account_name: props?.obj.account_name,
|
||||||
bank_account_name: props.obj.account_name,
|
bank_name: props?.obj.bank_of_deposit,
|
||||||
bank_name: props.obj.bank_of_deposit,
|
pay_type: props?.obj.settle_mode_name,
|
||||||
pay_type: props.obj.settle_mode_name,
|
client: props?.obj.purchaser_name,
|
||||||
client: props.obj.purchaser_name,
|
phone: props?.obj.target_user_phone,
|
||||||
phone: props.obj.target_user_phone,
|
order_total_length: (props?.obj.total_number / 100).toString(),
|
||||||
order_total_length: (props.obj.total_number / 100).toString(),
|
|
||||||
order_total_price: (
|
order_total_price: (
|
||||||
props.obj.bill_total_sale_price / 100
|
props?.obj.bill_total_sale_price / 100
|
||||||
).toString(),
|
).toString(),
|
||||||
total_weight_error_discount: (
|
total_weight_error_discount: (
|
||||||
props.obj.total_weight_error_discount / 100
|
props?.obj.total_weight_error_discount / 100
|
||||||
).toString(),
|
).toString(),
|
||||||
order_total_num: props.obj.total_number.toString(),
|
order_total_num: props?.obj.total_number.toString(),
|
||||||
qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${props.obj.order_no}`,
|
qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${props?.obj.order_no}`,
|
||||||
order_total_weight: (props.obj.total_weight / 1000).toString(),
|
order_total_weight: (props?.obj.total_weight / 1000).toString(),
|
||||||
estimate_amount: (props.obj.estimate_amount / 100).toString(),
|
estimate_amount: (props?.obj.estimate_amount / 100).toString(),
|
||||||
total_sale_price: (props.obj.total_sale_price / 100).toString(),
|
total_sale_price: (props?.obj.total_sale_price / 100).toString(),
|
||||||
show_total_sale_price: true,
|
actual_amount: (props?.obj.actual_amount / 100).toString(),
|
||||||
show_total_weight_error_discount: true,
|
wait_pay_amount: (props?.obj.wait_pay_amount / 100).toString(),
|
||||||
actual_amount: (props.obj.actual_amount / 100).toString(),
|
|
||||||
wait_pay_amount: (props.obj.wait_pay_amount / 100).toString(),
|
|
||||||
order_total_weight_error: (
|
order_total_weight_error: (
|
||||||
props.obj.total_weight_error / 1000
|
props?.obj.total_weight_error / 1000
|
||||||
).toString(),
|
).toString(),
|
||||||
};
|
show_sale_price: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_total_price: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_estimate_amount: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_total_sale_price: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_total_weight_error_discount: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_actual_amount: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
show_wait_pay_amount: props?.obj?.sale_mode === 0 && props?.obj?.is_display_price ? true : !!((props?.obj?.sale_mode === 1 || props?.obj?.sale_mode === 2)),
|
||||||
|
}
|
||||||
const res = await payFetch(query)
|
const res = await payFetch(query)
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
setPicUrl(res.data.base64)
|
setPicUrl(res.data.base64)
|
||||||
@ -106,11 +110,11 @@ export default memo((props: Props) => {
|
|||||||
base64: '',
|
base64: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
//预览图片
|
// 预览图片
|
||||||
const showImage = () => {
|
const showImage = () => {
|
||||||
const time = new Date().valueOf()
|
const time = new Date().valueOf()
|
||||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || []
|
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || []
|
||||||
let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format
|
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||||
fileData.current.filePath = filePath
|
fileData.current.filePath = filePath
|
||||||
fileData.current.base64 = bodyData
|
fileData.current.base64 = bodyData
|
||||||
const save = Taro.getFileSystemManager()
|
const save = Taro.getFileSystemManager()
|
||||||
@ -125,18 +129,18 @@ export default memo((props: Props) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查是否开启保存图片权限
|
// 检查是否开启保存图片权限
|
||||||
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
const { check } = useCheckAuthorize({ scope: 'scope.writePhotosAlbum', msg: '您没授权,无法保存图片' })
|
||||||
const saveImageCheck = async () => {
|
const saveImageCheck = async() => {
|
||||||
const res = await check()
|
const res = await check()
|
||||||
res && saveImage()
|
res && saveImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
//保存图片
|
// 保存图片
|
||||||
const saveImage = () => {
|
const saveImage = () => {
|
||||||
const time = new Date().valueOf()
|
const time = new Date().valueOf()
|
||||||
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || []
|
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(PicUrl) || []
|
||||||
let filePath = Taro.env.USER_DATA_PATH + '/img' + time + '.' + format
|
const filePath = `${Taro.env.USER_DATA_PATH}/img${time}.${format}`
|
||||||
fileData.current.filePath = filePath
|
fileData.current.filePath = filePath
|
||||||
fileData.current.base64 = bodyData
|
fileData.current.base64 = bodyData
|
||||||
const save = Taro.getFileSystemManager()
|
const save = Taro.getFileSystemManager()
|
||||||
@ -148,25 +152,27 @@ export default memo((props: Props) => {
|
|||||||
alert.loading('正在保存图片')
|
alert.loading('正在保存图片')
|
||||||
Taro.saveImageToPhotosAlbum({
|
Taro.saveImageToPhotosAlbum({
|
||||||
filePath: fileData.current.filePath,
|
filePath: fileData.current.filePath,
|
||||||
success: function () {
|
success() {
|
||||||
alert.success('图片保存成功')
|
alert.success('图片保存成功')
|
||||||
},
|
},
|
||||||
fail: function (err) {
|
fail(err) {
|
||||||
console.log('err::', err)
|
console.log('err::', err)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popup show={props.showPopup} title={'销售码单'} onClose={() => props.popupClose?.()}>
|
<Popup show={props.showPopup} title="销售码单" onClose={() => props.popupClose?.()}>
|
||||||
<View className={styles.popupBox}>
|
<View className={styles.popupBox}>
|
||||||
<ScrollView enhanced scrollY className={styles.scroStyle}>
|
<ScrollView enhanced scrollY className={styles.scroStyle}>
|
||||||
<View className={styles.pic}>
|
<View className={styles.pic}>
|
||||||
<Image lazyLoad mode='widthFix' style={{ width: '100%', height: '100%' }} src={PicUrl} onClick={() => showImage()}></Image>
|
<Image lazyLoad mode="widthFix" style={{ width: '100%', height: '100%' }} src={PicUrl} onClick={() => showImage()}></Image>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View className={styles.sure} onClick={() => saveImageCheck()}>保存图片</View>
|
<View className={styles.sure} onClick={() => saveImageCheck()}>保存图片</View>
|
||||||
</View>
|
</View>
|
||||||
</Popup>
|
</Popup>
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
export default memo(codeList)
|
||||||
|
|||||||
@ -503,7 +503,6 @@ const OrderDetails = () => {
|
|||||||
title: '面料销售电子确认单',
|
title: '面料销售电子确认单',
|
||||||
show_qrcode: true,
|
show_qrcode: true,
|
||||||
show_barcode: true,
|
show_barcode: true,
|
||||||
show_wait_pay_amount: true,
|
|
||||||
order_type: infoObj.sale_mode_name,
|
order_type: infoObj.sale_mode_name,
|
||||||
shipment_mode: infoObj.shipment_mode_name,
|
shipment_mode: infoObj.shipment_mode_name,
|
||||||
company: infoObj.title_purchaser_name,
|
company: infoObj.title_purchaser_name,
|
||||||
@ -531,13 +530,18 @@ const OrderDetails = () => {
|
|||||||
order_total_weight: (infoObj.total_weight / 1000).toString(),
|
order_total_weight: (infoObj.total_weight / 1000).toString(),
|
||||||
estimate_amount: (infoObj.estimate_amount / 100).toString(),
|
estimate_amount: (infoObj.estimate_amount / 100).toString(),
|
||||||
total_sale_price: (infoObj.total_sale_price / 100).toString(),
|
total_sale_price: (infoObj.total_sale_price / 100).toString(),
|
||||||
show_total_sale_price: true,
|
|
||||||
show_total_weight_error_discount: true,
|
|
||||||
actual_amount: (infoObj.actual_amount / 100).toString(),
|
actual_amount: (infoObj.actual_amount / 100).toString(),
|
||||||
wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(),
|
wait_pay_amount: (infoObj.wait_pay_amount / 100).toString(),
|
||||||
order_total_weight_error: (
|
order_total_weight_error: (
|
||||||
infoObj.total_weight_error / 1000
|
infoObj.total_weight_error / 1000
|
||||||
).toString(),
|
).toString(),
|
||||||
|
show_sale_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_total_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_estimate_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_total_sale_price: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_total_weight_error_discount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_actual_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
|
show_wait_pay_amount: infoObj?.sale_mode === 0 && infoObj?.is_display_price ? true : !!((infoObj?.sale_mode === 1 || infoObj?.sale_mode === 2)),
|
||||||
}
|
}
|
||||||
const res = await payFetch(query)
|
const res = await payFetch(query)
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user