肖凡3.31

yinyuyang^2
肖凡 2024-03-31 16:59:22 +08:00
parent 3ad3aab174
commit de6a67308f
2 changed files with 70 additions and 30 deletions

View File

@ -1,11 +1,11 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询菜单列表 // 查询菜单列表
export function list(data) { export function list(params) {
return request({ return request({
url: '/system/car/list', url: '/system/car/list',
method: 'get', 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'
});
}

View File

@ -130,6 +130,22 @@
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <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 <el-button
size="mini" size="mini"
type="text" type="text"
@ -176,16 +192,16 @@
</el-checkbox> </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item label="车辆状态" prop="state"> <!-- <el-form-item label="车辆状态" prop="state">-->
<el-select v-model="form.state" placeholder="请选择车辆状态"> <!-- <el-select v-model="form.state" placeholder="请选择车辆状态">-->
<el-option <!-- <el-option-->
v-for="dict in dict.type.car_state" <!-- v-for="dict in dict.type.car_state"-->
:key="dict.value" <!-- :key="dict.value"-->
:label="dict.label" <!-- :label="dict.label"-->
:value="parseInt(dict.value)" <!-- :value="parseInt(dict.value)"-->
></el-option> <!-- ></el-option>-->
</el-select> <!-- </el-select>-->
</el-form-item> <!-- </el-form-item>-->
<el-form-item label="电机厂商" prop="carElectricalmachiney"> <el-form-item label="电机厂商" prop="carElectricalmachiney">
<el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" /> <el-input v-model="form.carElectricalmachiney" placeholder="请输入电机厂商" />
</el-form-item> </el-form-item>
@ -211,7 +227,7 @@
</template> </template>
<script> <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 { export default {
name: "Car", name: "Car",
@ -232,7 +248,7 @@ export default {
// //
total: 0, total: 0,
// //
fenceIds:[], // fenceIds:[],
// //
selectedFenceIds: [], selectedFenceIds: [],
// //
@ -245,9 +261,8 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
carVin: '', carVin: null,
carType: '', carType: null,
carFenceId: '',
state: null, state: null,
carElectricalmachiney: null, carElectricalmachiney: null,
carBattery: null, carBattery: null,
@ -256,7 +271,6 @@ export default {
}, },
// //
form: { form: {
}, },
// //
rules: { rules: {
@ -265,7 +279,6 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.selectFenceList() this.selectFenceList()
}, },
methods: { methods: {
@ -273,10 +286,8 @@ export default {
selectFence().then(res=>{ selectFence().then(res=>{
this.selectFence=res.data this.selectFence=res.data
console.log(this.selectFence) console.log(this.selectFence)
this.fenceIds = this.selectFence // this.fenceIds = this.selectFence
console.log(this.fenceIds) // console.log(this.fenceIds)
}) })
}, },
/** 查询车辆管理列表 */ /** 查询车辆管理列表 */
@ -298,8 +309,8 @@ export default {
this.form = { this.form = {
carId: null, carId: null,
carVin: null, carVin: null,
carType: '', carType: null,
carFenceId: '', carFenceId: null,
state: null, state: null,
carElectricalmachiney: null, carElectricalmachiney: null,
carBattery: null, carBattery: null,
@ -341,23 +352,41 @@ export default {
this.reset(); this.reset();
const carId = row.carId || this.ids const carId = row.carId || this.ids
findById(carId).then(response => { findById(carId).then(response => {
console.log("Response Data:",response.data);
this.form = 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.open = true;
this.title = "修改车辆管理"; 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() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
//
if (!Array.isArray(this.form.carFenceId)){ if (!Array.isArray(this.form.carFenceId)){
this.form.carFenceId=[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.selectedFenceIds.join(",");
// this.form.carFenceId = this.form.carFenceId.join(",");
if (this.form.carId != null) { if (this.form.carId != null) {
update(this.form).then(response => { update(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");