Pārlūkot izejas kodu

沟通:修改表单

liqianyi 2 gadi atpakaļ
vecāks
revīzija
ff25cf4af3

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

@@ -119,6 +119,16 @@
               align="center"
               label="备注">
             </el-table-column>
+            <el-table-column
+              fixed="right"
+              header-align="center"
+              align="center"
+              width="80"
+              label="操作">
+              <template slot-scope="scope">
+                <el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.productId)">删除</el-button>
+              </template>
+            </el-table-column>
           </el-table>
         </el-row>
         <el-row v-if="!display" style="text-align: center; margin-top: 10px;">
@@ -131,18 +141,20 @@
       <el-button v-if="!display" type="primary" @click="dataFormSubmit()">确定</el-button>
     </span>
   <!-- </el-dialog> -->
-   <template-chose v-if="inboundVisible" ref="inbound" @addItems="addItems" />
+<!--   <template-chose v-if="inboundVisible" ref="inbound" @addItems="addItems" />-->
+  <add-or-update v-if="inboundVisible"  ref="inbound" @addItem="addItem" />
 </div>
 </template>
 
 <script>
-  import templateChose from '../product/template-chose'
+  // import templateChose from '../product/template-chose'
   import { getCustomer, getCoDetail } from '@/api/cus'
-  import uploadComponent from '../common/upload-component'
   import { getDictList } from '@/api/dict'
+  import uploadComponent from '../common/upload-component'
+  import AddOrUpdate from '../product/template-add-or-update'
   export default {
     name: 'communicate-add-or-update',
-    components: {templateChose, uploadComponent},
+    components: {AddOrUpdate, uploadComponent},
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }
@@ -219,12 +231,7 @@
             if (data.data.cusRCommProductVOS) {
               data.data.cusRCommProductVOS.forEach((item) => {
                 this.cusRCommProductVOS.push({
-                  cnt: item.cnt,
-                  price: item.price,
-                  productId: item.productId,
-                  rate: item.rate,
-                  productName: item.productName,
-                  notes: item.notes
+                  ...item
                 })
               })
             }
@@ -258,7 +265,7 @@
               this.dataForm.cusRCommProductVOS = this.cusRCommProductVOS
             }
             this.$http({
-              url: this.$http.adornUrl(`/biz-service/cusCommunication/save`),
+              url: !this.id ? this.$http.adornUrl(`/biz-service/cusCommunication/save`) : this.$http.adornUrl(`/biz-service/cusCommunication/update`),
               method: 'post',
               data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
             }).then(({data}) => {
@@ -289,19 +296,11 @@
         })
       },
       addItem (item) {
+        if (!item.productId) {
+          item.productId = Math.round(Math.random() * 1000000)
+        }
         this.cusRCommProductVOS.push({
-          cnt: 1,
-          price: 0,
-          productId: item.productId,
-          rate: 0,
-          productName: item.productName,
-          notes: item.notes
-        })
-      },
-      addItems (items) {
-        this.cusRCommProductVOS = []
-        items.forEach((item) => {
-          this.addItem(item)
+          ...item
         })
       },
       uploadSuccess (fileList) {
@@ -309,6 +308,10 @@
       },
       typeChanged (item) {
         this.detailVisible = item === '1'
+      },
+      // 删除产品项
+      deleteProductHandle (productId) {
+        this.cusRCommProductVOS.splice(this.cusRCommProductVOS.findIndex((item) => item.productId === productId))
       }
     }
   }

+ 91 - 0
src/views/modules/product/template-add-or-update.vue

@@ -0,0 +1,91 @@
+<template>
+  <el-dialog
+    :title="!isModify ? '新增':'修改'"
+    width="70%"
+    :close-on-click-modal="false"
+    :visible.sync="visible">
+    <div class="product-template">
+      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
+        <el-row class="my-row">
+          <el-form-item label="产品名称" prop="productName">
+            <el-input v-model="dataForm.productName" placeholder="产品名称"></el-input>
+          </el-form-item>
+        </el-row>
+        <el-row class="my-row">
+          <el-form-item label="规格" prop="productSpecifications">
+            <el-input v-model="dataForm.productSpecifications" placeholder="规格"></el-input>
+          </el-form-item>
+        </el-row>
+        <el-row class="my-row">
+          <el-form-item label="数量" prop="cnt">
+            <el-input-number v-model="dataForm.cnt"></el-input-number>
+          </el-form-item>
+        </el-row>
+        <el-row class="my-row">
+          <el-form-item label="含税单价" prop="price">
+            <el-input-number v-model="dataForm.price" :step="1" :min="0" :precision="1"></el-input-number>
+          </el-form-item>
+        </el-row>
+        <el-row class="my-row">
+          <el-form-item label="税率" prop="rate">
+            <el-input-number style="width: 160px" v-model="dataForm.rate" :step="1" :precision="1"/>&nbsp;%
+          </el-form-item>
+        </el-row>
+        <el-row class="my-row">
+          <el-form-item label="备注" prop="notes">
+            <el-input type="textarea" v-model="dataForm.notes" placeholder="备注"></el-input>
+          </el-form-item>
+        </el-row>
+      </el-form>
+      <span slot="footer">
+          <el-button @click="onChose">取消</el-button>
+          <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
+        </span>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  export default {
+    name: 'template-add-or-update',
+    data () {
+      return {
+        visible: false,
+        isModify: false,
+        dataForm: {},
+        dataRule: {
+          productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
+          productSpecifications: [{ required: true, message: '规格不能为空', trigger: 'blur' }],
+          cnt: [{ required: true, message: '数量不能为空', trigger: 'blur' }]
+        }
+      }
+    },
+    methods: {
+      onChose () {
+        this.visible = false
+      },
+      init (dataForm) {
+        if (dataForm) {
+          this.isModify = true
+          this.dataForm = dataForm
+        } else {
+          this.dataForm.productId = Math.round(Math.random() * 1000000)
+        }
+        this.visible = true
+      },
+      // 表单提交
+      dataFormSubmit () {
+        this.$refs['dataForm'].validate((valid) => {
+          if (valid) {
+            this.visible = false
+            this.$emit('addItem', this.dataForm)
+          }
+        })
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 0 - 1
src/views/modules/tech/product-add-or-update.vue

@@ -480,7 +480,6 @@ export default {
             }
             this.$http({
               url: !this.id ? this.$http.adornUrl(`/biz-service/product/save`) : this.$http.adornUrl(`/biz-service/product/update`),
-              // url: this.$http.adornUrl(`/biz-service/product/save`),
               method: 'post',
               data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
             }).then(({data}) => {