Kaynağa Gözat

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

AlanWong 2 yıl önce
ebeveyn
işleme
113a969182

+ 24 - 0
src/api/omsOrder.ts

@@ -168,4 +168,28 @@ export function addGift(data:any){
 		method:'POST',
 		data:data
 	})
+}
+//批量添加商品
+export function addItem(data:any){
+	return request({
+		url:'/omsOrder/omsOrder/addItem',
+		method:'POST',
+		data:data
+	})
+}
+//单条数据
+export function single(data:any){
+	return request({
+		url:'/omsOrder/omsOrder/single',
+		method:'GET',
+		params:data
+	})
+}
+//删除商品
+export function delItem(data:any){
+	return request({
+		url:'/omsOrder/omsOrder/delItem',
+		method:'POST',
+		params:data
+	})
 }

+ 7 - 1
src/benyun/utils/request.ts

@@ -25,7 +25,13 @@ service.interceptors.request.use((config:any) => {
   // 是否需要设置 token
   const isToken = (config.headers || {}).isToken === false
   // 是否需要防止数据重复提交
-  const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
+  const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
+  //获取用户信息
+  const user = store.getters.userInfo;
+  //设置租户id
+  if(user.tenantId){
+    config.headers['Tenantid'] = user.tenantId
+  }
   if (getToken() && !isToken) {
     config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
 		config.headers['tenantId'] = '000000';

+ 91 - 28
src/views/oms/order/components/addOrder.vue

@@ -65,7 +65,7 @@
             <div class="preferential">
               <div class="pre-title">抵扣金额<i class="el-icon-info" title="支持输入数字和百分比。若输入百分比,将自动计算折扣金额=商品成交总金额*百分比(举例:打9折,请输入10%),
                 只在订单创建时计算一次,在订单创建后修改商品价格不会自动计算,运费不参与折扣。"></i>:</div>
-              <el-input v-model="freeAmount" class="freeAmount" placeholder="请输入" size="mini" @input="freeAmountChange"></el-input>
+              <vxe-input v-model="freeAmount" class="freeAmount" placeholder="请输入" type="number" size="mini" @input="freeAmountChange"></vxe-input>
             </div>
           </div>
           
@@ -81,11 +81,11 @@
               </div>
             </template>
             <template v-slot:qty='{ row }'>
-              <el-input v-model="row.qty" placeholder="数量" class="number-input" size="mini" type="number" @input="qtyChange($event, row)"></el-input>
+              <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>
-              <el-input v-else v-model="row.price" placeholder="单价" class="number-input" size="mini" type="number" @input="priceChange($event, row)"></el-input>
+              <vxe-input v-else v-model="row.price" placeholder="单价" align="center" size="mini" type="number" @input="priceChange($event, row)"></vxe-input>
             </template>
           </by-table>
           <div class="product-row">
@@ -138,6 +138,7 @@
       </el-collapse>
       <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" />
     </template>
     <template #footer v-if="!orderValue.id">
       <div class="btn">
@@ -151,10 +152,10 @@
 </template>
 <script lang="ts">
 import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-import { addOrder,saveBaseOrder } from '@/api/omsOrder'
+import { addOrder,saveBaseOrder,single,delItem } from '@/api/omsOrder'
 import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
-
-@Component
+import AddProductModal from "./addProductModal.vue";
+@Component({components:{AddProductModal}})
 export default class AddOrder extends Vue {
   value=false;
   num:any=0;
@@ -498,11 +499,13 @@ export default class AddOrder extends Vue {
       title:'成交金额',
       field:'amount',
       width:100
-    },{
-      title:'库存',
-      field:'stock',
-      width:100
-    },{
+    },
+    // {
+    //   title:'库存',
+    //   field:'stock',
+    //   width:100
+    // },
+    {
       title:'操作',
       action:true,
       plugins:[{
@@ -522,14 +525,15 @@ export default class AddOrder extends Vue {
       {
         name: '新增商品', icon: 'el-icon-plus', event:{
           click:()=>{
-            (this.$refs.product as any).setShow(true);
+            this.toolAddProduct()
           }
         }
       },
       {
         name: '添加赠品', icon: 'el-icon-plus', event:{
           click:()=>{
-            (this.$refs.productGift as any).setShow(true);
+            this.toolAddGift();
+            
           }
         }
       }
@@ -846,6 +850,47 @@ export default class AddOrder extends Vue {
   created(){
     this.userInfo = this.$store.getters.userInfo;
   }
+  handleSuccess(){
+    this.$emit('handleSuccess');
+    this.getData();
+  }
+  //添加商品
+  toolAddProduct(){
+    if(this.orderValue.id){
+      (this.$refs.addProductModal as any).setBillValue(this.orderValue.id);
+      (this.$refs.addProductModal as any).setShow(true);
+      (this.$refs.addProductModal as any).setGift(false);
+    }else{
+      (this.$refs.product as any).setShow(true);
+    }
+  }
+  //添加赠品
+  toolAddGift(){
+    if(this.orderValue.id){
+      (this.$refs.addProductModal as any).setBillValue([this.orderValue.id]);
+      (this.$refs.addProductModal as any).setShow(true);
+      (this.$refs.addProductModal as any).setGift(true);
+    }else{
+      (this.$refs.productGift as any).setShow(true);
+    }
+  }
+  //获取数据
+  getData(){
+    if(!this.orderValue.id){
+      return
+    }
+    this.load = true;
+    single({
+      id:this.orderValue.id
+    }).then((res:any) => {
+      this.load = false;
+      this.orderValue = res.data;
+      this.show();
+      this.$forceUpdate();
+    }).catch(()=>{
+      this.load = false
+    })
+  }
   show(){
     this.baseConfig = (this as any).$lodash.cloneDeep(this.config);
     this.buyerInfoConfig = (this as any).$lodash.cloneDeep(this.config2);
@@ -990,7 +1035,7 @@ export default class AddOrder extends Vue {
     this.num = 0;
     for(const item of nowData){
       if(Number(item.qty)){
-        this.num = add(item.qty, this.num)
+        this.num = add(Number(item.qty), Number(this.num))
       }
     }
   }
@@ -1080,26 +1125,44 @@ export default class AddOrder extends Vue {
       cancelButtonText: '取消',
       type: 'warning'
     }).then(() => {
-      let data = (this.$refs.table as any).getValue();
-      let index = -1;
-      for(const item of data){
-        index ++;
-        if(row.skuId == item.skuId && row.name == item.name && row.isGift == item.isGift){
-          break;
+      let del=()=>{
+        let data = (this.$refs.table as any).getValue();
+        let index = -1;
+        for(const item of data){
+          index ++;
+          if(row.skuId == item.skuId && row.name == item.name && row.isGift == item.isGift){
+            break;
+          }
         }
+        data.splice(index,1);
+        (this.$refs.table as any).setValue(data);
+        this.totalAmount();
+        this.amountChange();
+        this.payAmountChange();
+        this.totalNum();
       }
-      data.splice(index,1);
-      (this.$refs.table as any).setValue(data);
-      this.totalAmount();
-      this.amountChange();
-      this.payAmountChange();
-      this.totalNum();
+      if(row.id){
+        this.load = true;
+        delItem({
+          itemId:row.id,
+          id:this.orderValue.id
+        }).then(()=>{
+          this.load = false;
+          del();
+          this.$emit('handleSuccess');
+        }).catch(()=>{
+          this.load = false;
+        })
+      }else{
+        del();
+      }
+      
     }).catch(() => { });
   }
   //数量的变化
   qtyChange(v:any,row:any){
     if(v && row.price){
-      row.amount = multiply(v,row.price)
+      row.amount = multiply(v,Number(row.price))
     }else{
       row.amount = 0
     }
@@ -1111,7 +1174,7 @@ export default class AddOrder extends Vue {
   //单价的变化
   priceChange(v:any,row:any){
     if(v && row.qty){
-      row.amount =multiply(v,row.qty)
+      row.amount =multiply(v,Number(row.qty))
     }else{
       row.amount = 0
     }

+ 247 - 0
src/views/oms/order/components/addProductModal.vue

@@ -0,0 +1,247 @@
+<template>
+  <vxe-modal v-model="value" id="addProductModal" width="70%" v-loading="load" @hide="hide" height="80%" show-footer :title="title">
+    <by-tool :propConfig="toolConfig" class="add-ptool" ref="tool">
+      <template v-slot:tool-right>
+        <el-switch
+          v-if="!isGift"
+          v-model="isPay"
+          active-text="快速支付" />
+      </template>
+    </by-tool>
+    <by-table :propConfig="config" ref="table">
+      <template v-slot:price='{ row }'>
+        <span v-if="isGift">0</span>
+        <vxe-input v-else v-model="row.price" placeholder="单价" align="center" size="mini" type="number"></vxe-input>
+      </template>
+    </by-table>
+    <template #footer>
+      <div class="btn">
+        <el-button type="primary" size="small" @click="btn">确定</el-button>
+      </div>
+    </template>
+    <!-- 商品 -->
+    <product-sku-modal ref="product" :mulit="true" @confirm="confirmProduct" />
+  </vxe-modal>
+</template>
+
+<script lang="ts">
+import { Component, Prop, Vue, Watch } from "vue-property-decorator";
+import { addItem,addGift } from '@/api/omsOrder'
+@Component({components:{}})
+export default class AddProductModal extends Vue {
+  isGift=false
+  title='';
+  value=false;
+  load=false;
+  isPay = false;
+  billValue:Array<any>=[];
+  config:any={
+    attr:{
+      size:'small',
+      align:'center'
+    },
+    columns:[{
+      title:'名称',
+      field:'name',
+      width:300
+    },{
+      title:'数量',
+      field:'qty',
+      width:120,
+      component:'by-input',
+      compConfig:{
+        attr:{
+          placeholder:'数量',
+          type:'integer',
+          size:'mini',
+          align:'center'
+        }
+      }
+    },{
+      title:'单价',
+      field:'price',
+      width:120,
+      slot:true,
+      component:'by-input',
+      compConfig:{
+        attr:{
+          type:'number',
+          size:'mini',
+          align:'center'
+        }
+      }
+    },{
+      title:'库存',
+      field:'stock',
+      width:100
+    },{
+      title:'操作',
+      action:true,
+      plugins:[{
+        icon:'el-icon-delete',
+        name:'删除',
+        audit:'',
+        event:{
+          click:(item:any) => {
+            this.deletaProduct(item);
+          }
+        }
+      }]
+    }]
+  }
+  toolConfig:any={
+    customTools:[
+      {
+        name: '新增商品', icon: 'el-icon-plus', event:{
+          click:()=>{
+            (this.$refs.product as any).setShow(true);
+          }
+        }
+      }
+    ]
+  }
+  created(){
+    
+  }
+  setGift(v:boolean){
+    this.isGift = v;
+    this.title = this.isGift?'添加赠品':'添加商品';
+    this.toolConfig.customTools[0].name = this.title;
+    if(this.$refs.tool){
+      (this.$refs.tool as any).initTools();
+    }
+    
+  }
+  hide(){
+    this.isPay = false;
+    (this.$refs.table as any).setValue([]);
+  }
+  setShow(v:boolean){
+    this.value = v;
+  }
+  setBillValue(data:any){
+    this.billValue = data;
+  }
+  giftHandle(){
+    let tlist=(this.$refs.table as any).getValue();
+    if(tlist.length == 0){
+      this.$message('请选择赠品!')
+      return
+    }
+    let parames:any={};
+    parames.idList = this.billValue;
+    parames.giftList=[];
+    for(const item of tlist){
+      parames.giftList.push({
+        itemId:item.itemId,
+        qty:item.qty
+      })
+    }
+    this.load = true;
+    addGift(parames).then(() => {
+      this.load = false;
+      this.$message({
+        message:'添加成功!',
+        type:'success'
+      });
+      this.$emit('handleSuccess');
+      this.value = false;
+    }).catch((err:any)=>{
+      this.load = false;
+    })
+  }
+  productHandle(){
+    let tlist=(this.$refs.table as any).getValue();
+    let data:any={};
+    if(tlist.length == 0){
+      this.$message('请选择商品!')
+      return
+    }
+    data.id = this.billValue;
+    data.items=[];
+    data.isPay = this.isPay;
+    for(const item of tlist){
+      data.items.push({
+        itemId:item.itemId,
+        qty:Number(item.qty),
+        price:Number(item.price)
+      })
+    }
+    this.load = true
+    addItem(data).then(()=>{
+      this.load = false;
+      this.$message({
+        message:'添加成功!',
+        type:'success'
+      });
+      this.$emit('handleSuccess');
+      this.value = false;
+    }).catch(()=>{
+      this.load = false
+    })
+  }
+  btn(){
+    if(this.isGift){
+      this.giftHandle()
+    }else{
+      this.productHandle()
+    }
+  }
+  confirmProduct(data:Array<any>){
+    let nowData = (this.$refs.table as any).getValue();
+    let names='';
+    if(data.length > 0){
+      for(const item of data){
+        let t = true;
+        for(const t_item of nowData){
+          if(item.id == t_item.itemId){
+            if(!names){
+              names = item.skuTitle
+            }else{
+              names = names + ',' + item.skuTitle
+            }
+            t = false;
+            break;
+          }
+        }
+        if(t){
+          let obj:any={};
+          obj.name = item.skuTitle; //商品名称
+          obj.itemId = item.id;
+          obj.qty = 1;
+          obj.price = this.isGift ? 0 : item.price;  //单价
+          
+          obj.stock = item.stock;
+          nowData.push(obj)
+        }
+      }
+      (this.$refs.table as any).setValue(nowData);
+      if(names){
+        let name = this.isGift ? '赠品' : '商品';
+        this.$alert(name+'“'+names+'”已存在!', '提示', {
+          confirmButtonText: '确定',
+          callback: action => {}
+        });
+      }
+    }
+  }
+  deletaProduct(item:any){
+    let data=(this.$refs.table as any).getValue();
+    let i = -1;
+    for(const v of data){
+      i++;
+      if(v.itemId == item.itemId){
+        break
+      }
+    }
+    data.splice(i,1);
+    (this.$refs.table as any).setValue(data);
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.add-ptool{
+  padding-bottom: 8px;
+}
+</style>

+ 1 - 2
src/views/oms/order/components/orderTool.vue

@@ -35,13 +35,12 @@
     <el-dropdown split-button type="text" class="dropdown" @command="handleCommand">
       修改
       <el-dropdown-menu slot="dropdown">
+        <!-- <el-dropdown-item command="addProduct">添加商品</el-dropdown-item> -->
         <el-dropdown-item command="addGift">添加赠品</el-dropdown-item>
         <el-dropdown-item command="updateFreight">改运费</el-dropdown-item>
         <el-dropdown-item command="updateTag">改标签</el-dropdown-item>
         <el-dropdown-item command="updateRmk">改备注</el-dropdown-item>
         <el-dropdown-item command="updateSalesman">设定业务员</el-dropdown-item>
-        <!-- <el-dropdown-item>拆分</el-dropdown-item>
-        <el-dropdown-item command="mergeOrder">合并</el-dropdown-item> -->
       </el-dropdown-menu>
     </el-dropdown>
     <el-button type="text" @click="handle('producePurchase')" title="选取已提交数据">生成采购单</el-button>

+ 12 - 42
src/views/oms/order/index.vue

@@ -165,7 +165,7 @@
       <div class="tool">
         <order-tool @addOrder="addOrder" @smt="smtOrder" @reSmt="reSmt" @loadOrder="loadOrder" @producePurchase="producePurchase" @cancelOrder="cancelOrder" 
         @reCancelOrder="reCancelOrder" @updateRmk="updateRmk" @changeQues="changeQues" @changeNormal="changeNormal" @updateSalesman="updateSalesman" 
-        @updateTag="updateTag" @addGift="addGift" />
+        @updateTag="updateTag" @addGift="addGift" @addProduct="addProduct" />
       </div>
       <div class="table">
         <order-table :data="data" ref="orderTable" class="order-table" @detail="detail" @mergeHandle="mergeHandle" @splitHandle="splitHandle"/>
@@ -197,8 +197,8 @@
       <update-saler-modal ref="updateSalerModal" @handleSuccess="handleSuccess" />
       <!-- 改标签 -->
       <tabModal ref="tabModal" @handleSuccess="handleSuccess" />
-      <!-- 赠品 -->
-      <product-sku-modal ref="productGift" :mulit="true" @confirm="confirmProduct" />
+      <!-- 添加赠品 -->
+      <add-product-modal ref="addProductModal" @handleSuccess="handleSuccess" />
     </div>
   </div>
 </template>
@@ -224,11 +224,12 @@ import SetQuesModal from "./components/setQuesModal.vue";
 import UpdateRmkModal from "./components/updateRmkModal.vue";
 import UpdateSalerModal from "./components/updateSalerModal.vue";
 import TabModal from "./components/tabModal.vue";
+import AddProductModal from "./components/addProductModal.vue";
 import { query,getProvince,smt,unSmt,purchaseQty,unCancel,resetQuestion,addGift } from '@/api/omsOrder'
 import { queryAll } from '@/api/question'
 @Component({components:{filterInput,OrderCheckbox,OrderRadio,filterDate,OrderTool,OrderTable,AddOrder,InputSelect,OrderProduct,
   filterMinMax,loadOrderModal,PurchaseModel,MergeModel,SplitModel,CancelOrderModel,QuestModel,SetQuesModal,UpdateRmkModal,UpdateSalerModal,
-  TabModal}})
+  TabModal,AddProductModal}})
 export default class Order extends Vue {
   activeNames:Array<any>=['1','status']
   radio=''
@@ -500,47 +501,16 @@ export default class Order extends Vue {
     this.getProvince();
     this.getQuestionList();
   }
+  //添加商品
+  addProduct(){
+    this.updateHandleModal('addProductModal');
+  }
   //添加赠品
   addGift(){
-    let data = (this.$refs.orderTable as any).getSelectData();
-    if(data.length == 0){
-      this.$message('请选择订单!');
-      return
-    }
-    (this.$refs.productGift as any).setShow(true);
-  }
-  confirmProduct(v:Array<any>){
-    if(v.length == 0){
-      this.$message('请选择赠品!')
-      return
-    }
-    let data = (this.$refs.orderTable as any).getSelectData();
-    let parames:any={};
-    parames.idList = [];
-    parames.giftList=[];
-    for(const item of data){
-      parames.idList.push(item.id);
-    }
-    for(const item of v){
-      parames.giftList.push({
-        itemId:item.id,
-        qty:1
-      })
-    }
-    addGift(parames).then(() => {
-      this.$message({
-        message:'赠品添加成功!',
-        type:'success'
-      });
-      this.handleSuccess();
-    }).catch((err:any)=>{
-      if(err.msg){
-        this.$message.error(err.msg);
-      }else{
-        this.$message.error('操作失败!');
-      }
-    })
+    this.updateHandleModal('addProductModal');
+    (this.$refs.addProductModal as any).setGift(true);
   }
+  
   //改标签
   updateTag(){
     this.updateHandleModal('tabModal')