You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
8.8 KiB
124 lines
8.8 KiB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
return new (P || (P = Promise))(function (resolve, reject) { |
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
}); |
|
}; |
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; |
|
import { ProCard, ProForm, ProFormDateTimePicker, ProFormItem, ProFormText, ProFormTextArea, ProFormUploadButton, FooterToolbar, } from '@ant-design/pro-components'; |
|
import { FormUpload, ReactRouterPrompt } from '@component/ui'; |
|
import { Button, Col, message, Row, Space } from 'antd'; |
|
import { PlusOutlined } from '@ant-design/icons'; |
|
import { useServiceContext } from '../../context'; |
|
import { getToken, getUploadList, getUploadValueFromEvent, jsonString, phoneReg, themeMessage, } from '@component/utils'; |
|
import { useRequest } from 'ahooks'; |
|
import { useRef } from 'react'; |
|
import { useRoutes } from '@component/utils'; |
|
import { GridForm, CardForm } from '@component/ui'; |
|
import { ProjectTime } from '../component'; |
|
import { useState } from 'react'; |
|
import EditServiceReport from '../edit.service.report'; |
|
import { updateServiceReport } from '../../action'; |
|
export default function ({ service, submitManagementStatus, serviceData }) { |
|
const { historyBack } = useRoutes(); |
|
const formRef = useRef(); |
|
const [isLeave, setLeave] = useState(true); |
|
const [visitble, setVisitble] = useState(false); |
|
const { reportCollection, serviceId, resultData, status, service_type } = useServiceContext(); |
|
const { runAsync } = useRequest(service, { |
|
manual: true, |
|
onSuccess(result) { |
|
themeMessage(result, historyBack); |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
const { runAsync: runReport } = useRequest(updateServiceReport, { |
|
manual: true, |
|
onSuccess() { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setVisitble(false); |
|
onSubmit(); |
|
}); |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
function onFinish() { |
|
var _a, _b; |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setLeave(false); |
|
const managementStatus = yield submitManagementStatus(false); |
|
console.log(managementStatus, 'managementStatus'); |
|
if (managementStatus.type === 'error') { |
|
return message.error(managementStatus.message); |
|
} |
|
const values = yield ((_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFieldsFormatValue) === null || _b === void 0 ? void 0 : _b.call(_a)); |
|
return runAsync(Object.assign(Object.assign({}, values), { serviceStartAt: values.serviceStartAt |
|
? values.serviceStartAt + ':00' |
|
: undefined, serviceCompleteAt: values.serviceCompleteAt |
|
? values.serviceCompleteAt + ':00' |
|
: undefined, serviceProcessProveAtts: JSON.stringify(getUploadList(values.serviceProcessProveAtts)), serviceResultsAtts: JSON.stringify(getUploadList(values.serviceResultsAtts)), serviceId })); |
|
}); |
|
} |
|
function onSubmit() { |
|
var _a, _b; |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setLeave(false); |
|
const values = yield ((_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.validateFieldsReturnFormatValue) === null || _b === void 0 ? void 0 : _b.call(_a)); |
|
return runAsync(Object.assign(Object.assign({}, values), { reportCollection, |
|
status, submitAction: true, serviceStartAt: values.serviceStartAt |
|
? values.serviceStartAt + ':00' |
|
: undefined, serviceCompleteAt: values.serviceCompleteAt |
|
? values.serviceCompleteAt + ':00' |
|
: undefined, serviceProcessProveAtts: JSON.stringify(getUploadList(values.serviceProcessProveAtts)), serviceResultsAtts: JSON.stringify(getUploadList(values.serviceResultsAtts)) })); |
|
}); |
|
} |
|
// 先编辑 成功后再提交表单 |
|
function onReport(values) { |
|
values.serviceId = serviceData === null || serviceData === void 0 ? void 0 : serviceData.serviceId; |
|
return runReport(values); |
|
} |
|
function request() { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
return Object.assign(Object.assign({}, resultData), { serviceProcessProveAtts: yield jsonString(resultData.serviceProcessProveAtts), serviceResultsAtts: yield jsonString(resultData.serviceResultsAtts) }); |
|
}); |
|
} |
|
return (_jsxs(_Fragment, { children: [_jsx(EditServiceReport, { onFinish: onReport, open: visitble, serviceType: service_type, setVisitble: setVisitble, data: serviceData }), _jsxs(GridForm, Object.assign({ request: request, formRef: formRef, onFinish: () => __awaiter(this, void 0, void 0, function* () { |
|
const managementStatus = yield submitManagementStatus(true); |
|
if (managementStatus.type === 'error') { |
|
return message.error(managementStatus.message); |
|
} |
|
setVisitble(true); |
|
}), submitter: { |
|
searchConfig: { |
|
submitText: '提交报告', |
|
}, |
|
}, renderAction: () => { |
|
return (_jsx(Button, Object.assign({ type: "primary", onClick: onFinish }, { children: "\u4FDD\u5B58" }))); |
|
} }, { children: [_jsx(ReactRouterPrompt, { when: isLeave }), _jsxs(CardForm, Object.assign({ title: "\u4E8B\u6545\u9884\u9632\u4FE1\u606F" }, { children: [_jsx(ProFormItem, { name: "serviceId", hidden: true }), _jsx(ProjectTime, { reportCollection: reportCollection, status: status }), _jsx(ProFormText, { name: "companySafetyName", label: "\u6574\u6539\u8D1F\u8D23\u4EBA\u59D3\u540D", placeholder: "\u8BF7\u8F93\u5165\u6574\u6539\u8D1F\u8D23\u4EBA\u59D3\u540D", rules: [{ required: true }] }), _jsx(ProFormText, { name: "companySafetyPhone", label: "\u6574\u6539\u8D1F\u8D23\u4EBA\u8054\u7CFB\u7535\u8BDD", placeholder: "\u8BF7\u8F93\u5165\u6574\u6539\u8D1F\u8D23\u4EBA\u8054\u7CFB\u7535\u8BDD", rules: [ |
|
{ required: true }, |
|
{ pattern: phoneReg, message: '请填写正确的手机号' }, |
|
] }), _jsx(ProFormTextArea, { rules: [{ required: true }], label: "\u4F01\u4E1A/\u9879\u76EE\u98CE\u9669\u7BA1\u63A7\u5EFA\u8BAE", name: "riskSuggest", placeholder: "\u8BF7\u8F93\u5165\u4F01\u4E1A/\u9879\u76EE\u98CE\u9669\u7BA1\u63A7\u5EFA\u8BAE", fieldProps: { |
|
maxLength: 1000, |
|
showCount: true, |
|
} }), _jsx(ProFormTextArea, { label: "\u5907\u6CE8", name: "remark", placeholder: "\u8BF7\u8F93\u5165\u5907\u6CE8", fieldProps: { |
|
maxLength: 1000, |
|
showCount: true, |
|
} })] })), _jsxs(CardForm, Object.assign({ title: "\u76F8\u5173\u9644\u4EF6" }, { children: [_jsx(FormUpload, { label: "\u670D\u52A1\u8FC7\u7A0B\u8BC1\u660E\u6587\u4EF6", rules: [{ required: true }], name: "serviceProcessProveAtts", max: 20, fieldProps: { |
|
accept: 'image/*', |
|
}, extra: "\u6700\u591A\u4E0A\u4F2020\u5F20\u56FE\u7247", params: { |
|
bizNo: resultData === null || resultData === void 0 ? void 0 : resultData.serviceId, |
|
type: '14', |
|
} }), _jsx(FormUpload, { rules: [{ required: true }], label: "\u670D\u52A1\u6210\u679C\u6587\u4EF6", name: "serviceResultsAtts", max: 20, fieldProps: { |
|
accept: 'image/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel', |
|
}, params: { |
|
bizNo: resultData === null || resultData === void 0 ? void 0 : resultData.serviceId, |
|
type: '18', |
|
}, extra: "\u6700\u591A\u4E0A\u4F2020\u4E2A\u9644\u4EF6,\uFF08\u652F\u6301\u683C\u5F0F\uFF1Ajpg\uFF0Cpng\uFF0Cjpeg\uFF0Cpdf\uFF0Cword\uFF0CExcel\uFF09" })] }))] }))] })); |
|
}
|
|
|