123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- import { h } from 'vue';
- import { Tag, Switch } from 'ant-design-vue';
- import { BasicColumn } from '/@/components/Table';
- import { FormSchema } from '/@/components/Form/index';
- import { Icon } from '/@/components/Icon';
- import { adapt } from '/@/utils/adapt';
- import { editRule } from '/@/api/sys/user';
- const adaptWidth = adapt();
- export const fakeTree = [
- {
- id: 1,
- title: 'Dashboard',
- status: true,
- icon: 'ion:layers-outline',
- create_time: '2021-01-01',
- detail: '',
- children: [
- {
- id: 2,
- title: '工作台',
- status: true,
- icon: 'ion:git-compare-outline',
- create_time: '2021-01-01',
- detail: '',
- children: [
- {
- id: 8,
- title: '天然光',
- status: true,
- icon: 'ion:git-compare-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- {
- id: 9,
- title: '小苏打粉',
- status: false,
- icon: 'ion:tv-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- {
- id: 22,
- title: '士大夫',
- status: true,
- icon: 'ion:git-compare-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- {
- id: 95,
- title: '小苏打粉',
- status: false,
- icon: 'ion:tv-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- ],
- },
- {
- id: 3,
- title: '分析页',
- status: false,
- icon: 'ion:tv-outline',
- create_time: '2021-01-01',
- detail: '',
- children: [
- {
- id: 10,
- title: '略略略',
- status: true,
- icon: 'ion:git-compare-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- {
- id: 19,
- title: '嘻嘻嘻',
- status: false,
- icon: 'ion:tv-outline',
- create_time: '2021-01-01',
- detail: '',
- },
- ],
- },
- ],
- },
- {
- id: 4,
- title: '权限管理',
- status: true,
- icon: 'bx:bx-lock',
- create_time: '2021-01-01',
- detail: '',
- children: [
- {
- id: 5,
- title: '角色管理',
- status: true,
- icon: 'bx:bx-lock',
- create_time: '2021-01-01',
- detail: '',
- },
- {
- id: 6,
- title: '菜单管理',
- status: true,
- icon: 'bx:bx-lock',
- create_time: '2021-01-01',
- detail: '',
- },
- ],
- },
- ];
- export const columns: BasicColumn[] = [
- {
- title: 'ID',
- dataIndex: 'id',
- editComponentProps: {
- prefix: '$',
- },
- width: 80,
- },
- {
- title: '标题',
- dataIndex: 'title',
- width: 160,
- },
- {
- title: '图标',
- dataIndex: 'icon',
- width: 80,
- customRender: ({ record }) => {
- return h(Icon, { icon: record.icon });
- },
- },
- {
- title: '规则',
- dataIndex: 'name',
- width: 200,
- },
- {
- title: '菜单',
- dataIndex: 'ismenu',
- width: 80,
- customRender: ({ record }) => {
- function onChange(val) {
- console.log(val, record.id);
- record.ismenu = val;
- const data = { id: record.id, ismenu: Number(val) };
- console.log(`data11`, data);
- editRule(data);
- }
- return h(Switch, { checked: record.ismenu, onChange: onChange });
- },
- },
- {
- title: '状态',
- dataIndex: 'status',
- width: 80,
- customRender: ({ record }) => {
- const status = record.status;
- const enable = status === 'normal';
- const color = enable ? 'green' : 'red';
- const text = enable ? '启用' : '停用';
- return h(Tag, { color: color }, () => text);
- },
- },
- {
- title: '权重',
- dataIndex: 'weigh',
- width: 160,
- },
- ];
- // popup =====================================================
- export const schemas: FormSchema[] = [
- {
- field: 'pid',
- label: '父级',
- component: 'TreeSelect',
- componentProps: {
- replaceFields: {
- title: 'title',
- key: 'id',
- value: 'id',
- },
- getPopupContainer: () => document.body,
- },
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'title',
- component: 'Input',
- label: '标题',
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'name',
- component: 'Input',
- label: '名称',
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'rules',
- component: 'Input',
- label: '规则',
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'icon',
- label: '图标',
- component: 'IconPicker',
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'ismenu',
- label: '是否菜单',
- component: 'Switch',
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- {
- field: 'status',
- label: '状态',
- component: 'RadioButtonGroup',
- defaultValue: 'normal',
- componentProps: {
- options: [
- { label: '启用', value: 'normal' },
- { label: '停用', value: 'locked' },
- ],
- },
- labelWidth: adaptWidth.labelWidth,
- colProps: {
- span: adaptWidth.elContainer,
- },
- },
- ];
|