Prechádzať zdrojové kódy

Merge branch 'master' of http://47.107.53.207:3000/ymy/oms

AlanWong 2 rokov pred
rodič
commit
7cf10e04fd

+ 9 - 1
src/api/omsOrder.ts

@@ -208,4 +208,12 @@ export function editFreight(data:any){
 		method:'POST',
 		data:data
 	})
-}
+}
+//编辑商品
+export const batchItem:any = (data:any) => {
+	return request({
+		url:'/omsOrder/omsOrder/batchItem',
+		method:'POST',
+		data:data
+	})
+}  

+ 1 - 1
src/benyun/components/byInput/byInput.vue

@@ -62,7 +62,7 @@ export default class ByInput extends VueViews {
     if(this.attrs.placeholder){
       return this.attrs.placeholder
     }
-    return '请输入内容'
+    return ''
   }
   mounted(){
   }

+ 84 - 12
src/views/oms/order/components/addOrder.vue

@@ -44,7 +44,7 @@
           </div>
           <by-form v-if="showPay" :propConfig="payConfig" ref="payform"></by-form>
           <div class="pay-row" v-if="showPay && orderValue.status != 'Split' && orderValue.status != 'Merged' && orderValue.status != 'Cancelled'">
-            <el-button type="primary" size="mini" @click="addPay">添加</el-button>
+            <el-button type="primary" size="small" @click="addPay">添加</el-button>
           </div>
           <div class="pay-info">
             <el-descriptions v-for="(item,index) of orderValue.pays" :key="index" :title="item.payment" size="mini" :column="4">
@@ -60,31 +60,36 @@
         </el-collapse-item>
         <el-collapse-item title="商品订单" name="3" class="add-order-item">
           <div class="addProductTool">
-            <by-tool :propConfig="toolConfig"></by-tool>
+            <by-tool :propConfig="toolConfig" ref="tool"></by-tool>
             <div class="preferential">
               <div class="pre-title">抵扣金额<i class="el-icon-info" title="支持输入数字和百分比。若输入百分比,将自动计算折扣金额=商品成交总金额*百分比(举例:打9折,请输入10%),
                 只在订单创建时计算一次,在订单创建后修改商品价格不会自动计算,运费不参与折扣。"></i>:</div>
-              <vxe-input v-model="freeAmount" class="freeAmount" placeholder="请输入" type="number" size="mini" @input="freeAmountChange"></vxe-input>
+              <vxe-input v-if="!orderValue.id" v-model="freeAmount" class="freeAmount" placeholder="请输入" type="number" size="mini" @change="freeAmountChange"></vxe-input>
+              <span v-else>{{ freeAmount }}</span>
             </div>
           </div>
           
           <by-table :propConfig="tableConfig" ref="table">
-            <!-- <template v-slot:t_cont='{ row }'>
+            <template v-slot:name='{ row }'>
               <div class="product-cont">
-                <div class="product-name">{{ row.name }}</div>
-                <div class="other-info">
+                <div class="product-name">{{ row.name }}<el-tag v-if="row.isGift == 1" size="mini" type="success">赠</el-tag></div>
+                <!-- <div class="other-info">
                   <span>{{ row.styleId }}</span>
                   <span>{{ row.skuId }}</span>
                   <el-tag v-if="row.isGift == 1" size="mini" type="success">赠</el-tag>
-                </div>
+                </div> -->
               </div>
-            </template> -->
+            </template>
             <template v-slot:qty='{ row }'>
-              <vxe-input v-model="row.qty" placeholder="数量" align="center" size="mini" type="integer" @input="qtyChange($event, row)"></vxe-input>
+              <vxe-input v-model="row.qty" v-if="!orderValue.id" placeholder="数量" align="center" size="mini" type="integer" @input="qtyChange($event, row)" >
+              </vxe-input>
+              <span v-else>{{ row.qty }}</span>
             </template>
             <template v-slot:price='{ row }'>
               <span v-if="row.isGift == 1">0</span>
-              <vxe-input v-else v-model="row.price" placeholder="单价" align="center" size="mini" type="number" @input="priceChange($event, row)"></vxe-input>
+              <vxe-input v-else-if="!orderValue.id" v-model="row.price" placeholder="单价" align="center" size="mini" type="number" @input="priceChange($event, row)" >
+              </vxe-input>
+              <span v-else>{{ row.price }}</span>
             </template>
           </by-table>
           <div class="product-row">
@@ -138,6 +143,7 @@
       <product-sku-modal ref="product" :mulit="true" @confirm="confirmProduct" />
       <product-sku-modal ref="productGift" :mulit="true" @confirm="confirmProductGift" />
       <add-product-modal ref="addProductModal" @handleSuccess="handleSuccess" />
+      <edit-product-modal ref="editProductModal" @handleSuccess="handleSuccess" />
     </template>
     <template #footer v-if="!orderValue.id">
       <div class="btn">
@@ -151,10 +157,11 @@
 </template>
 <script lang="ts">
 import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-import { addOrder,saveBaseOrder,single,delItem,addPay } from '@/api/omsOrder'
+import { addOrder,saveBaseOrder,single,delItem,addPay,batchItem } from '@/api/omsOrder'
 import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
 import AddProductModal from "./addProductModal.vue";
-@Component({components:{AddProductModal}})
+import EditProductModal from "./editProductModal.vue";
+@Component({components:{AddProductModal,EditProductModal}})
 export default class AddOrder extends Vue {
   value=false;
   num:any=0;
@@ -479,6 +486,7 @@ export default class AddOrder extends Vue {
     columns:[{
       title:'名称',
       field:'name',
+      slot:true,
       width:300
     },{
       title:'数量',
@@ -852,6 +860,42 @@ export default class AddOrder extends Vue {
   created(){
     this.userInfo = this.$store.getters.userInfo;
   }
+  //编辑商品
+  updataProduct(){
+    let data = (this.$refs.table as any).getValue();
+    let parames:any={};
+    parames.id = this.orderValue.id;
+    parames.freeAmount = this.freeAmount;
+    parames.addItems=[];
+    parames.addGifts=[];
+    parames.delItems=[];
+    parames.freight=10;
+    parames.isPay = false;
+    for(const item of data){
+      if(item.__status == 'modify'){
+        if(item.isGift == 1){
+          parames.addGifts.push({
+            itemId:item.id,
+            qty:item.qty,
+            price:0
+          })
+        }else{
+          parames.addItems.push({
+            itemId:item.id,
+            qty:item.qty,
+            price:0
+          })
+        }
+      }
+    }
+    this.load = true;
+    batchItem(parames).then(()=>{
+      this.load = false;
+      this.handleSuccess();
+    }).catch(()=>{
+      this.load = false;
+    })
+  }
   handleSuccess(){
     this.$emit('handleSuccess');
     this.getData();
@@ -920,10 +964,25 @@ export default class AddOrder extends Vue {
       this.load = false
     })
   }
+  //商品编辑
+  editProduct(){
+    let tableValue = (this.$refs.table as any).getValue();
+    let formValue = (this.$refs.baseform as any).getValue();
+    let newValue:any = {};
+    newValue.freight = formValue.freight;
+    newValue.freeAmount = this.freeAmount;
+    newValue.isPay = false;
+    (this.$refs.editProductModal as any).setShow(true);
+    (this.$refs.editProductModal as any).setFormValue(newValue);
+    (this.$refs.setTableValue as any).setFormValue(tableValue);
+  }
   show(){
     this.baseConfig = (this as any).$lodash.cloneDeep(this.config);
     this.buyerInfoConfig = (this as any).$lodash.cloneDeep(this.config2);
     this.newInvoicesConfig = (this as any).$lodash.cloneDeep(this.invoicesConfig);
+    if(this.$refs.tool){
+      (this.$refs.tool as any).initTools();
+    }
     if(this.orderValue.id){
       let data = this.orderValue;
       this.freeAmount = this.orderValue.freeAmount;
@@ -962,6 +1021,13 @@ export default class AddOrder extends Vue {
       //商品
       const productData:Array<any> = data.items ? data.items : [];
       (this.$refs.table as any).setValue(productData);
+      (this.$refs.tool as any).setCustomTools([{
+        name: '商品编辑', icon: 'el-icon-edit', event:{
+          click:()=>{
+            this.editProduct()
+          }
+        }
+      }])
       //付款
       this.orderValue.isPay = data.isPay;
       if(this.orderValue.isPay != 0 || this.orderValue.isPay != 1){
@@ -1464,6 +1530,12 @@ export default class AddOrder extends Vue {
     background-color: #198cf8;
   }
 }
+.updata-btn-row{
+  width: 100%;
+  display: flex;
+  justify-content: flex-end;
+  padding-bottom: 8px;
+}
 </style>
 
 <style lang="scss">

+ 162 - 0
src/views/oms/order/components/editProductModal.vue

@@ -0,0 +1,162 @@
+<template>
+  <vxe-modal v-model="value" id="editProductModal" width="70%" height="80%" @hide="hide" title="商品编辑" transfer show-footer v-loading="load">
+    <by-form :propConfig="form" ref="form">
+      <template v-slot:isPay="{value}">
+        <el-switch
+          v-model="value.isPay">
+        </el-switch>
+      </template>
+    </by-form>
+    <by-table :propConfig="tableConfig" ref="table">
+      <template v-slot:name='{ row }'>
+        <div class="product-cont">
+          <div class="product-name">{{ row.name }}<el-tag v-if="row.isGift == 1" size="mini" type="success">赠</el-tag></div>
+        </div>
+      </template>
+      <template v-slot:qty='{ row }'>
+        <vxe-input v-model="row.qty" placeholder="数量" align="center" size="mini" type="integer" @input="qtyChange($event, row)" >
+        </vxe-input>
+      </template>
+      <template v-slot:price='{ row }'>
+        <span v-if="row.isGift == 1">0</span>
+        <vxe-input v-else v-model="row.price" placeholder="单价" align="center" size="mini" type="number" @input="priceChange($event, row)" >
+        </vxe-input>
+      </template>
+    </by-table>
+    <template #footer>
+      <div class="btn">
+        <el-button type="primary" size="small" @click="btn">确定</el-button>
+      </div>
+    </template>
+  </vxe-modal>
+</template>
+
+<script lang="ts">
+import { Component, Prop, Vue, Watch } from "vue-property-decorator";
+import { multiply } from '@/benyun/utils/accuracy'
+@Component
+export default class EditProductModal extends Vue {
+  value=false;
+  load = false;
+  form:any={
+    attr:{
+      size:'small'
+    },
+    columns:[
+      [{
+        label:'运费',
+        prop:'freight',
+        labelWidth:'80px',
+        component:'by-input',
+        compConfig:{
+          attr:{
+            placeholder:'保留两位小数',
+            type:'number'
+          }
+        }
+      },{
+        label:'抵扣金额',
+        prop:'freeAmount',
+        labelWidth:'100px',
+        component:'by-input',
+        compConfig:{
+          attr:{
+            placeholder:'保留两位小数',
+            type:'number'
+          }
+        }
+      },{
+        label:'快速支付',
+        prop:'isPay',
+        slot:true
+      }]
+    ]
+  }
+  tableConfig:any={
+    attr:{
+      size:'small',
+      align:'center',
+    },
+    columns:[{
+      title:'名称',
+      field:'name',
+      slot:true,
+      width:300
+    },{
+      title:'数量',
+      field:'qty',
+      width:100,
+      slot:true
+    },{
+      title:'单价',
+      field:'price',
+      width:100,
+      slot:true
+    },{
+      title:'原价',
+      field:'basePrice',
+      width:100
+    },{
+      title:'成交金额',
+      field:'amount',
+      width:100
+    },
+
+    {
+      title:'操作',
+      action:true,
+      plugins:[{
+        icon:'el-icon-delete',
+        name:'删除',
+        audit:'',
+        event:{
+          click:(item:any) => {
+            
+          }
+        }
+      }]
+    }]
+  }
+  hide(){}
+  setShow(v:boolean){
+    this.value = v;
+  }
+  setFormValue(v:any){
+    this.$nextTick(()=>{
+      if(this.$refs.form){
+        (this.$refs.form as any).setValue(v)
+      }
+    })
+  }
+  setTableValue(v:any){
+    this.$nextTick(()=>{
+      if(this.$refs.table){
+        (this.$refs.table as any).setValue(v);
+      }
+    })
+  }
+  //数量的变化
+  qtyChange(v:any,row:any){
+    if(v.value && row.price){
+      row.amount = multiply(Number(v.value),Number(row.price))
+    }else{
+      row.amount = 0
+    }
+  }
+  //单价的变化
+  priceChange(v:any,row:any){
+    if(v.value && row.qty){
+      row.amount =multiply(Number(v.value),Number(row.qty))
+    }else{
+      row.amount = 0
+    }
+  }
+  btn(){
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>