浏览代码

feat: 合同劳务接口接入

lanjianrong 4 年之前
父节点
当前提交
234388fba0

+ 4 - 1
src/pages/Contract/Content/Income/components/Modal/api.ts

@@ -1,4 +1,5 @@
 import request from '@/utils/common/request'
+import consts from '@/utils/consts'
 
 /**
  * 获得标段回款-项目节信息
@@ -10,7 +11,7 @@ export async function apiContractIncome(bidsectionId: string) {
 }
 
 /**
- *
+ * 设置模板
  * @param templateNumber 模板号
  * @param bidsectionId 标段id
  * @param treeType 项目节类型(0收入1支出)默认为0
@@ -19,3 +20,5 @@ export async function apiSetTemplate(templateNumber: string, bidsectionId: strin
   const { data } = await request.post('/api/contract/section/template', { templateNumber: parseInt(templateNumber), bidsectionId, treeType: treeType })
   return data
 }
+
+

+ 49 - 6
src/pages/Contract/Content/Income/components/Modal/index.tsx

@@ -2,17 +2,51 @@ import Authorization from '@/components/Authorization'
 import DatePicker from '@/components/DatePicker'
 import { contractReturnStore, tenderStore } from '@/store/mobx'
 import { iModalCommonProps } from '@/types/contract'
+import { apiContractSection } from '@/utils/common/api'
+import { contractTreeBaseId } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { dayjsFormat, handleAutoCode } from '@/utils/util'
-import { Button, Form, Input, Modal, Select, Tree } from 'antd'
+import { Button, Form, Input, Modal, Select, Tree, TreeSelect } from 'antd'
 import locale from 'antd/es/date-picker/locale/zh_CN'
 import dayjs from 'dayjs'
 import React, { ChangeEvent, useEffect, useState } from 'react'
 import { apiGetReturnWay } from '../Tabs/Receivable/api'
 import styles from './index.module.scss'
+
+interface ContractSection {
+  id: string;
+  treeType: number;
+  parentId: string;
+  name: string;
+  depth: number;
+  serial: number;
+  attribution: string;
+  code: string;
+  projectId: string;
+  bidsectionId: string;
+  contractId: string;
+  contractName: string;
+  contractCode: string;
+  contractPrice: string;
+  contractReturned: string;
+  contractsPaid: string;
+  contractStatus: number;
+  contractLocking: number;
+  createTime: string;
+  children?: any;
+  templateNumber: number;
+  operation: string;
+  elderBrother: boolean;
+  isEnd: boolean;
+  key: string;
+  title: string;
+}
+
 const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible, confirmLoading, contractType }, onConfirm, onCancel, reload, row }) => {
   const { Option } = Select
+  const [ contractSection, setContractSection ] = useState<ContractSection[]>([])
   const [ form ] = Form.useForm()
+
   const [ options, setOptions ] = useState<string[]>([])
   const modalObj = {
     create: {
@@ -47,9 +81,18 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
     }
   }
 
+  const initTreeSection = async () => {
+    const { code = -1, sectionTree: data = {} } = await apiContractSection(tenderStore.bid, consts.CONTRACT_TREE.RETURN)
+    if (code === consts.RET_CODE.SUCCESS) {
+      setContractSection(data.children)
+    }
+  }
+
   useEffect(() => {
     if (visible) {
-      form.setFieldsValue({ treeId: row.id, bidsectionId: row.bidsectionId })
+      initTreeSection()
+      form.setFieldsValue({ treeId: row.contractId !== contractTreeBaseId ? row.id : '', bidsectionId: row.bidsectionId })
+
       if (type === 'update') {
         const { content = '', name = '', price = '', partyA = '', partyB = '', partyASigner = '', partyBSigner = '', signerTime = '', remarks = '' } = contractReturnStore.contract
         form.setFieldsValue({ content, name, price, partyA, partyB, partyASigner, partyBSigner, signerTime: signerTime ? dayjs(signerTime) : '', remarks })
@@ -134,12 +177,12 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
         <Form.Item name="bidsectionId" hidden>
           <Input />
         </Form.Item>
+        <Form.Item name="treeId" label="合同劳务">
+          <TreeSelect treeData={contractSection} />
+        </Form.Item>
         {/* <Form.Item name="treeId" label="合同劳务" hidden>
-          <Tree showLine={true} treeData={contractReturnStore.tree} />
-        </Form.Item> */}
-        <Form.Item name="treeId" label="合同劳务" hidden>
           <Input />
-        </Form.Item>
+        </Form.Item> */}
         {type === 'create' ? (
           <>
             <Form.Item name="code" label="合同编号" rules={[ { required: true, message: '请输入合同编号' } ]} className={styles.contractFormItem}>

+ 10 - 0
src/utils/common/api.ts

@@ -1,4 +1,5 @@
 import { iFile } from "@/types/file"
+import consts from "../consts"
 import request from "./request"
 
 /**
@@ -83,3 +84,12 @@ export async function apiAutoCode(bidsectionId: string, type: string) {
   return data
 }
 
+/**
+ * 获取项目节(不包括合同)
+ * @param bidsectionId 标段id
+ * @param treeType 树类型
+ */
+export async function apiContractSection(bidsectionId: string, treeType: number) {
+  const { data } = await request.get('/api/contract/section/not', { bidsectionId, treeType })
+  return data
+}