ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.3k stars 1.36k forks source link

🧐[问题] Not fill data edit when use tableRender #8573

Open pluderes opened 3 months ago

pluderes commented 3 months ago

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🧐 问题描述

💻 示例代码

This is code table: `<Table ref={tableRef} className="product-list-table" dataSource={dataSource} headerTitle={"List product"} actionRef={actionRef} rowKey="id" loading={isLoading || isFetching || updateLoading} actionOption={actionOption} rowClassName={(record) => { return record.status === "LOCKED" ? "row-locked" : "row-unlocked"; }} columns={[ ...columns, { title: "", render: (dom, record: ProductImport, index, action) => { return (

  • action?.startEditable(record.id)} > Fix
  • { handleDelete(record); }} > Delete
  •           );
            },
            hideInSearch: true,
            hideInForm: true,
            editable: false,
            width: 100,
          },
        ]}
        tableRender={(
          props,
          dom,
          domList: {
            toolbar: JSX.Element | undefined;
            alert: JSX.Element | undefined;
            table: JSX.Element | undefined;
          }
        ) => {
          return (
            <>
              <div className="tableToolbar bg-white">{domList.toolbar}</div>
              <Tabs
                onChange={onChange}
                type="card"
                tabBarStyle={{ margin: "10px 0 0" }}
                items={[
                  {
                    key: "1",
                    label: "Normal product",
                    children: domList.table,
                  },
                  {
                    key: "2",
                    label: "Final product",
                    children: domList.table,
                  },
                ]}
              />
            </>
          );
        }}
        rowSelection={{
          onChange: (_, selectedRows) => {
            setSelectedRows(selectedRows);
          },
        }}
        pagination={{
          total: data?.data.total,
          current: data?.data.current_page,
          pageSize: data?.data.per_page,
          onChange: (page, pageSize) => {
            setSearchQuery((prev) => {
              return {
                ...prev,
                pagination: {
                  current_page: page,
                  per_page: pageSize,
                },
              };
            });
          },
        }}
      />`

    And this is columns `const columns: ProColumns[] = [ { title: ( <FormattedMessage id="pages.searchTable.updateForm.ruleName.defaultMessage" defaultMessage="#" /> ), dataIndex: 'key', hideInSearch: true, width: 50, editable: false, }, { title: , dataIndex: 'date_import', hideInSearch: true, width: 200, render: (text: any) => moment(text).format('YYYY-MM-DD'), }, { title: , dataIndex: 'product.code', }, { title: , dataIndex: 'product.name', }, { title: (

        ),
        dataIndex: 'product.specification',
      },
      {
        title: <FormattedMessage id="table.columName.unit" defaultMessage="Đơn vị tính" />,
        dataIndex: 'product.unit',
        render: renderCenterCell,
      },
      {
        dataIndex: 'product.quantity',
        title: <FormattedMessage id="table.columName.quantity" defaultMessage="Số lượng" />,
        render: renderNumberCell,
      },
      {
        title: <FormattedMessage id="table.columName.price" defaultMessage="Đơn giá không VAT" />,
        dataIndex: 'product.price',
      },
      {
        title: <FormattedMessage id="table.columName.money" defaultMessage="Thành tiền" />,
        dataIndex: 'money',
        hideInSearch: true,
        render: (text, record: any) => {
          const quantity = record?.product?.quantity;
          const price = record?.product?.price;
          const total = quantity * price;
          return total.toLocaleString();
        },
      },
      {
        title: <FormattedMessage id="table.columName.note" defaultMessage="Ghi chú" />,
        dataIndex: 'note',
        hideInSearch: true,
      },
      {
        title: <FormattedMessage id="table.columName.stock" defaultMessage="Kho" />,
        dataIndex: 'stock',
        hideInSearch: true,
      },
      {
        title: (
          <FormattedMessage
            id="table.columName.user_create_id"
            defaultMessage="Nhân viên nhập kho"
          />
        ),
        dataIndex: 'user_create_id',
        hideInSearch: true,
      },
      {
        title: <FormattedMessage id="table.columName.create_time" defaultMessage="Ngày tạo" />,
        dataIndex: 'create_time',
        hideInSearch: true,
        filters: [
          {
            text: 'xxx',
            value: 'das',
          },
        ],
        render: (text: any) => moment(text).format('YYYY-MM-DD'),
      },
    ];`

    🚑 其他信息

    image image