瀏覽代碼

部门中增加部门经理 部门主管字段

hurx 2 周之前
父節點
當前提交
62a6a0e31d
共有 2 個文件被更改,包括 61 次插入1 次删除
  1. 6 0
      src/api/system/dept/types.ts
  2. 55 1
      src/views/system/dept/index.vue

+ 6 - 0
src/api/system/dept/types.ts

@@ -63,4 +63,10 @@ export interface DeptForm {
   ancestors?: string;
   platformCode?: string;
   companyId?: number | string;
+  managerId?: number | string;
+  managerName?: string;
+  managerNo?: string;
+  chargeId?: number | string;
+  chargeName?: string;
+  chargeNo?: string;
 }

+ 55 - 1
src/views/system/dept/index.vue

@@ -112,6 +112,20 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="12">
+            <el-form-item label="部门经理" prop="managerId">
+              <el-select v-model="form.managerId" placeholder="请选择部门经理" @change="handleManagerChange">
+                <el-option v-for="item in staffOptions" :key="item.staffId" :label="`${item.staffCode} , ${item.staffName}`" :value="item.staffId" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="部门主管" prop="chargeId">
+              <el-select v-model="form.chargeId" placeholder="请选择部门主管" @change="handleChargeChange">
+                <el-option v-for="item in staffOptions" :key="item.staffId" :label="`${item.staffCode} , ${item.staffName}`" :value="item.staffId" />
+              </el-select>
+            </el-form-item>
+          </el-col>
           <el-col :span="12">
             <el-form-item label="联系电话" prop="phone">
               <el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
@@ -157,7 +171,8 @@ import { DeptForm, DeptQuery, DeptVO } from '@/api/system/dept/types';
 import { UserVO } from '@/api/system/user/types';
 import { listUserByDeptId } from '@/api/system/user';
 import { getPlatformCode } from '@/utils/platform';
-
+import { listComStaff } from '@/api/company/comStaff';
+import { ComStaffVO } from '@/api/company/comStaff/types';
 interface DeptOptionsType {
   deptId: number | string;
   deptName: string;
@@ -184,6 +199,7 @@ const dialog = reactive<DialogOption>({
 const deptTableRef = ref<ElTableInstance>();
 const queryFormRef = ref<ElFormInstance>();
 const deptFormRef = ref<ElFormInstance>();
+const staffOptions = ref<ComStaffVO[]>([]);
 
 const initFormData: DeptForm = {
   deptId: undefined,
@@ -259,6 +275,43 @@ const resetQuery = () => {
   handleQuery();
 };
 
+/** 获取员工列表 */
+const getStaffList = async () => {
+  try {
+    const res = await listComStaff();
+    staffOptions.value = res.rows || [];
+  } catch (error) {
+    console.error('获取列表失败:', error);
+  }
+};
+
+/** 经理变更 */
+const handleManagerChange = (staffId: string | number) => {
+  if (staffId) {
+    const staff = staffOptions.value.find((item) => item.staffId === staffId);
+    if (staff) {
+      form.value.managerName = staff.staffName || '';
+      form.value.managerNo = staff.staffCode || '';
+    }
+  } else {
+    form.value.managerName = '';
+    form.value.managerNo = '';
+  }
+};
+/** 主管变更 */
+const handleChargeChange = (staffId: string | number) => {
+  if (staffId) {
+    const staff = staffOptions.value.find((item) => item.staffId === staffId);
+    if (staff) {
+      form.value.chargeName = staff.staffName || '';
+      form.value.chargeNo = staff.staffCode || '';
+    }
+  } else {
+    form.value.chargeName = '';
+    form.value.chargeNo = '';
+  }
+};
+
 /** 展开/折叠操作 */
 const handleToggleExpandAll = () => {
   isExpandAll.value = !isExpandAll.value;
@@ -335,5 +388,6 @@ const handleDelete = async (row: DeptVO) => {
 
 onMounted(() => {
   getList();
+  getStaffList();
 });
 </script>