1
+ <template >
2
+ <div >
3
+ <div class =" search-term" >
4
+ <el-form :inline =" true" :model =" searchInfo" class =" demo-form-inline" >
5
+ <!-- 此处可使用表单生成器生成搜索条件 -->
6
+ <el-form-item >
7
+ <el-button @click =" openDialog" type =" primary" >新增</el-button >
8
+ </el-form-item >
9
+ </el-form >
10
+ </div >
11
+ <el-table
12
+ :data =" tableData"
13
+ border
14
+ ref =" multipleTable"
15
+ stripe
16
+ style =" width : 100% "
17
+ tooltip-effect =" dark"
18
+ >
19
+ <el-table-column type =" selection" width =" 55" ></el-table-column >
20
+ <el-table-column label =" 日期" width =" 180" >
21
+ <template slot-scope =" scope" >{ { " {{scope.row.CreatedAt|formatDate}}" } }</template >
22
+ </el-table-column >
23
+ { {range .Fields} }
24
+ <el-table-column label =" { { .FieldDesc} } " prop =" { { .FieldJson} } " width =" 120" ></el-table-column >
25
+ { { end } }
26
+ <el-table-column label =" 按钮组" >
27
+ <template slot-scope =" scope" >
28
+ <el-button @click =" update{ { .StructName} } (scope.row)" size =" small" type =" text" >变更</el-button >
29
+ <el-popover placement =" top" width =" 160" v-model =" scope.row.visible" >
30
+ <p >确定要删除吗?</p >
31
+ <div style =" text-align : right ; margin : 0 " >
32
+ <el-button size =" mini" type =" text" @click =" scope.row.visible = false" >取消</el-button >
33
+ <el-button type =" primary" size =" mini" @click =" delete{ { .StructName} } (scope.row)" >确定</el-button >
34
+ </div >
35
+ <el-button type =" text" size =" mini" slot =" reference" >删除</el-button >
36
+ </el-popover >
37
+ </template >
38
+ </el-table-column >
39
+ </el-table >
40
+
41
+ <el-pagination
42
+ :current-page =" page"
43
+ :page-size =" pageSize"
44
+ :page-sizes =" [10, 30, 50, 100]"
45
+ :style =" { float:' right' ,padding:' 20px' } "
46
+ :total =" total"
47
+ @current-change =" handleCurrentChange"
48
+ @size-change =" handleSizeChange"
49
+ layout =" total, sizes, prev, pager, next, jumper"
50
+ ></el-pagination >
51
+
52
+ <el-dialog :before-close =" closeDialog" :visible.sync =" dialogFormVisible" title =" 弹窗操作" >
53
+ <!-- 此处请使用表单生成器生成form填充 -->
54
+ <div class =" dialog-footer" slot =" footer" >
55
+ <el-button @click =" closeDialog" >取 消</el-button >
56
+ <el-button @click =" enterDialog" type =" primary" >确 定</el-button >
57
+ </div >
58
+ </el-dialog >
59
+ </div >
60
+ </template >
61
+
62
+ <script >
63
+ import {
64
+ create{ { .StructName} }
65
+ delete{ { .StructName} }
66
+ update{ { .StructName} }
67
+ find{ { .StructName} }
68
+ get{ { .StructName} } List
69
+ } from " @/api/{ { .StructName} } " ; // 此处请自行替换地址
70
+ import { formatTimeToStr } from " @/utils/data" ;
71
+ import infoList from " @/components/mixins/infoList" ;
72
+
73
+ export default {
74
+ name: " { { .StructName} } " ,
75
+ mixins: [infoList],
76
+ data() {
77
+ return {
78
+ listApi: get{ { .StructName} } List,
79
+ dialogFormVisible: false ,
80
+ visible: false ,
81
+ type: " " ,
82
+ form: {
83
+ { { range .Fields} } { { .FieldJson} } :null,{ { end } }
84
+ }
85
+ } ;
86
+ } ,
87
+ filters: {
88
+ formatDate: function(time) {
89
+ if (time != null && time != " " ) {
90
+ var date = new Date(time);
91
+ return formatTimeToStr(date, " yyyy-MM-dd hh:mm:ss" );
92
+ } else {
93
+ return " " ;
94
+ }
95
+ }
96
+ } ,
97
+ methods: {
98
+ async update{ { .StructName} } (row) {
99
+ const res = await get{ { .StructName} } ({ ID: row.ID } );
100
+ this.type = " update" ;
101
+ if (res.code == 0) {
102
+ this.form = res.data.re{ { .Abbreviation} } ;
103
+ this.dialogFormVisible = true ;
104
+ }
105
+ } ,
106
+ closeDialog() {
107
+ this.dialogFormVisible = false ;
108
+ this.form = {
109
+ { { range .Fields} }
110
+ { { .FieldJson} } :null,{ { end } }
111
+ } ;
112
+ } ,
113
+ async delete{ { .StructName} } (row) {
114
+ this.visible = false ;
115
+ const res = await delete{ { .StructName} } ({ ID: row.ID } );
116
+ if (res.code == 0) {
117
+ this.$message ({
118
+ type: " success" ,
119
+ message: " 删除成功"
120
+ } );
121
+ this.getTableData();
122
+ }
123
+ } ,
124
+ async enterDialog() {
125
+ let res;
126
+ switch (this.type) {
127
+ case " create" :
128
+ res = await create{ { .StructName} } (this.form);
129
+ break ;
130
+ case " update" :
131
+ res = await update{ { .StructName} } (this.form);
132
+ break ;
133
+ default :
134
+ res = await create{ { .StructName} } (this.form);
135
+ break ;
136
+ }
137
+
138
+ if (res.code == 0) {
139
+ this.closeDialog();
140
+ this.getTableData();
141
+ }
142
+ } ,
143
+ openDialog() {
144
+ this.type = " create" ;
145
+ this.dialogFormVisible = true ;
146
+ }
147
+ } ,
148
+ created() {
149
+ this.getTableData();
150
+ }
151
+ } ;
152
+ </script >
153
+
154
+ <style >
155
+ </style >
0 commit comments