import React, { useState, useRef, } from 'react'; import { Button, Tabs, Form, Input, Modal, Checkbox, message, PageHeader, Popconfirm, Progress, Spin } from 'antd'; import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table'; import { getSection, exitProject, getProject, getOther, supplierRegister, exitProjectPayCheck } from './service'; import { getSupplierUser } from '@/utils/SupplierList/service' import { getProMethod, } from '@/utils/session'; import '@/assets/ld_style.less'; import { history } from 'umi'; import { followUpAProjectSupplier, getDicData } from '@/utils/session'; import { getDictName, getProjectTypeCode, getURLInformation, getUrlParam, getUrlRelativePath, isEmpty, isNotEmpty, proTableValueEnum, proTableValueEnumOther } from '@/utils/CommonUtils'; import { btnAuthority } from '@/utils/authority'; import kefu from '@/assets/img/kefu.png' //智慧客服 const { TabPane } = Tabs; const { TextArea } = Input; const CheckboxGroup = Checkbox.Group; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; const plainOptions: any[] = []; const defaultCheckedList: any[] = []; const Index: React.FC<{}> = () => { const { confirm } = Modal; const checkRelationRef = useRef(); //操作数据后刷新列表 const [personList, setPersonList] = useState([]); // 负责人列表 const [plainList, setPlainList] = useState(plainOptions); // 选择标段 const [quitVisible, setQuitVisible] = useState(false); // 退出项目弹窗按钮 const [personVisible, setPersonVisible] = useState(false); // 修改负责人弹窗按钮 const [indeterminate, setIndeterminate] = useState(false); // 复选框全选 const [checkAll, setCheckAll] = useState(false); // 复选框全选 const [checkedList, setCheckedList] = useState(defaultCheckedList); // 全选选中数组 const [sectionsVal, setSectionsVal] = useState([]); // 选中数组id const [organId, setOrganId] = useState(); // id const [projectId, setProjectId] = useState(); // id const [quitForm] = Form.useForm(); const MethodDict = getProMethod(); //获取采购方式 const modalHeight = (innerHeight * 96) / 100; //招募方式 const recruitmentMethodRecord = 'recruitment_method=record'; //存储当前页面项目类型 let proTypeCode = getProjectTypeCode(); // 项目列表url const [projectParams, setProjectParams] = useState(""); const projectName = getUrlParam("projectName"); const bidMethodDict = getURLInformation("bidMethodDict"); const current = getURLInformation("current"); //获取字典 const getDict: any = getDicData(); const dictData = JSON.parse(getDict); const actionRef = useRef(); const personColumns: ProColumns<{}>[] = [ // 修改项目负责人 { title: '姓名', dataIndex: 'empName', }, { title: '手机号', dataIndex: 'mobile', search: false, }, { title: '账号', dataIndex: 'userAccount', search: false, }, { title: '操作', dataIndex: 'action', search: false, align: 'center', render: (text: any, record: any) => ( choosePerson(record)} okText="确定" cancelText="返回" > ), }, ]; const columns: any = [ // 我参与的项目 { title: '序号', dataIndex: 'index', valueType: 'index', search: false, width: 50, }, { title: proTypeCode.indexOf("procurement_mode_4") !== -1 ? '招募方式' : '采购方式', dataIndex: 'bidMethodDict', search: proTypeCode?.length > 1 ? null : false, initialValue: bidMethodDict ? bidMethodDict : void 0, valueEnum: proTableValueEnumOther(dictData['procurement_mode=entrust'], proTypeCode), width: '7%', render: (_: any, record: any) => { if (proTypeCode.indexOf("procurement_mode_4") !== -1) { const recruitmentMethod = getDictName(dictData[recruitmentMethodRecord], record.examinationMethodDict) if (recruitmentMethod == '一次评审') { return "公开招募" } else { return "公开招募(多轮评审)" } } else { return _ } } }, { title: '项目名称', dataIndex: 'projectName', initialValue: projectName ? projectName : void 0, }, { title: '我要咨询', dataIndex: 'consult', render: (text: any, record: any) => ( {createHiddenForm(record);initChatUI()}}> ), }, { title: proTypeCode.indexOf("procurement_mode_4") !== -1 ? '招募人' : '采购人', dataIndex: 'tendereeOrgName', search: false, width: '15%' }, { title: '代理机构', dataIndex: 'tenderAgencyName', search: false, width: '15%' }, { title: '项目分类', dataIndex: 'procurementType', valueEnum: proTableValueEnum(dictData['procurement_type=entrust']), search: false, width: '5%' }, { title: '所属区域', dataIndex: 'regionDictName', search: false, width: '15%' }, { title: '操作', width: '7%', search: false, render: (text: any, record: any) => { if (MethodDict == "procurement_mode_7") { return ( ) } else { return ( <> ) } } }, ]; const otherColumns: any[] = [ // 公司其他项目 { title: '序号', dataIndex: 'index', valueType: 'index', search: false, width: 50, }, { title: '项目名称', dataIndex: 'projectName', }, { title: '采购类型', dataIndex: 'procurementTypeDict', search: false, width: '5%', valueEnum: proTableValueEnum(dictData['procurement_type=entrust']) }, { title: '采购方式', dataIndex: 'bidMethodDict', search: false, width: '7%', valueEnum: proTableValueEnum(dictData['procurement_mode=entrust']) }, { title: '已报名标段名称', dataIndex: 'bidSectName', width: '20%', search: false }, { title: '已报名标段编号', dataIndex: 'bidSectBizNum', width: '10%', search: false }, { title: '项目负责人', dataIndex: 'projectBidUser', search: false, width: '7%' }, ]; const dataSource = [ '语雀的天空', 'Ant Design', '蚂蚁金服体验科技', 'TechUI', 'TechUI 2.0', 'Bigfish', 'Umi', ].map((item) => ({ title: item, // subTitle: 语雀专栏, actions: [ 邀请, 操作, ], avatar: ( ), content: ( <>
第一个包 11
第一个包 11
), })); /** * 获取返回路径 * @returns */ const getReturnURL = () => { let projectURLParams = JSON.parse(projectParams); let params = `${'?current=' + projectURLParams.current}${isEmpty(projectURLParams.projectName) ? '' : '&projectName=' + projectURLParams.projectName}${isEmpty(projectURLParams.bidMethodDict) ? '' : '&bidMethodDict=' + projectURLParams.bidMethodDict}`; return getUrlRelativePath() + params; } const saveProject = async (val: any) => { // 点击项目跟进存储项目信息 //创建临时表单-智慧客服 createHiddenForm(val) val.returnURL = getReturnURL() await followUpAProjectSupplier(val); history.push('/ProjectLayout/Supplier/HomePageSectionList') } const changePerson = (val: any) => { // 修改负责人弹窗 setPersonVisible(true) setOrganId(val.companyId) setProjectId(val.id) } const [spin, spinSet] = useState(false); const choosePerson = async (val: any) => { // 确定修改负责人 spinSet(true); let data = { bidUserId: val.userAccount, bidUserName: val.empName, companyId: val.partnerMdmCode, projectId: projectId } await supplierRegister(data).then((res: any) => { if (res.code == 200) { message.success('修改负责人成功!') checkRelationRef.current?.reload(); setPersonVisible(false) } }); spinSet(false); } const onFinish = (val: any) => { // 校验成功确认提交 let date = { packageIdList: val.checkbox, remark: val.reason } exitProject(date).then((res: any) => { if (res.code == 200) { setQuitVisible(false) message.success('退出成功') setCheckedList([]) setIndeterminate(false) } else { setQuitVisible(false) } }) }; const onCheckAllChange = (e: any) => { // 全选 setCheckedList(e.target.checked ? sectionsVal : []); setIndeterminate(false) setCheckAll(e.target.checked) }; const onChange = (checkedList: any) => { // 多选单点 setCheckedList(checkedList) setIndeterminate(!!checkedList.length && checkedList.length < sectionsVal.length) setCheckAll(checkedList.length === sectionsVal.length) }; const quitProject = (id: any) => { // 退出项目 setQuitVisible(true) quitForm.resetFields() getSection(id).then((res: any) => { let secVals = []; if (res.success) { secVals = res.data.map((item: any) => { return item.id }) } setPlainList(res.data) setSectionsVal(secVals) }) } const showConfirm = (date: any) => { confirm({ title: date, onOk() { if (checkedList.length > 0) { //quitForm.getFieldValue().checkbox = checkedList 报错——林杰注释 quitForm.setFieldsValue({checkbox: checkedList}) } quitForm.submit() setCheckAll(false) setIndeterminate(false) setCheckedList([]) checkRelationRef.current?.reload(); }, onCancel() { setCheckAll(false) setIndeterminate(false) setCheckedList([]) setQuitVisible(false) }, }); } const submitQuit = (val: any) => { // 确定并进行校验 exitProjectPayCheck(checkedList).then((res: any) => { if(res.data && res.data != null){ showConfirm(res.data) } else { if (checkedList.length > 0) { //quitForm.getFieldValue().checkbox = checkedList 报错——林杰注释 quitForm.setFieldsValue({checkbox: checkedList}) } quitForm.submit() setCheckAll(false) setIndeterminate(false) setCheckedList([]) checkRelationRef.current?.reload(); } }) } const createHiddenForm = (record:any)=>{//智慧客服-创建临时表单 //const customerservice = REACT_APP_CUSTOMERSERVICE_USERCENTER + '&client_id=' + REACT_APP_CUSTOMERSERVICE_CLIENT_ID + '&redirect_uri=' + REACT_APP_CUSTOMERSERVICE_REDIRECT + '/redirect?page=home&mall3_token=';//智慧客服 const customerservice = REACT_APP_CUSTOMERSERVICE_USERCENTER + '&client_id=S00hFPxc&redirect_uri=http://localhost:3000/redirect?page=home&mall3_token=';//智慧客服 var tempForm = document.getElementById('tempForm_CustomerService') as HTMLFormElement if(tempForm) document.body.removeChild(tempForm); tempForm = document.createElement("form") tempForm.id="tempForm_CustomerService" tempForm.method="post" tempForm.action=customerservice + sessionStorage.getItem('Authorization') tempForm.target='_blank' const inputList = [ { paraName:'projectName', isEncode:true, defaultVal:null, }, { paraName:'projectBizNum', isEncode:false, defaultVal:null, }, { paraName:'tenderAgencyId', isEncode:false, defaultVal:null, }, { paraName:'tenderAgencyName', isEncode:true, defaultVal:null, }, { paraName:'tendereeName', isEncode:true, defaultVal:null, }, { paraName:'status', isEncode:false, defaultVal:null, }, { paraName:'ownerContactName', isEncode:true, defaultVal:null, }, { paraName:'ownerContactId', isEncode:false, defaultVal:null, }, { paraName:'ownerContactTel', isEncode:false, defaultVal:null, }, { paraName:'appManagerName', isEncode:true, defaultVal:null, }, { paraName:'appManagerId', isEncode:false, defaultVal:null, }, { paraName:'appManagerTel', isEncode:false, defaultVal:null, }, { paraName:'roleAuthority', isEncode:false, defaultVal:null, }, { paraName:'module', isEncode:false, defaultVal:'10', }, { paraName:'custType', isEncode:false, defaultVal:'2', }, ] if(inputList && inputList.length>0){ inputList.map(input=>{ var hideInput = document.createElement("input") hideInput.type="hidden" hideInput.name= input.paraName if(input.paraName=='roleAuthority'){ let roleAuthority: any | null = sessionStorage.getItem('roleAuthority'); hideInput.value = JSON.parse(roleAuthority)[0] }else{ if(input.isEncode){ hideInput.value = encodeURI(record[input.paraName]) }else{ if(input.defaultVal!=null){ hideInput.value = input.defaultVal }else{ hideInput.value = record[input.paraName] } } } tempForm.appendChild(hideInput) }) var input = document.createElement("input") input.name= 'sceneUrl' input.value= window.location.pathname tempForm.appendChild(input) document.body.appendChild(tempForm); }else{ message.warn('参数为空') } } const initChatUI = () => { //智慧客服 var tempForm = document.getElementById('tempForm_CustomerService') as HTMLFormElement if(tempForm){ tempForm.submit(); document.body.removeChild(tempForm); } } return ( <>
{/* className="pro-list" pagination={{ defaultPageSize: 10, showSizeChanger: true, }} metas={{ title: {}, subTitle: {}, type: {}, avatar: {}, content: {}, actions: {}, }} dataSource={dataSource} /> */} await getProject(params, proTypeCode).then((res) => { setProjectParams(JSON.stringify(params)); if (res.code == 200) { let data = res.data; return Promise.resolve({ data: data.records, success: res.success, total: res.data.total, current: res.data.current, }); } return Promise.resolve({ data: [], success: false, total: 0, current: 1, }); }) } search={{ filterType: "query", optionRender: (searchConfig: any, { form }) => { return [ , , ]; }, }} pagination={{ defaultCurrent: isNotEmpty(current) ? Number(current) : 1, defaultPageSize: 10, showSizeChanger: false }}//默认显示条数 toolBarRender={false} /> setPersonVisible(false)} footer={[]} centered style={{ maxHeight: modalHeight }} bodyStyle={{ maxHeight: modalHeight - 107, overflowY: 'auto' }} > size='small' actionRef={actionRef}//action触发后更新表格 columns={personColumns} request={async (params) => await getSupplierUser({ ...params, partnerMdmCode: organId, pageNum: params.current, pageSize: params.pageSize, }).then((res) => { if (res.success) { let data = res.data; setPersonList(data.records) return Promise.resolve({ data: data.records, success: res.success, total: res.data.total, current: res.data.page, }); } return Promise.resolve({ data: [], success: false, total: 0, current: 1, }); }) } pagination={{ defaultPageSize: 10, showSizeChanger: false }}//默认显示条数 dataSource={personList} toolBarRender={false} bordered /> setQuitVisible(false)} onOk={submitQuit} centered >