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.
262 lines
22 KiB
262 lines
22 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, ProFormText, ProFormTextArea, ProFormTreeSelect, ProFormCheckbox, ProFormSelect, EditableProTable, ProFormDependency, ProFormList, ProCard, ProFormItem, } from '@ant-design/pro-components'; |
|
import { UploadOutlined } from '@ant-design/icons'; |
|
import React, { useRef, useState } from 'react'; |
|
import { Space, TreeSelect, Button, message, Modal, Upload, Row, Col, Divider, } from 'antd'; |
|
import { getDictValList, getGridOptions } from './action'; |
|
import { getLabelInValue, getUploadList, themeMessage, } from '@component/utils'; |
|
import { getExpertDetail } from './action'; |
|
import { useRequest } from 'ahooks'; |
|
import { getStorage, idEncryption, phoneEncryption, useRoutes, } from '@component/utils'; |
|
import { map, omit } from 'lodash'; |
|
import { useGrid, jsonString } from '@component/utils'; |
|
import { GridForm, CardForm, FormUpload, ReactRouterPrompt, } from '@component/ui'; |
|
import { concatLabelValue } from '@component/utils'; |
|
import { IDReg, phoneReg, extendPhoneReg } from '@component/utils'; |
|
export default function ({ service, params }) { |
|
const [isLeave, setLeave] = useState(true); |
|
const [formDisabled, setFormDisabled] = useState(true); |
|
const [idDisabled, setIdDisabled] = useState(true); |
|
const [treeData, { onLoadData, setGridIds, gridExpandedKeys }] = useGrid({}, !!params); |
|
const [serviceTreeData, serviceGrid] = useGrid({}, !!params); |
|
const { historyBack } = useRoutes(); |
|
const { runAsync } = useRequest(service, { |
|
manual: true, |
|
onSuccess(result) { |
|
themeMessage(result, historyBack); |
|
}, |
|
onError(result) { |
|
message.error(result.message); |
|
}, |
|
}); |
|
const reg = /(^1([3456789])\d{9}$)/; |
|
function onFinish(values) { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
const skilledField = yield getLabelInValue('16', values.skilledField); |
|
const skilledIndustry = yield getLabelInValue('13', values.skilledIndustry); |
|
const skilledWork = yield getLabelInValue('18', values.skilledWork); |
|
values.titleId = values.titleName.value; |
|
values.titleName = values.titleName.label; |
|
values.education = values.educationName.value; |
|
values.educationName = values.educationName.label; |
|
values.skilledFieldName = skilledField.join(','); |
|
values.skilledIndustryName = skilledIndustry.join(','); |
|
values.skilledWorkName = skilledWork.join(','); |
|
values.scopeGrid = map(values.scopeGrid, 'value').join(','); |
|
values.skilledField = values.skilledField.join(','); |
|
values.skilledIndustry = values.skilledIndustry.join(','); |
|
values.skilledWork = values.skilledWork.join(','); |
|
values.certification = JSON.stringify(values.certification.map((item) => { |
|
var _a, _b, _c; |
|
return Object.assign(Object.assign({}, omit(item, ['certificationOtherName'])), { certificationType: (_a = item.certificationName) === null || _a === void 0 ? void 0 : _a.value, certificationName: ((_b = item.certificationName) === null || _b === void 0 ? void 0 : _b.value) != '10137' |
|
? (_c = item.certificationName) === null || _c === void 0 ? void 0 : _c.label |
|
: item.certificationOtherName }); |
|
})); |
|
values.signAttPath = JSON.stringify(getUploadList(values.signAttPath)); |
|
if (params) { |
|
values.userId = params.userId; |
|
} |
|
Modal.confirm({ |
|
content: '请确认是否提交?', |
|
onOk() { |
|
runAsync(omit(values, ['userName', 'sex', 'age'])); |
|
setLeave(false); |
|
}, |
|
}); |
|
}); |
|
} |
|
function request(params) { |
|
return __awaiter(this, void 0, void 0, function* () { |
|
return getExpertDetail(params).then((data) => __awaiter(this, void 0, void 0, function* () { |
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2; |
|
if (data) { |
|
const result = (_a = data.certifications) === null || _a === void 0 ? void 0 : _a.map((item, index) => __awaiter(this, void 0, void 0, function* () { |
|
return { |
|
certificationName: item.certificationName |
|
? { |
|
label: item.certificationType == '10137' |
|
? '其他' |
|
: item.certificationName || '', |
|
value: item.certificationType || '', |
|
} |
|
: null, |
|
certificationNumber: item.certificationNumber || '', |
|
certifications: (yield jsonString(item.certifications)) || [], |
|
certificationOtherName: item.certificationName || '', |
|
}; |
|
})); |
|
setGridIds((_b = data.feature) === null || _b === void 0 ? void 0 : _b.split(',')); |
|
const educationName = ((_c = data === null || data === void 0 ? void 0 : data.identification) === null || _c === void 0 ? void 0 : _c.education) |
|
? { |
|
label: (_d = data === null || data === void 0 ? void 0 : data.identification) === null || _d === void 0 ? void 0 : _d.educationName, |
|
value: (_e = data === null || data === void 0 ? void 0 : data.identification) === null || _e === void 0 ? void 0 : _e.education, |
|
} |
|
: null; |
|
const titleName = ((_f = data === null || data === void 0 ? void 0 : data.identification) === null || _f === void 0 ? void 0 : _f.titleId) |
|
? { |
|
label: (_g = data === null || data === void 0 ? void 0 : data.identification) === null || _g === void 0 ? void 0 : _g.titleName, |
|
value: (_h = data === null || data === void 0 ? void 0 : data.identification) === null || _h === void 0 ? void 0 : _h.titleId, |
|
} |
|
: null; |
|
if (getStorage('roleId') == '10000000001') { |
|
setIdDisabled(false); |
|
setFormDisabled(false); |
|
} |
|
else { |
|
if (!((_j = data === null || data === void 0 ? void 0 : data.identification) === null || _j === void 0 ? void 0 : _j.idNumber)) { |
|
setIdDisabled(false); |
|
} |
|
} |
|
if (data.identification.status == 1) { |
|
return { |
|
userName: data === null || data === void 0 ? void 0 : data.userName, |
|
idNumber: (_k = data === null || data === void 0 ? void 0 : data.identification) === null || _k === void 0 ? void 0 : _k.idNumber, |
|
sex: (data === null || data === void 0 ? void 0 : data.sex) == 1 ? '男' : '女', |
|
age: data === null || data === void 0 ? void 0 : data.age, |
|
phone: data === null || data === void 0 ? void 0 : data.phone, |
|
certification: result, |
|
workUnit: getStorage('organName'), |
|
}; |
|
} |
|
return { |
|
userName: data === null || data === void 0 ? void 0 : data.userName, |
|
idNumber: (_l = data === null || data === void 0 ? void 0 : data.identification) === null || _l === void 0 ? void 0 : _l.idNumber, |
|
sex: (data === null || data === void 0 ? void 0 : data.sex) == 1 ? '男' : '女', |
|
age: data === null || data === void 0 ? void 0 : data.age, |
|
phone: data === null || data === void 0 ? void 0 : data.phone, |
|
workUnit: getStorage('organName'), |
|
certification: result, |
|
gridId: (_m = data === null || data === void 0 ? void 0 : data.identification) === null || _m === void 0 ? void 0 : _m.gridId, |
|
graduationSchool: (_o = data === null || data === void 0 ? void 0 : data.identification) === null || _o === void 0 ? void 0 : _o.graduationSchool, |
|
major: (_p = data === null || data === void 0 ? void 0 : data.identification) === null || _p === void 0 ? void 0 : _p.major, |
|
educationName: educationName, |
|
titleName: titleName, |
|
skilledField: (_r = (_q = data === null || data === void 0 ? void 0 : data.identification) === null || _q === void 0 ? void 0 : _q.skilledField) === null || _r === void 0 ? void 0 : _r.split(','), |
|
skilledIndustry: (_t = (_s = data === null || data === void 0 ? void 0 : data.identification) === null || _s === void 0 ? void 0 : _s.skilledIndustry) === null || _t === void 0 ? void 0 : _t.split(','), |
|
skilledWork: (_v = (_u = data === null || data === void 0 ? void 0 : data.identification) === null || _u === void 0 ? void 0 : _u.skilledWork) === null || _v === void 0 ? void 0 : _v.split(','), |
|
workYear: (_w = data === null || data === void 0 ? void 0 : data.identification) === null || _w === void 0 ? void 0 : _w.workYear, |
|
experience: (_x = data === null || data === void 0 ? void 0 : data.identification) === null || _x === void 0 ? void 0 : _x.experience, |
|
scopeGrid: concatLabelValue((_z = (_y = data === null || data === void 0 ? void 0 : data.identification) === null || _y === void 0 ? void 0 : _y.scopeGrid) === null || _z === void 0 ? void 0 : _z.split(','), (_1 = (_0 = data === null || data === void 0 ? void 0 : data.identification) === null || _0 === void 0 ? void 0 : _0.scopeGridName) === null || _1 === void 0 ? void 0 : _1.split(',')), |
|
signAttPath: yield jsonString((_2 = data === null || data === void 0 ? void 0 : data.identification) === null || _2 === void 0 ? void 0 : _2.signAttPath), |
|
}; |
|
} |
|
return null; |
|
})); |
|
}); |
|
} |
|
return (_jsx(_Fragment, { children: _jsx("div", Object.assign({ className: "page-content-detail" }, { children: _jsxs(GridForm, Object.assign({ params: params, request: !!params && request, onFinish: onFinish }, { children: [_jsx(ReactRouterPrompt, { when: isLeave }), _jsxs(CardForm, { children: [_jsx(ProFormText, { name: "userName", placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D", label: "\u59D3\u540D", disabled: true }), _jsx(ProFormTreeSelect, { label: "\u8BC1\u4EF6\u7C7B\u578B", fieldProps: { |
|
defaultValue: '身份证', |
|
}, disabled: true }), _jsx(ProFormText, { name: "idNumber", label: "\u8BC1\u4EF6\u53F7\u7801", placeholder: "\u8BF7\u8F93\u5165\u8BC1\u4EF6\u53F7\u7801", disabled: idDisabled, rules: [ |
|
{ required: true }, |
|
{ pattern: IDReg, message: '证件号码格式不正确' }, |
|
] }), _jsx(ProFormText, { name: "phone", label: "\u8054\u7CFB\u7535\u8BDD", placeholder: "\u8BF7\u8F93\u5165\u8054\u7CFB\u7535\u8BDD", disabled: formDisabled, rules: [ |
|
{ required: true }, |
|
{ pattern: reg, message: '联系电话格式不正确' }, |
|
] }), _jsx(ProFormItem, Object.assign({ noStyle: true, shouldUpdate: true }, { children: (form) => { |
|
return (_jsx(ProFormTreeSelect, { name: "gridId", label: "\u6240\u5728\u57CE\u5E02", placeholder: "\u8BF7\u9009\u62E9\u6240\u5728\u57CE\u5E02", fieldProps: { |
|
treeDataSimpleMode: true, |
|
allowClear: true, |
|
loadData: onLoadData, |
|
treeData: treeData, |
|
treeDefaultExpandedKeys: gridExpandedKeys, |
|
onSelect: () => { |
|
form.setFieldsValue({ |
|
scopeGrid: undefined, |
|
}); |
|
}, |
|
}, rules: [{ required: true, message: '请选择所在城市' }] })); |
|
} })), _jsx(ProFormTreeSelect, { name: "scopeGrid", label: "\u670D\u52A1\u533A\u57DF", placeholder: "\u8BF7\u9009\u62E9\u670D\u52A1\u533A\u57DF", fieldProps: { |
|
labelInValue: true, |
|
multiple: true, |
|
treeDataSimpleMode: true, |
|
allowClear: true, |
|
loadData: serviceGrid === null || serviceGrid === void 0 ? void 0 : serviceGrid.onLoadData, |
|
treeDefaultExpandedKeys: serviceGrid === null || serviceGrid === void 0 ? void 0 : serviceGrid.gridExpandedKeys, |
|
treeData: serviceTreeData, |
|
}, rules: [{ required: true, message: '请选择服务区域' }] }), _jsx(ProFormText, { name: "graduationSchool", label: "\u6BD5\u4E1A\u9662\u6821", placeholder: "\u8BF7\u8F93\u5165\u6BD5\u4E1A\u9662\u6821", fieldProps: { |
|
maxLength: 100, |
|
}, rules: [{ required: true }] }), _jsx(ProFormText, { name: "major", label: "\u4E13\u4E1A", fieldProps: { |
|
maxLength: 100, |
|
}, placeholder: "\u8BF7\u8F93\u5165\u4E13\u4E1A", rules: [{ required: true }] }), _jsx(ProFormSelect, { name: "educationName", label: "\u6700\u9AD8\u5B66\u5386", placeholder: "\u8BF7\u9009\u62E9\u6700\u9AD8\u5B66\u5386", params: { dictId: '14' }, request: getDictValList, fieldProps: { |
|
labelInValue: true, |
|
}, rules: [{ required: true, message: '请选择最高学历' }] }), _jsx(ProFormText, { name: "workUnit", label: "\u6240\u5728\u5355\u4F4D", fieldProps: { |
|
maxLength: 100, |
|
}, disabled: true, placeholder: "\u8BF7\u8F93\u5165\u6240\u5728\u5355\u4F4D", rules: [{ required: true }] }), _jsx(ProFormSelect, { name: "titleName", label: "\u804C\u52A1/\u804C\u79F0", placeholder: "\u8BF7\u9009\u62E9\u804C\u52A1/\u804C\u79F0", params: { dictId: '15' }, request: getDictValList, fieldProps: { |
|
labelInValue: true, |
|
}, rules: [{ required: true, message: '请选择职务/职称' }] }), _jsx(ProFormSelect, { name: "skilledField", label: "\u64C5\u957F\u9886\u57DF", placeholder: "\u8BF7\u9009\u62E9\u64C5\u957F\u9886\u57DF", rules: [{ required: true, message: '请选择擅长领域' }], params: { |
|
dictId: '16', |
|
}, fieldProps: { |
|
allowClear: true, |
|
mode: 'multiple', |
|
}, request: getDictValList }), _jsx(ProFormSelect, { name: "skilledIndustry", label: "\u4E3B\u8981\u670D\u52A1\u884C\u4E1A\u9886\u57DF", placeholder: "\u8BF7\u9009\u62E9\u4E3B\u8981\u670D\u52A1\u884C\u4E1A\u9886\u57DF", rules: [{ required: true, message: '请选择主要服务行业领域' }], params: { |
|
dictId: '13', |
|
}, fieldProps: { |
|
allowClear: true, |
|
mode: 'multiple', |
|
}, request: getDictValList }), _jsx(ProFormSelect, { name: "skilledWork", label: "\u4E3B\u8981\u670D\u52A1\u9879\u76EE", placeholder: "\u8BF7\u9009\u62E9\u4E3B\u8981\u670D\u52A1\u9879\u76EE", rules: [{ required: true, message: '请选择主要服务项目' }], params: { |
|
dictId: '18', |
|
}, fieldProps: { |
|
allowClear: true, |
|
mode: 'multiple', |
|
}, request: getDictValList }), _jsx(ProFormText, { name: "workYear", label: "\u4ECE\u4E8B\u5B89\u5168\u751F\u4EA7\u5DE5\u4F5C\u5E74\u9650", placeholder: "\u8BF7\u8F93\u5165\u5DE5\u4F5C\u5E74\u9650", rules: [{ required: true, message: '请输入工作年限' }] }), _jsx(ProFormTextArea, { name: "experience", label: "\u4ECE\u4E8B\u5B89\u5168\u751F\u4EA7\u5DE5\u4F5C\u7ECF\u5386", placeholder: "\u8BF7\u8F93\u5165\u5DE5\u4F5C\u7ECF\u5386", fieldProps: { |
|
maxLength: 500, |
|
showCount: true, |
|
}, rules: [{ required: true, message: '请输入工作经历' }] }), _jsx(FormUpload, { labelCol: { |
|
span: 6, |
|
}, label: "\u4E13\u5BB6\u7B7E\u540D\u56FE\u7247", name: "signAttPath", title: null, max: 1, fieldProps: { |
|
accept: 'image/*', |
|
}, params: { |
|
bizNo: params.userId || '', |
|
imgTypeName: '专家签名图片', |
|
imgType: 'RPC4100006', |
|
} })] }), _jsx(Divider, { className: "self-pro-divider" }), _jsx(CardForm, Object.assign({ title: "\u5B89\u5168\u751F\u4EA7\u4FE1\u606F", gutter: [10, 10] }, { children: _jsxs(ProFormList, Object.assign({ required: true, rules: [ |
|
{ |
|
validator: (_, names) => __awaiter(this, void 0, void 0, function* () { |
|
console.log(names); |
|
if (!names || names.length < 1) { |
|
return Promise.reject(new Error('请添加安全生产信息')); |
|
} |
|
}), |
|
}, |
|
], name: "certification", creatorButtonProps: { |
|
creatorButtonText: '添加安全生产信息', |
|
}, min: 1, colProps: { |
|
span: 24, |
|
}, copyIconProps: false, itemRender: ({ listDom, action }, { index }) => { |
|
return (_jsx(ProCard, Object.assign({ bordered: true, size: "small", style: { marginBottom: 8 }, extra: action, bodyStyle: { paddingBottom: 0 } }, { children: listDom }))); |
|
} }, { children: [_jsx(ProFormSelect, { labelCol: { |
|
span: 6, |
|
}, label: "\u8D44\u8D28\u8BC1\u660E", name: "certificationName", rules: [{ required: true }], placeholder: "\u8BF7\u9009\u62E9\u8D44\u8D28\u8BC1\u660E", fieldProps: { |
|
labelInValue: true, |
|
}, params: { |
|
dictId: '17', |
|
}, request: getDictValList }), _jsx(ProFormDependency, Object.assign({ name: ['certificationName'] }, { children: ({ certificationName }) => { |
|
if ((certificationName === null || certificationName === void 0 ? void 0 : certificationName.label) !== '其他') { |
|
return null; |
|
} |
|
return (_jsx(ProFormText, { labelCol: { |
|
span: 6, |
|
}, placeholder: "\u8BF7\u8F93\u5165\u8BC1\u4E66\u540D\u79F0", rules: [{ required: true, message: '请输入证书名称' }], label: "\u8BC1\u4E66\u540D\u79F0", name: "certificationOtherName" })); |
|
} }), "remark"), _jsx(ProFormText, { labelCol: { |
|
span: 6, |
|
}, placeholder: "\u8BF7\u8F93\u5165\u8BC1\u4E66\u7F16\u53F7", rules: [{ required: true, message: '请输入证书编号' }], label: "\u8BC1\u4E66\u7F16\u53F7", name: "certificationNumber" }), _jsx(FormUpload, { labelCol: { |
|
span: 6, |
|
}, label: "\u8D44\u8D28\u56FE\u7247", name: "certifications", rules: [{ required: true, message: '请上传资质图片' }], title: null, max: 20, fieldProps: { |
|
accept: 'image/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel', |
|
}, formItemProps: { |
|
extra: '最多上传20个附件,(支持格式:jpg,png,jpeg,pdf,word,Excel)', |
|
}, params: { |
|
bizNo: params.userId || '', |
|
imgTypeName: '专家资质证书照片', |
|
imgType: 'RPC4100005', |
|
} })] })) }))] })) })) })); |
|
}
|
|
|