UNPKG

@schema-render/search-table-react

Version:
72 lines (71 loc) 2.27 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { HolderOutlined } from "@ant-design/icons"; import { Button, InputNumber, Switch, Tag } from "antd"; export function createColumns({ locale }) { const titleEnum = locale.SearchTable.settingModalColumnEnum; const sortEnum = locale.SearchTable.settingModalColumnSortEnum; const columns = [ { title: titleEnum[0], dataIndex: 'name', width: 200 }, { title: titleEnum[1], dataIndex: 'hidden', width: 90, render: (value, onChange)=>{ return /*#__PURE__*/ _jsx(Switch, { checked: !value, onChange: (val)=>onChange(!val) }); } }, { title: titleEnum[2], dataIndex: 'width', width: 100, render: (value, onChange)=>{ return /*#__PURE__*/ _jsx(InputNumber, { min: 1, value: value, onChange: (val)=>{ val ? onChange(val) : undefined; } }); } }, { title: titleEnum[3], dataIndex: 'fixed', width: 60, algin: 'center', render: (value)=>{ const text = value ? value === 'left' ? sortEnum[0] : sortEnum[1] : sortEnum[2]; const color = value ? value === 'left' ? 'orange' : 'blue' : undefined; return /*#__PURE__*/ _jsx(Tag, { color: color, style: { margin: 0 }, children: text }); } }, { title: titleEnum[4], dataIndex: 'sort', width: 50, algin: 'center', render: ()=>/*#__PURE__*/ _jsx(Button, { type: "text", size: "small", icon: /*#__PURE__*/ _jsx(HolderOutlined, {}), style: { cursor: 'move' } }) } ]; return columns; }