index.tsx 3.41 KB
// App.js

function Header() {
  return (
    <div className="flex items-start justify-between mb-6">
      <div className="text-sm">
        <p className="font-medium">网址: www.canrd.com</p>
      </div>
      <h1 className="text-3xl font-bold text-center">发票</h1>
      <div className="text-sm text-right">
        <p className="font-medium">QQ: 2902385824</p>
      </div>
    </div>
  );
}

function InvoiceDetails() {
  return (
    <div className="grid grid-cols-2 gap-4 mb-6 text-sm">
      <div>
        <p>单位名称: 某某科技有限公司</p>
        <p>联系电话: 18583817221</p>
      </div>
      <div className="text-right">
        <p>编号: Canrd-DZ-2023-1101-004</p>
        <p>开票日期: 2023年11月1日</p>
      </div>
    </div>
  );
}

function ProductsTable() {
  return (
    <div className="mb-6">
      <table className="w-full text-sm border border-gray-300 table-fixed">
        <thead>
          <tr className="bg-gray-200">
            <th className="w-1/4 p-2 border border-gray-300 border-solid">
              名称
            </th>
            <th className="w-1/6 p-2 border border-gray-300 border-solid">
              规格
            </th>
            <th className="w-1/6 p-2 border border-gray-300 border-solid">
              单位
            </th>
            <th className="w-1/12 p-2 border border-gray-300 border-solid">
              数量
            </th>
            <th className="w-1/6 p-2 border border-gray-300 border-solid">
              单价
            </th>
            <th className="w-1/6 p-2 border border-gray-300 border-solid">
              金额
            </th>
            <th className="w-1/4 p-2 border border-gray-300 border-solid">
              备注
            </th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td className="p-2 whitespace-normal border border-gray-300 border-solid">
              产品名称可能非常长,所以这里会自动换行
            </td>
            <td className="p-2 border border-gray-300 border-solid">
              规格型号
            </td>
            <td className="p-2 border border-gray-300 border-solid">单位</td>
            <td className="p-2 border border-gray-300 border-solid">1</td>
            <td className="p-2 border border-gray-300 border-solid">400</td>
            <td className="p-2 border border-gray-300 border-solid">400</td>
            <td className="p-2 whitespace-normal border border-gray-300 border-solid">
              备注信息可能也会很长,需要自动换行来适应内容
            </td>
          </tr>
          {/* 其他行 */}
        </tbody>
      </table>
    </div>
  );
}

function Footer() {
  return (
    <div className="text-sm">
      <p>备注: 一些备注文本...</p>
      <div className="flex items-center justify-between mt-4">
        <div>
          <p>销售人员: 签字</p>
        </div>
        <div>
          <p>业务员: 签字</p>
        </div>
        <div>
          <p>开票人: 签字</p>
          <p className="font-medium">总计: ¥400</p>
        </div>
      </div>
    </div>
  );
}

function App() {
  return (
    <div className="flex items-center justify-center min-h-screen bg-gray-100">
      <div className="w-full max-w-4xl p-10 bg-white border border-gray-300">
        <Header />
        <InvoiceDetails />
        <ProductsTable />
        <Footer />
      </div>
    </div>
  );
}

export default App;