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.
69 lines
4.1 KiB
69 lines
4.1 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 { ProForm, ProFormSelect } from '@ant-design/pro-components'; |
|
import { PlusOutlined } from '@ant-design/icons'; |
|
import { map, uniqueId, concat, find, isEmpty } from 'lodash'; |
|
import { getPolicyAddress } from '../action'; |
|
import { Divider, Button, Space, Input } from 'antd'; |
|
import { MapPositioning } from '@component/amap'; |
|
import { useState, useRef } from 'react'; |
|
export default function SelectedAddress() { |
|
const [visible, setVisible] = useState(false); |
|
const [name, setName] = useState(''); |
|
const [items, setItems] = useState([]); |
|
const inputRef = useRef(null); |
|
function onChange(form, data) { |
|
form.setFieldsValue({ |
|
address: { |
|
value: uniqueId('local_'), |
|
label: data.address, |
|
geoLng: data.lng, |
|
geoLat: data.lat, |
|
}, |
|
}); |
|
} |
|
function onNameChange(event) { |
|
setName(event.target.value); |
|
} |
|
function addItem() { |
|
if (name && !find(items, ['label', name])) { |
|
setItems([ |
|
...items, |
|
{ |
|
value: uniqueId('local_'), |
|
label: name, |
|
}, |
|
]); |
|
} |
|
} |
|
return (_jsx(ProForm.Item, Object.assign({ noStyle: true, shouldUpdate: true }, { children: (form) => { |
|
var _a; |
|
const policyNumber = (_a = map(form.getFieldValue('serviceObject'), 'policyNumber')) === null || _a === void 0 ? void 0 : _a.join(','); |
|
return (_jsxs(_Fragment, { children: [_jsx(ProFormSelect, { name: "address", label: "\u670D\u52A1\u5730\u5740", params: { |
|
policyNumbers: policyNumber, |
|
items, |
|
}, placeholder: "\u8BF7\u9009\u62E9\u670D\u52A1\u5730\u5740", fieldProps: { |
|
labelInValue: true, |
|
dropdownRender: (menu) => (_jsxs(_Fragment, { children: [menu, _jsx(Divider, { style: { margin: '8px 0' } }), _jsxs(Space, Object.assign({ style: { padding: '0 8px 4px' } }, { children: [_jsx(Input, { placeholder: "\u8BF7\u8F93\u5165\u670D\u52A1\u5730\u5740", ref: inputRef, value: name, onChange: onNameChange }), _jsx(Button, Object.assign({ type: "text", icon: _jsx(PlusOutlined, {}), onClick: addItem }, { children: "\u6DFB\u52A0\u670D\u52A1\u5730\u5740" }))] })), _jsx(Divider, { style: { margin: '8px 0' } }), _jsx(Button, Object.assign({ type: "link", size: "small", onClick: () => setVisible(true) }, { children: "\u9009\u62E9\u5730\u56FE\u4F4D\u7F6E" }))] })), |
|
}, request: (params) => __awaiter(this, void 0, void 0, function* () { |
|
return policyNumber |
|
? getPolicyAddress({ |
|
policyNumbers: params.policyNumbers, |
|
}).then((data) => { |
|
if (!isEmpty(data)) { |
|
return concat([], params.items, data); |
|
} |
|
return items; |
|
}) |
|
: items; |
|
}), rules: [{ required: true }] }), visible && (_jsx(MapPositioning, { onClose: () => setVisible(false), onConfirm: (data) => onChange(form, data) }))] })); |
|
} }))); |
|
}
|
|
|