UNPKG

ukelli-ui

Version:

Base on React's UI lib. Make frontend's dev simpler and faster.

199 lines (198 loc) 5.43 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; import React from 'react'; import { DescHelper, Table } from '.'; import { ShowModal } from '../modal'; var table; var columns = [ { key: 'username', namesMapper: { alex: '埃里克斯', chili: '吃梨', dove: '德芙', } }, { key: 'age', selectable: false, title: function () { return (React.createElement("span", null, "Age")); }, }, { key: 'property', selectable: false, money: true, tips: [ '超过 10 块钱的富人', '超过 20 块钱的巨富', '超过 40 块钱的富可敌国', ], }, { key: 'obj', filter: function (_, item) { return _.account; } }, { key: 'add', labels: { cn: 'red' } }, // {key: 'birth1', date: 1}, // {key: 'birth2', date: 1}, // {key: 'birth3', date: 1}, // {key: 'birth4', date: 1}, { key: 'status', title: { type: 'selector', values: { normal: '正常', abnormal: '异常', }, onChange: function (val) { console.log(val); } }, labels: { normal: 'success', exception: 'error', } }, ]; var action = { key: 'action', filter: function (str, item) { return (React.createElement("div", null, React.createElement("span", { onClick: function (e) { return ShowModal({ title: '详情', children: React.createElement(DescHelper, { columns: columns, record: item }) }); }, className: "link-btn" }, "\u8BE6\u60C5"), React.createElement("span", { onClick: function (e) { return ShowModal({ width: 1000, title: '详情', children: (React.createElement(Table, { columns: columns, ref: function (e) { table = e; }, checkedOverlay: (React.createElement("span", { className: "btn theme mu10", onClick: function (e) { return table.clearCheckeds(); } }, "\u6E05\u9664\u6240\u6709\u7684\u4EE5\u9009\u4E2D\u9879")), needCheck: true, needCount: true, records: records })) }); }, className: "link-btn t_red" }, "\u5F39\u51FA\u8868\u683C"))); } }; var keyMapperMiddle = __spreadArrays(columns).slice(1, columns.length); var keyMapperFixed = __spreadArrays([ { key: 'username', fixed: 'left', tips: [ '可以是数组1', '可以是数组2', '可以是数组3', ], title: function () { return (React.createElement("span", null, "Func Title")); }, namesMapper: { alex: '埃里克斯', chili: '吃梨', dove: '德芙', } } ], keyMapperMiddle, [ __assign(__assign({}, action), { fixed: 'right' }) ]); var records = [ { id: 1, username: 'alex', age: 100, property: '100000', add: 'cn', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 2, username: 'chili', age: 102, property: '200000', add: '帝国议会所代表的王国和皇室领地以及匈牙利圣斯蒂芬王冠领地', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 3, username: 'dove', property: '300000', age: 50, add: 'cn', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 4, username: 'susam', property: '400000', age: 20, add: 'uk', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 5, username: 'susam', property: '400000', age: 20, add: 'uk', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 6, username: 'susam', property: '400000', age: 20, add: 'cn', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'normal', }, { id: 7, username: 'susam', property: '400000', age: 20, add: 'cn', obj: { account: 123, }, birth: new Date('1999-01-01'), status: 'exception', }, ]; export { columns, keyMapperFixed, records };