# 查询表格

# 基础用法

当前共选中 0 项,共有 100 项
共 100 条
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 10
前往
<template>
  <el-card>
    <pro-search-table
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      selection
      :batch-operation="batchOperation"
      @request="request"
    >
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 100,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            format: "date",
            component: "DatePicker",
          },
          {
            label: "结束时间",
            name: "end",
            format: "date",
            component: "DatePicker",
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
        ],
      };
    },
    methods: {
      request(params, next) {
        setTimeout(next, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# 隐藏 search form

当前共选中 0 项,共有 100 项
共 100 条
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 10
前往
<template>
  <el-card>
    <pro-search-table
      selection
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      :search="false"
      :batch-operation="batchOperation"
      @request="request"
    >
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 100,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            format: "date",
            component: "DatePicker",
          },
          {
            label: "结束时间",
            name: "end",
            format: "date",
            component: "DatePicker",
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
        ],
      };
    },
    methods: {
      request(params, next) {
        setTimeout(next, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# 隐藏 search 输入框 和 table 列

当前共选中 0 项,共有 100 项
共 100 条
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 10
前往
<template>
  <el-card>
    <pro-search-table
      selection
      :limit="10"
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      :batch-operation="batchOperation"
      @request="request"
    >
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 100,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            component: "DatePicker",
            format: "date",
            hideSearch: true,
          },
          {
            label: "结束时间",
            name: "end",
            component: "DatePicker",
            format: "date",
            hideTable: true,
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            hideSearch: true,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
        ],
      };
    },
    methods: {
      request(params, next) {
        console.log(params);
        setTimeout(next, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# 使用序列

当前共选中 0 项,共有 0 项
暂无数据
<template>
  <el-card>
    <pro-search-table
      selection
      :limit="10"
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      :batch-operation="batchOperation"
      @request="handleRequest"
    >
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 0,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "序列",
            name: "$index",
            hideSearch: true,
          },
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            component: "DatePicker",
            format: "date",
            hideSearch: true,
          },
          {
            label: "结束时间",
            name: "end",
            component: "DatePicker",
            format: "date",
            hideTable: true,
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            hideSearch: true,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [],
      };
    },
    methods: {
      handleRequest(params, next) {
        const data = [];
        for (let index = 0; index < 10; index++) {
          data.push({
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          });
        }
        setTimeout(() => {
          next();
          this.dataSource = data;
          this.total = 100;
        }, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# 对 form 表单排序

当前共选中 0 项,共有 0 项
暂无数据

在 columns 属性中添加 sort 属性即可排序,值越大越靠前

<template>
  <el-card>
    <pro-search-table
      selection
      :limit="10"
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      :batch-operation="batchOperation"
      @request="handleRequest"
    >
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 0,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "序列",
            name: "$index",
            hideSearch: true,
          },
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            sort: 1,
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            component: "DatePicker",
            format: "date",
            hideSearch: true,
          },
          {
            label: "结束时间",
            name: "end",
            component: "DatePicker",
            format: "date",
            hideTable: true,
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            hideSearch: true,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [],
      };
    },
    methods: {
      handleRequest(params, next) {
        const data = [];
        for (let index = 0; index < 10; index++) {
          data.push({
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          });
        }
        setTimeout(() => {
          next();
          this.dataSource = data;
          this.total = 100;
        }, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# 隐藏 自定义 search 表单元素 和 自定义表格元素

TIP

继承 FormGrid 属性, 在原有的约定上增加search前缀,如:需要自定义 start 字段输入框则 slot name 值为 searchstartComponent;更多参考FormGrid Attributes
继承 ProTable 属性;在原有的约定上增加table前缀,如:需要自定义 start 字段输入框则 slot name 值为 tablestart;;更多参考ProTable Attributes

当前共选中 0 项,共有 100 项
共 100 条
  • 1
  • 2
  • 3
  • 4
  • 5
前往
<template>
  <el-card>
    <pro-search-table
      selection
      :limit="20"
      :columns="columns"
      :model="form"
      :data="dataSource"
      :total="total"
      :operation="operation"
      :batch-operation="batchOperation"
      @request="request"
    >
      <template #searchendComponent>
        <span>自定义 search end slot</span>
      </template>
      <template #tablestart>
        <span>自定义 table start slot</span>
      </template>
      <template v-slot:tool>
        <el-button size="small" type="primary" icon="el-icon-plus">
          新增
        </el-button>
      </template>
    </pro-search-table>
  </el-card>
</template>

<script>
  export default {
    data() {
      return {
        form: {},
        total: 100,
        batchOperation: [
          {
            text: "批量删除",
            popconfirm: {
              title: "确认批量删除?",
            },
            onClick: (multipleSelection) => {
              console.log(multipleSelection);
            },
          },
        ],
        operation: {
          props: { width: 120, fixed: "right" },
          list: [
            {
              text: "查看",
              onClick: () => {
                console.log("查看");
              },
            },
            {
              text: "删除",
              popconfirm: {
                title: "确认删除?",
              },
              onClick: () => {
                console.log("删除");
              },
            },
            {
              text: "修改",
              onClick: () => {
                console.log("修改");
              },
            },
          ],
        },
        columns: [
          {
            label: "姓名",
            name: "name",
            component: "Input",
          },
          {
            label: "性别",
            name: "sex",
            component: "Select",
            dict: [
              {
                name: "女",
                value: 0,
              },
              {
                name: "男",
                value: 1,
              },
            ],
          },
          {
            label: "开始时间",
            name: "start",
            component: "DatePicker",
            format: "date",
            hideSearch: true,
          },
          {
            label: "结束时间",
            name: "end",
            component: "DatePicker",
            format: "date",
            hideTable: true,
          },
          {
            label: "描述",
            name: "desc",
            component: "Input",
            colCount: 2,
            hideSearch: true,
            props: {
              type: "textarea",
              maxlength: 30,
              showWordLimit: true,
            },
          },
        ],
        dataSource: [
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 1,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
          {
            name: "王小虎",
            sex: 0,
            start: "20201012182912",
            end: "20201112182912",
            desc: "上海市普陀区金沙江路 1518 弄",
          },
        ],
      };
    },
    methods: {
      request(params, next) {
        console.log(params);
        setTimeout(next, 2000);
      },
    },
  };
</script>

<style lang="scss" scoped></style>
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
显示代码 复制代码

# API

# ProSearchTable Attributes

TIP

整合ProForm、[ProTable属性完全继承,更多可以参考对应文档

参数 说明 类型 可选值 默认值
batch-operation 批量操作按钮组,当 selection 为 true 生效, 回调参数multipleSelection为选中的数据 {text:string,onClick:Function(callback:Funtion(multipleSelection), popconfirm: object} - -
search 是否显示 顶部搜索 boolean - true

# ProSearchTable Events

事件名称 说明 回调参数
request 点击查查询、重置、分页时触发,回调参数 next 是一个 Funtion, 数据加载后,执行 next 隐藏 loading 框 Function({...model, page, limit}, next)

# ProSearchTable Slot

name 说明
tool table 上方 自定义插槽