肖凡3.31
parent
3ad3aab174
commit
de6a67308f
|
@ -1,11 +1,11 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询菜单列表
|
||||
export function list(data) {
|
||||
export function list(params) {
|
||||
return request({
|
||||
url: '/system/car/list',
|
||||
method: 'get',
|
||||
data
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,18 @@ export function del(carIds) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
export function updateStateClose(carId) {
|
||||
return request({
|
||||
url: '/system/car/updateStateClose/'+carId,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
export function updateStateOpen(carId) {
|
||||
return request({
|
||||
url: '/system/car/updateStateOpen/'+carId,
|
||||
method: 'post'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -130,6 +130,22 @@
|
|||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-success"
|
||||
v-if="scope.row.state === 1"
|
||||
@click="handleUpdateOpen(scope.row.carId)"
|
||||
v-hasPermi="['system:car:edit']"
|
||||
>启用</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-error"
|
||||
v-if="scope.row.state === 0"
|
||||
@click="handleUpdateClose(scope.row.carId)"
|
||||
v-hasPermi="['system:car:edit']"
|
||||
>禁用</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
|
@ -176,16 +192,16 @@
|
|||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="车辆状态" prop="state">
|
||||
<el-select v-model="form.state" placeholder="请选择车辆状态">
|
||||
<el-option
|
||||
v-for="dict in dict.type.car_state"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="parseInt(dict.value)"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="车辆状态" prop="state">-->
|
||||
<!-- <el-select v-model="form.state" placeholder="请选择车辆状态">-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="dict in dict.type.car_state"-->
|
||||
<!-- :key="dict.value"-->
|
||||
<!-- :label="dict.label"-->
|
||||
<!-- :value="parseInt(dict.value)"-->
|
||||
<!-- ></el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="电机厂商" prop="carElectricalmachiney">
|
||||
<el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" />
|
||||
</el-form-item>
|
||||
|
@ -211,7 +227,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {list, add, update, findById, del, exportA, selectFence} from "@/api/system/car";
|
||||
import {list, add, update, findById, del, exportA, selectFence,updateStateClose,updateStateOpen} from "@/api/system/car";
|
||||
|
||||
export default {
|
||||
name: "Car",
|
||||
|
@ -232,7 +248,7 @@ export default {
|
|||
// 总条数
|
||||
total: 0,
|
||||
//电子围栏空数组
|
||||
fenceIds:[],
|
||||
// fenceIds:[],
|
||||
//电子围栏选中的数组
|
||||
selectedFenceIds: [],
|
||||
// 车辆管理表格数据
|
||||
|
@ -245,9 +261,8 @@ export default {
|
|||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
carVin: '',
|
||||
carType: '',
|
||||
carFenceId: '',
|
||||
carVin: null,
|
||||
carType: null,
|
||||
state: null,
|
||||
carElectricalmachiney: null,
|
||||
carBattery: null,
|
||||
|
@ -256,7 +271,6 @@ export default {
|
|||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
|
@ -265,7 +279,6 @@ export default {
|
|||
},
|
||||
created() {
|
||||
this.getList();
|
||||
|
||||
this.selectFenceList()
|
||||
},
|
||||
methods: {
|
||||
|
@ -273,10 +286,8 @@ export default {
|
|||
selectFence().then(res=>{
|
||||
this.selectFence=res.data
|
||||
console.log(this.selectFence)
|
||||
this.fenceIds = this.selectFence
|
||||
console.log(this.fenceIds)
|
||||
|
||||
|
||||
// this.fenceIds = this.selectFence
|
||||
// console.log(this.fenceIds)
|
||||
})
|
||||
},
|
||||
/** 查询车辆管理列表 */
|
||||
|
@ -298,8 +309,8 @@ export default {
|
|||
this.form = {
|
||||
carId: null,
|
||||
carVin: null,
|
||||
carType: '',
|
||||
carFenceId: '',
|
||||
carType: null,
|
||||
carFenceId: null,
|
||||
state: null,
|
||||
carElectricalmachiney: null,
|
||||
carBattery: null,
|
||||
|
@ -341,23 +352,41 @@ export default {
|
|||
this.reset();
|
||||
const carId = row.carId || this.ids
|
||||
findById(carId).then(response => {
|
||||
console.log("Response Data:",response.data);
|
||||
this.form = response.data;
|
||||
this.form.carFenceId = this.form.carFenceId.split(",");
|
||||
console.log("Car Fence IDs:",this.form.carFenceId)
|
||||
this.selectedFenceIds = this.form.carFenceId.split(",");
|
||||
console.log("selectedFenceIds:"+this.selectedFenceIds)
|
||||
this.open = true;
|
||||
this.title = "修改车辆管理";
|
||||
});
|
||||
},
|
||||
/** 启用车辆 **/
|
||||
handleUpdateOpen(carId){
|
||||
updateStateOpen(carId).then(res=>{
|
||||
this.$message.success('启用成功')
|
||||
this.getList();
|
||||
})
|
||||
},
|
||||
/** 禁用车辆 **/
|
||||
handleUpdateClose(carId){
|
||||
updateStateClose(carId).then(res=>{
|
||||
this.$message.success('禁用成功')
|
||||
this.getList();
|
||||
})
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
//判断是否为数组,如果不正确转为数组
|
||||
if (!Array.isArray(this.form.carFenceId)){
|
||||
this.form.carFenceId=[this.form.carFenceId]
|
||||
}
|
||||
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); // 将每个元素转换为字符串
|
||||
|
||||
//将每个元素转换为字符串
|
||||
this.form.carFenceId = this.form.carFenceId.map(item => String(item)); //
|
||||
//拼接获取到数据的数组,切割
|
||||
this.form.carFenceId = this.selectedFenceIds.join(",");
|
||||
// this.form.carFenceId = this.form.carFenceId.join(",");
|
||||
if (this.form.carId != null) {
|
||||
update(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
|
|
Loading…
Reference in New Issue