1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
| import { ref } from 'vue';
| import { ElMessage } from 'element-plus';
| import { dict, compute, EditReq, DelReq, AddReq } from '@fast-crud/fast-crud';
|
| import { getAPI } from '/@/utils/axios-utils';
| import { SysNoticeApi } from '/@/api-services/api';
| import { PageFileInput } from '/@/api-services/models';
|
| export default function ({ expose }) {
| // 分页查询
| const pageRequest = async (query: any) => {
| const params = {
| page: query.currentPage,
| pageSize: query.pageSize,
| field: query.field,
| order: query.order,
| descStr: 'desc',
| } as PageFileInput;
| const result = await getAPI(SysNoticeApi).apiSysNoticePagePost(params);
| return result;
| };
| // 编辑
| const editRequest = async ({ form, row }: EditReq) => {
| if (form.id == null) {
| form.id = row.id;
| }
| return await getAPI(SysNoticeApi)
| .apiSysNoticeUpdatePost(form)
| .then((rsp: any) => {
| if (rsp.data.code == 200) {
| ElMessage.success('修改成功!');
| } else {
| ElMessage.error('修改失败:' + rsp.data.message);
| }
| });
| };
| // 删除
| const delRequest = async ({ row }: DelReq) => {
| return await getAPI(SysNoticeApi).apiSysNoticeDeletePost(row);
| };
| // 增加
| const addRequest = async ({ form }: AddReq) => {
| return await getAPI(SysNoticeApi).apiSysNoticeAddPost(form);
| };
| // 选择
| const selectedIds = ref([]);
| const onSelectionChange = (changed: any) => {
| selectedIds.value = changed;
| };
| return {
| selectedIds,
| crudOptions: {
| container: {
| is: 'fs-layout-card',
| },
| form: {
| wrapper: {
| // is: 'el-drawer',
| // width: '80%',
| draggable: false,
| closeOnEsc: false,
| maskClosable: false,
| },
| },
| search: {
| show: true,
| },
| actionbar: {},
| toolbar: {
| show: true,
| buttons: {
| search: { show: true },
| refresh: { show: true },
| compact: { show: true },
| export: { show: true },
| columns: { show: true },
| },
| },
| table: {
| scrollX: 725,
| bordered: false,
| rowKey: (row: any) => row.id,
| checkedRowKeys: selectedIds,
| 'onUpdate:checkedRowKeys': onSelectionChange,
| },
| pagination: {
| show: true,
| },
| request: {
| pageRequest,
| addRequest,
| editRequest,
| delRequest,
| },
| rowHandle: {
| fixed: 'right',
| align: 'center',
| width: 200,
| buttons: {
| view: { show: true },
| edit: { show: true },
| },
| },
| columns: {
| _checked: {
| title: '选择',
| form: { show: false },
| column: {
| type: 'selection',
| align: 'center',
| width: '55px',
| columnSetDisabled: true,
| disabled(row: any) {
| return row.account === 'gvanet';
| },
| },
| },
| type: {
| title: '类型',
| type: 'dict-select',
| search: { show: true, col: { span: 6 } },
| column: {
| align: 'center',
| width: '120px',
| },
| dict: dict({
| value: 'id',
| label: 'text',
| data: [
| { id: '1', text: '通知' },
| { id: '2', text: '公告' },
| ],
| }),
| form: {
| col: { span: 24 },
| rule: [{ required: true, message: '请输入类型' }],
| },
| },
| title: {
| title: '标题',
| type: 'text',
| search: { show: true, col: { span: 6 } },
| column: {
| align: 'center',
| width: 'auto',
| },
| form: {
| col: { span: 24 },
| rule: [{ required: true, message: '请输入标题' }],
| },
| },
| content: {
| title: '内容',
| type: 'editor-wang5',
| search: { show: false, col: { span: 6 } },
| column: {
| show: false,
| },
| form: {
| col: { span: 24 },
| rule: [{ required: true, message: '请输入内容' }],
| component: {
| disabled: compute(({ form }) => {
| return form.disabled;
| }),
| id: '1', // 当同一个页面有多个editor时,需要配置不同的id
| config: {},
| uploader: {
| type: 'form',
| buildUrl(res: any) {
| return res.url;
| },
| },
| },
| },
| },
| },
| },
| };
| }
|
|