Browse Source

促销对接

lilei 4 years ago
parent
commit
bef28000f5

+ 34 - 11
src/views/salesManagement/salesQuery/chooseActive.vue

@@ -54,32 +54,41 @@ export default {
     openModal: { //  弹框显示状态
       type: Boolean,
       default: false
+    },
+    buyerSn: {
+      type: String,
+      default: ''
     }
   },
   data () {
     return {
       isShow: this.openModal,
       columns: [
-        { title: '产品编码', dataIndex: 'productEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '成本价', dataIndex: 'showCost', align: 'center', ellipsis: true, customRender: function (text) { return '¥' + (text || 0) } },
-        { title: '原售价', dataIndex: 'origPrice', align: 'center', ellipsis: true, customRender: function (text) { return '¥' + (text || 0) } },
-        { title: '促销价', dataIndex: 'price', align: 'center', ellipsis: true, customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '产品编码', dataIndex: 'product.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'product.name', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '成本价', dataIndex: 'product.cost', align: 'center', customRender: function (text) { return '¥' + (text == undefined ? '--' : text) } },
+        { title: '原售价', dataIndex: 'product.productPrice', align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '促销价', dataIndex: 'goodsPrice', align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
         { title: '数量', dataIndex: 'qty', scopedSlots: { customRender: 'salesNums' }, align: 'center' },
-        { title: '单位', dataIndex: 'productEntity.unit', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '促销类型', dataIndex: 'promotionSourceSn', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } }
+        { title: '单位', dataIndex: 'product.unit', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销类型', dataIndex: 'promotionSourceSn', align: 'center', customRender: function (text) { return text || '--' } }
       ],
       selectedRowKeys: [], // Check here to configure the default column
       selectedRows: [],
       loading: false,
-      list: []
+      list: [],
+      salesBillDetailSn: null
     }
   },
   methods: {
     getData (row) {
       this.loading = true
-      getPromoGoodsList({ salesBillDetailSn: row.salesBillDetailSn }).then(res => {
-        this.list = res.data.list
+      this.salesBillDetailSn = row.salesBillDetailSn
+      getPromoGoodsList({ salesBillDetailSn: row.salesBillDetailSn, buyerSn: this.buyerSn }).then(res => {
+        this.list = res.data
+        this.list.map(item => {
+          item.qty = 1
+        })
         this.loading = false
       })
     },
@@ -96,7 +105,21 @@ export default {
       }
       const obj = []
       _this.selectedRows.map(item => {
-        obj.push(item.productSn)
+        obj.push({
+          showCost: 10,
+          price: item.goodsPrice,
+          origPrice: item.product.productPrice,
+          packQty: item.product.packQty,
+          productSn: item.product.productSn,
+          promotionSourceSn: this.salesBillDetailSn,
+          promotionActivitySn: item.promoActiveSn,
+          promotionActivityName: item.promoActiveName,
+          promotionRules: item.promoRuleSn,
+          promoGoodsType: item.promoGoodsType,
+          qty: item.qty,
+          promotableFlag: 0, // 可促销标记 有活动的传1,没活动的传0
+          promotionFlag: 1 // 促销标记 正品传0,促销品传1
+        })
       })
       _this.$emit('ok', obj)
     },

+ 59 - 13
src/views/salesManagement/salesQuery/edit.vue

@@ -74,10 +74,8 @@
         bordered>
         <!-- 产品名称 -->
         <template slot="productName" slot-scope="text, record">
-          <a-badge count="活动" v-if="record.promotableFlag == 1">
-            <div style="padding-right: 15px;">{{ text }}</div>
-          </a-badge>
-          <span v-else>{{ text }}</span>
+          <span>{{ text }}</span>
+          <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.promotableFlag == 1"></a-badge>
         </template>
 
         <!-- 销售数量 -->
@@ -105,10 +103,32 @@
             :loading="delLoading"
             class="button-warning"
             @click="handleSelCx(record)"
+            v-if="record.promotableFlag == 1"
           >选择促销品</a-button>
         </template>
       </s-table>
     </a-card>
+    <a-card :bordered="false" class="salesEdit-cont">
+      <div slot="title">
+        <div class="p-title">
+          已选促销品
+        </div>
+      </div>
+      <!-- 总计 -->
+      <a-alert type="info">
+        <div slot="message" class="total-bar">
+          <div>
+            总成本:<strong>¥{{ detailData&&detailData.totalPromoCost || 0 }}</strong>;
+            总款数:<strong>{{ detailData&&detailData.totalPromoCategory || 0 }}</strong>;
+            总数量:<strong>{{ detailData&&detailData.totalPromoQty || 0 }}</strong>;
+          </div>
+          <div>
+          </div>
+        </div>
+      </a-alert>
+      <!-- 已选促销品列表 -->
+      <queryPromotable ref="promotable" :salesBillSn="$route.params.sn" @onCellChange="onCellChange" @del="handleDel"></queryPromotable>
+    </a-card>
     <a-affix :offset-bottom="0">
       <div
         style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
@@ -124,21 +144,27 @@
     <!-- 选择客户弹框 -->
     <choose-custom-modal ref="custModal" :show="openModal" @cancel="openModal=false" />
     <!-- 添加产品 -->
-    <ChooseActive ref="activeProduct" :openModal="newActive" @ok="addNewActive" @close="newActive=false"></ChooseActive>
+    <ChooseActive
+      ref="activeProduct"
+      :buyerSn="detailData&&detailData.buyerSn"
+      :openModal="newActive"
+      @ok="addNewActive"
+      @close="newActive=false"></ChooseActive>
   </div>
 </template>
 
 <script>
 import { STable, VSelect } from '@/components'
 import queryPart from './queryPart.vue'
+import queryPromotable from './queryPromotable.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
 import ChooseActive from './chooseActive.vue'
 import { salesDetailBySn, salesWriteSubmit, getPromoacActiveList } from '@/api/sales'
 import EditableCell from '@/views/common/editInput.js'
-import { salesDetailList, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
+import { salesDetailList, salesDetailInsert, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll, addPromoGoods } from '@/api/salesDetail'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect, queryPart, chooseCustomModal, EditableCell, ChooseActive },
+  components: { STable, VSelect, queryPart, queryPromotable, chooseCustomModal, EditableCell, ChooseActive },
   data () {
     return {
       salesBillSn: null, // 销售单sn
@@ -150,7 +176,8 @@ export default {
       detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
       dataSource: [],
       productForm: {
-        salesBillSn: ''
+        salesBillSn: '',
+        promotionFlag: 0
       },
       activeList: [], // 促销活动
       // 表头
@@ -197,8 +224,8 @@ export default {
           salesBillSn: this.salesBillSn
         }).then(res => {
           this.resetSearchForm(true)
+          this.$refs.promotable.resetCurForm()
           if (res.status == 200) {
-            this.$refs.partQuery.resetCurForm()
             this.$message.success(res.message)
           }
         })
@@ -214,6 +241,7 @@ export default {
     //  重置
     resetSearchForm (flag) {
       this.$refs.table.refresh(!!flag)
+      this.getPromoacActiveList()
       this.getOrderDetail()
     },
     // 重置列表
@@ -237,6 +265,7 @@ export default {
           salesDetailDelAll({ salesBillSn: _this.salesBillSn }).then(res => {
             if (res.status == 200) {
               _this.resetSearchForm()
+              _this.$refs.promotable.resetCurForm()
               _this.$message.success(res.message)
             }
             _this.delLoading = false
@@ -257,6 +286,7 @@ export default {
           salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
             if (res.status == 200) {
               _this.resetSearchForm(true)
+              _this.$refs.promotable.resetCurForm()
               _this.$message.success(res.message)
             }
             _this.delLoading = false
@@ -290,12 +320,11 @@ export default {
         purchaseBillSn: this.detailData.purchaseBillSn,
         purchaseBillNo: this.detailData.purchaseBillNo,
         stockSn: row.stockSn,
-        promotableFlag: row.promotableFlag || 0, // 可促销标记 有活动的传1,没活动的传0
+        promotableFlag: row.isJoinActivityProduct || 0, // 可促销标记 有活动的传1,没活动的传0
         promotionFlag: promotionFlag // 促销标记 正品传0,促销品传1
       }).then(res => {
         if (res.status == 200) {
           this.resetSearchForm()
-          this.$refs.partQuery.resetCurForm()
           this.$message.success('产品添加成功', 2.5)
         }
         this.isInster = false
@@ -331,8 +360,22 @@ export default {
       this.newActive = true
       this.$refs.activeProduct.getData(row)
     },
-    addNewActive () {
-
+    // 批量添加促销品
+    addNewActive (list) {
+      const temp = []
+      list.map(item => {
+        temp.push(Object.assign(item, {
+          salesBillSn: this.detailData.salesBillSn,
+          salesBillNo: this.detailData.salesBillNo,
+          purchaseBillSn: this.detailData.purchaseBillSn,
+          purchaseBillNo: this.detailData.purchaseBillNo
+        }))
+      })
+      addPromoGoods(temp).then(res => {
+        if (res.status == 200) {
+          this.$refs.promotable.getData()
+        }
+      })
     }
   },
   mounted () {
@@ -341,7 +384,10 @@ export default {
   beforeRouteEnter (to, from, next) {
     next(vm => {
       vm.salesBillSn = vm.$route.params.sn
+      // 获取促销活动
       vm.getPromoacActiveList()
+      // 查询已选促销品
+      vm.$refs.promotable.getData()
     })
   }
 }

+ 2 - 4
src/views/salesManagement/salesQuery/queryPart.vue

@@ -72,10 +72,8 @@
       </template>
       <!-- 产品名称 -->
       <template slot="productName" slot-scope="text, record">
-        <a-badge count="活动" v-if="record.promotableFlag == 1">
-          <div style="padding-right: 15px;">{{ text }}</div>
-        </a-badge>
-        <span v-else>{{ text }}</span>
+        <span>{{ text }}</span>
+        <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
       </template>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">

+ 108 - 0
src/views/salesManagement/salesQuery/queryPromotable.vue

@@ -0,0 +1,108 @@
+<template>
+  <!-- 已选配件列表 -->
+  <s-table
+    class="sTable"
+    ref="table"
+    size="small"
+    :rowKey="(record) => record.id"
+    :columns="columns"
+    :data="loadData"
+    :scroll="{ x:1000, y: 300 }"
+    :defaultLoadData="false"
+    bordered>
+    <!-- 产品名称 -->
+    <template slot="productName" slot-scope="text, record">
+      <span>{{ text }}</span>
+    </template>
+
+    <!-- 销售数量 -->
+    <template slot="salesNums" slot-scope="text, record">
+      <editable-cell
+        size="small"
+        :text="record.qty"
+        :max="999999"
+        :min="1"
+        :precision="0"
+        @change="onCellChange(record.id, 'qty', $event)" />
+    </template>
+    <!-- 操作 -->
+    <template slot="action" slot-scope="text, record">
+      <a-button
+        size="small"
+        type="primary"
+        :loading="delLoading"
+        class="button-error"
+        @click="handleDel(record)"
+      >删除</a-button>
+    </template>
+  </s-table>
+</template>
+
+<script>
+import { salesDetailList } from '@/api/salesDetail'
+import { STable, VSelect } from '@/components'
+export default {
+  name: 'Promotable',
+  components: { STable, VSelect },
+  props: {
+    salesBillSn: {
+      type: [Number, String],
+      default: ''
+    },
+    newLoading: Boolean
+  },
+  data () {
+    return {
+      productForm: {
+        salesBillSn: '',
+        promotionFlag: 1
+      },
+      // 表头
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '产品编码', dataIndex: 'productEntity.code', width: 150, align: 'center', sorter: true },
+        { title: '产品名称', dataIndex: 'productEntity.name', scopedSlots: { customRender: 'productName' }, align: 'center' },
+        { title: '成本价', dataIndex: 'showCost', width: 150, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '原售价', dataIndex: 'origPrice', width: 150, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '促销价', dataIndex: 'price', width: 150, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '数量', scopedSlots: { customRender: 'salesNums' }, width: 150, align: 'center' },
+        { title: '单位', dataIndex: 'productEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '促销类型', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.productForm.salesBillSn = this.salesBillSn
+        return salesDetailList(Object.assign(parameter, this.productForm)).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          return data
+        })
+      }
+    }
+  },
+  methods: {
+    // 刷新当前页面
+    resetCurForm () {
+      this.$refs.table.refresh()
+    },
+    // 修改数量
+    onCellChange (id, key, $event) {
+      this.$emit('onCellChange', id, key, $event)
+    },
+    // 删除
+    handleDel (row) {
+      this.$emit('del', row)
+    },
+    getData () {
+      this.$refs.table.refresh(true)
+    }
+  }
+}
+</script>
+
+<style>
+</style>

+ 1 - 1
vue.config.js

@@ -108,7 +108,7 @@ const vueConfig = {
     // If you want to turn on the proxy, please remove the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        target: 'http://192.168.16.105:8602/ocs-admin',
+        target: 'http://192.168.16.103:8602/ocs-admin',
         // target: 'http://ocs-admin.360arrow.com.cn/ocs-admin',
         ws: false,
         changeOrigin: true,