/* eslint-disable no-confusing-arrow */
export const formItemLayout = {
  labelCol: {
    sm: { span: 3 },
  },
  wrapperCol: {
    sm: { span: 16 },
  },
};

export const TaskList = (canAddService, canAddNormal, canTakeawayService) => [
  {
    name: '实体商品',
    type: 1,
    desc: '物流发货',
    hide: !canAddNormal,
    imgConfig: {
      commonImageList: {
        title: '公共滑动图',
        rule: false,
        limit: null,
        renderExtra: () => '（图片最大上传2M）',
      },
      imageList: {
        rule: false,
        limit: null,
        renderExtra: () => '（图片最大上传2M）',
      },
      detailImageList: {
        title: '详情图',
        rule: true,
        limit: null,
        renderExtra: () => '（图片最大上传2M）',
      },
    },
  },
  // {
  //   name: '虚拟商品',
  //   type: 2,
  //   desc: '无需物流',
  //   hide: !canAddNormal,
  //   imgConfig: {
  //     commonImageList: {
  //       title: '公共滑动图',
  //       rule: false,
  //       limit: null,
  //       renderExtra: () => '（图片最大上传2M）',
  //     },
  //     imageList: {
  //       rule: false,
  //       limit: null,
  //       renderExtra: () => '（图片最大上传2M）',
  //     },
  //     detailImageList: {
  //       title: '详情图',
  //       rule: true,
  //       limit: null,
  //       renderExtra: () => '（图片最大上传2M）',
  //     },
  //   },
  // },
  {
    name: '服务类商品',
    type: 4,
    desc: '无需物流',
    hide: !canAddService,
    imgConfig: {
      commonImageList: {
        title: '封面图片',
        rule: true,
        limit: 1,
        renderExtra(leng) {
          return `建议尺寸: ##宽##高 (${leng} / 1) 封面图第一张 `;
        },
      },
      cardImageList: {
        title: '商品图片',
        rule: true,
        limit: 11,
        renderExtra(leng) {
          return `建议尺寸: ##宽##高,sku商品轮播图(${leng} / 11)`;
        },
      },
      detailImageList: {
        title: '商品详情图',
        // rule: true,
        limit: 30,
        renderExtra() {
          return '最多上传30张';
        },
      },
    },
  },
  {
    name: '外卖商品',
    type: 5,
    desc: '无需物流',
    hide: !canTakeawayService,
    imgConfig: {
      commonImageList: {
        title: '封面图片',
        rule: true,
        limit: 1,
        renderExtra(leng) {
          return `建议尺寸: ##宽##高 (${leng} / 1) 封面图第一张 `;
        },
      },
      cardImageList: {
        title: '商品图片',
        rule: true,
        limit: 11,
        renderExtra(leng) {
          return `建议尺寸: ##宽##高,sku商品轮播图(${leng} / 11)`;
        },
      },
      detailImageList: {
        title: '商品详情图',
        // rule: true,
        limit: 30,
        renderExtra() {
          return '最多上传30张';
        },
      },
    },
  },
];

export const WeeksList = [
  {
    name: '法定节假日',
    value: 8,
  },
  {
    name: '周一',
    value: 1,
  },
  {
    name: '周二',
    value: 2,
  },
  {
    name: '周三',
    value: 3,
  },
  {
    name: '周四',
    value: 4,
  },
  {
    name: '周五',
    value: 5,
  },
  {
    name: '周六',
    value: 6,
  },
  {
    name: '周日',
    value: 7,
  },
];
// isGoodsManage用来判断是否是popGoodsManage页面,这个页面是用来应付审计团队的,没有实际功能,这里删掉了供货价字段,正常业务逻辑不用考虑这个字段,这就用第一个数据就好了
const isGoodsManage = window.location.pathname.indexOf('popGoodsManage') < 0;
export const StaticColumns = customer =>
  isGoodsManage
    ? [
        {
          title: '供货价',
          dataIndex: 'supplyPrice',
          editable: true,
          batchRole: [1, 2, 3, 4],
          roleProps: {
            precision: 2,
            min: 0,
          },
          batchProps: {
            precision: 2,
            min: 0,
          },
          roleRules: { required: true },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '佣金费率',
          dataIndex: 'commissionRate',
          editable: true,
          role: [4],
          roleRules: { required: false },
          roleProps: {
            min: 0,
          },
          // batchProps: {
          //   min: 0,
          // },
        },
        {
          title: '市场价',
          dataIndex: 'marketPrice',
          editable: true,
          batchRole: [1, 2, 3, 4],
          roleProps: {
            precision: 2,
            min: 0,
          },
          batchProps: {
            precision: 2,
            min: 0,
          },
          roleRules: { required: true },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '销售价',
          dataIndex: 'salePrice',
          editable: true,
          batchRole: [4],
          role: [4],
          roleRules: { required: true },
          roleProps: {
            precision: 2,
            min: 0,
          },
          batchProps: {
            precision: 2,
            min: 0,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: `重量(${customer.isGold ? 'g' : 'kg'})`,
          dataIndex: 'weight',
          editable: true,
          batchRole: [1],
          batchProps: {
            min: 0,
            precision: customer.isGold ? 2 : 3,
            max: customer.isGold ? 100 : 999999.999,
          },
          role: [1],
          roleRules: { required: true },
          roleProps: {
            min: 0,
            precision: customer.isGold ? 2 : 3,
            max: customer.isGold ? 100 : 999999.999,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '库存',
          dataIndex: 'productStock',
          editable: true,
          role: [1, 2, 4],
          batchRole: [1, 2, 4],
          batchProps: {
            precision: 0,
            step: 1,
            min: 0,
          },
          roleProps: {
            min: 0,
            step: 1,
            precision: 0,
          },
          roleRules: { required: true },
          disabeldRender: record => {
            if (record.stock === null) return false;
            return customer.isEdit && customer.isNormal;
          },
        },
        {
          title: '库存预警',
          dataIndex: 'productStockWarning',
          editable: true,
          batchRole: [1],
          role: [1, 4],
          roleProps: {
            min: 0,
            precision: 0,
            maxLength: 5,
          },
          batchProps: {
            min: 0,
            precision: 0,
            maxLength: 5,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '商品自编码',
          dataIndex: 'thirdSkuNo',
          editable: true,
          role: [1, 2],
          inputType: 'input',
          roleRules: { required: true },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '京东链接',
          dataIndex: 'skuLink',
          editable: true,
          role: [1, 2],
          inputType: 'input',
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: 'sku名称',
          dataIndex: 'name',
          editable: true,
          role: customer.isEdit && customer.isJDGoods ? [1, 2] : [],
          inputType: 'btnText',
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '操作',
          editable: true,
          dataIndex: 'option',
          role: [1, 2],
          inputType: 'option',
          roleProps: {
            isJDGoods: customer.isJDGoods,
            disabled: customer.isDisabled,
            min: 0,
          },
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
      ]
    : [
        // 这部分是用来应付审计团队的,没有实际功能,这里删掉了供货价字段,正常业务逻辑不用考虑这里
        {
          title: '佣金费率',
          dataIndex: 'commissionRate',
          editable: true,
          role: [4],
          roleRules: { required: false },
          roleProps: {
            min: 0,
          },
          // batchProps: {
          //   min: 0,
          // },
        },
        {
          title: '市场价',
          dataIndex: 'marketPrice',
          editable: true,
          batchRole: [1, 2, 3, 4],
          roleProps: {
            precision: 2,
            min: 0,
          },
          batchProps: {
            precision: 2,
            min: 0,
          },
          roleRules: { required: true },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '销售价',
          dataIndex: 'salePrice',
          editable: true,
          batchRole: [4],
          role: [4],
          roleRules: { required: true },
          roleProps: {
            precision: 2,
            min: 0,
          },
          batchProps: {
            precision: 2,
            min: 0,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: `重量(${customer.isGold ? 'g' : 'kg'})`,
          dataIndex: 'weight',
          editable: true,
          batchRole: [1],
          batchProps: {
            min: 0,
            precision: customer.isGold ? 2 : 3,
            max: customer.isGold ? 100 : 999999.999,
          },
          role: [1],
          roleRules: { required: true },
          roleProps: {
            min: 0,
            precision: customer.isGold ? 2 : 3,
            max: customer.isGold ? 100 : 999999.999,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '库存',
          dataIndex: 'productStock',
          editable: true,
          role: [1, 2, 4],
          batchRole: [1, 2, 4],
          batchProps: {
            precision: 0,
            step: 1,
            min: 0,
          },
          roleProps: {
            min: 0,
            step: 1,
            precision: 0,
          },
          roleRules: { required: true },
          disabeldRender: record => {
            if (record.stock === null) return false;
            return customer.isEdit && customer.isNormal;
          },
        },
        {
          title: '库存预警',
          dataIndex: 'productStockWarning',
          editable: true,
          batchRole: [1],
          role: [1, 4],
          roleProps: {
            min: 0,
            precision: 0,
            maxLength: 5,
          },
          batchProps: {
            min: 0,
            precision: 0,
            maxLength: 5,
          },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '商品自编码',
          dataIndex: 'thirdSkuNo',
          editable: true,
          role: [1, 2],
          inputType: 'input',
          roleRules: { required: true },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '京东链接',
          dataIndex: 'skuLink',
          editable: true,
          role: [1, 2],
          inputType: 'input',
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: 'sku名称',
          dataIndex: 'name',
          editable: true,
          role: customer.isEdit && customer.isJDGoods ? [1, 2] : [],
          inputType: 'btnText',
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
        {
          title: '操作',
          editable: true,
          dataIndex: 'option',
          role: [1, 2],
          inputType: 'option',
          roleProps: {
            isJDGoods: customer.isJDGoods,
            disabled: customer.isDisabled,
            min: 0,
          },
          roleRules: { required: false },
          disabeldRender: () => customer.isDisabled,
        },
      ];
export const ENUM_REPERTORY = [{ label: '单规格', value: '1' }, { label: '多规格', value: '2' }];
export const ENUM_SET_REPERTORY = [{ label: '清零', value: '0' }, { label: '最大', value: '1' }];
export const ENUM_WEEK = [
  { value: '1', label: '周一' },
  { value: '2', label: '周二' },
  { value: '3', label: '周三' },
  { value: '4', label: '周四' },
  { value: '5', label: '周五' },
  { value: '6', label: '周六' },
  { value: '7', label: '周日' },
  // { value: 8, label: '法定假日' },
];
