fix
parent
242fb41d22
commit
c42bc60564
|
|
@ -49,6 +49,11 @@ export const ENTERPRISE_STATUS_OPTIONS = [
|
|||
{ label: "注销", value: 3 },
|
||||
];
|
||||
|
||||
export const ENTERPRISE_STATUS_OPTIONS_MAP = ENTERPRISE_STATUS_OPTIONS.reduce(
|
||||
(acc, cur) => ({ ...acc, [cur.value]: cur.label }),
|
||||
{},
|
||||
);
|
||||
|
||||
/** 企业规模 */
|
||||
export const ENTERPRISE_SCALE_OPTIONS = [
|
||||
{ label: "大", value: "大" },
|
||||
|
|
|
|||
|
|
@ -22,18 +22,37 @@ import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
|||
import SearchForm from "~/components/SearchForm";
|
||||
import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper";
|
||||
import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
|
||||
import { QUALIFICATION_INDUSTRY_OPTIONS } from "~/enumerate/enterpriseOptions";
|
||||
import { isOrgAccountEnabled } from "~/utils/enterpriseInfo/adapter";
|
||||
import {
|
||||
CHONGQING_DISTRICTS,
|
||||
ENTERPRISE_SCALE_OPTIONS,
|
||||
ORG_ACCOUNT_STATE_OPTIONS,
|
||||
ENTERPRISE_STATUS_OPTIONS,
|
||||
ENTERPRISE_STATUS_OPTIONS_MAP,
|
||||
} from "~/enumerate/enterpriseOptions";
|
||||
import { NS_ORG_INFO } from "~/enumerate/namespace";
|
||||
import { safeListRequest, safeRequest } from "~/utils";
|
||||
|
||||
const { router } = tools;
|
||||
|
||||
const CONTACT_SEP = "/";
|
||||
const mergeContactNamePhone = (name, phone) => {
|
||||
if (!name && !phone) return undefined;
|
||||
return [name, phone].filter(Boolean).join(CONTACT_SEP);
|
||||
};
|
||||
const splitContactNamePhone = (value) => {
|
||||
if (!value) return { contactName: undefined, contactPhone: undefined };
|
||||
const idx = String(value).indexOf(CONTACT_SEP);
|
||||
if (idx >= 0) {
|
||||
return {
|
||||
contactName: String(value).slice(0, idx).trim(),
|
||||
contactPhone: String(value).slice(idx + 1).trim(),
|
||||
};
|
||||
}
|
||||
return { contactName: String(value).trim(), contactPhone: undefined };
|
||||
};
|
||||
|
||||
function OrgAccountPage(props) {
|
||||
const [searchForm] = Form.useForm();
|
||||
const [editForm] = Form.useForm();
|
||||
|
|
@ -47,8 +66,6 @@ function OrgAccountPage(props) {
|
|||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
|
||||
|
||||
const getData = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
|
@ -105,7 +122,13 @@ function OrgAccountPage(props) {
|
|||
setEditOpen(true);
|
||||
const res = await loadDetail(id);
|
||||
if (res?.data) {
|
||||
editForm.setFieldsValue(res.data);
|
||||
editForm.setFieldsValue({
|
||||
...res.data,
|
||||
contactNamePhone: mergeContactNamePhone(
|
||||
res.data.contactName,
|
||||
res.data.contactPhone,
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -188,12 +211,17 @@ function OrgAccountPage(props) {
|
|||
};
|
||||
|
||||
const onEditSubmit = async () => {
|
||||
const values = await editForm.validateFields();
|
||||
setEditLoading(true);
|
||||
const res = await props.orgAccountModify({
|
||||
...values,
|
||||
const formValues = await editForm.validateFields();
|
||||
const split = splitContactNamePhone(formValues.contactNamePhone);
|
||||
const values = {
|
||||
...formValues,
|
||||
contactName: split.contactName,
|
||||
contactPhone: split.contactPhone,
|
||||
contactNamePhone: undefined,
|
||||
id: currentId,
|
||||
});
|
||||
};
|
||||
setEditLoading(true);
|
||||
const res = await props.orgAccountModify(values);
|
||||
setEditLoading(false);
|
||||
if (res?.success !== false) {
|
||||
message.success("保存成功");
|
||||
|
|
@ -326,7 +354,7 @@ function OrgAccountPage(props) {
|
|||
current: 1,
|
||||
pageSize: 10,
|
||||
};
|
||||
getData()
|
||||
getData();
|
||||
}}
|
||||
/>
|
||||
<Table
|
||||
|
|
@ -373,23 +401,18 @@ function OrgAccountPage(props) {
|
|||
<Descriptions.Item label="属地">
|
||||
{detail.districtName}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="执业资质范围">
|
||||
<Descriptions.Item label="所属行业">
|
||||
{detail.safetyIndustryCategoryName}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="经营地址" span={2}>
|
||||
{detail.businessAddress}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="企业状态">
|
||||
{detail.enterpriseStatusName}
|
||||
{ENTERPRISE_STATUS_OPTIONS_MAP[detail.enterpriseStatusCode]}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="经度/纬度">
|
||||
{detail.longitude}, {detail.latitude}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="主要负责人">
|
||||
{detail.principalName}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="主要负责人电话">
|
||||
{detail.principalPhone}
|
||||
|
||||
<Descriptions.Item label="联系人及电话" span={2}>
|
||||
{mergeContactNamePhone(detail.contactName, detail.contactPhone) || "-"}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="法定代表人">
|
||||
{detail.legalRepresentative}
|
||||
|
|
@ -448,56 +471,119 @@ function OrgAccountPage(props) {
|
|||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item
|
||||
name="safetyIndustryCategoryName"
|
||||
label="执业资质范围"
|
||||
<Form.Item name="safetyIndustryCategoryCode" label="所属行业">
|
||||
<Select
|
||||
mode="multiple"
|
||||
placeholder="请选择"
|
||||
allowClear
|
||||
onChange={(values) => {
|
||||
const names = (values || [])
|
||||
.map(
|
||||
(v) =>
|
||||
QUALIFICATION_INDUSTRY_OPTIONS.find(
|
||||
(o) => o.value === v,
|
||||
)?.label,
|
||||
)
|
||||
.filter(Boolean);
|
||||
editForm.setFieldsValue({
|
||||
safetyIndustryCategoryName: names.join(","),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Input />
|
||||
{QUALIFICATION_INDUSTRY_OPTIONS.map((opt) => (
|
||||
<Select.Option key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="safetyIndustryCategoryName" noStyle />
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="businessAddress" label="经营地址">
|
||||
<Input />
|
||||
<Input placeholder="请输入" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Form.Item name="enterpriseStatusCode" label="企业状态">
|
||||
<Select
|
||||
options={ENTERPRISE_STATUS_OPTIONS}
|
||||
placeholder="请选择"
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="enterpriseStatusName" label="企业状态">
|
||||
<Select options={ENTERPRISE_STATUS_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Form.Item name="longitude" label="经度">
|
||||
<InputNumber style={{ width: "100%" }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={6}>
|
||||
<Form.Item name="latitude" label="纬度">
|
||||
<InputNumber style={{ width: "100%" }} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="principalName" label="主要负责人">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="principalPhone" label="主要负责人电话">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="contactNamePhone"
|
||||
label="联系人及电话"
|
||||
validateFirst
|
||||
rules={[
|
||||
{ required: true, message: "请输入联系人及电话" },
|
||||
{
|
||||
validator: (_, value) => {
|
||||
const { contactName, contactPhone } =
|
||||
splitContactNamePhone(value);
|
||||
if (!contactName) {
|
||||
return Promise.reject(new Error("联系人不能为空"));
|
||||
}
|
||||
if (contactName.length > 50) {
|
||||
return Promise.reject(new Error("联系人不能超过50字"));
|
||||
}
|
||||
if (!contactPhone) {
|
||||
return Promise.reject(
|
||||
new Error("请使用/分隔联系人和电话,并填写电话"),
|
||||
);
|
||||
}
|
||||
if (
|
||||
!/^(1[3-9]\d{9}|\d{10,12})$/.test(
|
||||
String(contactPhone).replace(/\s+/g, ""),
|
||||
)
|
||||
) {
|
||||
return Promise.reject(
|
||||
new Error("电话格式不正确(手机11位或固话区号+号码)"),
|
||||
);
|
||||
}
|
||||
if (contactPhone.length > 20) {
|
||||
return Promise.reject(new Error("电话不能超过20字"));
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
},
|
||||
]}
|
||||
extra="请使用/分隔联系人和电话,如:张三/13800138000"
|
||||
>
|
||||
<Input
|
||||
placeholder="如:张三/13800138000"
|
||||
allowClear
|
||||
maxLength={73}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="legalRepresentative" label="法定代表人">
|
||||
<Input />
|
||||
<Input placeholder="请选择" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="legalRepresentativePhone" label="法人电话">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="legalRepresentativePhone"
|
||||
label="法人电话"
|
||||
rules={[
|
||||
{
|
||||
pattern: /(^1[3-9]\d{9}$)|(^0\d{2,3}-?\d{7,8}$)/,
|
||||
message: "请输入正确的手机号或座机号",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder="请输入" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item name="enterpriseScaleName" label="企业规模">
|
||||
<Select
|
||||
placeholder="请选择"
|
||||
allowClear
|
||||
options={ENTERPRISE_SCALE_OPTIONS.map((o) => ({
|
||||
label: o.label,
|
||||
value: o.label,
|
||||
|
|
|
|||
Loading…
Reference in New Issue