import { jsx as _jsx } from "react/jsx-runtime"; import { ModalForm, ProTable } from "@ant-design/pro-components"; import { Button } from "antd"; import React, { useRef, useState } from "react"; import { getList } from "actions/service.apply.action"; import { getDetail } from 'actions/service.apply.action'; import { dateFormatter, jsonString, truncateText } from "@component/utils"; import moment from "moment/moment"; import { compact, isEmpty } from "lodash"; import { getAqServiceStandard, getServiceType, } from "actions/service.action"; export default function ({ form }) { const [visible, setVisible] = useState(false); const [aqCategoryId, setAqCategoryId] = useState(''); const formRef = useRef(); const columns = [ { title: "保单号", dataIndex: "policyNumber", ellipsis: true, fieldProps: { placeholder: '' }, }, { title: "标准分类", dataIndex: "aqServiceName", ellipsis: true, valueType: 'select', fieldProps: { placeholder: '', onChange: getAqCategoryId }, formItemProps: { name: 'aqServiceId', }, request: getAqServiceStandard, }, { title: '服务活动', dataIndex: 'serviceTypeName', ellipsis: true, valueType: 'select', fieldProps: { placeholder: '' }, params: { aqServiceId: aqCategoryId }, request: getServiceType, formItemProps: { name: 'serviceTypeId' }, }, { title: '服务名称', dataIndex: 'serviceProjectName', ellipsis: true, search: false, }, { title: '期望服务时间', dataIndex: 'estimatedServiceAt', renderText: dateFormatter, ellipsis: true, search: false, }, { title: "操作", search: false, render: (_, { serviceApplyId }) => (_jsx(Button, Object.assign({ type: "link", onClick: () => onClick(serviceApplyId) }, { children: "\u590D\u7528" }))) } ]; function getAqCategoryId(value) { setAqCategoryId(value); } function onClick(id) { getDetail({ id }).then(res => { var _a; (_a = form === null || form === void 0 ? void 0 : form.current) === null || _a === void 0 ? void 0 : _a.setFieldsValue({ executedAt: res.estimatedServiceAt ? moment(res.estimatedServiceAt) : undefined, servicePrice: res.servicePrice, form: res.form ? String(res.form) : '2', aqServiceStandardCategory: (res === null || res === void 0 ? void 0 : res.aqServiceId) ? { value: res.aqServiceId, label: res.aqServiceName, } : null, serviceTypeId: !isEmpty(compact([ res === null || res === void 0 ? void 0 : res.serviceTypeId, res === null || res === void 0 ? void 0 : res.serviceTypeName, res === null || res === void 0 ? void 0 : res.serviceClassifyType, ])) ? { value: res === null || res === void 0 ? void 0 : res.serviceTypeId, label: res === null || res === void 0 ? void 0 : res.serviceTypeName, serviceClassifyType: res === null || res === void 0 ? void 0 : res.serviceClassifyType, } : null, serviceSchemeId: !isEmpty(compact([res === null || res === void 0 ? void 0 : res.serviceSchemeId, res === null || res === void 0 ? void 0 : res.serviceSchemeName])) ? { value: res === null || res === void 0 ? void 0 : res.serviceSchemeId, label: res === null || res === void 0 ? void 0 : res.serviceSchemeName, } : null, address: !isEmpty(res === null || res === void 0 ? void 0 : res.address) || !isEmpty(res === null || res === void 0 ? void 0 : res.serviceAddress) ? { value: res === null || res === void 0 ? void 0 : res.serviceAddress, label: res === null || res === void 0 ? void 0 : res.serviceAddress, address: res === null || res === void 0 ? void 0 : res.address, geoLat: res === null || res === void 0 ? void 0 : res.serviceAddressLat, geoLng: res === null || res === void 0 ? void 0 : res.serviceAddressLng, } : null, }); }); setVisible(false); } return (_jsx(ModalForm, Object.assign({ title: "\u590D\u7528\u7533\u8BF7\u8BB0\u5F55", layout: "horizontal", open: visible, formRef: formRef, trigger: _jsx(Button, Object.assign({ type: "primary", onClick: () => setVisible(true) }, { children: "\u590D\u7528\u7533\u8BF7\u8BB0\u5F55" })), submitter: false, modalProps: { closable: false, onCancel: () => setVisible(false) } }, { children: _jsx(ProTable, { rowKey: "serviceApplyId", request: getList, columns: columns, pagination: { pageSize: 5, showSizeChanger: false }, toolBarRender: false }) }))); }