Merge pull request 'feat: 合同方案租金表添加修改校验' (#625) from fix_contract_plan_lease_save_check into dev
Reviewed-on: daoyoucloud/tachycode#625
This commit is contained in:
		
						commit
						5d45a4b34c
					
				
							
								
								
									
										5
									
								
								.changeset/modern-chicken-compare.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								.changeset/modern-chicken-compare.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
---
 | 
			
		||||
"@hera/plugin-rental": patch
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
修改合同方案租赁明细表的添加校验
 | 
			
		||||
@ -71,14 +71,14 @@ export class ContractRuleService {
 | 
			
		||||
    if (!options.values?.contract_plan && !options.values?.products) return;
 | 
			
		||||
    const plan = await this.db.getRepository('contract_plans').findOne({
 | 
			
		||||
      where: {
 | 
			
		||||
        id: options.values.contract_plan.id,
 | 
			
		||||
        id: options.values?.contract_plan?.id || options.values?.contract_plan_id,
 | 
			
		||||
      },
 | 
			
		||||
      appends: ['lease_items', 'lease_items.products'],
 | 
			
		||||
    });
 | 
			
		||||
    const add = options.values.products;
 | 
			
		||||
    const productData = plan.lease_items.map((item) => item.products).flat();
 | 
			
		||||
    const productData = plan.lease_items.filter(item => item.id !== options.values.id && item.products.length === add.length).map((item) => item.products).flat()
 | 
			
		||||
    productData.forEach((item) => {
 | 
			
		||||
      const isHas = add.find((p) => p.raw_category_id === item.raw_category_id);
 | 
			
		||||
      const isHas = add.find((p) => (p.id < 99999 && (p.id === item.id || (item.id > 99999 && p.raw_category_id === item.raw_category_id))) || (p.id > 99999 && p.raw_category_id === item.raw_category_id));
 | 
			
		||||
      if (isHas) {
 | 
			
		||||
        throw new Error('方案中存在此产品');
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user