Răsfoiți Sursa

feat: 部门及岗位管理联调

lujialiang 2 săptămâni în urmă
părinte
comite
8c097b53ae

+ 2 - 2
src/locales/langs/zh-cn.ts

@@ -441,7 +441,7 @@ const local: App.I18n.Schema = {
       sysDept: {
         parentId: '上级部门',
         deptName: '部门名称',
-        orderNum: '显示排序',
+        sort: '显示排序',
         leader: '负责人',
         phone: '联系电话',
         email: '邮箱',
@@ -449,7 +449,7 @@ const local: App.I18n.Schema = {
         form: {
           parentId: '请选择上级部门',
           deptName: '请输入部门名称',
-          orderNum: '请输入显示排序',
+          sort: '请输入显示排序',
           leader: '请输入负责人',
           phone: '请输入联系电话',
           email: '请输入邮箱',

+ 1 - 1
src/typings/api.d.ts

@@ -269,7 +269,7 @@ declare namespace Api {
       deptId: number | null;
       parentId: string | null;
       deptName: string;
-      orderNum: number;
+      sort: number;
       leader: string;
       phone: string;
       email: string;

+ 2 - 2
src/typings/app.d.ts

@@ -606,7 +606,7 @@ declare namespace App {
           sysDept: {
             parentId: string;
             deptName: string;
-            orderNum: string;
+            sort: string;
             leader: string;
             phone: string;
             email: string;
@@ -614,7 +614,7 @@ declare namespace App {
             form: {
               parentId: string;
               deptName: string;
-              orderNum: string;
+              sort: string;
               leader: string;
               phone: string;
               email: string;

+ 2 - 1
src/views/admin/sys-dept/index.vue

@@ -130,7 +130,8 @@ function handleRowEdit(row: AntDesign.TableData) {
       class="flex-col-stretch sm:flex-1-hidden card-wrapper">
       <template #extra>
         <TableHeaderOperation v-model:columns="columnChecks" :disabled-delete="checkedRowKeys.length === 0"
-          :loading="loading" @add="handleAdd" @delete="handleBatchDelete" @refresh="getData" />
+          :loading="loading" @add="handleAdd" @delete="handleBatchDelete" @refresh="getData">
+        </TableHeaderOperation>
       </template>
       <ATable ref="tableWrapperRef" :columns="columns" :data-source="data" size="small" :scroll="scrollConfig"
         :loading="loading" row-key="userId" :pagination="mobilePagination" class="h-full"

+ 33 - 21
src/views/admin/sys-dept/modules/m-operate-drawer.vue

@@ -42,7 +42,7 @@ const title = computed(() => {
 
 type Model = Pick<
   Api.Admin.SysDept,
-  'parentId' | 'deptName' | 'orderNum' | 'leader' | 'phone' | 'email' | 'status'>;
+  'parentId' | 'deptName' | 'sort' | 'leader' | 'phone' | 'email' | 'status'>;
 
 const model: Model = reactive(createDefaultModel());
 
@@ -50,7 +50,7 @@ function createDefaultModel(): Model {
   return {
     parentId: null,
     deptName: '',
-    orderNum: 10,
+    sort: 10,
     leader: '',
     phone: '',
     email: '',
@@ -58,12 +58,12 @@ function createDefaultModel(): Model {
   };
 }
 
-type RuleKey = Extract<keyof Model, 'parentId' | 'deptName' | 'orderNum' | 'leader' | 'phone' | 'email' | 'status'>;
+type RuleKey = Extract<keyof Model, 'parentId' | 'deptName' | 'sort' | 'leader' | 'phone' | 'email' | 'status'>;
 
 const rules: Record<RuleKey, App.Global.FormRule> = {
   parentId: createRequiredRule($t('page.admin.sysDept.form.parentId')),
   deptName: defaultRequiredRule,
-  orderNum: defaultRequiredRule,
+  sort: defaultRequiredRule,
   leader: defaultRequiredRule,
   phone: formRules.phone,
   email: formRules.email,
@@ -73,7 +73,7 @@ const rules: Record<RuleKey, App.Global.FormRule> = {
 const deptList = ref<CommonType.Option<string>[]>([]);
 async function getDeptList() {
   const { data } = await fetchDeptList()
-  const dept = { deptId: '0', value: '0', deptName: '主类目', label: '主类目', children: [], selectable: false }
+  const dept = { deptId: '0', value: '0', deptName: '主类目', label: '主类目', children: [] }
   dept.children = data
   deptList.value = [dept]
 }
@@ -87,7 +87,7 @@ async function getDeptDetails() {
   let deptId = props.rowData?.deptId + ''
   const { data } = await fetchDeptDetail(deptId)
   data.status = data.status + ''
-  data.orderNum = data.sort
+  //data.orderNum = data.sort
   Object.assign(model, data);
 }
 
@@ -105,24 +105,36 @@ function closeDrawer() {
 
 async function handleSubmit() {
   await validate();
+  let formData = {}
+  Object.keys(model).forEach(key => {
+    if (key === 'status' || key === 'parentId') {
+      formData[key] = model[key] - 0
+    } else {
+      formData[key] = model[key]
+    }
+  })
+
   let fnMap = {
     add: () => {
-      const { code, msg } = fetchDeptAdd(model)
-      if (code === 200) {
-        window.$message?.success(msg);
-        closeDrawer();
-        emit('submitted');
-      }
+      fetchDeptAdd(formData).then(({ code, msg }) => {
+        console.log('code', code)
+        if (code === 200) {
+          window.$message?.success(msg);
+          closeDrawer();
+          emit('submitted');
+        }
+      })
     },
     edit: () => {
       let deptId = props.rowData?.deptId + ''
-      const { code, msg } = fetchDeptEdit(model, deptId)
-      if (code === 200) {
-        window.$message?.success(msg);
-        closeDrawer();
-        emit('submitted');
-      }
-      console.log('edit')
+      fetchDeptEdit(formData, deptId).then(({ code, msg }) => {
+        if (code === 200) {
+          window.$message?.success(msg);
+          closeDrawer();
+          emit('submitted');
+        }
+      })
+
     }
   }
   fnMap[props.operateType] && fnMap[props.operateType]()
@@ -154,8 +166,8 @@ watch(visible, () => {
           </AFormItem>
         </ACol>
         <ACol :span="12" :md="12" :xs="24">
-          <AFormItem :label="$t('page.admin.sysDept.orderNum')" name="orderNum">
-            <AInputNumber v-model:value="model.orderNum" :min="0" :placeholder="$t('page.admin.sysDept.form.orderNum')"
+          <AFormItem :label="$t('page.admin.sysDept.sort')" name="sort">
+            <AInputNumber v-model:value="model.sort" :min="0" :placeholder="$t('page.admin.sysDept.form.sort')"
               allowClear />
           </AFormItem>
         </ACol>

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

@@ -92,7 +92,7 @@ const {
           <Button type="primary" ghost size="small" onClick={() => handleRowEdit(record.postId)} style="margin-right:5px">
             {$t('common.edit')}
           </Button>
-          <Popconfirm title={$t('common.confirmDelete')} onConfirm={() => handleDelete(record.deptId)}>
+          <Popconfirm title={$t('common.confirmDelete')} onConfirm={() => handleDelete(record.postId)}>
             <Button danger size="small" style="margin-right:5px">
               {$t('common.delete')}
             </Button>

+ 26 - 13
src/views/admin/sys-post/modules/m-operate-drawer.vue

@@ -94,24 +94,37 @@ function closeDrawer() {
 
 async function handleSubmit() {
   await validate();
+
+  let formData = {}
+  Object.keys(model).forEach(key => {
+    if (key === 'status') {
+      formData[key] = model[key] - 0
+    } else {
+      formData[key] = model[key]
+    }
+  })
   let fnMap = {
     add: () => {
-      const { code, msg } = fetchPostAdd(model)
-      if (code === 200) {
-        window.$message?.success(msg);
-        closeDrawer();
-        emit('submitted');
-      }
+      delete formData.postId
+      fetchPostAdd(formData).then(({ code, msg }) => {
+        if (code === 200) {
+          window.$message?.success(msg);
+          closeDrawer();
+          emit('submitted');
+        }
+      })
+
     },
     edit: () => {
       let postId = props.rowData?.postId + ''
-      const { code, msg } = fetchPostEdit(model, postId)
-      if (code === 200) {
-        window.$message?.success(msg);
-        closeDrawer();
-        emit('submitted');
-      }
-      console.log('edit')
+      fetchPostEdit(formData, postId).then(({ code, msg }) => {
+        if (code === 200) {
+          window.$message?.success(msg);
+          closeDrawer();
+          emit('submitted');
+        }
+        console.log('edit')
+      })
     }
   }
   fnMap[props.operateType] && fnMap[props.operateType]()