Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
1、改bug
2、打印
3、收入确认加一级区域搜索条件,列表加一级区域列
  • Loading branch information
ZreoDark committed Dec 26, 2024
1 parent 91c7b55 commit b5ae669
Show file tree
Hide file tree
Showing 19 changed files with 370 additions and 68 deletions.
4 changes: 4 additions & 0 deletions pm-resource-server/src/graphql/def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const dataTypeDef = gql`
salesLeader: String!
name: String!
customer: String
regionOneName:String
contName: String
projStatus: String
contStatus: String
Expand Down Expand Up @@ -437,6 +438,7 @@ const dataTypeDef = gql`
payState: String
expectedQuarter: String
actualQuarter: String
actualDate:String
paymentRemark: String
paymentFileList: [File]
}
Expand Down Expand Up @@ -576,6 +578,7 @@ const dataTypeDef = gql`
iLeadProjs(
isArchive: Boolean
regions: [String]
regionones: [String]
industries: [String]
projTypes: [String]
page: Int
Expand Down Expand Up @@ -975,6 +978,7 @@ const dataTypeDef = gql`
payState: [String]
expectedQuarter: [String]
actualQuarter: [String]
actualDate:String
paymentRemark: String
paymentFileList: [FileInput]
}
Expand Down
71 changes: 54 additions & 17 deletions pm-resource-server/src/graphql/resolvers/projs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
Agreement,
Customer,
IProject,
Region,
RegionOne,
} from "../../mongodb";
import { dbid2id, id2dbid, getMaxGroup } from "../../util/utils";
import { ObjectId } from "mongodb";
Expand Down Expand Up @@ -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: [
Expand All @@ -488,6 +489,7 @@ export default {

let {
regions,
regionones,
industries,
projTypes,
page,
Expand All @@ -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;
}
Expand All @@ -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)
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion pm-web-app/src/pages/Business/Agreement/Edit/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const queryGql = gql`
query (
$customersPageSize: Int
$pageSizeAgreements: Int
$pageSizeContractPaymentManages:Int
$name: String
$customer: [String]
$type: [String]
Expand Down Expand Up @@ -71,7 +72,7 @@ const queryGql = gql`
page
total
}
contractPaymentManages {
contractPaymentManages(pageSize: $pageSizeContractPaymentManages) {
result {
id
contractId
Expand Down Expand Up @@ -144,6 +145,7 @@ export function useAgreementState() {
variables: {
customersPageSize: 10000000,
pageSizeAgreements: 10000000,
pageSizeContractPaymentManages:1000000,
...query,
},
});
Expand Down
3 changes: 2 additions & 1 deletion pm-web-app/src/pages/Business/Agreement/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ const Agreement: React.FC<any> = () => {

// 获取唯一的 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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default (form: FormInstance<AgreementInput>, data?: AgreementInput) => {
<Form.Item label="付款状态" name="payState" rules={[{ required: true }]}>
<Select
defaultValue="lucy"
style={{ width: 120 }}
style={{ width: '100%' }}
onChange={(v) => {
setPayState(v);
}}
Expand All @@ -204,7 +204,7 @@ export default (form: FormInstance<AgreementInput>, data?: AgreementInput) => {
<Form.Item label="预计回款季度" name="expectedQuarter" rules={[{ required: true }]}>
<Select
defaultValue="lucy"
style={{ width: 120 }}
style={{ width: '100%' }}
fieldNames={{ label: 'name', value: 'code' }}
onChange={(v) => {
setExpectedQuarter(v);
Expand All @@ -215,18 +215,23 @@ export default (form: FormInstance<AgreementInput>, data?: AgreementInput) => {
<Form.Item label="实际回款季度" name="actualQuarter" rules={[{ required: true }]}>
<Select
defaultValue="lucy"
style={{ width: 120 }}
style={{ width: '100%' }}
fieldNames={{ label: 'name', value: 'code' }}
onChange={(v) => {
setExpectedQuarter(v);
}}
options={resData?.collectionQuarterManages.filter((item) => item.enable == true)}
/>
</Form.Item>
<Form.Item label="实际回款日期" name="actualDate" rules={[{ required: true }]} getValueProps={(value) => ({
value: value ? moment(value) : undefined,
})}>
<DatePicker format="YYYY-MM-DD" style={{ width: '100%' }} />
</Form.Item>
<Form.Item
label="资料上传"
name="paymentFileList"
rules={[{ required: true }]}
rules={[{ required: false }]}
getValueFromEvent={normFile}
>
<Upload {...props}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { gql, useLazyQuery, useMutation } from '@apollo/client';
import { useCallback, useEffect, useState } from 'react';
import axios from 'axios';
import { agreementType } from '@/pages/utils/hook';
import moment from 'moment';

const queryGql = gql`
query (
Expand Down Expand Up @@ -81,6 +82,7 @@ const queryGql = gql`
payState
expectedQuarter
actualQuarter
actualDate
paymentRemark
paymentFileList {
uid
Expand Down Expand Up @@ -215,7 +217,8 @@ export function useAgreementState() {
const payWaySub = useCallback(
async (agreement: AgreementInput) => {
let reqAgreement = await attachmentUpload(agreement);

reqAgreement.actualDate = moment(reqAgreement.actualDate).format('YYYY-MM-DD')
console.log(reqAgreement,'reqAgreement LLLLLL')
await contractPaymentSubSubHandle({
variables: {
agreement: { ...reqAgreement },
Expand Down
6 changes: 4 additions & 2 deletions pm-web-app/src/pages/Project/Edit/ChangeLeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ const ChangePm: React.FC<any> = () => {
})
};

const pageChange = (page:any) => {
const pageChange = (page:any,pageSize:any) => {
setParams({
...params,
page,
pageSize,
})
setQuery({
...query,
...params,
page,
pageSize,
})
}

Expand Down Expand Up @@ -292,7 +294,7 @@ const ChangePm: React.FC<any> = () => {
rowSelection={rowSelection}
/>
<div className="paginationCon marginTop20 lineHeight32">
<Pagination onChange={(page, pageSize)=>pageChange(page)} current={params.page} total={total} className="floatRight " />
<Pagination onChange={(page, pageSize)=>pageChange(page,pageSize)} current={params.page} total={total} className="floatRight " showSizeChanger/>
<label className="floatRight ">一共{total}</label>
</div>
<DialogForm submitHandle={onFinish} ref={ref} title="选择新的项目经理">
Expand Down
2 changes: 2 additions & 0 deletions pm-web-app/src/pages/Project/Edit/EditActive/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const queryGql = gql`
$industries: [String]
$regions: [String]
$page: Int
$pageSize:Int
$confirmYear: String
$group: String
$status: String
Expand All @@ -37,6 +38,7 @@ const queryGql = gql`
industries: $industries
regions: $regions
page: $page
pageSize:$pageSize
confirmYear: $confirmYear
group: $group
status: $status
Expand Down
8 changes: 6 additions & 2 deletions pm-web-app/src/pages/Project/Edit/EditActive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const Project: React.FC<any> = () => {
industries: [],
projTypes: [],
page: 1,
pageSize:10,
confirmYear: null,
group: [],
status: '',
Expand Down Expand Up @@ -145,15 +146,17 @@ const Project: React.FC<any> = () => {
};

// 分页器
const pageChange = (page: any) => {
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}`;
Expand Down Expand Up @@ -499,10 +502,11 @@ const Project: React.FC<any> = () => {
/>
<div className="paginationCon marginTop20 lineHeight32">
<Pagination
onChange={(page, pageSize) => pageChange(page)}
onChange={(page, pageSize) => pageChange(page,pageSize)}
current={params.page}
total={total}
className="floatRight "
showSizeChanger
/>
<label className="floatRight ">一共{total}</label>
</div>
Expand Down
Loading

0 comments on commit b5ae669

Please sign in to comment.