import { goodsPage, goodsUpdate } from '@/services/goods/index'; import { history } from '@umijs/max'; import React, { useRef, useEffect } from 'react'; import { useIntl, useAccess } from '@umijs/max'; import { message, Tag, Button, Modal, Image, Switch } from 'antd'; import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components'; import { PlusOutlined } from '@ant-design/icons'; const GoodsTableList: React.FC = () => { const actionRef = useRef(); const columns = [ { title: 'ID', dataIndex: 'id', valueType: 'text', search: false, }, { title: '商品名称', dataIndex: 'goodsName', valueType: 'text', search: false, }, { title: '功率', dataIndex: 'itemType', valueType: 'text', search: false, }, { title: '销售价格', dataIndex: 'salePrice', valueType: 'text', search: false, }, { title: '利润', dataIndex: 'profit', valueType: 'text', search: false, }, { title: '库存', dataIndex: 'stock', valueType: 'text', search: false, }, { title: '销量', dataIndex: 'sales', valueType: 'text', search: false, }, { title: '商品主图', dataIndex: 'picture', valueType: 'text', search: false, render: (_, record) => { let _Img = record.picture ? JSON.parse(record.picture)[0] : '' return _Img ? : '' } }, { title: '是否上架', dataIndex: 'isUp', valueType: 'text', search: false, render: (_, record) => { let onChange = async (e) => { let data = JSON.parse(JSON.stringify(record)) data.isUp = e ? 1 : 0 let _res = await goodsUpdate(data) message.success(e ? '上架成功' : '下架成功'); if (actionRef.current) { actionRef.current.reload(); } } return } }, { title: '操作', dataIndex: 'option', width: '220px', valueType: 'option', render: (_, record) => [ , , ], }, ]; return (
[ ]} request={async (params, sorter, filter) => { let { data } = await goodsPage(params) return { data: data?.records || [], total: data?.total, }; }} columns={columns} />
); }; export default GoodsTableList;