# 起步
本项目是基于iview开发,使用前请先在main.js写入语句(使用iview)
import iview from 'iview';
import 'iview/dist/styles/iview.css';
Vue.use(iview);
1
2
3
2
3
再写入(使用iview-extends2)
import 'iviewExtends2' from 'iview-extends2';
import 'iview-extends2/src/styles/iview-extends2.css';
Vue.use(iviewExtends2);
1
2
3
2
3
# 配置一个基础的增删改查页面
<template>
<div>
<ive-filter-form
:formConfig="formConfig"
@query="handleQuery"
/>
<ive-table
ref="table"
:columns="columns"
:getListApi="getListApi()"
:deleteApi="deleteApi()"
@showEditModal="showEditModal"
/>
<ive-edit-modal
ref="modal"
:id="id"
:modal="modal"
:formConfig.sync="formConfigEdit"
:getDetailApi="getDetailApi()"
:editApi="editApi()"
@close="hideEditModal"
@success="editSuccess"
/>
</div>
</template>
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
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
<script>
export default {
name: 'simple-page-demo',
data() {
return {
// ive-filter-form
formConfig: [
{
prop: 'title',
label: '消息标题',
},
],
// ive-table
pager: {
pageIndex: 1,
pageSize: 30,
count: 0,
},
columns: [
{
title: '消息标题',
key: 'title',
minWidth: 120,
},
{
title: '操作',
slot: 'action',
align: 'center',
fixed: 'right',
minWidth: 130,
},
],
// ive-edit-modal
id: '',
modal: false,
formConfigEdit: [
{
prop: 'title',
label: '标题',
required: true,
itemConfig: {
props: {
maxlength: 22,
},
},
rules: [
{
validator: function () {},
},
],
},
],
};
},
methods: {
// ive-filter-form
handleQuery(queryParams) {
this.getList(queryParams, 1);
},
// ive-table
getListApi() {
return axios.getList;
},
deleteApi() {
return axios.delMessage;
},
getList(queryParams, pageIndex) {
this.$refs.table.getList(queryParams, pageIndex);
},
// ive-edit-modal
getDetailApi() {
return axios.getMessage;
},
editApi() {
return axios.editMessage;
},
showEditModal(id) {
this.id = id;
this.modal = true;
},
hideEditModal() {
this.modal = false;
this.id = '';
},
editSuccess() {
this.hideEditModal();
this.getList();
},
},
};
</script>
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
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