mcya / myReactComponentLibrary

我的开发的组件库(基于react+antd) + 开发过程中的一些经验(Issuess)
1 stars 0 forks source link

react+antd 设置序号自动增加(另外 + table表格的各类设置) #8

Open mcya opened 7 years ago

mcya commented 7 years ago

const columns = [
  {
    title: '序号',
    dataIndex: 'projNum',
    key: 'projNum',
    render: (text, record, index) => ++index
  },
  {
    title: '折扣类型',
    dataIndex: 'type',
    key: 'type',
    render: (status, record, index) => {
      if (status==0) {
        return <span>普通折扣方案</span>
      } else if (status==1) {
        return <span>开盘前折扣方案</span>
      } else if (status==2) {
        return <span>员工折扣方案</span>
      } else if (status==3) {
        return <span>合作项目领导折扣方案</span>
      }
    }
  },
  {
    title: '折扣方案名称',
    dataIndex: 'discntplanname',
    key: 'discntplanname'
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    render: (status, record, index) => {
      if (status==1) {
        return <span>审批中</span>
      } else if (status==0) {
        return <span>草稿</span>
      } else if (status==2) {
        return <span>已启用</span>
      } else if (status==3) {
        return <span>已作废</span>
      } else if (status==4) {
        return <span>已终止</span>
      } else if (status==5) {
        return <span>已停用</span>
      }
    }
  },
  {
    title: '修改日期',
    dataIndex: 'changetime',
    key: 'changetime',
    render: (text, record, index) => text && dateformat(text, 'yyyy-MM-dd hh:mm')
  },
  {
    title: '操作',
    dataIndex: 'cuozuo',
    key: 'cuozuo', render: (record, item) => {
      // console.log('操作字段值text, record, item', text, record, item);
      const discntplanid = item.discntplanid;
      const workflowid = item.workflowdataid;
      const flowtype = item.flowid;
      if (workflowid) {
        if (item.workflowstatus === '3') {
          return (
            <span>
              <span className={styles.iconBtn} onClick={!hasPermission('discount.zhixing')&&this.activeOrAbandonedApproval.bind(this, discntplanid, workflowid, 1, flowtype)}>执行&nbsp;</span>
              <span className={styles.iconBtn} onClick={!hasPermission('discount.zuofei')&&this.activeOrAbandonedApproval.bind(this, discntplanid, workflowid, 0, flowtype)}>作废&nbsp;</span>
            </span>
          )
        }
      }
    }
  },
  {
    title: '工作流',
    dataIndex: 'workflowtitle',
    key: 'workflowtitle', render: (record, item) => {
      const workflowid = item.workflowdataid;
      return (
        <span className={styles.iconBtn} onClick={this.openworkflow.bind(this, workflowid)}>{item.workflowtitle}</span>
      )
    }
  }]
mcya commented 7 years ago

{
    title: '序号',
    dataIndex: 'projNum',
    key: 'projNum',
    render: (text, record, index) => ++index
  },

序号

mcya commented 7 years ago

<Table
      loading={this.props.loading}
      rowSelection={rowSelection}
      size="middle" columns = {columns}
      pagination={this.state.pagination}
      dataSource={this.props.discntsList.data.disnts}
      onRowDoubleClick={::this.tableDblClick}
/>
hualinIT commented 5 years ago

good