Преглед на файлове

【新增】零售订单

莫绍宝 преди 3 години
родител
ревизия
391da5cee1
променени са 2 файла, в които са добавени 79 реда и са изтрити 16 реда
  1. 72 13
      src/views/supply/retail/components/retail_form.vue
  2. 7 3
      src/views/supply/retail/retail_list.vue

+ 72 - 13
src/views/supply/retail/components/retail_form.vue

@@ -92,11 +92,13 @@
         </el-table-column>
         <el-table-column align="center" label="返利金额" min-width="100" show-overflow-tooltip>
           <template slot-scope="scope">
-            {{scope.row.price * scope.row.qty * scope.row.rebateRate}}
+            {{(scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100}}
           </template>
         </el-table-column>
         <el-table-column align="center" label="格力折扣" min-width="100" show-overflow-tooltip>
-          {{scope.row.qty * scope.row.discAmount}}
+          <template slot-scope="scope">
+            {{scope.row.qty * scope.row.discAmount}}
+          </template>
         </el-table-column>
         <el-table-column align="center" label="现金钱包" prop="walletRebateId2" min-width="160" show-overflow-tooltip>
           <template slot-scope="scope">
@@ -113,7 +115,7 @@
         </el-table-column>
         <el-table-column align="center" label="实付金额" prop="qty" min-width="100" show-overflow-tooltip>
           <template slot-scope="scope">
-            {{(scope.row.price * scope.row.qty) - (scope.row.price * scope.row.qty * scope.row.rebateRate) - (scope.row.qty * scope.row.discAmount)}}
+            {{((scope.row.price * scope.row.qty) * 100 - ((scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) / 100) * 100 - ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) / 100}}
           </template>
         </el-table-column>
         <el-table-column align="center" label="是否直调" prop="isDirectTransfer" min-width="100">
@@ -132,8 +134,16 @@
           </template>
         </el-table-column>
         <el-table-column align="center" label="税率" prop="tax" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip></el-table-column>
-        <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip></el-table-column>
+        <el-table-column align="center" label="总仓库" prop="status1" min-width="100" show-overflow-tooltip v-if="!listItem">
+          <template slot-scope="scope">
+            <el-tag :type="scope.row.status1 | statusTagFilter">{{ scope.row.status1 | statusFilter }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column align="center" label="仓库状态" prop="status2" min-width="100" show-overflow-tooltip v-if="!listItem">
+          <template slot-scope="scope">
+            <el-tag :type="scope.row.status2 | statusTagFilter">{{ scope.row.status2 | statusFilter }}</el-tag>
+          </template>
+        </el-table-column>
         <el-table-column align="center" label="操作" width="100" fixed="right">
           <template slot-scope="scope">
             <el-button type="text" @click="deleteItem(scope.$index)">删除</el-button>
@@ -257,6 +267,24 @@ export default {
   name: 'RetailForm',
   componentName: 'RetailForm',
   props: ['listItem'],
+  filters: {
+    statusFilter(val) {
+      if (val === '') return '未检查';
+      const MAP = {
+        0: '库存不足',
+        1: '库存充足'
+      }
+      return MAP[val];
+    },
+    statusTagFilter(val) {
+      if (val === '') return 'info';
+      const MAP = {
+        0: 'danger',
+        1: 'success'
+      }
+      return MAP[val];
+    }
+  },
   data() {
     return {
       mainForm: {
@@ -332,7 +360,15 @@ export default {
     // 获取详情
     getDetail() {
       getDetail({id: this.listItem.id}).then(res => {
-        
+        let data = res.data;
+        this.mainForm.date = data.theTime;
+        this.mainForm.type = data.mainId;
+        this.mainForm.remark = data.remark;
+        data.retailOrderItemList.forEach(item => {
+          item.status1 = '';
+          item.status2 = '';
+        })
+        this.goodsList = data.retailOrderItemList;
       })
     },
 
@@ -546,6 +582,9 @@ export default {
       if(!this.warehouseValue) {
         return this.$errorMsg('请选择仓库');
       }
+      if(!this.goodsList) {
+        return this.$errorMsg('请添加货品');
+      }
       let ids = [];
       this.goodsList.forEach(item => {
         ids.push(item.materialId);
@@ -554,7 +593,12 @@ export default {
         correspondId: this.warehouseValue,
         materialId: ids.join(',')
       }).then(res => {
-
+        if(res.data) {
+          this.goodsList.forEach((item, index) => {
+            item.status1 = res.data[index].allStockStatus;
+            item.status2 = res.data[index].stockStatus;
+          })
+        }
       })
     },
     
@@ -562,6 +606,13 @@ export default {
     clickSubmitForm() {
       this.$refs.mainForm.validate((valid) => {
         if (valid) {
+          for(let i=0; i<this.goodsList.length; i++) {
+            if(!this.goodsList[i].walletRebateId2) {
+              this.$errorMsg('请选择现金钱包');
+              return;
+            }
+          }
+
           let mainName = this.typeList[findElem(this.typeList, 'dictCode', this.mainForm.type)].dictValue;
           let params = {
             theTime: this.mainForm.date + ' 00:00:00',
@@ -571,12 +622,20 @@ export default {
             type: 1, // 1:普通零售单,2:政策零售单
             retailOrderItemList: this.goodsList
           }
-          addData(params).then(res => {
-            this.$successMsg('添加成功');
-            this.goBack();
-            this.$parent.getList();
-          })
-
+          if(this.listItem) {
+            params.id = this.listItem.id;
+            editData(params).then(res => {
+              this.$successMsg('编辑成功');
+              this.goBack();
+              this.$parent.getList();
+            })
+          }else {
+            addData(params).then(res => {
+              this.$successMsg('添加成功');
+              this.goBack();
+              this.$parent.getList();
+            })
+          }
         }
       })
     },

+ 7 - 3
src/views/supply/retail/retail_list.vue

@@ -78,9 +78,13 @@
         </div>
         <div class="table">
           <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
-            <el-table-column align="center" label="订单号" prop="id" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="订单日期" prop="theTime" min-width="160" show-overflow-tooltip></el-table-column>
-            <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="160" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="订单号" prop="id" min-width="180" show-overflow-tooltip></el-table-column>
+            <el-table-column align="center" label="订单日期" prop="theTime" min-width="100" show-overflow-tooltip>
+              <template slot-scope="scope">
+                {{scope.row.theTime | dateToDayFilter}}
+              </template>
+            </el-table-column>
+            <el-table-column align="center" label="销售类型" prop="saleTypeName" min-width="100" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="货品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
             <el-table-column align="center" label="计量单位" prop="unit" min-width="100" show-overflow-tooltip></el-table-column>