diff --git a/src/pages/SitePerson/components/SitePersonModal.tsx b/src/pages/SitePerson/components/SitePersonModal.tsx new file mode 100644 index 0000000..39364bb --- /dev/null +++ b/src/pages/SitePerson/components/SitePersonModal.tsx @@ -0,0 +1,203 @@ +import React, { useEffect, useState } from 'react'; +import { Form, Input, Modal, Spin, Button, Tooltip, Radio, RadioChangeEvent } from 'antd'; +import { getSessionUserData } from '@/utils/session'; + + +interface SitePersonModalProps { + title: any; + modalVisible: boolean; + values: any; + onSubmit: any; + type: string; + onCancel: () => void; +} +const layout = { + labelCol: { span: 7 }, + wrapperCol: { span: 12 }, +}; +const SitePersonModal: React.FC = (props) => { + const [form] = Form.useForm(); + const { title, modalVisible, type, values, onSubmit: handleUpdate, onCancel } = props; + //loading + const [loading, setLoading] = useState(false); + const organizationId = getSessionUserData().organizationId; + const organizationName = getSessionUserData().organizationName; + const [value, setValue] = useState("0"); + + const onChange = (e: RadioChangeEvent) => { + console.log('radio checked', e.target.value); + setValue(e.target.value); + }; + + + + useEffect(() => { + if (JSON.stringify(values) !== "{}") { + setValue(values.bankFlag); + form.setFieldsValue({ + "id": values.id, + "accountName": values.accountName, + "cardNumber": values.cardNumber, + "bank": values.bank, + "bankOutlets": values.bankOutlets, + "bankUnionNumber": values.bankUnionNumber, + "bankFlag": values.bankFlag, + "companyId": values.companyId, + "companyName": values.companyName, + "type": values.type, + "contactName": values.contactName, + "contactPhone": values.contactPhone, + "contactMail": values.contactMail, + }); + } else { + form.setFieldsValue({ + "accountName": organizationName, + "companyId": organizationId, + "companyName": organizationName, + "type": "0", + }); + } + }, [values]) + + + + const onOk = async () => { + const fieldsValue = await form.validateFields(); + setLoading(true) + let tzsState = { + state: "1" + } + if (form.getFieldValue('bankFlag') == "0") { + fieldsValue["bank"] = "中信银行" + } + await handleUpdate({ ...fieldsValue, ...tzsState }).finally(() => { + setLoading(false) + }); + }; + + + const renderFooter = () => { + if (type == "read") { + return ( + <> + + + ); + } else { + return ( + <> + + + + ); + } + } + + return ( + onCancel()} + width={"60%"} + centered + footer={renderFooter()} + > + +
+ + + + + + + + + + + + + + 中信银行 + 其他银行 + + + {value == "1" ? + + + + : null} + + + + + + + + + + + + + + + + +
+
+
+ ); +}; + +export default SitePersonModal; diff --git a/src/pages/SitePerson/index.tsx b/src/pages/SitePerson/index.tsx new file mode 100644 index 0000000..4e45548 --- /dev/null +++ b/src/pages/SitePerson/index.tsx @@ -0,0 +1,203 @@ +import React, { useEffect, useRef, useState } from 'react'; +import ProTable, { ActionType } from '@ant-design/pro-table'; +import { getList, saveSitePerson, delAccount } from './service'; +import { Button, Card, Form, message, Spin, Popconfirm } from 'antd'; +import { getSessionUserData } from '@/utils/session'; +import SitePersonModal from './components/SitePersonModal'; + + +const SitePersonList: React.FC<{}> = () => { + const checkRelationRef = useRef(); //操作数据后刷新列表 + const [isEditModalVisible, setIsEditModalVisible] = useState(false) //控制新增或编辑模态框是否显示 + const [form] = Form.useForm();//新增模块form + // const [editForm] = Form.useForm();//编辑模块form + //单条数据 + const [editForm, setEditForm] = useState({}); + const [spinning, setSping] = useState(false);//加载遮罩 + const [accountList, setAccountList] = useState([]); //账号信息 + //是否可以新增 + const [insertDisabled, setInsertDisabled] = useState(true); + const [type, setType] = useState('cease');//弹窗类型 + const organizationId = getSessionUserData().organizationId; + let typename = "新增"; + + + const columns: any = [ + { + title: '序号', + valueType: 'index', + width: 80, + }, + // { + // title: '评标场所编号', + // dataIndex: 'eroomNum', + // }, + { + title: '评标场所名称', + dataIndex: 'eroomName', + }, + // { + // title: '人员类型', + // dataIndex: 'bank', + // }, + { + title: '人员姓名', + dataIndex: 'personName', + }, + { + title: '身份证号', + dataIndex: 'identityCard', + width: 300, + ellipsis: true, + }, + { + title: '人脸照片', + dataIndex: 'facePic', + }, + { + title: '操作', + search: false, + render: (text: any, record: any) => { + return ( + <> + setFormVals(record)}>编辑 + { delSitePerson(record.id); }} okText="确定" cancelText="取消" > 删除 + + ) + } + }, + ] + + const delSitePerson = (id: any) => { // 删除 + setSping(true); + delAccount(id).then(res => { + if (res.code == 200) { + setSping(false); + message.success('删除成功'); + setAccountList(null) + setInsertDisabled(false) + } else { + setSping(false); + form.resetFields() + } + }).finally(() => { + setSping(false); + });; + } + + // 编辑页面赋值 + const setFormVals = (item: any) => { + typename = "编辑"; + setEditForm(item); + setType("edit"); + setIsEditModalVisible(true) + setSping(false); + } + + // 新增页面 + const insertSitePerson = () => { + setType("insert"); + setIsEditModalVisible(true) + setSping(false); + } + + // 获取页面数据 + const getSitePerson = () => { + getList(organizationId).then(res => { + if (res.code === 200) { + if (res.data.length == 0) { + setInsertDisabled(false) + } + setAccountList(res.data) + } else { + setAccountList(null) + } + }) + } + + useEffect(() => { + // getSitePerson(); + }, []) + + + return ( + <> + + + + [ + ...dom.reverse(), + , + ], + }} + + request={(params) => { + let trueParams = { + ...params, + pageNo: params.current, + } + return new Promise((resolve, reject) => { + getList(trueParams).then(res => { + if (res.code === 200) { + resolve({ + data: res.data.records, + success: res.success, + total: res.data.total, + }) + } else { + resolve({ + data: [], + success: false, + total: 0, + }) + } + }) + }); + }} + pagination={{ defaultPageSize: 10, showSizeChanger: false }}//默认显示条数 + /> + + {/* 新增及编辑银行账号Modal */} + { + isEditModalVisible ? + { + await saveSitePerson(value).then((res: any) => { + if (res.success === true) { + message.success("保存成功!"); + setInsertDisabled(true) + setIsEditModalVisible(false); + setEditForm({}); + getSitePerson(); + checkRelationRef.current?.reload(); + } + }); + }} + onCancel={() => { + setIsEditModalVisible(!isEditModalVisible); + setEditForm({}); + }} + > + : null + } + + + + ); +} + +export default SitePersonList; \ No newline at end of file diff --git a/src/pages/SitePerson/service.ts b/src/pages/SitePerson/service.ts new file mode 100644 index 0000000..0d7b5b0 --- /dev/null +++ b/src/pages/SitePerson/service.ts @@ -0,0 +1,33 @@ +import request from '@/utils/request'; +/** + * 查询数据并分页 + * @param params + */ +export async function getList(params?: any) { + return request('/api/biz-service-ebtp-evaluation/v1/eval/room/site/person/page', { + method: 'get', + params, + }); +} + +/** + * 新增 + * @param params + */ +export async function saveSitePerson(data?: any) { + return request('/api/biz-service-ebtp-expenses//v1/bank/account/save', { + method: 'post', + data: data + }); +} + +/** + * 删除 + * @param params + */ +export async function delAccount(id?: any) { + return request('/api/biz-service-ebtp-expenses//v1/bank/account/del/'+id, { + method: 'post', + }); +} +