@aliretail/react-materials-components
Version:
79 lines (73 loc) • 2.23 kB
JavaScript
import _Dialog from "@alifd/next/es/dialog";
import _Loading from "@alifd/next/es/loading";
import _Table from "@alifd/next/es/table";
/* eslint-disable react/prop-types */
import * as React from 'react';
import ImageText from "../ImageText";
var SelectSKUDialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
var type = props.type,
goodIds = props.goodIds,
onGoodIdsChange = props.onGoodIdsChange,
visible = props.visible,
primaryKey = props.primaryKey,
onVisibleChange = props.onVisibleChange,
loading = props.loading,
goodList = props.goodList;
var _React$useState = React.useState([]),
currentGoodIds = _React$useState[0],
setCurrentGoodIds = _React$useState[1];
React.useEffect(function () {
if (visible) {
// 每次打开时设置一下外面的skuIds
setCurrentGoodIds(goodIds || []);
}
}, [visible]);
var handleCancel = function handleCancel() {
setCurrentGoodIds([]);
onVisibleChange(false);
};
var handleOk = function handleOk() {
onGoodIdsChange(currentGoodIds);
onVisibleChange(false);
};
return /*#__PURE__*/React.createElement(_Dialog, {
title: "\u9009\u62E9\u8D27\u54C1",
visible: visible,
onClose: handleCancel,
onCancel: handleCancel,
onOk: handleOk,
style: {
width: 600
},
ref: ref
}, /*#__PURE__*/React.createElement(_Loading, {
visible: loading
}, /*#__PURE__*/React.createElement("div", {
style: {
marginBottom: 8
}
}, type), /*#__PURE__*/React.createElement(_Table, {
hasBorder: false,
dataSource: goodList || [],
primaryKey: primaryKey,
rowSelection: {
selectedRowKeys: currentGoodIds,
onChange: function onChange(rowKeys) {
return setCurrentGoodIds(rowKeys);
},
mode: 'multiple'
}
}, /*#__PURE__*/React.createElement(_Table.Column, {
dataIndex: "good",
title: "\u8D27\u54C1",
cell: function cell(v) {
return /*#__PURE__*/React.createElement(ImageText, v);
}
}), /*#__PURE__*/React.createElement(_Table.Column, {
dataIndex: "count",
title: "\u6570\u91CF",
width: 80,
align: "right"
}))));
});
export default SelectSKUDialog;