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.
111 lines
7.7 KiB
111 lines
7.7 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 { ProFormTextArea, ProFormItem } from '@ant-design/pro-components'; |
|
import { FormUpload, ReactRouterPrompt } from '@component/ui'; |
|
import { Button, message } from 'antd'; |
|
import { useServiceContext } from '../../context'; |
|
import { jsonString, useRoutes, themeMessage } from '@component/utils'; |
|
import { useRequest } from 'ahooks'; |
|
import { getUploadList } from '@component/utils'; |
|
import { GridForm, CardForm } from '@component/ui'; |
|
import { useRef } from 'react'; |
|
import { ProjectTime } from '../component'; |
|
import { useState } from 'react'; |
|
import EditServiceReport from '../edit.service.report'; |
|
import { updateServiceReport } from '../../action'; |
|
export default function ({ service, serviceData }) { |
|
const { historyBack } = useRoutes(); |
|
const formRef = useRef(); |
|
const [visitble, setVisitble] = useState(false); |
|
const { reportCollection, resultData, status, service_type } = useServiceContext(); |
|
const [isLeave, setLeave] = useState(true); |
|
const { runAsync, loading } = useRequest(service, { |
|
manual: true, |
|
onSuccess(result) { |
|
themeMessage(result, historyBack); |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
const { runAsync: runReport } = useRequest(updateServiceReport, { |
|
manual: true, |
|
onSuccess() { |
|
var _a, _b, _c; |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setVisitble(false); |
|
const values = yield ((_b = (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.getFieldsFormatValue) === null || _b === void 0 ? void 0 : _b.call(_a)); |
|
runAsync(Object.assign(Object.assign({}, values), { reportCollection, |
|
status, serviceDescription: (_c = values.serviceDescription) === null || _c === void 0 ? void 0 : _c.replaceAll(/<[^>]+>/g, ''), 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)) })); |
|
}); |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
// 先编辑 成功后再提交表单 |
|
function onReport(values) { |
|
values.serviceId = serviceData === null || serviceData === void 0 ? void 0 : serviceData.serviceId; |
|
return runReport(values); |
|
} |
|
function onFinish() { |
|
var _a, _b, _c; |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setLeave(false); |
|
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), { serviceDescription: (_c = values.serviceDescription) === null || _c === void 0 ? void 0 : _c.replaceAll(/<[^>]+>/g, ''), 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 onSubmit(values) { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
setLeave(false); |
|
setVisitble(true); |
|
}); |
|
} |
|
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, colProps: { |
|
span: 24, |
|
}, formRef: formRef, onFinish: onSubmit, 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(ProjectTime, { reportCollection: reportCollection, status: status }), _jsx(ProFormItem, { name: "serviceId", hidden: true }), _jsx(ProFormTextArea, { name: "serviceDescription", label: "\u670D\u52A1\u63CF\u8FF0", placeholder: "\u8BF7\u8F93\u5165\u670D\u52A1\u63CF\u8FF0", rules: [{ required: true }], fieldProps: { |
|
maxLength: 1000, |
|
showCount: true, |
|
} }), _jsx(ProFormTextArea, { label: "\u5907\u6CE8", name: "remark", 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, { label: "\u670D\u52A1\u6210\u679C\u6587\u4EF6", name: "serviceResultsAtts", rules: service_type == 'tongyongfuwu' && [{ required: true }], max: 20, fieldProps: { |
|
accept: 'image/*,application/pdf,pplication/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel', |
|
}, extra: "\u6700\u591A\u4E0A\u4F2020\u4E2A\u9644\u4EF6,\uFF08\u652F\u6301\u683C\u5F0F\uFF1Ajpg\uFF0Cpng\uFF0Cjpeg\uFF0Cpdf\uFF0Cword\u3001Excel\uFF09", params: { |
|
bizNo: resultData === null || resultData === void 0 ? void 0 : resultData.serviceId, |
|
type: '18', |
|
} })] }))] }))] })); |
|
}
|
|
|