|
@@ -1,6 +1,11 @@
|
|
|
<script setup lang="ts">
|
|
|
import { useMutation } from '@tanstack/vue-query'
|
|
|
-import { getContractMilestoneList } from '@/service/contract'
|
|
|
+import {
|
|
|
+ getContractMilestoneList,
|
|
|
+ addContractMilestone,
|
|
|
+ updateContractMilestone,
|
|
|
+ deleteContractMilestoneList
|
|
|
+} from '@/service/contract'
|
|
|
|
|
|
/**
|
|
|
* 项目合同里程碑
|
|
@@ -25,11 +30,17 @@ watch(
|
|
|
const contractMilestoneList = ref<any>()
|
|
|
const { mutate: getContractMilestoneListMutate } = useMutation(getContractMilestoneList, {
|
|
|
onSuccess: (data: any) => {
|
|
|
- contractMilestoneList.value = data
|
|
|
+ contractMilestoneList.value = data.map((item) => {
|
|
|
+ item['type'] = 2
|
|
|
+ return item
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
const addClickHandle = () => {
|
|
|
contractMilestoneList.value.push({
|
|
|
+ type: 1, // 1 新增/编辑 2 查看
|
|
|
+ id: '',
|
|
|
+ contractId: '',
|
|
|
name: '',
|
|
|
returnAmount: '',
|
|
|
actualReturnAmount: '',
|
|
@@ -37,14 +48,41 @@ const addClickHandle = () => {
|
|
|
description: ''
|
|
|
})
|
|
|
}
|
|
|
+const saveContractMilestone = (item) => {
|
|
|
+ if (item['type'] === 2) {
|
|
|
+ item['type'] = 1
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item['contractId'] = props.contractId
|
|
|
+ item['actualReturnAmount'] = parseFloat(item['actualReturnAmount'])
|
|
|
+ if (item['id'] === '') {
|
|
|
+ addContractMilestone(item).then((result) => {
|
|
|
+ item['type'] = 2
|
|
|
+ item['id'] = result
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ updateContractMilestone(item).then((result) => {
|
|
|
+ item['type'] = 2
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+const message = useMessage()
|
|
|
+const removeContractMilestone = (item, index) => {
|
|
|
+ deleteContractMilestoneList([item['id']]).then((result) => {
|
|
|
+ if (result) {
|
|
|
+ message.error('删除成功!')
|
|
|
+ contractMilestoneList.value.splice(index, 1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="tableBox tableLineBox">
|
|
|
<h4 class="td_title"><i class="icon"></i>合同里程碑</h4>
|
|
|
- <!-- <div class="add_box">
|
|
|
+ <div class="add_box">
|
|
|
<el-button type="primary" @click="addClickHandle">新增</el-button>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
<table>
|
|
|
<thead>
|
|
|
<tr>
|
|
@@ -55,22 +93,48 @@ const addClickHandle = () => {
|
|
|
<th>已回款金额(元)</th>
|
|
|
<th>预计到款时间</th>
|
|
|
<th>说明</th>
|
|
|
- <!-- <th>操作</th> -->
|
|
|
+ <th>操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
<tr v-for="(item, index) in contractMilestoneList" :key="index">
|
|
|
<td>{{ index + 1 }}</td>
|
|
|
- <td>{{ item['name'] }}</td>
|
|
|
+ <td>
|
|
|
+ <el-input type="text" :disabled="item['type'] === 2" v-model="item['name']" />
|
|
|
+ </td>
|
|
|
<td>{{ ((item['returnAmount'] / (contractAmount || 1)) * 100).toFixed(0) }}%</td>
|
|
|
- <td>{{ item['returnAmount'] }}</td>
|
|
|
- <td>{{ item['actualReturnAmount'] }}</td>
|
|
|
- <td>{{ item['planReturnTime'] }}</td>
|
|
|
- <td>{{ item['description'] }}</td>
|
|
|
- <!-- <td style="width: 120px">
|
|
|
- <el-button type="primary" size="small">编辑</el-button>
|
|
|
- <el-button type="danger" size="small">删除</el-button>
|
|
|
- </td> -->
|
|
|
+ <td>
|
|
|
+ <el-input type="text" :disabled="item['type'] === 2" v-model="item['returnAmount']" />
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <el-input
|
|
|
+ type="text"
|
|
|
+ :disabled="item['type'] === 2"
|
|
|
+ v-model="item['actualReturnAmount']"
|
|
|
+ />
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <el-date-picker
|
|
|
+ style="width: 100%"
|
|
|
+ v-model="item.planReturnTime"
|
|
|
+ type="date"
|
|
|
+ :disabled="item['type'] === 2"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ :clearable="false"
|
|
|
+ placeholder="请选择预计到款时间"
|
|
|
+ />
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <el-input type="text" :disabled="item['type'] === 2" v-model="item['description']" />
|
|
|
+ </td>
|
|
|
+ <td style="width: 120px">
|
|
|
+ <el-button type="primary" size="small" @click="saveContractMilestone(item)">
|
|
|
+ {{ item['type'] === 1 ? '保存' : '编辑' }}
|
|
|
+ </el-button>
|
|
|
+ <el-button type="danger" size="small" @click="removeContractMilestone(item, index)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
+ </td>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|