Browse Source

重新dept模块

admin 2 years ago
parent
commit
1846ba150e
2 changed files with 13 additions and 21 deletions
  1. 4 9
      src/views/system/dept/form.vue
  2. 9 12
      src/views/system/dept/index.vue

+ 4 - 9
src/views/system/dept/form.vue

@@ -33,7 +33,7 @@
               style="width: 100%"
             >
               <el-option
-                v-for="item in props.userOption"
+                v-for="item in userList"
                 :key="item.id"
                 :label="item.nickname"
                 :value="item.id"
@@ -88,6 +88,7 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
 const formType = ref('') // 表单的类型:create - 新增;update - 修改
 const formRef = ref() // 表单 Ref
 const deptOptions = ref() // 树形结构
+const userList = ref() // 负责人列表选项结构
 
 const formData = ref({
   id: undefined,
@@ -100,12 +101,6 @@ const formData = ref({
   email: undefined,
   status: undefined
 })
-const props = defineProps({
-  userOption: {
-    type: Array,
-    default: () => [] as UserVO[]
-  }
-})
 
 const formRules = reactive({
   parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
@@ -118,12 +113,12 @@ const formRules = reactive({
 })
 
 /** 打开弹窗 */
-const openModal = async (type: string, id?: number) => {
+const openModal = async (type: string, id?: number, userOption?: UserVO[]) => {
+  userList.value = userOption
   modelVisible.value = true
   modelTitle.value = t('action.' + type)
   formType.value = type
   resetForm()
-  console.log(id)
   // 修改时,设置数据
   if (id) {
     formLoading.value = true

+ 9 - 12
src/views/system/dept/index.vue

@@ -85,7 +85,7 @@
   </ContentWrap>
 
   <!-- 添加或修改部门对话框 -->
-  <dept-form ref="modalRef" @success="getList" :userOption="userOption" />
+  <dept-form ref="modalRef" @success="getList" />
 </template>
 <script setup lang="ts" name="Dept">
 import { handleTree } from '@/utils/tree'
@@ -105,17 +105,14 @@ const queryParams = reactive({
   pageSize: 100
 })
 
-// 搜索的表单
-const queryFormRef = ref()
-// 数据变量
-const deptDatas = ref()
+const queryFormRef = ref() // 搜索的表单
+const deptDatas = ref() // 数据变量
 const userOption = ref<UserVO[]>([])
-// 是否展开,默认全部展开
-const isExpandAll = ref(true)
-// 重新渲染表格状态
-const refreshTable = ref(true)
-// 列表的加载中
-const loading = ref(true)
+
+const isExpandAll = ref(true) // 是否展开,默认全部展开
+const refreshTable = ref(true) // 重新渲染表格状态
+const loading = ref(true) // 列表的加载中
+
 //获取用户列表
 const getUserList = async () => {
   const res = await getListSimpleUsersApi()
@@ -172,7 +169,7 @@ const resetQuery = () => {
 /** 添加/修改操作 */
 const modalRef = ref()
 const openModal = (type: string, id?: number) => {
-  modalRef.value.openModal(type, id)
+  modalRef.value.openModal(type, id, userOption.value)
 }
 
 const userNicknameFormat = (row) => {