From b5ae6694f50bdda6a7a491acf200c49cbfd0530b Mon Sep 17 00:00:00 2001 From: 13718154103 <1161593628@qq.com> Date: Thu, 26 Dec 2024 18:47:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201=E3=80=81=E6=94=B9bug=202=E3=80=81?= =?UTF-8?q?=E6=89=93=E5=8D=B0=203=E3=80=81=E6=94=B6=E5=85=A5=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=8A=A0=E4=B8=80=E7=BA=A7=E5=8C=BA=E5=9F=9F=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9D=A1=E4=BB=B6=EF=BC=8C=E5=88=97=E8=A1=A8=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=8C=BA=E5=9F=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pm-resource-server/src/graphql/def.ts | 4 + .../src/graphql/resolvers/projs.ts | 71 +++++-- .../src/pages/Business/Agreement/Edit/hook.ts | 4 +- .../pages/Business/Agreement/Edit/index.tsx | 3 +- .../ContractPaymentManage/Edit/PayWayForm.tsx | 13 +- .../ContractPaymentManage/Edit/hook.ts | 5 +- .../pages/Project/Edit/ChangeLeader/index.tsx | 6 +- .../src/pages/Project/Edit/EditActive/hook.ts | 2 + .../pages/Project/Edit/EditActive/index.tsx | 8 +- .../src/pages/Project/Edit/EditProj/hook.ts | 18 +- .../src/pages/Project/Edit/EditProj/index.tsx | 183 +++++++++++++++++- .../Project/Edit/EstablishPro/ProjForm.tsx | 6 - .../Project/Edit/EstablishProReview/hook.ts | 4 +- .../Project/Edit/EstablishProReview/index.tsx | 9 +- .../Project/Edit/RevenueConfirm/ProjForm.tsx | 2 +- .../pages/Project/Edit/RevenueConfirm/hook.ts | 21 +- .../Project/Edit/RevenueConfirm/index.tsx | 67 +++++-- pm-web-app/src/pages/Project/View/hook.ts | 3 + pm-web-app/src/pages/Project/View/index.tsx | 9 +- 19 files changed, 370 insertions(+), 68 deletions(-) diff --git a/pm-resource-server/src/graphql/def.ts b/pm-resource-server/src/graphql/def.ts index 6b41163..0b07965 100644 --- a/pm-resource-server/src/graphql/def.ts +++ b/pm-resource-server/src/graphql/def.ts @@ -64,6 +64,7 @@ const dataTypeDef = gql` salesLeader: String! name: String! customer: String + regionOneName:String contName: String projStatus: String contStatus: String @@ -437,6 +438,7 @@ const dataTypeDef = gql` payState: String expectedQuarter: String actualQuarter: String + actualDate:String paymentRemark: String paymentFileList: [File] } @@ -576,6 +578,7 @@ const dataTypeDef = gql` iLeadProjs( isArchive: Boolean regions: [String] + regionones: [String] industries: [String] projTypes: [String] page: Int @@ -975,6 +978,7 @@ const dataTypeDef = gql` payState: [String] expectedQuarter: [String] actualQuarter: [String] + actualDate:String paymentRemark: String paymentFileList: [FileInput] } diff --git a/pm-resource-server/src/graphql/resolvers/projs.ts b/pm-resource-server/src/graphql/resolvers/projs.ts index c1763b7..ccce20d 100644 --- a/pm-resource-server/src/graphql/resolvers/projs.ts +++ b/pm-resource-server/src/graphql/resolvers/projs.ts @@ -12,6 +12,8 @@ import { Agreement, Customer, IProject, + Region, + RegionOne, } from "../../mongodb"; import { dbid2id, id2dbid, getMaxGroup } from "../../util/utils"; import { ObjectId } from "mongodb"; @@ -476,7 +478,6 @@ export default { const subordinate = await getUsersByGroups(user, maxGroup); subordinateIds = subordinate.map((subordinate) => subordinate.id); } - const filter = { isArchive: __.isArchive ? __.isArchive : false, $or: [ @@ -488,6 +489,7 @@ export default { let { regions, + regionones, industries, projTypes, page, @@ -499,21 +501,27 @@ export default { leaders, incomeConfirm, contractState, - } = __; - + } = __ if (!page || page === 0) { - page = 1; + page = 1 } if (!pageSize || pageSize === 0) { - pageSize = 10; + pageSize = 10 } - const skip = (page - 1) * pageSize; - - const regexArray: RegExp[] = []; + const skip = (page - 1) * pageSize + let regionsT = [] + let regiononesT = [] + if (regions) { + regionsT = JSON.parse(JSON.stringify(regions)) + } + if (regionones) { + regiononesT = JSON.parse(JSON.stringify(regionones)) + } + const regexArray: RegExp[] = [] if (!regions || regions.length == 0) regions = ["\\w*"]; + if (!regionones || regionones.length == 0) regionones = ["\\w*"]; if (!industries || industries.length == 0) industries = ["\\w*"]; if (!projTypes || projTypes.length == 0) projTypes = ["\\w*"]; - if (confirmYear) { filter["confirmYear"] = confirmYear; } @@ -535,16 +543,34 @@ export default { if (contractState) { filter["contractState"] = Number(contractState); } + /** + * 如果一级区域有值,二级区域没值,拿着一级区域去找二级区域的表,找出来符合的二级区域 + * 符合的二级区域合并到regions里,且去重 + */ + let newregions = [] as any + if ((regiononesT && regiononesT.length > 0) && (!regionsT || regionsT.length === 0)) { + const regions_ = await Region.find({ isDel: false, parentId: { $in: regiononesT } }) + .sort({ sort: 1 }) + .map(dbid2id) + .toArray() + const regionsCode = regions_.map(item => item.code) + newregions = [...regionsCode] + } else if ((regiononesT && regiononesT.length > 0) && (regionsT && regionsT.length > 0)) { + newregions = [...regionsT] + } + if (!newregions || newregions.length === 0) { + newregions = ['\\w*'] + } - for (let i = 0; i < regions.length; i++) { + for (let i = 0; i < newregions.length; i++) { for (let j = 0; j < industries.length; j++) { for (let k = 0; k < projTypes.length; k++) { - const regexStr = `^${industries[j]}-${regions[i]}-${projTypes[k]}-.*`; - regexArray.push(new RegExp(regexStr)); + const regexStr = `^${industries[j]}-${newregions[i]}-${projTypes[k]}-.*`; + regexArray.push(new RegExp(regexStr)) } } } - filter["_id"] = { $in: regexArray, $not: /-ZH-/ }; + filter["_id"] = { $in: regexArray, $not: /-ZH-/ } const result = await Project.find(filter) .skip(skip) .limit(pageSize) @@ -569,18 +595,29 @@ export default { await Promise.all( result.map(async (oneResult) => { + // console.dir(oneResult,{depth:null,color:true}) const customer = await Customer.findOne({ $or: [ { _id: new ObjectId(oneResult.customer) }, { _id: oneResult.customer }, ], - }); + }) + const regionTemp = await Region.findOne({code: oneResult.id.split('-')[1], // 添加查询条件 + // 其他条件(如需要) + isDel: false,}) + const regionOneTemp = await RegionOne.findOne({ + $or: [ + { _id: new ObjectId(regionTemp?.parentId) }, + ], + }) + // console.dir(regionOneTemp,{depth:null,color:true}) + if(regionOneTemp) oneResult.regionOneName = regionOneTemp.name if (customer) oneResult.customerObj = dbid2id(customer); - }) - ); + }), + ) const total = await Project.countDocuments(filter); - + console.dir(result,{depth:null,color:true}) return { result, page, diff --git a/pm-web-app/src/pages/Business/Agreement/Edit/hook.ts b/pm-web-app/src/pages/Business/Agreement/Edit/hook.ts index 14cb8a9..d847e85 100644 --- a/pm-web-app/src/pages/Business/Agreement/Edit/hook.ts +++ b/pm-web-app/src/pages/Business/Agreement/Edit/hook.ts @@ -15,6 +15,7 @@ const queryGql = gql` query ( $customersPageSize: Int $pageSizeAgreements: Int + $pageSizeContractPaymentManages:Int $name: String $customer: [String] $type: [String] @@ -71,7 +72,7 @@ const queryGql = gql` page total } - contractPaymentManages { + contractPaymentManages(pageSize: $pageSizeContractPaymentManages) { result { id contractId @@ -144,6 +145,7 @@ export function useAgreementState() { variables: { customersPageSize: 10000000, pageSizeAgreements: 10000000, + pageSizeContractPaymentManages:1000000, ...query, }, }); diff --git a/pm-web-app/src/pages/Business/Agreement/Edit/index.tsx b/pm-web-app/src/pages/Business/Agreement/Edit/index.tsx index 570b8b2..cf46db3 100644 --- a/pm-web-app/src/pages/Business/Agreement/Edit/index.tsx +++ b/pm-web-app/src/pages/Business/Agreement/Edit/index.tsx @@ -107,7 +107,8 @@ const Agreement: React.FC = () => { // 获取唯一的 payName(假设所有 payName 相同) const payName = filteredData.length > 0 ? filteredData[0].payWayName : null; - + console.log(data,'data PPPPP') + console.log(targetContId,'targetContId PPPPP') // 转换数据格式 const milestone = filteredData.map((item:any) => ({ id: item.id.toString(), diff --git a/pm-web-app/src/pages/Business/ContractPaymentManage/Edit/PayWayForm.tsx b/pm-web-app/src/pages/Business/ContractPaymentManage/Edit/PayWayForm.tsx index f610b8b..7730a05 100644 --- a/pm-web-app/src/pages/Business/ContractPaymentManage/Edit/PayWayForm.tsx +++ b/pm-web-app/src/pages/Business/ContractPaymentManage/Edit/PayWayForm.tsx @@ -193,7 +193,7 @@ export default (form: FormInstance, data?: AgreementInput) => { { setExpectedQuarter(v); @@ -215,7 +215,7 @@ export default (form: FormInstance, data?: AgreementInput) => { { label="确认季度" name="confirmQuarter" rules={[{ required: false }]} - getValueProps={(value) => ({ - value: value ? moment(value) : undefined, - })} > { return gql` - query ($isArchive: Boolean,$industries: [String],$regions:[String],$projTypes:[String],$page:Int,$confirmYear:String,$group:String,$status:String,$name:String,$agreementPageSize:Int,$contractState:String,$incomeConfirm:String) { + query ($isArchive: Boolean,$industries: [String],$regions:[String],$regionones:[String],$projTypes:[String],$page:Int,$pageSize:Int,$confirmYear:String,$group:String,$status:String,$name:String,$agreementPageSize:Int,$contractState:String,$incomeConfirm:String) { subordinates { id name @@ -46,14 +46,28 @@ const getGql = (proName: string) => { name enable } + regionones{ + id + code + name + enable + } + regions{ + id + code + name + enable + parentId + } - ${proName}(isArchive: $isArchive,industries:$industries,regions:$regions,projTypes:$projTypes,page:$page,confirmYear:$confirmYear,group:$group,status:$status,name:$name,contractState:$contractState,incomeConfirm:$incomeConfirm){ + ${proName}(isArchive: $isArchive,industries:$industries,regions:$regions,regionones:$regionones,projTypes:$projTypes,page:$page,pageSize:$pageSize,confirmYear:$confirmYear,group:$group,status:$status,name:$name,contractState:$contractState,incomeConfirm:$incomeConfirm){ result{ id pId name contName customer + regionOneName leader salesLeader projStatus @@ -136,6 +150,7 @@ const getGql = (proName: string) => { remark isDel createDate + } } page @@ -449,5 +464,7 @@ export function useProjStatus() { query, getTodoList, todoProjsTotal, + regionones:queryData?.regionones || [], + regions:queryData?.regions || [] }; } diff --git a/pm-web-app/src/pages/Project/Edit/RevenueConfirm/index.tsx b/pm-web-app/src/pages/Project/Edit/RevenueConfirm/index.tsx index 71835ae..9260b9f 100644 --- a/pm-web-app/src/pages/Project/Edit/RevenueConfirm/index.tsx +++ b/pm-web-app/src/pages/Project/Edit/RevenueConfirm/index.tsx @@ -56,6 +56,8 @@ const Project: React.FC = () => { incomeConfirmProj, agreements, projectAgreements, + regionones, + regions, } = useProjStatus(); const { status, orgCode, zoneCode, projType, buildProjName, groupType } = useBaseState(); const editHandle = (proj: Proj, openRef: any) => { @@ -74,7 +76,7 @@ const Project: React.FC = () => { title: '项目ID', dataIndex: 'id', key: 'id', - fixed: 'left', + fixed: 'left' as 'left', render: (text: string, record: Proj) => (
editHandle(record, ref)}>{buildProjName(record.id, record.name)} @@ -82,6 +84,16 @@ const Project: React.FC = () => { ), width: 250, }, + //regionOneName + { + title: '一级区域', + dataIndex: 'regionOneName', + key: 'regionOneName', + render: (text: string, record: Proj) => { + return record.regionOneName || '---'; + }, + width: 100, + }, { title: '合同状态', dataIndex: 'contractState', @@ -181,7 +193,12 @@ const Project: React.FC = () => { render: (contractSignDate: string, record: Proj) => { let contract = projectAgreements.filter((item) => item.id == record.id); let amount = agreements?.result.filter((item) => item.id == contract[0]?.agreementId); - return moment(amount[0]?.contractSignDate).format('YYYY-MM-DD'); + if(amount.length > 0){ + return moment(amount[0]?.contractSignDate).format('YYYY-MM-DD'); + } else{ + return '---' + } + }, width: 100, }, @@ -260,23 +277,29 @@ const Project: React.FC = () => { //=====zhouyueyang const [params, setParams] = useState({ regions: [], + regionones:[], industries: [], projTypes: [], page: 1, + pageSize:10, confirmYear: null, group: [], status: '', name: '', contractState: '', acceptanceStatus: '', - confirmYear: '', incomeConfirm: '', }); const handleChange = (value = '', type: string) => { + if(type == 'regionones'){ + // console.log(regions.filter(item=>value.includes(item.parentId)),'JJJKKK') + let options_ = regions.filter(item=>value.includes(item.parentId)) + setZoneCodeOptions(options_) + } setParams({ ...params, [type]: - type !== 'regions' && type !== 'industries' && type !== 'projTypes' ? String(value) : value, + type !== 'regions' && type !== 'regionones' && type !== 'industries' && type !== 'projTypes' ? String(value) : value, }); }; const handleChangeCas = (value: any, type: string) => { @@ -297,12 +320,13 @@ const Project: React.FC = () => { name, }); }; - const pageChange = (page: any) => { - setParams({ ...params, page }); + const pageChange = (page: any,pageSize:any) => { + setParams({ ...params, page,pageSize }); setQuery({ ...query, ...params, page, + pageSize, group: params.group.length !== 0 ? params.group.reduce((accumulator: string, currentValue: string) => { return `${accumulator}/${currentValue}`; @@ -331,6 +355,7 @@ const Project: React.FC = () => { setParams({ ...params, regions: [], + regionones:[], industries: [], projTypes: [], page: 1, @@ -345,6 +370,7 @@ const Project: React.FC = () => { ...query, ...params, regions: [], + regionones:[], industries: [], projTypes: [], page: 1, @@ -383,9 +409,7 @@ const Project: React.FC = () => { const [orgCodeOptions] = useState( Object.keys(orgCode).map((s) => ({ label: orgCode[s], value: s })), ); - const [zoneCodeOptions] = useState( - Object.keys(zoneCode).map((s) => ({ label: zoneCode[s], value: s })), - ); + const [zoneCodeOptions,setZoneCodeOptions] = useState([]); const [projTypeOptoins] = useState( Object.keys(projType).map((s) => ({ label: projType[s], value: s })), ); @@ -524,20 +548,32 @@ const Project: React.FC = () => { options={orgCodeOptions} /> + + + - (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) - } + fieldNames={{label:'name',value:'id'}} value={params.regions} mode="multiple" allowClear className="width120" placeholder="请选择" onChange={(value: any, event) => handleChange(value, 'regions')} - options={zoneCodeOptions} + options={zoneCodeOptions?.filter(item=>item.enable == true)} /> @@ -642,14 +678,17 @@ const Project: React.FC = () => { scroll={{ x: 1000 }} pagination={false} size="middle" + /> {/*
*/}
pageChange(page)} + pageSizeOptions={[1,2,3]} + onChange={(page, pageSize) => pageChange(page,pageSize)} current={params.page} total={total} className="floatRight " + showSizeChanger />
diff --git a/pm-web-app/src/pages/Project/View/hook.ts b/pm-web-app/src/pages/Project/View/hook.ts index c0557b6..86f1350 100644 --- a/pm-web-app/src/pages/Project/View/hook.ts +++ b/pm-web-app/src/pages/Project/View/hook.ts @@ -24,6 +24,7 @@ const queryGql = gql` $regions: [String] $projTypes: [String] $page: Int + $superProjsPageSize:Int $confirmYear: String $group: String $status: String @@ -76,6 +77,7 @@ const queryGql = gql` regions: $regions projTypes: $projTypes page: $page + pageSize:$superProjsPageSize confirmYear: $confirmYear group: $group status: $status @@ -226,6 +228,7 @@ export function useProjStatus() { variables: { isArchive: archive, ...query, + superProjsPageSize:query.pageSize, pageAgreements: 1, pageSizeAgreements: 10000000, pageSize: 100000000, diff --git a/pm-web-app/src/pages/Project/View/index.tsx b/pm-web-app/src/pages/Project/View/index.tsx index 597f27b..705e6fb 100644 --- a/pm-web-app/src/pages/Project/View/index.tsx +++ b/pm-web-app/src/pages/Project/View/index.tsx @@ -96,6 +96,7 @@ const Project: React.FC = (props) => { industries: [], projTypes: [], page: 1, + pageSize:10, confirmYear: null, group: [], status: '', @@ -137,8 +138,8 @@ const Project: React.FC = (props) => { page: 1, }); }; - const pageChange = (page: any) => { - setParams({ ...params, page }); + const pageChange = (page: any,pageSize:any) => { + setParams({ ...params, page ,pageSize}); let obj = { group: params.group.length !== 0 ? params.group.reduce((accumulator: string, currentValue: string) => { return `${accumulator}/${currentValue}`; @@ -148,6 +149,7 @@ const Project: React.FC = (props) => { ...query, ...params, page, + pageSize, ...obj, }); }; @@ -508,10 +510,11 @@ const Project: React.FC = (props) => { />
pageChange(page)} + onChange={(page, pageSize) => pageChange(page,pageSize)} current={params.page} total={total} className="floatRight " + showSizeChanger />