Pārlūkot izejas kodu

fix: 资料清单模板初始化渲染

lanjianrong 2 gadi atpakaļ
vecāks
revīzija
d01d76a0d7
1 mainītis faili ar 80 papildinājumiem un 82 dzēšanām
  1. 80 82
      src/pages/Business/Inventory/index.tsx

+ 80 - 82
src/pages/Business/Inventory/index.tsx

@@ -32,7 +32,7 @@ const Inventory = () => {
   const {
     loading,
     record,
-    list,
+    list = [],
     rowClick,
     move,
     addFolder,
@@ -96,89 +96,87 @@ const Inventory = () => {
   return (
     <PageContainer title={false}>
       <div style={{ height: `${contentHeight}px` }} className="bg-white">
-        {list?.length && (
-          <Table
-            rowKey="ID"
-            title={() => (
-              <div className="ml-2 flex flex-nowrap justify-start items-center">
-                <Dropdown
-                  overlay={<Menu selectable defaultSelectedKeys={['1']} items={items} />}
-                  trigger={['click']}>
-                  <div className="font-bold cursor-pointer">
-                    <Space>
-                      {items[0].label}
-                      <DownOutlined />
-                    </Space>
-                  </div>
-                </Dropdown>
-                <div className="children:mx-1 px-1 py-2 ml-5">
-                  <Button icon={<FolderAddOutlined />} size="small" type="primary" ghost onClick={addFolder}>
-                    新建目录
-                  </Button>
-                  <Button icon={<FileAddOutlined />} size="small" type="primary" ghost onClick={addFile}>
-                    新建文件
-                  </Button>
-                  <Button
-                    icon={<EditOutlined />}
-                    size="small"
-                    type="primary"
-                    ghost
-                    onClick={editFolder}
-                    disabled={!record}>
-                    编辑
-                  </Button>
-                  <Button
-                    icon={<DeleteOutlined />}
-                    size="small"
-                    type="primary"
-                    ghost
-                    onClick={deleteFolderOrFile}
-                    disabled={!record}>
-                    删除
-                  </Button>
-                  <Button
-                    icon={<ArrowUpOutlined />}
-                    size="small"
-                    type="primary"
-                    ghost
-                    disabled={!record?.moveable || record?.position === 'top'}
-                    onClick={() => moveWithOperation('up')}>
-                    上移
-                  </Button>
-                  <Button
-                    icon={<ArrowDownOutlined />}
-                    size="small"
-                    type="primary"
-                    ghost
-                    disabled={!record?.moveable || record?.position === 'bottom'}
-                    onClick={() => moveWithOperation('down')}>
-                    下移
-                  </Button>
-                  <Button
-                    icon={<SelectOutlined />}
-                    size="small"
-                    type="primary"
-                    ghost
-                    disabled={!record}
-                    onClick={move}>
-                    移动至
-                  </Button>
+        <Table
+          rowKey="ID"
+          title={() => (
+            <div className="ml-2 flex flex-nowrap justify-start items-center">
+              <Dropdown
+                overlay={<Menu selectable defaultSelectedKeys={['1']} items={items} />}
+                trigger={['click']}>
+                <div className="font-bold cursor-pointer">
+                  <Space>
+                    {items[0].label}
+                    <DownOutlined />
+                  </Space>
                 </div>
+              </Dropdown>
+              <div className="children:mx-1 px-1 py-2 ml-5">
+                <Button icon={<FolderAddOutlined />} size="small" type="primary" ghost onClick={addFolder}>
+                  新建目录
+                </Button>
+                <Button icon={<FileAddOutlined />} size="small" type="primary" ghost onClick={addFile}>
+                  新建文件
+                </Button>
+                <Button
+                  icon={<EditOutlined />}
+                  size="small"
+                  type="primary"
+                  ghost
+                  onClick={editFolder}
+                  disabled={!record}>
+                  编辑
+                </Button>
+                <Button
+                  icon={<DeleteOutlined />}
+                  size="small"
+                  type="primary"
+                  ghost
+                  onClick={deleteFolderOrFile}
+                  disabled={!record}>
+                  删除
+                </Button>
+                <Button
+                  icon={<ArrowUpOutlined />}
+                  size="small"
+                  type="primary"
+                  ghost
+                  disabled={!record?.moveable || record?.position === 'top'}
+                  onClick={() => moveWithOperation('up')}>
+                  上移
+                </Button>
+                <Button
+                  icon={<ArrowDownOutlined />}
+                  size="small"
+                  type="primary"
+                  ghost
+                  disabled={!record?.moveable || record?.position === 'bottom'}
+                  onClick={() => moveWithOperation('down')}>
+                  下移
+                </Button>
+                <Button
+                  icon={<SelectOutlined />}
+                  size="small"
+                  type="primary"
+                  ghost
+                  disabled={!record}
+                  onClick={move}>
+                  移动至
+                </Button>
               </div>
-            )}
-            loading={loading}
-            columns={columns}
-            dataSource={list}
-            pagination={false}
-            size="small"
-            bordered
-            expandable={{ defaultExpandAllRows: true }}
-            onRow={record => ({
-              onClick: () => rowClick(record)
-            })}
-            rowClassName={row => (row.ID === record?.ID ? 'ant-table-row-selected' : '')}
-          />
-        )}
+            </div>
+          )}
+          loading={loading}
+          columns={columns}
+          dataSource={list}
+          pagination={false}
+          size="small"
+          bordered
+          expandable={{ defaultExpandAllRows: true }}
+          onRow={record => ({
+            onClick: () => rowClick(record)
+          })}
+          rowClassName={row => (row.ID === record?.ID ? 'ant-table-row-selected' : '')}
+        />
       </div>
       {ModalDOM}
     </PageContainer>