Skip to content

Commit 907faa4

Browse files
committed
add switch change event
1 parent b417d04 commit 907faa4

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

CrazyCarBackground/src/views/assets/index.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
</el-table-column>
1818
<el-table-column label="Status" width="110px" align="center">
1919
<template v-slot="{row}">
20-
<span>{{ row.is_on }}</span>
20+
<el-switch
21+
v-model="row.is_on"
22+
@change="handleIsOnChange(row)"
23+
/>
2124
</template>
2225
</el-table-column>
2326
<el-table-column label="Url" min-width="150px">
@@ -166,6 +169,20 @@ export default {
166169
this.$refs['dataForm'].clearValidate()
167170
})
168171
},
172+
handleIsOnChange(row) {
173+
const tempData = Object.assign({}, row)
174+
tempData.timestamp = +new Date(tempData.timestamp)
175+
updateAssetsInfo(tempData).then(response => {
176+
const index = this.list.findIndex(v => v.id === response.id)
177+
this.list.splice(index, 1, response)
178+
this.$notify({
179+
title: 'Success',
180+
message: 'Update Successfully',
181+
type: 'success',
182+
duration: 2000
183+
})
184+
})
185+
},
169186
updateData() {
170187
this.$refs['dataForm'].validate((valid) => {
171188
if (valid) {

CrazyCarBackground/src/views/equip/index.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@
4747
</el-table-column>
4848
<el-table-column label="Wade" min-width="150px">
4949
<template v-slot="{row}">
50-
<span>{{ row.can_wade }}</span>
50+
<el-switch
51+
v-model="row.can_wade"
52+
@change="handleSwitchChange(row)"
53+
/>
5154
</template>
5255
</el-table-column>
5356
<el-table-column label="Show" min-width="150px">
5457
<template v-slot="{row}">
55-
<span>{{ row.is_show }}</span>
58+
<el-switch
59+
v-model="row.is_show"
60+
@change="handleSwitchChange(row)"
61+
/>
5662
</template>
5763
</el-table-column>
5864
<el-table-column label="Actions" align="center" width="230" class-name="small-padding fixed-width">
@@ -217,6 +223,19 @@ export default {
217223
this.$refs['dataForm'].clearValidate()
218224
})
219225
},
226+
handleSwitchChange(row) {
227+
const tempData = Object.assign({}, row)
228+
updtaeEquipInfo(tempData).then(response => {
229+
const index = this.list.findIndex(v => v.eid === response.eid)
230+
this.list.splice(index, 1, response)
231+
this.$notify({
232+
title: 'Success',
233+
message: 'Update Successfully',
234+
type: 'success',
235+
duration: 2000
236+
})
237+
})
238+
},
220239
updateData() {
221240
this.$refs['dataForm'].validate((valid) => {
222241
if (valid) {

CrazyCarBackground/src/views/match/index.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
</el-table-column>
4343
<el-table-column label="Water" min-width="150px">
4444
<template v-slot="{row}">
45-
<span>{{ row.has_water }}</span>
45+
<el-switch
46+
v-model="row.has_water"
47+
@change="handleHasWaterChange(row)"
48+
/>
4649
</template>
4750
</el-table-column>
4851
<el-table-column label="Actions" align="center" width="230" class-name="small-padding fixed-width">
@@ -196,6 +199,19 @@ export default {
196199
this.$refs['dataForm'].clearValidate()
197200
})
198201
},
202+
handleHasWaterChange(row) {
203+
const tempData = Object.assign({}, row)
204+
updtaeMatchInfo(tempData).then(response => {
205+
const index = this.list.findIndex(v => v.cid === response.cid)
206+
this.list.splice(index, 1, response)
207+
this.$notify({
208+
title: 'Success',
209+
message: 'Update Successfully',
210+
type: 'success',
211+
duration: 2000
212+
})
213+
})
214+
},
199215
updateData() {
200216
this.$refs['dataForm'].validate((valid) => {
201217
if (valid) {

CrazyCarBackground/src/views/trial/index.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
</el-table-column>
4343
<el-table-column label="Water" min-width="150px">
4444
<template v-slot="{row}">
45-
<span>{{ row.has_water }}</span>
45+
<el-switch
46+
v-model="row.has_water"
47+
@change="handleHasWaterChange(row)"
48+
/>
4649
</template>
4750
</el-table-column>
4851
<el-table-column label="Actions" align="center" width="230" class-name="small-padding fixed-width">
@@ -196,6 +199,19 @@ export default {
196199
this.$refs['dataForm'].clearValidate()
197200
})
198201
},
202+
handleHasWaterChange(row) {
203+
const tempData = Object.assign({}, row)
204+
updtaeTimeTrialInfo(tempData).then(response => {
205+
const index = this.list.findIndex(v => v.cid === response.cid)
206+
this.list.splice(index, 1, response)
207+
this.$notify({
208+
title: 'Success',
209+
message: 'Update Successfully',
210+
type: 'success',
211+
duration: 2000
212+
})
213+
})
214+
},
199215
updateData() {
200216
this.$refs['dataForm'].validate((valid) => {
201217
if (valid) {

0 commit comments

Comments
 (0)