Ver Fonte

pms 调拨同时调整责任人

zhangcl há 2 meses atrás
pai
commit
a13b1ef633

+ 2 - 1
src/locales/en.ts

@@ -635,7 +635,8 @@ export default {
     rpHolder:'Please select the Department',
     reasonForAdjustment:'ReasonForAdjustment',
     rfaHolder:'Please enter reason',
-    adjustmentRecords:'AdjustmentRecords'
+    adjustmentRecords:'AdjustmentRecords',
+    selectPersons: 'Please select Person'
   },
   deviceStatus:{
     deviceName:'DeviceName',

+ 2 - 1
src/locales/zh-CN.ts

@@ -629,7 +629,8 @@ export default {
     rpHolder:'请选择所属部门',
     reasonForAdjustment:'调整原因',
     rfaHolder:'请输入调整原因',
-    adjustmentRecords:'调整记录'
+    adjustmentRecords:'调整记录',
+    selectPersons: '请选择人员'
   },
   deviceStatus:{
     deviceName:'设备名称',

+ 79 - 12
src/views/pms/device/allotlog/ConfigDeviceAllot.vue

@@ -37,7 +37,7 @@
                 class="checkbox-item"
               >
                 <el-checkbox :label="device.id">
-                  {{ device.deviceCode }} ({{ device.deviceName }}) - {{ device.deptName }}
+                  {{ device.deviceCode }} ({{ device.deviceName }}) - {{ device.deptName }} —— {{ device.devicePersons }}
                 </el-checkbox>
               </div>
             </el-checkbox-group>
@@ -58,24 +58,45 @@
 
     <!-- 暂存关联列表 -->
     <div class="submit-area">
-      <div class="card">
-        <el-input
-          v-model="formData.reason"
-          :placeholder="t('configDevice.rfaHolder')"
-          class="reason-input"
-          type="textarea"
-          :rows="3"
-          @input="updateTempRelations"
-        />
+      <div class="card selection-area">
+        <!-- 左侧人员选择 -->
+        <div class="person-selector">
+          <el-select
+            v-model="selectedPersons"
+            multiple
+            filterable
+            :placeholder="t('configPerson.selectPersons')"
+            style="width: 100%"
+          >
+            <el-option
+              v-for="person in simpleUsers"
+              :key="person.id"
+              :label="person.nickname"
+              :value="person.id"
+            />
+          </el-select>
+        </div>
+
+        <div class="reason-input-wrapper">
+          <el-input
+            v-model="formData.reason"
+            :placeholder="t('configDevice.rfaHolder')"
+            class="reason-input"
+            type="textarea"
+            :rows="3"
+            @input="updateTempRelations"
+          />
+        </div>
       </div>
       <el-button
         type="primary"
         size="large"
         @click="submitRelations"
-        :disabled="tempRelations.length === 0 || !formData.reason.trim()"
+        :disabled="tempRelations.length === 0 || !formData.reason.trim() || selectedPersons.length === 0"
       >
         {{ t('iotMaintain.save') }}
       </el-button>
+
       <div class="temp-list card" v-if="false">
         <h3>{{ t('configPerson.adjustmentRecords') }}</h3>
         <el-table :data="tempRelations" style="width: 100%">
@@ -105,10 +126,12 @@ import { ref, computed } from 'vue'
 import { ElMessage } from 'element-plus'
 import {defaultProps, handleTree} from "@/utils/tree";
 import * as DeptApi from "@/api/system/dept";
+import * as UserApi from "@/api/system/user";
 import {IotDeviceApi, IotDeviceVO} from "@/api/pms/device";
 import DeptTree2 from "@/views/pms/device/DeptTree2.vue";
 import { useRouter } from 'vue-router'
 import { useTagsViewStore } from "@/store/modules/tagsView";
+import {UserVO} from "@/api/system/user";
 
 const router = useRouter()
 const { t } = useI18n() // 国际化
@@ -140,6 +163,9 @@ const deptTreeRef = ref<InstanceType<typeof DeptTree2>>()
 
 const emit = defineEmits(['success', 'node-click']) // 定义 success 树点击 事件,用于操作成功后的回调
 
+const simpleUsers = ref<UserVO[]>([])     // 人员下拉列表选项
+const selectedPersons = ref<number[]>([]) // 存储选中的人员ID
+
 // 响应式数据
 const tempRelationsMap = ref(new Map<number, {
   deviceId: number
@@ -195,6 +221,16 @@ watch([selectedDevices, selectedDeptId], () => {
   updateTempRelations();
 }, {deep: true, immediate: true, debounce: 100})
 
+// 监听部门变化
+watch(selectedDeptId, (newVal) => {
+  if (newVal) {
+    loadDeptPersons(newVal as number)
+  } else {
+    simpleUsers.value = []
+  }
+  selectedPersons.value = [] // 切换部门时清空已选人员
+})
+
 // 修改部门变更处理方法
 const handleDeptChange = (deptId) => {
   if (!deptId) {
@@ -233,6 +269,26 @@ const getDeviceList = async () => {
   }
 }
 
+// 选择部门后 加载部门人员
+const loadDeptPersons = async (deptId: number) => {
+  if (!deptId) {
+    simpleUsers.value = []
+    return
+  }
+  try {
+    // 调用API获取部门人员
+    const params = { deptId: deptId, pageNo: 1, pageSize: 10 }
+    const data = await UserApi.simpleUserList(params)
+    simpleUsers.value = data.map(user => ({
+      id: user.id,
+      nickname: user.nickname || user.username
+    }))
+  } catch (error) {
+    console.error('获取部门人员失败:', error)
+    simpleUsers.value = []
+  }
+}
+
 // 计算选中的设备原部门集合
 const originDeptIds = computed(() =>
   selectedDevices.value
@@ -286,7 +342,8 @@ const submitRelations = async () => {
     const submitData = tempRelations.value.map(r => ({
       deviceId: r.deviceId,
       deptId: r.deptId,
-      reason: r.reason
+      reason: r.reason,
+      personIds: selectedPersons.value // 添加人员ID列表
     }))
     await IotDeviceApi.saveDeviceAllot(submitData)
     // 模拟API调用
@@ -428,4 +485,14 @@ h3 {
   text-align: center;
   color: #999;
 }
+
+.selection-area {
+  display: flex;
+  gap: 20px; /* 两个元素之间的间距 */
+}
+
+.reason-input-wrapper {
+  flex: 1; /* 占据一半宽度 */
+  min-width: 0; /* 防止溢出 */
+}
 </style>