소스 검색

销售单选择促销品

lilei 4 년 전
부모
커밋
2c5fb1b821
4개의 변경된 파일171개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 0
      src/api/sales.js
  2. 18 0
      src/api/salesDetail.js
  3. 120 0
      src/views/salesManagement/salesQuery/chooseActive.vue
  4. 24 5
      src/views/salesManagement/salesQuery/edit.vue

+ 9 - 0
src/api/sales.js

@@ -101,3 +101,12 @@ export const salesReceipt = (params) => {
     method: 'get'
   })
 }
+
+// 获取促销活动
+export const getPromoacActiveList = (params) => {
+  return axios({
+    url: `/sales/getPromoacActiveList/${params.salesBillSn}`,
+    data: params,
+    method: 'get'
+  })
+}

+ 18 - 0
src/api/salesDetail.js

@@ -86,3 +86,21 @@ export const salesDetailDelAll = (params) => {
     method: 'post'
   })
 }
+
+// 获取产品适用活动的促销产品列表
+export const getPromoGoodsList = (params) => {
+  return axios({
+    url: `/sales/detail/getPromoGoodsList`,
+    data: params,
+    method: 'post'
+  })
+}
+
+// 批量添加促销品
+export const addPromoGoods = (params) => {
+  return axios({
+    url: `/sales/detail/addPromoGoods`,
+    data: params,
+    method: 'post'
+  })
+}

+ 120 - 0
src/views/salesManagement/salesQuery/chooseActive.vue

@@ -0,0 +1,120 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    title="促销品列表"
+    v-model="isShow"
+    @cancle="cansel"
+    width="80%">
+    <a-card size="small" :bordered="false" class="productInfoList-wrap">
+      <!-- 列表 -->
+      <a-table
+        class="sTable"
+        ref="table"
+        size="small"
+        :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+        :rowKey="(record) => record.id"
+        :columns="columns"
+        :data-source="list"
+        :loading="loading"
+        :scroll="{ y: 350 }"
+        bordered>
+        <!-- 销售数量 -->
+        <template slot="salesNums" slot-scope="text, record">
+          <a-input-number
+            size="small"
+            :max="999999"
+            :min="1"
+            v-model="record.qty"
+            :precision="0"
+            :step="1"
+          />
+        </template>
+      </a-table>
+      <div style="display: flex;justify-content: center;padding: 10px 0;">
+        <a-button size="large" type="primary" class="button-primary" @click="handleSubmit" style="padding: 0 60px;">
+          确定
+        </a-button>
+        <a-button size="large" style="padding: 0 60px;margin-left: 15px;font-size: 12px;" @click="cansel">
+          取消
+        </a-button>
+      </div>
+    </a-card>
+  </a-modal>
+</template>
+
+<script>
+import { STable, VSelect } from '@/components'
+import { getPromoGoodsList } from '@/api/salesDetail'
+export default {
+  name: 'ChooseProduct',
+  components: { STable, VSelect },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    }
+  },
+  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: '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 || '--' } }
+      ],
+      selectedRowKeys: [], // Check here to configure the default column
+      selectedRows: [],
+      loading: false,
+      list: []
+    }
+  },
+  methods: {
+    getData (row) {
+      this.loading = true
+      getPromoGoodsList({ salesBillDetailSn: row.salesBillDetailSn }).then(res => {
+        this.list = res.data.list
+        this.loading = false
+      })
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    // 选择产品
+    handleSubmit () {
+      const _this = this
+      if (_this.selectedRowKeys.length < 1) {
+        _this.$message.warning('请选择促销品!')
+        return
+      }
+      const obj = []
+      _this.selectedRows.map(item => {
+        obj.push(item.productSn)
+      })
+      _this.$emit('ok', obj)
+    },
+    cansel () {
+      this.$emit('close')
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+      }
+    }
+  }
+}
+</script>

+ 24 - 5
src/views/salesManagement/salesQuery/edit.vue

@@ -99,13 +99,13 @@
             class="button-error"
             @click="handleDel(record)"
           >删除</a-button>
-          <!-- <a-button
+          <a-button
             size="small"
             type="primary"
             :loading="delLoading"
             class="button-warning"
             @click="handleSelCx(record)"
-          >选择促销品</a-button> -->
+          >选择促销品</a-button>
         </template>
       </s-table>
     </a-card>
@@ -123,6 +123,8 @@
     </a-affix>
     <!-- 选择客户弹框 -->
     <choose-custom-modal ref="custModal" :show="openModal" @cancel="openModal=false" />
+    <!-- 添加产品 -->
+    <ChooseActive ref="activeProduct" :openModal="newActive" @ok="addNewActive" @close="newActive=false"></ChooseActive>
   </div>
 </template>
 
@@ -130,12 +132,13 @@
 import { STable, VSelect } from '@/components'
 import queryPart from './queryPart.vue'
 import chooseCustomModal from './chooseCustomModal.vue'
-import { salesDetailBySn, salesWriteSubmit } from '@/api/sales'
+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'
 export default {
   name: 'SalesDetail',
-  components: { STable, VSelect, queryPart, chooseCustomModal, EditableCell },
+  components: { STable, VSelect, queryPart, chooseCustomModal, EditableCell, ChooseActive },
   data () {
     return {
       salesBillSn: null, // 销售单sn
@@ -143,11 +146,13 @@ export default {
       isInster: false, // 是否正在添加产品
       openModal: false, // 客户弹框
       delLoading: false,
+      newActive: false, // 选择促销品
       detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
       dataSource: [],
       productForm: {
         salesBillSn: ''
       },
+      activeList: [], // 促销活动
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
@@ -314,6 +319,20 @@ export default {
           this.$message.success(res.message)
         }
       })
+    },
+    // 获取促销活动
+    getPromoacActiveList () {
+      getPromoacActiveList({ salesBillSn: this.salesBillSn }).then(res => {
+        this.activeList = res.data || []
+      })
+    },
+    // 选择促销品
+    handleSelCx (row) {
+      this.newActive = true
+      this.$refs.activeProduct.getData(row)
+    },
+    addNewActive () {
+
     }
   },
   mounted () {
@@ -321,8 +340,8 @@ export default {
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
-      console.log('beforeRouteEnter')
       vm.salesBillSn = vm.$route.params.sn
+      vm.getPromoacActiveList()
     })
   }
 }