import { useCountryInfoStore } from '/@/stores/countryInfo';


const countryInfoStore = useCountryInfoStore();

export const companyColumns = [
  { type: 'seq', width: 50, align: 'center', fixed: 'left' },
  {
    field: 'platform', title: '平台', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        return <span class={ 'font-medium' }>{ row.platform ? row.platform : '--' }</span>;
      }
    }
  },
  {
    field: 'platformNumber', title: '店铺编号', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        return <span class={ 'font-medium' }>{ row.platformNumber ? row.platformNumber : '--' }</span>;
      }
    }
  },
  {
    field: 'platformName', title: '店铺名称', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        return <span class={ 'font-medium' }>{ row.platformName ? row.platformName : '--' }</span>;
      }
    }
  },
  {
    field: 'status', title: '状态', width: 80, align: 'center',
    slots: {
      default({ row }: any) {
        return (
            <el-tag
                class="font-medium"
                type={ row.status === 1 ? 'success' : 'danger' }
            >
              { row.status === 1 ? '启用' : '暂停' }
            </el-tag>
        );
      }
    }
  },
  {
    field: 'country', title: '国家', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        const country = countryInfoStore.countries.find(c => c.name === row.country);
        const color = country ? country.color : '#3875F6';
        return <el-tag effect="plain" round
                       style={ { color: color, borderColor: color } }>{ row.country ? row.country : '--' }</el-tag>;
      }
    }
  },
  {
    field: 'brandName', title: '品牌', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        return <span class={ 'font-medium' }>{ row.brandName ? row.brandName : '--' }</span>;
      }
    }
  },
  {
    field: 'line', title: '线路', minWidth: 'auto', align: 'center',
    slots: {
      default({ row }: any) {
        return <span class={ 'font-medium' }>{ row.line ? row.line : '--' }</span>;
      }
    }
  },
];
