@cainiaofe/cn-ui-m
Version:
70 lines (69 loc) • 2.98 kB
JavaScript
import React, { useMemo, useRef } from 'react';
import { CnCardItems, CnDemoPage, CnIcon } from "../../..";
export var 带远程请求 = function () {
var ref = useRef(null);
var operateColumn = useMemo(function () { return ({
buttons: [
{
children: '编辑',
onClick: function (event, record, index) {
var _a;
console.log('编辑', event, record, index);
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.refreshAsync();
},
},
{
children: '详情',
onClick: function (event, record, index) {
var _a;
console.log('详情', event, record, index);
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.currentPageRefreshAsync();
},
},
],
}); }, []);
return (React.createElement(CnDemoPage, { title: "\u5E26\u8FDC\u7A0B\u8BF7\u6C42" },
React.createElement(CnCardItems, { ref: ref, primaryKey: "id", icon: function () { return ({
type: 'add',
}); }, title: function () { return '外标题'; }, desc: function () { return '外标题说明'; }, action: function () { return React.createElement(CnIcon, { type: "time" }); }, subIcon: function () { return ({
type: 'add',
}); }, subTitle: function () { return '内标题'; }, subDesc: function () { return '内标题说明'; }, subAction: function () { return React.createElement(CnIcon, { type: "forward1" }); }, tags: function () { return [
{
status: 'success',
text: '成功',
},
{
status: 'warning',
text: '警告',
},
{
status: 'error',
text: '失败',
},
]; }, operateColumn: operateColumn, requestConfig: {
url: 'https://mocks.alibaba-inc.com/mock/cnui-api-demo/cardsOpt',
}, showSelect: true, onSelectChange: function (a, b) {
console.log('onSelectChange', a, b);
}, toolbar: {
buttons: [
{
children: '关注',
onClick: console.log,
},
{
children: '喜欢',
onClick: console.log,
},
{
children: '更新',
onClick: console.log,
},
{
children: '新增',
type: 'primary',
onClick: console.log,
},
],
} })));
};
export default { title: 'demo/CnCardItems' };