Bläddra i källkod

修复部分 bug

code4eat 2 år sedan
förälder
incheckning
ff18e7d053
1 ändrade filer med 40 tillägg och 35 borttagningar
  1. 40 35
      src/pages/setting/reportSet/reportSetting/index.tsx

+ 40 - 35
src/pages/setting/reportSet/reportSetting/index.tsx

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 11:30:33
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-04-07 12:14:31
+ * @LastEditTime: 2023-04-07 12:33:52
  * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -17,7 +17,7 @@ import { createFromIconfontCN } from '@ant-design/icons';
 import { ActionType, arrayMoveImmutable, useRefFunction } from '@ant-design/pro-components';
 import { ModalForm, ProFormSelect, ProFormText } from '@ant-design/pro-form';
 import { ProColumns } from '@ant-design/pro-table';
-import { Dropdown, Input, MenuProps, message, Modal,Popconfirm,Switch, Table } from 'antd';
+import { Dropdown, Input, MenuProps, message, Modal, Popconfirm, Switch, Table } from 'antd';
 import { ColumnsType, TableRowSelection } from 'antd/es/table/interface';
 import Transfer, { TransferItem, TransferProps } from 'antd/es/transfer';
 import React from 'react';
@@ -141,7 +141,7 @@ const ReportSetting = () => {
     }
 
 
-    const updateTable = async (formVal: any, type: 'EDIT' | "ADD" | 'ADD_LEFTDATA'|'EDIT_LEFTDATA') => {
+    const updateTable = async (formVal: any, type: 'EDIT' | "ADD" | 'ADD_LEFTDATA' | 'EDIT_LEFTDATA') => {
 
 
         if (type == 'ADD_LEFTDATA') {
@@ -155,7 +155,7 @@ const ReportSetting = () => {
             }
         }
 
-    
+
 
         if (type == 'EDIT_LEFTDATA') {
             const resp = await editReport({
@@ -169,12 +169,12 @@ const ReportSetting = () => {
             }
         }
 
-        if(type == 'EDIT'){
+        if (type == 'EDIT') {
             // console.log({dataSource,temp_dataSource});
             // return;
-            let newDataSource = dataSource.map((a:any,index:number)=>{
-                  //更新排序
-                  return {...a,sort:index+1}
+            let newDataSource = dataSource.map((a: any, index: number) => {
+                //更新排序
+                return { ...a, sort: index + 1 }
             })
             const resp = await editReportTbaleData(newDataSource);
             set_ifEditTable(false);
@@ -187,8 +187,7 @@ const ReportSetting = () => {
 
     }
 
-    const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' | 'ADD_LEFTDATA'|'EDIT_LEFTDATA' }) => {
-
+    const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' | 'ADD_LEFTDATA' | 'EDIT_LEFTDATA' }) => {
 
         const getTrriger = () => {
             if (type == 'ADD') {
@@ -213,7 +212,7 @@ const ReportSetting = () => {
             <ModalForm
                 title={type == 'ADD_LEFTDATA' ? `新增医疗组` : `编辑医疗组`}
                 width={352}
-                initialValues={type == 'EDIT' ? { ...record } : {}}
+                initialValues={type == 'EDIT_LEFTDATA' ? { ...record } : {}}
                 trigger={
                     getTrriger()
                 }
@@ -275,10 +274,10 @@ const ReportSetting = () => {
         },
         {
             title: '列标题',
-            width:120,
+            width: 120,
             dataIndex: 'headerText',
             key: 'headerText',
-            ellipsis:true
+            ellipsis: true
         },
     ];
 
@@ -311,17 +310,14 @@ const ReportSetting = () => {
 
         //获取报表列管理
         const getFuncList = async () => {
-            const resp = await getReportListTableData({pageSize:1000,current:1});
+            const resp = await getReportListTableData({ pageSize: 1000, current: 1 });
             if (resp) {
 
                 set_datasource(resp.list);
 
-                // if (record && record.unitInfoVos) {
+                const defaultSelctedkeys = dataSource.map((item: any) => item.columnCode);
 
-                //     const defaultSelctedkeys = record.unitInfoVos.map((item: any) => item.unitCode);
-
-                //     setTargetKeys(defaultSelctedkeys);
-                // }
+                setTargetKeys(defaultSelctedkeys);
 
             }
         }
@@ -341,13 +337,13 @@ const ReportSetting = () => {
                 const needData = datasource.filter(item => targetKeys.includes(item.code));
 
                 const result = needData.map(a => ({
-                    reportCode:currentSelectedType.code,
-                    columnCode:a.code,
-                    columnHeaderText:a.headerText,
-                    columnName:a.name,
-                    sort:dataSource.length+1,
-                    primaryKey:0,
-                    hide:0
+                    reportCode: currentSelectedType.code,
+                    columnCode: a.code,
+                    columnHeaderText: a.headerText,
+                    columnName: a.name,
+                    sort: dataSource.length + 1,
+                    primaryKey: 0,
+                    hide: 0
                 }));
 
                 // console.log({result,record});
@@ -439,12 +435,12 @@ const ReportSetting = () => {
         {
             key: '2',
             label: (
-                <a onClick={async (e)=>{
-                     e.preventDefault();
-                     const resp = await delLeftReportData(currentEditLeftData.id);
-                     if(resp){
+                <a onClick={async (e) => {
+                    e.preventDefault();
+                    const resp = await delLeftReportData(currentEditLeftData.id);
+                    if (resp) {
                         getPageLeftReports();
-                     }
+                    }
                 }}>
                     删除
                 </a>
@@ -521,14 +517,14 @@ const ReportSetting = () => {
                         <Popconfirm
                             title="是否确认移除?"
                             key="del"
-                            onConfirm={() => {delData(record.id);getTableData({ reportCode: currentSelectedType.code });}}
+                            onConfirm={() => { delData(record.id); getTableData({ reportCode: currentSelectedType.code }); }}
                         >
                             <a>删除</a>
                         </Popconfirm>
                     ]
                 },
             }])
-        }else{
+        } else {
             set_tableColumn(column);
         }
     }, [ifEditTable]);
@@ -568,7 +564,16 @@ const ReportSetting = () => {
                             return (
                                 <div className={currentSelectedType ? currentSelectedType.id == item.id ? 'type on' : 'type' : 'type'}
                                     key={index}
-                                    onClick={() => set_currentSelectedType(item)}
+                                    onClick={() => {
+                                           if(ifEditTable){
+                                               //编辑状态还未保存
+                                               Modal.confirm({
+                                                   title:'当前存在编辑未保存,请保存后再操作!'
+                                               })
+                                           }else{
+                                            set_currentSelectedType(item)
+                                           }
+                                    }}
                                 >
                                     <img className='icon' src={require('../../../../../static/reportIcon.png')} alt="" />
                                     <div className='content'>
@@ -621,7 +626,7 @@ const ReportSetting = () => {
                         {
                             ifEditTable && (
                                 <div className='inner'>
-                                    <span className='save' onClick={()=>updateTable(undefined,'EDIT')}>保存</span>
+                                    <span className='save' onClick={() => updateTable(undefined, 'EDIT')}>保存</span>
                                     <span className='add' onClick={() => addReportColumnHandle()}>添加列</span>
                                 </div>
                             )