Blame view

src/views/system/robot.vue 6.39 KB
2d21111e   wangming   项目初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  <template>
  	<div class="container" style="margin: 10px;">
  		<el-form :inline="true" :model="robotmodel" class="demo-form-inline">
  			<el-form-item label="关键字">
  				<el-input v-model="robotmodel.KeyWord" placeholder="关键字"></el-input>
  			</el-form-item>
  			<el-form-item>
  				<el-button type="primary" @click="onSubmit">查询</el-button>
  			</el-form-item>
  			<el-form-item>
  				<el-button type="success" @click="AddOrUpdRobot(null)">新增</el-button>
  			</el-form-item>
  		</el-form>
  		<el-table :data="tableData" style="width: 100%">
  			<el-table-column prop="id" label="ID">
  				<template slot-scope="scope">
  					{{scope.row.id}}
  				</template>
  			</el-table-column>
dc36257f   wwk   后端页面
20
  			<el-table-column prop="full_name" label="贵姓">
2d21111e   wangming   项目初始化
21
  				<template slot-scope="scope">
dc36257f   wwk   后端页面
22
  					{{scope.row.full_name}}
2d21111e   wangming   项目初始化
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
  				</template>
  			</el-table-column>
  
  			<el-table-column prop="phone" label="联系方式">
  				<template slot-scope="scope">
  					{{scope.row.phone}}
  				</template>
  			</el-table-column>
  			<el-table-column prop="carModel" label="车型">
  				<template slot-scope="scope">
  				{{scope.row.carModel}}
  				</template>
  			</el-table-column>
  			<el-table-column prop="ReservationStatus" label="状态">
  				<template slot-scope="scope">
  					<el-tag :type="scope.row.ReservationStatus=='已预约'?'success':'warn'">
  						{{scope.row.ReservationStatus}}
  					</el-tag>
  				</template>
  			</el-table-column>
  			<el-table-column label="编辑">
  				<template slot-scope="scope">
  					<el-button type="primary" @click="AddOrUpdRobot(scope.row)">编辑</el-button>
  				</template>
  			</el-table-column>
  			<el-table-column label="删除">
  				<template slot-scope="scope">
  					<el-button type="danger" @click="DelRobot(scope.row.id)">删除</el-button>
  				</template>
  			</el-table-column>
  		</el-table>
dc36257f   wwk   后端页面
54
  		<el-pagination background layout="prev, pager, next" :total="TotalCount" @current-change="Pages"
2d21111e   wangming   项目初始化
55
56
57
  			style="text-align: right;margin-top: 10px;">
  		</el-pagination>
  		<el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
2d21111e   wangming   项目初始化
58
  			<el-form ref="form" :model="form" label-width="80px" :rules="rules">
dc36257f   wwk   后端页面
59
60
  				<el-form-item label="贵姓" prop="full_name">
  					<el-input v-model="form.full_name" placeholder="请输入贵姓"></el-input>
2d21111e   wangming   项目初始化
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
  				</el-form-item>
  				<el-form-item label="电话号码" prop="phone">
  					<el-input v-model="form.phone" placeholder="请输入电话号码"></el-input>
  				</el-form-item>
  				<el-form-item label="车型" prop="carModel">
  					<el-input v-model="form.carModel" placeholder="请输入车型"></el-input>
  				</el-form-item>
  				<el-form-item label="状态" prop="ReservationStatus" >
  					 <el-select v-model="form.ReservationStatus" placeholder="请选择状态">
  					   <el-option label="已预约" value="已预约"></el-option>
  					   <el-option label="已取消" value="已取消"></el-option>
  					   <el-option label="已完成" value="已完成"></el-option>
  					  </el-select>
  				</el-form-item>
  			</el-form>
  			<span slot="footer" class="dialog-footer">
  				<el-button @click="dialogVisible = false">取 消</el-button>
  				<el-button type="primary" @click="SubmitMoney">确 定</el-button>
  			</span>
  		</el-dialog>
  	</div>
  </template>
  
  <script>
  	import {
  		CreateRobot,
  		UpdateRobot,
  		DeleteRobot,
  		ListRobot
  	} from '../../api/RobotReservation.js'
  	import utils from '../../utils/utils.js'
  	export default {
  		data() {
  			return {
  				dialogVisible: false,
  				rules: {
dc36257f   wwk   后端页面
97
  					full_name: [{
2d21111e   wangming   项目初始化
98
  						required: true,
dc36257f   wwk   后端页面
99
  						message: '请输入贵姓',
2d21111e   wangming   项目初始化
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
  						trigger: 'change'
  					}, ],
  					phone: [{
  							required: true,
  							message: '请输入手机号',
  							trigger: 'change'
  						},
  						{
  							pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
  							message: '请输入手机号码',
  							trigger: 'blur'
  						}
  					],
  					carModel: [{
  							required: true,
  							message: '请输入车型',
  							trigger: 'change'
  						}
  					],
  				},
  				tableData: [],
  				robotmodel: {
  					KeyWord: "",
  					pageIndex: 1,
  					pageSize: 20,
  					sort: '',
  					sortOrder: '',
  				},
  				TotalCount: 0,
  				form: {
dc36257f   wwk   后端页面
130
  					"full_name":'',
2d21111e   wangming   项目初始化
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
  					"id": 0,
  					"userName": "",
  					"phone": "",
  					"carModel": "",
  					"ReservationStatus": "已预约"
  				}
  			}
  		},
  		created() {
  			this.ShowRobot()
  		},
  		methods: {
  			// 提交添加或者修改
  			SubmitMoney() {
  				this.$refs.form.validate((valid) => {
  					if (valid) {
  						if(this.form.id>0){
  							UpdateRobot(this.form).then(res=>{
  								console.log('数据',res)
  								if(res.data.code==200){
  									this.$message.success('修改成功')
  									this.dialogVisible=false
  									this.ShowRobot()
  								}else{
  									this.$message.error('修改失败')
  								}
  							})
  						}else{
  							CreateRobot(this.form).then(res=>{
  								console.log('新增',res)
  								if(res.data.code==200){
  									this.$message.success('新增成功')
  									this.dialogVisible=false
  									this.ShowRobot()
  								}else{
  									this.$message.error('新增失败')
  								}
  								
  							})
  						}
  						AddOrUpdMoney(this.form).then(res => {
  							console.log('哈哈', res)
  							if (res.data.code == 200) {
  								this.$message.success('操作成功')
  								this.dialogVisible = false
  								this.ShowMoneys()
  							} else {
  								this.$message.error('操作失败')
  							}
  						})
  					}
  				})
  			},
  			DelRobot(id) {
  				DeleteRobot({
  					ids:id
  				}).then(res => {
  					console.log('删除数据', res)
  					if (res.code == 200) {
  						this.$message.success('删除成功')
  						this.ShowRobot()
  					}else{
  						this.$message.error('删除失败')
  					}
  				})
  			},
  			Pages(e) {
  				this.robotmodel.pageIndex = e
  				this.ShowRobot()
  			},
  			// 展示机器人列表
  			ShowRobot() {
  				ListRobot(this.robotmodel).then(res => {
  					console.log('提现记录', res)
  					this.tableData = res.data.data
  					this.TotalCount = res.data.count
  				})
  			},
  			AddOrUpdRobot(obj) {
  				this.dialogVisible = true
  				if (obj == null) {
  					// 新增
  					this.form.id = 0
dc36257f   wwk   后端页面
214
  					this.form.full_name=''
2d21111e   wangming   项目初始化
215
216
217
218
219
220
  					this.form.userName = ''
  					this.form.phone = ''
  					this.form.carModel =''
  				} else {
  					// 修改
  					this.form.id = obj.id
dc36257f   wwk   后端页面
221
  					this.form.full_name=obj.full_name
2d21111e   wangming   项目初始化
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
  					this.form.userName = obj.userName
  					this.form.phone = obj.phone
  					this.form.carModel =obj.carModel
  					this.form.ReservationStatus=obj.ReservationStatus
  				}
  			},
  			onSubmit() {
  				this.ShowRobot()
  			}
  		}
  	}
  </script>
  
  <style>
  </style>