index.jsx 1.72 KB
Newer Older
wuhao's avatar
wuhao committed
1
import * as React from 'react';
wuhao's avatar
wuhao committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
import { useState, useMemo, useRef } from 'react';
import DrawerPro from '@/components/DrawerPro';
import AutoTable from '@/components/AutoTable';
import PremButton from '@/components/PremButton';
import getcolumns from './columns';
import { useRequest } from 'ahooks';
import { doFetch } from '@/utils/doFetch';
import AutoTables from '@/components/AutoTable/mtable';

function ExtraTable({ spareStockId }) {
  return (
    <div style={{ padding: '4px 4px 4px 36px', backgroundColor: '#cccccc' }}>
      <AutoTables
        path={'/sparepart/spareSupplierStock/queryBySpareStockId'}
        extraparams={{ spareStockId: spareStockId }}
        pagination={false}
        resizeable={false}
        columns={[
          { title: '供应商编号', dataIndex: 'supplierNo', key: 'supplierNo' },
          { title: '供应商名称', dataIndex: 'supplierName', key: 'supplierName' },
          { title: '库存数量', dataIndex: 'actualStock', key: 'actualStock', hideInSearch: true },
        ]}
      />
    </div>
  );
}

function Stock(props) {
  const actionRef = useRef();
  const pathconfig = useMemo(() => {
    let pathconf = getcolumns()?.pathconfig ?? {};
    return pathconf;
  }, []);

  const columns = useMemo(() => {
    let defcolumn = getcolumns()?.columns;
    return defcolumn;
  }, []);

  return (
    <div style={{ position: 'relative' }}>
      <AutoTable
        pagetitle="备件库存"
        columns={columns}
        actionRef={actionRef}
        path={pathconfig?.list || '/ngic-auth/sysUser/query/page'}
        resizeable={false}
        expandable={{
          expandedRowRender: (record) => <ExtraTable spareStockId={record?.id} />,
        }}
      />
    </div>
  );
}

export default Stock;