123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- import { optionsListApi } from '/@/api/demo/select';
- import { FormProps, FormSchema } from '/@/components/Table';
- import { BasicColumn } from '/@/components/Table/src/types/table';
- import { VxeFormItemProps, VxeGridPropTypes } from '/@/components/VxeTable';
- import { ref } from 'vue';
- import { Input } from 'ant-design-vue';
- export function getBasicColumns(): BasicColumn[] {
- return [
- {
- title: 'ID',
- dataIndex: 'id',
- fixed: 'left',
- width: 200,
- },
- {
- title: '姓名',
- dataIndex: 'name',
- width: 150,
- filters: [
- { text: 'Male', value: 'male' },
- { text: 'Female', value: 'female' },
- ],
- },
- {
- title: '地址',
- dataIndex: 'address',
- },
- {
- title: '编号',
- dataIndex: 'no',
- width: 150,
- sorter: true,
- defaultHidden: true,
- },
- {
- title: '开始时间',
- width: 150,
- sorter: true,
- dataIndex: 'beginTime',
- },
- {
- title: '结束时间',
- width: 150,
- sorter: true,
- dataIndex: 'endTime',
- },
- ];
- }
- export function getBasicShortColumns(): BasicColumn[] {
- return [
- {
- title: 'ID',
- width: 150,
- dataIndex: 'id',
- sorter: true,
- sortOrder: 'ascend',
- },
- {
- title: '姓名',
- dataIndex: 'name',
- width: 120,
- },
- {
- title: '地址',
- dataIndex: 'address',
- },
- {
- title: '编号',
- dataIndex: 'no',
- width: 80,
- },
- ];
- }
- export function getMultipleHeaderColumns(): BasicColumn[] {
- const testRef = ref('姓名:');
- return [
- {
- title: 'ID',
- dataIndex: 'id',
- width: 200,
- },
- {
- title: '姓名',
- customHeaderRender() {
- return (
- <Input placeholder="输入值 更新 自定义title" size="small" v-model:value={testRef.value} />
- );
- },
- dataIndex: 'name',
- width: 120,
- },
- {
- title: '地址',
- dataIndex: 'address',
- sorter: true,
- children: [
- {
- title: '编号',
- customHeaderRender(column) {
- // 【自定义渲染的】
- return (
- <div>
- _ <span style="background: #f00; color: #fff;">{testRef.value}</span> _
- {column.customTitle}
- </div>
- );
- },
- dataIndex: 'no',
- width: 120,
- filters: [
- { text: 'Male', value: 'male', children: [] },
- { text: 'Female', value: 'female', children: [] },
- ],
- },
- {
- title: '开始时间',
- dataIndex: 'beginTime',
- width: 120,
- },
- {
- title: '结束时间',
- dataIndex: 'endTime',
- width: 120,
- },
- ],
- },
- ];
- }
- export function getCustomHeaderColumns(): BasicColumn[] {
- return [
- {
- title: 'ID',
- dataIndex: 'id',
- helpMessage: 'headerHelpMessage方式1',
- width: 200,
- },
- {
- // title: '姓名',
- dataIndex: 'name',
- width: 120,
- // slots: { title: 'customTitle' },
- },
- {
- // title: '地址',
- dataIndex: 'address',
- width: 120,
- // slots: { title: 'customAddress' },
- sorter: true,
- },
- {
- title: '编号',
- dataIndex: 'no',
- width: 120,
- filters: [
- { text: 'Male', value: 'male', children: [] },
- { text: 'Female', value: 'female', children: [] },
- ],
- },
- {
- title: '开始时间',
- dataIndex: 'beginTime',
- width: 120,
- },
- {
- title: '结束时间',
- dataIndex: 'endTime',
- width: 120,
- },
- ];
- }
- const cellContent = (_, index) => ({
- colSpan: index === 9 ? 0 : 1,
- });
- export function getMergeHeaderColumns(): BasicColumn[] {
- return [
- {
- title: 'ID',
- dataIndex: 'id',
- width: 300,
- customCell: (_, index) => ({
- colSpan: index === 9 ? 6 : 1,
- }),
- },
- {
- title: '姓名',
- dataIndex: 'name',
- width: 300,
- customCell: cellContent,
- },
- {
- title: '地址',
- dataIndex: 'address',
- colSpan: 2,
- width: 120,
- sorter: true,
- customCell: (_, index) => ({
- rowSpan: index === 2 ? 2 : 1,
- colSpan: index === 3 || index === 9 ? 0 : 1,
- }),
- },
- {
- title: '编号',
- dataIndex: 'no',
- colSpan: 0,
- filters: [
- { text: 'Male', value: 'male', children: [] },
- { text: 'Female', value: 'female', children: [] },
- ],
- customCell: cellContent,
- },
- {
- title: '开始时间',
- dataIndex: 'beginTime',
- width: 200,
- customCell: cellContent,
- },
- {
- title: '结束时间',
- dataIndex: 'endTime',
- width: 200,
- customCell: cellContent,
- },
- ];
- }
- export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => {
- const arr: any = [];
- for (let index = 0; index < itemNumber; index++) {
- arr.push({
- field: `field${index}`,
- label: `字段${index}`,
- component: 'Input',
- colProps: {
- xl: 12,
- xxl: 8,
- },
- });
- }
- return arr;
- };
- export function getFormConfig(): Partial<FormProps> {
- return {
- labelWidth: 100,
- schemas: [
- ...getAdvanceSchema(5),
- {
- field: `field11`,
- label: `Slot示例`,
- component: 'Select',
- slot: 'custom',
- colProps: {
- xl: 12,
- xxl: 8,
- },
- },
- ],
- };
- }
- export function getBasicData() {
- return (() => {
- const arr: any = [];
- for (let index = 0; index < 40; index++) {
- arr.push({
- id: `${index}`,
- name: 'John Brown',
- age: `1${index}`,
- no: `${index + 10}`,
- address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
- beginTime: new Date().toLocaleString(),
- endTime: new Date().toLocaleString(),
- });
- }
- return arr;
- })();
- }
- export function getTreeTableData() {
- return (() => {
- const arr: any = [];
- for (let index = 0; index < 40; index++) {
- arr.push({
- id: `${index}`,
- name: 'John Brown',
- age: `1${index}`,
- no: `${index + 10}`,
- address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
- beginTime: new Date().toLocaleString(),
- endTime: new Date().toLocaleString(),
- children: [
- {
- id: `l2-${index}`,
- name: 'John Brown',
- age: `1${index}`,
- no: `${index + 10}`,
- address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
- beginTime: new Date().toLocaleString(),
- endTime: new Date().toLocaleString(),
- },
- ],
- });
- }
- return arr;
- })();
- }
- export const vxeTableColumns: VxeGridPropTypes.Columns = [
- {
- title: '序号',
- type: 'seq',
- fixed: 'left',
- width: '50',
- align: 'center',
- },
- {
- title: '固定列',
- field: 'name',
- width: 150,
- showOverflow: 'tooltip',
- fixed: 'left',
- },
- {
- title: '自适应列',
- field: 'address',
- },
- {
- title: '自定义列(自定义导出)',
- field: 'no',
- width: 200,
- showOverflow: 'tooltip',
- align: 'center',
- slots: {
- default: ({ row }) => {
- const text = `自定义${row.no}`;
- return [<div class="text-red-500">{text}</div>];
- },
- },
- exportMethod: ({ row }) => {
- return `自定义${row.no}导出`;
- },
- },
- {
- title: '自定义编辑',
- width: 150,
- field: 'name1',
- align: 'center',
- editRender: {
- name: 'AInput',
- placeholder: '请点击输入',
- },
- },
- {
- title: '开始时间',
- width: 150,
- field: 'beginTime',
- showOverflow: 'tooltip',
- align: 'center',
- },
- {
- title: '结束时间',
- width: 150,
- field: 'endTime',
- showOverflow: 'tooltip',
- align: 'center',
- },
- {
- width: 160,
- title: '操作',
- align: 'center',
- slots: { default: 'action' },
- fixed: 'right',
- },
- ];
- export const vxeTableFormSchema: VxeFormItemProps[] = [
- {
- field: 'field0',
- title: 'field0',
- itemRender: {
- name: 'AInput',
- },
- span: 6,
- },
- {
- field: 'field1',
- title: 'field1',
- itemRender: {
- name: 'AApiSelect',
- props: {
- api: optionsListApi,
- resultField: 'list',
- labelField: 'name',
- valueField: 'id',
- },
- },
- span: 6,
- },
- {
- span: 12,
- align: 'right',
- className: '!pr-0',
- itemRender: {
- name: 'AButtonGroup',
- children: [
- {
- props: { type: 'primary', content: '查询', htmlType: 'submit' },
- attrs: { class: 'mr-2' },
- },
- { props: { type: 'default', htmlType: 'reset', content: '重置' } },
- ],
- },
- },
- ];
|