Przeglądaj źródła

修复定性选项管理界面表单bug

code4eat 2 lat temu
rodzic
commit
e8cb8e77cf

+ 22 - 0
src/components/KCIMDrawerForm/index.tsx

@@ -0,0 +1,22 @@
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2023-10-07 10:34:43
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-10-07 10:48:53
+ * @FilePath: /pfmBackMana/src/components/KCIMDrawerForm/index.tsx
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+import { DrawerForm, DrawerFormProps } from "@ant-design/pro-components";
+
+import './style.less';
+
+
+const KCIMDrawerForm: React.FC<DrawerFormProps> = (props) => {
+    // 在这里可以添加任何自定义逻辑或样式
+
+    return <DrawerForm {...props} />;
+};
+
+
+export default KCIMDrawerForm;
+

+ 20 - 0
src/components/KCIMDrawerForm/style.less

@@ -0,0 +1,20 @@
+
+
+
+.pfm-ant-drawer {
+      .pfm-ant-drawer-content-wrapper {
+           .pfm-ant-drawer-content {
+                .pfm-ant-drawer-wrapper-body {
+                       .pfm-ant-drawer-footer {
+                             .pfm-ant-space-item {
+                                  .pfm-ant-btn {
+                                       height: 24px !important;
+                                       padding: 0 11px;
+                                       border-radius: 4px !important;
+                                  }
+                             }
+                       }
+                }
+           }
+      }
+}

+ 4 - 1
src/global.less

@@ -395,6 +395,9 @@ textarea {
 
 .pfm-ant-menu-item-selected {
     background-color:#F2F6FF !important;
+    &:hover {
+         color: #3376FE !important; 
+    }
 }
 .pfm-ant-menu-light:not(.pfm-ant-menu-horizontal) .pfm-ant-menu-item:not(.pfm-ant-menu-item-selected):hover {
     background-color: #f0f2f5 !important;
@@ -446,9 +449,9 @@ textarea {
                             height: 15px;
                             line-height: 15px;
                             font-size: 14px;
+                            padding: 8px 8px !important;
                             font-family: SourceHanSansCN-Medium, SourceHanSansCN;
                             color: #17181A;
-                            padding: 12px 16px !important;
 
                             &>div {
                                 justify-content: flex-start !important;

+ 13 - 27
src/pages/setting/fenyeTemplate/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-09-27 17:52:05
+ * @LastEditTime: 2023-10-08 09:42:53
  * @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
  */
@@ -26,28 +26,14 @@ import './style.less';
 
 import KCIMPagecontainer from '@/components/KCIMPageContainer';
 import { KCIMTable } from '@/components/KCIMTable';
+import KCIMDrawerForm from '@/components/KCIMDrawerForm';
+
 
 const IconFont = createFromIconfontCN({
     scriptUrl: '',
 });
 
-const resultTypeList = [
-    {
-        label: '不适用', value: 1
-    },
-    {
-        label: '无缺失', value: 1
-    },
-    {
-        label: '无需操作', value: 1
-    },
-    {
-        label: '需使用改善工具', value: 3
-    },
-    {
-        label: '需改善回复', value: 2
-    }
-]
+
 
 export default function FenyeTemplate() {
 
@@ -58,7 +44,7 @@ export default function FenyeTemplate() {
     const columns: ProColumns[] = [
 
         {
-            title: 'Id',
+            title: 'ID',
             dataIndex: 'id',
         },
         {
@@ -233,6 +219,7 @@ export default function FenyeTemplate() {
                     <a
                         key="editable"
                         onClick={() => {
+                            console.log({record});
                             action?.startEditable?.(record.tempId);
                         }}
                     >
@@ -262,14 +249,14 @@ export default function FenyeTemplate() {
         // console.log({defaultTableData});
 
         return (
-            <DrawerForm
+            <KCIMDrawerForm
                 title={`${type == 'EDIT' ? '编辑' : '新增'}模板数据`}
                 width={800}
                 initialValues={type == 'EDIT' ? { ...record, table: defaultTableData, filedType: 'Text' } : { filedType: 'Text' }}
                 trigger={
                     type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
                 }
-                onFinish={(val) => {
+                onFinish={(val: any) => {
                     return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type);
                 }}
                 formRef={formRef}
@@ -291,21 +278,21 @@ export default function FenyeTemplate() {
                 />
 
                 <EditableProTable
+                    className='pfm-EditableProTable'
                     name='table'
+                    style={{margin:'0 4px'}}
                     rowKey={'tempId'}
                     editableFormRef={editorFormRef}
                     tableStyle={{ padding: 0 }}
                     columns={editableColumns}
-                    controlled
-                    editable={{
-                       
-                    }}
+                    // controlled
+                    editable={{}}
                     recordCreatorProps={{
                         record: () => ({ tempId: (Math.random() * 1000000).toFixed(0), filedType: 'Text' }),
                         
                     }}
                 />
-            </DrawerForm>
+            </KCIMDrawerForm>
         )
     }
 
@@ -343,7 +330,6 @@ export default function FenyeTemplate() {
                                 }
                             }}
                             onPressEnter={(e) => {
-
                                 set_tableDataFilterParams({
                                     ...tableDataFilterParams,
                                     filter: (e.target as HTMLInputElement).value

+ 57 - 33
src/pages/setting/qualitativeOptionsMana/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-09-27 17:04:16
+ * @LastEditTime: 2023-10-08 09:49:09
  * @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
  */
@@ -14,13 +14,13 @@
 
 import { createFromIconfontCN } from '@ant-design/icons';
 
-import { ActionType, ProFormSelect } from '@ant-design/pro-components';
+import { ActionType, ProFormInstance, ProFormSelect } from '@ant-design/pro-components';
 import { ModalForm, ProFormDigit, 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, getData } from './service';
+import { addData, delData, editData, getColorFromDic, getData } from './service';
 
 import './style.less';
 
@@ -48,11 +48,12 @@ export default function DicClassfication() {
     const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
     const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
     const tableRef = useRef<ActionType>();
+    const modalFormRef = useRef<ProFormInstance>();
 
     const columns: ProColumns[] = [
 
         {
-            title: 'Id',
+            title: 'ID',
             dataIndex: 'id',
         },
         {
@@ -135,21 +136,21 @@ export default function DicClassfication() {
         if (type == 'ADD') {
             const currentHosp = localStorage.getItem('currentSelectedSubHop');
             const currentUser = localStorage.getItem('userData');
-            if(currentHosp&&currentUser){
-                const {id} = JSON.parse(currentHosp);
-                const {userId} = JSON.parse(currentUser);
+            if (currentHosp && currentUser) {
+                const { id } = JSON.parse(currentHosp);
+                const { userId } = JSON.parse(currentUser);
                 const result = {
-                    hiId:id,
-                    code:formVal.code,
-                    name:formVal.name,
-                    resultType:formVal.resultType,
-                    defaultFlag:formVal.defaultFlag,
-                    sort:formVal.sort,
-                    delFlag:'',
-                    createUser:userId,
-                    createTime:new Date().getTime(),
-                    color:formVal.color
-    
+                    hiId: id,
+                    code: formVal.code,
+                    name: formVal.name,
+                    resultType: formVal.resultType,
+                    defaultFlag: formVal.defaultFlag,
+                    sort: formVal.sort,
+                    delFlag: '',
+                    createUser: userId,
+                    createTime: new Date().getTime(),
+                    color: formVal.color
+
                 }
                 const resp = await addData({ ...formVal });
                 if (resp) {
@@ -157,10 +158,10 @@ export default function DicClassfication() {
                     message.success('操作成功!');
                 }
             }
-            
+
         }
         if (type == 'EDIT') {
-            
+
             const resp = await editData({ ...formVal });
             if (resp) {
                 tableRef.current?.reload();
@@ -173,14 +174,16 @@ export default function DicClassfication() {
 
     const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => {
 
+
         return (
             <ModalForm
                 title={`${type == 'EDIT' ? '编辑' : '新增'}定性选项`}
                 width={352}
-                initialValues={type == 'EDIT' ? { ...record } : {}}
+                initialValues={type == 'EDIT' ? { ...record} : {}}
                 trigger={
                     type == 'EDIT' ? <a key="edit" >编辑</a> : <span className='add'>新增</span>
                 }
+                formRef={modalFormRef}
                 onFinish={(val) => {
                     return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type);
                 }}
@@ -206,15 +209,15 @@ export default function DicClassfication() {
 
                         return resultTypeList
                     }}
-                    rules={[{ required: true, message: '类型不能为空!' }]} 
+                    rules={[{ required: true, message: '类型不能为空!' }]}
                 />
 
                 <ProFormSelect label='是否默认:' name='defaultFlag'
                     request={async () => {
-                          return [
-                            {label:'是',value:1},
-                            {label:'否',value:0}
-                          ]
+                        return [
+                            { label: '是', value: 1 },
+                            { label: '否', value: 0 }
+                        ]
                     }}
                 />
                 <ProFormDigit
@@ -222,10 +225,32 @@ export default function DicClassfication() {
                     label="排序序号:"
                     placeholder="请输入"
                 />
-                <ProFormText
-                    name="color"
-                    label="默认颜色:"
-                    placeholder="请输入,不需要#号"
+                <ProFormSelect label='默认颜色:' name='color'
+                    request={ async () => {
+                        const currentSys = localStorage.getItem('currentSelectedTab');
+                        if(currentSys){
+                            const {systemId} = JSON.parse(currentSys);
+                            const resp = await getColorFromDic({ dictType: "COLOR_TYPE",systemId:systemId });
+
+                            if (resp && resp.length > 0) {
+                                 const list = resp[0].dataVoList.map((a:any)=>{
+                                      if(type == 'ADD'&&a.defaultValue){
+                                        modalFormRef.current?.setFieldValue('color',a.value);
+                                      }
+                                      return {
+                                        label:<span style={{background:`#${a.value}`,color:'#fff',width:20,height:15,display:'inline-block',position:'relative',top:1}}>{}</span>,
+                                        value: a.value
+                                      }
+                                 });
+                                 return list
+                                
+                            } 
+                        }
+
+                        return []
+                        
+                        
+                    }}
                 />
             </ModalForm>
         )
@@ -265,7 +290,6 @@ export default function DicClassfication() {
                                 }
                             }}
                             onPressEnter={(e) => {
-
                                 set_tableDataFilterParams({
                                     ...tableDataFilterParams,
                                     filter: (e.target as HTMLInputElement).value
@@ -286,10 +310,10 @@ export default function DicClassfication() {
                             }}
                             fieldProps={{
                                 onChange(value, option) {
-                                    set_tableDataFilterParams({ ...tableDataFilterParams, resultType: value })
+                                    set_tableDataFilterParams({ ...tableDataFilterParams, resultType: value })                                                                                                                                                                                                                    
                                 },
                             }}
-                        />
+                        />                                                                                                                                                                                                                                                                                                                                           
                     </div>
                 </div>
                 <div className='btnGroup'>

+ 9 - 1
src/pages/setting/qualitativeOptionsMana/service.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2023-03-03 16:31:27
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-09-27 11:02:05
+ * @LastEditTime: 2023-09-28 10:25:52
  * @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
  */
@@ -80,6 +80,14 @@ export const delData = (id:string) => {
     params:{id}
   });
 };
+//获取颜色字典
+export const getColorFromDic = (params:{dictType:string,systemId:number}) => {
+  return request('/centerSys/sysdictdata/getDictData', {
+    method: 'GET',
+    params:{...params}
+  });
+};
+