Jelajahi Sumber

合同台账

chris 3 tahun lalu
induk
melakukan
3b7604f5de

+ 2 - 2
src/views/modules/cus/communicate-add-or-update.vue

@@ -81,8 +81,8 @@
               label="数量"
               width="170">
               <template slot-scope="scope">
-                 <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;"/>
-              </template>
+              <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;"/>
+            </template>
             </el-table-column>
             <el-table-column
               prop="price"

+ 51 - 18
src/views/modules/cus/contract-record-add-or-update.vue

@@ -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)
+        })
       }
     }
   }

+ 8 - 5
src/views/modules/cus/contract-record-product-add-or-update.vue

@@ -55,7 +55,7 @@ export default {
   data () {
     return {
       visible: false,
-      isAdd: true,
+      isAdd: false,
       dataForm: {
         cnt: 1,
         price: 1,
@@ -72,8 +72,10 @@ export default {
   methods: {
     async init (row) {
       this.visible = true
-      this.isAdd = !!row
-      if (!row) return
+      if (!row) {
+        this.isAdd = true
+        return
+      }
       this.dataForm = row
     },
     validateField (type) {
@@ -86,13 +88,14 @@ export default {
     dataFormSubmit () {
       this.$refs['dataForm'].validate((valid) => {
         if (valid) {
-          if (this.isAdd) {
+          if (this.isAdd === true) {
+            console.log('1')
             this.dataForm.productId = Math.round(Math.random() * 1000000)
           }
           // 计算含税总价
           this.dataForm.amount = (this.dataForm.cnt * this.dataForm.price).toFixed(1)
           this.onChose()
-          this.$emit('addItem', this.dataForm)
+          this.$emit('changeItem', this.dataForm)
         }
       })
     }