import React, { useEffect, useState } from 'react'; import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { Card, Table, Button, Row, DatePicker, Col, InputNumber, message } from 'antd'; import { getTackMaunuaList, ListItem, autoAlloctionApi, ShopTaskList, save, saveParams } from './api'; import EModal from './component/Modal'; import moment from 'moment'; import ApproveModal from '@/pages/order3/Common/ApproveModal'; const { Column } = Table; const day = new Date(); const month = day.getMonth() + 1; const year = day.getFullYear(); const strtime = year + '-' + month; let newDate = new Date(strtime); const newDay = newDate.getTime(); export default function TacklingCarModels() { const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(false); const [current, setCurrent] = useState({}); const [confirmLoading, setConfirmLoading] = useState(false); const [saveLoading, setSaveLoading] = useState(false); const [date, setDate] = useState(1612346107410); const [edit, setEdit] = useState(false); const [list, setList] = useState({}); const [orginDara, setOrginDara] = useState({}); const [approveOpen, setApproveOpen] = useState(false); let index; useEffect(() => { getList(newDay); }, []); function setReset() { setList({ ...orginDara }); setEdit(false); } //查询列表 function getList(date: number) { const params = { taskDate: date.valueOf(), autoAssign: true, }; getTackMaunuaList(params).then(res => { setLoading(false); const data = res.data; setOrginDara(data || {}); setList(data || {}); message.success('请求成功!'); }).catch(e => { setLoading(false); message.warning(e.message); }); } function _ChangeMoth(date: any) { setLoading(true); setDate(date.valueOf()); getList(date); } function _onChange(e: number, index: number) { const data = list; data.shopTaskList![index].taskCount = e; setList({ ...data }); } //保存 function handleClick() { setLoading(true); const params = { id: list.id, shopTaskList: list.shopTaskList }; autoAllocationSave(params); } //提交审批 function saveClick(params?: any) { setLoading(true); setSaveLoading(true); save({...params, id: list.id}).then(() => { setSaveLoading(false); setLoading(false); setList({ ...list, canModified: false }); message.success('提交成功!'); }).catch(e => { setLoading(false); message.warning(e.message); setSaveLoading(false); }); } //自动提交 function autoAllocationSave(params: saveParams) { setConfirmLoading(true); setEdit(true); autoAlloctionApi(params).then(() => { setConfirmLoading(false); getList(date); setEdit(false); }).catch(e => { message.warning(`${e.message}`); setConfirmLoading(false); setLoading(false); }); } function handleOpenApprove() { setApproveOpen(true); } return ( { let total = 0; pageData.forEach(({ taskCount }) => { total += taskCount || 0; }); return ( <> {total == 0 ? null : ( 合计 {total} )} ); }} > { if (edit) { return _onChange(e, index)} />; } else { return {value}; } }} /> ( <> )} />
{list.canModified ? ( <> {edit ? : } {edit ? null : } {edit ? : null} ) : null}
); }