zuohuaijun 4 лет назад
Родитель
Сommit
c1fed0194a

+ 3 - 27
Admin.NET/Admin.NET.Core/Service/Org/SysOrgService.cs

@@ -47,16 +47,7 @@ namespace Admin.NET.Core.Service
         [HttpGet("/sysOrg/list")]
         public async Task<List<SysOrg>> GetOrgList([FromQuery] OrgInput input)
         {
-            var orgIdList = new List<long>();
-
-            if (input.Id > 0)
-            {
-                orgIdList = await GetChildIdListWithSelfById(input.Id);
-            }
-            else
-            {
-                orgIdList = await GetUserOrgIdList();
-            }
+            var orgIdList = input.Id > 0 ? await GetChildIdListWithSelfById(input.Id) : await GetUserOrgIdList();
 
             var iSugarQueryable = _sysOrgRep.AsQueryable().OrderBy(u => u.Order)
                 .WhereIF(orgIdList.Count > 0, u => orgIdList.Contains(u.Id)); // 非超级管理员限制
@@ -96,23 +87,8 @@ namespace Admin.NET.Core.Service
                 else
                     throw Oops.Oh(ErrorCodeEnum.D2006);
             }
-
-            // 生成编码Code和排序(每级2位编码)
-            var sysOrg = await _sysOrgRep.GetFirstAsync(u => u.Pid == input.Pid);
-            var newCode = "";
-            if (sysOrg != null)
-            {
-                newCode = sysOrg.Code[0..^2] + string.Format("{0:d2}", int.Parse(sysOrg.Code[^2..]) + 1);
-            }
-            else
-            {
-                sysOrg = await _sysOrgRep.GetFirstAsync(u => u.Id == input.Pid);
-                newCode = sysOrg.Code + "01";
-            }
-            var newOrg = input.Adapt<SysOrg>();
-            newOrg.Code = newCode;
-            newOrg.Order = int.Parse(newCode[^2..]);
-            newOrg = await _sysOrgRep.AsInsertable(newOrg).ExecuteReturnEntityAsync();
+            var sysOrg = input.Adapt<SysOrg>();
+            var newOrg = await _sysOrgRep.AsInsertable(sysOrg).ExecuteReturnEntityAsync();
 
             // 非超级管理员时,将新机构加到用户数据范围内
             if (!_userManager.SuperAdmin)

+ 1 - 1
Vben2/src/views/sys/admin/config/index.vue

@@ -65,7 +65,7 @@
         showIndexColumn: false,
         canResize: false,
         actionColumn: {
-          width: 140,
+          width: 170,
           title: '操作',
           dataIndex: 'action',
           slots: { customRender: 'action' },

+ 4 - 2
Vben2/src/views/sys/admin/database/index.vue

@@ -43,11 +43,13 @@
           <TableAction
             :actions="[
               {
-                label: '编辑',
+                icon: 'clarity:note-edit-line',
+                label: '',
                 onClick: handleColumnEdit.bind(null, record),
               },
               {
-                label: '删除',
+                icon: 'ant-design:delete-outlined',
+                label: '',
                 popConfirm: {
                   confirm: handleColumnDelete.bind(null, record),
                   title: '确认删除?',

+ 1 - 1
Vben2/src/views/sys/admin/dict/index.vue

@@ -65,7 +65,7 @@
         showIndexColumn: false,
         canResize: false,
         actionColumn: {
-          width: 220,
+          width: 250,
           title: '操作',
           dataIndex: 'action',
           slots: { customRender: 'action' },

+ 1 - 1
Vben2/src/views/sys/admin/menu/index.vue

@@ -68,7 +68,7 @@
         showIndexColumn: false,
         canResize: true,
         actionColumn: {
-          width: 140,
+          width: 170,
           title: '操作',
           dataIndex: 'action',
           slots: { customRender: 'action' },

+ 2 - 2
Vben2/src/views/sys/admin/org/OrgModal.vue

@@ -30,7 +30,7 @@
         setModalProps({ confirmLoading: false });
         isUpdate.value = !!data?.isUpdate;
 
-        const treeData = await getOrgList({ id: data.parentId || 0 });
+        const treeData = await getOrgList({ id: data.record.pid || 0 });
         updateSchema({
           field: 'pid',
           componentProps: { treeData },
@@ -42,7 +42,7 @@
             ...data.record,
           });
         } else {
-          setFieldsValue({ pid: data.parentId });
+          setFieldsValue({ pid: data.searchInfo.pId }); // 以当前选择父节点新增
         }
       });
 

+ 12 - 34
Vben2/src/views/sys/admin/org/index.vue

@@ -8,19 +8,8 @@
     />
     <BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo">
       <template #toolbar>
-        <a-button
-          type="primary"
-          @click="handleCreatebrother"
-          :disabled="!hasPermission('sysOrg:add')"
-        >
-          添加同级单位
-        </a-button>
-        <a-button
-          type="primary"
-          @click="handleCreatechild()"
-          :disabled="!hasPermission('sysOrg:add')"
-        >
-          添加下级单位
+        <a-button type="primary" @click="handleCreate" :disabled="!hasPermission('sysOrg:add')">
+          新增机构
         </a-button>
       </template>
       <template #action="{ record }">
@@ -88,11 +77,10 @@
         showIndexColumn: false,
         canResize: true,
         actionColumn: {
-          width: 150,
+          width: 170,
           title: '操作',
           dataIndex: 'action',
           slots: { customRender: 'action' },
-          fixed: undefined,
         },
       });
 
@@ -109,7 +97,7 @@
       }
 
       function updateNodeByKey(key, values) {
-        getTree().updateNodeByKey(key, values); // 子组件里的方法
+        getTree().updateNodeByKey(key, values);
       }
 
       function deleteNodeByKey(key) {
@@ -118,24 +106,11 @@
 
       function handleCreate() {
         openModal(true, {
+          searchInfo,
           isUpdate: false,
         });
       }
 
-      function handleCreatechild() {
-        openModal(true, {
-          isUpdate: false,
-          parentId: searchInfo.Id,
-        });
-      }
-
-      function handleCreatebrother() {
-        openModal(true, {
-          isUpdate: false,
-          parentId: searchInfo.pId,
-        });
-      }
-
       function handleEdit(record: Recordable) {
         openModal(true, {
           record,
@@ -151,8 +126,13 @@
       }
 
       function handleSelect(orgId: number, obj) {
-        searchInfo.Id = orgId;
-        searchInfo.pId = obj.pid ? obj.pid : 0;
+        if (obj == undefined) {
+          searchInfo.Id = 0;
+          searchInfo.pId = 0;
+        } else {
+          searchInfo.Id = orgId;
+          searchInfo.pId = obj.pid ? obj.pid : 0;
+        }
         reload();
       }
 
@@ -177,8 +157,6 @@
         appendNodeByKey,
         deleteNodeByKey,
         handleCreate,
-        handleCreatebrother,
-        handleCreatechild,
         handleEdit,
         handleDelete,
         handleSuccess,

+ 0 - 2
Vben2/src/views/sys/admin/org/org.data.ts

@@ -13,8 +13,6 @@ export const columns: BasicColumn[] = [
   {
     title: '编码',
     dataIndex: 'code',
-    width: 200,
-    align: 'left',
   },
   {
     title: '状态',

+ 1 - 1
Vben2/src/views/sys/admin/pos/index.vue

@@ -66,7 +66,7 @@
         showIndexColumn: false,
         canResize: true,
         actionColumn: {
-          width: 150,
+          width: 170,
           title: '操作',
           dataIndex: 'action',
           slots: { customRender: 'action' },

+ 2 - 1
Vben2/src/views/sys/admin/user/OrgTree.vue

@@ -54,7 +54,8 @@
       }
 
       function handleSelect(keys, obj) {
-        emit('select', keys[0], obj.selectedNodes[0]);
+        if (obj == undefined) return;
+        else emit('select', keys[0], obj.selectedNodes[0]);
       }
 
       onMounted(() => {