Jelajahi Sumber

促销规则

chenrui 1 tahun lalu
induk
melakukan
1996b25284

+ 5 - 1
src/views/common/chooseTypeModal.vue

@@ -17,7 +17,7 @@
         style="height: 400px;overflow-y: scroll;"
         checkable
         @check="onCheck"
-        :checkStrictly="true"
+        :checkStrictly="linkageStatus"
         v-model="checkedKeys"
         :treeData="productTypeList"
         :replaceFields="replaceFields"
@@ -60,6 +60,10 @@ export default {
     type: { //  类型,促销规则promo
       type: String,
       default: ''
+    },
+    linkageStatus: { // 父子是否联动
+      type: Boolean,
+      default: true
     }
   },
   data () {

+ 17 - 17
src/views/promotionRulesManagement/dealerPromotions/chooseProductsModal.vue

@@ -34,7 +34,7 @@
                 </a-col>
                 <a-col :md="6" :sm="24">
                   <a-form-model-item label="产品分类">
-                    <productTypeAll :isAll="type!='default'" placeholder="请选择产品分类" @change="changeProductType" v-model="queryParam.productType" id="chooseProducts-productType"></productTypeAll>
+                    <productTypeAll placeholder="请选择产品分类" @change="changeProductType" v-model="queryParam.productType" id="chooseProducts-productType"></productTypeAll>
                   </a-form-model-item>
                 </a-col>
                 <a-col :md="6" :sm="24">
@@ -62,12 +62,17 @@
             size="small"
             :rowKey="(record) => record.productSn"
             rowKeyName="productSn"
-            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: (this.type == 'supplier') && (this.chooseData && this.chooseData.indexOf(record.productSn) > -1) }}) }"
+            :row-selection="{ columnWidth: 40, getCheckboxProps:record =>({props: { disabled: this.chooseData && this.chooseData.indexOf(record.productSn) > -1 }}) }"
             @rowSelection="rowSelectionFun"
             :columns="columns"
             :data="loadData"
             :defaultLoadData="false"
             bordered>
+            <!-- 产品分类 -->
+            <template slot="productType" slot-scope="text, record">
+              <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
+              <span v-else>--</span>
+            </template>
           </s-table>
         </div>
       </div>
@@ -80,8 +85,7 @@ import { STable } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
 import ProductBrand from '@/views/common/productBrand.js'
 import productTypeAll from '@/views/common/productTypeAll.js'
-import { dealerScopeValidProduct } from '@/api/dealerScope'
-import { productList, productPricedList, productPricingList } from '@/api/product'
+import { productList } from '@/api/product'
 export default {
   name: 'ChooseProductsModal',
   components: { STable, tablePagination, ProductBrand, productTypeAll },
@@ -95,14 +99,6 @@ export default {
       default: () => {
         return []
       }
-    },
-    type: { //  类型,经销权设置dealership,  供应商添加产品supplier
-      type: String,
-      default: 'default'
-    },
-    dealerSn: {
-      type: String || Number,
-      default: ''
     }
   },
   data () {
@@ -127,7 +123,12 @@ export default {
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'code', align: 'center' },
-        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } }
+        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '原厂编码', dataIndex: 'origCode', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '品牌', dataIndex: 'productBrandName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'center' },
+        { title: '包装数', dataIndex: 'packQtyV', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '单位', dataIndex: 'unit', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -174,7 +175,8 @@ export default {
     //  重置
     resetSearchForm () {
       this.resetData()
-      this.$refs.table.clearTable()
+      this.$refs.table.refresh()
+      // this.$refs.table.clearTable()
     },
     // 保存
     handleSave () {
@@ -201,11 +203,9 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.$refs.table.clearTable()
-        this.resetData()
+        this.resetSearchForm()
       } else {
         const _this = this
-        _this.$refs.table.refresh()
         // let selectedRows = []
         // const selectedRowKeys = []
         // selectedRows = this.chooseData

+ 41 - 27
src/views/promotionRulesManagement/dealerPromotions/detail.vue

@@ -51,16 +51,27 @@
           :rowKey="(record) => record.id"
           :columns="columns"
           :data="loadData"
-          :scroll="{ y: 500 }"
           :defaultLoadData="false"
           :showPagination="false"
           bordered>
-          <!-- 产品编码 -->
-          <template slot="productCode" slot-scope="text, record">
-            <a-badge count="促" v-if="record.promotionFlag == 1">
-              <div style="padding-right: 15px;">{{ text }}</div>
-            </a-badge>
-            <span v-else>{{ text }}</span>
+          <!-- 门槛规则 -->
+          <template slot="cillProduct" slot-scope="text, record">
+            <div v-if="record.gateFlag === '1'">
+              购买满{{ record.gateAmount }}元门槛产品,可使用 {{ record.quotaAmount }}元配额,采购规则中的正价商品
+            </div>
+            <span v-else>--</span>
+          </template>
+          <!-- 规则 -->
+          <template slot="ruleProduct" slot-scope="text, record">
+            <div v-if="record.promotionRuleType == 'BUY_PROD_GIVE_PROD'">
+              购买满{{ record.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品
+            </div>
+            <div v-else-if="record.promotionRuleType == 'BUY_PROD_GIVE_MONEY'">
+              购买满{{ record.regularAmount }}元正价产品,送{{ record.giveAmount }}元促销品采购额
+            </div>
+            <div v-else>
+              特价产品
+            </div>
           </template>
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
@@ -96,11 +107,11 @@
     <!-- 详情 -->
     <detailModal :openModal="openDetailModal" @close="openDetailModal = false"></detailModal>
     <!-- 买产品送产品  弹窗 -->
-    <sendProductsModal :openModal="openSendProductsModal" :promotionSn="$route.query.sn" @close="openSendProductsModal = false"></sendProductsModal>
+    <sendProductsModal :openModal="openSendProductsModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendProductsModal = false"></sendProductsModal>
     <!-- 买产品送采购额 弹窗 -->
-    <sendAmountModal :openModal="openSendAmountModal" @close="openSendAmountModal = false"></sendAmountModal>
+    <sendAmountModal :openModal="openSendAmountModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSendAmountModal = false"></sendAmountModal>
     <!-- 特价产品  弹窗 -->
-    <specialOfferModal :openModal="openSpecialOfferModal" @close="openSpecialOfferModal = false"></specialOfferModal>
+    <specialOfferModal :openModal="openSpecialOfferModal" :promotionSn="$route.query.sn" @ok="$refs.table.refresh()" @close="openSpecialOfferModal = false"></specialOfferModal>
   </div>
 </template>
 
@@ -122,9 +133,21 @@ export default {
     return {
       disabled: false,
       spinning: false,
+      detailData: null, //  详情数据
+      countData: null, // 数量数据
+      fromRouter: null,
+      openModal: false,
+      isShowBisiceInfo: false,
+      openCustomerModal: false,
+      openType: undefined,
+      openDetailModal: false,
+      openSendProductsModal: false,
+      openSendAmountModal: false,
+      openSpecialOfferModal: false,
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
+        this.spinning = true
         const dataAjax = Object.assign(parameter, { sn: this.$route.query.sn })
         return getRuleQueryList(dataAjax).then(res => {
           let data
@@ -135,31 +158,22 @@ export default {
             }
             this.disabled = false
           }
+          this.spinning = false
           return data
         })
-      },
-      detailData: null, //  详情数据
-      countData: null, // 数量数据
-      fromRouter: null,
-      openModal: false,
-      isShowBisiceInfo: false,
-      openCustomerModal: false,
-      openType: undefined,
-      openDetailModal: false,
-      openSendProductsModal: false,
-      openSendAmountModal: false,
-      openSpecialOfferModal: false
+      }
     }
   },
   computed: {
     columns () {
+      const _this = this
       const arr = [
         { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
-        { title: '促销类型', dataIndex: 'productEntity.unit', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '规则门槛', dataIndex: 'productEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '规则', dataIndex: 'productEntity.origCode', width: '28%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '订单起订金额', dataIndex: 'productCode', width: '15%', scopedSlots: { customRender: 'productCode' }, align: 'center' },
-        { title: '订单经费上限', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '规则门槛', scopedSlots: { customRender: 'cillProduct' }, width: '20%', align: 'center' },
+        { title: '规则', scopedSlots: { customRender: 'ruleProduct' }, width: '28%', align: 'center' },
+        { title: '订单起订金额(元)', dataIndex: 'minOrderAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '订单经费上限(元)', dataIndex: 'upperLimitAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
       ]
       return arr

+ 78 - 69
src/views/promotionRulesManagement/dealerPromotions/sendAmountModal.vue

@@ -35,7 +35,7 @@
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
           <div class="ruleDescList">
-            <a-select default-value="0" :value="form.regularSameFlag" style="width: 100px" size="small">
+            <a-select default-value="0" v-model="form.regularSameFlag" style="width: 100px" size="small">
               <a-select-option value="1">
                 同款
               </a-select-option>
@@ -49,12 +49,6 @@
             <a-input-number v-model="form.giveAmount" :min="0" :step="1" :precision="0" size="small"/>
             元%促销品采购额
           </div>
-          <div class="ruleDescList">
-            <a-checkbox size="small" :value="form.restrictFlag">
-              限制正价产品款数
-            </a-checkbox>
-            <a-input-number v-model="form.restrictCategory" :min="0" :step="1" :precision="0" size="small"/>
-          </div>
         </a-form-model-item>
         <a-form-model-item label="金额叠加" prop="accrualFlag">
           <a-radio-group v-model="form.accrualFlag" button-style="solid" size="small">
@@ -74,7 +68,7 @@
             </a-tooltip>
             订单起订金额
           </span>
-          <a-select default-value="1" :value="form.minOrderFlag" style="width: 160px" size="small">
+          <a-select default-value="1" v-model="form.minOrderFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -99,7 +93,7 @@
             </a-tooltip>
             活动经费上限
           </span>
-          <a-select default-value="1" :value="form.upperLimitFlag" style="width: 160px" size="small">
+          <a-select default-value="1" v-model="form.upperLimitFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -117,8 +111,8 @@
             :precision="2"
             placeholder="请输入金额"/>
         </a-form-model-item>
-        <a-form-model-item label="采购额适用范围" prop="regularPromotionSameFlag">
-          <a-radio-group v-model="form.regularPromotionSameFlag" button-style="solid" size="small">
+        <a-form-model-item label="采购额适用范围" prop="scopeFlag">
+          <a-radio-group v-model="form.scopeFlag" button-style="solid" size="small">
             <a-radio-button value="0">
               部分产品
             </a-radio-button>
@@ -137,7 +131,7 @@
             <a-radio-button value="b">
               正价产品
             </a-radio-button>
-            <a-radio-button value="c" v-show="form.regularPromotionSameFlag==='0'">
+            <a-radio-button value="c" v-show="form.scopeFlag==='0'">
               促销产品
             </a-radio-button>
           </a-radio-group>
@@ -147,9 +141,9 @@
             class="button-info"
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
-        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct" selectType="gateProduct"></tableType1></div>
-        <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct" selectType="regularProduct"></tableType1></div>
-        <div v-show="chooseVal=='c'"><tableType2 ref="offerProduct" selectType="specialProductList"></tableType2></div>
+        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
+        <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct"></tableType1></div>
+        <div v-show="chooseVal=='c'"><tableType2 ref="offerProduct"></tableType2></div>
       </a-card>
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
@@ -164,7 +158,7 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
@@ -174,7 +168,7 @@ export default {
       type: Boolean,
       default: false
     },
-    itemSn: {
+    promotionSn: {
       type: [Number, String],
       default: ''
     }
@@ -193,16 +187,15 @@ export default {
         gateAmount: '',
         quotaAmount: '',
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularQty: '',
-        promotionQty: '',
-        restrictFlag: undefined, // 限制正价产品款数
+        regularAmount: '',
+        giveAmount: '',
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
         minOrderAmount: '',
         upperLimitFlag: '1', // 活动经费上限
         upperLimitAmount: '',
-        regularPromotionSameFlag: undefined
+        scopeFlag: undefined
       },
       rules: {
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
@@ -210,7 +203,7 @@ export default {
         accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }],
-        regularPromotionSameFlag: [{ required: true, message: '请选择采购额适用范围', trigger: 'change' }]
+        scopeFlag: [{ required: true, message: '请选择采购额适用范围', trigger: 'change' }]
       },
       chooseVal: 'a'
     }
@@ -226,54 +219,51 @@ export default {
         }
       }
     },
-    //  附件上传
-    changeAttach (file) {
-      this.attachList = JSON.parse(file)
-      this.attachList.map(item => {
-        item.fileType = item.extName
-      })
-    },
-    // 选择参与客户
-    handleDealerModal () {
-      this.openDealerModal = true
-      const _this = this
-      if (_this.chooseDealerList.length == 0) {
-        _this.form.promoBuyerList = []
-      }
-      const arr = _this.chooseDealerList.map(item => {
-        return item.buyerSn
-      })
-      // 选择经销商回显
-      _this.$nextTick(() => {
-        _this.$refs.dealerChoose.pageInit(arr)
-      })
-    },
-    // 添加经销商
-    handleAddDealer (list) {
-      this.chooseDealerList = list.map(con => {
-        return {
-          buyerSn: con.dealerSn,
-          buyerName: con.dealerName
-        }
-      })
-      this.openDealerModal = false
-      // 移除表单必填项
-      this.$refs.ruleForm.clearValidate('promoBuyerList')
-    },
     //  保存
     handleSave () {
       const _this = this
+      // 验证必填
+      if (_this.form.gateFlag == '1') {
+        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
+          _this.$message.warning('规则门槛条件不能为空!')
+          return
+        }
+      }
+      if (!_this.form.regularAmount || !_this.form.giveAmount) {
+        _this.$message.warning('满赠规则条件不能为空!')
+        return
+      }
+
+      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
+        _this.$message.warning('请输入订单起订限制金额数!')
+        return
+      }
+      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
+        _this.$message.warning('请输入活动经费上限金额!')
+        return
+      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
-          form.attachmentList = _this.attachList
+          if (form.gateFlag == '1') {
+            form.gateProductList = this.$refs.cillProduct.getResultVal()
+          } else {
+            form.gateProductList = []
+          }
+          if (form.scopeFlag == '0') {
+            form.giftProductList = this.$refs.offerProduct.getResultVal()
+          } else {
+            form.giftProductList = []
+          }
+          form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
+          form.promotionSn = _this.promotionSn
           _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
+          promotionSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
               }, 1000)
             } else {
@@ -285,6 +275,34 @@ export default {
         }
       })
     },
+    // 重置表格
+    resetSearchForm () {
+      this.form = {
+        promotionRuleType: 'BUY_PROD_GIVE_MONEY', // 买产品送采购额
+        gateFlag: '0', // 门槛
+        gateAmount: '',
+        quotaAmount: '',
+        regularSameFlag: '0', // 满赠规则  不同款商品
+        regularAmount: '',
+        giveAmount: '',
+        restrictCategory: '',
+        accrualFlag: '1', // 数量叠加
+        minOrderFlag: '1', // 起订金额
+        minOrderAmount: '',
+        upperLimitFlag: '1', // 活动经费上限
+        upperLimitAmount: '',
+        scopeFlag: undefined,
+        gateProductList: undefined,
+        giftProductList: undefined,
+        regularProductList: undefined
+      }
+      this.$nextTick(() => {
+        this.$refs.ruleForm.resetFields()
+        this.$refs.cillProduct.reSetTableData()
+        this.$refs.normalPriceProduct.reSetTableData()
+        this.$refs.offerProduct.reSetTableData()
+      })
+    },
     // 获取编辑详情
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -306,10 +324,6 @@ export default {
           this.detailsData = null
         }
       })
-    },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
     }
   },
   watch: {
@@ -321,12 +335,7 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
         if (this.itemSn) {
           this.getDetail()

+ 73 - 18
src/views/promotionRulesManagement/dealerPromotions/sendProductsModal.vue

@@ -35,7 +35,7 @@
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
           <div class="ruleDescList">
-            <a-select default-value="0" :value="form.regularSameFlag" style="width: 100px" size="small">
+            <a-select default-value="0" v-model="form.regularSameFlag" style="width: 100px" size="small">
               <a-select-option value="1">
                 同款
               </a-select-option>
@@ -74,7 +74,7 @@
             </a-tooltip>
             订单起订金额
           </span>
-          <a-select default-value="1" :value="form.minOrderFlag" style="width: 160px" size="small">
+          <a-select v-model="form.minOrderFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -99,7 +99,7 @@
             </a-tooltip>
             活动经费上限
           </span>
-          <a-select default-value="1" :value="form.upperLimitFlag" style="width: 160px" size="small">
+          <a-select v-model="form.upperLimitFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -147,9 +147,9 @@
             class="button-info"
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
-        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct" selectType="gateProduct"></tableType1></div>
-        <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct" selectType="regularProduct"></tableType1></div>
-        <div v-show="chooseVal=='c'"><tableType2 ref="offerProduct" selectType="specialProductList"></tableType2></div>
+        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
+        <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct"></tableType1></div>
+        <div v-show="chooseVal=='c'"><tableType2 ref="offerProduct"></tableType2></div>
       </a-card>
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
@@ -229,21 +229,52 @@ export default {
     //  保存
     handleSave () {
       const _this = this
-      const tableData = this.$refs.cillProduct.getResultVal()
-      const newtableData = this.$refs.normalPriceProduct.getResultVal()
-      const newtableData1 = this.$refs.offerProduct.getResultVal()
-      debugger
+      // 验证必填
+      if (_this.form.gateFlag == '1') {
+        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
+          _this.$message.warning('规则门槛条件不能为空!')
+          return
+        }
+      }
+      if (!_this.form.regularQty || !_this.form.promotionQty) {
+        _this.$message.warning('满赠规则条件不能为空!')
+        return
+      }
+      if (_this.form.restrictFlag && !_this.form.restrictCategory) {
+        _this.$message.warning('请输入限制正价产品款数个数!')
+        return
+      }
+
+      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
+        _this.$message.warning('请输入订单起订限制金额数!')
+        return
+      }
+      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
+        _this.$message.warning('请输入活动经费上限金额!')
+        return
+      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
-          form.attachmentList = _this.attachList
+          if (form.gateFlag == '1') {
+            form.gateProductList = this.$refs.cillProduct.getResultVal()
+          } else {
+            form.gateProductList = []
+          }
+          if (form.regularPromotionSameFlag == '0') {
+            form.giftProductList = this.$refs.offerProduct.getResultVal()
+          } else {
+            form.giftProductList = []
+          }
+          form.regularProductList = this.$refs.normalPriceProduct.getResultVal()
+          form.promotionSn = _this.promotionSn
           _this.spinning = true
           promotionSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
               }, 1000)
             } else {
@@ -255,6 +286,35 @@ export default {
         }
       })
     },
+    // 重置表格
+    resetSearchForm () {
+      this.form = {
+        promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
+        gateFlag: '0', // 门槛
+        gateAmount: '',
+        quotaAmount: '',
+        regularSameFlag: '0', // 满赠规则  不同款商品
+        regularQty: '',
+        promotionQty: '',
+        restrictFlag: undefined, // 限制正价产品款数
+        restrictCategory: '',
+        accrualFlag: '1', // 数量叠加
+        minOrderFlag: '1', // 起订金额
+        minOrderAmount: '',
+        upperLimitFlag: '1', // 活动经费上限
+        upperLimitAmount: '',
+        regularPromotionSameFlag: undefined,
+        gateProductList: undefined,
+        giftProductList: undefined,
+        regularProductList: undefined
+      }
+      this.$nextTick(() => {
+        this.$refs.ruleForm.resetFields()
+        this.$refs.cillProduct.reSetTableData()
+        this.$refs.normalPriceProduct.reSetTableData()
+        this.$refs.offerProduct.reSetTableData()
+      })
+    },
     // 获取编辑详情
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -287,12 +347,7 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
         if (this.itemSn) {
           this.getDetail()

+ 63 - 57
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -7,7 +7,7 @@
     title="规则设置"
     v-model="isShow"
     @cancel="isShow=false"
-    width="70%">
+    width="80%">
     <a-spin :spinning="spinning" tip="Loading...">
       <a-form-model
         id="promotionList-basicInfo-form"
@@ -17,7 +17,7 @@
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
         <a-form-model-item label="规则门槛" prop="gateFlag">
-          <a-radio-group v-model="form.gateFlag" button-style="solid" size="small">
+          <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="handleChange">
             <a-radio-button value="1">
             </a-radio-button>
@@ -25,7 +25,7 @@
             </a-radio-button>
           </a-radio-group>
-          <div class="ruleDescList">
+          <div class="ruleDescList" v-if="form.gateFlag && form.gateFlag === '1'">
             购买满
             <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
             元门槛产品,可使用
@@ -40,7 +40,7 @@
             </a-tooltip>
             订单起订金额
           </span>
-          <a-select default-value="1" :value="form.minOrderFlag" style="width: 160px" size="small">
+          <a-select default-value="1" v-model="form.minOrderFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -65,7 +65,7 @@
             </a-tooltip>
             活动经费上限
           </span>
-          <a-select default-value="1" :value="form.upperLimitFlag" style="width: 160px" size="small">
+          <a-select default-value="1" v-model="form.upperLimitFlag" style="width: 160px" size="small">
             <a-select-option value="0">
               不限
             </a-select-option>
@@ -90,8 +90,8 @@
             <a-radio-button value="a" v-show="form.gateFlag==='1'">
               门槛产品
             </a-radio-button>
-            <a-radio-button value="c">
-              促销产品
+            <a-radio-button value="d">
+              特价产品
             </a-radio-button>
           </a-radio-group>
           <div>
@@ -108,8 +108,8 @@
               id="promotionList-edit-btn">+新增产品</a-button>
           </div>
         </div>
-        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct" selectType="gateProduct"></tableType1></div>
-        <div v-show="chooseVal=='c'"> <tableType3></tableType3></div>
+        <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct"></tableType1></div>
+        <div v-show="chooseVal=='d'"><tableType3 ref="specialProduct"></tableType3></div>
       </a-card>
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
@@ -124,7 +124,7 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType3 from './tableType3.vue'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
 export default {
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
@@ -134,7 +134,7 @@ export default {
       type: Boolean,
       default: false
     },
-    itemSn: {
+    promotionSn: {
       type: [Number, String],
       default: ''
     }
@@ -166,54 +166,49 @@ export default {
     }
   },
   methods: {
-    //  附件上传
-    changeAttach (file) {
-      this.attachList = JSON.parse(file)
-      this.attachList.map(item => {
-        item.fileType = item.extName
-      })
-    },
-    // 选择参与客户
-    handleDealerModal () {
-      this.openDealerModal = true
-      const _this = this
-      if (_this.chooseDealerList.length == 0) {
-        _this.form.promoBuyerList = []
+    // 门槛产品
+    handleChange (e) {
+      if (e.target.value == '1') {
+        this.chooseVal = 'a'
+      } else {
+        this.chooseVal = 'd'
       }
-      const arr = _this.chooseDealerList.map(item => {
-        return item.buyerSn
-      })
-      // 选择经销商回显
-      _this.$nextTick(() => {
-        _this.$refs.dealerChoose.pageInit(arr)
-      })
-    },
-    // 添加经销商
-    handleAddDealer (list) {
-      this.chooseDealerList = list.map(con => {
-        return {
-          buyerSn: con.dealerSn,
-          buyerName: con.dealerName
-        }
-      })
-      this.openDealerModal = false
-      // 移除表单必填项
-      this.$refs.ruleForm.clearValidate('promoBuyerList')
     },
     //  保存
     handleSave () {
       const _this = this
+      // 验证必填
+      if (_this.form.gateFlag == '1') {
+        if (!_this.form.gateAmount || !_this.form.quotaAmount) {
+          _this.$message.warning('规则门槛条件不能为空!')
+          return
+        }
+      }
+      if (_this.form.minOrderFlag == 1 && !_this.form.minOrderAmount) {
+        _this.$message.warning('请输入订单起订限制金额数!')
+        return
+      }
+      if (_this.form.upperLimitFlag == 1 && !_this.form.upperLimitAmount) {
+        _this.$message.warning('请输入活动经费上限金额!')
+        return
+      }
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
-          form.attachmentList = _this.attachList
+          if (form.gateFlag == '1') {
+            form.gateProductList = _this.$refs.cillProduct.getResultVal()
+          } else {
+            form.gateProductList = []
+          }
+          form.specialProductList = _this.$refs.specialProduct.getResultVal()
+          form.promotionSn = _this.promotionSn
           _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
+          promotionSave(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
               }, 1000)
             } else {
@@ -225,6 +220,26 @@ export default {
         }
       })
     },
+    // 重置表格
+    resetSearchForm () {
+      this.form = {
+        promotionRuleType: 'PROMO_PROD', // 特价产品
+        gateFlag: '0', // 门槛
+        gateAmount: '',
+        quotaAmount: '',
+        minOrderFlag: '1', // 起订金额
+        minOrderAmount: '',
+        upperLimitFlag: '1', // 活动经费上限
+        upperLimitAmount: '',
+        gateProductList: undefined,
+        specialProductList: undefined
+      }
+      this.$nextTick(() => {
+        this.$refs.ruleForm.resetFields()
+        this.$refs.cillProduct.reSetTableData()
+        this.$refs.specialProduct.reSetTableData()
+      })
+    },
     // 获取编辑详情
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -246,10 +261,6 @@ export default {
           this.detailsData = null
         }
       })
-    },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
     }
   },
   watch: {
@@ -261,17 +272,12 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
         if (this.itemSn) {
           this.getDetail()
         } else {
-          this.chooseVal = this.form.gateFlag == '0' ? 'c' : 'a'
+          this.chooseVal = this.form.gateFlag == '0' ? 'd' : 'a'
         }
       }
     }

+ 107 - 52
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -1,23 +1,22 @@
 <template>
   <div class="pages-wrap">
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       style="margin-top:10px;"
       ref="table"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
-      :data="loadData"
-      :defaultLoadData="false"
+      :data-source="dataSource"
       bordered>
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
         <div style="max-height:80px;width:100%;overflow-y:scroll;">
-          <a-row v-if="record.productTypeList && record.productTypeList.length>0">
+          <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="18">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeList" :key="i">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,con,'typeList')" v-for="(con,i) in record.productTypeArr" :key="i">
                 {{ con.title }}
               </a-tag>
             </a-col>
@@ -39,9 +38,9 @@
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
         <div style="max-height:106spx;overflow-y:scroll;">
-          <a-row v-if="record.productBrandList && record.productBrandList.length>0">
+          <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandList" :key="j">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,item,'brandList')" v-for="(item,j) in record.productBrandArr" :key="j">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -65,8 +64,8 @@
         <div style="max-height:64px;overflow-y:scroll;">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'productList')" v-for="(item,k) in record.productThisList" :key="k">
-                {{ item.code }}
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(index,item,'productList')" v-for="(item,k) in record.productThisList" :key="k">
+                {{ item.productCode }}
               </a-tag>
             </a-col>
             <a-col :span="4" style="text-align:right;">
@@ -115,14 +114,14 @@
           删除
         </a-button>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <chooseTypeModal :openModal="openTypeModal" :linkageStatus="false" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
     <!-- 选择产品 -->
     <chooseProductsModal
       type="dealership"
@@ -135,25 +134,19 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
-
-import { sparePartsReturnList } from '@/api/sparePartsReturn'
 import { getNewScopeSn } from '@/api/promotion'
 export default {
   name: 'TableType1',
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
   props: {
     itemSn: {
       type: [Number, String],
       default: ''
-    },
-    selectType: {
-      type: String,
-      default: ''
     }
   },
   data () {
@@ -166,35 +159,10 @@ export default {
         { title: '设置起订量', width: '25%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
-      queryParam: {},
       dataSource: [],
       openBrandModal: false,
       openTypeModal: false,
       openProductsModal: false,
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.spinning = true
-
-        // return sparePartsReturnList(Object.assign(parameter, this.queryParam)).then(res => {
-        //   let data
-        //   if (res.status == 200) {
-        //     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
-        //     }
-        //     this.dataSource[this.selectType] = data.list
-        //   }
-        //   this.spinning = false
-        //   return data
-        // })
-        return new Promise((resolve, reject) => {
-          resolve({
-            list: [],
-            count: 0
-          })
-        })
-      },
       chooseBrand: [],
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
@@ -212,23 +180,71 @@ export default {
         if (res.status == 200) {
           const newData = {
             productScopeSn: res.data,
+            productTypeArr: [],
             productTypeList: [],
+            productBrandArr: [],
             productBrandList: [],
             productThisList: []
           }
-          _this.dataSource[_this.selectType].push(newData)
+          _this.dataSource.push(newData)
         } else {
           _this.spinning = false
         }
       })
     },
+    // 删除一行
+    handleDel (row) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)
+      this.dataSource.splice(pos, 1)
+    },
     // 添加产品分类
     addClassifyTag (pos, row) {
       this.classifyTagIndex = pos
       this.openTypeModal = true
     },
     handleTypeOk (mainArr) {
-      this.dataSource[this.selectType][this.classifyTagIndex].productTypeList = mainArr
+      const classifyArr = []
+      const newClassifyArr = []
+      mainArr.forEach(item => {
+        if (item.productTypeLevel == 1) {
+          if (!item.dataRef.children) {
+            const objType1 = {
+              productType1: item.snPaths
+            }
+            newClassifyArr.push(objType1)
+            const obj = JSON.parse(JSON.stringify(objType1))
+            obj.title = item.title
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 2) {
+          if (!item.dataRef.children) {
+            const typeArr1 = item.snPaths ? item.snPaths.split(',') : []
+            const objType2 = {
+              productType1: typeArr1[0],
+              productType2: typeArr1[1]
+            }
+            newClassifyArr.push(objType2)
+            const obj = JSON.parse(JSON.stringify(objType2))
+            obj.title = item.namePaths.replace(/,/g, '/')
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 3) {
+          const typeArr2 = item.snPaths ? item.snPaths.split(',') : []
+          const objType3 = {
+            productType1: typeArr2[0],
+            productType2: typeArr2[1],
+            productType3: typeArr2[2]
+          }
+          newClassifyArr.push(objType3)
+          const obj = JSON.parse(JSON.stringify(objType3))
+          obj.title = item.namePaths.replace(/,/g, '/')
+          classifyArr.push(obj)
+        }
+      })
+      this.dataSource[this.classifyTagIndex].productTypeList = newClassifyArr
+      this.dataSource[this.classifyTagIndex].productTypeArr = classifyArr
     },
     // 添加产品品牌
     addBrandTag (pos, row) {
@@ -236,18 +252,57 @@ export default {
       this.openBrandModal = true
     },
     handleBrandOk (conList) {
-      this.dataSource[this.selectType][this.brandTagIndex].productBrandList = conList
+      const newConList = conList.map(con => {
+        return {
+          brandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
     },
     // 添加产品
     addProductTag (pos, row) {
       this.productTagIndex = pos
       this.openProductsModal = true
     },
+    handleProductsOk (arr) {
+      const newArr = []
+      arr.forEach(item => {
+        const obj = {
+          productCode: item.code,
+          productSn: item.productSn
+        }
+        newArr.push(obj)
+      })
+      this.dataSource[this.productTagIndex].productThisList = newArr
+    },
     getResultVal () {
-      return this.dataSource
+      const resultObj = JSON.parse(JSON.stringify(this.dataSource))
+      resultObj.map(item => {
+        delete item.productTypeArr
+        delete item.productBrandArr
+        return item
+      })
+      return resultObj
     },
-    handleProductsOk (arr) {
-      this.dataSource[this.selectType][this.productTagIndex].productThisList = arr
+    // 关闭时清空表格数据
+    reSetTableData () {
+      this.dataSource = []
+    },
+    // 删除标签
+    delLabel (pos, row, type) {
+      if (type === 'typeList') {
+        const i = this.dataSource[pos].productTypeArr.findIndex(con => con.productType1 == row.productType1)
+        this.dataSource[pos].productTypeArr.splice(i, 1)
+        this.dataSource[pos].productTypeList.splice(i, 1)
+      } else if (type === 'brandList') {
+        const j = this.dataSource[pos].productTypeArr.findIndex(con => con.brandSn == row.brandSn)
+        this.dataSource[pos].productBrandArr.splice(j, 1)
+        this.dataSource[pos].productBrandList.splice(j, 1)
+      } else {
+        const k = this.dataSource[pos].productTypeArr.findIndex(con => con.productSn == row.productSn)
+        this.dataSource[pos].productThisList.splice(k, 1)
+      }
     }
   }
 }

+ 88 - 44
src/views/promotionRulesManagement/dealerPromotions/tableType2.vue

@@ -1,22 +1,22 @@
 <template>
   <div class="pages-wrap">
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       style="margin-top:10px;"
       ref="table"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
-      :data="loadData"
+      :data-source="dataSource"
       bordered>
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
         <div style="max-height:80px;width:100%;overflow-y:scroll;">
-          <a-row v-if="record.productTypeList && record.productTypeList.length>0">
+          <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="18">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeList" :key="i">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeArr" :key="i">
                 {{ con.title }}
               </a-tag>
             </a-col>
@@ -38,9 +38,9 @@
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
         <div style="max-height:106spx;overflow-y:scroll;">
-          <a-row v-if="record.productBrandList && record.productBrandList.length>0">
+          <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandList" :key="j">
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandArr" :key="j">
                 {{ item.brandName }}
               </a-tag>
             </a-col>
@@ -65,7 +65,7 @@
           <a-row v-if="record.productThisList && record.productThisList.length>0">
             <a-col :span="20">
               <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'productList')" v-for="(item,k) in record.productThisList" :key="k">
-                {{ item.code }}
+                {{ item.productCode }}
               </a-tag>
             </a-col>
             <a-col :span="4" style="text-align:right;">
@@ -93,14 +93,14 @@
           删除
         </a-button>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <chooseTypeModal :openModal="openTypeModal" :linkageStatus="false" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
     <!-- 选择产品 -->
     <chooseProductsModal
       type="dealership"
@@ -113,25 +113,19 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
-
-import { sparePartsReturnList } from '@/api/sparePartsReturn'
 import { getNewScopeSn } from '@/api/promotion'
 export default {
   name: 'TableType1',
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
   props: {
     itemSn: {
       type: [Number, String],
       default: ''
-    },
-    selectType: {
-      type: String,
-      default: ''
     }
   },
   data () {
@@ -143,33 +137,16 @@ export default {
         { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
       ],
-      queryParam: {},
       dataSource: [],
       openBrandModal: false,
       openTypeModal: false,
       openProductsModal: false,
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.spinning = true
-        return sparePartsReturnList(Object.assign(parameter, this.queryParam)).then(res => {
-          let data
-          if (res.status == 200) {
-            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
-            }
-            this.dataSource[this.selectType] = data.list
-          }
-          this.spinning = false
-          return data
-        })
-      },
       chooseBrand: [],
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
       classifyTagIndex: null, // 所选分类位置
-      productTagIndex: null// 所选产品位置
+      productTagIndex: null, // 所选产品位置
+      chooseProducts: []
     }
   },
   methods: {
@@ -181,11 +158,13 @@ export default {
         if (res.status == 200) {
           const newData = {
             productScopeSn: res.data,
+            productTypeArr: [],
             productTypeList: [],
+            productBrandArr: [],
             productBrandList: [],
             productThisList: []
           }
-          _this.dataSource[this.selectType].push(newData)
+          _this.dataSource.push(newData)
         } else {
           _this.spinning = false
         }
@@ -197,7 +176,48 @@ export default {
       this.openTypeModal = true
     },
     handleTypeOk (mainArr) {
-      this.dataSource[this.selectType][this.classifyTagIndex].productTypeList = mainArr
+      const classifyArr = []
+      const newClassifyArr = []
+      mainArr.forEach(item => {
+        if (item.productTypeLevel == 1) {
+          if (!item.dataRef.children) {
+            const objType1 = {
+              productType1: item.snPaths
+            }
+            newClassifyArr.push(objType1)
+            const obj = JSON.parse(JSON.stringify(objType1))
+            obj.title = item.title
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 2) {
+          if (!item.dataRef.children) {
+            const typeArr1 = item.snPaths ? item.snPaths.split(',') : []
+            const objType2 = {
+              productType1: typeArr1[0],
+              productType2: typeArr1[1]
+            }
+            newClassifyArr.push(objType2)
+            const obj = JSON.parse(JSON.stringify(objType2))
+            obj.title = item.namePaths.replace(/,/g, '/')
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 3) {
+          const typeArr2 = item.snPaths ? item.snPaths.split(',') : []
+          const objType3 = {
+            productType1: typeArr2[0],
+            productType2: typeArr2[1],
+            productType3: typeArr2[2]
+          }
+          newClassifyArr.push(objType3)
+          const obj = JSON.parse(JSON.stringify(objType3))
+          obj.title = item.namePaths.replace(/,/g, '/')
+          classifyArr.push(obj)
+        }
+      })
+      this.dataSource[this.classifyTagIndex].productTypeList = newClassifyArr
+      this.dataSource[this.classifyTagIndex].productTypeArr = classifyArr
     },
     // 添加产品品牌
     addBrandTag (pos, row) {
@@ -205,18 +225,42 @@ export default {
       this.openBrandModal = true
     },
     handleBrandOk (conList) {
-      this.dataSource[this.selectType][this.brandTagIndex].productBrandList = conList
+      const newConList = conList.map(con => {
+        return {
+          brandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
     },
     // 添加产品
     addProductTag (pos, row) {
       this.productTagIndex = pos
       this.openProductsModal = true
     },
+    handleProductsOk (arr) {
+      const newArr = []
+      arr.forEach(item => {
+        const obj = {
+          productCode: item.code,
+          productSn: item.productSn
+        }
+        newArr.push(obj)
+      })
+      this.dataSource[this.productTagIndex].productThisList = newArr
+    },
     getResultVal () {
-      return this.dataSource
+      const resultObj = JSON.parse(JSON.stringify(this.dataSource))
+      resultObj.map(item => {
+        delete item.productTypeArr
+        delete item.productBrandArr
+        return item
+      })
+      return resultObj
     },
-    handleProductsOk (arr) {
-      this.dataSource[this.selectType][this.productTagIndex].productThisList = arr
+    // 关闭时清空表格数据
+    reSetTableData () {
+      this.dataSource = []
     }
   }
 }

+ 132 - 75
src/views/promotionRulesManagement/dealerPromotions/tableType3.vue

@@ -1,23 +1,23 @@
 <template>
   <div class="pages-wrap">
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       style="margin-top:10px;width:100%;"
       ref="table"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
-      :data="loadData"
+      :data-source="dataSource"
       bordered>
       <!-- 产品分类 -->
-      <template slot="productType" slot-scope="text, record">
+      <template slot="productType" slot-scope="text, record,index">
         <div style="max-height:64px;overflow-y:scroll;">
-          <a-row v-if="record.productTypeList && record.productTypeList.length>0">
+          <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeList" :key="i">
-                {{ con.dataName }}
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeArr" :key="i">
+                {{ con.title }}
               </a-tag>
             </a-col>
             <a-col :span="4" style="text-align:right;">
@@ -36,12 +36,12 @@
         </div>
       </template>
       <!-- 品牌 -->
-      <template slot="productBrand" slot-scope="text, record">
+      <template slot="productBrand" slot-scope="text, record,index">
         <div style="max-height:64px;overflow-y:scroll;">
-          <a-row v-if="record.productBrandList && record.productBrandList.length>0">
+          <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
-              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandList" :key="j">
-                {{ item.dataName }}
+              <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandArr" :key="j">
+                {{ item.brandName }}
               </a-tag>
             </a-col>
             <a-col :span="4" style="text-align:right;">
@@ -126,26 +126,26 @@
           placeholder="请输入"/>%
       </template>
       <!-- 设置起订量 -->
-     <template slot="setNum" slot-scope="text, record">
-       <div>
-         <v-select
-           v-model="record.unitType"
-           size="small"
-           style="width:55%;"
-           ref="returnReason"
-           code="SCOPE_UNIT_TYPE"
-           placeholder="请选择"
-           allowClear></v-select>
-         <a-input-number
-           size="small"
-           style="margin-left:10px;width:30%;"
-           v-model="record.unitQty"
-           :min="0"
-           :step="1"
-           :precision="2"
-           placeholder="请输入"/>
-       </div>
-     </template>
+      <template slot="setNum" slot-scope="text, record">
+        <div>
+          <v-select
+            v-model="record.unitType"
+            size="small"
+            style="width:55%;"
+            ref="returnReason"
+            code="SCOPE_UNIT_TYPE"
+            placeholder="请选择"
+            allowClear></v-select>
+          <a-input-number
+            size="small"
+            style="margin-left:10px;width:30%;"
+            v-model="record.unitQty"
+            :min="0"
+            :step="1"
+            :precision="2"
+            placeholder="请输入"/>
+        </div>
+      </template>
       <span slot="action" slot-scope="text,record">
         <a-button
           size="small"
@@ -156,29 +156,27 @@
           删除
         </a-button>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <chooseTypeModal :openModal="openTypeModal" :linkageStatus="false" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
   </div>
 </template>
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
-import chooseProductsModal from '@/views/common/chooseProductsModal.vue'
-
-import { sparePartsReturnList } from '@/api/sparePartsReturn'
+import { getNewScopeSn } from '@/api/promotion'
 export default {
   name: 'TableType3',
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal },
   props: {
     itemSn: {
       type: [Number, String],
@@ -194,63 +192,122 @@ export default {
         { title: '品牌', width: '11%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
         { title: '产品', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '省价原价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '省价特价', scopedSlots: { customRender: 'provincePrice' }, width: '6%', align: 'right'},
-        { title: '省价折扣',scopedSlots: { customRender: 'provinceDiscount' },width: '6%', align: 'right'},
+        { title: '省价特价', scopedSlots: { customRender: 'provincePrice' }, width: '6%', align: 'right' },
+        { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '6%', align: 'right' },
         { title: '市价原价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '市价特价', scopedSlots: { customRender: 'cityPrice' },width: '6%', align: 'right' },
-        { title: '市价折扣',scopedSlots: { customRender: 'cityDiscount' },width: '6%', align: 'right' },
+        { title: '市价特价', scopedSlots: { customRender: 'cityPrice' }, width: '6%', align: 'right' },
+        { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '6%', align: 'right' },
         { title: '特约原价', dataIndex: 'specialPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
-        { title: '特约特价', scopedSlots: { customRender: 'specialPrice' },width: '6%', align: 'right'},
-        { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' },width: '6%', align: 'right'},
-        { title: '设置起订量', width: '14%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
+        { title: '特约特价', scopedSlots: { customRender: 'specialPrice' }, width: '6%', align: 'right' },
+        { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '6%', align: 'right' },
+        { title: '设置起订量', width: '12%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
-      queryParam: {},
       dataSource: [],
       openBrandModal: false,
       openTypeModal: false,
-      openProductsModal: false,
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.spinning = true
-        return sparePartsReturnList(Object.assign(parameter, this.queryParam)).then(res => {
-          let data
-          if (res.status == 200) {
-            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
-            }
-            this.dataSource = data.list
-          }
-          this.spinning = false
-          return data
-        })
-      }
+      chooseBrand: [],
+      chooseType: [],
+      brandTagIndex: null, // 所选品牌位置
+      classifyTagIndex: null // 所选分类位置
     }
   },
   methods: {
     // 新增一行
     handleAddRow () {
       const _this = this
-      const newData = {
-        productTypeList: [],
-        productBrandList: [],
-        productList: []
-      }
-      _this.dataSource.push(newData)
+      _this.spinning = false
+      getNewScopeSn({}).then(res => {
+        if (res.status == 200) {
+          const newData = {
+            productScopeSn: res.data,
+            productTypeArr: [],
+            productTypeList: [],
+            productBrandArr: [],
+            productBrandList: []
+          }
+          _this.dataSource.push(newData)
+        } else {
+          _this.spinning = false
+        }
+      })
     },
     // 添加产品分类
     addClassifyTag (pos, row) {
+      this.classifyTagIndex = pos
       this.openTypeModal = true
     },
+    handleTypeOk (mainArr) {
+      const classifyArr = []
+      const newClassifyArr = []
+      mainArr.forEach(item => {
+        if (item.productTypeLevel == 1) {
+          if (!item.dataRef.children) {
+            const objType1 = {
+              productType1: item.snPaths
+            }
+            newClassifyArr.push(objType1)
+            const obj = JSON.parse(JSON.stringify(objType1))
+            obj.title = item.title
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 2) {
+          if (!item.dataRef.children) {
+            const typeArr1 = item.snPaths ? item.snPaths.split(',') : []
+            const objType2 = {
+              productType1: typeArr1[0],
+              productType2: typeArr1[1]
+            }
+            newClassifyArr.push(objType2)
+            const obj = JSON.parse(JSON.stringify(objType2))
+            obj.title = item.namePaths.replace(/,/g, '/')
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 3) {
+          const typeArr2 = item.snPaths ? item.snPaths.split(',') : []
+          const objType3 = {
+            productType1: typeArr2[0],
+            productType2: typeArr2[1],
+            productType3: typeArr2[2]
+          }
+          newClassifyArr.push(objType3)
+          const obj = JSON.parse(JSON.stringify(objType3))
+          obj.title = item.namePaths.replace(/,/g, '/')
+          classifyArr.push(obj)
+        }
+      })
+      this.dataSource[this.classifyTagIndex].productTypeList = newClassifyArr
+      this.dataSource[this.classifyTagIndex].productTypeArr = classifyArr
+    },
     // 添加产品品牌
     addBrandTag (pos, row) {
+      this.brandTagIndex = pos
       this.openBrandModal = true
     },
-    // 添加产品
-    addProductTag () {
-      this.openProductsModal = true
+    handleBrandOk (conList) {
+      const newConList = conList.map(con => {
+        return {
+          brandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
+    },
+    getResultVal () {
+      debugger
+      const resultObj = JSON.parse(JSON.stringify(this.dataSource))
+      resultObj.map(item => {
+        delete item.productTypeArr
+        delete item.productBrandArr
+        return item
+      })
+      return resultObj
+    },
+    // 关闭时清空表格数据
+    reSetTableData () {
+      this.dataSource = []
     }
   }
 }