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.
54 lines
3.4 KiB
54 lines
3.4 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 } from "react/jsx-runtime"; |
|
import { ModalForm, ProFormItem, ProFormSelect, ProFormText, } from '@ant-design/pro-components'; |
|
import { Form, message } from 'antd'; |
|
import { useRequest } from 'ahooks'; |
|
import { omit } from 'lodash'; |
|
import { useServiceContext } from '../../context'; |
|
import { phoneReg, themeMessage } from '@component/utils'; |
|
import { getCustomerList } from './action'; |
|
export default ({ title, onCancel, init, item, service }) => { |
|
const { serviceId } = useServiceContext(); |
|
const [form] = Form.useForm(); |
|
const { runAsync, loading } = useRequest(service, { |
|
manual: true, |
|
onSuccess(result) { |
|
themeMessage(result); |
|
if (result.type === 'success') { |
|
init && init(); |
|
onCancel(); |
|
} |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
function onFinish(values) { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
const customer = values.customer; |
|
return runAsync(Object.assign({}, omit(values, ['customer']), { |
|
customerId: customer.value, |
|
customerName: customer.label, |
|
serviceId, |
|
})); |
|
}); |
|
} |
|
return (_jsxs(ModalForm, Object.assign({ visible: true, title: title, form: form, autoFocusFirstInput: true, modalProps: { |
|
destroyOnClose: true, |
|
confirmLoading: loading, |
|
onCancel: onCancel, |
|
}, submitTimeout: 2000, onFinish: onFinish }, { children: [_jsx(ProFormItem, { name: "serviceId", hidden: true }), _jsx(ProFormSelect, { params: { serviceId }, request: getCustomerList, rules: [{ required: true, message: '请选择企业名称' }], name: "customer", fieldProps: { |
|
labelInValue: true, |
|
}, placeholder: "\u8BF7\u9009\u62E9\u4F01\u4E1A\u540D\u79F0", label: "\u4F01\u4E1A\u540D\u79F0" }), _jsx(ProFormText, { rules: [{ required: true }], name: "userName", placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D", label: "\u59D3\u540D" }), _jsx(ProFormText, { rules: [ |
|
{ required: true }, |
|
{ pattern: phoneReg, message: '请输入正确的电话' }, |
|
], placeholder: "\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u7535\u8BDD", name: "phone", label: "\u7535\u8BDD" }), _jsx(ProFormText, { placeholder: "\u8BF7\u8F93\u5165\u90E8\u95E8", rules: [{ required: true }, { max: 40, message: '字数过长' }], name: "groupName", label: "\u90E8\u95E8" }), _jsx(ProFormText, { placeholder: "\u8BF7\u8F93\u5165\u804C\u52A1", rules: [{ required: true }, { max: 40, message: '字数过长' }], name: "userPosition", label: "\u804C\u52A1" })] }))); |
|
};
|
|
|