Kaynağa Gözat

1 沟通:修改
2 订单:修改

chris 2 yıl önce
ebeveyn
işleme
ea730b9bc3

+ 2 - 1
src/views/modules/common/product-component.vue

@@ -101,7 +101,8 @@
         if (item === 'undefined') {
           this.value = null
         }
-        this.$emit('productSelected', item)
+        let obj = this.options.find((t) => t.value === item)
+        this.$emit('productSelected', obj)
       },
       cancelReadOnly (onOff) {
         this.$nextTick(() => {

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

@@ -72,20 +72,24 @@
               prop="productName"
               header-align="center"
               align="center"
+              min-width="120"
+              :show-tooltip-when-overflow="true"
               label="产品名称">
             </el-table-column>
             <el-table-column
               prop="productSpecifications"
               header-align="center"
               align="center"
+              min-width="120"
+              :show-tooltip-when-overflow="true"
               label="规格">
             </el-table-column>
             <el-table-column
               prop="cnt"
               header-align="center"
               align="center"
-              label="数量"
-              width="170">
+              min-width="160"
+              label="数量">
               <template slot-scope="scope">
               <el-input-number v-model="scope.row.cnt" :disabled="display" :min="1" style="width: 140px;"/>
             </template>
@@ -94,6 +98,7 @@
               prop="price"
               header-align="center"
               align="center"
+              min-width="160"
               label="含税单价">
               <template slot-scope="scope">
                 <el-input-number v-model="scope.row.price" :disabled="display" :precision="1" :step="0.1" :min="0" style="width: 140px;"/>
@@ -103,6 +108,7 @@
               prop="amount"
               header-align="center"
               align="center"
+              min-width="100"
               label="含税总价">
               <template slot-scope="scope">
                 <span>{{ (scope.row.cnt*scope.row.price).toFixed(1) }}</span>
@@ -112,6 +118,7 @@
               prop="rate"
               header-align="center"
               align="center"
+              min-width="120"
               label="税率">
               <template slot-scope="scope">
                 <el-input type="number" v-model="scope.row.rate" :disabled="display">
@@ -123,6 +130,8 @@
               prop="notes"
               header-align="center"
               align="center"
+              width="120"
+              :show-tooltip-when-overflow="true"
               label="备注">
             </el-table-column>
             <el-table-column
@@ -132,7 +141,7 @@
               width="80"
               label="操作">
               <template slot-scope="scope">
-                <el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.productId)">删除</el-button>
+                <el-button style="color: red" type="text" size="small" @click="deleteProductHandle(scope.row.recordId)">删除</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -300,8 +309,8 @@
         })
       },
       addItem (item) {
-        if (!item.productId) {
-          item.productId = Math.round(Math.random() * 1000000)
+        if (!item.recordId) {
+          item.recordId = Math.round(Math.random() * 1000000)
         }
         this.cusRCommProductVOS.push({
           ...item
@@ -314,8 +323,8 @@
         this.detailVisible = item === '1'
       },
       // 删除产品项
-      deleteProductHandle (productId) {
-        this.cusRCommProductVOS.splice(this.cusRCommProductVOS.findIndex((item) => item.productId === productId))
+      deleteProductHandle (recordId) {
+        this.cusRCommProductVOS.splice(this.cusRCommProductVOS.findIndex((item) => item.recordId === recordId))
       }
     }
   }

+ 46 - 48
src/views/modules/order/order-add-or-update.vue

@@ -95,6 +95,14 @@
               :show-tooltip-when-overflow="true"
               label="产品名称">
             </el-table-column>
+            <el-table-column
+              prop="productSpecifications"
+              header-align="center"
+              align="center"
+              min-width="120"
+              :show-tooltip-when-overflow="true"
+              label="规格">
+            </el-table-column>
             <el-table-column
               prop="cnt"
               header-align="center"
@@ -142,7 +150,7 @@
               min-width="130"
               label="税率">
               <template slot-scope="scope">
-                <el-input type="number" v-model="scope.row.rateVal" :disabled="display">
+                <el-input type="number" v-model="scope.row.rate" :disabled="display">
                   <template slot="append">%</template>
                 </el-input>
               </template>
@@ -152,9 +160,27 @@
               header-align="center"
               align="center"
               width="120"
-              :show-overflow-tooltip="true"
+              :show-tooltip-when-overflow="true"
               label="备注">
             </el-table-column>
+            <el-table-column
+              prop="relatedProduct"
+              header-align="center"
+              align="center"
+              width="120"
+              :show-tooltip-when-overflow="true"
+              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.recordId)">删除</el-button>
+              </template>
+            </el-table-column>
           </el-table>
           <el-row style="text-align: center; margin-top: 10px;">
             <el-button v-show="!display" type="primary" icon="el-icon-plus" @click="addProduct"></el-button>
@@ -166,22 +192,23 @@
           <el-button v-if="!display" type="primary" @click="dataFormSubmit()">确定</el-button>
         </span>
     <!-- </el-dialog> -->
-    <template-chose v-if="productListVisible" ref="productList" @addItems="addProductItems" />
+    <add-or-update v-if="productListVisible"  ref="productList" @addItem="addItem" />
   </div>
 </template>
 
 <script>
-  import templateChose from '../product/template-chose'
+  // import templateChose from '../product/template-chose'
   import { getOrderDetail } from '@/api/sale'
   import UserComponent from '../common/user-component'
-  import {toNumber, toPercent} from '@/utils/common'
+  import {toNumber} from '@/utils/common'
   import UploadComponent from '../common/upload-component'
   import { dealStepData, dealStepLogs } from '@/api/util'
   import CusComponent from '../common/cus-component'
+  import AddOrUpdate from '../product/template-add-or-update'
 
   export default {
     name: 'order-add-or-update',
-    components: {CusComponent, UploadComponent, UserComponent, templateChose},
+    components: {CusComponent, UploadComponent, UserComponent, AddOrUpdate},
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }
@@ -242,16 +269,7 @@
           // 订单产品明细
             if (data.data.saleROrderProductList) {
               data.data.saleROrderProductList.forEach((item) => {
-                this.productDetails.push({
-                  id: item.id,
-                  productId: item.productId,
-                  productName: item.productName,
-                  notes: item.notes,
-                  cnt: item.cnt,
-                  price: item.price,
-                  productNumber: item.productNumber,
-                  rateVal: toPercent(item.rate)
-                })
+                this.addItem(item)
               })
             }
           }
@@ -260,43 +278,19 @@
       uploadSuccess (fileList) {
         this.fileList = fileList
       },
-      // 添加组合产品
+      // 添加订单产品明细
       addProduct () {
         this.productListVisible = true
         this.$nextTick(() => {
-          this.$refs.productList.init()
+          this.$refs.productList.init(2)
         })
       },
-      addProductItem (item) {
+      addItem (item) {
+        if (!item.recordId) {
+          item.recordId = Math.round(Math.random() * 1000000)
+        }
         this.productDetails.push({
-          productId: item.productId,
-          productName: item.productName,
-          notes: item.notes,
-          cnt: 1,
-          price: 0,
-          rate: 0
-        })
-      },
-      addProductItems (items) {
-        this.productDetails = []
-        items.forEach((item) => {
-          this.addProductItem(item)
-        })
-      },
-      addMaterial () {
-        this.materialListVisible = true
-        this.$nextTick(() => {
-          this.$refs.materialList.init()
-        })
-      },
-      addMaterialItem (item) {
-        this.materialList.push({
-          materialId: item.materialId,
-          materialName: item.materialName,
-          specifications: item.specifications,
-          cnt: item.cnt,
-          unitName: item.unitName,
-          notes: item.notes
+          ...item
         })
       },
       validateField (type) {
@@ -330,7 +324,7 @@
               return
             }
             this.$http({
-              url: this.$http.adornUrl(`/biz-service/order/save`),
+              url: !this.id ? this.$http.adornUrl(`/biz-service/order/save`) : this.$http.adornUrl(`/biz-service/order/update`),
               method: 'post',
               data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
             }).then(({data}) => {
@@ -354,6 +348,10 @@
       // 业务员选择变化
       salesmanChanged (val) {
         this.dataForm.salesmanId = val
+      },
+      // 删除产品项
+      deleteProductHandle (recordId) {
+        this.productDetails.splice(this.productDetails.findIndex((item) => item.recordId === recordId))
       }
     }
   }

+ 15 - 2
src/views/modules/product/template-add-or-update.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog
     :title="!isModify ? '新增':'修改'"
-    width="70%"
+    width="50%"
     :close-on-click-modal="false"
     :visible.sync="visible">
     <div class="product-template">
@@ -36,6 +36,11 @@
             <el-input type="textarea" v-model="dataForm.notes" placeholder="备注"></el-input>
           </el-form-item>
         </el-row>
+        <el-row class="my-row" v-if="bizType === 2">
+          <el-form-item label="产品关联" prop="relatedProductId">
+            <product-component v-model="dataForm.relatedProductId + ''" @productSelected="prodSelected"/>
+          </el-form-item>
+        </el-row>
       </el-form>
       <span slot="footer">
           <el-button @click="onChose">取消</el-button>
@@ -46,12 +51,16 @@
 </template>
 
 <script>
+  import ProductComponent from '@/views/modules/common/product-component'
+
   export default {
     name: 'template-add-or-update',
+    components: {ProductComponent},
     data () {
       return {
         visible: false,
         isModify: false,
+        bizType: 1,
         dataForm: {},
         dataRule: {
           productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
@@ -66,11 +75,12 @@
       },
       // 初始化:type: 1 沟通产品明细,2 订单产品明细
       init (type, dataForm) {
+        this.bizType = type
         if (dataForm) {
           this.isModify = true
           this.dataForm = dataForm
         } else {
-          this.dataForm.productId = Math.round(Math.random() * 1000000)
+          this.dataForm.recordId = Math.round(Math.random() * 1000000)
         }
         this.visible = true
       },
@@ -82,6 +92,9 @@
             this.$emit('addItem', this.dataForm)
           }
         })
+      },
+      prodSelected (item) {
+        this.dataForm.relatedProduct = item.label
       }
     }
   }