UNPKG

@antdp/edit-table

Version:

基于antd封装的组件

77 lines 2.35 kB
import _extends from "@babel/runtime/helpers/extends"; import React from 'react'; import { Popconfirm, Typography, Space } from 'antd'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** 操作列配置 */ var operation = _ref => { var { optConfig, isEditing, isAddEdit, save, isOptDelete, cancel, onDelete, edit, newAdd, editingKey, rowKey, multiple } = _ref; return [_extends({ title: '操作', align: 'center', width: 120 }, optConfig, { render: (item, record, index) => { var editable = isEditing(record); var isNewAdd = isAddEdit(record); if (optConfig && optConfig.render) { return optConfig.render(item, record, index, { editable, isNewAdd, save, cancel, onDelete, edit, newAdd, editingKey }); } return editable ? /*#__PURE__*/_jsxs("span", { children: [/*#__PURE__*/_jsx(Typography.Link, { onClick: () => save(record[rowKey], record, index), style: { marginRight: 8 }, children: "\u4FDD\u5B58" }), /*#__PURE__*/_jsx(Popconfirm, { title: "\u662F\u5426\u53D6\u6D88\u5F53\u524D\u884C\u7F16\u8F91?", okText: "\u662F", cancelText: "\u5426", onConfirm: // 如果是新增操作的数据,进行判断 取消时使用删除方法 isNewAdd ? onDelete.bind(this, record[rowKey], record, index) : cancel.bind(this, record[rowKey]), children: /*#__PURE__*/_jsx(Typography.Link, { children: "\u53D6\u6D88" }) })] }) : /*#__PURE__*/_jsxs(Space, { children: [/*#__PURE__*/_jsx(Typography.Link, { disabled: !!editingKey.length && !multiple, onClick: () => edit(record), children: "\u7F16\u8F91" }), isOptDelete && /*#__PURE__*/_jsx(Popconfirm, { title: "\u662F\u5426\u5220\u9664\u5F53\u524D\u884C\u6570\u636E?", okText: "\u662F", cancelText: "\u5426", onConfirm: () => onDelete(record[rowKey], record, index), children: /*#__PURE__*/_jsx(Typography.Link, { children: "\u5220\u9664" }) })] }); } })]; }; export default operation;