wlzboy
2025-11-10 766c2b5c6940fb4373b7b8097b31d2b03aa49ac2
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: []  // 多个分公司ID数组
      },
      // 表单校验
      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 => {
        // 过滤出分公司(parent_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("修改成功");