소스 검색

部门调整change事件

zhuangdezheng 1 년 전
부모
커밋
26578c102c
1개의 변경된 파일14개의 추가작업 그리고 45개의 파일을 삭제
  1. 14 45
      src/views/business/department/index.vue

+ 14 - 45
src/views/business/department/index.vue

@@ -38,21 +38,6 @@
               </template>
             </el-table-column>
           </el-table>
-          <!-- <el-input v-model="deptName" placeholder="请输入部门名称" clearable prefix-icon="Search" style="margin-bottom: 20px" />
-          <el-tree
-            :data="deptList"
-            :props="{ label: 'label', children: 'children' }"
-            :expand-on-click-node="false"
-            :filter-node-method="filterNode"
-            ref="deptTreeRef"
-            node-key="id"
-            highlight-current
-            check-strictly
-            default-expand-all
-            show-checkbox
-            @check-change="handleDeptChange"
-            @node-click="handleGetUser"
-          /> -->
         </div>
       </div>
     </section>
@@ -63,8 +48,8 @@
       <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true">
         <el-form-item class="section-title" label="员工" />
         <el-form-item>
-          <el-button v-if="!editStatus" type="primary" icon="Plus" @click="openUser">新增</el-button>
-          <el-button v-if="!editStatus" type="danger" icon="Delete" @click="handleUserDelete"> 删除</el-button>
+          <el-button type="primary" icon="Plus" @click="openUser">新增</el-button>
+          <el-button type="danger" icon="Delete" @click="handleUserDelete"> 删除</el-button>
         </el-form-item>
       </el-form>
 
@@ -124,18 +109,15 @@
 </template>
 
 <script setup name="Process">
-import { getToken } from '@/utils/auth'
 import { getUsersByDeptId, saveDeptUser, deptTreeSelect, delDeptUser } from '@/api/system/user'
 import { delDept, getDept } from '@/api/system/dept'
-import useUserStore from '@/store/modules/user'
 import deptForm from './form'
 import person from '@/views/dialog/person.vue'
-import Sortable from 'sortablejs'
+import { ref } from 'vue'
 const { proxy } = getCurrentInstance()
 const { dept_status } = proxy.useDict('dept_status')
 /** 查询 对象 */
 const deptList = ref([])
-const editStatus = ref(false)
 const userList = ref([])
 const loading = ref(true)
 const ids = ref([])
@@ -146,7 +128,7 @@ const multiple = ref(true)
 //多选员工数据
 const deptUser = ref([])
 const deptIds = ref([])
-const sysDept = ref({})
+const currentDept = ref({})
 const total = ref(0)
 /** 查询对象 */
 const queryParams = ref({
@@ -169,6 +151,10 @@ function getList() {
   loading.value = true
   deptTreeSelect().then((response) => {
     deptList.value = response.data
+    if (deptList.value.length > 0) {
+      currentDept.value = deptList.value[0]
+      proxy.$refs.departmentTable.setCurrentRow(currentDept.value)
+    }
     loading.value = false
   })
 }
@@ -182,12 +168,6 @@ const filterNode = (value, data) => {
   return data.label.indexOf(value) !== -1
 }
 
-/** 搜索按钮操作 */
-function handleQuery() {
-  queryParams.value.pageNum = 1
-  getList()
-}
-
 //打开添加人员
 function openUser() {
   handleAddBatch()
@@ -204,14 +184,14 @@ function handleMultipleSelected(selection) {
     const newPerson = {}
 
     newPerson.userId = selection[i].userId
-    newPerson.deptId = sysDept.value.id
+    newPerson.deptId = currentDept.value.id
 
     userList.value.push(newPerson)
   }
   saveDeptUser(userList.value).then((response) => {
     if (response.code == 200) {
       proxy.$modal.msgSuccess('操作成功')
-      handleGetUser(sysDept.value)
+      handleGetUser(currentDept.value)
     }
   })
 }
@@ -235,7 +215,7 @@ function handleSelectionChange(selection) {
   for (var i = 0; i < selection.length; ++i) {
     var newDeptUser = {}
     newDeptUser.userId = selection[i].userId
-    newDeptUser.deptId = sysDept.value.id
+    newDeptUser.deptId = currentDept.value.id
     deptUser.value.push(newDeptUser)
   }
 
@@ -260,8 +240,8 @@ function handleUpdate(row) {
 /**部门名称表点击事件 */
 function handleGetUser(row) {
   if (row) {
-    sysDept.value = row
-    queryParams.value.deptId = sysDept.value.id
+    currentDept.value = row
+    queryParams.value.deptId = currentDept.value.id
     getUsersByDeptId(queryParams.value).then((response) => {
       if (response.code == 200) {
         userList.value = response.rows
@@ -274,7 +254,7 @@ function handleGetUser(row) {
 function updateUserHandle(row) {
   const id = row.id
   const userData = row
-  userData.sysDept = sysDept.value
+  userData.sysDept = currentDept.value
   proxy.$refs.updateUser.open(userData)
 }
 
@@ -306,17 +286,6 @@ function handleUserDelete(row) {
     .catch(() => {})
 }
 
-/** 导出按钮操作 */
-function handleExport() {
-  proxy.download(
-    'business/Department/export',
-    {
-      ...queryParams.value
-    },
-    `process_${new Date().getTime()}.xlsx`
-  )
-}
-
 onMounted(() => {
   getList()
 })