import { Text, View } from '@tarojs/components'
import { useMemo } from 'react'
import styles from './index.module.scss'
import LabAndImg from '@/components/LabAndImg'
import { formatPriceDiv, formatWeightDiv } from '@/common/fotmat'
import { goLink } from '@/common/common'

interface Param {
  info: {
    purchaser_name: string
    purchaser_phone: string
    sale_order_no: string
    title_name: string
    sale_mode: number
    product_color_count: number
    product_count: number
    roll: number
    total_amount: number
    total_sale_weight: number
    sale_mode_name: string
    id: number
  }
}
export default (props: Param) => {
  const { info } = props
  const product = useMemo(() => {
    return {
      message: `${formatWeightDiv(info?.total_sale_weight)}kg | ¥${formatPriceDiv(info?.total_amount)}`,
      count: `订单信息：共 ${info?.product_count} 种面料，${info?.product_color_count} 种颜色，共 ${info?.roll} 条`,
    }
  }, [info])
  return <View className={styles.code_list_item} >
    <View className={styles.code_list_con__title}>
      <Text>订单号：{info?.sale_order_no}</Text>
      <View className={styles.code_list_con__title_mode}>{info?.sale_mode_name}</View>
    </View>
    <View className={styles.code_list_desc}>
      <View className={styles.image}>
        <LabAndImg value={{}} />
      </View>
      <View className={styles.company}>
        <View className={styles.company_item}>
          <Text>公司抬头：</Text>
          <Text>{info?.title_name}</Text>
        </View>
        <View className={styles.company_item}>
          <Text>客户名称：</Text>
          <Text>{info?.purchaser_name}</Text>
        </View>
        <View className={styles.company_item}>
          <Text>商品信息：</Text>
          <Text>{product.message}</Text>
        </View>
      </View>
    </View>
    <View className={styles.code_list_number}>{product.count}</View>
    <View className={styles.code_list_bottom}>
      <View className={styles.code_list_bottom_item}>码单浏览</View>
      <View className={styles.code_list_bottom_item} onClick={() => goLink(`/pages/codeSetting/index?custom_print_id=${info.id}`)}>码单编辑</View>
    </View>
  </View>
}
