|
@@ -0,0 +1,200 @@
|
|
1
|
+<template>
|
|
2
|
+ <div style="text-align: center;">
|
|
3
|
+ <div style="width:600px;float: left; margin-left: 10px;margin-bottom: 10px;">
|
|
4
|
+ <el-input v-model="query" size="small" placeholder="请输入运输商名称" style="width :300px;float: left;"></el-input>
|
|
5
|
+ <el-button type="info" size="small" @click="search">查询</el-button>
|
|
6
|
+ <el-button type="primary" size="small" @click="handleAdd">新增</el-button>
|
|
7
|
+ </div>
|
|
8
|
+
|
|
9
|
+ <div style="padding-right: 30px;">
|
|
10
|
+ <el-table v-loading="loading" :data="tableData" border size="small">
|
|
11
|
+ <el-table-column prop="id" size="small" label="编号" width="60" v-if="isShow">
|
|
12
|
+ </el-table-column>
|
|
13
|
+ <el-table-column prop="name" size="small" label="运输商名称" width="250" show-overflow-tooltip>
|
|
14
|
+ </el-table-column>
|
|
15
|
+ <el-table-column label="操作" width="150">
|
|
16
|
+ <template slot-scope="scope">
|
|
17
|
+ <el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
|
|
18
|
+ <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
|
|
19
|
+ </template>
|
|
20
|
+ </el-table-column>
|
|
21
|
+ </el-table>
|
|
22
|
+ </div>
|
|
23
|
+
|
|
24
|
+ <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
|
|
25
|
+ :page-sizes="pageSizes" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalRows">
|
|
26
|
+ </el-pagination>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+ <el-dialog title="运输商" :visible.sync="dialogVisible" width="500px" >
|
|
31
|
+ <el-form :model="transport" label-width="100px">
|
|
32
|
+ <el-form-item label="运输商编码" v-if="isShow">
|
|
33
|
+ <el-input v-model="transport.id"></el-input>
|
|
34
|
+ </el-form-item>
|
|
35
|
+ <el-form-item label="运输商名称">
|
|
36
|
+ <el-input v-model="transport.name"></el-input>
|
|
37
|
+ </el-form-item>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+ <el-form-item>
|
|
41
|
+ <el-button type="success" @click="handleSave">保存</el-button>
|
|
42
|
+ <el-button @click="handleCancelSave">取消</el-button>
|
|
43
|
+ </el-form-item>
|
|
44
|
+ </el-form>
|
|
45
|
+ </el-dialog>
|
|
46
|
+ </div>
|
|
47
|
+</template>
|
|
48
|
+
|
|
49
|
+<script>
|
|
50
|
+ import axios from '@/axios'
|
|
51
|
+ export default {
|
|
52
|
+ components: {
|
|
53
|
+
|
|
54
|
+ },
|
|
55
|
+ data() {
|
|
56
|
+ return {
|
|
57
|
+ tableData: [],
|
|
58
|
+ currentPage: 1,
|
|
59
|
+ totalRows: 0,
|
|
60
|
+ pageSizes: [50, 100, 200,500],
|
|
61
|
+ pageSize: 50,
|
|
62
|
+ //查询条件
|
|
63
|
+ query: '',
|
|
64
|
+ //录入框
|
|
65
|
+ dialogVisible: false,
|
|
66
|
+ transport: {
|
|
67
|
+ id: '',
|
|
68
|
+ name: '',
|
|
69
|
+ },
|
|
70
|
+ isShow: false,
|
|
71
|
+ loading: true,
|
|
72
|
+ }
|
|
73
|
+ },
|
|
74
|
+ //界面渲染完毕调用 初始化表格参数
|
|
75
|
+ mounted() {
|
|
76
|
+ this.getTableData()
|
|
77
|
+ },
|
|
78
|
+ methods: {
|
|
79
|
+ // 获取table数据
|
|
80
|
+ getTableData() {
|
|
81
|
+ this.loading = true
|
|
82
|
+ var url = 'MaintTransport/query.do'
|
|
83
|
+ var param = {
|
|
84
|
+ page: this.currentPage,
|
|
85
|
+ rows: this.pageSize,
|
|
86
|
+ query: this.query
|
|
87
|
+ }
|
|
88
|
+ axios.get(url, param).then(response => {
|
|
89
|
+ if (response.data.code == 0) {
|
|
90
|
+ this.tableData = response.data.data.list
|
|
91
|
+ this.totalRows = response.data.data.total
|
|
92
|
+ } else {
|
|
93
|
+ this.$message({
|
|
94
|
+ type: 'error',
|
|
95
|
+ message: '保存失败' + response.data.msg,
|
|
96
|
+ });
|
|
97
|
+ }
|
|
98
|
+ this.loading = false
|
|
99
|
+ });
|
|
100
|
+ },
|
|
101
|
+ // 修改每页条数事件
|
|
102
|
+ handleSizeChange(val) {
|
|
103
|
+ console.log(`每页 ${val} 条`);
|
|
104
|
+ this.pageSize = val
|
|
105
|
+ this.getTableData()
|
|
106
|
+ },
|
|
107
|
+ // 修改当前页事件
|
|
108
|
+ handleCurrentChange(val) {
|
|
109
|
+ console.log(`当前页: ${val}`);
|
|
110
|
+ this.currentPage = val
|
|
111
|
+ this.getTableData()
|
|
112
|
+ },
|
|
113
|
+ //保存按钮事件
|
|
114
|
+ handleSave(row) {
|
|
115
|
+ var json = JSON.stringify(this.transport)
|
|
116
|
+ var url = 'MaintTransport/save.do'
|
|
117
|
+ var param = {
|
|
118
|
+ json: json
|
|
119
|
+ }
|
|
120
|
+ axios.post(url, param).then(response => {
|
|
121
|
+ if (response.data.code == 0) {
|
|
122
|
+ this.$message({
|
|
123
|
+ type: 'success',
|
|
124
|
+ message: '保存成功!',
|
|
125
|
+ });
|
|
126
|
+ this.getTableData()
|
|
127
|
+ this.dialogVisible = false
|
|
128
|
+ } else {
|
|
129
|
+ this.$message({
|
|
130
|
+ type: 'error',
|
|
131
|
+ message: '保存失败' + response.data.msg,
|
|
132
|
+ });
|
|
133
|
+ }
|
|
134
|
+ // loading.close();
|
|
135
|
+ });
|
|
136
|
+
|
|
137
|
+ },
|
|
138
|
+ //保存取消按钮事件 关闭编辑对话框
|
|
139
|
+ handleCancelSave(row) {
|
|
140
|
+ this.dialogVisible = false
|
|
141
|
+ },
|
|
142
|
+ // 新增按钮事件
|
|
143
|
+ handleAdd() {
|
|
144
|
+ this.dialogVisible = true
|
|
145
|
+ this.customer = {
|
|
146
|
+ id: '',
|
|
147
|
+ name: ''
|
|
148
|
+ }
|
|
149
|
+ },
|
|
150
|
+ // 编辑按钮事件
|
|
151
|
+ handleEdit(row) {
|
|
152
|
+ this.dialogVisible = true
|
|
153
|
+ this.transport = row
|
|
154
|
+ },
|
|
155
|
+
|
|
156
|
+ // 删除按钮事件
|
|
157
|
+ handleDelete(row) {
|
|
158
|
+ this.$confirm('此操作将删除该数据, 是否继续?', '提示', {
|
|
159
|
+ confirmButtonText: '确定',
|
|
160
|
+ cancelButtonText: '取消',
|
|
161
|
+ type: 'warning'
|
|
162
|
+ }).then(() => {
|
|
163
|
+
|
|
164
|
+ var url = 'MaintTransport/remove.do'
|
|
165
|
+ var param = {
|
|
166
|
+ id: row.id
|
|
167
|
+ }
|
|
168
|
+ axios.post(url, param).then(response => {
|
|
169
|
+ if (response.data.code == 0) {
|
|
170
|
+ this.$message({
|
|
171
|
+ type: 'success',
|
|
172
|
+ message: '删除成功!',
|
|
173
|
+ });
|
|
174
|
+ this.getTableData()
|
|
175
|
+ } else {
|
|
176
|
+ this.$message({
|
|
177
|
+ type: 'error',
|
|
178
|
+ message: '删除失败;' + response.data.msg
|
|
179
|
+ });
|
|
180
|
+ }
|
|
181
|
+ });
|
|
182
|
+ }).catch(() => {
|
|
183
|
+ this.$message({
|
|
184
|
+ type: 'info',
|
|
185
|
+ message: '已取消删除'
|
|
186
|
+ });
|
|
187
|
+ });
|
|
188
|
+ },
|
|
189
|
+ // 查询按钮事件
|
|
190
|
+ search() {
|
|
191
|
+ this.currentPage = 1
|
|
192
|
+ this.getTableData()
|
|
193
|
+ },
|
|
194
|
+
|
|
195
|
+ close(){
|
|
196
|
+ this.getTableData()
|
|
197
|
+ }
|
|
198
|
+ }
|
|
199
|
+ }
|
|
200
|
+</script>
|