import React from 'react'; import Taro from '@tarojs/taro'; import { View } from '@tarojs/components'; import { Cell, CellGroup, Field, Button, Popup } from '@antmjs/vantui'; import DatePicker from '@/components/DatePicker'; import { getDateStr } from '@/utils/date'; import { postTaIssueApply } from '@/services/taissueapply'; import { warn } from '@/utils/message'; const today = new Date(); export default (props) => { const { orgIssue, applyType, ...leftProps } = props; const [show, setShow] = React.useState(false); const [submitting, setSubmitting] = React.useState(false); const [formData, setFormData] = React.useState({}); const [showDatePicker, setShowDatePicker] = React.useState(false); const setFieldValue = (key, value) => { setFormData({ ...formData, [key]: value, }) } const onDateClick = () => { setShow(false); setShowDatePicker(true); } const onDateChange = (dt) => { const date = getDateStr(dt); setFieldValue('content', date); setShowDatePicker(false); setShow(true); } const onClick = () => { if (applyType == 'org-verify' || applyType == 'end') { onSubmit(); } else { setShow(true); } } const onSubmit = () => { try { warn(!orgIssue || !orgIssue.issueId, '未找到问题单'); if (applyType === 'delay') { warn(!formData.content, '请选择延期时间'); } if (applyType == 'delay' || applyType == 'reject') { warn(!formData.remark, '请填写理由说明'); } } catch (e) { return ; } const data = { applyType, issueId: orgIssue.issueId, ...formData } setSubmitting(true); postTaIssueApply(data).then(() => { Taro.navigateBack({delta: 1}); setSubmitting(false); }).catch(() => { setSubmitting(false); }) } return ( <> setShowDatePicker(false)} onChange={onDateChange} /> setShow(false)}> { applyType == 'delay' && ( ) } setFieldValue('remark', e.detail)} /> ) }