|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <div class="my-title">{{ !id ? '新增' : '修改' }}</div>
|
|
|
+ <div class="my-title">{{ !id?'新增':'修改' }}</div>
|
|
|
<!-- 表单 -->
|
|
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
|
|
|
<el-row class="my-row">
|
|
@@ -54,7 +54,7 @@
|
|
|
<el-row v-if="isProductListVisible">
|
|
|
<div class="title"><span style="color: red">*</span> 产品列表</div>
|
|
|
<el-table
|
|
|
- :data="productList"
|
|
|
+ :data="dataForm.cusCBookProducts"
|
|
|
border
|
|
|
style="width: 100%;">
|
|
|
<el-table-column
|
|
@@ -111,13 +111,13 @@
|
|
|
width="150"
|
|
|
label="操作">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" size="small" @click="addOrUpdateProductHandle(scope.row)">编辑</el-button>
|
|
|
+ <el-button type="text" size="small" @click="updateProductHandle(scope.row)">编辑</el-button>
|
|
|
<el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.productId)">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<el-row style="text-align: center; margin-top: 10px;">
|
|
|
- <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateProductHandle()"></el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" @click="addProductHandle()"></el-button>
|
|
|
</el-row>
|
|
|
</el-row>
|
|
|
<el-row class="my-row">
|
|
@@ -128,12 +128,14 @@
|
|
|
<el-button @click="onChose">取消</el-button>
|
|
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
</span>
|
|
|
- <add-or-update-product v-if="productAddOrUpdateVisible" ref="productDialog" @addItem="addItem"/>
|
|
|
+ <add-or-update-product v-if="productUpdateVisible" ref="productDialog"/>
|
|
|
+ <template-chose v-if="inboundVisible" ref="inbound" @addItems="addItems" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import UploadComponent from '../common/upload-component'
|
|
|
+ import TemplateChose from '../product/template-chose'
|
|
|
import AddOrUpdateProduct from './contract-record-product-add-or-update'
|
|
|
import { getReviewCodeList, geContractBookDetail, getCommunicationList } from '@/api/cus'
|
|
|
|
|
@@ -141,6 +143,7 @@ export default {
|
|
|
name: 'contract-record-add-or-update',
|
|
|
components: {
|
|
|
UploadComponent,
|
|
|
+ TemplateChose,
|
|
|
AddOrUpdateProduct
|
|
|
},
|
|
|
computed: {
|
|
@@ -155,7 +158,7 @@ export default {
|
|
|
getCommunicationList(d.coId).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.isProductListVisible = true
|
|
|
- this.productList = data.data
|
|
|
+ this.dataForm.cusCBookProducts = data.data
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -167,12 +170,10 @@ export default {
|
|
|
fileList: [],
|
|
|
dataList: [],
|
|
|
isProductListVisible: false, // 产品列表是否显示
|
|
|
- productAddOrUpdateVisible: false, // 产品新增或修改对话框是否显示
|
|
|
- productList: [], // 产品列表
|
|
|
+ productUpdateVisible: false, // 产品修改对话框是否显示
|
|
|
+ inboundVisible: false, // 产品新增对话框是否显示
|
|
|
id: 0,
|
|
|
- dataForm: {
|
|
|
- displayProductList: false
|
|
|
- },
|
|
|
+ dataForm: {},
|
|
|
dataRule: {
|
|
|
reCode: [{ required: true, message: '请选择合同评审编码', trigger: 'change' }],
|
|
|
contractNumber: [{ required: true, message: '合同号不能为空', trigger: 'blur' }],
|
|
@@ -198,6 +199,7 @@ export default {
|
|
|
})
|
|
|
// 详情
|
|
|
if (!id) return
|
|
|
+ this.isProductListVisible = true
|
|
|
await geContractBookDetail(this.id).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.dataForm = data.data
|
|
@@ -238,6 +240,7 @@ export default {
|
|
|
this.$message.error('请上传文件')
|
|
|
return
|
|
|
}
|
|
|
+ // 产品明细
|
|
|
this.$http({
|
|
|
url: this.$http.adornUrl(`/biz-service/cusContractBook/${!this.id ? 'save' : 'update'}`),
|
|
|
method: 'post',
|
|
@@ -262,23 +265,53 @@ export default {
|
|
|
},
|
|
|
// 删除产品项
|
|
|
deleteProductHandle (productId) {
|
|
|
- this.productList.splice(this.productList.findIndex((item) => item.productId === productId))
|
|
|
+ this.dataForm.cusCBookProducts.splice(this.dataForm.cusCBookProducts.findIndex((item) => item.productId === productId))
|
|
|
},
|
|
|
- // 添加或编辑产品
|
|
|
- addOrUpdateProductHandle (row) {
|
|
|
- this.productAddOrUpdateVisible = true
|
|
|
+ // 编辑产品
|
|
|
+ updateProductHandle (row) {
|
|
|
+ this.productUpdateVisible = true
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.productDialog.init(row)
|
|
|
})
|
|
|
},
|
|
|
- addItem (item) {
|
|
|
+ // 添加产品
|
|
|
+ addProductHandle () {
|
|
|
+ this.inboundVisible = true
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.inbound.init()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ changeItem (item) {
|
|
|
if (!item) return
|
|
|
- this.productAddOrUpdateVisible = false
|
|
|
- let i = this.productList.findIndex((item1) => item1.productId === item.productId)
|
|
|
+ this.productUpdateVisible = false
|
|
|
+ let i = this.dataForm.cusCBookProducts.findIndex((item1) => item1.productId === item.productId)
|
|
|
if (i > -1) {
|
|
|
this.productList.splice(i)
|
|
|
}
|
|
|
this.productList.push(item)
|
|
|
+ },
|
|
|
+ addItem (item) {
|
|
|
+ if (!item) return
|
|
|
+ let i = this.dataForm.cusCBookProducts.findIndex((item1) => item1.productId === item.productId)
|
|
|
+ if (i > -1) {
|
|
|
+ this.dataForm.cusCBookProducts.splice(i)
|
|
|
+ }
|
|
|
+ this.dataForm.cusCBookProducts.push({
|
|
|
+ cnt: 1,
|
|
|
+ price: 0,
|
|
|
+ productId: item.productId,
|
|
|
+ rate: 0,
|
|
|
+ productName: item.productName,
|
|
|
+ notes: item.notes
|
|
|
+ })
|
|
|
+ },
|
|
|
+ addItems (items) {
|
|
|
+ if (!this.dataForm.cusCBookProducts) {
|
|
|
+ this.dataForm.cusCBookProducts = []
|
|
|
+ }
|
|
|
+ items.forEach((item) => {
|
|
|
+ this.addItem(item)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|