import React, { useState, useEffect } from 'react';
import styles from './index.less';
import { Input ,Menu,Table,Space,Upload,message,Button } from 'antd';

import { Link, useIntl, connect, Dispatch } from 'umi';


const pagination={defaultCurrent:1,total: 16}
const dataSource = [
  {
    key: '1',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
  },
];

const PropertyServices = (props: { location: any; }) => {

  const { formatMessage } = useIntl();
  
  const nameofowner = formatMessage({ id: 'R.charge.input.nameofowner' })
  const inputProject = formatMessage({ id: 'R.charge.input.project' })
  const username = formatMessage({ id: 'R.charge.username' })
  const project = formatMessage({ id: 'R.charge.project' })
  const unit = formatMessage({ id: 'R.charge.unit' })
  const status = formatMessage({ id: 'R.charge.status' })
  const submissionTime = formatMessage({ id: 'R.charge.submissionTime' })
  const actions = formatMessage({ id: 'R.charge.actions' })
  const search = formatMessage({ id: 'R.charge.search' })
  const addaccount = formatMessage({ id: 'R.charge.addaccount' })
  const paymentsetting = formatMessage({ id: 'R.charge.paymentsetting' })

  const { location} = props;

  const tags = [username, project, unit, submissionTime, status,actions];
  
  const [columns, setColums] = useState([{title:"1", dataIndex:"1", key:"1"}]);
  useEffect(() => {
    var tagval;
    if (location.pathname=="/runTest2") {
      tagval=['name', 'age', 'address', 'address', 'address'];      
    } else {
      tagval=['name', 'age', 'age', 'age', 'address']; 
    }

    var columnsTmp = [
      { title: tags[0], dataIndex: tagval[0], key: tagval[0] },
      { title: tags[1], dataIndex: tagval[1], key: tagval[1] },
      { title: tags[2], dataIndex: tagval[2], key: tagval[2] },
      { title: tags[3], dataIndex: tagval[3], key: tagval[3] },
      { title: tags[4], dataIndex: tagval[4], key: tagval[4] },
      { title: tags[5], dataIndex: tagval[3], key: tagval[3],
        render: (text: any, record: any) => (
          <Space size="middle">
            <a>{text==33?"回复":"详情"}</a>
          </Space>
        ),},];
    setColums(columnsTmp)
  },[location.pathname]);


  return (
    <div className={styles.base}>

        {/* 头部组件 */}
        <div className={styles.box}>
          <input className={styles.item1} placeholder={nameofowner} />
          <input className={styles.item2} placeholder={inputProject} />
          <input className={styles.item4} placeholder={inputProject} />
          <button className={styles.item3}>{search}</button>
      </div>

          {/* 列表组件 */}
      <Table style={{ marginTop: 16 }} dataSource={dataSource} columns={columns} pagination={pagination} />;
      
    </div>
  );
};


export default PropertyServices;
