From 37de2f4b0f732ca5c19582d4a340ad7c987925b5 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 05 十一月 2025 22:40:47 +0800
Subject: [PATCH] feat: 部门管理多个车辆
---
ruoyi-ui/src/views/system/vehicle/index.vue | 46 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/ruoyi-ui/src/views/system/vehicle/index.vue b/ruoyi-ui/src/views/system/vehicle/index.vue
index 4049d3d..e1fdf89 100644
--- a/ruoyi-ui/src/views/system/vehicle/index.vue
+++ b/ruoyi-ui/src/views/system/vehicle/index.vue
@@ -118,12 +118,19 @@
<dict-tag :options="dict.type.sys_platform" :value="scope.row.platformCode"/>
</template>
</el-table-column>
+ <el-table-column label="褰掑睘鍒嗗叕鍙�" align="center" prop="deptNames" width="200">
+ <template slot-scope="scope">
+ <span v-if="scope.row.deptNames && scope.row.deptNames.length > 0">
+ {{ scope.row.deptNames.join('銆�') }}
+ </span>
+ <span v-else>-</span>
+ </template>
+ </el-table-column>
<el-table-column label="鐘舵��" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
- <el-table-column label="褰掑睘閮ㄩ棬" align="center" prop="deptName" />
<el-table-column label="鍒涘缓鏃堕棿" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
@@ -198,8 +205,8 @@
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
- <el-form-item label="褰掑睘閮ㄩ棬" prop="deptId">
- <el-select v-model="form.deptId" placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬" clearable style="width: 100%">
+ <el-form-item label="褰掑睘鍒嗗叕鍙�" prop="deptIds">
+ <el-select v-model="form.deptIds" placeholder="璇烽�夋嫨褰掑睘鍒嗗叕鍙�" multiple clearable style="width: 100%">
<el-option
v-for="dept in deptList"
:key="dept.deptId"
@@ -271,7 +278,8 @@
status: "0",
remark: null,
platformCode: null,
- deptId: null
+ deptId: null,
+ deptIds: [] // 澶氫釜鍒嗗叕鍙窱D鏁扮粍
},
// 琛ㄥ崟鏍¢獙
rules: {
@@ -283,6 +291,9 @@
],
platformCode: [
{ required: true, message: "骞冲彴鏍囪瘑涓嶈兘涓虹┖", trigger: "change" }
+ ],
+ deptIds: [
+ { required: true, message: "褰掑睘鍒嗗叕鍙镐笉鑳戒负绌�", trigger: "change", type: 'array' }
]
}
};
@@ -301,10 +312,15 @@
this.loading = false;
});
},
- /** 鑾峰彇閮ㄩ棬鍒楄〃 */
+ /** 鑾峰彇閮ㄩ棬鍒楄〃锛堝彧鏄剧ず鍒嗗叕鍙革細parent_id=100锛� */
getDeptList() {
- listDept().then(response => {
- this.deptList = response.data;
+ listDept({ parentId: 100 }).then(response => {
+ // 杩囨护鍑哄垎鍏徃锛坧arent_id=100鐨勯儴闂級
+ if (response.data) {
+ this.deptList = response.data.filter(dept => dept.parentId === 100);
+ } else {
+ this.deptList = [];
+ }
});
},
// 鍙栨秷鎸夐挳
@@ -323,7 +339,8 @@
status: "0",
remark: null,
platformCode: null,
- deptId: null
+ deptId: null,
+ deptIds: [] // 閲嶇疆涓虹┖鏁扮粍
};
this.resetForm("form");
},
@@ -355,6 +372,14 @@
const vehicleId = row.vehicleId || this.ids
getVehicle(vehicleId).then(response => {
this.form = response.data;
+ // 濡傛灉娌℃湁deptIds锛屽垯浠� deptId 鍜� deptName 涓濉�
+ if (!this.form.deptIds || this.form.deptIds.length === 0) {
+ if (this.form.deptId) {
+ this.form.deptIds = [this.form.deptId];
+ } else {
+ this.form.deptIds = [];
+ }
+ }
this.open = true;
this.title = "淇敼杞﹁締淇℃伅";
});
@@ -363,6 +388,11 @@
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
+ // 濡傛灉閫夋嫨浜嗗涓垎鍏徃锛屽皢绗竴涓缃负deptId锛堜富鍒嗗叕鍙革級
+ if (this.form.deptIds && this.form.deptIds.length > 0) {
+ this.form.deptId = this.form.deptIds[0];
+ }
+
if (this.form.vehicleId != null) {
updateVehicle(this.form).then(response => {
this.$modal.msgSuccess("淇敼鎴愬姛");
--
Gitblit v1.9.1