Browse Source

部门管理

wangwei 3 years ago
parent
commit
1a0b5956d9

+ 17 - 4
src/api/sys/department.ts

@@ -1,6 +1,7 @@
 import { defHttp } from '/@/utils/http/axios';
 import {
   GetDepartmentListModel,
+  GetDepartmentTreeModel,
   DeleteBatchesParams,
   DepartmentIdParams,
   AddDepartmentParams,
@@ -10,6 +11,7 @@ import {
 
 enum Api {
   DepartmentUrl = '/department/',
+  DepartmentTreeUrl = '/department/menu',
 }
 
 /**
@@ -35,7 +37,7 @@ export function addDepartment(params: AddDepartmentParams) {
   });
 }
 /**
- * @description: 批量删除交易类型
+ * @description: 批量删除部门
  */
 export function deleteBatchesDepartment(params: DeleteBatchesParams) {
   return defHttp.request<GetDepartmentListModel>({
@@ -46,7 +48,7 @@ export function deleteBatchesDepartment(params: DeleteBatchesParams) {
 }
 
 /**
- * @description: 获取单个交易类型
+ * @description: 获取单个部门
  */
 export function getDepartment(params: DepartmentIdParams) {
   return defHttp.request<GetDepartmentModel>({
@@ -55,7 +57,7 @@ export function getDepartment(params: DepartmentIdParams) {
   });
 }
 /**
- * @description: 修改单个交易类型
+ * @description: 修改单个部门
  */
 export function editDepartment(params: EditDepartmentParams) {
   return defHttp.request<GetDepartmentListModel>({
@@ -65,7 +67,7 @@ export function editDepartment(params: EditDepartmentParams) {
   });
 }
 /**
- * @description: 删除单个交易类型
+ * @description: 删除单个部门
  */
 export function deleteDepartment(params: DepartmentIdParams) {
   return defHttp.request<GetDepartmentListModel>({
@@ -73,3 +75,14 @@ export function deleteDepartment(params: DepartmentIdParams) {
     method: 'DELETE',
   });
 }
+
+/**
+ * @description: GetDepartmentTree
+ */
+export function getDepartmentTree(params) {
+  console.log('-------------------getDepartmentTree---------------');
+  return defHttp.request<GetDepartmentTreeModel>({
+    url: Api.DepartmentTreeUrl + '/' + params.id,
+    method: 'GET',
+  });
+}

+ 7 - 0
src/api/sys/model/departmentModel.ts

@@ -5,6 +5,13 @@ export interface GetDepartmentListModel {
   count: number;
   list: object[];
 }
+/**
+ * @description: Get Department tree
+ */
+export interface GetDepartmentTreeModel {
+  count: number;
+  list: object[];
+}
 
 /**
  * @description: Get event information return value

+ 0 - 1
src/views/admin/admin/data.ts

@@ -174,7 +174,6 @@ export const schemas: FormSchema[] = [
         key: 'groups',
         value: 'id',
       },
-      getPopupContainer: () => document.body,
     },
     labelWidth: adaptWidth.adminLabelWidth,
     colProps: {

+ 1 - 1
src/views/admin/admin/index.vue

@@ -183,7 +183,7 @@
           return;
         }
         popupData.title = '添加';
-        openPopup(true, null);
+        openPopup(true, {});
       }
 
       function handleEdit(record: EditRecordRow) {

+ 3 - 2
src/views/admin/admin/popup.vue

@@ -35,6 +35,7 @@
         id: 0,
       });
       const popupData = props.popupData as PopupData;
+      console.log(`popupData`, popupData);
       const modelRef = ref({});
 
       const [registerForm, { updateSchema, setFieldsValue, resetFields, validate }] = useForm({
@@ -52,7 +53,6 @@
       //   });
       const [register, { closeModal }] = useModalInner((data) => {
         resetFields();
-        setFieldsValue(data);
         if (data) {
           role.id = data.id;
           updateSchema({
@@ -66,6 +66,7 @@
             required: true,
           });
         }
+        setFieldsValue(data);
         console.log(`popupData.treeData`, popupData.treeData);
         updateSchema({
           field: 'groups_value',
@@ -81,7 +82,7 @@
           }
           const popupData = { closeModal, data };
           emit('saveData', popupData);
-        } catch (err) {
+        } catch (err: any) {
           error(err.errorFields[0].errors[0]);
         }
       }

+ 11 - 21
src/views/department/department/customCom/CustomInput.vue

@@ -3,12 +3,7 @@
   <div class="wrap">
     <div class="content">
       <Input :placeholder="placeholder" disabled v-model:value="value" />
-      <a-button
-        class="mr-2 add-btn"
-        color="success"
-        :disabled="disabled"
-        @click="openAddPop(placeholder)"
-      >
+      <a-button class="mr-2 add-btn" color="success" @click="openAddPop(placeholder)">
         添加
       </a-button>
     </div>
@@ -46,21 +41,16 @@
       // 初始化
       function init() {
         nextTick(() => {
-          if (props.value.name) {
-            console.log(`props.value.name`, props.value.name);
-            state.value = props.value.name;
-          } else if (props.value.url) {
-            state.value = props.value.url;
-          } else {
-            state.value = props.value;
-          }
-          if (
-            state.value !== '' &&
-            (typeof props.value === 'string' || typeof props.value === 'number')
-          ) {
-            state.disabled = true;
-          } else {
-            state.disabled = false;
+          if (props.value) {
+            const nameArr: string[] = [];
+            const idArr: string[] = [];
+            props.value.map((item) => {
+              if (item.name && item.id) {
+                nameArr.push(item.name);
+                idArr.push(item.id);
+              }
+            });
+            state.value = nameArr.toString();
           }
         });
       }

+ 0 - 48
src/views/department/department/customCom/EditInput.vue

@@ -1,48 +0,0 @@
-<template>
-  <!-- <BasicTable @register="registerTable" /> -->
-  <div class="wrap">
-    <div class="content">
-      <Input :placeholder="placeholder" disabled v-model:value="value" />
-      <a-button
-        class="mr-2 add-btn"
-        color="success"
-        :disabled="disabled"
-        @click="openAddPop(placeholder)"
-      >
-        添加
-      </a-button>
-    </div>
-  </div>
-</template>
-<script lang="ts">
-  import { defineComponent } from 'vue';
-  import { Input } from 'ant-design-vue';
-  import Popup from './popup.vue';
-
-  const props = {
-    value: { type: Object, default: '' },
-    placeholder: { type: String, default: '' },
-  };
-
-  export default defineComponent({
-    name: 'CustomInput',
-    components: { Input, Popup },
-    props,
-    emits: ['change'],
-    setup(props, { emit }) {
-
-      return {
-
-      };
-    },
-  });
-</script>
-<style scoped>
-  .content {
-    display: flex;
-  }
-
-  .add-btn {
-    margin-left: 2px;
-  }
-</style>

+ 1 - 1
src/views/department/department/customCom/member/index.vue

@@ -4,7 +4,7 @@
     @register="registerTable"
     rowKey="id"
     @selectionChange="selectionChange"
-    :rowSelection="{ type: 'radio' }"
+    :rowSelection="{ type: 'check' }"
     @rowClick="rowClick"
     @rowDbClick="handleEdit"
     :canResize="true"

+ 22 - 8
src/views/department/department/data.ts

@@ -203,7 +203,7 @@ export const schemas: FormSchema[] = [
   },
   {
     field: 'pid',
-    component: 'Input',
+    component: 'MultipleTreeSelect',
     label: '上级部门',
     labelWidth: adaptWidth.labelWidth,
     colProps: {
@@ -211,6 +211,11 @@ export const schemas: FormSchema[] = [
     },
     componentProps: {
       placeholder: '上级部门',
+      replaceFields: {
+        title: 'name',
+        key: 'pid',
+        value: 'id',
+      },
     },
   },
   {
@@ -233,14 +238,23 @@ export const schemas: FormSchema[] = [
     colProps: {
       span: adaptWidth.elContainer,
     },
-    render: ({ model, field }) => {
-      return h(CustomInput, {
-        value: model.master,
+    componentProps: (value) => {
+      console.log(`value`, value);
+      return {
         placeholder: '总负责人',
-        onChange(value) {
-          model[field] = value;
-        },
-      });
+        options: [
+          {
+            label: '启用',
+            value: 'normal',
+            key: 'status',
+          },
+          {
+            label: '停用',
+            value: 'locked',
+            key: 'status',
+          },
+        ],
+      };
     },
   },
   {

+ 11 - 0
src/views/department/department/popup.vue

@@ -9,6 +9,7 @@
   import { BasicForm, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { schemas } from './data';
+  import { getDepartmentTree } from '/@/api/sys/department';
   interface PopupData {
     title: string;
   }
@@ -65,8 +66,18 @@
               },
             },
           ]);
+          getDepartmentTree({ id: data.id }).then((res) => {
+            console.log(`getDepartmentTree res`, res);
+          });
         } else {
           role.id = 0;
+          getDepartmentTree({ id: 0 }).then((res) => {
+            console.log(`getDepartmentTree res`, res);
+            updateSchema({
+              field: 'pid',
+              componentProps: { treeData: res },
+            });
+          });
           updateSchema([
             {
               field: 'year',

+ 0 - 48
src/views/event/activity/customCom/EditInput.vue

@@ -1,48 +0,0 @@
-<template>
-  <!-- <BasicTable @register="registerTable" /> -->
-  <div class="wrap">
-    <div class="content">
-      <Input :placeholder="placeholder" disabled v-model:value="value" />
-      <a-button
-        class="mr-2 add-btn"
-        color="success"
-        :disabled="disabled"
-        @click="openAddPop(placeholder)"
-      >
-        添加
-      </a-button>
-    </div>
-  </div>
-</template>
-<script lang="ts">
-  import { defineComponent } from 'vue';
-  import { Input } from 'ant-design-vue';
-  import Popup from './popup.vue';
-
-  const props = {
-    value: { type: Object, default: '' },
-    placeholder: { type: String, default: '' },
-  };
-
-  export default defineComponent({
-    name: 'CustomInput',
-    components: { Input, Popup },
-    props,
-    emits: ['change'],
-    setup(props, { emit }) {
-
-      return {
-
-      };
-    },
-  });
-</script>
-<style scoped>
-  .content {
-    display: flex;
-  }
-
-  .add-btn {
-    margin-left: 2px;
-  }
-</style>

+ 0 - 48
src/views/event/meeting/customCom/EditInput.vue

@@ -1,48 +0,0 @@
-<template>
-  <!-- <BasicTable @register="registerTable" /> -->
-  <div class="wrap">
-    <div class="content">
-      <Input :placeholder="placeholder" disabled v-model:value="value" />
-      <a-button
-        class="mr-2 add-btn"
-        color="success"
-        :disabled="disabled"
-        @click="openAddPop(placeholder)"
-      >
-        添加
-      </a-button>
-    </div>
-  </div>
-</template>
-<script lang="ts">
-  import { defineComponent } from 'vue';
-  import { Input } from 'ant-design-vue';
-  import Popup from './popup.vue';
-
-  const props = {
-    value: { type: Object, default: '' },
-    placeholder: { type: String, default: '' },
-  };
-
-  export default defineComponent({
-    name: 'CustomInput',
-    components: { Input, Popup },
-    props,
-    emits: ['change'],
-    setup(props, { emit }) {
-
-      return {
-
-      };
-    },
-  });
-</script>
-<style scoped>
-  .content {
-    display: flex;
-  }
-
-  .add-btn {
-    margin-left: 2px;
-  }
-</style>