/**
 * 商品编辑相关的 Mock 数据
 */

// 商品分类数据
export const categoryData = [
  {
    id: 1,
    name: '电子产品',
    children: [
      {
        id: 11,
        name: '手机通讯',
        children: [
          { id: 111, name: '智能手机' },
          { id: 112, name: '老人机' },
          { id: 113, name: '对讲机' },
        ],
      },
      {
        id: 12,
        name: '电脑办公',
        children: [
          { id: 121, name: '笔记本电脑' },
          { id: 122, name: '台式机' },
          { id: 123, name: '平板电脑' },
        ],
      },
      {
        id: 13,
        name: '数码配件',
        children: [
          { id: 131, name: '手机壳' },
          { id: 132, name: '充电器' },
          { id: 133, name: '数据线' },
        ],
      },
    ],
  },
  {
    id: 2,
    name: '服装鞋帽',
    children: [
      {
        id: 21,
        name: '男装',
        children: [
          { id: 211, name: 'T恤' },
          { id: 212, name: '衬衫' },
          { id: 213, name: '裤子' },
        ],
      },
      {
        id: 22,
        name: '女装',
        children: [
          { id: 221, name: '连衣裙' },
          { id: 222, name: '上衣' },
          { id: 223, name: '下装' },
        ],
      },
      {
        id: 23,
        name: '鞋靴',
        children: [
          { id: 231, name: '运动鞋' },
          { id: 232, name: '休闲鞋' },
          { id: 233, name: '皮鞋' },
        ],
      },
    ],
  },
  {
    id: 3,
    name: '家居用品',
    children: [
      {
        id: 31,
        name: '家具',
        children: [
          { id: 311, name: '沙发' },
          { id: 312, name: '床' },
          { id: 313, name: '桌椅' },
        ],
      },
      {
        id: 32,
        name: '家纺',
        children: [
          { id: 321, name: '床上用品' },
          { id: 322, name: '窗帘' },
          { id: 323, name: '地毯' },
        ],
      },
    ],
  },
];

// 商品详情数据示例
export const goodsDetailData = {
  id: 'BZ6542',
  category_id: [1, 11, 111],
  title: 'BOLON Classic Aviator Polarized Sunglasses',
  subtitle: '经典飞行员偏光太阳镜',
  brand: 'BOLON',
  description: '这是一款经典的飞行员风格偏光太阳镜，采用优质材料制作，具有出色的防紫外线效果。',
  freight_template: 'free',
  goods_no: 'BL001',
  price: '299.00',
  market_price: '399.00',
  stock: 100,
  stock_warning: 10,
  status: 'up',
  supplier: '博伦眼镜有限公司',

  // 图片
  images: [
    'https://mall-oss.trust-will.com/storage/default/20250701/7bf12c56300454532244dec2aff808eb.jpg',
    'https://mall-oss.trust-will.com/storage/default/20250701/8bf12c56300454532244dec2aff808eb.jpg',
  ],
  white_bg_image: [
    'https://mall-oss.trust-will.com/storage/default/20250701/9bf12c56300454532244dec2aff808eb.jpg',
  ],
  detail_images: [
    'https://mall-oss.trust-will.com/storage/default/20250701/abf12c56300454532244dec2aff808eb.jpg',
    'https://mall-oss.trust-will.com/storage/default/20250701/bbf12c56300454532244dec2aff808eb.jpg',
  ],

  // 规格
  has_spec: true,
  specs: [
    {
      spec_0: '黑色',
      spec_1: 'M',
      price: '299.00',
      stock: '50',
      weight: '0.15',
      sku: 'BL001-BK-M',
    },
    {
      spec_0: '黑色',
      spec_1: 'L',
      price: '299.00',
      stock: '30',
      weight: '0.15',
      sku: 'BL001-BK-L',
    },
    {
      spec_0: '棕色',
      spec_1: 'M',
      price: '319.00',
      stock: '20',
      weight: '0.15',
      sku: 'BL001-BR-M',
    },
  ],
};

// 保存商品接口响应
export const saveGoodsResponse = {
  error: 0,
  msg: '保存成功',
  data: {
    id: 'BZ6542',
    status: 'success',
  },
};

// 获取商品详情接口响应
export const getGoodsDetailResponse = {
  error: 0,
  msg: '获取成功',
  data: goodsDetailData,
};

// 获取商品分类接口响应
export const getCategoryResponse = {
  error: 0,
  msg: '获取成功',
  data: categoryData,
};

// 上传图片接口响应
export const uploadImageResponse = {
  error: 0,
  msg: '上传成功',
  data: {
    url: 'https://mall-oss.trust-will.com/storage/default/20250701/new-image.jpg',
    name: 'new-image.jpg',
    size: 102400,
  },
};

// 商品编辑表单验证规则
export const goodsFormRules = {
  category_id: [{ required: true, message: '请选择商品分类', trigger: 'change' }],
  title: [
    { required: true, message: '请输入商品名称', trigger: 'blur' },
    { min: 1, max: 100, message: '商品名称长度在 1 到 100 个字符', trigger: 'blur' },
  ],
  brand: [{ required: true, message: '请输入商品品牌', trigger: 'blur' }],
  freight_template: [{ required: true, message: '请选择运费模板', trigger: 'change' }],
  goods_no: [{ required: true, message: '请输入商品货号', trigger: 'blur' }],
  price: [
    { required: true, message: '请输入商品售价', trigger: 'blur' },
    { pattern: /^\d+(\.\d{1,2})?$/, message: '请输入正确的价格格式', trigger: 'blur' },
  ],
  stock: [
    { required: true, message: '请输入商品库存', trigger: 'blur' },
    { pattern: /^\d+$/, message: '库存必须为正整数', trigger: 'blur' },
  ],
  status: [{ required: true, message: '请选择商品状态', trigger: 'change' }],
  supplier: [{ required: true, message: '请输入商品供应商', trigger: 'blur' }],
  images: [{ required: true, message: '请上传商品主图', trigger: 'change' }],
};

// 运费模板选项
export const freightTemplateOptions = [
  { label: '包邮', value: 'free' },
  { label: '按重量计费', value: 'weight' },
  { label: '按件数计费', value: 'piece' },
  { label: '按体积计费', value: 'volume' },
];

// 商品状态选项
export const goodsStatusOptions = [
  { label: '上架', value: 'up' },
  { label: '下架', value: 'down' },
  { label: '草稿', value: 'draft' },
];

// 图片上传配置
export const imageUploadConfig = {
  // 主图配置
  mainImage: {
    maxCount: 5,
    accept: ['jpg', 'jpeg', 'png'],
    maxSize: 2, // MB
    recommend: '建议尺寸800x800px，支持jpg、png格式',
  },
  // 白底图配置
  whiteBgImage: {
    maxCount: 1,
    accept: ['jpg', 'jpeg', 'png'],
    maxSize: 2, // MB
    recommend: '白底图，建议尺寸800x800px',
  },
  // 详情图配置
  detailImage: {
    maxCount: 10,
    accept: ['jpg', 'jpeg', 'png'],
    maxSize: 2, // MB
    recommend: '商品详情图片，建议宽度750px',
  },
};
