|
@@ -28,10 +28,11 @@
|
|
|
<div class="tableBox tableBox—first">
|
|
|
<h4><i class="icon"></i>基本信息</h4>
|
|
|
<ul>
|
|
|
- <li>编辑合同</li>
|
|
|
+ <li v-if="editor === false" @click="handleEdit">编辑合同</li>
|
|
|
+ <li v-else @click="saveContractHandle">保存合同</li>
|
|
|
<li>用款申请</li>
|
|
|
- <li>分包申请</li>
|
|
|
- <li>外包申请</li>
|
|
|
+ <li @click="handleStartSubcontract">分包申请</li>
|
|
|
+ <li @click="handleStartOutsourcing">外包申请</li>
|
|
|
</ul>
|
|
|
<table>
|
|
|
<tr>
|
|
@@ -293,17 +294,32 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import request from '@/config/axios'
|
|
|
+import { useRoute } from 'vue-router'
|
|
|
import UserOrgTree from '@/views/OaSystem/components/UserOrgTree/index.vue'
|
|
|
import ContractMilestone from '@/views/OaSystem/projectCenter/projectDetail/components/xmht/ContractMilestone.vue'
|
|
|
import ContractReturnedMoney from '@/views/OaSystem/projectCenter/projectDetail/components/xmht/ContractReturnedMoney.vue'
|
|
|
import ContractSharing from '@/views/OaSystem/projectCenter/projectDetail/components/xmht/ContractSharing.vue'
|
|
|
+import {
|
|
|
+ getContractsByProject,
|
|
|
+ putContract,
|
|
|
+ startOutsourcing,
|
|
|
+ startSubcontract
|
|
|
+} from '@/service/contract'
|
|
|
+import { useQuery, useMutation } from '@tanstack/vue-query'
|
|
|
+import { ref } from 'vue'
|
|
|
+import { openFlow } from '@/utils/flow'
|
|
|
|
|
|
defineOptions({ name: 'XmhtComp' })
|
|
|
const _mainProjectId: any = useRoute().query.id
|
|
|
// 合同id ??是否存在
|
|
|
const _toContractId = useRoute().query.contractId
|
|
|
const editor = ref<Boolean>(false)
|
|
|
+const contractDetail = ref()
|
|
|
+
|
|
|
+const handleEdit = () => {
|
|
|
+ console.log('handleEdit: ')
|
|
|
+ editor.value = true
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 切换子项目信息
|
|
@@ -312,81 +328,52 @@ const contractInfoIndex = ref<number>(0)
|
|
|
const switchContractInfo = (item: any, key: number): void => {
|
|
|
contractInfoIndex.value = key
|
|
|
}
|
|
|
+
|
|
|
/***
|
|
|
* 查询主合同和子合同详情数据
|
|
|
* **/
|
|
|
-const contractDetail = ref({
|
|
|
- id: '',
|
|
|
- children: [] as any
|
|
|
-})
|
|
|
-
|
|
|
-watch(contractDetail, () => {
|
|
|
- console.log('contractDetail change: ', contractDetail)
|
|
|
-})
|
|
|
-
|
|
|
-function queryContractWithChildByList(): void {
|
|
|
- const urlApi = `/contract-with-children`
|
|
|
- const sendData = {
|
|
|
- projectId: _mainProjectId
|
|
|
- }
|
|
|
- request.get({ url: urlApi, params: sendData }, '/business').then((resultData) => {
|
|
|
- // contractDetail.value = resultData
|
|
|
- console.log('queryContractWithChildByList: ', resultData)
|
|
|
- contractDetail.value = { id: resultData['id'] ?? '', children: [{}] }
|
|
|
- if (resultData) {
|
|
|
- // queryContractMilestoneByList(resultData['id'])
|
|
|
- // queryContractRMoneyByList(resultData['id'])
|
|
|
- // queryContractPaymentByList(resultData['id'])
|
|
|
- // queryContractSharingByList(resultData['id'])
|
|
|
+const { refetch } = useQuery(
|
|
|
+ [getContractsByProject.name, unref(_mainProjectId)],
|
|
|
+ async () => await getContractsByProject(unref(_mainProjectId)),
|
|
|
+ {
|
|
|
+ onSuccess: (tData) => {
|
|
|
+ contractDetail.value = tData
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function queryContract(): void {
|
|
|
- const urlApi = `/contract`
|
|
|
- const sendData = {
|
|
|
- id: _toContractId
|
|
|
}
|
|
|
- request.get({ url: urlApi, params: sendData }, '/business').then((resultData) => {
|
|
|
- contractDetail.value = resultData
|
|
|
- // queryContractMilestoneByList(resultData['id'])
|
|
|
- // queryContractRMoneyByList(resultData['id'])
|
|
|
- // queryContractPaymentByList(resultData['id'])
|
|
|
- // queryContractSharingByList(resultData['id'])
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-if (_toContractId) {
|
|
|
- queryContract()
|
|
|
-} else {
|
|
|
- queryContractWithChildByList()
|
|
|
-}
|
|
|
+)
|
|
|
|
|
|
-//@ts-ignore
|
|
|
-const invoiceTypeMap = {
|
|
|
- '1': '增值税专用发票',
|
|
|
- '2': '增值税普通发票',
|
|
|
- '3': '服务业通用机打发票',
|
|
|
- '4': '统一收款收据'
|
|
|
-}
|
|
|
-const invoiceTypeFilter: (val: number | string) => string = (val: number | string): string => {
|
|
|
- if (!val) return ''
|
|
|
- return invoiceTypeMap[val.toString()]
|
|
|
-}
|
|
|
/**
|
|
|
* 编辑保存合同信息
|
|
|
* **/
|
|
|
-const saveContractHandle = (): void => {
|
|
|
- const urlApi = `/contract`
|
|
|
- request.put({ url: urlApi, data: contractDetail.value }, '/business').then((resultData) => {
|
|
|
- if (resultData) {
|
|
|
- ElMessage({
|
|
|
- message: '保存合同成功',
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
+const { mutate: saveContract } = useMutation(putContract, {
|
|
|
+ onMutate: () => {
|
|
|
+ editor.value = false
|
|
|
+ },
|
|
|
+ onSuccess: () => {
|
|
|
+ void refetch()
|
|
|
+ ElMessage({
|
|
|
+ message: '保存合同成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+const saveContractHandle = () => saveContract(contractDetail.value)
|
|
|
+
|
|
|
+/**
|
|
|
+ * 发起分包合同申请
|
|
|
+ */
|
|
|
+const { mutate: startSubcontractMutate } = useMutation(startSubcontract, {
|
|
|
+ onSuccess: (data) => openFlow(data)
|
|
|
+})
|
|
|
+const handleStartSubcontract = () => startSubcontractMutate(contractDetail.value.id)
|
|
|
+
|
|
|
+/**
|
|
|
+ * 发起外合同申请
|
|
|
+ */
|
|
|
+const { mutate: startOutsourcingMutate } = useMutation(startOutsourcing, {
|
|
|
+ onSuccess: (data) => openFlow(data)
|
|
|
+})
|
|
|
+const handleStartOutsourcing = () => startOutsourcingMutate(contractDetail.value.id)
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
@import './index.scss';
|