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.
215 lines
9.4 KiB
215 lines
9.4 KiB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; |
|
import { Form } from 'antd'; |
|
import { EditableProTable, ProFormItem } from '@ant-design/pro-components'; |
|
import { compact, isEmpty, pick, map, uniqueId, includes, find } from 'lodash'; |
|
import SelectedPolicy from './selected.policys'; |
|
import { getIndustryList } from './action'; |
|
import { useState } from 'react'; |
|
import { useRoutes } from '@component/utils'; |
|
const editColumns = [ |
|
{ |
|
title: '保单号', |
|
dataIndex: 'policyNumber', |
|
readonly: true, |
|
}, |
|
{ |
|
title: '被服务对象', |
|
dataIndex: 'serviceObjectName', |
|
renderText: (_, record) => record.customerName || record.serviceObjectName || '-', |
|
readonly: true, |
|
}, |
|
{ |
|
title: '归属机构', |
|
dataIndex: 'belongToHandlerOrganName', |
|
renderText: (_, record) => record.insuranceName || record.belongToHandlerOrganName || '-', |
|
readonly: true, |
|
}, |
|
{ |
|
title: '归属经办人', |
|
dataIndex: 'belongToHandlerUserName', |
|
readonly: true, |
|
renderText(_, item) { |
|
return compact([ |
|
item.belongToHandlerUserName, |
|
item.belongToHandlerCode, |
|
]).join(','); |
|
}, |
|
}, |
|
{ |
|
title: (_jsxs(_Fragment, { children: [_jsx("span", Object.assign({ style: { color: 'red' } }, { children: "*" })), "\u7BA1\u7406\u5206\u7C7B"] })), |
|
dataIndex: 'type', |
|
valueType: 'select', |
|
request: getIndustryList, |
|
fieldProps: { placeholder: '请输入选择管理分类', labelInValue: true }, |
|
}, |
|
{ |
|
title: '企业联系人', |
|
dataIndex: 'contactsName', |
|
valueType: 'text', |
|
fieldProps: { placeholder: '请输入企业联系人' }, |
|
}, |
|
{ |
|
title: '企业联系电话', |
|
dataIndex: 'contactsPhone', |
|
valueType: 'text', |
|
fieldProps: { placeholder: '请输入企业联系电话' }, |
|
}, |
|
{ |
|
title: '企业邮箱', |
|
dataIndex: 'email', |
|
valueType: 'text', |
|
fieldProps: { placeholder: '请输入企业邮箱' }, |
|
}, |
|
{ |
|
title: '操作', |
|
valueType: 'option', |
|
width: 70, |
|
fixed: 'right', |
|
render: () => { |
|
return null; |
|
}, |
|
}, |
|
]; |
|
export default function ({ disabled, flag = false, setFlag }) { |
|
const form = Form.useFormInstance(); |
|
const serviceTypeId = Form.useWatch('serviceTypeId', form); |
|
const aqServiceStandardCategory = Form.useWatch('aqServiceStandardCategory', form); |
|
const serviceObject = Form.useWatch('serviceObject', form); |
|
const serviceClassifyType = serviceTypeId === null || serviceTypeId === void 0 ? void 0 : serviceTypeId.serviceClassifyType; |
|
const [isShow, setIsShow] = useState(false); |
|
const { paramsParse } = useRoutes(); |
|
function onOk(selectedRowOptions) { |
|
var _a; |
|
if (!isEmpty(selectedRowOptions)) { |
|
const data = []; |
|
const selected = selectedRowOptions.map((item) => { |
|
return Object.assign(Object.assign({}, pick(item, [ |
|
'policyId', |
|
'policyNumber', |
|
'customerId', |
|
'customerName', |
|
'contactsName', |
|
'contactsPhone', |
|
'belongToHandlerOrganId', |
|
'belongToHandlerOrganName', |
|
'belongToHandlerCode', |
|
'belongToHandlerUserName', |
|
'belongToHandlerNumber', |
|
'insuranceId', |
|
'insuranceName', |
|
'serviceObjectId', |
|
'serviceObjectName', |
|
])), { contactsName: item.contactsName || '', contactsPhone: item.phone || item.contactsPhone || '', email: item.email || '', type: item.typePid |
|
? { |
|
value: item.typePid, |
|
label: item.typePname, |
|
} |
|
: null }); |
|
}); |
|
for (const selectedElement of selected) { |
|
const item = find(serviceObject, [ |
|
'policyId', |
|
selectedElement.policyId, |
|
]); |
|
if (item) { |
|
data.push(item); |
|
} |
|
else { |
|
selectedElement.id = uniqueId(); |
|
data.push(selectedElement); |
|
} |
|
} |
|
form.setFieldsValue({ |
|
serviceObject: data, |
|
}); |
|
if (isShow) { |
|
form.setFieldsValue({ |
|
address: null, |
|
}); |
|
} |
|
if (serviceClassifyType !== 'jizhongfuwu') { |
|
if ((paramsParse === null || paramsParse === void 0 ? void 0 : paramsParse.reSubmit) && flag) |
|
return setFlag(false); |
|
if (isShow) { |
|
form.setFieldValue('serviceName', `${((_a = selectedRowOptions[0]) === null || _a === void 0 ? void 0 : _a.customerName) || ''}${(aqServiceStandardCategory === null || aqServiceStandardCategory === void 0 ? void 0 : aqServiceStandardCategory.label) || ''}`); |
|
} |
|
} |
|
} |
|
} |
|
return (_jsx(SelectedPolicy, Object.assign({ disabled: disabled, name: "serviceObject", serviceClassifyType: serviceClassifyType, onConfirm: onOk, rowSelectionType: serviceClassifyType === 'jizhongfuwu' ? 'checkbox' : 'radio' }, { children: ({ handleOpen, setSelectedRowOptions }) => (_jsx(_Fragment, { children: _jsx(ProFormItem, Object.assign({ label: "\u9009\u62E9\u4FDD\u5355", required: true, labelCol: { |
|
span: 3, |
|
}, name: "serviceObject", trigger: "onValuesChange", rules: [ |
|
() => ({ |
|
validator(_, value) { |
|
var _a; |
|
if (isEmpty(value)) { |
|
return Promise.reject(new Error('请选择保单')); |
|
} |
|
let message = ''; |
|
for (const valueElement of value) { |
|
// if (!valueElement.contactsName) { |
|
// message = '请输入企业联系人'; |
|
// break; |
|
// } |
|
// |
|
// if (!valueElement.contactsPhone) { |
|
// message = '请输入企业联系电话'; |
|
// break; |
|
// } |
|
// |
|
// if (!phoneReg.test(valueElement.contactsPhone)) { |
|
// message = '请输入正确的企业联系电话'; |
|
// break; |
|
// } |
|
// if (!valueElement.email) { |
|
// message = '请输入企业邮箱'; |
|
// break; |
|
// } |
|
// if (!emailReg.test(valueElement.email)) { |
|
// message = '请输入正确的企业邮箱'; |
|
// break; |
|
// } |
|
if (!((_a = valueElement === null || valueElement === void 0 ? void 0 : valueElement.type) === null || _a === void 0 ? void 0 : _a.value)) { |
|
message = '请选择管理分类'; |
|
break; |
|
} |
|
} |
|
if (message) { |
|
return Promise.reject(new Error(message)); |
|
} |
|
return Promise.resolve(); |
|
}, |
|
}), |
|
], colProps: { |
|
span: 24, |
|
} }, { children: _jsx(EditableProTable, { tableStyle: { |
|
display: isEmpty(serviceObject) ? 'none' : 'block', |
|
marginBottom: 10, |
|
}, size: "small", tableClassName: "tableClassName", rowKey: "id", toolBarRender: false, columns: editColumns, recordCreatorProps: { |
|
creatorButtonText: '选择保单', |
|
disabled: disabled || !serviceClassifyType, |
|
onClick: () => { |
|
handleOpen(); |
|
setIsShow(true); |
|
}, |
|
parentKey: Date.now(), |
|
style: { |
|
margin: 0, |
|
}, |
|
}, editable: { |
|
type: 'multiple', |
|
editableKeys: map(serviceObject, 'id'), |
|
actionRender: (row, config, defaultDoms) => { |
|
if (disabled) { |
|
return null; |
|
} |
|
return [defaultDoms.delete]; |
|
}, |
|
onChange: (editableKeys, editableOptions) => { |
|
form.setFieldsValue({ |
|
serviceObject: editableOptions, |
|
}); |
|
setSelectedRowOptions(editableOptions); |
|
}, |
|
} }) })) })) }))); |
|
}
|
|
|