chenrui пре 10 месеци
родитељ
комит
a99effee2d

+ 10 - 11
src/views/promotionRulesManagement/promotionManagement/edit.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="promotionEdit-wrap">
+  <div class="promotionEdit-wrap" :style="{paddingBottom: pageType!='see'?'51px':'10px'}">
     <a-spin :spinning="spinning" tip="Loading...">
       <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
         <!-- 自定义的二级文字标题 -->
@@ -209,6 +209,7 @@
         :disabled="spinning"
         id="productInfoEdit-submit-btn"
         size="large"
+        v-if="pageType!='see'"
         @click="handleSave"
         style="padding: 0 60px;">保存</a-button>
     </div>
@@ -221,7 +222,6 @@
       :chooseData="chooseDataList"
       :chooseProduct="chooseProductList"
       :openModal="showProModal"
-      v-if="pageType!='see'"
       @ok="addProductSuccess"
       @close="closeProductModal"></chooseProduct>
   </div>
@@ -255,7 +255,7 @@ export default {
         content: '', // 内容
         contentLink: '', // 链接内容
         sort: undefined, // 排序
-        ruleEnableFlag: '0', // 参数配置 1勾选配置  0不能配置
+        ruleEnableFlag: '1', // 参数配置 1勾选配置  0不能配置
         publishState: 'UNPUBLISH',
         dealerEditFlag: '0', // 加盟商编辑 1是 0否
         // 参数配置数据
@@ -399,7 +399,7 @@ export default {
     //  确定保存
     handleSave () {
       const _this = this
-      if (_this.form.contentType == 'LINK') {
+      if (_this.form.contentType === 'LINK') {
         _this.form.content = _this.form.contentLink
         if (_this.form.ruleEnableFlag === '1') {
           _this.form.promoRule.ruleDetailList = _this.$refs.setContent.couponList
@@ -568,7 +568,6 @@ export default {
 .promotionEdit-wrap{
     position: relative;
     height: 100%;
-    padding-bottom: 51px;
     box-sizing: border-box;
     >.ant-spin-nested-loading{
       overflow-y: scroll;
@@ -587,9 +586,6 @@ export default {
         z-index: 0;
       }
     }
-    // /deep/.upload-file .ant-upload-list-item-info{
-    //   padding:2px !important;
-    // }
     //  商品图片描述
     .upload-desc{
       font-size: 12px;
@@ -598,9 +594,6 @@ export default {
     #promotionEdit-attachList{
       height: auto;
     }
-    // a{
-    //   color: inherit;
-    // }
     .box{
       border:1px solid #d9d9d9;
       border-radius:4px;
@@ -614,5 +607,11 @@ export default {
         z-index: 101;
       }
     }
+    /deep/.ant-radio-disabled{
+     span{
+        color:rgb(0,0,0) !important;
+      }
+
+    }
   }
 </style>

+ 248 - 0
src/views/promotionRulesManagement/promotionManagement/productTable.vue

@@ -0,0 +1,248 @@
+<template>
+  <div class="veTableCon">
+    <ve-table
+      border-y
+      v-show="!showEmpty"
+      :scroll-width="0"
+      :max-height="(tableHeight)"
+      :show-header="showTableHead"
+      :row-style-option="{clickHighlight: true}"
+      :cellSelectionOption="{enable: false}"
+      :virtual-scroll-option="{enable: true}"
+      :columns="columns"
+      :table-data="dataSource"
+    />
+    <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
+  </div>
+</template>
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { Empty } from 'ant-design-vue'
+export default {
+  name: 'DetailProductList',
+  mixins: [commonMixin],
+  props: {
+    newLoading: Boolean, // loadin
+    // 最大高度
+    maxHeight: {
+      type: [String, Number],
+      default: '300'
+    },
+    // 是否显示表格头部
+    showHeader: {
+      type: Boolean,
+      default: true
+    }
+  },
+  data () {
+    return {
+      spinning: false,
+      openDetailModal: false, // 活动规则详情弹框
+      detailSn: null, // 活动规则详情sn
+      activeList: [], // 活动列表
+      dataSource: [], // 列表原始数据
+      tableHeight: this.maxHeight, // 表格高度
+      // 自定义单元格样式
+      cellStyleOption: {
+        bodyCellClass: ({ row, column, rowIndex }) => {
+          if (row.id.indexOf('promo-') >= 0 && column.field === 'no') {
+            return 'table-body-cell-no'
+          }
+        }
+      },
+      // 表格列可拖曳
+      columnWidthResizeOption: {
+        // default false
+        enable: true,
+        // column resize min width
+        minWidth: 50
+      },
+      // 自定义单元格内容
+      cellSpanOption: {
+        bodyCellSpan: this.bodyCellSpan
+      },
+      isCityPrice: false, // 是否显示市级价
+      outStockStr: '', // 产品库存不足提示信息
+      showEmpty: true, // 是否显示空数据图片
+      showTableHead: true, // 是否显示表格头部
+      colspanNums: 13, // 单元格合并列数
+      hasOutStockOfActive: false,
+      simpleImage: Empty.PRESENTED_IMAGE_SIMPLE // 空图片
+    }
+  },
+  computed: {
+    columns () {
+      const _this = this
+      // 终端价格变价
+      const priceEdit = function (record, data) {
+        return (
+          <a-input placeholder="请输入"/>
+        )
+      }
+      // 操作按钮
+      const actionFormat = function (record, data) {
+        return (
+          <div>
+            <a-button size="small" type="link" class="button-info" onClick={() => _this.handleDel(record)}>删除</a-button>
+          </div>
+        )
+      }
+      const arr = [
+        { title: '序号', field: 'no', key: 'a', width: 40, align: 'center' },
+        { title: '产品编码', field: 'productBrandName', key: 'a', align: 'center', width: 80, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '全品类' } },
+        { title: '产品名称', field: 'productTypeName1', key: 'b', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
+        { title: '原厂编码', field: 'productTypeName2', key: 'c', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
+        { title: '活动价', field: 'productTypeName3', key: 'd', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return priceEdit(row, row[column.field]) } },
+        { title: '参考终端价', field: 'priceLevelDictValue', key: 'e', width: 80, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
+        { title: '操作', field: 'action', width: 80, key: 'f', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column }) => { return actionFormat(row, row[column.field]) } }
+      ]
+      return arr
+    }
+  },
+  methods: {
+    // 关闭详情弹窗
+    closeDetailModal () {
+      this.detailSn = null
+      this.openDetailModal = false
+    },
+    // 合并活动分类单元格
+    bodyCellSpan ({ row, column, rowIndex }) {
+      if (row.id.indexOf('promo-') >= 0) {
+        if (column.field == 'no') {
+          return {
+            rowspan: 1,
+            colspan: this.colspanNums
+          }
+        } else {
+          return {
+            rowspan: 0,
+            colspan: 0
+          }
+        }
+      }
+    },
+    // 查看活动详情
+    showDesc (row) {
+      this.detailSn = row.promoRuleSn
+      this.openDetailModal = true
+    },
+    // 获取销售单参与的活动列表
+    pageInit () {
+      salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
+        if (res.status == 200) {
+          this.activeList = res.data || []
+        }
+        this.$nextTick(() => {
+          this.searchTable()
+        })
+      })
+    },
+    // 查询表格数据
+    async searchTable () {
+      this.dataSource = []
+      this.disabled = true
+      this.spinning = true
+      // 参数
+      const params = {
+        salesBillSn: this.salesBillSn,
+        showStock: this.showStock,
+        warehouseSn: this.warehouseSn,
+        promotionFlag: this.promoFlag == '' ? undefined : this.promoFlag
+      }
+      // 参与活动数据
+      const active = this.activeList.filter(item => item.enabledFlag == 1)
+
+      // 正常产品
+      const hasSearchNormal = !params.promotionFlag || params.promotionFlag == 0
+      const proList = hasSearchNormal ? await salesDetailAllList(params).then(res => res.data) : []
+      const norTotal = hasSearchNormal ? await salesDetaiCount(params).then(res => res.data) : null
+
+      // 没有活动时,表格不显示统计数据
+      let listData = active.length ? (proList.length ? [{
+        id: 'promo-normal',
+        total: norTotal
+      }, ...proList] : []) : proList
+
+      // 有促销活动产品
+      if (params.promotionFlag != 0) {
+        // 循环获取活动产品
+        for (let i = 0; i < active.length; i++) {
+          const promo = active[i]
+          const activeParams = {
+            promoRuleSn: promo.promoRuleSn,
+            promoSn: promo.promoSn,
+            salesPromoSn: promo.salesPromoSn,
+            ...params
+          }
+
+          // 获取活动产品统计
+          const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
+          if (acTotal) {
+            // 采购额结余
+            acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
+            // 采购额超出
+            acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
+          }
+          // 有数据时才调用接口,避免做无用的调用
+          if (acTotal && acTotal.totalQty) {
+            // 获取活动产品列表
+            const aclist = await salesDetailAllList(activeParams).then(res => res.data)
+            // 合并结果数据
+            const retList = aclist.length ? [{
+              id: 'promo-' + i,
+              promo: promo,
+              total: acTotal
+            }, ...aclist] : []
+            // 将活动产品数据拼接
+            listData = aclist && aclist.length ? listData.concat(retList) : listData
+          }
+        }
+        // 如果活动没有任何产品,不显示统计一行
+        if (active.length) {
+          const hasAcp = listData.filter(item => item.id != 'promo-normal').filter(item => item.id.indexOf('promo-') >= 0)
+          if (hasAcp && hasAcp.length == 0) {
+            listData = listData.filter(item => item.id.indexOf('promo-') < 0) || []
+          }
+        }
+      }
+      // 赋值
+      this.dataSource = listData
+      // 格式化数据
+      let f = 0
+      let str = ''
+      this.outStockStr = ''
+      this.dataSource.map((item, i) => {
+        if (item.id.indexOf('promo-') >= 0) { f = f - 1 }
+        item.no = i + 1 + f
+        // 格式化数据
+        const productCode = (item.productEntity && item.productEntity.code) || (item.dealerProductEntity && item.dealerProductEntity.code)
+        const productName = (item.productEntity && item.productEntity.name) || (item.dealerProductEntity && item.dealerProductEntity.name)
+        const productOrigCode = (item.productEntity && item.productEntity.origCode) || (item.dealerProductEntity && item.dealerProductEntity.origCode)
+        const productOrigUnit = (item.productEntity && item.productEntity.unit) || (item.dealerProductEntity && item.dealerProductEntity.unit)
+        item.productCode = productCode || '--'
+        item.productName = productName || '--'
+        item.productOrigCode = productOrigCode == ' ' ? '--' : productOrigCode
+        item.productOrigUnit = productOrigUnit || '--'
+        item.epushedQty = Number(item.pushedQty) - Number(item.pushQty)
+        if (item.unpushedQty && (Number(item.stockQty) < Number(item.unpushedQty))) {
+          str += item.productCode + '、'
+          if (item.promotionFlag != 0) {
+            this.hasOutStockOfActive = true
+          }
+        }
+      })
+      if (str.length > 0) {
+        str = str.substr(0, str.length - 1)
+        this.outStockStr = '产品编号为:' + str + '的产品库存不足;'
+      }
+      this.showEmpty = this.dataSource.length <= 0
+      this.tableHeight = (this.showEmpty ? 200 : this.maxHeight) + 'px'
+      this.spinning = false
+      this.disabled = false
+    }
+  }
+}
+</script>
+
+<style>
+</style>

+ 6 - 2
src/views/promotionRulesManagement/promotionManagement/setPromotion.vue

@@ -119,6 +119,7 @@
                           <a-tag :closable="!disabledVal" @close="delBuyerName(item,con)" v-for="con in item.ruleProductList" :key="con.productSn">
                             {{ con.productCode }}
                           </a-tag>
+                          <!-- <productTable></productTable> -->
                         </div>
                       </a-form-model-item>
                       <a-form-model-item class="productName" label="券适用范围" prop="range">
@@ -191,12 +192,13 @@
 import { commonMixin } from '@/utils/mixin'
 import moment from 'moment'
 import { VSelect } from '@/components'
+import productTable from './productTable'
 import { productTypeQuery } from '@/api/productType'
 import { getNewScopeSn } from '@/api/promotion'
 export default {
   name: 'PromotionAddModal',
   mixins: [commonMixin],
-  components: { VSelect },
+  components: { VSelect, productTable },
   props: {
     disabledVal: {
       type: Boolean,
@@ -430,7 +432,9 @@ export default {
     },
     // 详情赋值
     setDetailData (info, arr) {
-      info.productRangeList = info.productRangeList.map(item => item.productTypeSn)
+      if (info.productRangeList && info.productRangeList.length > 0) {
+        info.productRangeList = info.productRangeList.map(item => item.productTypeSn)
+      }
       if (info.validType === 'FIXED') {
         this.time = [info.validStartDate, info.validEndDate]
       }