فهرست منبع

Merge branch 'develop_cuxiao' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into develop_cuxiao

lilei 1 سال پیش
والد
کامیت
7087e971f1

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

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

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

@@ -34,7 +34,7 @@
                 </a-col>
                 </a-col>
                 <a-col :md="6" :sm="24">
                 <a-col :md="6" :sm="24">
                   <a-form-model-item label="产品分类">
                   <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-form-model-item>
                 </a-col>
                 </a-col>
                 <a-col :md="6" :sm="24">
                 <a-col :md="6" :sm="24">
@@ -62,12 +62,17 @@
             size="small"
             size="small"
             :rowKey="(record) => record.productSn"
             :rowKey="(record) => record.productSn"
             rowKeyName="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"
             @rowSelection="rowSelectionFun"
             :columns="columns"
             :columns="columns"
             :data="loadData"
             :data="loadData"
             :defaultLoadData="false"
             :defaultLoadData="false"
             bordered>
             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>
           </s-table>
         </div>
         </div>
       </div>
       </div>
@@ -80,8 +85,7 @@ import { STable } from '@/components'
 import tablePagination from '@/views/common/tablePagination.vue'
 import tablePagination from '@/views/common/tablePagination.vue'
 import ProductBrand from '@/views/common/productBrand.js'
 import ProductBrand from '@/views/common/productBrand.js'
 import productTypeAll from '@/views/common/productTypeAll.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 {
 export default {
   name: 'ChooseProductsModal',
   name: 'ChooseProductsModal',
   components: { STable, tablePagination, ProductBrand, productTypeAll },
   components: { STable, tablePagination, ProductBrand, productTypeAll },
@@ -95,14 +99,6 @@ export default {
       default: () => {
       default: () => {
         return []
         return []
       }
       }
-    },
-    type: { //  类型,经销权设置dealership,  供应商添加产品supplier
-      type: String,
-      default: 'default'
-    },
-    dealerSn: {
-      type: String || Number,
-      default: ''
     }
     }
   },
   },
   data () {
   data () {
@@ -127,7 +123,12 @@ export default {
       columns: [
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '产品编码', dataIndex: 'code', 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 对象
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
       loadData: parameter => {
@@ -174,7 +175,9 @@ export default {
     //  重置
     //  重置
     resetSearchForm () {
     resetSearchForm () {
       this.resetData()
       this.resetData()
-      this.$refs.table.clearTable()
+      console.log('1111111111111111')
+      this.$refs.table.refresh()
+      // this.$refs.table.clearTable()
     },
     },
     // 保存
     // 保存
     handleSave () {
     handleSave () {
@@ -201,11 +204,9 @@ export default {
     isShow (newValue, oldValue) {
     isShow (newValue, oldValue) {
       if (!newValue) {
       if (!newValue) {
         this.$emit('close')
         this.$emit('close')
-        this.$refs.table.clearTable()
-        this.resetData()
+        this.resetSearchForm()
       } else {
       } else {
         const _this = this
         const _this = this
-        _this.$refs.table.refresh()
         // let selectedRows = []
         // let selectedRows = []
         // const selectedRowKeys = []
         // const selectedRowKeys = []
         // selectedRows = this.chooseData
         // selectedRows = this.chooseData

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

@@ -51,35 +51,46 @@
           :rowKey="(record) => record.id"
           :rowKey="(record) => record.id"
           :columns="columns"
           :columns="columns"
           :data="loadData"
           :data="loadData"
-          :scroll="{ y: 500 }"
           :defaultLoadData="false"
           :defaultLoadData="false"
           :showPagination="false"
           :showPagination="false"
           bordered>
           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>
           <!-- 操作 -->
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
           <template slot="action" slot-scope="text, record">
             <a-button
             <a-button
-              v-if="$route.params.type=='rule'"
+              v-if="$route.query.type=='rule'"
               size="small"
               size="small"
               type="link"
               type="link"
-              @click="handleDetail(record)"
+              @click="handleEdit(record)"
               class="button-info"
               class="button-info"
               id="promotionList-edit-btn">编辑</a-button>
               id="promotionList-edit-btn">编辑</a-button>
             <a-button
             <a-button
-              v-if="$route.params.type=='rule'"
+              v-if="$route.query.type=='rule'"
               size="small"
               size="small"
               type="link"
               type="link"
               @click="handleDel(record)"
               @click="handleDel(record)"
               class="button-error"
               class="button-error"
               id="promotionList-del-btn">删除</a-button>
               id="promotionList-del-btn">删除</a-button>
             <a-button
             <a-button
-              v-if="!$route.params.type"
+              v-if="!$route.query.type"
               size="small"
               size="small"
               type="link"
               type="link"
               @click="handleDetail(record)"
               @click="handleDetail(record)"
@@ -94,13 +105,13 @@
     <!-- 促销品费用归属品牌/促销品费用归属品类 -->
     <!-- 促销品费用归属品牌/促销品费用归属品类 -->
     <brandCategoryModal :openType="openType" :openModal="openModal" @close="openModal = false"></brandCategoryModal>
     <brandCategoryModal :openType="openType" :openModal="openModal" @close="openModal = false"></brandCategoryModal>
     <!-- 详情 -->
     <!-- 详情 -->
-    <detailModal :openModal="openDetailModal" @close="openDetailModal = false"></detailModal>
+    <detailModal :openModal="openDetailModal" :itemSn="detailSn" @close="closeDetailModal"></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>
   </div>
 </template>
 </template>
 
 
@@ -113,7 +124,7 @@ import detailModal from './detailModal'
 import sendProductsModal from './sendProductsModal'
 import sendProductsModal from './sendProductsModal'
 import sendAmountModal from './sendAmountModal'
 import sendAmountModal from './sendAmountModal'
 import specialOfferModal from './specialOfferModal'
 import specialOfferModal from './specialOfferModal'
-import { getRuleQueryList, dealerPromotionInfo } from '@/api/promotion'
+import { getRuleQueryList, dealerPromotionInfo, promotionRulesDel } from '@/api/promotion'
 export default {
 export default {
   name: 'SalesOrderWarehouseDetail',
   name: 'SalesOrderWarehouseDetail',
   mixins: [commonMixin],
   mixins: [commonMixin],
@@ -122,9 +133,21 @@ export default {
     return {
     return {
       disabled: false,
       disabled: false,
       spinning: 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 对象
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
       loadData: parameter => {
         this.disabled = true
         this.disabled = true
+        this.spinning = true
         const dataAjax = Object.assign(parameter, { sn: this.$route.query.sn })
         const dataAjax = Object.assign(parameter, { sn: this.$route.query.sn })
         return getRuleQueryList(dataAjax).then(res => {
         return getRuleQueryList(dataAjax).then(res => {
           let data
           let data
@@ -135,46 +158,44 @@ export default {
             }
             }
             this.disabled = false
             this.disabled = false
           }
           }
+          this.spinning = false
           return data
           return data
         })
         })
       },
       },
-      detailData: null, //  详情数据
-      countData: null, // 数量数据
-      fromRouter: null,
-      openModal: false,
-      isShowBisiceInfo: false,
-      openCustomerModal: false,
-      openType: undefined,
-      openDetailModal: false,
-      openSendProductsModal: false,
-      openSendAmountModal: false,
-      openSpecialOfferModal: false
+      detailSn: null
     }
     }
   },
   },
   computed: {
   computed: {
     columns () {
     columns () {
+      const _this = this
       const arr = [
       const arr = [
         { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
         { 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: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
+        { title: '促销类型', dataIndex: 'promotionRuleTypeDictValue', width: '13%', 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: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '订单经费上限(元)', dataIndex: 'upperLimitAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '20%', align: 'center' }
       ]
       ]
       return arr
       return arr
     }
     }
   },
   },
   methods: {
   methods: {
-    // 查看详情
-    handleDetail (con) {
+    // 打开详情弹窗
+    handleDetail (row) {
+      this.detailSn = row.promotionRuleSn
       this.openDetailModal = true
       this.openDetailModal = true
     },
     },
+    // 关闭详情弹窗
+    closeDetailModal () {
+      this.detailSn = null
+      this.openDetailModal = false
+    },
     //  返回
     //  返回
     handleBack () {
     handleBack () {
       this.$router.push({ name: 'dealerPromotionManagement' })
       this.$router.push({ name: 'dealerPromotionManagement' })
     },
     },
-    //  详情
+    //  基础信息详情
     getDetail () {
     getDetail () {
       dealerPromotionInfo({ sn: this.$route.query.sn }).then(res => {
       dealerPromotionInfo({ sn: this.$route.query.sn }).then(res => {
         if (res.status == 200) {
         if (res.status == 200) {
@@ -185,11 +206,6 @@ export default {
         }
         }
       })
       })
     },
     },
-    // 基础信息  详情弹窗
-    handleSeeDetail (name) {
-      this.openType = name
-      this.openModal = true
-    },
     // 买产品送产品
     // 买产品送产品
     handleProduct () {
     handleProduct () {
       this.openSendProductsModal = true
       this.openSendProductsModal = true
@@ -205,6 +221,33 @@ export default {
     // 查看客户
     // 查看客户
     handleSee () {
     handleSee () {
       this.openCustomerModal = true
       this.openCustomerModal = true
+      this.$nextTick(() => {
+        this.$refs.lookUpCustomers.pageInit({ dealerSnList: this.detailData.dealerSnList ? this.detailData.dealerSnList : undefined })
+      })
+    },
+    // 删除规则
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '确认要该规则吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          promotionRulesDel({ promotionSn: _this.$route.query.sn, promotionRuleSn: row.promotionRuleSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+              _this.spinning = false
+            } else {
+              _this.spinning = false
+            }
+          })
+        }
+      })
+    },
+    handleEdit () {
+
     }
     }
   },
   },
   mounted () {
   mounted () {

+ 182 - 140
src/views/promotionRulesManagement/dealerPromotions/detailModal.vue

@@ -16,65 +16,134 @@
         :rules="rules"
         :rules="rules"
         :label-col="formItemLayout.labelCol"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
         :wrapper-col="formItemLayout.wrapperCol" >
-        <a-form-model-item label="规则门槛" prop="supplierSn">是</a-form-model-item>
-        <a-form-model-item label="满赠规则" prop="supplierSn">
-          <div>购买满10000元门槛产品,可使用200  元配额,采购规则中的正价商品(配额算销售额)</div>
-          <div>同款产品购买满10个正价产品,送2个促销产品,限制正价产品款数40</div>
+        <a-form-model-item label="规则门槛" prop="gateFlag" v-if="form.gateFlag">
+          <div>{{ form.gateFlag=== '0'?'无':'有' }}</div>
+          <div v-if="gateFlag==='1'">购买满{{ form.gateAmount }}元门槛产品,可使用{{ form.quotaAmount }}元配额,采购规则中的正价商品(配额算销售额)</div>
         </a-form-model-item>
         </a-form-model-item>
-        <a-form-model-item label="数量叠加" prop="supplierSn">是</a-form-model-item>
-        <a-form-model-item prop="supplierSn" v-bind="formItemLayout">
+        <!-- 买产品送产品 -->
+        <a-form-model-item label="满赠规则" prop="regularSameFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_PROD'">
+          <span>{{ form.regularSameFlag==='1'?'同款':'不同款' }}产品购买满{{ form.regularQty }}个正价产品,送{{ form.promotionQty }}个促销产品</span>
+          <span v-if="form.restrictFlag&&form.restrictFlag==1">,限制正价产品款数{{ form.restrictCategory }}</span>
+        </a-form-model-item>
+        <a-form-model-item label="满赠规则" prop="regularSameFlag" v-if="form.promotionRuleType ==='BUY_PROD_GIVE_MONEY'">
+          {{ form.regularSameFlag==='1'?'同款':'不同款' }}产品购买满{{ form.regularAmount }}元正价产品,送{{ form.giveAmount }}元{{ perCentNum }}促销品采购额
+        </a-form-model-item>
+        <a-form-model-item label="数量叠加" prop="accrualFlag" v-if="form.accrualFlag">{{ form.accrualFlag==='1'?'是':'否' }}</a-form-model-item>
+        <a-form-model-item prop="minOrderFlag">
           <span slot="label">
           <span slot="label">
             <a-tooltip title="What do you want others to call you?">
             <a-tooltip title="What do you want others to call you?">
               <a-icon type="info-circle" />
               <a-icon type="info-circle" />
             </a-tooltip>
             </a-tooltip>
             订单起订金额
             订单起订金额
           </span>
           </span>
+          {{ form.minOrderFlag === '1'?'限制':'不限制' }}{{ form.minOrderAmount }}元
+        </a-form-model-item>
+        <a-form-model-item prop="upperLimitFlag">
+          <span slot="label">
+            <a-tooltip title="What do you want others to call you?">
+              <a-icon type="info-circle" />
+            </a-tooltip>
+            活动经费上限
+          </span>
+          {{ form.upperLimitFlag === '1'?'限制':'不限制' }}{{ form.upperLimitAmount }}元
         </a-form-model-item>
         </a-form-model-item>
-        <a-form-model-item label="活动经费上限" prop="supplierSn">限制 20000元</a-form-model-item>
-        <a-form-model-item label="促销品是否与正品一致" prop="supplierSn">否</a-form-model-item>
+        <a-form-model-item label="促销品是否与正品一致" v-if="form.regularPromotionSameFlag" prop="regularPromotionSameFlag">{{ form.regularPromotionSameFlag==='1'?'是':'否' }}</a-form-model-item>
+        <a-form-model-item label="采购额使用范围" v-if="form.scopeFlag" prop="scopeFlag">{{ form.scopeFlag==='1'?'全部产品':'部分产品' }}</a-form-model-item>
       </a-form-model>
       </a-form-model>
       <a-card size="small" :bordered="false" class="pages-wrap">
       <a-card size="small" :bordered="false" class="pages-wrap">
         <a-radio-group v-model="chooseVal" button-style="solid">
         <a-radio-group v-model="chooseVal" button-style="solid">
-          <a-radio-button value="a">
+          <a-radio-button value="a" v-show="form.gateFlag==='1'">
             门槛产品
             门槛产品
           </a-radio-button>
           </a-radio-button>
-          <a-radio-button value="b">
+          <a-radio-button value="b" v-show="form.promotionRuleType!='PROMO_PROD'">
             正价产品
             正价产品
           </a-radio-button>
           </a-radio-button>
-          <a-radio-button value="c">
+          <a-radio-button value="c" v-show="form.regularPromotionSameFlag==='0'||form.scopeFlag==='0'">
             促销产品
             促销产品
           </a-radio-button>
           </a-radio-button>
+          <a-radio-button value="d" v-show="form.promotionRuleType=='PROMO_PROD'">
+            特价产品
+          </a-radio-button>
         </a-radio-group>
         </a-radio-group>
         <!-- 列表 -->
         <!-- 列表 -->
-        <s-table
-          class="sTable"
-          style="margin-top:10px;max-height:280px;"
-          ref="table"
-          size="small"
-          :rowKey="(record) => record.id"
-          :columns="columns"
-          :data="loadData"
-          :scroll="{ y: 500 }"
-          :defaultLoadData="false"
-          bordered>
-          <!-- 产品分类 -->
-          <template slot="productType" slot-scope="text, record">
-            <a-tag>产品分类</a-tag>
-          </template>
-          <!-- 品牌 -->
-          <template slot="productBrand" slot-scope="text, record">
-            <a-tag>品牌</a-tag>
-          </template>
-          <!-- 产品 -->
-          <template slot="product" slot-scope="text, record">
-            <a-tag>产品</a-tag>
-          </template>
-          <!-- 设置起订量 -->
-          <template slot="setNum" slot-scope="text, record">
-            <span style="margin-right:10px;">按数量设置</span>
-            <span>1</span>
-          </template>
-        </s-table>
+        <div v-show="chooseVal!='d'">
+          <a-table
+            class="sTable"
+            style="margin-top:10px;max-height:280px;"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.productScopeSn"
+            :columns="columns"
+            :data-source="chooseVal==='a'?form.gateProductList:chooseVal==='b'?form.regularProductList:form.giftProductList"
+            :scroll="{ y: 500 }"
+            :pagination="false"
+            bordered
+          >
+            <!-- 产品分类 -->
+            <template slot="productType" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productTypeList && record.productTypeList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productTypeList" :key="item.id">{{ item.productTypeName1 }}{{ item.productTypeName2?'/'+item.productTypeName2 :'' }}{{ item.productTypeName3?'/'+item.productTypeName3:'' }}</a-tag>
+              </div>
+            </template>
+            <!-- 品牌 -->
+            <template slot="productBrand" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productBrandList && record.productBrandList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productBrandList" :key="item.id">{{ item.productBrandName }}</a-tag>
+              </div>
+            </template>
+            <!-- 产品 -->
+            <template slot="product" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productThisList && record.productThisList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productThisList" :key="item.id">{{ item.productCode }}</a-tag>
+              </div>
+            </template>
+            <!-- 设置起订量 -->
+            <template slot="setNum" slot-scope="text, record">
+              <span style="margin-right:10px;">{{ record.unitTypeDictValue }}</span>
+              <span>{{ record.unitQty }}</span>
+            </template>
+          </a-table>
+        </div>
+        <!-- 特价产品 -->
+        <div v-show="chooseVal=='d'">
+          <a-table
+            class="sTable"
+            style="margin-top:10px;max-height:280px;"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.productScopeSn"
+            :columns="specialColumns"
+            :data-source="form.specialProductList"
+            :scroll="{ y: 500 }"
+            :pagination="false"
+            bordered
+          >
+            <!-- 产品分类 -->
+            <template slot="productType" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productTypeList && record.productTypeList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productTypeList" :key="item.id">{{ item.productTypeName1 }}{{ item.productTypeName2?'/'+item.productTypeName2 :'' }}{{ item.productTypeName3?'/'+item.productTypeName3:'' }}</a-tag>
+              </div>
+            </template>
+            <!-- 品牌 -->
+            <template slot="productBrand" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productBrandList && record.productBrandList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productBrandList" :key="item.id">{{ item.productBrandName }}</a-tag>
+              </div>
+            </template>
+            <!-- 产品 -->
+            <template slot="product" slot-scope="text, record">
+              <div style="max-height:100px;overflow-y:scroll;" v-if="record.productThisList && record.productThisList.length>0">
+                <a-tag style="margin-bottom:5px;" v-for="item in record.productThisList" :key="item.id">{{ item.productCode }}</a-tag>
+              </div>
+              <span v-else>--</span>
+            </template>
+            <!-- 设置起订量 -->
+            <template slot="setNum" slot-scope="text, record">
+              <span style="margin-right:10px;">{{ record.unitTypeDictValue }}</span>
+              <span>{{ record.unitQty }}</span>
+            </template>
+          </a-table>
+        </div>
       </a-card>
       </a-card>
       <div class="btn-cont">
       <div class="btn-cont">
         <a-button id="dealerPromotions-basicInfo-modal-back" @click="isShow = false">关闭</a-button>
         <a-button id="dealerPromotions-basicInfo-modal-back" @click="isShow = false">关闭</a-button>
@@ -86,7 +155,7 @@
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
 import { STable } from '@/components'
 import { STable } from '@/components'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { getRuleDetail } from '@/api/promotion'
 export default {
 export default {
   name: 'DetailModal',
   name: 'DetailModal',
   mixins: [commonMixin],
   mixins: [commonMixin],
@@ -97,11 +166,12 @@ export default {
       default: false
       default: false
     },
     },
     itemSn: {
     itemSn: {
-      type: [Number, String],
+      type: String,
       default: ''
       default: ''
     }
     }
   },
   },
   data () {
   data () {
+    const _this = this
     return {
     return {
       isShow: this.openModal, //  是否打开弹框
       isShow: this.openModal, //  是否打开弹框
       spinning: false,
       spinning: false,
@@ -110,115 +180,97 @@ export default {
         wrapperCol: { span: 16 }
         wrapperCol: { span: 16 }
       },
       },
       form: {
       form: {
-        promotionName: '',
-        activeDate: undefined,
-        supplierSn: undefined, // 供应商
-        returnReason: '', // 退货原因
-        explainInfo: '', // 补充说明
-        warehouseSn: undefined,
-        attachmentList: ''
+        promotionRuleType: undefined,
+        gateFlag: undefined, // 门槛
+        gateAmount: undefined,
+        quotaAmount: undefined,
+        regularSameFlag: undefined, // 满赠规则  不同款商品
+        regularQty: undefined,
+        promotionQty: undefined,
+        regularAmount: undefined,
+        giveAmount: undefined,
+        restrictFlag: undefined, // 限制正价产品款数
+        restrictCategory: undefined,
+        accrualFlag: undefined, // 数量叠加
+        minOrderFlag: undefined, // 起订金额
+        minOrderAmount: undefined,
+        upperLimitFlag: undefined, // 活动经费上限
+        upperLimitAmount: undefined,
+        regularPromotionSameFlag: undefined,
+        productTypeArr: [],
+        productTypeList: [],
+        productBrandArr: [],
+        productBrandList: [],
+        productThisList: []
       },
       },
-      rules: {
-        supplierSn: [
-          { required: true, message: '请选择供应商名称', trigger: 'change' }
-        ]
-      },
-      chooseVal: 'a'
+      chooseVal: 'a',
+      specialColumns: [
+        { title: '产品分类', width: '11%', scopedSlots: { customRender: 'productType' }, align: 'center' },
+        { title: '品牌', width: '11%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
+        { title: '产品', scopedSlots: { customRender: 'product' }, width: '8%', align: 'center' },
+        { title: '省价原价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '省价特价', dataIndex: 'provinceDiscountPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '省价折扣', dataIndex: 'provinceDiscountRate', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? (text + '%') : '--') } },
+        { title: '市价原价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '市价特价', dataIndex: 'cityDiscountPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '市价折扣', dataIndex: 'cityDiscountRate', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? (text + '%') : '--') } },
+        { title: '特约原价', dataIndex: 'specialPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '特约特价', dataIndex: 'specialDiscountPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '特约折扣', dataIndex: 'specialDiscountRate', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? (text + '%') : '--') } },
+        { title: '设置起订量', width: '12%', scopedSlots: { customRender: 'setNum' }, align: 'center' }
+      ]
     }
     }
   },
   },
   computed: {
   computed: {
     columns () {
     columns () {
       const _this = this
       const _this = this
       const arr = [
       const arr = [
-        { title: '产品分类', width: '20%', scopedSlots: { customRender: 'productType' }, align: 'center' },
-        { title: '品牌', width: '40%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
-        { title: '产品', width: '40%', scopedSlots: { customRender: 'product' }, align: 'center' },
+        { title: '产品分类', width: '30%', scopedSlots: { customRender: 'productType' }, align: 'center' },
+        { title: '品牌', width: '35%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
+        { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '设置起订量', width: '20%', scopedSlots: { customRender: 'setNum' }, align: 'center' }
         { title: '设置起订量', width: '20%', scopedSlots: { customRender: 'setNum' }, align: 'center' }
       ]
       ]
       if (_this.chooseVal == 'c') {
       if (_this.chooseVal == 'c') {
         arr.pop()
         arr.pop()
       }
       }
       return arr
       return arr
+    },
+    perCentNum () {
+      return Math.floor(((this.form.giveAmount / this.form.regularAmount) * 100).toFixed(2)) + '%'
     }
     }
   },
   },
   methods: {
   methods: {
-    // 选择参与客户
-    handleDealerModal () {
-      this.openDealerModal = true
-      const _this = this
-      if (_this.chooseDealerList.length == 0) {
-        _this.form.promoBuyerList = []
+    // 重置
+    resetSearchForm () {
+      this.form = {
+        promotionRuleType: undefined,
+        gateFlag: undefined, // 门槛
+        gateAmount: undefined,
+        quotaAmount: undefined,
+        regularSameFlag: undefined, // 满赠规则  不同款商品
+        regularQty: undefined,
+        promotionQty: undefined,
+        regularAmount: undefined,
+        giveAmount: undefined,
+        restrictFlag: undefined, // 限制正价产品款数
+        restrictCategory: undefined,
+        accrualFlag: undefined, // 数量叠加
+        minOrderFlag: undefined, // 起订金额
+        minOrderAmount: undefined,
+        upperLimitFlag: undefined, // 活动经费上限
+        upperLimitAmount: undefined,
+        regularPromotionSameFlag: undefined
       }
       }
-      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
-      this.$refs.ruleForm.validate(valid => {
-        if (valid) {
-          const form = JSON.parse(JSON.stringify(_this.form))
-          form.attachmentList = _this.attachList
-          _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              setTimeout(() => {
-                _this.isShow = false
-                _this.$emit('ok', res.data)
-                _this.spinning = false
-              }, 1000)
-            } else {
-              _this.spinning = false
-            }
-          })
-        } else {
-          return false
-        }
-      })
-    },
-    // 获取编辑详情
+    // 获取列表详情
     getDetail () {
     getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
+      getRuleDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
         if (res.status == 200) {
           const resultObj = res.data
           const resultObj = res.data
-          this.attachList = resultObj.attachmentList
-          const obj = {
-            supplierSn: resultObj.supplierSn,
-            returnReason: resultObj.returnReason, // 退货原因
-            explainInfo: resultObj.explainInfo, // 补充说明
-            warehouseSn: resultObj.warehouseSn,
-            sparePartsReturnSn: this.itemSn
-          }
-          this.$nextTick(() => {
-            this.$refs.attachList.setFileList(this.attachList)
-          })
-          this.form = { ...this.form, ...obj }
-        } else {
-          this.detailsData = null
+          this.chooseVal = resultObj.gateFlag == '1' ? 'a' : 'b'
+          this.form = { ...this.form, ...resultObj }
         }
         }
       })
       })
-    },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
     }
     }
   },
   },
   watch: {
   watch: {
@@ -230,19 +282,9 @@ export default {
     isShow (newValue, oldValue) {
     isShow (newValue, oldValue) {
       if (!newValue) {
       if (!newValue) {
         this.$emit('close')
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
       } else {
-        if (this.itemSn) {
-          this.getDetail()
-        } else {
-          // 默认仓库
-          this.form.warehouseSn = this.isShowWarehouse ? undefined : this.defWarehouse && this.defWarehouse.warehouseSn
-        }
+        this.getDetail()
       }
       }
     }
     }
   }
   }

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

@@ -35,7 +35,7 @@
         </a-form-model-item>
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
           <div class="ruleDescList">
           <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 value="1">
                 同款
                 同款
               </a-select-option>
               </a-select-option>
@@ -49,12 +49,6 @@
             <a-input-number v-model="form.giveAmount" :min="0" :step="1" :precision="0" size="small"/>
             <a-input-number v-model="form.giveAmount" :min="0" :step="1" :precision="0" size="small"/>
             元%促销品采购额
             元%促销品采购额
           </div>
           </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>
         <a-form-model-item label="金额叠加" prop="accrualFlag">
         <a-form-model-item label="金额叠加" prop="accrualFlag">
           <a-radio-group v-model="form.accrualFlag" button-style="solid" size="small">
           <a-radio-group v-model="form.accrualFlag" button-style="solid" size="small">
@@ -74,7 +68,7 @@
             </a-tooltip>
             </a-tooltip>
             订单起订金额
             订单起订金额
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -99,7 +93,7 @@
             </a-tooltip>
             </a-tooltip>
             活动经费上限
             活动经费上限
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -117,8 +111,8 @@
             :precision="2"
             :precision="2"
             placeholder="请输入金额"/>
             placeholder="请输入金额"/>
         </a-form-model-item>
         </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 value="0">
               部分产品
               部分产品
             </a-radio-button>
             </a-radio-button>
@@ -137,7 +131,7 @@
             <a-radio-button value="b">
             <a-radio-button value="b">
               正价产品
               正价产品
             </a-radio-button>
             </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-button>
           </a-radio-group>
           </a-radio-group>
@@ -147,9 +141,9 @@
             class="button-info"
             class="button-info"
             id="promotionList-edit-btn">+导入产品</a-button>
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
         </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>
       </a-card>
       <div class="btn-cont">
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
         <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 { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType1 from './tableType1.vue'
 import tableType2 from './tableType2.vue'
 import tableType2 from './tableType2.vue'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
 export default {
 export default {
   name: 'PromotionListBasicInfoModal',
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
   mixins: [commonMixin],
@@ -174,7 +168,7 @@ export default {
       type: Boolean,
       type: Boolean,
       default: false
       default: false
     },
     },
-    itemSn: {
+    promotionSn: {
       type: [Number, String],
       type: [Number, String],
       default: ''
       default: ''
     }
     }
@@ -193,16 +187,15 @@ export default {
         gateAmount: '',
         gateAmount: '',
         quotaAmount: '',
         quotaAmount: '',
         regularSameFlag: '0', // 满赠规则  不同款商品
         regularSameFlag: '0', // 满赠规则  不同款商品
-        regularQty: '',
-        promotionQty: '',
-        restrictFlag: undefined, // 限制正价产品款数
+        regularAmount: '',
+        giveAmount: '',
         restrictCategory: '',
         restrictCategory: '',
         accrualFlag: '1', // 数量叠加
         accrualFlag: '1', // 数量叠加
         minOrderFlag: '1', // 起订金额
         minOrderFlag: '1', // 起订金额
         minOrderAmount: '',
         minOrderAmount: '',
         upperLimitFlag: '1', // 活动经费上限
         upperLimitFlag: '1', // 活动经费上限
         upperLimitAmount: '',
         upperLimitAmount: '',
-        regularPromotionSameFlag: undefined
+        scopeFlag: undefined
       },
       },
       rules: {
       rules: {
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
         gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
@@ -210,7 +203,7 @@ export default {
         accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
         accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         upperLimitFlag: [{ 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'
       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 () {
     handleSave () {
       const _this = this
       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 => {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           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
           _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
+          promotionSave(form).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
               setTimeout(() => {
               setTimeout(() => {
                 _this.isShow = false
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
                 _this.spinning = false
               }, 1000)
               }, 1000)
             } else {
             } 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 () {
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -306,10 +324,6 @@ export default {
           this.detailsData = null
           this.detailsData = null
         }
         }
       })
       })
-    },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
     }
     }
   },
   },
   watch: {
   watch: {
@@ -321,12 +335,7 @@ export default {
     isShow (newValue, oldValue) {
     isShow (newValue, oldValue) {
       if (!newValue) {
       if (!newValue) {
         this.$emit('close')
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
       } else {
         if (this.itemSn) {
         if (this.itemSn) {
           this.getDetail()
           this.getDetail()

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

@@ -35,7 +35,7 @@
         </a-form-model-item>
         </a-form-model-item>
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
         <a-form-model-item label="满赠规则" prop="regularSameFlag">
           <div class="ruleDescList">
           <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 value="1">
                 同款
                 同款
               </a-select-option>
               </a-select-option>
@@ -74,7 +74,7 @@
             </a-tooltip>
             </a-tooltip>
             订单起订金额
             订单起订金额
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -99,7 +99,7 @@
             </a-tooltip>
             </a-tooltip>
             活动经费上限
             活动经费上限
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -147,9 +147,9 @@
             class="button-info"
             class="button-info"
             id="promotionList-edit-btn">+导入产品</a-button>
             id="promotionList-edit-btn">+导入产品</a-button>
         </div>
         </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>
       </a-card>
       <div class="btn-cont">
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
@@ -229,21 +229,52 @@ export default {
     //  保存
     //  保存
     handleSave () {
     handleSave () {
       const _this = this
       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 => {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           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
           _this.spinning = true
           promotionSave(form).then(res => {
           promotionSave(form).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
               setTimeout(() => {
               setTimeout(() => {
                 _this.isShow = false
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
                 _this.spinning = false
               }, 1000)
               }, 1000)
             } else {
             } 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 () {
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -287,12 +347,7 @@ export default {
     isShow (newValue, oldValue) {
     isShow (newValue, oldValue) {
       if (!newValue) {
       if (!newValue) {
         this.$emit('close')
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
       } else {
         if (this.itemSn) {
         if (this.itemSn) {
           this.getDetail()
           this.getDetail()

+ 129 - 59
src/views/promotionRulesManagement/dealerPromotions/specialOfferModal.vue

@@ -7,7 +7,7 @@
     title="规则设置"
     title="规则设置"
     v-model="isShow"
     v-model="isShow"
     @cancel="isShow=false"
     @cancel="isShow=false"
-    width="70%">
+    width="80%">
     <a-spin :spinning="spinning" tip="Loading...">
     <a-spin :spinning="spinning" tip="Loading...">
       <a-form-model
       <a-form-model
         id="promotionList-basicInfo-form"
         id="promotionList-basicInfo-form"
@@ -17,7 +17,7 @@
         :label-col="formItemLayout.labelCol"
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
         :wrapper-col="formItemLayout.wrapperCol" >
         <a-form-model-item label="规则门槛" prop="gateFlag">
         <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 value="1">
             </a-radio-button>
             </a-radio-button>
@@ -25,7 +25,7 @@
             </a-radio-button>
             </a-radio-button>
           </a-radio-group>
           </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"/>
             <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
             元门槛产品,可使用
             元门槛产品,可使用
@@ -40,7 +40,7 @@
             </a-tooltip>
             </a-tooltip>
             订单起订金额
             订单起订金额
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -65,7 +65,7 @@
             </a-tooltip>
             </a-tooltip>
             活动经费上限
             活动经费上限
           </span>
           </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 value="0">
               不限
               不限
             </a-select-option>
             </a-select-option>
@@ -90,8 +90,8 @@
             <a-radio-button value="a" v-show="form.gateFlag==='1'">
             <a-radio-button value="a" v-show="form.gateFlag==='1'">
               门槛产品
               门槛产品
             </a-radio-button>
             </a-radio-button>
-            <a-radio-button value="c">
-              促销产品
+            <a-radio-button value="d">
+              特价产品
             </a-radio-button>
             </a-radio-button>
           </a-radio-group>
           </a-radio-group>
           <div>
           <div>
@@ -101,21 +101,30 @@
               class="button-info"
               class="button-info"
               id="promotionList-edit-btn">+导入产品</a-button>
               id="promotionList-edit-btn">+导入产品</a-button>
             <a-button
             <a-button
+              v-show="chooseVal==='d'"
               style="margin-left:10px;"
               style="margin-left:10px;"
               size="small"
               size="small"
               type="link"
               type="link"
               class="button-error"
               class="button-error"
-              id="promotionList-edit-btn">+新增产品</a-button>
+              id="promotionList-edit-btn"
+              @click="openProductsModal = true">+新增产品</a-button>
           </div>
           </div>
         </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>
       </a-card>
       <div class="btn-cont">
       <div class="btn-cont">
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
         <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
         <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
         <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
       </div>
       </div>
     </a-spin>
     </a-spin>
+    <!-- 选择产品 -->
+    <chooseProductsModal
+      type="dealership"
+      :openModal="openProductsModal"
+      :chooseData="chooseProducts"
+      @close="openProductsModal=false"
+      @ok="handleProductsOk" />
   </a-modal>
   </a-modal>
 </template>
 </template>
 
 
@@ -124,17 +133,18 @@ import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import { VSelect } from '@/components'
 import tableType1 from './tableType1.vue'
 import tableType1 from './tableType1.vue'
 import tableType3 from './tableType3.vue'
 import tableType3 from './tableType3.vue'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+import { promotionSave, sparePartsReturnInfo, getNewScopeSn } from '@/api/promotion'
+import chooseProductsModal from './chooseProductsModal.vue'
 export default {
 export default {
   name: 'PromotionListBasicInfoModal',
   name: 'PromotionListBasicInfoModal',
   mixins: [commonMixin],
   mixins: [commonMixin],
-  components: { VSelect, tableType1, tableType3 },
+  components: { VSelect, tableType1, tableType3, chooseProductsModal },
   props: {
   props: {
     openModal: { //  弹框显示状态
     openModal: { //  弹框显示状态
       type: Boolean,
       type: Boolean,
       default: false
       default: false
     },
     },
-    itemSn: {
+    promotionSn: {
       type: [Number, String],
       type: [Number, String],
       default: ''
       default: ''
     }
     }
@@ -162,58 +172,55 @@ export default {
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }]
         upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }]
       },
       },
-      chooseVal: 'a'
+      chooseVal: 'a',
+      openProductsModal: false,
+      chooseProducts: []
     }
     }
   },
   },
   methods: {
   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 () {
     handleSave () {
       const _this = this
       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 => {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
           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
           _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
+          promotionSave(form).then(res => {
             if (res.status == 200) {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$message.success(res.message)
               setTimeout(() => {
               setTimeout(() => {
                 _this.isShow = false
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
                 _this.spinning = false
               }, 1000)
               }, 1000)
             } else {
             } else {
@@ -225,6 +232,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 () {
     getDetail () {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
       sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
@@ -247,9 +274,57 @@ export default {
         }
         }
       })
       })
     },
     },
-    // 不可选日期
-    disabledDate (date, dateStrings) {
-      return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
+    // +新增产品
+    handleProductsOk (con) {
+      debugger
+      const chooseProductsList = []
+      const _this = this
+      con.forEach(item => {
+        getNewScopeSn({}).then(res => {
+          if (res.status == 200) {
+            const newData = {
+              productScopeSn: res.data,
+              dataSourceOrigin: 'sel',
+              productTypeArr: [],
+              productTypeList: [],
+              productBrandArr: [{ brandSn: item.productBrandSn, brandName: item.productBrandName }],
+              productBrandList: [{ brandSn: item.productBrandSn }],
+              productThisList: [{
+                productSn: item.productSn,
+                productCode: item.code
+              }],
+              provincePrice: item.provincePrice,
+              cityPrice: item.cityPrice,
+              specialPrice: item.specialPrice
+            }
+            const obj = {}
+            if (item.productTypeSn1) {
+              obj.productType1 = item.productTypeSn1
+            }
+            if (item.productTypeSn2) {
+              obj.productType2 = item.productTypeSn2
+            }
+            if (item.productTypeSn3) {
+              obj.productType3 = item.productTypeSn3
+            }
+            const newObj = { ...obj, ...{} }
+            if (Object.keys(obj).length == 1) {
+              newObj.title = item.productTypeName1
+              newObj.id = item.productTypeSn1
+            } else if (Object.keys(obj).length == 2) {
+              newObj.title = item.productTypeName1 + '/' + item.productTypeName2
+              newObj.id = item.productTypeSn2
+            } else {
+              newObj.title = item.productTypeName1 + '/' + item.productTypeName2 + '/' + item.productTypeName3
+              newObj.id = item.productTypeSn3
+            }
+            newData.productTypeList[0] = obj
+            newData.productTypeArr[0] = newObj
+            chooseProductsList.push(newData)
+            _this.$refs.specialProduct.setSourceData(chooseProductsList)
+          }
+        })
+      })
     }
     }
   },
   },
   watch: {
   watch: {
@@ -261,17 +336,12 @@ export default {
     isShow (newValue, oldValue) {
     isShow (newValue, oldValue) {
       if (!newValue) {
       if (!newValue) {
         this.$emit('close')
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
-        this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
-          this.$refs.ruleForm.resetFields()
-        })
+        this.resetSearchForm()
       } else {
       } else {
         if (this.itemSn) {
         if (this.itemSn) {
           this.getDetail()
           this.getDetail()
         } else {
         } else {
-          this.chooseVal = this.form.gateFlag == '0' ? 'c' : 'a'
+          this.chooseVal = this.form.gateFlag == '0' ? 'd' : 'a'
         }
         }
       }
       }
     }
     }

+ 120 - 54
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -1,25 +1,31 @@
 <template>
 <template>
   <div class="pages-wrap">
   <div class="pages-wrap">
     <!-- 列表 -->
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       class="sTable"
       style="margin-top:10px;"
       style="margin-top:10px;"
       ref="table"
       ref="table"
       size="small"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
       :columns="columns"
-      :data="loadData"
-      :defaultLoadData="false"
+      :data-source="dataSource"
       bordered>
       bordered>
       <!-- 产品分类 -->
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
       <template slot="productType" slot-scope="text, record,index">
         <div style="max-height:80px;width:100%;overflow-y:scroll;">
         <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-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">
-                {{ con.title }}
-              </a-tag>
+              <div v-for="con in record.productTypeArr" :key="con.id">
+                <a-tooltip v-if="con.title&&con.title.length > 6" :title="con.title">
+                  <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')">
+                    {{ `${con.title.slice(0, 6)}...` }}
+                  </a-tag>
+                </a-tooltip>
+                <a-tag v-else style="margin-bottom:10px;" closable @close.prevent="delLabel(record.productScopeSn,con,'typeList')">
+                  {{ con.title }}
+                </a-tag>
+              </div>
             </a-col>
             </a-col>
             <a-col :span="4" style="text-align:right;">
             <a-col :span="4" style="text-align:right;">
               <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
               <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
@@ -39,9 +45,9 @@
       <!-- 品牌 -->
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
       <template slot="productBrand" slot-scope="text, record,index">
         <div style="max-height:106spx;overflow-y:scroll;">
         <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-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.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
                 {{ item.brandName }}
                 {{ item.brandName }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
@@ -65,8 +71,8 @@
         <div style="max-height:64px;overflow-y:scroll;">
         <div style="max-height:64px;overflow-y:scroll;">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
             <a-col :span="20">
             <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(record.productScopeSn,item,'productList')" v-for="item in record.productThisList" :key="item.productSn">
+                {{ item.productCode }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
             <a-col :span="4" style="text-align:right;">
             <a-col :span="4" style="text-align:right;">
@@ -115,14 +121,14 @@
           删除
           删除
         </a-button>
         </a-button>
       </span>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     </div>
     <!-- 选择产品品牌 -->
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <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
     <chooseProductsModal
       type="dealership"
       type="dealership"
@@ -135,25 +141,19 @@
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
-
-import { sparePartsReturnList } from '@/api/sparePartsReturn'
 import { getNewScopeSn } from '@/api/promotion'
 import { getNewScopeSn } from '@/api/promotion'
 export default {
 export default {
   name: 'TableType1',
   name: 'TableType1',
   mixins: [commonMixin],
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
   props: {
   props: {
     itemSn: {
     itemSn: {
       type: [Number, String],
       type: [Number, String],
       default: ''
       default: ''
-    },
-    selectType: {
-      type: String,
-      default: ''
     }
     }
   },
   },
   data () {
   data () {
@@ -166,35 +166,10 @@ export default {
         { title: '设置起订量', width: '25%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
         { title: '设置起订量', width: '25%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
       ],
-      queryParam: {},
       dataSource: [],
       dataSource: [],
       openBrandModal: false,
       openBrandModal: false,
       openTypeModal: false,
       openTypeModal: false,
       openProductsModal: 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: [],
       chooseBrand: [],
       chooseType: [],
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
       brandTagIndex: null, // 所选品牌位置
@@ -212,23 +187,74 @@ export default {
         if (res.status == 200) {
         if (res.status == 200) {
           const newData = {
           const newData = {
             productScopeSn: res.data,
             productScopeSn: res.data,
+            productTypeArr: [],
             productTypeList: [],
             productTypeList: [],
+            productBrandArr: [],
             productBrandList: [],
             productBrandList: [],
             productThisList: []
             productThisList: []
           }
           }
-          _this.dataSource[_this.selectType].push(newData)
+          _this.dataSource.push(newData)
         } else {
         } else {
           _this.spinning = false
           _this.spinning = false
         }
         }
       })
       })
     },
     },
+    // 删除一行
+    handleDel (row) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)
+      this.dataSource.splice(pos, 1)
+    },
     // 添加产品分类
     // 添加产品分类
     addClassifyTag (pos, row) {
     addClassifyTag (pos, row) {
       this.classifyTagIndex = pos
       this.classifyTagIndex = pos
       this.openTypeModal = true
       this.openTypeModal = true
     },
     },
     handleTypeOk (mainArr) {
     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 = {
+              productTypeSn1: item.snPaths
+            }
+            newClassifyArr.push(objType1)
+            const obj = JSON.parse(JSON.stringify(objType1))
+            obj.title = item.title
+            obj.id = item.snPaths
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 2) {
+          if (!item.dataRef.children) {
+            const typeArr1 = item.snPaths ? item.snPaths.split(',') : []
+            const objType2 = {
+              productTypeSn1: typeArr1[0],
+              productTypeSn2: typeArr1[1]
+            }
+            newClassifyArr.push(objType2)
+            const obj = JSON.parse(JSON.stringify(objType2))
+            obj.title = item.namePaths.replace(/,/g, '/')
+            obj.id = typeArr1[1]
+            classifyArr.push(obj)
+          }
+        }
+        if (item.productTypeLevel == 3) {
+          const typeArr2 = item.snPaths ? item.snPaths.split(',') : []
+          const objType3 = {
+            productTypeSn1: typeArr2[0],
+            productTypeSn2: typeArr2[1],
+            productTypeSn3: typeArr2[2]
+          }
+          newClassifyArr.push(objType3)
+          const obj = JSON.parse(JSON.stringify(objType3))
+          obj.title = item.namePaths.replace(/,/g, '/')
+          obj.id = typeArr2[2]
+          classifyArr.push(obj)
+        }
+      })
+      this.dataSource[this.classifyTagIndex].productTypeList = newClassifyArr
+      this.dataSource[this.classifyTagIndex].productTypeArr = classifyArr
     },
     },
     // 添加产品品牌
     // 添加产品品牌
     addBrandTag (pos, row) {
     addBrandTag (pos, row) {
@@ -236,18 +262,58 @@ export default {
       this.openBrandModal = true
       this.openBrandModal = true
     },
     },
     handleBrandOk (conList) {
     handleBrandOk (conList) {
-      this.dataSource[this.selectType][this.brandTagIndex].productBrandList = conList
+      const newConList = conList.map(con => {
+        return {
+          productBrandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
     },
     },
     // 添加产品
     // 添加产品
     addProductTag (pos, row) {
     addProductTag (pos, row) {
       this.productTagIndex = pos
       this.productTagIndex = pos
       this.openProductsModal = true
       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 () {
     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 (sn, row, type) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == sn)
+      if (type === 'typeList') {
+        const i = this.dataSource[pos].productTypeArr.findIndex(con => con.id == row.id)
+        this.dataSource[pos].productTypeArr.splice(i, 1)
+        this.dataSource[pos].productTypeList.splice(i, 1)
+      } else if (type === 'brandList') {
+        const j = this.dataSource[pos].productBrandArr.findIndex(con => con.brandSn == row.productBrandSn)
+        this.dataSource[pos].productBrandArr.splice(j, 1)
+        this.dataSource[pos].productBrandList.splice(j, 1)
+      } else {
+        const k = this.dataSource[pos].productThisList.findIndex(con => con.productSn == row.productSn)
+        this.dataSource[pos].productThisList.splice(k, 1)
+      }
     }
     }
   }
   }
 }
 }

+ 110 - 45
src/views/promotionRulesManagement/dealerPromotions/tableType2.vue

@@ -1,22 +1,22 @@
 <template>
 <template>
   <div class="pages-wrap">
   <div class="pages-wrap">
     <!-- 列表 -->
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       class="sTable"
       style="margin-top:10px;"
       style="margin-top:10px;"
       ref="table"
       ref="table"
       size="small"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
       :columns="columns"
-      :data="loadData"
+      :data-source="dataSource"
       bordered>
       bordered>
       <!-- 产品分类 -->
       <!-- 产品分类 -->
       <template slot="productType" slot-scope="text, record,index">
       <template slot="productType" slot-scope="text, record,index">
         <div style="max-height:80px;width:100%;overflow-y:scroll;">
         <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-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.productScopeSn,con,'typeList')" v-for="con in record.productTypeArr" :key="con.id">
                 {{ con.title }}
                 {{ con.title }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
@@ -38,9 +38,9 @@
       <!-- 品牌 -->
       <!-- 品牌 -->
       <template slot="productBrand" slot-scope="text, record,index">
       <template slot="productBrand" slot-scope="text, record,index">
         <div style="max-height:106spx;overflow-y:scroll;">
         <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-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.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
                 {{ item.brandName }}
                 {{ item.brandName }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
@@ -64,8 +64,8 @@
         <div style="max-height:64px;overflow-y:scroll;">
         <div style="max-height:64px;overflow-y:scroll;">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
           <a-row v-if="record.productThisList && record.productThisList.length>0">
             <a-col :span="20">
             <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(record.productScopeSn,item,'productList')" v-for="item in record.productThisList" :key="item.productSn">
+                {{ item.productCode }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
             <a-col :span="4" style="text-align:right;">
             <a-col :span="4" style="text-align:right;">
@@ -93,14 +93,14 @@
           删除
           删除
         </a-button>
         </a-button>
       </span>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     </div>
     <!-- 选择产品品牌 -->
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <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
     <chooseProductsModal
       type="dealership"
       type="dealership"
@@ -113,25 +113,19 @@
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
 import chooseProductsModal from './chooseProductsModal.vue'
-
-import { sparePartsReturnList } from '@/api/sparePartsReturn'
 import { getNewScopeSn } from '@/api/promotion'
 import { getNewScopeSn } from '@/api/promotion'
 export default {
 export default {
   name: 'TableType1',
   name: 'TableType1',
   mixins: [commonMixin],
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
   props: {
   props: {
     itemSn: {
     itemSn: {
       type: [Number, String],
       type: [Number, String],
       default: ''
       default: ''
-    },
-    selectType: {
-      type: String,
-      default: ''
     }
     }
   },
   },
   data () {
   data () {
@@ -143,33 +137,16 @@ export default {
         { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '产品', width: '35%', scopedSlots: { customRender: 'product' }, align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
       ],
       ],
-      queryParam: {},
       dataSource: [],
       dataSource: [],
       openBrandModal: false,
       openBrandModal: false,
       openTypeModal: false,
       openTypeModal: false,
       openProductsModal: 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: [],
       chooseBrand: [],
       chooseType: [],
       chooseType: [],
       brandTagIndex: null, // 所选品牌位置
       brandTagIndex: null, // 所选品牌位置
       classifyTagIndex: null, // 所选分类位置
       classifyTagIndex: null, // 所选分类位置
-      productTagIndex: null// 所选产品位置
+      productTagIndex: null, // 所选产品位置
+      chooseProducts: []
     }
     }
   },
   },
   methods: {
   methods: {
@@ -181,23 +158,71 @@ export default {
         if (res.status == 200) {
         if (res.status == 200) {
           const newData = {
           const newData = {
             productScopeSn: res.data,
             productScopeSn: res.data,
+            productTypeArr: [],
             productTypeList: [],
             productTypeList: [],
+            productBrandArr: [],
             productBrandList: [],
             productBrandList: [],
             productThisList: []
             productThisList: []
           }
           }
-          _this.dataSource[this.selectType].push(newData)
+          _this.dataSource.push(newData)
         } else {
         } else {
           _this.spinning = false
           _this.spinning = false
         }
         }
       })
       })
     },
     },
+    // 删除一行
+    handleDel (row) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == row.productScopeSn)
+      this.dataSource.splice(pos, 1)
+    },
     // 添加产品分类
     // 添加产品分类
     addClassifyTag (pos, row) {
     addClassifyTag (pos, row) {
       this.classifyTagIndex = pos
       this.classifyTagIndex = pos
       this.openTypeModal = true
       this.openTypeModal = true
     },
     },
     handleTypeOk (mainArr) {
     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 = {
+              productTypeSn1: 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 = {
+              productTypeSn1: typeArr1[0],
+              productTypeSn2: 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 = {
+            productTypeSn1: typeArr2[0],
+            productTypeSn2: typeArr2[1],
+            productTypeSn3: 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) {
     addBrandTag (pos, row) {
@@ -205,18 +230,58 @@ export default {
       this.openBrandModal = true
       this.openBrandModal = true
     },
     },
     handleBrandOk (conList) {
     handleBrandOk (conList) {
-      this.dataSource[this.selectType][this.brandTagIndex].productBrandList = conList
+      const newConList = conList.map(con => {
+        return {
+          productBrandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
     },
     },
     // 添加产品
     // 添加产品
     addProductTag (pos, row) {
     addProductTag (pos, row) {
       this.productTagIndex = pos
       this.productTagIndex = pos
       this.openProductsModal = true
       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 () {
     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 (sn, row, type) {
+      const pos = this.dataSource.findIndex(con => con.productScopeSn == sn)
+      if (type === 'typeList') {
+        const i = this.dataSource[pos].productTypeArr.findIndex(con => con.id == row.id)
+        this.dataSource[pos].productTypeArr.splice(i, 1)
+        this.dataSource[pos].productTypeList.splice(i, 1)
+      } else if (type === 'brandList') {
+        const j = this.dataSource[pos].productBrandArr.findIndex(con => con.brandSn == row.productBrandSn)
+        this.dataSource[pos].productBrandArr.splice(j, 1)
+        this.dataSource[pos].productBrandList.splice(j, 1)
+      } else {
+        const k = this.dataSource[pos].productThisList.findIndex(con => con.productSn == row.productSn)
+        this.dataSource[pos].productThisList.splice(k, 1)
+      }
     }
     }
   }
   }
 }
 }

+ 206 - 106
src/views/promotionRulesManagement/dealerPromotions/tableType3.vue

@@ -1,23 +1,23 @@
 <template>
 <template>
   <div class="pages-wrap">
   <div class="pages-wrap">
     <!-- 列表 -->
     <!-- 列表 -->
-    <s-table
+    <a-table
       class="sTable"
       class="sTable"
       style="margin-top:10px;width:100%;"
       style="margin-top:10px;width:100%;"
       ref="table"
       ref="table"
       size="small"
       size="small"
-      :showPagination="false"
-      :rowKey="(record) => record.id"
+      :pagination="false"
+      :rowKey="(record) => record.productScopeSn"
       :columns="columns"
       :columns="columns"
-      :data="loadData"
+      :data-source="dataSource"
       bordered>
       bordered>
       <!-- 产品分类 -->
       <!-- 产品分类 -->
-      <template slot="productType" slot-scope="text, record">
-        <div style="max-height:64px;overflow-y:scroll;">
-          <a-row v-if="record.productTypeList && record.productTypeList.length>0">
+      <template slot="productType" slot-scope="text, record,index">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
+          <a-row v-if="record.productTypeArr && record.productTypeArr.length>0">
             <a-col :span="20">
             <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.productScopeSn,con,'typeList')" v-for="con in record.productTypeArr" :key="con.id">
+                {{ con.title }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
             <a-col :span="4" style="text-align:right;">
             <a-col :span="4" style="text-align:right;">
@@ -34,14 +34,15 @@
             </a-col>
             </a-col>
           </a-row>
           </a-row>
         </div>
         </div>
+        <span v-else v-for="con in record.productTypeArr" :key="con.id">{{ con.title }}</span>
       </template>
       </template>
       <!-- 品牌 -->
       <!-- 品牌 -->
-      <template slot="productBrand" slot-scope="text, record">
-        <div style="max-height:64px;overflow-y:scroll;">
-          <a-row v-if="record.productBrandList && record.productBrandList.length>0">
+      <template slot="productBrand" slot-scope="text, record,index">
+        <div style="max-height:64px;overflow-y:scroll;" v-if="!record.dataSourceOrigin">
+          <a-row v-if="record.productBrandArr && record.productBrandArr.length>0">
             <a-col :span="20">
             <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.productScopeSn,item,'brandList')" v-for="item in record.productBrandArr" :key="item.productBrandSn">
+                {{ item.brandName }}
               </a-tag>
               </a-tag>
             </a-col>
             </a-col>
             <a-col :span="4" style="text-align:right;">
             <a-col :span="4" style="text-align:right;">
@@ -58,6 +59,12 @@
             </a-col>
             </a-col>
           </a-row>
           </a-row>
         </div>
         </div>
+        <span v-else v-for="item in record.productBrandArr" :key="item.brandSn">{{ item.brandName }}</span>
+      </template>
+      <!-- 产品 -->
+      <template slot="product" slot-scope="text, record">
+        <span v-if="record.dataSourceOrigin" v-for="item in record.productThisList" :key="item.productSn">{{ item.productCode }}</span>
+        <span v-else>--</span>
       </template>
       </template>
       <!-- 省价特价 -->
       <!-- 省价特价 -->
       <template slot="provincePrice" slot-scope="text, record">
       <template slot="provincePrice" slot-scope="text, record">
@@ -68,18 +75,26 @@
           :min="0"
           :min="0"
           :step="1"
           :step="1"
           :precision="2"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.provincePrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'province')"/>
+        <span v-else>--</span>
       </template>
       </template>
       <!-- 省价折扣 -->
       <!-- 省价折扣 -->
       <template slot="provinceDiscount" slot-scope="text, record">
       <template slot="provinceDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.provinceDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:80%;"
+            v-model="record.provinceDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"
+          />%
+        </div>
+        <span v-else>{{ record.provinceDiscountRate?record.provinceDiscountRate:'--' }}</span>
       </template>
       </template>
       <!-- 市价特价 -->
       <!-- 市价特价 -->
       <template slot="cityPrice" slot-scope="text, record">
       <template slot="cityPrice" slot-scope="text, record">
@@ -90,18 +105,25 @@
           :min="0"
           :min="0"
           :step="1"
           :step="1"
           :precision="2"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.cityPrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'city')"/>
+        <span v-else>--</span>
       </template>
       </template>
       <!-- 市价折扣 -->
       <!-- 市价折扣 -->
       <template slot="cityDiscount" slot-scope="text, record">
       <template slot="cityDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.cityDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:80%;"
+            v-model="record.cityDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"/>%
+        </div>
+        <span v-else>{{ record.cityDiscountRate?record.cityDiscountRate:'--' }}</span>
       </template>
       </template>
       <!-- 特约特价 -->
       <!-- 特约特价 -->
       <template slot="specialPrice" slot-scope="text, record">
       <template slot="specialPrice" slot-scope="text, record">
@@ -112,40 +134,47 @@
           :min="0"
           :min="0"
           :step="1"
           :step="1"
           :precision="2"
           :precision="2"
-          placeholder="请输入"/>
+          placeholder="请输入"
+          v-if="record.dataSourceOrigin"
+          :max="record.specialPrice"
+          @blur="e=>calculatePrice(e.target.value,record.productScopeSn,'special')"/>
+        <span v-else>--</span>
       </template>
       </template>
       <!-- 特约折扣 -->
       <!-- 特约折扣 -->
       <template slot="specialDiscount" slot-scope="text, record">
       <template slot="specialDiscount" slot-scope="text, record">
-        <a-input-number
-          size="small"
-          style="width:80%;"
-          v-model="record.specialDiscountRate"
-          :min="0"
-          :step="1"
-          :precision="0"
-          placeholder="请输入"/>%
+        <div v-if="!record.dataSourceOrigin">
+          <a-input-number
+            size="small"
+            style="width:80%;"
+            v-model="record.specialDiscountRate"
+            :min="0"
+            :step="1"
+            :max="100"
+            placeholder="请输入"/>%
+        </div>
+        <span v-else>{{ record.specialDiscountRate ? record.specialDiscountRate:'--' }}</span>
       </template>
       </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="0"
+            placeholder="请输入"/>
+        </div>
+      </template>
       <span slot="action" slot-scope="text,record">
       <span slot="action" slot-scope="text,record">
         <a-button
         <a-button
           size="small"
           size="small"
@@ -156,29 +185,27 @@
           删除
           删除
         </a-button>
         </a-button>
       </span>
       </span>
-    </s-table>
+    </a-table>
     <div class="btn-cont">
     <div class="btn-cont">
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
       <a-button id="tableType1-add" type="primary" class="button-gray" @click="handleAddRow">+新增一行</a-button>
     </div>
     </div>
     <!-- 选择产品品牌 -->
     <!-- 选择产品品牌 -->
     <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <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>
   </div>
 </template>
 </template>
 
 
 <script>
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, STable } from '@/components'
+import { VSelect } from '@/components'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.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 {
 export default {
   name: 'TableType3',
   name: 'TableType3',
   mixins: [commonMixin],
   mixins: [commonMixin],
-  components: { VSelect, STable, ChooseBrandModal, ChooseTypeModal, chooseProductsModal },
+  components: { VSelect, ChooseBrandModal, ChooseTypeModal },
   props: {
   props: {
     itemSn: {
     itemSn: {
       type: [Number, String],
       type: [Number, String],
@@ -192,65 +219,138 @@ export default {
       columns: [
       columns: [
         { title: '产品分类', width: '11%', scopedSlots: { customRender: 'productType' }, align: 'center' },
         { title: '产品分类', width: '11%', scopedSlots: { customRender: 'productType' }, align: 'center' },
         { title: '品牌', width: '11%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
         { title: '品牌', width: '11%', scopedSlots: { customRender: 'productBrand' }, align: 'center' },
-        { title: '产品', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品', scopedSlots: { customRender: 'product' }, width: '8%', align: 'center' },
         { title: '省价原价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(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: '市价原价', 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: 'provincePrice' }, width: '6%', align: 'center' },
+        { title: '省价折扣', scopedSlots: { customRender: 'provinceDiscount' }, width: '6%', align: 'center' },
+        { title: '市价原价', dataIndex: 'cityPrice', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '市价特价', scopedSlots: { customRender: 'cityPrice' }, width: '6%', align: 'center' },
+        { title: '市价折扣', scopedSlots: { customRender: 'cityDiscount' }, width: '6%', align: 'center' },
         { title: '特约原价', dataIndex: 'specialPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
         { 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: 'center' },
+        { title: '特约折扣', scopedSlots: { customRender: 'specialDiscount' }, width: '6%', align: 'center' },
+        { title: '设置起订量', width: '12%', scopedSlots: { customRender: 'setNum' }, align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ],
       ],
-      queryParam: {},
       dataSource: [],
       dataSource: [],
       openBrandModal: false,
       openBrandModal: false,
       openTypeModal: 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, // 所选分类位置
+      dataSourceOrigin: null // 数据来源  sle  选择产品  null 新增一行品类
     }
     }
   },
   },
   methods: {
   methods: {
+    // 计算百分比
+    calculatePrice (val, sn, typePrice) {
+      const _this = this
+      const pos = _this.dataSource.findIndex(con => con.productScopeSn == sn)
+      const oldPrice = typePrice + 'Price'
+      const str = Math.floor(((val / _this.dataSource[pos][oldPrice]) * 100).toFixed(2)) + '%'
+      const name = typePrice + 'DiscountRate'
+      _this.dataSource[pos][name] = str
+      _this.$forceUpdate()
+    },
+    // 新增产品 数据
+    setSourceData (list) {
+      this.dataSource = list
+    },
     // 新增一行
     // 新增一行
     handleAddRow () {
     handleAddRow () {
       const _this = this
       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) {
     addClassifyTag (pos, row) {
+      this.classifyTagIndex = pos
       this.openTypeModal = true
       this.openTypeModal = true
     },
     },
+    handleTypeOk (mainArr) {
+      const classifyArr = []
+      const newClassifyArr = []
+      mainArr.forEach(item => {
+        if (item.productTypeLevel == 1) {
+          if (!item.dataRef.children) {
+            const objType1 = {
+              productTypeSn1: 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 = {
+              productTypeSn1: typeArr1[0],
+              productTypeSn2: 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 = {
+            productTypeSn1: typeArr2[0],
+            productTypeSn2: typeArr2[1],
+            productTypeSn3: 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) {
     addBrandTag (pos, row) {
+      this.brandTagIndex = pos
       this.openBrandModal = true
       this.openBrandModal = true
     },
     },
-    // 添加产品
-    addProductTag () {
-      this.openProductsModal = true
+    handleBrandOk (conList) {
+      const newConList = conList.map(con => {
+        return {
+          productBrandSn: con.brandSn
+        }
+      })
+      this.dataSource[this.brandTagIndex].productBrandArr = conList
+      this.dataSource[this.brandTagIndex].productBrandList = newConList
+    },
+    getResultVal () {
+      const resultObj = JSON.parse(JSON.stringify(this.dataSource))
+      resultObj.map(item => {
+        delete item.productTypeArr
+        delete item.productBrandArr
+        return item
+      })
+      return resultObj
+    },
+    // 关闭时清空表格数据
+    reSetTableData () {
+      this.dataSource = []
     }
     }
   }
   }
 }
 }