function initPages(pagesSize = 15){
  return {
    total: 0,
    //size: 'Pagination',
    defaultCurrent: 1,
    defaultPageSize: pagesSize,
    current: 1,
    pageSize: pagesSize,
    showQuickJumper: false,
    //  size: 'small',
    showTotal: function(total, range) {
      return "总计" + total + "条";
    },
    showSizeChanger: true,
    pageSizeOptions: ["10",'15', "20", "30", "40", "50", "100", "200", "500"]
  };
};

function setColCount(context) {
  const { defaultCountKey, rowDrag } = context

  //如果没设置序列
  const def = {
    width: 40,
    fixed: false,

    key: defaultCountKey,
    ...context.filterDropdownColumn
  };
  const { width, key } = def;


  let count = {
    dataIndex: key,
    title: '序号',
    align: 'center',
    skip: true,
    ellipsis: false,
    width,
    _s: 0
  };
  if (rowDrag) {
    let h = context._c, v = context._v
    count.customRender = (text, record, index) => {
      return text&& h('div', {class:'row-drag'},
        [ h('span', {class:'row-drag-count'},[v(text||' ')]),
          h('a-icon', {
            class:'row-drag-icon',
            style: {
              fontSize: '14px'
            },
            attrs: { type: 'fullscreen' }
          })])


    }
  }
  return count;
}

export default {
  setColCount,
  cbPagersObj(pagination, data) {
    if (!pagination) return {};
    pagination.current = data.pageNum;
    pagination.pageSize = data.pageSize;
    pagination.defaultPageSize = data.pageSize;
    pagination.total = parseInt(data.totalCount);
   return pagination;
  },

  getDefaultPagination(pagination) {
    let _pages = pagination;
    if (_pages === 'default') return undefined;
    if (typeof _pages === 'boolean' && _pages === false) return false;
    if (typeof _pages === 'number') return initPages(_pages);
    if (typeof _pages === 'function') return _pages(initPages());
    if (typeof _pages === 'object') return _pages;

    return initPages();
  },
  initPages
};
