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
| <template>
| <el-dialog title="请选择产品" :visible.sync="dialogVisible" @close="close">
| <!-- 表格数据 -->
| <el-table stripe :data="tableData" @row-dblclick="close">
| <el-table-column type="index" label="序号"> </el-table-column>
| <el-table-column prop="name" label="名称"> </el-table-column>
| <el-table-column prop="type" label="型号"> </el-table-column>
| <el-table-column label="操作" width="100">
| <template slot-scope="scope">
| <el-button @click.native.prevent="close(scope.row)" type="text" size="small">
| 选择
| </el-button>
| </template>
| </el-table-column>
| </el-table>
| <!-- 分页组件 -->
| <el-pagination style="margin-top: 20px;" @size-change="onGetTableData" @current-change="onGetTableData"
| :current-page.sync="pageCurr" :page-size.sync="pageSize" :page-sizes="[10, 20, 50, 100]"
| layout="total, sizes, prev, pager, next, jumper" :total="total">
| </el-pagination>
| </el-dialog>
| </template>
|
| <script>
|
| export default {
| name: 'ProductList',
| props: {
| showFlag:{
| type: Boolean,
| }
| },
| data() {
| return {
| pageSize: 10,
| pageCurr: 1,
| total: 0,
| tableData: [],
| dialogVisible: false,
| callBack: null,
| };
| },
| watch: {
| showFlag (newVal, oldVal) {
| this.dialogVisible = newVal
| }
| },
| mounted() {
| this.onGetTableData()
| },
| methods: {
| // 获取表格数据
| onGetTableData: function () {
| var that = this;
| var data = {
| type: this.type,
| pageSize: this.pageSize,
| pageCurr: this.pageCurr,
| };
| that
| .$axiosAdmin({
| method: "post",
| url: "platform/product/some",
| data,
| })
| .then((res) => {
| if (res.success == true) {
| that.tableData = res.content.obj;
| that.total = res.content.itemTotal;
| } else {
| that.$alert(res.content, "提示", {
| confirmButtonText: "确定",
| });
| }
| })
| .catch((err) => {
| console.log(err);
| });
| },
| //成功回调函数
| doCallBack(data) {
| if (typeof this.callBack == 'function') {
| this.callBack(data)
| this.callBack = null;
| }
| },
| close(data) {
| this.doCallBack(data)
| this.dialogVisible = false;
| },
| show(callBack) {
| this.callBack = callBack;
| this.dialogVisible = true;
| }
| },
| };
| </script>
|
| <style lang="scss" scope>
|
| </style>
|
|