Explorar o código

修复部分bug

code4eat %!s(int64=2) %!d(string=hai) anos
pai
achega
fecf66e9c2

+ 6 - 2
src/global.less

@@ -116,7 +116,7 @@ textarea {
                         display: flex;
                         justify-content: center;
                         align-items: center;
-                        width: 56px;
+                        min-width: 56px;
                         height: 24px;
                         border-radius: 4px;
         
@@ -136,9 +136,13 @@ textarea {
                 justify-content: center;
                 align-items: center;
                 min-width: 56px;
-                height: 24px;
+                height: 24px;;
                 border-radius: 4px;
 
+                &>span {
+                    padding: 0 8px;
+                }
+
                 &.bms-ant-btn-default {
                     border: 1px solid #DAE2F2;
                 }

+ 350 - 0
src/pages/setting/reportSet/reportNavSet/index.tsx

@@ -0,0 +1,350 @@
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2023-03-03 11:30:33
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-04-11 09:16:54
+ * @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
+ */
+
+
+
+
+import BMSPagecontainer from '@/components/BMSPageContainer';
+import { BMSTable } from '@/components/BMSTable';
+import { createFromIconfontCN } from '@ant-design/icons';
+
+import { ActionType, ProFormRadio } from '@ant-design/pro-components';
+import { ModalForm, ProFormDependency, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
+import { ProColumns } from '@ant-design/pro-table';
+import { Input, message, Popconfirm } from 'antd';
+import { useEffect, useRef, useState } from 'react';
+
+import { addData, delData, editData, getManaIndic, getReportListTableData, getReportListType } from './service';
+
+import './style.less';
+
+
+const IconFont = createFromIconfontCN({
+    scriptUrl: '//at.alicdn.com/t/c/font_1927152_4nm5kxbv4m3.js',
+});
+
+
+
+export default function ReportNavSet() {
+
+    const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
+    const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
+    const tableRef = useRef<ActionType>();
+
+    const columns: ProColumns[] = [
+
+        {
+            title: '列名称',
+            dataIndex: 'name',
+        },
+        {
+            title: '列标题',
+            dataIndex: 'headerText',
+        },
+        {
+            title: '列类型',
+            dataIndex: 'columnTypeName',
+            // render:(_:any)=>_ == 1?'指标':'自定义SQL'
+        },
+        {
+            title: '取数类型',
+            dataIndex: 'dataSource',
+            render: (_: any) => _ == 1 ? '指标' : '自定义SQL'
+        },
+        {
+            title: '取数来源',
+            width: 300,
+            ellipsis: true,
+            dataIndex: 'sql',
+            render: (_: any, record: any) => {
+
+                if (record.sql) return record.sql;
+                if (record.indicatorCodeName) return record.indicatorCodeName
+            }
+        },
+        {
+            title: '操作',
+            key: 'option',
+            width: 120,
+            valueType: 'option',
+            render: (_: any, record: any) => {
+                return [
+                    <UpDataActBtn key={'act'} record={record} type='EDIT' />,
+                    <Popconfirm
+                        title="是否确认删除?"
+                        key="del"
+                        onConfirm={() => delTableData(record)}
+                    >
+                        <a>删除</a>
+                    </Popconfirm>
+                ]
+            },
+        },
+
+    ]
+
+
+    const getTableData = async (params: any) => {
+        const resp = await getReportListTableData(params);
+        if (resp) {
+            return {
+                data: resp.list,
+                success: true,
+                total: resp.totalCount,
+                pageSize: resp.pageSize,
+                totalPage: resp.totalPage,
+            }
+        }
+        return []
+    }
+
+    const delTableData = async (record: any) => {
+        const resp = await delData(record.id);
+        if (resp) {
+            message.success('操作成功!');
+            tableRef.current?.reload();
+            // message.success('操作成功!');
+        }
+    }
+
+    const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => {
+
+        if (type == 'ADD') {
+            if (formVal.dataSource == 1) {
+                //
+                let result = {
+                    name: formVal.name,
+                    headerText: formVal.headerText,
+                    dataSource: formVal.dataSource,
+                    columnType: formVal.columnType,
+                    sql:'',
+                    indicatorCode: formVal.indicatorCode.key,
+                    indicatorCodeName: formVal.indicatorCode.label,
+                }
+
+                const resp = await addData({ ...result });
+                if (resp) {
+                    tableRef.current?.reload();
+                    message.success('操作成功!');
+                }
+
+            }
+            if(formVal.dataSource == 2){
+                //sql
+                let result = {
+                    name: formVal.name,
+                    headerText: formVal.headerText,
+                    dataSource: formVal.dataSource,
+                    columnType: formVal.columnType,
+                    sql: formVal.sql,
+                    indicatorCode:'',
+                    indicatorCodeName:''
+                }
+
+                const resp = await addData({ ...result });
+                if (resp) {
+                    tableRef.current?.reload();
+                    message.success('操作成功!');
+                }
+            }
+
+
+
+        }
+        if (type == 'EDIT') {
+
+            if (formVal.dataSource == 1){
+                //指标
+                const result = {
+                    id: formVal.id,
+                    name: formVal.name,
+                    headerText: formVal.headerText,
+                    dataSource: formVal.dataSource,
+                    columnType: formVal.columnType,
+                    sql:'',
+                    indicatorCode: formVal.indicatorCode.key,
+                    indicatorCodeName: formVal.indicatorCode.label,
+                }
+                const resp = await editData({ ...result });
+                if (resp) {
+                    tableRef.current?.reload();
+                    message.success('操作成功!');
+                }
+
+            }
+
+            if(formVal.dataSource == 2){
+                //sql
+                const result = {
+                    id: formVal.id,
+                    name: formVal.name,
+                    headerText: formVal.headerText,
+                    dataSource: formVal.dataSource,
+                    columnType: formVal.columnType,
+                    sql: formVal.sql,
+                    indicatorCode:'',
+                    indicatorCodeName:''
+                }
+                const resp = await editData({ ...result });
+                if (resp) {
+                    tableRef.current?.reload();
+                    message.success('操作成功!');
+                }
+            }
+
+            
+        }
+        return true;
+
+    }
+
+    const formRef = useRef();
+
+    const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
+
+        return (
+            <ModalForm
+                title={`${type == 'EDIT' ? '编辑' : '新增'}报表列`}
+                width={352}
+                formRef={formRef}
+                initialValues={type == 'EDIT' ? { ...record, indicatorCode: { label: record.indicatorCodeName, value: record.indicatorCode } } : {}}
+                trigger={
+                    type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
+                }
+                onFinish={(val) => {
+                    console.log({ val });
+                    return updateTable(type == 'EDIT' ? { ...record, ...val, sql: val.sql ? val.sql : '', } : { ...val }, type);
+                }}
+                colProps={{ span: 24 }}
+                grid
+            >
+
+                <ProFormText
+                    name="name"
+                    label="列名称:"
+                    placeholder="请输入"
+                    rules={[{ required: true, message: '列名称不能为空!' }]}
+                />
+                <ProFormText
+                    name="headerText"
+                    label="列标题:"
+                    placeholder="请输入"
+                    rules={[{ required: true, message: '列标题不能为空!' }]}
+                />
+                <ProFormSelect
+                    name="columnType"
+                    label="列类型:"
+                    placeholder="请选择"
+                    request={async () => {
+                        const resp = await getReportListType();
+                        if (resp) {
+                            return resp.list.map((a: any) => ({ label: a.name, value: a.code }))
+                        }
+                    }}
+                    rules={[{ required: true, message: '列类型不能为空!' }]}
+                />
+
+                <ProFormSelect
+                    name="dataSource"
+                    label="取数类型:"
+                    placeholder="请选择"
+                    options={[
+                        { label: '指标', value: 1 },
+                        { label: '自定义SQL', value: 2 }
+                    ]}
+                    rules={[{ required: true, message: '取数类型不能为空!' }]}
+                />
+                <ProFormDependency name={['dataSource']}>
+                    {
+                        ({ dataSource }) => dataSource == 1 && (
+                            <ProFormSelect
+                                name="indicatorCode"
+                                label="取数来源:"
+                                placeholder="请选择"
+                                fieldProps={{
+                                    labelInValue: true
+                                }}
+                                request={async () => {
+                                    const resp = await getManaIndic();
+                                    if (resp) {
+                                        return resp.map((a: any) => ({ label: a.name, value: a.code }))
+                                    }
+                                }}
+                                rules={[{ required: true, message: '数据来源不能为空!' }]}
+                            />
+                        )
+                    }
+                </ProFormDependency>
+                <ProFormDependency name={['dataSource']}>
+                    {
+                        ({ dataSource }) => dataSource == 2 && (
+                            <ProFormTextArea name={'sql'} label='SQL:' rules={[{ required: true, message: 'SQL不能为空!' }]} />
+                        )
+                    }
+                </ProFormDependency>
+
+            </ModalForm>
+        )
+    }
+
+    const tableDataSearchHandle = (paramName: string) => {
+
+        set_tableDataFilterParams({
+            ...tableDataFilterParams,
+            [`${paramName}`]: tableDataSearchKeywords
+        })
+
+    }
+
+
+    useEffect(() => {
+
+    }, [])
+
+    return (
+        <BMSPagecontainer className='ReportNavSet' title={false}>
+            <div className='toolBar'>
+                <div className='filter'>
+                    <div className='filterItem'>
+                        <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
+                        <Input placeholder={'请输入列标题'} allowClear
+                            suffix={
+                                <IconFont type="iconsousuo" onClick={() => tableDataSearchHandle('columnName')} />
+                            }
+                            onChange={(e) => {
+                                set_tableDataSearchKeywords(e.target.value);
+                                if (e.target.value.length == 0) {
+                                    set_tableDataFilterParams({
+                                        ...tableDataFilterParams,
+                                        columnName: ''
+                                    });
+                                }
+                            }}
+                            onPressEnter={(e) => {
+
+                                set_tableDataFilterParams({
+                                    ...tableDataFilterParams,
+                                    columnName: (e.target as HTMLInputElement).value
+                                });
+                            }}
+
+                        />
+                    </div>
+                </div>
+                <div className='btnGroup'>
+                    <UpDataActBtn record type='ADD' />
+                </div>
+            </div>
+
+            <div style={{ marginTop: 16 }}>
+                <BMSTable columns={columns as ProColumns[]} actionRef={tableRef} rowKey='id' params={tableDataFilterParams} request={(params) => getTableData(params)} />
+            </div>
+        </BMSPagecontainer>
+    )
+}

+ 119 - 0
src/pages/setting/reportSet/reportNavSet/service.ts

@@ -0,0 +1,119 @@
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2023-03-03 16:31:27
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-04-07 12:03:02
+ * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/service.ts
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+
+
+import { request } from 'umi';
+
+//获取table列表数据
+
+export type ReportListTableDataType = {
+  id:number,
+  hospId:number,
+  code:number,
+  name:string,
+  headerText:string,
+  dataSource:number,
+  columnType:string,
+  columnTypeName:string,
+  sql:string,
+  indicatorCode:string,
+  indicatorCodeName:string
+}
+
+
+export const getReportListTableData = (params?:any) => {
+  return request<{
+       current:number;
+       list:ReportListTableDataType[];
+       pageSize:number;
+       totalCount:number;
+       totalPage:number;
+  }>('/performance/report/getColumnList', {
+    method: 'GET',
+    params:{...params}
+  });
+};
+
+
+//新增报表
+export type AddTableDataType = {
+  name:string,
+  headerText:string,
+  dataSource:number,
+  columnType:string,
+  sql?:string,
+  indicatorCode?:string,
+  indicatorCodeName?:string
+}
+
+export const addData = (data:any) => {
+  return request('/performance/report/addColumn', {
+    method: 'POST',
+    data
+  });
+};
+
+
+
+//获取报表列类型
+
+export const getReportListType = () => {
+  return request('/performance/dict/getDictDataList?current=1&pageSize=10&typeCode=9', {
+    method: 'GET',
+  });
+};
+
+//获取管理指标
+
+export const getManaIndic = () => {
+  return request('/performance/report/getIndicatorList', {
+    method: 'GET',
+  });
+};
+
+
+//编辑表格数据
+
+export type ManaIndicItemTableRowEditType = {
+  id:number;
+}&AddTableDataType
+
+export const editData = (data:any) => {
+  return request('/performance/report/editColumn', {
+    method: 'POST',
+    data
+  });
+};
+
+//删除表格操作
+export const delData = (id:string) => {
+  return request('/performance/report/deleteColumn', {
+    method: 'POST',
+    params:{id}
+  });
+};
+
+
+//添加报表列
+export const addReportTableList = (data:any) => {
+  return request('/performance/report/addReportColumn', {
+    method: 'POST',
+    data
+  });
+};
+
+
+
+
+
+
+
+
+

+ 43 - 0
src/pages/setting/reportSet/reportNavSet/style.less

@@ -0,0 +1,43 @@
+.ReportNavSet {
+  padding: 16px;
+  background: #FFFFFF;
+  border-radius: 4px;
+
+
+  .toolBar {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+
+    .filter {
+      display: flex;
+      flex-direction: row;
+      justify-content: flex-start;
+      align-items: center;
+
+      .filterItem {
+        display: flex;
+        flex-direction: row;
+        justify-content: center;
+        align-items: center;
+      }
+    }
+
+    .btnGroup {
+      .add {
+        cursor: pointer;
+        display: inline-block;
+        font-size: 14px;
+        font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+        font-weight: 400;
+        color: #FFFFFF;
+        line-height: 24px;
+        padding: 0 14px;
+        background: #3377FF;
+        border-radius: 4px;
+      }
+    }
+
+  }
+}

+ 16 - 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:33:52
+ * @LastEditTime: 2023-04-11 15:07:39
  * @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
  */
@@ -142,7 +142,8 @@ const ReportSetting = () => {
 
 
     const updateTable = async (formVal: any, type: 'EDIT' | "ADD" | 'ADD_LEFTDATA' | 'EDIT_LEFTDATA') => {
-
+        
+        // console.log({formVal,type});
 
         if (type == 'ADD_LEFTDATA') {
             const resp = await addReport({
@@ -170,8 +171,7 @@ const ReportSetting = () => {
         }
 
         if (type == 'EDIT') {
-            // console.log({dataSource,temp_dataSource});
-            // return;
+   
             let newDataSource = dataSource.map((a: any, index: number) => {
                 //更新排序
                 return { ...a, sort: index + 1 }
@@ -217,7 +217,7 @@ const ReportSetting = () => {
                     getTrriger()
                 }
                 onFinish={(val) => {
-                    return updateTable(type == 'EDIT' ? { ...record, ...val } : val, type);
+                    return updateTable(type == 'EDIT_LEFTDATA' ? { ...record, ...val } : val, type);
                 }}
             >
 
@@ -303,7 +303,7 @@ const ReportSetting = () => {
 
     const TableTransfer = React.forwardRef(({ leftColumns, rightColumns, record, ...restProps }: TableTransferProps, ref) => {
 
-        const [_data, _set_data] = useState<any>();
+
         const [targetKeys, setTargetKeys] = useState<string[]>([]);
         const [datasource, set_datasource] = useState<any[]>([]);
         const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
@@ -314,7 +314,7 @@ const ReportSetting = () => {
             if (resp) {
 
                 set_datasource(resp.list);
-
+        
                 const defaultSelctedkeys = dataSource.map((item: any) => item.columnCode);
 
                 setTargetKeys(defaultSelctedkeys);
@@ -346,9 +346,8 @@ const ReportSetting = () => {
                     hide: 0
                 }));
 
-                // console.log({result,record});
-
                 const resp = await addReportTableList(result);
+                
                 if (resp) {
                     message.success('添加成功!');
                     getTableData({ reportCode: currentSelectedType.code });
@@ -568,7 +567,14 @@ const ReportSetting = () => {
                                            if(ifEditTable){
                                                //编辑状态还未保存
                                                Modal.confirm({
-                                                   title:'当前存在编辑未保存,请保存后再操作!'
+                                                   title:'当前存在编辑未保存,请保存后再操作!',
+                                                   okText:'放弃编辑',
+                                                   cancelText:'继续编辑',
+                                                   onOk(...args) {
+                                                      set_ifEditTable(false);
+                                                      set_currentSelectedType(item);
+                                                      getTableData({ reportCode: item.code });
+                                                   },
                                                })
                                            }else{
                                             set_currentSelectedType(item)
@@ -595,31 +601,6 @@ const ReportSetting = () => {
             <div className='right'>
                 <div className='toolBar'>
                     <div className='filter'>
-                        {/* <div className='filterItem'>
-                            <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
-                            <Input placeholder={'请输入列标题'} allowClear
-                                suffix={
-                                    <IconFont type="iconsousuo" onClick={() => tableDataSearchHandle('name')} />
-                                }
-                                onChange={(e) => {
-                                    set_tableDataSearchKeywords(e.target.value);
-                                    if (e.target.value.length == 0) {
-                                        set_tableDataFilterParams({
-                                            ...tableDataFilterParams,
-                                            name: ''
-                                        });
-                                    }
-                                }}
-                                onPressEnter={(e) => {
-
-                                    set_tableDataFilterParams({
-                                        ...tableDataFilterParams,
-                                        name: (e.target as HTMLInputElement).value
-                                    });
-                                }}
-
-                            />
-                        </div> */}
                     </div>
                     <div className='btnGroup'>
                         {!ifEditTable && <span className='manaBtn' onClick={() => set_ifEditTable(true)}>管理列</span>}