import React, { useState } from 'react'; import { Row, Modal, Table, Button, InputNumber, message } from 'antd'; import Column from 'antd/lib/table/Column'; import { ShopTaskList, ListItem } from '../api'; import { isNil } from 'lodash'; interface Props { setVisible: any, visible: boolean, current: ShopTaskList, index?: number, setList: (value: any) => any, list: ListItem, setCurrent: (value: any) => any, isHandledit: boolean } export default function EModal({ setVisible, visible, current = {}, index, setList, list = {}, setCurrent, isHandledit }: Props) { const [editable, setEditable] = useState(false); function _onChange(e: number, innerIndex: number) { //改变整体外层数据 const data = JSON.parse(JSON.stringify(list)); const currentData = JSON.parse(JSON.stringify(current)); if (!isNil(index)) { data.shopTaskList![index].staffTaskList![innerIndex].taskCount = e || 0; data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0)); currentData.staffTaskList![innerIndex].taskCount = e || 0; currentData.staffTaskList![innerIndex].clueDealTaskCount = Math.ceil((data.shopTaskList![index].clueDealTaskRate || 0)/100 *(e || 0)); } setList({ ...data }); //回显改变数据 setCurrent({ ...currentData }); } /** * 修改零售任务 * @param e * @param innerIndex */ function hanldeChangeClue(e: number, innerIndex: number) { //改变整体外层数据 const data = JSON.parse(JSON.stringify(list)); const currentData = JSON.parse(JSON.stringify(current)); if (!isNil(index) && data.shopTaskList![index].staffTaskList[innerIndex].taskCount < e) { message.error("线索到店零售台数不能大于零售任务!"); return; } if (!isNil(index)) { data.shopTaskList![index].staffTaskList![innerIndex].clueDealTaskCount = e || 0; currentData.staffTaskList![innerIndex].clueDealTaskCount = e || 0; } setList({ ...data }); //回显改变数据 setCurrent({ ...currentData }); } function handleClick() { setVisible(false); setEditable(false); } return ( setVisible(false)} maskClosable={false} width={600} footer={null} > { if (value.regularMonth) { return {value.staffName}(转正第{value.regularMonth}个月); } else { return {value.staffName}; } }} /> { if (editable) { return _onChange(e, index)} />; } else { return {value}; } }} /> { if (editable) { return hanldeChangeClue(e, index)} />; } else { return {value}; } }} />
{isHandledit ? ( <> ) : null}
); }