Prechádzať zdrojové kódy

指标配置前端变更

ZhangYanJie 4 mesiacov pred
rodič
commit
523f2f6710

+ 98 - 18
src/pages/internalEvaluation/configuration/indexconfig.tsx

@@ -1,12 +1,13 @@
 import React, { useEffect, useRef, useState } from "react";
-import type { ProColumns, ActionType, ProFormInstance } from '@ant-design/pro-components';
+import { type ProColumns, type ActionType, type ProFormInstance, EditableProTable } from '@ant-design/pro-components';
 import type {FormInstance} from 'antd'
 import { SDPage,SDFormText,SDModalForm,SDTable,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun, validateFun, SDFormDict, } from "@sundata/ui-frame";
-import type { IndexConfigModel } from '@/services/internalEvaluation/configuration/indexconfig';
+import type { IndexConfigModel, IndexSourceModel } from '@/services/internalEvaluation/configuration/indexconfig';
 import { WomanOutlined } from "@ant-design/icons";
 import { ProductProps } from "@/sundataImport";
 import { deleteRows, getDataList, selectDetailData, updateExistData, createData } from "@/services/internalEvaluation/configuration/indexconfig";
 import { countChineseChars } from "../utils/rwacheckutils";
+import { useModel } from '@umijs/max';
 
 type widowRush = {
   onCancel:  () => void;
@@ -27,6 +28,9 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
 
     // 页面数据
     var formDataList = new Array<IndexConfigModel>;
+    const { fetchDict } = useModel('dict');
+
+    const [indexSourceList, setIndexSourceList] = useState<IndexSourceModel[]>();
  
     useEffect(() => {
 
@@ -36,6 +40,7 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
     const selectData = async (formdata : IndexConfigModel) => {
       const data = await selectDetailData(formdata);
       formRef.current?.setFieldsValue(data);
+      setIndexSourceList(data.indexDataSource);
      }
 
     // 删除
@@ -55,7 +60,7 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
 
   // 插入或者更新数据
   const handleSave = async(data: IndexConfigModel,) => {
-    
+    data.indexDataSource = indexSourceList;
     if (editType == 'update' ) {
        await updateExistData(data);
        closeAndRefresh();
@@ -91,19 +96,6 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
           search: false,
           hideInTable: false,
         },
-        {
-          title: '数据来源', 
-          dataIndex: 'dataSource',
-          search: false,
-          hideInTable: false,
-        },
-        {
-          title: '数据集', 
-          dataIndex: 'dataSet',
-          search: false,
-          hideInTable: false,
-
-        },
         {
           title: '操作',
           dataIndex: 'operate',
@@ -135,6 +127,77 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
         },
 
       ];
+
+       // 数据项配置页面展示元素
+       const indexSourceColumns: ProColumns<IndexSourceModel>[] = [
+        {
+          title: '指标数据来源编号', 
+          dataIndex: 'indexSourceNo',
+          search: false,
+          hideInTable: true,
+        },
+        {
+          title: '指标编号', 
+          dataIndex: 'indexNo',
+          search:false,
+          hideInTable: true,
+        },
+        {
+          title: '其他指标编号', 
+          dataIndex: 'otherIndexNo',
+          hideInTable: false,
+          request:()=>fetchDict('@selectAllIndexToDict'),
+          fieldProps: {
+             treeDefaultExpandAll: true,
+             treeCheckable:true,
+           },
+        },
+        {
+          title: '数据集编号', 
+          dataIndex: 'dataSetNo',
+          search: false,
+          hideInTable: false,
+          request:()=>fetchDict('@selectDataSet'),
+          fieldProps: {
+             treeDefaultExpandAll: true,
+             treeCheckable:true,
+           },
+        },
+        {
+          title: '数据类型', 
+          dataIndex: 'dataSourceType',
+          search: false,
+          hideInTable: false,
+          request:()=>fetchDict('org'),
+          fieldProps: {
+             treeDefaultExpandAll: true,
+             treeCheckable:true,
+           },
+        },
+        {
+          title: '操作',
+          valueType: 'option',
+          width: 200,
+          render: (text, record, _, action) => [
+            <a
+              key="editable"
+              onClick={() => {
+                action?.startEditable?.(record.indexSourceNo);
+              }}
+            >
+              编辑
+            </a>,
+            <a
+              key="delete"
+              onClick={() => {
+                setIndexSourceList(indexSourceList?.filter((item) => item.indexSourceNo !== record.indexSourceNo));
+              }}
+            >
+              删除
+            </a>,
+          ],
+        },
+      ];
     
     return (
         <SDPage>
@@ -189,8 +252,25 @@ const indexconfig : React.FC<widowRush> = (prop:widowRush) => {
             <SDFormText name="indexNo"  readonlyCond="update" required={true} rules={[{required:true},{validator:validateFun.number,message:'请输入数字'}]}  label="指标编号"/>
             <SDFormText name="indexName" rules={[{validator:validateFun.chineseRex,message:'请输入中文'}]} label="指标名称"/>
             <SDFormText type="textarea" name="indexLogic"  label="指标逻辑"/>
-            <SDFormText  name="dataSource"  label="数据来源"/>
-            <SDFormDict  dictKey="@selectDataSet" name="dataSets" multiple={true} label="数据集"/>
+
+            <SDAreaTtile title='数据来源'/>
+            <EditableProTable<IndexSourceModel>
+             rowKey="indexSourceNo"
+             headerTitle="可编辑表格"
+             columns={indexSourceColumns}
+             value={indexSourceList}
+             dataSource={indexSourceList}
+             onChange={(value)=>{
+              setIndexSourceList([...value]);
+             }}
+             recordCreatorProps={
+              {
+                position:'bottom',
+                record: () => ({ indexSourceNo: (Math.random() * 1000000).toFixed(0),
+                 })
+              }
+             }
+            />
         </SDModalForm>
       )}
         </SDPage>

+ 14 - 3
src/services/internalEvaluation/configuration/indexconfig.ts

@@ -9,9 +9,20 @@ export type IndexConfigModel = {
     // 指标逻辑
     indexLogic?: string;
     // 数据来源
-    dataSource?: string;
-    // 数据集
-    dataSets?: string[];
+    indexDataSource?: IndexSourceModel[];
+  } & BasePageModel;
+
+  export type IndexSourceModel = {
+    // 指标数据来源编号
+    indexSourceNo : string;
+    // 指标编号
+    indexNo?: string;
+    // 其他指标编号
+    otherIndexNo?: string;
+    // 数据集编号
+    dataSetNo ?: string;
+    // 数据类型
+    dataSourceType ?: string;
   } & BasePageModel;
 
   /** 获取页面初始化查询 POST*/