|
@@ -4,7 +4,7 @@
|
|
|
* @Author: code4eat awesomedema@gmail.com
|
|
|
* @Date: 2022-12-16 09:42:52
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
- * @LastEditTime: 2023-08-02 11:01:20
|
|
|
+ * @LastEditTime: 2023-08-03 15:36:29
|
|
|
* @FilePath: /BudgetManaSystem/src/pages/budgetMana/monthlySet/index.tsx
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
*/
|
|
@@ -24,7 +24,7 @@ import closeIcon from '../../../../static/treenode_collapse.png';
|
|
|
import { BMSTable } from '@/components/BMSTable';
|
|
|
import { ActionType, ModalForm, ProColumns, ProFormDatePicker, ProFormDigit, ProFormInstance, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
|
|
import { createFromIconfontCN } from '@ant-design/icons';
|
|
|
-import { checkCurrentRequest, checkRequest, commitRequest, getCurrentCheckStatusReq, getCurrentCommitStatusReq, getCurrentUnitCheckStatusReq, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, save } from './service';
|
|
|
+import { checkCurrentRequest, checkRequest, commitRequest, downloadTemplateReq, getCurrentCheckStatusReq, getCurrentCommitStatusReq, getCurrentUnitCheckStatusReq, getData, getSecondaryDistriComputeTableData, getTreeData, getTreeDataRespType, importExcelData, save } from './service';
|
|
|
import FormItem from 'antd/es/form/FormItem';
|
|
|
|
|
|
import { getComputeDate } from '@/pages/Home/service';
|
|
@@ -62,6 +62,8 @@ export type TableListItem = {
|
|
|
name: string;
|
|
|
};
|
|
|
|
|
|
+let inputsRefKeys:string[] = [];
|
|
|
+
|
|
|
|
|
|
const UnitCheckProjectScore: React.FC = () => {
|
|
|
const location = useLocation();
|
|
@@ -95,7 +97,7 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
const [needSaveData, set_needSaveData] = useState<any | undefined>(undefined);
|
|
|
|
|
|
- const [inputsRefKeys, set_inputsRefKeys] = useState<string[]>([]);
|
|
|
+ // const [inputsRefKeys, set_inputsRefKeys] = useState<string[]>([]);
|
|
|
|
|
|
const inputsRef = useRef<{ [key: string]: any }>({});
|
|
|
|
|
@@ -113,13 +115,10 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
const column: ProColumns[] = [
|
|
|
{
|
|
|
- title: '姓名',
|
|
|
+ title: '人员',
|
|
|
width: 140,
|
|
|
fixed: 'left',
|
|
|
- dataIndex: 'name',
|
|
|
- renderText(text, record, index, action) {
|
|
|
- return `${record.name}(${record.account})`
|
|
|
- },
|
|
|
+ dataIndex: 'Employee',
|
|
|
},
|
|
|
];
|
|
|
|
|
@@ -142,8 +141,8 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
};
|
|
|
|
|
|
- const downloadTemplate = ()=>{
|
|
|
-
|
|
|
+ const downloadTemplate = () => {
|
|
|
+ downloadTemplateReq(currentComputeDate as string, currentSelectedTreeNode.code);
|
|
|
}
|
|
|
|
|
|
const importData = () => {
|
|
@@ -161,12 +160,6 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
return b.key != 'rest'
|
|
|
})
|
|
|
return [
|
|
|
- // <Button
|
|
|
- // key="ok"
|
|
|
- // onClick={auditType == '0' ? () => downloadTemplate(index) : () => { }}
|
|
|
- // >
|
|
|
- // 下载模板
|
|
|
- // </Button>,
|
|
|
...needBtn,
|
|
|
];
|
|
|
},
|
|
@@ -176,28 +169,22 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
const { importFile: { fileList } } = values;
|
|
|
|
|
|
let formData = new FormData();
|
|
|
- // if (index == 7) {
|
|
|
- // formData.append('file', fileList[0].originFileObj);
|
|
|
- // formData.append('computeDate', currentComputeDate as string);
|
|
|
- // formData.append('unitCode', currentSelectedTreeNode.code);
|
|
|
- // } else {
|
|
|
- // formData.append('file', fileList[0].originFileObj);
|
|
|
- // formData.append('computeDate', currentComputeDate as string);
|
|
|
- // formData.append('groupId', currentSelectedManaGroup?.id as any);
|
|
|
- // }
|
|
|
+ formData.append('file', fileList[0].originFileObj);
|
|
|
+ formData.append('computeDate', currentComputeDate as string);
|
|
|
+ formData.append('unitCode', currentSelectedTreeNode.code);
|
|
|
|
|
|
|
|
|
- // const resp = await importMonthlyperformanceRelaFiles(index, formData);
|
|
|
+ const resp = await importExcelData(formData);
|
|
|
|
|
|
- // if (resp) {
|
|
|
- // tableRef.current?.reload();
|
|
|
- // return true;
|
|
|
- // }
|
|
|
+ if (resp) {
|
|
|
+ tableRef.current?.reload();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
}}
|
|
|
>
|
|
|
<FormItem name={'importFile'}>
|
|
|
- <BMSUpload downloadTemplateFile={()=>auditType == '0' ? downloadTemplate() : () => { }} />
|
|
|
+ <BMSUpload downloadTemplateFile={() => auditType == '0' ? downloadTemplate() : () => { }} />
|
|
|
</FormItem>
|
|
|
|
|
|
</ModalForm>
|
|
@@ -236,7 +223,9 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
const gennerateColumns = (data: { title: any; userList: any; }, inputsRefKeys?: string[]) => {
|
|
|
const { title } = data;
|
|
|
- const _columns = title.map((item: any, index: number) => {
|
|
|
+ const _title = title.filter((a:any)=>a.code != 'Employee');
|
|
|
+ _title.sort((prev: any, next: any) => prev.sort - next.sort);
|
|
|
+ const _columns = _title.map((item: any, index: number) => {
|
|
|
return {
|
|
|
title: item.name,
|
|
|
dataIndex: `${item.code}`,
|
|
@@ -246,37 +235,37 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
let _val = _;
|
|
|
|
|
|
- if(true){
|
|
|
+ if (item.evaluation == 2) {
|
|
|
|
|
|
- return <ProFormSelect
|
|
|
- request={async ()=>{
|
|
|
- return []
|
|
|
- }}
|
|
|
+ return <ProFormSelect
|
|
|
+ noStyle
|
|
|
+ options={item.level}
|
|
|
/>
|
|
|
}
|
|
|
|
|
|
return <ProFormDigit noStyle min={-1000000000} fieldProps={{
|
|
|
ref: ref => {
|
|
|
- inputsRef.current[`${record.account}-${item.code}`] = ref;
|
|
|
+ inputsRef.current[`${record.empNo}-${item.code}`] = ref;
|
|
|
+ inputsRefKeys?.push(`${record.empNo}-${item.code}`);
|
|
|
//console.log({ref});
|
|
|
},
|
|
|
onBlur: () => {
|
|
|
- const updatedUserList = needSaveData.userList.map((a: any) => {
|
|
|
- if (a.account == record.account) {
|
|
|
- const arr = a.itemValue.map((b: any) => {
|
|
|
+ const updatedList = needSaveData.secondValueVos.map((a: any) => {
|
|
|
+ if (a.empNo == record.empNo) {
|
|
|
+ const arr = a.value.map((b: any) => {
|
|
|
if (b.code == item.code) {
|
|
|
return { ...b, value: _val ? _val : 0 } //value有为undefined的可能
|
|
|
} else {
|
|
|
return b
|
|
|
}
|
|
|
});
|
|
|
- return { ...a, itemValue: arr }
|
|
|
+ return { ...a, value: arr }
|
|
|
} else {
|
|
|
return a
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- set_needSaveData({ ...needSaveData, userList: updatedUserList })
|
|
|
+ set_needSaveData({ ...needSaveData, secondValueVos: updatedList })
|
|
|
},
|
|
|
onChange(value) {
|
|
|
_val = value ? value : 0;
|
|
@@ -286,24 +275,24 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
event.preventDefault();
|
|
|
|
|
|
const value = event.target.value ? Number(event.target.value) : 0;
|
|
|
- const updatedUserList = needSaveData.userList.map((a: any) => {
|
|
|
- if (a.account == record.account) {
|
|
|
- const arr = a.itemValue.map((b: any) => {
|
|
|
+ const updatedList = needSaveData.secondValueVos.map((a: any) => {
|
|
|
+ if (a.empNo == record.empNo) {
|
|
|
+ const arr = a.value.map((b: any) => {
|
|
|
if (b.code == item.code) {
|
|
|
return { ...b, value: value ? value : 0 } //value有为undefined的可能
|
|
|
} else {
|
|
|
return b
|
|
|
}
|
|
|
});
|
|
|
- return { ...a, itemValue: arr }
|
|
|
+ return { ...a, value: arr }
|
|
|
} else {
|
|
|
return a
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- set_needSaveData({ ...needSaveData, userList: updatedUserList });
|
|
|
+ set_needSaveData({ ...needSaveData, secondValueVos: updatedList });
|
|
|
|
|
|
- const index = inputsRefKeys ? inputsRefKeys.findIndex(a => a == `${record.account}-${item.code}`) : -1;
|
|
|
+ const index = inputsRefKeys ? inputsRefKeys.findIndex(a => a == `${record.empNo}-${item.code}`) : -1;
|
|
|
//console.log({index,input:inputsRef.current,inputsRefKeys});
|
|
|
const nextInput = inputsRefKeys ? inputsRef.current[inputsRefKeys[index + 1]] : null;
|
|
|
if (nextInput) {
|
|
@@ -312,7 +301,7 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- onFocus: () => set_currentInputRefKeys(`${record.account}-${item.code}`),
|
|
|
+ onFocus: () => set_currentInputRefKeys(`${record.empNo}-${item.code}`),
|
|
|
defaultValue: _,
|
|
|
|
|
|
}} width={80} />
|
|
@@ -322,23 +311,8 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
},
|
|
|
}
|
|
|
});
|
|
|
- set_tableColumn([...column, ..._columns, {
|
|
|
- title: '总奖金',
|
|
|
- dataIndex: 'totalScore',
|
|
|
- width: 120,
|
|
|
- fixed: 'right',
|
|
|
- },
|
|
|
- // {
|
|
|
- // title: '状态',
|
|
|
- // width:120,
|
|
|
- // dataIndex: 'submitName',
|
|
|
- // renderText(text, record, index, action) {
|
|
|
- // return record.submit == 1 ? text : <span style={{ color: '#FF8C19' }}>{text}</span>
|
|
|
- // },
|
|
|
- // },
|
|
|
- ]);
|
|
|
-
|
|
|
|
|
|
+ set_tableColumn([...column,..._columns]);
|
|
|
}
|
|
|
|
|
|
const getTableData = async (params: any) => {
|
|
@@ -361,13 +335,13 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
|
|
|
|
|
|
const buildTableData = (resp: any, inputsRefKeys?: string[]) => {
|
|
|
- const { title, userList } = resp;
|
|
|
+ const { title, secondValueVos } = resp;
|
|
|
const _columns = gennerateColumns(resp, inputsRefKeys);
|
|
|
- const data = userList.map((item: any) => {
|
|
|
+ const data = secondValueVos.map((item: any) => {
|
|
|
let total = 0;
|
|
|
let rowData: { [key: string]: any } = {};
|
|
|
|
|
|
- item.itemValue.forEach((b: any) => {
|
|
|
+ item.value.forEach((b: any) => {
|
|
|
const needTitle = title.filter((a: any) => a.code == b.code);
|
|
|
if (needTitle.length > 0) {
|
|
|
rowData[`${needTitle[0].code}`] = b.value
|
|
@@ -375,7 +349,7 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
total = total + b.value;
|
|
|
});
|
|
|
|
|
|
- return { ...item, ...rowData, id: Math.random(), _columns, totalScore: Number(total.toFixed(2)) }
|
|
|
+ return { ...item, ...rowData, id: Math.random(), _columns,Employee:item.empName}
|
|
|
});
|
|
|
|
|
|
const compeltedTotal = data.reduce((prev: any, cur: any) => prev + cur.totalScore, 0);
|
|
@@ -640,6 +614,8 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
const handleResize = (e: any) => {
|
|
|
const wH = e.target.innerHeight;
|
|
|
const tableHeight = wH - 290;
|
|
@@ -653,16 +629,23 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
}, 0)
|
|
|
}
|
|
|
|
|
|
- const computeHandle = () => {
|
|
|
- Modal.confirm({
|
|
|
- title: '注意',
|
|
|
- content: '重新计算会覆盖原有数据,确定要继续计算操作?'
|
|
|
- })
|
|
|
+ const getDataByBtn = async () => { //获取按钮获取数据
|
|
|
+ const resp = await getData(currentComputeDate as string, currentSelectedTreeNode.code);
|
|
|
+ if (resp) {
|
|
|
+ message.success('数据获取成功!');
|
|
|
+ tableRef.current?.reload();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
const saveHandle = async () => {
|
|
|
-
|
|
|
- const resp = await save(needSaveData);
|
|
|
+
|
|
|
+ const resp = await save({
|
|
|
+ computeDate:currentComputeDate,
|
|
|
+ unitCode:currentSelectedTreeNode.code,
|
|
|
+ unitName:currentSelectedTreeNode.name,
|
|
|
+ itemData:needSaveData.secondValueVos
|
|
|
+ });
|
|
|
if (resp) {
|
|
|
message.success('操作成功!');
|
|
|
set_ifEditMode(false);
|
|
@@ -756,14 +739,16 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
let keys: string[] = [];
|
|
|
|
|
|
if (ifEditMode && needSaveData) {
|
|
|
- //获取所有输入框的ref key
|
|
|
- const { userList } = needSaveData;
|
|
|
- userList.forEach((a: any) => {
|
|
|
- a.itemValue.forEach((b: any) => {
|
|
|
- keys.push(`${a.account}-${b.code}`)
|
|
|
- })
|
|
|
- });
|
|
|
- set_inputsRefKeys(keys);
|
|
|
+ // //获取所有输入框的ref key
|
|
|
+ // const { secondValueVos } = needSaveData;
|
|
|
+ // secondValueVos.forEach((a: any) => {
|
|
|
+ // a.value.forEach((b: any) => {
|
|
|
+ // keys.push(`${a.empNo}-${b.code}`)
|
|
|
+ // })
|
|
|
+ // });
|
|
|
+ // set_inputsRefKeys(keys);
|
|
|
+
|
|
|
+ console.log({inputsRefKeys});
|
|
|
|
|
|
}
|
|
|
|
|
@@ -784,11 +769,12 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
}, [ifEditMode]);
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (ifEditMode && Object.keys(inputsRef.current).length > 0 && inputsRefKeys.length > 0) {
|
|
|
+ console.log({inputsRefKeys,inputsRef})
|
|
|
+ // if (ifEditMode && Object.keys(inputsRef.current).length > 0 && inputsRefKeys.length > 0) {
|
|
|
|
|
|
- inputsRef.current[`${inputsRefKeys[0]}`].focus();
|
|
|
- set_currentInputRefKeys(inputsRefKeys[0]);
|
|
|
- }
|
|
|
+ // inputsRef.current[`${inputsRefKeys[0]}`].focus();
|
|
|
+ // set_currentInputRefKeys(inputsRefKeys[0]);
|
|
|
+ // }
|
|
|
}, [inputsRef, inputsRefKeys])
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -902,7 +888,7 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
<IconFont style={{ color: '#99A6BF' }} type="iconsousuo" />
|
|
|
}
|
|
|
onChange={(e) => {
|
|
|
-
|
|
|
+
|
|
|
}}
|
|
|
|
|
|
/>
|
|
@@ -922,8 +908,8 @@ const UnitCheckProjectScore: React.FC = () => {
|
|
|
onMouseEnter={() => auditType == '0' ? commitStatus == '1' ? set_ifShowTip(true) : set_ifShowTip(false) : set_ifShowTip(true)}
|
|
|
onMouseLeave={() => set_ifShowTip(false)}
|
|
|
>
|
|
|
- {!ifEditMode && <span className='compute cancel' onClick={commitStatus == '0' && auditType != '1' ? () => computeHandle() : () => { }}>获取</span>}
|
|
|
- {importData()}
|
|
|
+ {!ifEditMode && <span className='compute cancel' onClick={commitStatus == '0' && auditType != '1' ? () => getDataByBtn() : () => { }}>获取</span>}
|
|
|
+ {!ifEditMode && importData()}
|
|
|
{!ifEditMode && <span className='cancel' onClick={commitStatus == '0' && auditType != '1' ? () => set_ifEditMode(true) : () => { }}>编辑</span>}
|
|
|
{ifEditMode && <span className='cancel' onClick={commitStatus == '0' ? () => set_ifEditMode(false) : () => { }}>取消</span>}
|
|
|
{ifEditMode && <span className='editBtn' onClick={commitStatus == '0' && auditType != '1' ? () => saveHandle() : () => { }}>保存</span>}
|