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