Browse Source

新增订单

ymy 2 năm trước cách đây
mục cha
commit
923643a3ba

+ 4 - 3
src/api/omsOrder.ts

@@ -1,9 +1,10 @@
 import request from '@/benyun/utils/request'
 
-export function query(data : any) {
+export function query(params:any,data?:any) {
 	return request({
 		url: '/omsOrder/omsOrder/query',
 		method: 'POST',
+		params:params,
 		data: data
 	})
 }
@@ -16,9 +17,9 @@ export function getProvince(data:any){
 	})
 }
 
-export function save(data:any){
+export function addOrder(data:any){
 	return request({
-		url: '/omsOrder/omsOrder/save',
+		url: '/omsOrder/omsOrder/manual',
 		method: 'POST',
 		data: data
 	})

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

@@ -296,7 +296,7 @@ export default class ByArea extends VueViews {
     display: flex;
     align-items: center;
     .left-label{
-      width: 100px;
+      width: 80px;
       text-align: right;
       // flex-shrink: 0;
       // .require{

+ 9 - 3
src/benyun/components/byTable/byTable.vue

@@ -254,7 +254,15 @@ export default class ByTable extends VueViews {
     }
     return data
   }
-
+  //清楚选中
+  clearCheckboxRow(){
+    if(this.attrs.checkbox){
+      (this.$refs.table as any).clearCheckboxRow();
+    }
+    if(this.attrs.radio){
+      (this.$refs.table as any).clearRadioRow();
+    }
+  }
   setValue(data:Array<any>){
     // setTimeout(()=>{
       this.value = data ? data : [];
@@ -269,8 +277,6 @@ export default class ByTable extends VueViews {
     }
     return d;
   }
-
-
   request(){
     if(!this.requestConfig || !this.requestConfig.url){
       return

+ 6 - 0
src/benyun/components/moduleView/moduleView.vue

@@ -83,6 +83,12 @@ export default class ModuleView extends ModuleViewHandle {
     }
     return data;
   }
+  //清楚选中表格
+  clearCheckboxRow(){
+    if(this.$refs[this.tableID]){
+      (this.$refs[this.tableID] as any).clearCheckboxRow()
+    }
+  }
   //设置表格数据
   setTableValue(data:Array<any>){
     if(this.$refs[this.tableID]){

+ 3 - 0
src/benyun/utils/request.ts

@@ -42,6 +42,9 @@ service.interceptors.request.use((config:any) => {
       data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
       time: new Date().getTime()
     }
+    if(config.params){
+      requestObj.url = requestObj.url + '?' + tansParams(config.params);
+    }
     const sessionObj = cache.session.getJSON('sessionObj')
     if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
       cache.session.setJSON('sessionObj', requestObj)

+ 9 - 6
src/components/productDialog/productDialog.vue

@@ -160,17 +160,17 @@ export default class ProductDialog extends Vue {
         field:'short_name',
         width:100
       },{
-        title:'财务编号',
-        field:'accounting_code'
+        title:'款式编码',
+        field:'newNumber'
       },{
         title:'国际码',
         field:'ns_code'
       },{
-        title:'基本售价',
-        field:'base_price'
+        title:'价',
+        field:'price'
       },{
-        title:'市场价格(统一售价)',
-        field:'mark_price'
+        title:'原价',
+        field:'basePrice'
       },{
         title:'单位',
         field:'unit'
@@ -244,6 +244,9 @@ export default class ProductDialog extends Vue {
         this.getList()
       },500) 
     }
+    if(this.$refs.view){
+      (this.$refs.view as any).clearCheckboxRow();
+    }
   }
   getList(){
     if(!this.$refs.view){

+ 140 - 88
src/views/oms/order/components/addOrder.vue

@@ -10,13 +10,7 @@
           <by-form :propConfig="config" ref="baseform" @formChange="formChangeBase"></by-form>
         </el-collapse-item>
         <el-collapse-item title="买家信息" name="2" class="add-order-item">
-          <by-form :propConfig="config2" ref="infoform">
-            <template v-slot:slotField='{ value }'>
-              <div class="updateBuyer">
-                <el-checkbox v-model="value.slotField">更新买家收货人信息</el-checkbox>
-              </div>
-            </template>
-          </by-form>
+          <by-form :propConfig="config2" ref="infoform"></by-form>
         </el-collapse-item>
         <el-collapse-item title="商品订单" name="3" class="add-order-item">
           <div class="addProductTool">
@@ -35,6 +29,7 @@
                 <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>
             </template>
@@ -42,7 +37,8 @@
               <el-input v-model="row.qty" placeholder="数量" class="number-input" size="mini" type="number" @input="qtyChange($event, row)"></el-input>
             </template>
             <template v-slot:price='{ row }'>
-              <el-input v-model="row.price" placeholder="单价" class="number-input" size="mini" type="number" @input="priceChange($event, row)"></el-input>
+              <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>
             </template>
           </by-table>
           <div class="product-row">
@@ -76,11 +72,11 @@
         </el-collapse-item>
         <el-collapse-item title="订单支付情况" name="4" class="add-order-item">
           <el-radio-group v-model="radioPay" @input="inputPay" class="payType">
-            <el-radio :label="1">待付款</el-radio>
-            <el-radio :label="2">快速支付&已付款</el-radio>
-            <el-radio :label="3">手工添加支付信息</el-radio>
+            <el-radio :label="0">待付款</el-radio>
+            <el-radio :label="1">快速支付&已付款</el-radio>
+            <el-radio :label="2">手工添加支付信息</el-radio>
           </el-radio-group>
-          <by-form v-if="radioPay == 3" :propConfig="payConfig" ref="payform"></by-form>
+          <by-form v-if="radioPay == 2" :propConfig="payConfig" ref="payform"></by-form>
         </el-collapse-item>
         <el-collapse-item title="发票信息" name="5" class="add-order-item">
           <by-form :propConfig="invoicesConfig" ref="invoicesform"></by-form>
@@ -100,32 +96,30 @@
 </template>
 <script lang="ts">
 import { Component, Prop, Vue, Watch } from "vue-property-decorator";
-import { save } from '@/api/omsOrder'
-import { add,multiply } from '@/benyun/utils/accuracy'
+import { addOrder } from '@/api/omsOrder'
+import { add,multiply,subtract,divide } from '@/benyun/utils/accuracy'
 
 @Component
 export default class AddOrder extends Vue {
   value=false;
-  num=0;
+  isValidate = true; //验证结果
+  num:any=0;
   freeAmount="";
-  productTotal=0;
-  productData:Array<any>=[]
+  productTotal:any=0;
   userName:any='';//用户信息
   orderValue:any={}; //新增订单值
-  radioPay=null;
+  radioPay=0;
+  isHandleGift = false; //是否在操作赠品
   activeNames:Array<any> =['1','2','3','4','5'];
   config:any={
     attr:{
       size:'mini',
       rules:{
         shopName:[{
-          required: true, message: '请输入名称', trigger: 'blur'
-        }],
-        sourceId:[{
-          required: true, message: '请输入名称', trigger: 'blur'
+          required: true, message: '店铺名称', trigger: 'blur'
         }],
         orderDate:[{
-          required: true, message: '请输入名称', trigger: 'blur'
+          required: true, message: '请选择订单日期', trigger: 'blur'
         }]
       }
     },
@@ -148,8 +142,8 @@ export default class AddOrder extends Vue {
         component:'by-input',
         compConfig:{
           attr:{
-            placeholder:'请输入线上订单',
-            clearable:true
+            placeholder:'自动生成',
+            readonly:true
           }
         }
       },{
@@ -179,10 +173,10 @@ export default class AddOrder extends Vue {
         span:6,
         label:'快递公司',
         prop:'logisticsCompany',
-        component:'by-select',
+        component:'by-input',
         compConfig:{
           attr:{
-            placeholder:'请选择快递公司',
+            placeholder:'请输入快递公司',
             clearable:true
           }
         }
@@ -268,12 +262,6 @@ export default class AddOrder extends Vue {
             clearable:true
           }
         }
-      },{
-        span:6,
-        // label:'插槽',
-        labelWidth:'0px',
-        slot:true,
-        prop:'slotField',
       }],
       [{
         span:24,
@@ -298,7 +286,7 @@ export default class AddOrder extends Vue {
       [{
         span:24,
         label:'详细地址',
-        prop:'address',
+        prop:'receiverAddress',
         component:'by-input',
         compConfig:{
           attr:{
@@ -416,17 +404,18 @@ export default class AddOrder extends Vue {
       {
         name: '添加赠品', icon: 'el-icon-plus', event:{
           click:()=>{
-            console.log('新增123')
+            this.isHandleGift = true;
+            (this.$refs.product as any).setShow(true);
           }
         }
       },
-      {
-        name: '导入商品', icon: 'el-icon-bottom', event:{
-          click:()=>{
-            console.log('新增123')
-          }
-        }
-      }
+      // {
+      //   name: '导入商品', icon: 'el-icon-bottom', event:{
+      //     click:()=>{
+      //       console.log('新增123')
+      //     }
+      //   }
+      // }
     ]
   }
   invoicesConfig:any={
@@ -678,12 +667,9 @@ export default class AddOrder extends Vue {
   }
   //订单支付情况单选值
   inputPay(v:number){
-    if(!this.orderValue.pays) this.orderValue.pays = {};
-    this.orderValue.pays.isOrderPay = null;
-    if(v == 1){
-      this.orderValue.pays.isOrderPay = 0
-    }else if(v == 2){
-      this.orderValue.pays.isOrderPay = 1
+    this.orderValue.isPay = null;
+    if(v != 2){
+      this.orderValue.isPay = v;
     }
   }
   mounted(){
@@ -699,47 +685,82 @@ export default class AddOrder extends Vue {
   //抵扣金额数值变化
   freeAmountChange(v:any){
     this.orderValue.freeAmount = 0;
-    if(v){
-      if(Number(v) >= 0){
-        this.orderValue.freeAmount = Number(v)
+    this.amountChange();
+    this.payAmountChange();
+  }
+  //商品成交总金额
+  totalAmount(){
+    let nowData = (this.$refs.table as any).getValue();
+    this.productTotal = 0;
+    for(const item of nowData){
+      if(Number(item.amount)){
+        this.productTotal = add(item.amount, this.productTotal)
+      }
+    }
+    this.productTotal = this.productTotal.toFixed(2);
+  }
+  //具体折扣数目
+  amountChange(){
+    if(this.freeAmount){
+      if(Number(this.freeAmount) >= 0){
+        this.orderValue.freeAmount = Number(this.freeAmount)
       }else{
-        let arr = v.split("%");
+        let arr:Array<any> = this.freeAmount.split("%");
         if(arr.length == 2 && Number(arr[0]) > 0){
-          let nowData = (this.$refs.table as any).getValue();
-          let totalPrice:any = 0;
-          for(const item of nowData){
-            if(Number(item.amount)){
-              totalPrice = add(item.amount, totalPrice)
-            }
-          }
-          this.orderValue.freeAmount = multiply(totalPrice,Number(arr[0]))
+          const n = divide(Number(arr[0]),100)
+          this.orderValue.freeAmount = multiply(this.productTotal,n)
         }
       }
+      this.orderValue.freeAmount = this.orderValue.freeAmount.toFixed(2);
+    }
+  }
+  //应付总金额
+  payAmountChange(){
+    const freight = Number(this.orderValue.freight)?Number(this.orderValue.freight):0;
+    const freeAmount = Number(this.orderValue.freeAmount)?Number(this.orderValue.freeAmount):0;
+    let t = subtract(this.productTotal, freeAmount);
+    this.orderValue.payAmount = subtract(t, freight);
+    this.orderValue.payAmount = this.orderValue.payAmount.toFixed(2);
+  }
+  //商品总数量
+  totalNum(){
+    let nowData = (this.$refs.table as any).getValue();
+    this.num = 0;
+    for(const item of nowData){
+      if(Number(item.qty)){
+        this.num = add(item.qty, this.num)
+      }
     }
   }
+  //基本信息表单数据变化
   formChangeBase(data:any){
     if(!this.orderValue[data.code]){
       Vue.set(this.orderValue, data.code, data.value);
     }else{
       this.orderValue[data.code] = data.value;
     }
-    
+    if(data.code == 'freight'){
+      this.payAmountChange();
+    }
   }
+  //确定新增的商品
   confirmProduct(data:Array<any>){
     let nowData = (this.$refs.table as any).getValue();
     let ids='';
     if(data.length > 0){
       for(const item of data){
         let t = true;
-        for(const t_item of nowData){
-          if(item.id == t_item.skuId){
-            if(!ids){
-              ids = item.id
-            }else{
-              ids = ids + ',' + item.id
+        if(!this.isHandleGift){
+          for(const t_item of nowData){
+            if(item.id == t_item.skuId){
+              if(!ids){
+                ids = item.id
+              }else{
+                ids = ids + ',' + item.id
+              }
+              t = false;
+              break;
             }
-            t = false;
-            break;
           }
         }
         if(t){
@@ -748,7 +769,14 @@ export default class AddOrder extends Vue {
           obj.skuId = item.id; //商品编码
           obj.styleId = item.newNumber; //款式编码
           obj.qty = 1;
-          obj.price = item.price;  //单价
+          if(this.isHandleGift){
+            obj.price = 0;  //单价
+            obj.isGift = 1;
+          }else{
+            obj.price = item.price;  //单价
+            obj.isGift = 0;
+          }
+          
           obj.basePrice = item.basePrice; //原价
           obj.amount = item.price;
           obj.stock = item.stock;
@@ -756,6 +784,10 @@ export default class AddOrder extends Vue {
         }
       }
       (this.$refs.table as any).setValue(nowData);
+      this.totalAmount();
+      this.amountChange();
+      this.payAmountChange();
+      this.totalNum();
       if(ids){
         this.$alert('编码“'+ids+'”已添加!', '提示', {
           confirmButtonText: '确定',
@@ -763,22 +795,34 @@ export default class AddOrder extends Vue {
         });
       }
     }
+    this.isHandleGift = false;
   }
+  //数量的变化
   qtyChange(v:any,row:any){
     if(v && row.price){
-      row.amount = v*row.price
+      row.amount = multiply(v,row.price)
     }else{
       row.amount = 0
     }
+    this.totalAmount();
+    this.amountChange();
+    this.payAmountChange();
+    this.totalNum();
   }
+  //单价的变化
   priceChange(v:any,row:any){
     if(v && row.qty){
-      row.amount = v*row.qty
+      row.amount =multiply(v,row.qty)
     }else{
       row.amount = 0
     }
+    this.totalAmount();
+    this.amountChange();
+    this.payAmountChange();
   }
+  //清楚整个订单数据
   clearValue(){
+    this.orderValue = {};
     (this.$refs.baseform as any).setValue({});
     (this.$refs.infoform as any).setValue({});
     (this.$refs.table as any).setValue([]);
@@ -786,9 +830,12 @@ export default class AddOrder extends Vue {
       (this.$refs.payform as any).setValue({});
     }
     (this.$refs.invoicesform as any).setValue({});
+    this.num = 0;
+    this.productTotal = 0;
+    this.radioPay = 0;
   }
   getOrderValue(){
-    this.orderValue = {};
+    // this.orderValue = {};
     let r = true;
     (this.$refs.baseform as any).validate({noMsg:true}).then(()=>{
       let baseInfo = (this.$refs.baseform as any).getValue();
@@ -820,16 +867,12 @@ export default class AddOrder extends Vue {
     });
     if(this.$refs.table){
       let productOrder:Array<any> = (this.$refs.table as any).getValue();
-      this.orderValue.item = productOrder;
+      this.orderValue.items = productOrder;
     }
-    this.orderValue.status = null;
-    if(this.radioPay != 3){
-      if(this.radioPay == 1){
-        this.orderValue.status = 'WaitPay'
-      }else if(this.radioPay == 2){
-        this.orderValue.status = 'WaitConfirm'
-      }
-    }else{
+    if(this.radioPay != 2){
+      this.orderValue.isPay = this.radioPay;
+    }
+    if(this.radioPay == 2){
       (this.$refs.payform as any).validate({noMsg:true}).then(()=>{
         this.orderValue.pays = [];
         let payFormValue = (this.$refs.payform as any).getValue();
@@ -847,16 +890,25 @@ export default class AddOrder extends Vue {
     let invoiceValue = (this.$refs.invoicesform as any).getValue();
     this.orderValue.invoices=[];
     this.orderValue.invoices.push(invoiceValue);
+    this.isValidate = r;
   }
+  //确定
   btn(){
     this.getOrderValue();
     setTimeout(()=>{
-      save({data:this.orderValue}).then((res:any) => {
-        (this as any).$message({
-          message: '订单添加成功!',
-          type: 'success',
-        })
-      }).catch((err:any) => {})
+      if(this.isValidate){
+        if(this.orderValue.orderDate){
+          this.orderValue.orderDate = this.orderValue.orderDate + ' 00:00:00'
+        }
+        this.orderValue.receiverCountryCode = '86';
+        this.orderValue.receiverCountry="中华人民共和国";
+        addOrder(this.orderValue).then((res:any) => {
+          (this as any).$message({
+            message: '订单添加成功!',
+            type: 'success',
+          })
+        }).catch((err:any) => {})
+      }
     },500)
     
   }

+ 23 - 2
src/views/oms/order/components/orderTable.vue

@@ -6,8 +6,29 @@
     <vxe-column type="seq" width="60" title="序号"></vxe-column>
     <vxe-column type="checkbox" width="50"></vxe-column>
     <vxe-column field="sourceId" title="线上订单号" width="120"></vxe-column>
-    <vxe-column field="type" title="订单类型" width="120"></vxe-column>
-    <vxe-column field="status" title="订单状态" width="120"></vxe-column>
+    <vxe-column field="type" title="订单类型" width="120">
+      <template #default="{ row }">
+        <span v-if="row.type == 'Common'">普通订单</span>
+        <span v-if="row.type == 'Reissue'">补发订单</span>
+        <span v-if="row.type == 'DistributionPlus'">分销Plus</span>
+        <span v-if="row.type == 'SupplyPlus'">供销Plus</span>
+        <span v-if="row.type == 'Exchange'">换货订单</span>
+      </template>
+    </vxe-column>
+    <vxe-column field="status" title="订单状态" width="120">
+      <template #default="{ row }">
+        <span v-if="row.status == 'WaitPay'">待付款</span>
+        <span v-if="row.status == 'Delivering'">发货中</span>
+        <span v-if="row.status == 'Merged'">被合并</span>
+        <span v-if="row.status == 'Question'">异常</span>
+        <span v-if="row.status == 'Split'">被拆分</span>
+        <span v-if="row.status == 'WaitOuterSent'">等供销商|外仓发货</span>
+        <span v-if="row.status == 'WaitConfirm'">已付款待审核</span>
+        <span v-if="row.status == 'WaitFConfirm'">已客审待财审</span>
+        <span v-if="row.status == 'Sent'">已发货</span>
+        <span v-if="row.status == 'Cancelled'">取消</span>
+      </template>
+    </vxe-column>
     <vxe-column field="shipment" title="跨境买家指定物流" width="120"></vxe-column>
     <vxe-column field="chosenChannel" title="实发快递渠道" width="120"></vxe-column>
     <vxe-column field="logisticsId" title="快递单号" width="120"></vxe-column>

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

@@ -4,8 +4,8 @@
       <el-collapse v-model="activeNames" class="my-collapse">
         <el-collapse-item title="基本信息" name="1">
           <input-select :options="myOptions" @input="parameChange" ref="searchCom01" />
-          <input-select :options="outLineOptions" @input="parameChange" ref="searchCom02" />
-          <input-select :options="buyerOptions" @input="parameChange" ref="searchCom03" />
+          <input-select :options="outLineOptions" @input="parameChangeBase" ref="searchCom02" />
+          <input-select :options="buyerOptions" @input="parameChangeBase" ref="searchCom03" />
         </el-collapse-item>
         <order-checkbox title="订单状态" keyName="status" ref="searchCom04" :options="statusOptions" noLimit @checkboxChange="onChange($event,'status')" />
         <order-radio title="买家留言" keyName="buyerMessageFilter" ref="searchCom05" :options="buyerMessageOptions" noLimit @radioChange="onChange($event,'buyerMessageFilter')">
@@ -169,6 +169,7 @@ import filterMinMax from './components/filterMinMax.vue'
 import { query,getProvince,smt,unSmt } from '@/api/omsOrder'
 @Component({components:{filterInput,OrderCheckbox,OrderRadio,filterDate,OrderTool,OrderTable,AddOrder,InputSelect,OrderProduct,filterMinMax}})
 export default class Order extends Vue {
+  test={}
   activeNames:Array<any>=['1']
   radio=''
   radio2=''
@@ -388,15 +389,20 @@ export default class Order extends Vue {
 
   //订单类型
   typeOption:Array<any>=[{
-    label:'普通订单'
+    label:'普通订单',
+    value:'Common'
   },{
-    label:'补发订单'
+    label:'补发订单',
+    value:'Reissue'
   },{
-    label:'分销Plus'
+    label:'分销Plus',
+    value:'DistributionPlus'
   },{
-    label:'供销Plus'
+    label:'供销Plus',
+    value:'SupplyPlus'
   },{
-    label:'换货订单'
+    label:'换货订单',
+    value:'Exchange'
   }]
 
   //订单状态 
@@ -528,6 +534,17 @@ export default class Order extends Vue {
       }
     }
   }
+  parameChangeBase(parames:any){
+    for(const key in parames){
+      if(parames[key]){
+        this.value.idType = key;
+        this.value.idValue = parames[key].split(',');
+      }else{
+        this.value.idType = '';
+        this.value.idValue = [];
+      }
+    }
+  }
   colChange(v:any){
     if(v == 1){
       this.value.isCod = false
@@ -552,10 +569,11 @@ export default class Order extends Vue {
   }
   //获取订单列表数据
   getList(){
-    let data:any =(this as any).$lodash.cloneDeep(this.value);
-    data.pageNo = this.page.pageNo;
-    data.pageSize = this.page.pageSize;
-    query(data).then((res:any) => {
+    let data:any = (this as any).$lodash.cloneDeep(this.value);
+    let params:any={};
+    params.pageNo = this.page.pageNo;
+    params.pageSize = this.page.pageSize;
+    query(params,data).then((res:any) => {
       this.data = res.data.records;
       this.page.pageNo = res.data.pages;
       // this.page.pageSize = res.data.size;
@@ -583,7 +601,7 @@ export default class Order extends Vue {
   display: flex;
   overflow-x: hidden;
   .order-left{
-    width: 240px;
+    width: 260px;
     flex-shrink: 0;
     background-color: #f0f0f0;
     border-right: solid 1px #CCC;